1 |
- {"ast":null,"code":"import { Scene } from \"../scene.js\";\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nimport { SubSurfaceConfiguration } from \"./subSurfaceConfiguration.js\";\nimport { Color3 } from \"../Maths/math.color.js\";\nimport { AddParser } from \"../Loading/Plugins/babylonFileParser.function.js\";\n// Adds the parser to the scene parsers.\nAddParser(SceneComponentConstants.NAME_SUBSURFACE, (parsedData, scene) => {\n // Diffusion profiles\n if (parsedData.ssDiffusionProfileColors !== undefined && parsedData.ssDiffusionProfileColors !== null) {\n scene.enableSubSurfaceForPrePass();\n if (scene.subSurfaceConfiguration) {\n for (let index = 0, cache = parsedData.ssDiffusionProfileColors.length; index < cache; index++) {\n const color = parsedData.ssDiffusionProfileColors[index];\n scene.subSurfaceConfiguration.addDiffusionProfile(new Color3(color.r, color.g, color.b));\n }\n }\n }\n});\nObject.defineProperty(Scene.prototype, \"subSurfaceConfiguration\", {\n get: function () {\n return this._subSurfaceConfiguration;\n },\n set: function (value) {\n if (value) {\n if (this.enablePrePassRenderer()) {\n this._subSurfaceConfiguration = value;\n }\n }\n },\n enumerable: true,\n configurable: true\n});\nScene.prototype.enableSubSurfaceForPrePass = function () {\n if (this._subSurfaceConfiguration) {\n return this._subSurfaceConfiguration;\n }\n const prePassRenderer = this.enablePrePassRenderer();\n if (prePassRenderer) {\n this._subSurfaceConfiguration = new SubSurfaceConfiguration(this);\n prePassRenderer.addEffectConfiguration(this._subSurfaceConfiguration);\n return this._subSurfaceConfiguration;\n }\n return null;\n};\nScene.prototype.disableSubSurfaceForPrePass = function () {\n if (!this._subSurfaceConfiguration) {\n return;\n }\n this._subSurfaceConfiguration.dispose();\n this._subSurfaceConfiguration = null;\n};\n/**\n * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful\n * in several rendering techniques.\n */\nexport class SubSurfaceSceneComponent {\n /**\n * Creates a new instance of the component for the given scene\n * @param scene Defines the scene to register the component in\n */\n constructor(scene) {\n /**\n * The component name helpful to identify the component in the list of scene components.\n */\n this.name = SceneComponentConstants.NAME_PREPASSRENDERER;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() {}\n /**\n * Serializes the component data to the specified json object\n * @param serializationObject The object to serialize to\n */\n serialize(serializationObject) {\n if (!this.scene.subSurfaceConfiguration) {\n return;\n }\n const ssDiffusionProfileColors = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;\n serializationObject.ssDiffusionProfileColors = [];\n for (let i = 0; i < ssDiffusionProfileColors.length; i++) {\n serializationObject.ssDiffusionProfileColors.push({\n r: ssDiffusionProfileColors[i].r,\n g: ssDiffusionProfileColors[i].g,\n b: ssDiffusionProfileColors[i].b\n });\n }\n }\n /**\n * Adds all the elements from the container to the scene\n */\n addFromContainer() {\n // Nothing to do\n }\n /**\n * Removes all the elements in the container from the scene\n */\n removeFromContainer() {\n // Make sure nothing will be serialized\n if (!this.scene.prePassRenderer) {\n return;\n }\n if (this.scene.subSurfaceConfiguration) {\n this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles();\n }\n }\n /**\n * Rebuilds the elements related to this component in case of\n * context lost for instance.\n */\n rebuild() {\n // Nothing to do for this component\n }\n /**\n * Disposes the component and the associated resources\n */\n dispose() {\n // Nothing to do for this component\n }\n}\nSubSurfaceConfiguration._SceneComponentInitialization = scene => {\n // Register the G Buffer component to the scene.\n let component = scene._getComponent(SceneComponentConstants.NAME_SUBSURFACE);\n if (!component) {\n component = new SubSurfaceSceneComponent(scene);\n scene._addComponent(component);\n }\n};","map":{"version":3,"names":["Scene","SceneComponentConstants","SubSurfaceConfiguration","Color3","AddParser","NAME_SUBSURFACE","parsedData","scene","ssDiffusionProfileColors","undefined","enableSubSurfaceForPrePass","subSurfaceConfiguration","index","cache","length","color","addDiffusionProfile","r","g","b","Object","defineProperty","prototype","get","_subSurfaceConfiguration","set","value","enablePrePassRenderer","enumerable","configurable","prePassRenderer","addEffectConfiguration","disableSubSurfaceForPrePass","dispose","SubSurfaceSceneComponent","constructor","name","NAME_PREPASSRENDERER","register","serialize","serializationObject","i","push","addFromContainer","removeFromContainer","clearAllDiffusionProfiles","rebuild","_SceneComponentInitialization","component","_getComponent","_addComponent"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Rendering/subSurfaceSceneComponent.js"],"sourcesContent":["import { Scene } from \"../scene.js\";\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nimport { SubSurfaceConfiguration } from \"./subSurfaceConfiguration.js\";\nimport { Color3 } from \"../Maths/math.color.js\";\nimport { AddParser } from \"../Loading/Plugins/babylonFileParser.function.js\";\n// Adds the parser to the scene parsers.\nAddParser(SceneComponentConstants.NAME_SUBSURFACE, (parsedData, scene) => {\n // Diffusion profiles\n if (parsedData.ssDiffusionProfileColors !== undefined && parsedData.ssDiffusionProfileColors !== null) {\n scene.enableSubSurfaceForPrePass();\n if (scene.subSurfaceConfiguration) {\n for (let index = 0, cache = parsedData.ssDiffusionProfileColors.length; index < cache; index++) {\n const color = parsedData.ssDiffusionProfileColors[index];\n scene.subSurfaceConfiguration.addDiffusionProfile(new Color3(color.r, color.g, color.b));\n }\n }\n }\n});\nObject.defineProperty(Scene.prototype, \"subSurfaceConfiguration\", {\n get: function () {\n return this._subSurfaceConfiguration;\n },\n set: function (value) {\n if (value) {\n if (this.enablePrePassRenderer()) {\n this._subSurfaceConfiguration = value;\n }\n }\n },\n enumerable: true,\n configurable: true,\n});\nScene.prototype.enableSubSurfaceForPrePass = function () {\n if (this._subSurfaceConfiguration) {\n return this._subSurfaceConfiguration;\n }\n const prePassRenderer = this.enablePrePassRenderer();\n if (prePassRenderer) {\n this._subSurfaceConfiguration = new SubSurfaceConfiguration(this);\n prePassRenderer.addEffectConfiguration(this._subSurfaceConfiguration);\n return this._subSurfaceConfiguration;\n }\n return null;\n};\nScene.prototype.disableSubSurfaceForPrePass = function () {\n if (!this._subSurfaceConfiguration) {\n return;\n }\n this._subSurfaceConfiguration.dispose();\n this._subSurfaceConfiguration = null;\n};\n/**\n * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful\n * in several rendering techniques.\n */\nexport class SubSurfaceSceneComponent {\n /**\n * Creates a new instance of the component for the given scene\n * @param scene Defines the scene to register the component in\n */\n constructor(scene) {\n /**\n * The component name helpful to identify the component in the list of scene components.\n */\n this.name = SceneComponentConstants.NAME_PREPASSRENDERER;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() { }\n /**\n * Serializes the component data to the specified json object\n * @param serializationObject The object to serialize to\n */\n serialize(serializationObject) {\n if (!this.scene.subSurfaceConfiguration) {\n return;\n }\n const ssDiffusionProfileColors = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;\n serializationObject.ssDiffusionProfileColors = [];\n for (let i = 0; i < ssDiffusionProfileColors.length; i++) {\n serializationObject.ssDiffusionProfileColors.push({\n r: ssDiffusionProfileColors[i].r,\n g: ssDiffusionProfileColors[i].g,\n b: ssDiffusionProfileColors[i].b,\n });\n }\n }\n /**\n * Adds all the elements from the container to the scene\n */\n addFromContainer() {\n // Nothing to do\n }\n /**\n * Removes all the elements in the container from the scene\n */\n removeFromContainer() {\n // Make sure nothing will be serialized\n if (!this.scene.prePassRenderer) {\n return;\n }\n if (this.scene.subSurfaceConfiguration) {\n this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles();\n }\n }\n /**\n * Rebuilds the elements related to this component in case of\n * context lost for instance.\n */\n rebuild() {\n // Nothing to do for this component\n }\n /**\n * Disposes the component and the associated resources\n */\n dispose() {\n // Nothing to do for this component\n }\n}\nSubSurfaceConfiguration._SceneComponentInitialization = (scene) => {\n // Register the G Buffer component to the scene.\n let component = scene._getComponent(SceneComponentConstants.NAME_SUBSURFACE);\n if (!component) {\n component = new SubSurfaceSceneComponent(scene);\n scene._addComponent(component);\n }\n};\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAa;AACnC,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9D,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,MA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