1 |
- {"ast":null,"code":"import { __decorate } from \"../tslib.es6.js\";\nimport { serialize, expandToProperty } from \"../Misc/decorators.js\";\nimport { MaterialDefines } from \"./materialDefines.js\";\nimport { MaterialPluginBase } from \"./materialPluginBase.js\";\nimport { MaterialFlags } from \"./materialFlags.js\";\nimport { RegisterClass } from \"../Misc/typeStore.js\";\nimport { BindTextureMatrix, PrepareDefinesForMergedUV } from \"./materialHelper.functions.js\";\n/**\n * @internal\n */\nexport class DecalMapDefines extends MaterialDefines {\n constructor() {\n super(...arguments);\n this.DECAL = false;\n this.DECALDIRECTUV = 0;\n this.DECAL_SMOOTHALPHA = false;\n this.GAMMADECAL = false;\n }\n}\n/**\n * Plugin that implements the decal map component of a material\n * @since 5.49.1\n */\nexport class DecalMapConfiguration extends MaterialPluginBase {\n /** @internal */\n _markAllSubMeshesAsTexturesDirty() {\n this._enable(this._isEnabled);\n this._internalMarkAllSubMeshesAsTexturesDirty();\n }\n /**\n * Gets a boolean indicating that the plugin is compatible with a given shader language.\n * @returns true if the plugin is compatible with the shader language\n */\n isCompatible() {\n return true;\n }\n /**\n * Creates a new DecalMapConfiguration\n * @param material The material to attach the decal map plugin to\n * @param addToPluginList If the plugin should be added to the material plugin list\n */\n constructor(material, addToPluginList = true) {\n super(material, \"DecalMap\", 150, new DecalMapDefines(), addToPluginList);\n this._isEnabled = false;\n /**\n * Enables or disables the decal map on this material\n */\n this.isEnabled = false;\n this._smoothAlpha = false;\n /**\n * Enables or disables the smooth alpha mode on this material. Default: false.\n * When enabled, the alpha value used to blend the decal map will be the squared value and will produce a smoother result.\n */\n this.smoothAlpha = false;\n this.registerForExtraEvents = true; // because we override the hardBindForSubMesh method\n this._internalMarkAllSubMeshesAsTexturesDirty = material._dirtyCallbacks[1];\n }\n isReadyForSubMesh(defines, scene, engine, subMesh) {\n const decalMap = subMesh.getMesh().decalMap;\n if (!this._isEnabled || !(decalMap !== null && decalMap !== void 0 && decalMap.texture) || !MaterialFlags.DecalMapEnabled || !scene.texturesEnabled) {\n return true;\n }\n return decalMap.isReady();\n }\n prepareDefinesBeforeAttributes(defines, scene, mesh) {\n const decalMap = mesh.decalMap;\n if (!this._isEnabled || !(decalMap !== null && decalMap !== void 0 && decalMap.texture) || !MaterialFlags.DecalMapEnabled || !scene.texturesEnabled) {\n const isDirty = defines.DECAL;\n if (isDirty) {\n defines.markAsTexturesDirty();\n }\n defines.DECAL = false;\n } else {\n const isDirty = !defines.DECAL || defines.GAMMADECAL !== decalMap.texture.gammaSpace;\n if (isDirty) {\n defines.markAsTexturesDirty();\n }\n defines.DECAL = true;\n defines.GAMMADECAL = decalMap.texture.gammaSpace;\n defines.DECAL_SMOOTHALPHA = this._smoothAlpha;\n PrepareDefinesForMergedUV(decalMap.texture, defines, \"DECAL\");\n }\n }\n hardBindForSubMesh(uniformBuffer, scene, _engine, subMesh) {\n /**\n * Note that we override hardBindForSubMesh and not bindForSubMesh because the material can be shared by multiple meshes,\n * in which case mustRebind could return false even though the decal map is different for each mesh: that's because the decal map\n * is not part of the material but hosted by the decalMap of the mesh instead.\n */\n const decalMap = subMesh.getMesh().decalMap;\n if (!this._isEnabled || !(decalMap !== null && decalMap !== void 0 && decalMap.texture) || !MaterialFlags.DecalMapEnabled || !scene.texturesEnabled) {\n return;\n }\n const isFrozen = this._material.isFrozen;\n const texture = decalMap.texture;\n if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {\n uniformBuffer.updateFloat4(\"vDecalInfos\", texture.coordinatesIndex, 0, 0, 0);\n BindTextureMatrix(texture, uniformBuffer, \"decal\");\n }\n uniformBuffer.setTexture(\"decalSampler\", texture);\n }\n getClassName() {\n return \"DecalMapConfiguration\";\n }\n getSamplers(samplers) {\n samplers.push(\"decalSampler\");\n }\n getUniforms() {\n return {\n ubo: [{\n name: \"vDecalInfos\",\n size: 4,\n type: \"vec4\"\n }, {\n name: \"decalMatrix\",\n size: 16,\n type: \"mat4\"\n }]\n };\n }\n}\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")], DecalMapConfiguration.prototype, \"isEnabled\", void 0);\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")], DecalMapConfiguration.prototype, \"smoothAlpha\", void 0);\nRegisterClass(\"BABYLON.DecalMapConfiguration\", DecalMapConfiguration);","map":{"version":3,"names":["__decorate","serialize","expandToProperty","MaterialDefines","MaterialPluginBase","MaterialFlags","RegisterClass","BindTextureMatrix","PrepareDefinesForMergedUV","DecalMapDefines","constructor","arguments","DECAL","DECALDIRECTUV","DECAL_SMOOTHALPHA","GAMMADECAL","DecalMapConfiguration","_markAllSubMeshesAsTexturesDirty","_enable","_isEnabled","_internalMarkAllSubMeshesAsTexturesDirty","isCompatible","material","addToPluginList","isEnabled","_smoothAlpha","smoothAlpha","registerForExtraEvents","_dirtyCallbacks","isReadyForSubMesh","defines","scene","engine","subMesh","decalMap","getMesh","texture","DecalMapEnabled","texturesEnabled","isReady","prepareDefinesBeforeAttributes","mesh","isDirty","markAsTexturesDirty","gammaSpace","hardBindForSubMesh","uniformBuffer","_engine","isFrozen","_material","useUbo","isSync","updateFloat4","coordinatesIndex","setTexture","getClassName","getSamplers","samplers","push","getUniforms","ubo","name","size","type","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/material.decalMapConfiguration.js"],"sourcesContent":["import { __decorate } from \"../tslib.es6.js\";\nimport { serialize, expandToProperty } from \"../Misc/decorators.js\";\nimport { MaterialDefines } from \"./materialDefines.js\";\nimport { MaterialPluginBase } from \"./materialPluginBase.js\";\n\nimport { MaterialFlags } from \"./materialFlags.js\";\nimport { RegisterClass } from \"../Misc/typeStore.js\";\nimport { BindTextureMatrix, PrepareDefinesForMergedUV } from \"./materialHelper.functions.js\";\n/**\n * @internal\n */\nexport class DecalMapDefines extends MaterialDefines {\n constructor() {\n super(...arguments);\n this.DECAL = false;\n this.DECALDIRECTUV = 0;\n this.DECAL_SMOOTHALPHA = false;\n this.GAMMADECAL = false;\n }\n}\n/**\n * Plugin that implements the decal map component of a material\n * @since 5.49.1\n */\nexport class DecalMapConfiguration extends MaterialPluginBase {\n /** @internal */\n _markAllSubMeshesAsTexturesDirty() {\n this._enable(this._isEnabled);\n this._internalMarkAllSubMeshesAsTexturesDirty();\n }\n /**\n * Gets a boolean indicating that the plugin is compatible with a given shader language.\n * @returns true if the plugin is compatible with the shader language\n */\n isCompatible() {\n return true;\n }\n /**\n * Creates a new DecalMapConfiguration\n * @param material The material to attach the decal map plugin to\n * @param addToPluginList If the plugin should be added to the material plugin list\n */\n constructor(material, addToPluginList = true) {\n super(material, \"DecalMap\", 150, new DecalMapDefines(), addToPluginList);\n this._isEnabled = false;\n /**\n * Enables or disables the decal map on this material\n */\n this.isEnabled = false;\n this._smoothAlpha = false;\n /**\n * Enables or disables the smooth alpha mode on this material. Default: false.\n * When enabled, the alpha value used to blend the decal map will be the squared value and will produce a smoother result.\n */\n this.smoothAlpha = false;\n this.registerForExtraEvents = true; // because we override the hardBindForSubMesh method\n this._internalMarkAllSubMeshesAsTexturesDirty = material._dirtyCallbacks[1];\n }\n isReadyForSubMesh(defines, scene, engine, subMesh) {\n const decalMap = subMesh.getMesh().decalMap;\n if (!this._isEnabled || !decalMap?.texture || !MaterialFlags.DecalMapEnabled || !scene.texturesEnabled) {\n return true;\n }\n return decalMap.isReady();\n }\n prepareDefinesBeforeAttributes(defines, scene, mesh) {\n const decalMap = mesh.decalMap;\n if (!this._isEnabled || !decalMap?.texture || !MaterialFlags.DecalMapEnabled || !scene.texturesEnabled) {\n const isDirty = defines.DECAL;\n if (isDirty) {\n defines.markAsTexturesDirty();\n }\n defines.DECAL = false;\n }\n else {\n const isDirty = !defines.DECAL || defines.GAMMADECAL !== decalMap.texture.gammaSpace;\n if (isDirty) {\n defines.markAsTexturesDirty();\n }\n defines.DECAL = true;\n defines.GAMMADECAL = decalMap.texture.gammaSpace;\n defines.DECAL_SMOOTHALPHA = this._smoothAlpha;\n PrepareDefinesForMergedUV(decalMap.texture, defines, \"DECAL\");\n }\n }\n hardBindForSubMesh(uniformBuffer, scene, _engine, subMesh) {\n /**\n * Note that we override hardBindForSubMesh and not bindForSubMesh because the material can be shared by multiple meshes,\n * in which case mustRebind could return false even though the decal map is different for each mesh: that's because the decal map\n * is not part of the material but hosted by the decalMap of the mesh instead.\n */\n const decalMap = subMesh.getMesh().decalMap;\n if (!this._isEnabled || !decalMap?.texture || !MaterialFlags.DecalMapEnabled || !scene.texturesEnabled) {\n return;\n }\n const isFrozen = this._material.isFrozen;\n const texture = decalMap.texture;\n if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {\n uniformBuffer.updateFloat4(\"vDecalInfos\", texture.coordinatesIndex, 0, 0, 0);\n BindTextureMatrix(texture, uniformBuffer, \"decal\");\n }\n uniformBuffer.setTexture(\"decalSampler\", texture);\n }\n getClassName() {\n return \"DecalMapConfiguration\";\n }\n getSamplers(samplers) {\n samplers.push(\"decalSampler\");\n }\n getUniforms() {\n return {\n ubo: [\n { name: \"vDecalInfos\", size: 4, type: \"vec4\" },\n { name: \"decalMatrix\", size: 16, type: \"mat4\" },\n ],\n };\n }\n}\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\n], DecalMapConfiguration.prototype, \"isEnabled\", void 0);\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\n], DecalMapConfiguration.prototype, \"smoothAlpha\", void 0);\nRegisterClass(\"BABYLON.DecalMapConfiguration\", DecalMapConfiguration);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,SAAS,EAAEC,gBAAgB,QAAQ,uBAAuB;AACnE,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,iBAAiB,EAAEC,yBAAyB,QAAQ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