{"ast":null,"code":"import { __decorate } from \"../../../../tslib.es6.js\";\nimport { Vector4 } from \"../../../../Maths/math.vector.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock.js\";\nimport { editableInPropertyPage } from \"../../../../Decorators/nodeDecorator.js\";\n/**\n * Block used to fetch a color from texture data\n */\nexport class GeometryTextureFetchBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryTextureFetchBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n /**\n * Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1\n */\n this.clampCoordinates = true;\n this.registerInput(\"texture\", NodeGeometryBlockConnectionPointTypes.Texture);\n this.registerInput(\"coordinates\", NodeGeometryBlockConnectionPointTypes.Vector2);\n this.registerOutput(\"rgba\", NodeGeometryBlockConnectionPointTypes.Vector4);\n this.registerOutput(\"rgb\", NodeGeometryBlockConnectionPointTypes.Vector3);\n this.registerOutput(\"r\", NodeGeometryBlockConnectionPointTypes.Float);\n this.registerOutput(\"g\", NodeGeometryBlockConnectionPointTypes.Float);\n this.registerOutput(\"b\", NodeGeometryBlockConnectionPointTypes.Float);\n this.registerOutput(\"a\", NodeGeometryBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryTextureFetchBlock\";\n }\n /**\n * Gets the texture component\n */\n get texture() {\n return this.inputs[0];\n }\n /**\n * Gets the coordinates component\n */\n get coordinates() {\n return this.inputs[1];\n }\n /**\n * Gets the rgba component\n */\n get rgba() {\n return this._outputs[0];\n }\n /**\n * Gets the rgb component\n */\n get rgb() {\n return this._outputs[1];\n }\n /**\n * Gets the r component\n */\n get r() {\n return this._outputs[2];\n }\n /**\n * Gets the g component\n */\n get g() {\n return this._outputs[3];\n }\n /**\n * Gets the b component\n */\n get b() {\n return this._outputs[4];\n }\n /**\n * Gets the a component\n */\n get a() {\n return this._outputs[5];\n }\n _repeatClamp(num) {\n if (num >= 0) {\n return num % 1;\n } else {\n return 1 - Math.abs(num) % 1;\n }\n }\n _buildBlock() {\n const func = state => {\n const textureData = this.texture.getConnectedValue(state);\n if (!textureData || !textureData.data) {\n return null;\n }\n const uv = this.coordinates.getConnectedValue(state);\n if (!uv) {\n return null;\n }\n const u = this.clampCoordinates ? Math.max(0, Math.min(uv.x, 1.0)) : this._repeatClamp(uv.x);\n const v = this.clampCoordinates ? Math.max(0, Math.min(uv.y, 1.0)) : this._repeatClamp(uv.y);\n const x = Math.floor(u * (textureData.width - 1));\n const y = Math.floor(v * (textureData.height - 1));\n const index = x + textureData.width * y;\n return Vector4.FromArray(textureData.data, index * 4);\n };\n this.rgba._storedFunction = state => {\n return func(state);\n };\n this.rgb._storedFunction = state => {\n const color = func(state);\n return color ? color.toVector3() : null;\n };\n this.r._storedFunction = state => {\n const color = func(state);\n return color ? color.x : null;\n };\n this.g._storedFunction = state => {\n const color = func(state);\n return color ? color.y : null;\n };\n this.b._storedFunction = state => {\n const color = func(state);\n return color ? color.z : null;\n };\n this.a._storedFunction = state => {\n const color = func(state);\n return color ? color.w : null;\n };\n }\n _dumpPropertiesCode() {\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.clampCoordinates = ${this.clampCoordinates};\\n`;\n return codeString;\n }\n /**\n * Serializes this block in a JSON representation\n * @returns the serialized block object\n */\n serialize() {\n const serializationObject = super.serialize();\n serializationObject.clampCoordinates = this.clampCoordinates;\n return serializationObject;\n }\n _deserialize(serializationObject) {\n super._deserialize(serializationObject);\n this.clampCoordinates = serializationObject.clampCoordinates;\n }\n}\n__decorate([editableInPropertyPage(\"Clamp Coordinates\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", {\n embedded: true,\n notifiers: {\n rebuild: true\n }\n})], GeometryTextureFetchBlock.prototype, \"clampCoordinates\", void 0);\nRegisterClass(\"BABYLON.GeometryTextureFetchBlock\", GeometryTextureFetchBlock);","map":{"version":3,"names":["__decorate","Vector4","RegisterClass","NodeGeometryBlockConnectionPointTypes","NodeGeometryBlock","editableInPropertyPage","GeometryTextureFetchBlock","constructor","name","clampCoordinates","registerInput","Texture","Vector2","registerOutput","Vector3","Float","getClassName","texture","inputs","coordinates","rgba","_outputs","rgb","r","g","b","a","_repeatClamp","num","Math","abs","_buildBlock","func","state","textureData","getConnectedValue","data","uv","u","max","min","x","v","y","floor","width","height","index","FromArray","_storedFunction","color","toVector3","z","w","_dumpPropertiesCode","codeString","_codeVariableName","serialize","serializationObject","_deserialize","embedded","notifiers","rebuild","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js"],"sourcesContent":["import { __decorate } from \"../../../../tslib.es6.js\";\nimport { Vector4 } from \"../../../../Maths/math.vector.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock.js\";\nimport { editableInPropertyPage } from \"../../../../Decorators/nodeDecorator.js\";\n/**\n * Block used to fetch a color from texture data\n */\nexport class GeometryTextureFetchBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryTextureFetchBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n /**\n * Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1\n */\n this.clampCoordinates = true;\n this.registerInput(\"texture\", NodeGeometryBlockConnectionPointTypes.Texture);\n this.registerInput(\"coordinates\", NodeGeometryBlockConnectionPointTypes.Vector2);\n this.registerOutput(\"rgba\", NodeGeometryBlockConnectionPointTypes.Vector4);\n this.registerOutput(\"rgb\", NodeGeometryBlockConnectionPointTypes.Vector3);\n this.registerOutput(\"r\", NodeGeometryBlockConnectionPointTypes.Float);\n this.registerOutput(\"g\", NodeGeometryBlockConnectionPointTypes.Float);\n this.registerOutput(\"b\", NodeGeometryBlockConnectionPointTypes.Float);\n this.registerOutput(\"a\", NodeGeometryBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryTextureFetchBlock\";\n }\n /**\n * Gets the texture component\n */\n get texture() {\n return this.inputs[0];\n }\n /**\n * Gets the coordinates component\n */\n get coordinates() {\n return this.inputs[1];\n }\n /**\n * Gets the rgba component\n */\n get rgba() {\n return this._outputs[0];\n }\n /**\n * Gets the rgb component\n */\n get rgb() {\n return this._outputs[1];\n }\n /**\n * Gets the r component\n */\n get r() {\n return this._outputs[2];\n }\n /**\n * Gets the g component\n */\n get g() {\n return this._outputs[3];\n }\n /**\n * Gets the b component\n */\n get b() {\n return this._outputs[4];\n }\n /**\n * Gets the a component\n */\n get a() {\n return this._outputs[5];\n }\n _repeatClamp(num) {\n if (num >= 0) {\n return num % 1;\n }\n else {\n return 1 - (Math.abs(num) % 1);\n }\n }\n _buildBlock() {\n const func = (state) => {\n const textureData = this.texture.getConnectedValue(state);\n if (!textureData || !textureData.data) {\n return null;\n }\n const uv = this.coordinates.getConnectedValue(state);\n if (!uv) {\n return null;\n }\n const u = this.clampCoordinates ? Math.max(0, Math.min(uv.x, 1.0)) : this._repeatClamp(uv.x);\n const v = this.clampCoordinates ? Math.max(0, Math.min(uv.y, 1.0)) : this._repeatClamp(uv.y);\n const x = Math.floor(u * (textureData.width - 1));\n const y = Math.floor(v * (textureData.height - 1));\n const index = x + textureData.width * y;\n return Vector4.FromArray(textureData.data, index * 4);\n };\n this.rgba._storedFunction = (state) => {\n return func(state);\n };\n this.rgb._storedFunction = (state) => {\n const color = func(state);\n return color ? color.toVector3() : null;\n };\n this.r._storedFunction = (state) => {\n const color = func(state);\n return color ? color.x : null;\n };\n this.g._storedFunction = (state) => {\n const color = func(state);\n return color ? color.y : null;\n };\n this.b._storedFunction = (state) => {\n const color = func(state);\n return color ? color.z : null;\n };\n this.a._storedFunction = (state) => {\n const color = func(state);\n return color ? color.w : null;\n };\n }\n _dumpPropertiesCode() {\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.clampCoordinates = ${this.clampCoordinates};\\n`;\n return codeString;\n }\n /**\n * Serializes this block in a JSON representation\n * @returns the serialized block object\n */\n serialize() {\n const serializationObject = super.serialize();\n serializationObject.clampCoordinates = this.clampCoordinates;\n return serializationObject;\n }\n _deserialize(serializationObject) {\n super._deserialize(serializationObject);\n this.clampCoordinates = serializationObject.clampCoordinates;\n }\n}\n__decorate([\n editableInPropertyPage(\"Clamp Coordinates\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\n], GeometryTextureFetchBlock.prototype, \"clampCoordinates\", void 0);\nRegisterClass(\"BABYLON.GeometryTextureFetchBlock\", GeometryTextureFetchBlock);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,OAAO,QAAQ,kCAAkC;AAC1D,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,qCAAqC,QAAQ,iDAAiD;AACvG,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,sBAAsB,QAAQ,yCAAyC;AAChF;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,SAASF,iBAAiB,CAAC;EAC7D;AACJ;AACA;AACA;EACIG,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,CAAC;IACX;AACR;AACA;IACQ,IAAI,CAACC,gBAAgB,GAAG,IAAI;IAC5B,IAAI,CAACC,aAAa,CAAC,SAAS,EAAEP,qCAAqC,CAACQ,OAAO,CAAC;IAC5E,IAAI,CAACD,aAAa,CAAC,aAAa,EAAEP,qCAAqC,CAACS,OAAO,CAAC;IAChF,IAAI,CAACC,cAAc,CAAC,MAAM,EAAEV,qCAAqC,CAACF,OAAO,CAAC;IAC1E,IAAI,CAACY,cAAc,CAAC,KAAK,EAAEV,qCAAqC,CAACW,O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