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 posterize a value\n * @see https://en.wikipedia.org/wiki/Posterization\n */\nexport class GeometryPosterizeBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryPosterizeBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"steps\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\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[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\n this._inputs[1].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryPosterizeBlock\";\n }\n /**\n * Gets the value input component\n */\n get value() {\n return this._inputs[0];\n }\n /**\n * Gets the steps input component\n */\n get steps() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock() {\n if (!this.value.isConnected || !this.steps.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n this.output._storedFunction = state => {\n const source = this.value.getConnectedValue(state);\n const steps = this.steps.getConnectedValue(state);\n let stepVector = steps;\n if (this.steps.type === NodeGeometryBlockConnectionPointTypes.Float) {\n switch (this.value.type) {\n case NodeGeometryBlockConnectionPointTypes.Vector2:\n stepVector = new Vector2(steps, steps);\n break;\n case NodeGeometryBlockConnectionPointTypes.Vector3:\n stepVector = new Vector3(steps, steps, steps);\n break;\n case NodeGeometryBlockConnectionPointTypes.Vector4:\n stepVector = new Vector4(steps, steps, steps, steps);\n break;\n }\n }\n switch (this.value.type) {\n case NodeGeometryBlockConnectionPointTypes.Vector2:\n return new Vector2(source.x / (1.0 / stepVector.x) * (1.0 / stepVector.x), source.y / (1.0 / stepVector.y) * (1.0 / stepVector.y));\n case NodeGeometryBlockConnectionPointTypes.Vector3:\n return new Vector3(source.x / (1.0 / stepVector.x) * (1.0 / stepVector.x), source.y / (1.0 / stepVector.y) * (1.0 / stepVector.y), source.z / (1.0 / stepVector.z) * (1.0 / stepVector.z));\n case NodeGeometryBlockConnectionPointTypes.Vector4:\n return new Vector4(source.x / (1.0 / stepVector.x) * (1.0 / stepVector.x), source.y / (1.0 / stepVector.y) * (1.0 / stepVector.y), source.z / (1.0 / stepVector.z) * (1.0 / stepVector.z), source.w / (1.0 / stepVector.w) * (1.0 / stepVector.w));\n default:\n return Math.floor(source / (1.0 / steps) * (1.0 / steps));\n }\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometryPosterizeBlock\", GeometryPosterizeBlock);","map":{"version":3,"names":["Vector2","Vector3","Vector4","RegisterClass","NodeGeometryBlockConnectionPointTypes","NodeGeometryBlock","GeometryPosterizeBlock","constructor","name","registerInput","AutoDetect","registerOutput","BasedOnInput","_outputs","_typeConnectionSource","_inputs","_linkConnectionTypes","excludedConnectionPointTypes","push","Matrix","acceptedConnectionPointTypes","Float","getClassName","value","steps","output","_buildBlock","isConnected","_storedFunction","_storedValue","state","source","getConnectedValue","stepVector","type","x","y","z","w","Math","floor"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/geometryPosterizeBlock.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 posterize a value\n * @see https://en.wikipedia.org/wiki/Posterization\n */\nexport class GeometryPosterizeBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryPosterizeBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"steps\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\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[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\n this._inputs[1].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryPosterizeBlock\";\n }\n /**\n * Gets the value input component\n */\n get value() {\n return this._inputs[0];\n }\n /**\n * Gets the steps input component\n */\n get steps() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock() {\n if (!this.value.isConnected || !this.steps.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n this.output._storedFunction = (state) => {\n const source = this.value.getConnectedValue(state);\n const steps = this.steps.getConnectedValue(state);\n let stepVector = steps;\n if (this.steps.type === NodeGeometryBlockConnectionPointTypes.Float) {\n switch (this.value.type) {\n case NodeGeometryBlockConnectionPointTypes.Vector2:\n stepVector = new Vector2(steps, steps);\n break;\n case NodeGeometryBlockConnectionPointTypes.Vector3:\n stepVector = new Vector3(steps, steps, steps);\n break;\n case NodeGeometryBlockConnectionPointTypes.Vector4:\n stepVector = new Vector4(steps, steps, steps, steps);\n break;\n }\n }\n switch (this.value.type) {\n case NodeGeometryBlockConnectionPointTypes.Vector2:\n return new Vector2((source.x / (1.0 / stepVector.x)) * (1.0 / stepVector.x), (source.y / (1.0 / stepVector.y)) * (1.0 / stepVector.y));\n case NodeGeometryBlockConnectionPointTypes.Vector3:\n return new Vector3((source.x / (1.0 / stepVector.x)) * (1.0 / stepVector.x), (source.y / (1.0 / stepVector.y)) * (1.0 / stepVector.y), (source.z / (1.0 / stepVector.z)) * (1.0 / stepVector.z));\n case NodeGeometryBlockConnectionPointTypes.Vector4:\n return new Vector4((source.x / (1.0 / stepVector.x)) * (1.0 / stepVector.x), (source.y / (1.0 / stepVector.y)) * (1.0 / stepVector.y), (source.z / (1.0 / stepVector.z)) * (1.0 / stepVector.z), (source.w / (1.0 / stepVector.w)) * (1.0 / stepVector.w));\n default:\n return Math.floor((source / (1.0 / steps)) * (1.0 / steps));\n }\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometryPosterizeBlock\", GeometryPosterizeBlock);\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;AACA,OAAO,MAAMC,sBAAsB,SAASD,iBAAiB,CAAC;EAC1D;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,CAACM,UAAU,CAAC;IAC7E,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEP,qCAAqC,CAACQ,YAAY,CAAC;IACjF,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC,CAACC,q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