1 |
- {"ast":null,"code":"import { Scene } from \"../scene.js\";\nimport { DepthRenderer } from \"./depthRenderer.js\";\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nScene.prototype.enableDepthRenderer = function (camera, storeNonLinearDepth = false, force32bitsFloat = false, samplingMode = 3, storeCameraSpaceZ = false) {\n camera = camera || this.activeCamera;\n if (!camera) {\n // eslint-disable-next-line no-throw-literal\n throw \"No camera available to enable depth renderer\";\n }\n if (!this._depthRenderer) {\n this._depthRenderer = {};\n }\n if (!this._depthRenderer[camera.id]) {\n const supportFullfloat = !!this.getEngine().getCaps().textureFloatRender;\n let textureType = 0;\n if (this.getEngine().getCaps().textureHalfFloatRender && (!force32bitsFloat || !supportFullfloat)) {\n textureType = 2;\n } else if (supportFullfloat) {\n textureType = 1;\n } else {\n textureType = 0;\n }\n this._depthRenderer[camera.id] = new DepthRenderer(this, textureType, camera, storeNonLinearDepth, samplingMode, storeCameraSpaceZ);\n }\n return this._depthRenderer[camera.id];\n};\nScene.prototype.disableDepthRenderer = function (camera) {\n camera = camera || this.activeCamera;\n if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {\n return;\n }\n this._depthRenderer[camera.id].dispose();\n};\n/**\n * Defines the Depth Renderer scene component responsible to manage a depth buffer useful\n * in several rendering techniques.\n */\nexport class DepthRendererSceneComponent {\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_DEPTHRENDERER;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() {\n this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);\n this.scene._gatherActiveCameraRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);\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 for (const key in this.scene._depthRenderer) {\n this.scene._depthRenderer[key].dispose();\n }\n }\n _gatherRenderTargets(renderTargets) {\n if (this.scene._depthRenderer) {\n for (const key in this.scene._depthRenderer) {\n const depthRenderer = this.scene._depthRenderer[key];\n if (depthRenderer.enabled && !depthRenderer.useOnlyInActiveCamera) {\n renderTargets.push(depthRenderer.getDepthMap());\n }\n }\n }\n }\n _gatherActiveCameraRenderTargets(renderTargets) {\n if (this.scene._depthRenderer) {\n for (const key in this.scene._depthRenderer) {\n const depthRenderer = this.scene._depthRenderer[key];\n if (depthRenderer.enabled && depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {\n renderTargets.push(depthRenderer.getDepthMap());\n }\n }\n }\n }\n}\nDepthRenderer._SceneComponentInitialization = scene => {\n // Register the G Buffer component to the scene.\n let component = scene._getComponent(SceneComponentConstants.NAME_DEPTHRENDERER);\n if (!component) {\n component = new DepthRendererSceneComponent(scene);\n scene._addComponent(component);\n }\n};","map":{"version":3,"names":["Scene","DepthRenderer","SceneComponentConstants","prototype","enableDepthRenderer","camera","storeNonLinearDepth","force32bitsFloat","samplingMode","storeCameraSpaceZ","activeCamera","_depthRenderer","id","supportFullfloat","getEngine","getCaps","textureFloatRender","textureType","textureHalfFloatRender","disableDepthRenderer","dispose","DepthRendererSceneComponent","constructor","scene","name","NAME_DEPTHRENDERER","register","_gatherRenderTargetsStage","registerStep","STEP_GATHERRENDERTARGETS_DEPTHRENDERER","_gatherRenderTargets","_gatherActiveCameraRenderTargetsStage","STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER","_gatherActiveCameraRenderTargets","rebuild","key","renderTargets","depthRenderer","enabled","useOnlyInActiveCamera","push","getDepthMap","_SceneComponentInitialization","component","_getComponent","_addComponent"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Rendering/depthRendererSceneComponent.js"],"sourcesContent":["import { Scene } from \"../scene.js\";\nimport { DepthRenderer } from \"./depthRenderer.js\";\n\nimport { SceneComponentConstants } from \"../sceneComponent.js\";\nScene.prototype.enableDepthRenderer = function (camera, storeNonLinearDepth = false, force32bitsFloat = false, samplingMode = 3, storeCameraSpaceZ = false) {\n camera = camera || this.activeCamera;\n if (!camera) {\n // eslint-disable-next-line no-throw-literal\n throw \"No camera available to enable depth renderer\";\n }\n if (!this._depthRenderer) {\n this._depthRenderer = {};\n }\n if (!this._depthRenderer[camera.id]) {\n const supportFullfloat = !!this.getEngine().getCaps().textureFloatRender;\n let textureType = 0;\n if (this.getEngine().getCaps().textureHalfFloatRender && (!force32bitsFloat || !supportFullfloat)) {\n textureType = 2;\n }\n else if (supportFullfloat) {\n textureType = 1;\n }\n else {\n textureType = 0;\n }\n this._depthRenderer[camera.id] = new DepthRenderer(this, textureType, camera, storeNonLinearDepth, samplingMode, storeCameraSpaceZ);\n }\n return this._depthRenderer[camera.id];\n};\nScene.prototype.disableDepthRenderer = function (camera) {\n camera = camera || this.activeCamera;\n if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {\n return;\n }\n this._depthRenderer[camera.id].dispose();\n};\n/**\n * Defines the Depth Renderer scene component responsible to manage a depth buffer useful\n * in several rendering techniques.\n */\nexport class DepthRendererSceneComponent {\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_DEPTHRENDERER;\n this.scene = scene;\n }\n /**\n * Registers the component in a given scene\n */\n register() {\n this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);\n this.scene._gatherActiveCameraRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);\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 for (const key in this.scene._depthRenderer) {\n this.scene._depthRenderer[key].dispose();\n }\n }\n _gatherRenderTargets(renderTargets) {\n if (this.scene._depthRenderer) {\n for (const key in this.scene._depthRenderer) {\n const depthRenderer = this.scene._depthRenderer[key];\n if (depthRenderer.enabled && !depthRenderer.useOnlyInActiveCamera) {\n renderTargets.push(depthRenderer.getDepthMap());\n }\n }\n }\n }\n _gatherActiveCameraRenderTargets(renderTargets) {\n if (this.scene._depthRenderer) {\n for (const key in this.scene._depthRenderer) {\n const depthRenderer = this.scene._depthRenderer[key];\n if (depthRenderer.enabled && depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {\n renderTargets.push(depthRenderer.getDepthMap());\n }\n }\n }\n }\n}\nDepthRenderer._SceneComponentInitialization = (scene) => {\n // Register the G Buffer component to the scene.\n let component = scene._getComponent(SceneComponentConstants.NAME_DEPTHRENDERER);\n if (!component) {\n component = new DepthRendererSceneComponent(scene);\n scene._addComponent(component);\n }\n};\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAa;AACnC,SAASC,aAAa,QAAQ,oBAAoB;AAElD,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9DF,KAAK,CAACG,SAAS,CAACC,mBAAmB,GAAG,UAAUC,MAAM,EAAEC,mBAAmB,GAAG,KAAK,EAAEC,gBAAgB,GAAG,KAAK,EAAEC,YAAY,GAAG,CAAC,EAAEC,iBAAiB,GAAG,KAAK,EAAE;EACxJJ,MAAM,GAAGA,MAAM,IAAI,IAAI,CAACK,YAAY;EACpC,IAAI,CAACL,MAAM,EAAE;IACT;IACA,MAAM,8CAA8C;EACxD;EACA,IAAI,CAAC,IAAI,CAACM,cAAc,EAAE;IACtB,IAAI,CAACA,cAAc,GAAG,CAAC,CAAC;EAC5B;EACA,IAAI,CAAC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