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 normalize lerp between 2 values\n */\nexport class GeometryNLerpBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryNLerpBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"gradient\", NodeGeometryBlockConnectionPointTypes.Float, true, 0, 0, 1);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._linkConnectionTypes(0, 1);\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 \"GeometryNLerpBlock\";\n }\n /**\n * Gets the left operand input component\n */\n get left() {\n return this._inputs[0];\n }\n /**\n * Gets the right operand input component\n */\n get right() {\n return this._inputs[1];\n }\n /**\n * Gets the gradient operand input component\n */\n get gradient() {\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.left.isConnected || !this.right.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n const func = (gradient, left, right) => {\n return (1 - gradient) * left + gradient * right;\n };\n this.output._storedFunction = state => {\n const left = this.left.getConnectedValue(state);\n const right = this.right.getConnectedValue(state);\n const gradient = this.gradient.getConnectedValue(state);\n switch (this.left.type) {\n case NodeGeometryBlockConnectionPointTypes.Int:\n case NodeGeometryBlockConnectionPointTypes.Float:\n {\n return func(gradient, left, right); // NLerp is really lerp in that case\n }\n case NodeGeometryBlockConnectionPointTypes.Vector2:\n {\n const result = new Vector2(func(gradient, left.x, right.x), func(gradient, left.y, right.y));\n result.normalize();\n return result;\n }\n case NodeGeometryBlockConnectionPointTypes.Vector3:\n {\n const result = new Vector3(func(gradient, left.x, right.x), func(gradient, left.y, right.y), func(gradient, left.z, right.z));\n result.normalize();\n return result;\n }\n case NodeGeometryBlockConnectionPointTypes.Vector4:\n {\n const result = new Vector4(func(gradient, left.x, right.x), func(gradient, left.y, right.y), func(gradient, left.z, right.z), func(gradient, left.w, right.w));\n result.normalize();\n return result;\n }\n }\n return 0;\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometryNLerpBlock\", GeometryNLerpBlock);","map":{"version":3,"names":["Vector2","Vector3","Vector4","RegisterClass","NodeGeometryBlockConnectionPointTypes","NodeGeometryBlock","GeometryNLerpBlock","constructor","name","registerInput","AutoDetect","Float","registerOutput","BasedOnInput","_outputs","_typeConnectionSource","_inputs","_linkConnectionTypes","excludedConnectionPointTypes","push","Matrix","Geometry","Texture","getClassName","left","right","gradient","output","_buildBlock","isConnected","_storedFunction","_storedValue","func","state","getConnectedValue","type","Int","result","x","y","normalize","z","w"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/geometryNLerpBlock.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 normalize lerp between 2 values\n */\nexport class GeometryNLerpBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryNLerpBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"gradient\", NodeGeometryBlockConnectionPointTypes.Float, true, 0, 0, 1);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._linkConnectionTypes(0, 1);\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 \"GeometryNLerpBlock\";\n }\n /**\n * Gets the left operand input component\n */\n get left() {\n return this._inputs[0];\n }\n /**\n * Gets the right operand input component\n */\n get right() {\n return this._inputs[1];\n }\n /**\n * Gets the gradient operand input component\n */\n get gradient() {\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.left.isConnected || !this.right.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n const func = (gradient, left, right) => {\n return (1 - gradient) * left + gradient * right;\n };\n this.output._storedFunction = (state) => {\n const left = this.left.getConnectedValue(state);\n const right = this.right.getConnectedValue(state);\n const gradient = this.gradient.getConnectedValue(state);\n switch (this.left.type) {\n case NodeGeometryBlockConnectionPointTypes.Int:\n case NodeGeometryBlockConnectionPointTypes.Float: {\n return func(gradient, left, right); // NLerp is really lerp in that case\n }\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\n const result = new Vector2(func(gradient, left.x, right.x), func(gradient, left.y, right.y));\n result.normalize();\n return result;\n }\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\n const result = new Vector3(func(gradient, left.x, right.x), func(gradient, left.y, right.y), func(gradient, left.z, right.z));\n result.normalize();\n return result;\n }\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\n const result = new Vector4(func(gradient, left.x, right.x), func(gradient, left.y, right.y), func(gradient, left.z, right.z), func(gradient, left.w, right.w));\n result.normalize();\n return result;\n }\n }\n return 0;\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometryNLerpBlock\", GeometryNLerpBlock);\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,kBAAkB,SAASD,iBAAiB,CAAC;EACtD;AACJ;AACA;AACA;EACIE,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,CAAC;IACX,IAAI,CAACC,aAAa,CAAC,MAAM,EAAEL,qCAAqC,CAACM,UAAU,CAAC;IAC5E,IAAI,CAACD,aAAa,CAAC,OAAO,EAAEL,qCAAqC,CAACM,UAAU,CAAC;IAC7E,IAAI,CAACD,aAAa,CAAC,UAAU,EAAEL,qCAAqC,CAACO,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1F,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,CAACC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/B,IAAI,CAACD,OAAO,CAAC,CAAC,CAAC,CAACE,4BAA4B,CAACC,IAAI,CAACf,qCAAqC,CAACgB,MAAM,CAAC;IAC/F,IAAI,CAACJ,OAAO,CAAC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