1 |
- {"ast":null,"code":"import { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock.js\";\n/**\n * Block used to smooth step a value\n */\nexport class GeometrySmoothStepBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometrySmoothStepBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"edge0\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerInput(\"edge1\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometrySmoothStepBlock\";\n }\n /**\n * Gets the value operand input component\n */\n get value() {\n return this._inputs[0];\n }\n /**\n * Gets the first edge operand input component\n */\n get edge0() {\n return this._inputs[1];\n }\n /**\n * Gets the second edge operand input component\n */\n get edge1() {\n return this._inputs[2];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock() {\n if (!this.value.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n const func = (value, edge0, edge1) => {\n const x = Math.max(0, Math.min((value - edge0) / (edge1 - edge0), 1));\n // Smoothstep formula: 3x^2 - 2x^3\n return x * x * (3 - 2 * x);\n };\n this.output._storedFunction = state => {\n const source = this.value.getConnectedValue(state);\n const edge0 = this.edge0.getConnectedValue(state);\n const edge1 = this.edge1.getConnectedValue(state);\n switch (this.value.type) {\n case NodeGeometryBlockConnectionPointTypes.Int:\n case NodeGeometryBlockConnectionPointTypes.Float:\n {\n return func(source, edge0, edge1);\n }\n case NodeGeometryBlockConnectionPointTypes.Vector2:\n {\n return new Vector2(func(source.x, edge0, edge1), func(source.y, edge0, edge1));\n }\n case NodeGeometryBlockConnectionPointTypes.Vector3:\n {\n return new Vector3(func(source.x, edge0, edge1), func(source.y, edge0, edge1), func(source.z, edge0, edge1));\n }\n case NodeGeometryBlockConnectionPointTypes.Vector4:\n {\n return new Vector4(func(source.x, edge0, edge1), func(source.y, edge0, edge1), func(source.z, edge0, edge1), func(source.w, edge0, edge1));\n }\n }\n return 0;\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometrySmoothStepBlock\", GeometrySmoothStepBlock);","map":{"version":3,"names":["Vector2","Vector3","Vector4","RegisterClass","NodeGeometryBlockConnectionPointTypes","NodeGeometryBlock","GeometrySmoothStepBlock","constructor","name","registerInput","AutoDetect","Float","registerOutput","BasedOnInput","_outputs","_typeConnectionSource","_inputs","excludedConnectionPointTypes","push","Matrix","Geometry","Texture","getClassName","value","edge0","edge1","output","_buildBlock","isConnected","_storedFunction","_storedValue","func","x","Math","max","min","state","source","getConnectedValue","type","Int","y","z","w"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/geometrySmoothStepBlock.js"],"sourcesContent":["import { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock.js\";\n/**\n * Block used to smooth step a value\n */\nexport class GeometrySmoothStepBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometrySmoothStepBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"edge0\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerInput(\"edge1\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometrySmoothStepBlock\";\n }\n /**\n * Gets the value operand input component\n */\n get value() {\n return this._inputs[0];\n }\n /**\n * Gets the first edge operand input component\n */\n get edge0() {\n return this._inputs[1];\n }\n /**\n * Gets the second edge operand input component\n */\n get edge1() {\n return this._inputs[2];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock() {\n if (!this.value.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n const func = (value, edge0, edge1) => {\n const x = Math.max(0, Math.min((value - edge0) / (edge1 - edge0), 1));\n // Smoothstep formula: 3x^2 - 2x^3\n return x * x * (3 - 2 * x);\n };\n this.output._storedFunction = (state) => {\n const source = this.value.getConnectedValue(state);\n const edge0 = this.edge0.getConnectedValue(state);\n const edge1 = this.edge1.getConnectedValue(state);\n switch (this.value.type) {\n case NodeGeometryBlockConnectionPointTypes.Int:\n case NodeGeometryBlockConnectionPointTypes.Float: {\n return func(source, edge0, edge1);\n }\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\n return new Vector2(func(source.x, edge0, edge1), func(source.y, edge0, edge1));\n }\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\n return new Vector3(func(source.x, edge0, edge1), func(source.y, edge0, edge1), func(source.z, edge0, edge1));\n }\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\n return new Vector4(func(source.x, edge0, edge1), func(source.y, edge0, edge1), func(source.z, edge0, edge1), func(source.w, edge0, edge1));\n }\n }\n return 0;\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometrySmoothStepBlock\", GeometrySmoothStepBlock);\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,OAAO,QAAQ,+BAA+B;AACzE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,qCAAqC,QAAQ,8CAA8C;AACpG,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,SAASD,iBAAiB,CAAC;EAC3D;AACJ;AACA;AACA;EACIE,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,CAAC;IACX,IAAI,CAACC,aAAa,CAAC,OAAO,EAAEL,qCAAqC,CAACM,UAAU,CAAC;IAC7E,IAAI,CAACD,aAAa,CAAC,OAAO,EAAEL,qCAAqC,CAACO,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjF,IAAI,CAACF,aAAa,CAAC,OAAO,EAAEL,qCAAqC,CAACO,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjF,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAER,qCAAqC,CAACS,YAAY,CAAC;IACjF,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC,CAACC,qBAAqB,GAAG,IAAI,CAACC,OAAO,CAAC,CAAC,CAAC;IACxD,IAAI,CAACA,OAAO,CAAC,CAAC,CAAC,CAACC,4BAA4B,CAACC,IAAI,CAACd,qCAAqC,CAACe,MAAM,CAAC;IAC/F,IAAI,CAACH,OAAO,CAAC,CAAC,CAAC,CAACC,4BAA4B,CAACC,IAAI,CAACd,qCAAqC,CAACgB,QAAQ,CAAC;IACjG,IAAI,CAACJ,O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