1 |
- {"ast":null,"code":"import { Tools } from \"../Misc/tools.js\";\nimport { Scene } from \"../scene.js\";\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nimport { LensFlareSystem } from \"./lensFlareSystem.js\";\nimport { AddParser } from \"../Loading/Plugins/babylonFileParser.function.js\";\n// Adds the parser to the scene parsers.\nAddParser(SceneComponentConstants.NAME_LENSFLARESYSTEM, (parsedData, scene, container, rootUrl) => {\n // Lens flares\n if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {\n if (!container.lensFlareSystems) {\n container.lensFlareSystems = [];\n }\n for (let index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {\n const parsedLensFlareSystem = parsedData.lensFlareSystems[index];\n const lf = LensFlareSystem.Parse(parsedLensFlareSystem, scene, rootUrl);\n container.lensFlareSystems.push(lf);\n }\n }\n});\nScene.prototype.getLensFlareSystemByName = function (name) {\n for (let index = 0; index < this.lensFlareSystems.length; index++) {\n if (this.lensFlareSystems[index].name === name) {\n return this.lensFlareSystems[index];\n }\n }\n return null;\n};\nScene.prototype.getLensFlareSystemById = function (id) {\n for (let index = 0; index < this.lensFlareSystems.length; index++) {\n if (this.lensFlareSystems[index].id === id) {\n return this.lensFlareSystems[index];\n }\n }\n return null;\n};\nScene.prototype.getLensFlareSystemByID = function (id) {\n return this.getLensFlareSystemById(id);\n};\nScene.prototype.removeLensFlareSystem = function (toRemove) {\n const index = this.lensFlareSystems.indexOf(toRemove);\n if (index !== -1) {\n this.lensFlareSystems.splice(index, 1);\n }\n return index;\n};\nScene.prototype.addLensFlareSystem = function (newLensFlareSystem) {\n this.lensFlareSystems.push(newLensFlareSystem);\n};\n/**\n * Defines the lens flare scene component responsible to manage any lens flares\n * in a given scene.\n */\nexport class LensFlareSystemSceneComponent {\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_LENSFLARESYSTEM;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() {\n this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);\n }\n /**\n * Rebuilds the elements related to this component in case of\n * context lost for instance.\n */\n rebuild() {\n for (let index = 0; index < this.scene.lensFlareSystems.length; index++) {\n this.scene.lensFlareSystems[index].rebuild();\n }\n }\n /**\n * Adds all the elements from the container to the scene\n * @param container the container holding the elements\n */\n addFromContainer(container) {\n if (!container.lensFlareSystems) {\n return;\n }\n container.lensFlareSystems.forEach(o => {\n this.scene.addLensFlareSystem(o);\n });\n }\n /**\n * Removes all the elements in the container from the scene\n * @param container contains the elements to remove\n * @param dispose if the removed element should be disposed (default: false)\n */\n removeFromContainer(container, dispose) {\n if (!container.lensFlareSystems) {\n return;\n }\n container.lensFlareSystems.forEach(o => {\n this.scene.removeLensFlareSystem(o);\n if (dispose) {\n o.dispose();\n }\n });\n }\n /**\n * Serializes the component data to the specified json object\n * @param serializationObject The object to serialize to\n */\n serialize(serializationObject) {\n // Lens flares\n serializationObject.lensFlareSystems = [];\n const lensFlareSystems = this.scene.lensFlareSystems;\n for (const lensFlareSystem of lensFlareSystems) {\n serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());\n }\n }\n /**\n * Disposes the component and the associated resources.\n */\n dispose() {\n const lensFlareSystems = this.scene.lensFlareSystems;\n while (lensFlareSystems.length) {\n lensFlareSystems[0].dispose();\n }\n }\n _draw(camera) {\n // Lens flares\n if (this.scene.lensFlaresEnabled) {\n const lensFlareSystems = this.scene.lensFlareSystems;\n Tools.StartPerformanceCounter(\"Lens flares\", lensFlareSystems.length > 0);\n for (const lensFlareSystem of lensFlareSystems) {\n if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {\n lensFlareSystem.render();\n }\n }\n Tools.EndPerformanceCounter(\"Lens flares\", lensFlareSystems.length > 0);\n }\n }\n}\nLensFlareSystem._SceneComponentInitialization = scene => {\n let component = scene._getComponent(SceneComponentConstants.NAME_LENSFLARESYSTEM);\n if (!component) {\n component = new LensFlareSystemSceneComponent(scene);\n scene._addComponent(component);\n }\n};","map":{"version":3,"names":["Tools","Scene","SceneComponentConstants","LensFlareSystem","AddParser","NAME_LENSFLARESYSTEM","parsedData","scene","container","rootUrl","lensFlareSystems","undefined","index","cache","length","parsedLensFlareSystem","lf","Parse","push","prototype","getLensFlareSystemByName","name","getLensFlareSystemById","id","getLensFlareSystemByID","removeLensFlareSystem","toRemove","indexOf","splice","addLensFlareSystem","newLensFlareSystem","LensFlareSystemSceneComponent","constructor","register","_afterCameraDrawStage","registerStep","STEP_AFTERCAMERADRAW_LENSFLARESYSTEM","_draw","rebuild","addFromContainer","forEach","o","removeFromContainer","dispose","serialize","serializationObject","lensFlareSystem","camera","lensFlaresEnabled","StartPerformanceCounter","layerMask","render","EndPerformanceCounter","_SceneComponentInitialization","component","_getComponent","_addComponent"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/LensFlares/lensFlareSystemSceneComponent.js"],"sourcesContent":["import { Tools } from \"../Misc/tools.js\";\nimport { Scene } from \"../scene.js\";\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nimport { LensFlareSystem } from \"./lensFlareSystem.js\";\nimport { AddParser } from \"../Loading/Plugins/babylonFileParser.function.js\";\n// Adds the parser to the scene parsers.\nAddParser(SceneComponentConstants.NAME_LENSFLARESYSTEM, (parsedData, scene, container, rootUrl) => {\n // Lens flares\n if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {\n if (!container.lensFlareSystems) {\n container.lensFlareSystems = [];\n }\n for (let index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {\n const parsedLensFlareSystem = parsedData.lensFlareSystems[index];\n const lf = LensFlareSystem.Parse(parsedLensFlareSystem, scene, rootUrl);\n container.lensFlareSystems.push(lf);\n }\n }\n});\nScene.prototype.getLensFlareSystemByName = function (name) {\n for (let index = 0; index < this.lensFlareSystems.length; index++) {\n if (this.lensFlareSystems[index].name === name) {\n return this.lensFlareSystems[index];\n }\n }\n return null;\n};\nScene.prototype.getLensFlareSystemById = function (id) {\n for (let index = 0; index < this.lensFlareSystems.length; index++) {\n if (this.lensFlareSystems[index].id === id) {\n return this.lensFlareSystems[index];\n }\n }\n return null;\n};\nScene.prototype.getLensFlareSystemByID = function (id) {\n return this.getLensFlareSystemById(id);\n};\nScene.prototype.removeLensFlareSystem = function (toRemove) {\n const index = this.lensFlareSystems.indexOf(toRemove);\n if (index !== -1) {\n this.lensFlareSystems.splice(index, 1);\n }\n return index;\n};\nScene.prototype.addLensFlareSystem = function (newLensFlareSystem) {\n this.lensFlareSystems.push(newLensFlareSystem);\n};\n/**\n * Defines the lens flare scene component responsible to manage any lens flares\n * in a given scene.\n */\nexport class LensFlareSystemSceneComponent {\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_LENSFLARESYSTEM;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() {\n this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);\n }\n /**\n * Rebuilds the elements related to this component in case of\n * context lost for instance.\n */\n rebuild() {\n for (let index = 0; index < this.scene.lensFlareSystems.length; index++) {\n this.scene.lensFlareSystems[index].rebuild();\n }\n }\n /**\n * Adds all the elements from the container to the scene\n * @param container the container holding the elements\n */\n addFromContainer(container) {\n if (!container.lensFlareSystems) {\n return;\n }\n container.lensFlareSystems.forEach((o) => {\n this.scene.addLensFlareSystem(o);\n });\n }\n /**\n * Removes all the elements in the container from the scene\n * @param container contains the elements to remove\n * @param dispose if the removed element should be disposed (default: false)\n */\n removeFromContainer(container, dispose) {\n if (!container.lensFlareSystems) {\n return;\n }\n container.lensFlareSystems.forEach((o) => {\n this.scene.removeLensFlareSystem(o);\n if (dispose) {\n o.dispose();\n }\n });\n }\n /**\n * Serializes the component data to the specified json object\n * @param serializationObject The object to serialize to\n */\n serialize(serializationObject) {\n // Lens flares\n serializationObject.lensFlareSystems = [];\n const lensFlareSystems = this.scene.lensFlareSystems;\n for (const lensFlareSystem of lensFlareSystems) {\n serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());\n }\n }\n /**\n * Disposes the component and the associated resources.\n */\n dispose() {\n const lensFlareSystems = this.scene.lensFlareSystems;\n while (lensFlareSystems.length) {\n lensFlareSystems[0].dispose();\n }\n }\n _draw(camera) {\n // Lens flares\n if (this.scene.lensFlaresEnabled) {\n const lensFlareSystems = this.scene.lensFlareSystems;\n Tools.StartPerformanceCounter(\"Lens flares\", lensFlareSystems.length > 0);\n for (const lensFlareSystem of lensFlareSystems) {\n if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {\n lensFlareSystem.render();\n }\n }\n Tools.EndPerformanceCounter(\"Lens flares\", lensFlareSystems.length > 0);\n }\n }\n}\nLensFlareSystem._SceneComponentInitialization = (scene) => {\n let component = scene._getComponent(SceneComponentConstants.NAME_LENSFLARESYSTEM);\n if (!component) {\n component = new LensFlareSystemSceneComponent(scene);\n scene._addComponent(component);\n }\n};\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,kBAAkB;AACxC,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9D,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,SAAS,QAAQ,kDAAkD;AAC5E;AACAA,SAAS,CAACF,uBAAuB,CAACG,oBAAoB,EAAE,CAACC,UAAU,EAAEC,KAAK,EAAEC,SAAS,EAAEC,OAAO,KAAK;EAC/F;EACA,IAAIH,UAAU,CAACI,gBAAgB,KAAKC,SAAS,IAAIL,UAAU,CAACI,gBAAgB,KAAK,IAAI,EAAE;IACnF,IAAI,CAACF,SAAS,CAACE,gBAAgB,EAAE;MAC7BF,SAAS,CA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