73b9332d69282b056dee0cbdc5d82fd12f66224369aa263ad43f9a0eec4a4d5a.json 9.6 KB

1
  1. {"ast":null,"code":"import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature.js\";\n/**\n * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.\n */\nexport class WebXRBackgroundRemover extends WebXRAbstractFeature {\n /**\n * constructs a new background remover module\n * @param _xrSessionManager the session manager for this module\n * @param options read-only options to be used in this module\n */\n constructor(_xrSessionManager,\n /**\n * [Empty Object] read-only options to be used in this module\n */\n options = {}) {\n super(_xrSessionManager);\n this.options = options;\n /**\n * registered observers will be triggered when the background state changes\n */\n this.onBackgroundStateChangedObservable = new Observable();\n }\n /**\n * attach this feature\n * Will usually be called by the features manager\n *\n * @returns true if successful.\n */\n attach() {\n this._setBackgroundState(false);\n return super.attach();\n }\n /**\n * detach this feature.\n * Will usually be called by the features manager\n *\n * @returns true if successful.\n */\n detach() {\n this._setBackgroundState(true);\n return super.detach();\n }\n /**\n * Dispose this feature and all of the resources attached\n */\n dispose() {\n super.dispose();\n this.onBackgroundStateChangedObservable.clear();\n }\n _onXRFrame(_xrFrame) {\n // no-op\n }\n _setBackgroundState(newState) {\n const scene = this._xrSessionManager.scene;\n if (!this.options.ignoreEnvironmentHelper) {\n if (this.options.environmentHelperRemovalFlags) {\n if (this.options.environmentHelperRemovalFlags.skyBox) {\n const backgroundSkybox = scene.getMeshByName(\"BackgroundSkybox\");\n if (backgroundSkybox) {\n backgroundSkybox.setEnabled(newState);\n }\n }\n if (this.options.environmentHelperRemovalFlags.ground) {\n const backgroundPlane = scene.getMeshByName(\"BackgroundPlane\");\n if (backgroundPlane) {\n backgroundPlane.setEnabled(newState);\n }\n }\n } else {\n const backgroundHelper = scene.getMeshByName(\"BackgroundHelper\");\n if (backgroundHelper) {\n backgroundHelper.setEnabled(newState);\n }\n }\n }\n if (this.options.backgroundMeshes) {\n this.options.backgroundMeshes.forEach(mesh => mesh.setEnabled(newState));\n }\n this.onBackgroundStateChangedObservable.notifyObservers(newState);\n }\n}\n/**\n * The module's name\n */\nWebXRBackgroundRemover.Name = WebXRFeatureName.BACKGROUND_REMOVER;\n/**\n * The (Babylon) version of this module.\n * This is an integer representing the implementation version.\n * This number does not correspond to the WebXR specs version\n */\nWebXRBackgroundRemover.Version = 1;\n//register the plugin\nWebXRFeaturesManager.AddWebXRFeature(WebXRBackgroundRemover.Name, (xrSessionManager, options) => {\n return () => new WebXRBackgroundRemover(xrSessionManager, options);\n}, WebXRBackgroundRemover.Version, true);","map":{"version":3,"names":["WebXRFeaturesManager","WebXRFeatureName","Observable","WebXRAbstractFeature","WebXRBackgroundRemover","constructor","_xrSessionManager","options","onBackgroundStateChangedObservable","attach","_setBackgroundState","detach","dispose","clear","_onXRFrame","_xrFrame","newState","scene","ignoreEnvironmentHelper","environmentHelperRemovalFlags","skyBox","backgroundSkybox","getMeshByName","setEnabled","ground","backgroundPlane","backgroundHelper","backgroundMeshes","forEach","mesh","notifyObservers","Name","BACKGROUND_REMOVER","Version","AddWebXRFeature","xrSessionManager"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/XR/features/WebXRBackgroundRemover.js"],"sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature.js\";\n/**\n * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.\n */\nexport class WebXRBackgroundRemover extends WebXRAbstractFeature {\n /**\n * constructs a new background remover module\n * @param _xrSessionManager the session manager for this module\n * @param options read-only options to be used in this module\n */\n constructor(_xrSessionManager, \n /**\n * [Empty Object] read-only options to be used in this module\n */\n options = {}) {\n super(_xrSessionManager);\n this.options = options;\n /**\n * registered observers will be triggered when the background state changes\n */\n this.onBackgroundStateChangedObservable = new Observable();\n }\n /**\n * attach this feature\n * Will usually be called by the features manager\n *\n * @returns true if successful.\n */\n attach() {\n this._setBackgroundState(false);\n return super.attach();\n }\n /**\n * detach this feature.\n * Will usually be called by the features manager\n *\n * @returns true if successful.\n */\n detach() {\n this._setBackgroundState(true);\n return super.detach();\n }\n /**\n * Dispose this feature and all of the resources attached\n */\n dispose() {\n super.dispose();\n this.onBackgroundStateChangedObservable.clear();\n }\n _onXRFrame(_xrFrame) {\n // no-op\n }\n _setBackgroundState(newState) {\n const scene = this._xrSessionManager.scene;\n if (!this.options.ignoreEnvironmentHelper) {\n if (this.options.environmentHelperRemovalFlags) {\n if (this.options.environmentHelperRemovalFlags.skyBox) {\n const backgroundSkybox = scene.getMeshByName(\"BackgroundSkybox\");\n if (backgroundSkybox) {\n backgroundSkybox.setEnabled(newState);\n }\n }\n if (this.options.environmentHelperRemovalFlags.ground) {\n const backgroundPlane = scene.getMeshByName(\"BackgroundPlane\");\n if (backgroundPlane) {\n backgroundPlane.setEnabled(newState);\n }\n }\n }\n else {\n const backgroundHelper = scene.getMeshByName(\"BackgroundHelper\");\n if (backgroundHelper) {\n backgroundHelper.setEnabled(newState);\n }\n }\n }\n if (this.options.backgroundMeshes) {\n this.options.backgroundMeshes.forEach((mesh) => mesh.setEnabled(newState));\n }\n this.onBackgroundStateChangedObservable.notifyObservers(newState);\n }\n}\n/**\n * The module's name\n */\nWebXRBackgroundRemover.Name = WebXRFeatureName.BACKGROUND_REMOVER;\n/**\n * The (Babylon) version of this module.\n * This is an integer representing the implementation version.\n * This number does not correspond to the WebXR specs version\n */\nWebXRBackgroundRemover.Version = 1;\n//register the plugin\nWebXRFeaturesManager.AddWebXRFeature(WebXRBackgroundRemover.Name, (xrSessionManager, options) => {\n return () => new WebXRBackgroundRemover(xrSessionManager, options);\n}, WebXRBackgroundRemover.Version, true);\n"],"mappings":"AAAA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACnF,SAASC,UAAU,QAAQ,0B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