@roomle/web-sdk 3.6.0-alpha.2 → 3.6.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BufferGeometry-DLEagG41.mjs +1022 -0
- package/lib/BufferGeometry-DLEagG41.mjs.map +1 -0
- package/lib/ConfiguratorKernel.js +2 -2
- package/lib/ConfiguratorKernel.wasm +0 -0
- package/lib/GLTFExporter-D8qsdwDK.mjs +1092 -0
- package/lib/GLTFExporter-D8qsdwDK.mjs.map +1 -0
- package/lib/Object3D-DSjIOhON.mjs +1713 -0
- package/lib/Object3D-DSjIOhON.mjs.map +1 -0
- package/lib/PointLightHelper-BnjxGaOG.mjs +257 -0
- package/lib/PointLightHelper-BnjxGaOG.mjs.map +1 -0
- package/lib/RoomleCore.js +4 -4
- package/lib/RoomleCore.wasm +0 -0
- package/lib/RoomleToolsCore.wasm +0 -0
- package/lib/SpotLightHelper-DqsfqCrs.mjs +154 -0
- package/lib/SpotLightHelper-DqsfqCrs.mjs.map +1 -0
- package/lib/USDZExporter-DxIqi8St.mjs +296 -0
- package/lib/USDZExporter-DxIqi8St.mjs.map +1 -0
- package/lib/Vector4-DGmBYfpK.mjs +204 -0
- package/lib/Vector4-DGmBYfpK.mjs.map +1 -0
- package/lib/api-CNoIBuvr.mjs +55 -0
- package/lib/api-CNoIBuvr.mjs.map +1 -0
- package/lib/asset-loader.worker.js +1 -1
- package/lib/banana-for-scale-C_iNmlCT.mjs +36 -0
- package/lib/banana-for-scale-C_iNmlCT.mjs.map +1 -0
- package/lib/common-utils-DMSTohiS.mjs +187 -0
- package/lib/common-utils-DMSTohiS.mjs.map +1 -0
- package/lib/component-dimensioning-CvRmUja4.mjs +162 -0
- package/lib/component-dimensioning-CvRmUja4.mjs.map +1 -0
- package/lib/component-raycast-helper-CEp7wy9c.mjs +97 -0
- package/lib/component-raycast-helper-CEp7wy9c.mjs.map +1 -0
- package/lib/configurator-B_5XVG2O.mjs +45 -0
- package/lib/configurator-B_5XVG2O.mjs.map +1 -0
- package/lib/configurator-DCdvMM0o.mjs +2 -0
- package/lib/continuous-drawing-helper-v_5UAM9A.mjs +42 -0
- package/lib/continuous-drawing-helper-v_5UAM9A.mjs.map +1 -0
- package/lib/decorate-C1QnXPYw.mjs +35 -0
- package/lib/decorate-C1QnXPYw.mjs.map +1 -0
- package/lib/dimensioning-helper-DTcW85Oq.mjs +2 -0
- package/lib/dimensioning-helper-Fwpt1HTT.mjs +268 -0
- package/lib/dimensioning-helper-Fwpt1HTT.mjs.map +1 -0
- package/lib/fflate.module-dFNj5UPI.mjs +536 -0
- package/lib/fflate.module-dFNj5UPI.mjs.map +1 -0
- package/lib/glb-viewer-cP8g6bcm.mjs +315 -0
- package/lib/glb-viewer-cP8g6bcm.mjs.map +1 -0
- package/lib/glb-viewer-dZThmlwM.mjs +2 -0
- package/lib/homag-intelligence-LoOJ7roM.mjs +381 -0
- package/lib/homag-intelligence-LoOJ7roM.mjs.map +1 -0
- package/lib/imos-ix-poc-export-helper-CQh94HsO.mjs +161 -0
- package/lib/imos-ix-poc-export-helper-CQh94HsO.mjs.map +1 -0
- package/lib/kernel-BAQSG9r5.mjs +46 -0
- package/lib/kernel-BAQSG9r5.mjs.map +1 -0
- package/lib/kernel-utils-H74uNY1h.mjs +44 -0
- package/lib/kernel-utils-H74uNY1h.mjs.map +1 -0
- package/lib/layer-C_JtkhdO.mjs +8 -0
- package/lib/layer-C_JtkhdO.mjs.map +1 -0
- package/lib/main-BxEZ11ag.mjs +20461 -0
- package/lib/main-BxEZ11ag.mjs.map +1 -0
- package/lib/material-viewer-njBFF0Zg.mjs +292 -0
- package/lib/material-viewer-njBFF0Zg.mjs.map +1 -0
- package/lib/planner-Cr495Cyn.mjs +2 -0
- package/lib/planner-DY73rplC.mjs +44 -0
- package/lib/planner-DY73rplC.mjs.map +1 -0
- package/lib/plugin-system-D9K46xJk.mjs +55 -0
- package/lib/plugin-system-D9K46xJk.mjs.map +1 -0
- package/lib/roomle-sdk.d.ts +302 -134
- package/lib/roomle-sdk.js +7 -36
- package/lib/scene-renderer-D8HkTFeZ.mjs +3826 -0
- package/lib/scene-renderer-D8HkTFeZ.mjs.map +1 -0
- package/lib/script-loader-KBq8SjP6.mjs +45 -0
- package/lib/script-loader-KBq8SjP6.mjs.map +1 -0
- package/lib/static/draco/node_modules/three/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/lib/static/draco/node_modules/three/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/lib/static/draco/node_modules/three/examples/jsm/libs/draco/draco_encoder.js +33 -0
- package/lib/static/draco/node_modules/three/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/lib/static/packages/workers/generated/asset-loader.worker.js +1 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -0
- package/lib/static/roomle-core-hsc/{configuratorCore.d.ts → node_modules/roomle-core-hsc/src/embind/configuratorCore.d.ts} +1 -2
- package/lib/static/roomle-core-hsc/{configuratorCoreInterface.d.ts → node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts} +22 -29
- package/lib/static/roomle-core-hsc/{src → node_modules/roomle-core-hsc/src}/embind/plannerCore.d.ts +1 -2
- package/lib/static/roomle-core-hsc/{src → node_modules/roomle-core-hsc/src}/embind/plannerCoreCallback.d.ts +1 -1
- package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/plannerCoreCallback.js +1 -1
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreCallback.js.map +1 -0
- package/lib/static/roomle-core-hsc/{plannerCoreInterface.d.ts → node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts} +76 -81
- package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/plannerCoreInterface.js +1 -6
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -0
- package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/configurableObject.d.ts +2 -2
- package/lib/static/roomle-core-hsc/{src → node_modules/roomle-core-hsc/src}/loader/configurableObject.js +6 -6
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/loader/configurableObject.js.map +1 -0
- package/lib/static/roomle-core-hsc/{src → node_modules/roomle-core-hsc/src}/loader/configurationLoader.js +1 -5
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/loader/configurationLoader.js.map +1 -0
- package/lib/static/roomle-core-hsc/{configurationManager.d.ts → node_modules/roomle-core-hsc/src/loader/configurationManager.d.ts} +1 -0
- package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/configurationManager.js +6 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/loader/configurationManager.js.map +1 -0
- package/lib/static/roomle-core-hsc/{src → node_modules/roomle-core-hsc/src}/loader/planElementManager.d.ts +2 -2
- package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/planElementManager.js.map +1 -1
- package/lib/static/roomle-core-hsc/{wasm_modern → node_modules/roomle-core-hsc/wasm_modern}/ConfiguratorKernel.js +2 -2
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/{wasm_modern → node_modules/roomle-core-hsc/wasm_modern}/RoomleCore.js +4 -4
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/stats-helper-HM0TaIM5.mjs +95 -0
- package/lib/stats-helper-HM0TaIM5.mjs.map +1 -0
- package/lib/three.core-CLIofecG.mjs +7629 -0
- package/lib/three.core-CLIofecG.mjs.map +1 -0
- package/lib/three.module-C4Q1skJQ.mjs +5795 -0
- package/lib/three.module-C4Q1skJQ.mjs.map +1 -0
- package/lib/three.webgpu-dFspy2yF.mjs +16057 -0
- package/lib/three.webgpu-dFspy2yF.mjs.map +1 -0
- package/lib/threejs-utils-jEzvlJF1.mjs +2233 -0
- package/lib/threejs-utils-jEzvlJF1.mjs.map +1 -0
- package/lib/tools-core-CZbPygRC.mjs +30 -0
- package/lib/tools-core-CZbPygRC.mjs.map +1 -0
- package/package.json +3 -3
- package/lib/BufferGeometry-BZdSmtHt.mjs +0 -2064
- package/lib/BufferGeometry-BZdSmtHt.mjs.map +0 -1
- package/lib/GLTFExporter-DiE_HuI6.mjs +0 -1286
- package/lib/GLTFExporter-DiE_HuI6.mjs.map +0 -1
- package/lib/PointLightHelper-BvRpTX7D.mjs +0 -522
- package/lib/PointLightHelper-BvRpTX7D.mjs.map +0 -1
- package/lib/SpotLightHelper-Byg39thi.mjs +0 -222
- package/lib/SpotLightHelper-Byg39thi.mjs.map +0 -1
- package/lib/USDZExporter-VBx9xybH.mjs +0 -545
- package/lib/USDZExporter-VBx9xybH.mjs.map +0 -1
- package/lib/banana-for-scale-C9_AyZkI.mjs +0 -50
- package/lib/banana-for-scale-C9_AyZkI.mjs.map +0 -1
- package/lib/component-dimensioning-DHTSa-If.mjs +0 -229
- package/lib/component-dimensioning-DHTSa-If.mjs.map +0 -1
- package/lib/continuous-drawing-helper-BNHRsd4B.mjs +0 -48
- package/lib/continuous-drawing-helper-BNHRsd4B.mjs.map +0 -1
- package/lib/homag-intelligence-BraN723F.mjs +0 -545
- package/lib/homag-intelligence-BraN723F.mjs.map +0 -1
- package/lib/imos-ix-poc-export-helper-D7ubISCJ.mjs +0 -180
- package/lib/imos-ix-poc-export-helper-D7ubISCJ.mjs.map +0 -1
- package/lib/index-C-Prfui2.mjs +0 -73502
- package/lib/index-C-Prfui2.mjs.map +0 -1
- package/lib/material-viewer-DyVGp6Xm.mjs +0 -450
- package/lib/material-viewer-DyVGp6Xm.mjs.map +0 -1
- package/lib/roomle-sdk.js.map +0 -1
- package/lib/static/asset-loader.worker.js +0 -1
- package/lib/static/draco/gltf/draco_decoder.js +0 -33
- package/lib/static/draco/gltf/draco_decoder.wasm +0 -0
- package/lib/static/draco/gltf/draco_encoder.js +0 -33
- package/lib/static/draco/gltf/draco_wasm_wrapper.js +0 -116
- package/lib/static/roomle-core-hsc/ConfiguratorKernel.js +0 -74
- package/lib/static/roomle-core-hsc/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleCore.js +0 -79
- package/lib/static/roomle-core-hsc/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/RoomleToolsCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/configurableObject.d.ts +0 -30
- package/lib/static/roomle-core-hsc/configurableObject.js +0 -111
- package/lib/static/roomle-core-hsc/configurableObject.js.map +0 -1
- package/lib/static/roomle-core-hsc/configurationLoader.js +0 -349
- package/lib/static/roomle-core-hsc/configurationLoader.js.map +0 -1
- package/lib/static/roomle-core-hsc/configurationManager.js +0 -141
- package/lib/static/roomle-core-hsc/configurationManager.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/configuratorCallback.d.ts +0 -82
- package/lib/static/roomle-core-hsc/embind/configuratorCallback.js +0 -355
- package/lib/static/roomle-core-hsc/embind/configuratorCallback.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/configuratorCore.d.ts +0 -20
- package/lib/static/roomle-core-hsc/embind/configuratorCore.js +0 -50
- package/lib/static/roomle-core-hsc/embind/configuratorCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/configuratorCoreInterface.d.ts +0 -753
- package/lib/static/roomle-core-hsc/embind/configuratorCoreInterface.js +0 -99
- package/lib/static/roomle-core-hsc/embind/configuratorCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/configuratorUtils.d.ts +0 -3
- package/lib/static/roomle-core-hsc/embind/configuratorUtils.js +0 -52
- package/lib/static/roomle-core-hsc/embind/configuratorUtils.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/coreModue.d.ts +0 -4
- package/lib/static/roomle-core-hsc/embind/coreModue.js +0 -3
- package/lib/static/roomle-core-hsc/embind/coreModue.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/coreModule.d.ts +0 -11
- package/lib/static/roomle-core-hsc/embind/coreModule.js +0 -19
- package/lib/static/roomle-core-hsc/embind/coreModule.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/plannerCore.d.ts +0 -32
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.d.ts +0 -39
- package/lib/static/roomle-core-hsc/embind/plannerCoreCallback.js.map +0 -1
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.d.ts +0 -858
- package/lib/static/roomle-core-hsc/embind/plannerCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/loader/configurableObject.js +0 -111
- package/lib/static/roomle-core-hsc/loader/configurableObject.js.map +0 -1
- package/lib/static/roomle-core-hsc/loader/configurationGeometryConstructor.d.ts +0 -21
- package/lib/static/roomle-core-hsc/loader/configurationGeometryConstructor.js +0 -90
- package/lib/static/roomle-core-hsc/loader/configurationGeometryConstructor.js.map +0 -1
- package/lib/static/roomle-core-hsc/loader/configurationLoader.d.ts +0 -116
- package/lib/static/roomle-core-hsc/loader/configurationLoader.js +0 -349
- package/lib/static/roomle-core-hsc/loader/configurationLoader.js.map +0 -1
- package/lib/static/roomle-core-hsc/loader/configurationManager.d.ts +0 -40
- package/lib/static/roomle-core-hsc/loader/configurationManager.js.map +0 -1
- package/lib/static/roomle-core-hsc/loader/planElementManager.d.ts +0 -96
- package/lib/static/roomle-core-hsc/loaderUtility.d.ts +0 -81
- package/lib/static/roomle-core-hsc/loaderUtility.js +0 -141
- package/lib/static/roomle-core-hsc/loaderUtility.js.map +0 -1
- package/lib/static/roomle-core-hsc/logger.d.ts +0 -29
- package/lib/static/roomle-core-hsc/logger.js +0 -61
- package/lib/static/roomle-core-hsc/logger.js.map +0 -1
- package/lib/static/roomle-core-hsc/package.json +0 -1
- package/lib/static/roomle-core-hsc/planElementManager.d.ts +0 -96
- package/lib/static/roomle-core-hsc/planElementManager.js +0 -300
- package/lib/static/roomle-core-hsc/planElementManager.js.map +0 -1
- package/lib/static/roomle-core-hsc/plannerCore.d.ts +0 -32
- package/lib/static/roomle-core-hsc/plannerCore.js +0 -111
- package/lib/static/roomle-core-hsc/plannerCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/plannerCoreCallback.d.ts +0 -39
- package/lib/static/roomle-core-hsc/plannerCoreCallback.js +0 -116
- package/lib/static/roomle-core-hsc/plannerCoreCallback.js.map +0 -1
- package/lib/static/roomle-core-hsc/plannerCoreInterface.js +0 -98
- package/lib/static/roomle-core-hsc/plannerCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/rapiAccess.d.ts +0 -70
- package/lib/static/roomle-core-hsc/rapiAccess.js +0 -227
- package/lib/static/roomle-core-hsc/rapiAccess.js.map +0 -1
- package/lib/static/roomle-core-hsc/serviceCore.d.ts +0 -20
- package/lib/static/roomle-core-hsc/serviceCore.js +0 -54
- package/lib/static/roomle-core-hsc/serviceCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/serviceCoreInterface.d.ts +0 -13
- package/lib/static/roomle-core-hsc/serviceCoreInterface.js +0 -3
- package/lib/static/roomle-core-hsc/serviceCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/configuratorCallback.d.ts +0 -82
- package/lib/static/roomle-core-hsc/src/embind/configuratorCallback.js +0 -355
- package/lib/static/roomle-core-hsc/src/embind/configuratorCallback.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/configuratorCore.d.ts +0 -20
- package/lib/static/roomle-core-hsc/src/embind/configuratorCore.js +0 -50
- package/lib/static/roomle-core-hsc/src/embind/configuratorCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts +0 -753
- package/lib/static/roomle-core-hsc/src/embind/configuratorCoreInterface.js +0 -99
- package/lib/static/roomle-core-hsc/src/embind/configuratorCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/configuratorUtils.d.ts +0 -3
- package/lib/static/roomle-core-hsc/src/embind/configuratorUtils.js +0 -52
- package/lib/static/roomle-core-hsc/src/embind/configuratorUtils.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/coreModue.d.ts +0 -4
- package/lib/static/roomle-core-hsc/src/embind/coreModue.js +0 -3
- package/lib/static/roomle-core-hsc/src/embind/coreModue.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/coreModule.d.ts +0 -11
- package/lib/static/roomle-core-hsc/src/embind/coreModule.js +0 -19
- package/lib/static/roomle-core-hsc/src/embind/coreModule.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCore.js +0 -111
- package/lib/static/roomle-core-hsc/src/embind/plannerCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.js +0 -116
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreCallback.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +0 -858
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.js +0 -98
- package/lib/static/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/serviceCore.d.ts +0 -20
- package/lib/static/roomle-core-hsc/src/embind/serviceCore.js +0 -54
- package/lib/static/roomle-core-hsc/src/embind/serviceCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/serviceCoreInterface.d.ts +0 -13
- package/lib/static/roomle-core-hsc/src/embind/serviceCoreInterface.js +0 -3
- package/lib/static/roomle-core-hsc/src/embind/serviceCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/toolsCore.d.ts +0 -17
- package/lib/static/roomle-core-hsc/src/embind/toolsCore.js +0 -75
- package/lib/static/roomle-core-hsc/src/embind/toolsCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/embind/toolsCoreInterface.d.ts +0 -40
- package/lib/static/roomle-core-hsc/src/embind/toolsCoreInterface.js +0 -8
- package/lib/static/roomle-core-hsc/src/embind/toolsCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/configurableObject.d.ts +0 -30
- package/lib/static/roomle-core-hsc/src/loader/configurableObject.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/configurationGeometryConstructor.d.ts +0 -21
- package/lib/static/roomle-core-hsc/src/loader/configurationGeometryConstructor.js +0 -90
- package/lib/static/roomle-core-hsc/src/loader/configurationGeometryConstructor.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/configurationLoader.d.ts +0 -116
- package/lib/static/roomle-core-hsc/src/loader/configurationLoader.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/configurationManager.d.ts +0 -40
- package/lib/static/roomle-core-hsc/src/loader/configurationManager.js +0 -141
- package/lib/static/roomle-core-hsc/src/loader/configurationManager.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/loaderUtility.d.ts +0 -81
- package/lib/static/roomle-core-hsc/src/loader/loaderUtility.js +0 -141
- package/lib/static/roomle-core-hsc/src/loader/loaderUtility.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/logger.d.ts +0 -29
- package/lib/static/roomle-core-hsc/src/loader/logger.js +0 -61
- package/lib/static/roomle-core-hsc/src/loader/logger.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/planElementManager.js +0 -300
- package/lib/static/roomle-core-hsc/src/loader/planElementManager.js.map +0 -1
- package/lib/static/roomle-core-hsc/src/loader/rapiAccess.d.ts +0 -70
- package/lib/static/roomle-core-hsc/src/loader/rapiAccess.js +0 -227
- package/lib/static/roomle-core-hsc/src/loader/rapiAccess.js.map +0 -1
- package/lib/static/roomle-core-hsc/toolsCore.d.ts +0 -17
- package/lib/static/roomle-core-hsc/toolsCore.js +0 -75
- package/lib/static/roomle-core-hsc/toolsCore.js.map +0 -1
- package/lib/static/roomle-core-hsc/toolsCoreInterface.d.ts +0 -40
- package/lib/static/roomle-core-hsc/toolsCoreInterface.js +0 -8
- package/lib/static/roomle-core-hsc/toolsCoreInterface.js.map +0 -1
- package/lib/static/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleToolsCore.js +0 -74
- package/lib/static/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/stats-helper-UQlUyOTj.mjs +0 -108
- package/lib/stats-helper-UQlUyOTj.mjs.map +0 -1
- package/lib/three.webgpu-sHJcp001.mjs +0 -27625
- package/lib/three.webgpu-sHJcp001.mjs.map +0 -1
- package/lib/tools-core-wkPFRdnH.mjs +0 -36
- package/lib/tools-core-wkPFRdnH.mjs.map +0 -1
- /package/lib/static/draco/{README.md → node_modules/three/examples/jsm/libs/draco/README.md} +0 -0
- /package/lib/static/draco/{draco_decoder.js → node_modules/three/examples/jsm/libs/draco/gltf/draco_decoder.js} +0 -0
- /package/lib/static/draco/{draco_decoder.wasm → node_modules/three/examples/jsm/libs/draco/gltf/draco_decoder.wasm} +0 -0
- /package/lib/static/draco/{draco_encoder.js → node_modules/three/examples/jsm/libs/draco/gltf/draco_encoder.js} +0 -0
- /package/lib/static/draco/{draco_wasm_wrapper.js → node_modules/three/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js} +0 -0
- /package/lib/static/{budgeteer.sw.js → packages/workers/generated/budgeteer.sw.js} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCallback.d.ts → node_modules/roomle-core-hsc/src/embind/configuratorCallback.d.ts} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCallback.js → node_modules/roomle-core-hsc/src/embind/configuratorCallback.js} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCallback.js.map → node_modules/roomle-core-hsc/src/embind/configuratorCallback.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCore.js → node_modules/roomle-core-hsc/src/embind/configuratorCore.js} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCore.js.map → node_modules/roomle-core-hsc/src/embind/configuratorCore.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCoreInterface.js → node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorCoreInterface.js.map → node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorUtils.d.ts → node_modules/roomle-core-hsc/src/embind/configuratorUtils.d.ts} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorUtils.js → node_modules/roomle-core-hsc/src/embind/configuratorUtils.js} +0 -0
- /package/lib/static/roomle-core-hsc/{configuratorUtils.js.map → node_modules/roomle-core-hsc/src/embind/configuratorUtils.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{coreModue.d.ts → node_modules/roomle-core-hsc/src/embind/coreModue.d.ts} +0 -0
- /package/lib/static/roomle-core-hsc/{coreModue.js → node_modules/roomle-core-hsc/src/embind/coreModue.js} +0 -0
- /package/lib/static/roomle-core-hsc/{coreModue.js.map → node_modules/roomle-core-hsc/src/embind/coreModue.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{coreModule.d.ts → node_modules/roomle-core-hsc/src/embind/coreModule.d.ts} +0 -0
- /package/lib/static/roomle-core-hsc/{coreModule.js → node_modules/roomle-core-hsc/src/embind/coreModule.js} +0 -0
- /package/lib/static/roomle-core-hsc/{coreModule.js.map → node_modules/roomle-core-hsc/src/embind/coreModule.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/plannerCore.js +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/plannerCore.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/serviceCore.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/serviceCore.js +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/serviceCore.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/serviceCoreInterface.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/serviceCoreInterface.js +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/serviceCoreInterface.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/toolsCore.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/toolsCore.js +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/toolsCore.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/toolsCoreInterface.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/toolsCoreInterface.js +0 -0
- /package/lib/static/roomle-core-hsc/{embind → node_modules/roomle-core-hsc/src/embind}/toolsCoreInterface.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{configurationGeometryConstructor.d.ts → node_modules/roomle-core-hsc/src/loader/configurationGeometryConstructor.d.ts} +0 -0
- /package/lib/static/roomle-core-hsc/{configurationGeometryConstructor.js → node_modules/roomle-core-hsc/src/loader/configurationGeometryConstructor.js} +0 -0
- /package/lib/static/roomle-core-hsc/{configurationGeometryConstructor.js.map → node_modules/roomle-core-hsc/src/loader/configurationGeometryConstructor.js.map} +0 -0
- /package/lib/static/roomle-core-hsc/{configurationLoader.d.ts → node_modules/roomle-core-hsc/src/loader/configurationLoader.d.ts} +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/loaderUtility.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/loaderUtility.js +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/loaderUtility.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/logger.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/logger.js +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/logger.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/planElementManager.js +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/rapiAccess.d.ts +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/rapiAccess.js +0 -0
- /package/lib/static/roomle-core-hsc/{loader → node_modules/roomle-core-hsc/src/loader}/rapiAccess.js.map +0 -0
- /package/lib/static/roomle-core-hsc/{RoomleToolsCore.js → node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.js} +0 -0
|
@@ -0,0 +1,3826 @@
|
|
|
1
|
+
import { $n as e, $t as t, At as n, B as r, Bt as i, Cr as a, Dt as o, E as s, Ft as c, H as l, Hr as u, Ht as d, It as f, Kt as p, Lr as m, M as h, Mt as g, N as _, Nt as v, Or as y, P as b, Pt as x, Rr as S, Rt as C, St as w, U as T, Ut as E, Vt as D, X as O, Xn as ee, Y as te, Zt as k, br as ne, d as re, dr as A, g as j, gt as M, h as N, jr as ie, kr as P, l as ae, lr as F, o as I, p as L, pn as R, qn as oe, tn as se, ur as z, vt as ce, w as le, wr as ue, zr as B } from "./three.core-CLIofecG.mjs";
|
|
2
|
+
import { P as V } from "./threejs-utils-jEzvlJF1.mjs";
|
|
3
|
+
import { h as de } from "./common-utils-DMSTohiS.mjs";
|
|
4
|
+
import { n as fe, r as pe, t as me } from "./decorate-C1QnXPYw.mjs";
|
|
5
|
+
import "./dimensioning-helper-Fwpt1HTT.mjs";
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
|
+
var he = Object.create, H = Object.defineProperty, ge = Object.getOwnPropertyDescriptor, _e = Object.getOwnPropertyNames, ve = Object.getPrototypeOf, ye = Object.prototype.hasOwnProperty, be = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), xe = (e, t) => {
|
|
8
|
+
let n = {};
|
|
9
|
+
for (var r in e) H(n, r, {
|
|
10
|
+
get: e[r],
|
|
11
|
+
enumerable: !0
|
|
12
|
+
});
|
|
13
|
+
return t || H(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
14
|
+
}, Se = (e, t, n, r) => {
|
|
15
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = _e(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ye.call(e, s) && s !== n && H(e, s, {
|
|
16
|
+
get: ((e) => t[e]).bind(null, s),
|
|
17
|
+
enumerable: !(r = ge(t, s)) || r.enumerable
|
|
18
|
+
});
|
|
19
|
+
return e;
|
|
20
|
+
}, Ce = (e, t, n) => (n = e == null ? {} : he(ve(e)), Se(t || !e || !e.__esModule ? H(n, "default", {
|
|
21
|
+
value: e,
|
|
22
|
+
enumerable: !0
|
|
23
|
+
}) : n, e)), we = {
|
|
24
|
+
uniforms: {
|
|
25
|
+
tDiffuse: { value: null },
|
|
26
|
+
colorTransform: { value: new v() },
|
|
27
|
+
colorBase: { value: new B(0, 0, 0, 0) },
|
|
28
|
+
multiplyChannels: { value: 0 },
|
|
29
|
+
uvTransform: { value: new g() }
|
|
30
|
+
},
|
|
31
|
+
vertexShader: "\n varying vec2 vUv;\n uniform mat3 uvTransform;\n\n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",
|
|
32
|
+
fragmentShader: "\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n\n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n #if PREMULTIPLIED_ALPHA == 1\n if (color.a > 0.0) color.rgb /= color.a;\n #endif\n color = colorTransform * color + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n #if LINEAR_TO_SRGB == 1\n color.rgb = mix(color.rgb * 12.92, 1.055 * pow(color.rgb, vec3(0.41666)) - 0.055, step(0.0031308, color.rgb));\n #endif\n gl_FragColor = color;\n }"
|
|
33
|
+
}, Te = new v(), Ee = new v().set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), De = new v().set(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0), Oe = new v().set(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1);
|
|
34
|
+
new v().set(0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), new v().set(0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
35
|
+
var U = new v().set(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1), W = new B(0, 0, 0, 0), G = new B(0, 0, 0, 1), K = new g(), q = new g().set(1, 0, 0, 0, -1, 1, 0, 0, 1), ke = {
|
|
36
|
+
DEFAULT: "default",
|
|
37
|
+
ADDITIVE: "additive"
|
|
38
|
+
}, Ae = class extends z {
|
|
39
|
+
constructor(e, t = ke.ADDITIVE, n = !1, r = !1) {
|
|
40
|
+
let i = t === ke.ADDITIVE ? {
|
|
41
|
+
blendSrc: 208,
|
|
42
|
+
blendDst: 200,
|
|
43
|
+
blendEquation: 100,
|
|
44
|
+
blendSrcAlpha: 206,
|
|
45
|
+
blendDstAlpha: 200,
|
|
46
|
+
blendEquationAlpha: 100
|
|
47
|
+
} : {};
|
|
48
|
+
super({
|
|
49
|
+
uniforms: y.clone(we.uniforms),
|
|
50
|
+
vertexShader: we.vertexShader,
|
|
51
|
+
fragmentShader: we.fragmentShader,
|
|
52
|
+
defines: {
|
|
53
|
+
LINEAR_TO_SRGB: n ? 1 : 0,
|
|
54
|
+
PREMULTIPLIED_ALPHA: r ? 1 : 0
|
|
55
|
+
},
|
|
56
|
+
transparent: !0,
|
|
57
|
+
depthTest: !1,
|
|
58
|
+
depthWrite: !1,
|
|
59
|
+
...i
|
|
60
|
+
}), this.update(e);
|
|
61
|
+
}
|
|
62
|
+
update(e) {
|
|
63
|
+
return e?.texture !== void 0 && (this.uniforms.tDiffuse.value = e?.texture), e?.colorTransform !== void 0 && (this.uniforms.colorTransform.value = e?.colorTransform), e?.colorBase !== void 0 && (this.uniforms.colorBase.value = e?.colorBase), e?.multiplyChannels !== void 0 && (this.uniforms.multiplyChannels.value = e?.multiplyChannels), e?.uvTransform !== void 0 && (this.uniforms.uvTransform.value = e?.uvTransform), e?.blending !== void 0 && (this.blending = e?.blending), e?.blendSrc !== void 0 && (this.blendSrc = e?.blendSrc), e?.blendDst !== void 0 && (this.blendDst = e?.blendDst), e?.blendEquation !== void 0 && (this.blendEquation = e?.blendEquation), e?.blendSrcAlpha !== void 0 && (this.blendSrcAlpha = e?.blendSrcAlpha), e?.blendDstAlpha !== void 0 && (this.blendDstAlpha = e?.blendDstAlpha), e?.blendEquationAlpha !== void 0 && (this.blendEquationAlpha = e?.blendEquationAlpha), this;
|
|
64
|
+
}
|
|
65
|
+
}, je = {
|
|
66
|
+
uniforms: {
|
|
67
|
+
tDiffuse: { value: null },
|
|
68
|
+
rangeMin: { value: new m(1 / 512, 1 / 512) },
|
|
69
|
+
rangeMax: { value: new m(1 / 512, 1 / 512) }
|
|
70
|
+
},
|
|
71
|
+
vertexShader: "\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",
|
|
72
|
+
fragmentShader: "\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n\n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"
|
|
73
|
+
};
|
|
74
|
+
new m(.1, .9), new m(.1, .9);
|
|
75
|
+
var Me = "varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }", Ne = "uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n\n #include <packing>\n\n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n\n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }", Pe = class e extends z {
|
|
76
|
+
static {
|
|
77
|
+
this._linearDepthShader = {
|
|
78
|
+
uniforms: {
|
|
79
|
+
tDepth: { value: null },
|
|
80
|
+
depthFilter: { value: new B(1, 0, 0, 0) },
|
|
81
|
+
cameraNear: { value: .1 },
|
|
82
|
+
cameraFar: { value: 1 }
|
|
83
|
+
},
|
|
84
|
+
defines: {
|
|
85
|
+
PERSPECTIVE_CAMERA: 1,
|
|
86
|
+
ALPHA_DEPTH: 0
|
|
87
|
+
},
|
|
88
|
+
vertexShader: Me,
|
|
89
|
+
fragmentShader: Ne
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
constructor(t) {
|
|
93
|
+
super({
|
|
94
|
+
defines: Object.assign({}, e._linearDepthShader.defines),
|
|
95
|
+
uniforms: y.clone(e._linearDepthShader.uniforms),
|
|
96
|
+
vertexShader: e._linearDepthShader.vertexShader,
|
|
97
|
+
fragmentShader: e._linearDepthShader.fragmentShader,
|
|
98
|
+
blending: 0
|
|
99
|
+
}), this.update(t);
|
|
100
|
+
}
|
|
101
|
+
update(e) {
|
|
102
|
+
if (e?.depthTexture !== void 0 && (this.uniforms.tDepth.value = e?.depthTexture), e?.camera !== void 0) {
|
|
103
|
+
let t = e?.camera || e?.camera;
|
|
104
|
+
this.uniforms.cameraNear.value = t.near, this.uniforms.cameraFar.value = t.far;
|
|
105
|
+
}
|
|
106
|
+
return e?.depthFilter !== void 0 && (this.uniforms.depthFilter.value = e?.depthFilter), this;
|
|
107
|
+
}
|
|
108
|
+
}, Fe = class {
|
|
109
|
+
constructor() {
|
|
110
|
+
this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
|
|
111
|
+
}
|
|
112
|
+
setSize() {}
|
|
113
|
+
render() {
|
|
114
|
+
console.error("THREE.Pass: .render() must be implemented in derived pass.");
|
|
115
|
+
}
|
|
116
|
+
dispose() {}
|
|
117
|
+
}, Ie = new k(-1, 1, 1, -1, 0, 1), Le = new class extends ae {
|
|
118
|
+
constructor() {
|
|
119
|
+
super(), this.setAttribute("position", new l([
|
|
120
|
+
-1,
|
|
121
|
+
3,
|
|
122
|
+
0,
|
|
123
|
+
-1,
|
|
124
|
+
-1,
|
|
125
|
+
0,
|
|
126
|
+
3,
|
|
127
|
+
-1,
|
|
128
|
+
0
|
|
129
|
+
], 3)), this.setAttribute("uv", new l([
|
|
130
|
+
0,
|
|
131
|
+
2,
|
|
132
|
+
0,
|
|
133
|
+
0,
|
|
134
|
+
2,
|
|
135
|
+
0
|
|
136
|
+
], 2));
|
|
137
|
+
}
|
|
138
|
+
}(), Re = class {
|
|
139
|
+
constructor(e) {
|
|
140
|
+
this._mesh = new x(Le, e);
|
|
141
|
+
}
|
|
142
|
+
dispose() {
|
|
143
|
+
this._mesh.geometry.dispose();
|
|
144
|
+
}
|
|
145
|
+
render(e) {
|
|
146
|
+
e.render(this._mesh, Ie);
|
|
147
|
+
}
|
|
148
|
+
get material() {
|
|
149
|
+
return this._mesh.material;
|
|
150
|
+
}
|
|
151
|
+
set material(e) {
|
|
152
|
+
this._mesh.material = e;
|
|
153
|
+
}
|
|
154
|
+
}, ze = class {
|
|
155
|
+
constructor(e = Math) {
|
|
156
|
+
this.grad3 = [
|
|
157
|
+
[
|
|
158
|
+
1,
|
|
159
|
+
1,
|
|
160
|
+
0
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
-1,
|
|
164
|
+
1,
|
|
165
|
+
0
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
1,
|
|
169
|
+
-1,
|
|
170
|
+
0
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
-1,
|
|
174
|
+
-1,
|
|
175
|
+
0
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
1,
|
|
179
|
+
0,
|
|
180
|
+
1
|
|
181
|
+
],
|
|
182
|
+
[
|
|
183
|
+
-1,
|
|
184
|
+
0,
|
|
185
|
+
1
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
1,
|
|
189
|
+
0,
|
|
190
|
+
-1
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
-1,
|
|
194
|
+
0,
|
|
195
|
+
-1
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
0,
|
|
199
|
+
1,
|
|
200
|
+
1
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
0,
|
|
204
|
+
-1,
|
|
205
|
+
1
|
|
206
|
+
],
|
|
207
|
+
[
|
|
208
|
+
0,
|
|
209
|
+
1,
|
|
210
|
+
-1
|
|
211
|
+
],
|
|
212
|
+
[
|
|
213
|
+
0,
|
|
214
|
+
-1,
|
|
215
|
+
-1
|
|
216
|
+
]
|
|
217
|
+
], this.grad4 = [
|
|
218
|
+
[
|
|
219
|
+
0,
|
|
220
|
+
1,
|
|
221
|
+
1,
|
|
222
|
+
1
|
|
223
|
+
],
|
|
224
|
+
[
|
|
225
|
+
0,
|
|
226
|
+
1,
|
|
227
|
+
1,
|
|
228
|
+
-1
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
0,
|
|
232
|
+
1,
|
|
233
|
+
-1,
|
|
234
|
+
1
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
0,
|
|
238
|
+
1,
|
|
239
|
+
-1,
|
|
240
|
+
-1
|
|
241
|
+
],
|
|
242
|
+
[
|
|
243
|
+
0,
|
|
244
|
+
-1,
|
|
245
|
+
1,
|
|
246
|
+
1
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
0,
|
|
250
|
+
-1,
|
|
251
|
+
1,
|
|
252
|
+
-1
|
|
253
|
+
],
|
|
254
|
+
[
|
|
255
|
+
0,
|
|
256
|
+
-1,
|
|
257
|
+
-1,
|
|
258
|
+
1
|
|
259
|
+
],
|
|
260
|
+
[
|
|
261
|
+
0,
|
|
262
|
+
-1,
|
|
263
|
+
-1,
|
|
264
|
+
-1
|
|
265
|
+
],
|
|
266
|
+
[
|
|
267
|
+
1,
|
|
268
|
+
0,
|
|
269
|
+
1,
|
|
270
|
+
1
|
|
271
|
+
],
|
|
272
|
+
[
|
|
273
|
+
1,
|
|
274
|
+
0,
|
|
275
|
+
1,
|
|
276
|
+
-1
|
|
277
|
+
],
|
|
278
|
+
[
|
|
279
|
+
1,
|
|
280
|
+
0,
|
|
281
|
+
-1,
|
|
282
|
+
1
|
|
283
|
+
],
|
|
284
|
+
[
|
|
285
|
+
1,
|
|
286
|
+
0,
|
|
287
|
+
-1,
|
|
288
|
+
-1
|
|
289
|
+
],
|
|
290
|
+
[
|
|
291
|
+
-1,
|
|
292
|
+
0,
|
|
293
|
+
1,
|
|
294
|
+
1
|
|
295
|
+
],
|
|
296
|
+
[
|
|
297
|
+
-1,
|
|
298
|
+
0,
|
|
299
|
+
1,
|
|
300
|
+
-1
|
|
301
|
+
],
|
|
302
|
+
[
|
|
303
|
+
-1,
|
|
304
|
+
0,
|
|
305
|
+
-1,
|
|
306
|
+
1
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
-1,
|
|
310
|
+
0,
|
|
311
|
+
-1,
|
|
312
|
+
-1
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
1,
|
|
316
|
+
1,
|
|
317
|
+
0,
|
|
318
|
+
1
|
|
319
|
+
],
|
|
320
|
+
[
|
|
321
|
+
1,
|
|
322
|
+
1,
|
|
323
|
+
0,
|
|
324
|
+
-1
|
|
325
|
+
],
|
|
326
|
+
[
|
|
327
|
+
1,
|
|
328
|
+
-1,
|
|
329
|
+
0,
|
|
330
|
+
1
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
1,
|
|
334
|
+
-1,
|
|
335
|
+
0,
|
|
336
|
+
-1
|
|
337
|
+
],
|
|
338
|
+
[
|
|
339
|
+
-1,
|
|
340
|
+
1,
|
|
341
|
+
0,
|
|
342
|
+
1
|
|
343
|
+
],
|
|
344
|
+
[
|
|
345
|
+
-1,
|
|
346
|
+
1,
|
|
347
|
+
0,
|
|
348
|
+
-1
|
|
349
|
+
],
|
|
350
|
+
[
|
|
351
|
+
-1,
|
|
352
|
+
-1,
|
|
353
|
+
0,
|
|
354
|
+
1
|
|
355
|
+
],
|
|
356
|
+
[
|
|
357
|
+
-1,
|
|
358
|
+
-1,
|
|
359
|
+
0,
|
|
360
|
+
-1
|
|
361
|
+
],
|
|
362
|
+
[
|
|
363
|
+
1,
|
|
364
|
+
1,
|
|
365
|
+
1,
|
|
366
|
+
0
|
|
367
|
+
],
|
|
368
|
+
[
|
|
369
|
+
1,
|
|
370
|
+
1,
|
|
371
|
+
-1,
|
|
372
|
+
0
|
|
373
|
+
],
|
|
374
|
+
[
|
|
375
|
+
1,
|
|
376
|
+
-1,
|
|
377
|
+
1,
|
|
378
|
+
0
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
1,
|
|
382
|
+
-1,
|
|
383
|
+
-1,
|
|
384
|
+
0
|
|
385
|
+
],
|
|
386
|
+
[
|
|
387
|
+
-1,
|
|
388
|
+
1,
|
|
389
|
+
1,
|
|
390
|
+
0
|
|
391
|
+
],
|
|
392
|
+
[
|
|
393
|
+
-1,
|
|
394
|
+
1,
|
|
395
|
+
-1,
|
|
396
|
+
0
|
|
397
|
+
],
|
|
398
|
+
[
|
|
399
|
+
-1,
|
|
400
|
+
-1,
|
|
401
|
+
1,
|
|
402
|
+
0
|
|
403
|
+
],
|
|
404
|
+
[
|
|
405
|
+
-1,
|
|
406
|
+
-1,
|
|
407
|
+
-1,
|
|
408
|
+
0
|
|
409
|
+
]
|
|
410
|
+
], this.p = [];
|
|
411
|
+
for (let t = 0; t < 256; t++) this.p[t] = Math.floor(e.random() * 256);
|
|
412
|
+
this.perm = [];
|
|
413
|
+
for (let e = 0; e < 512; e++) this.perm[e] = this.p[e & 255];
|
|
414
|
+
this.simplex = [
|
|
415
|
+
[
|
|
416
|
+
0,
|
|
417
|
+
1,
|
|
418
|
+
2,
|
|
419
|
+
3
|
|
420
|
+
],
|
|
421
|
+
[
|
|
422
|
+
0,
|
|
423
|
+
1,
|
|
424
|
+
3,
|
|
425
|
+
2
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
0,
|
|
429
|
+
0,
|
|
430
|
+
0,
|
|
431
|
+
0
|
|
432
|
+
],
|
|
433
|
+
[
|
|
434
|
+
0,
|
|
435
|
+
2,
|
|
436
|
+
3,
|
|
437
|
+
1
|
|
438
|
+
],
|
|
439
|
+
[
|
|
440
|
+
0,
|
|
441
|
+
0,
|
|
442
|
+
0,
|
|
443
|
+
0
|
|
444
|
+
],
|
|
445
|
+
[
|
|
446
|
+
0,
|
|
447
|
+
0,
|
|
448
|
+
0,
|
|
449
|
+
0
|
|
450
|
+
],
|
|
451
|
+
[
|
|
452
|
+
0,
|
|
453
|
+
0,
|
|
454
|
+
0,
|
|
455
|
+
0
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
1,
|
|
459
|
+
2,
|
|
460
|
+
3,
|
|
461
|
+
0
|
|
462
|
+
],
|
|
463
|
+
[
|
|
464
|
+
0,
|
|
465
|
+
2,
|
|
466
|
+
1,
|
|
467
|
+
3
|
|
468
|
+
],
|
|
469
|
+
[
|
|
470
|
+
0,
|
|
471
|
+
0,
|
|
472
|
+
0,
|
|
473
|
+
0
|
|
474
|
+
],
|
|
475
|
+
[
|
|
476
|
+
0,
|
|
477
|
+
3,
|
|
478
|
+
1,
|
|
479
|
+
2
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
0,
|
|
483
|
+
3,
|
|
484
|
+
2,
|
|
485
|
+
1
|
|
486
|
+
],
|
|
487
|
+
[
|
|
488
|
+
0,
|
|
489
|
+
0,
|
|
490
|
+
0,
|
|
491
|
+
0
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
0,
|
|
495
|
+
0,
|
|
496
|
+
0,
|
|
497
|
+
0
|
|
498
|
+
],
|
|
499
|
+
[
|
|
500
|
+
0,
|
|
501
|
+
0,
|
|
502
|
+
0,
|
|
503
|
+
0
|
|
504
|
+
],
|
|
505
|
+
[
|
|
506
|
+
1,
|
|
507
|
+
3,
|
|
508
|
+
2,
|
|
509
|
+
0
|
|
510
|
+
],
|
|
511
|
+
[
|
|
512
|
+
0,
|
|
513
|
+
0,
|
|
514
|
+
0,
|
|
515
|
+
0
|
|
516
|
+
],
|
|
517
|
+
[
|
|
518
|
+
0,
|
|
519
|
+
0,
|
|
520
|
+
0,
|
|
521
|
+
0
|
|
522
|
+
],
|
|
523
|
+
[
|
|
524
|
+
0,
|
|
525
|
+
0,
|
|
526
|
+
0,
|
|
527
|
+
0
|
|
528
|
+
],
|
|
529
|
+
[
|
|
530
|
+
0,
|
|
531
|
+
0,
|
|
532
|
+
0,
|
|
533
|
+
0
|
|
534
|
+
],
|
|
535
|
+
[
|
|
536
|
+
0,
|
|
537
|
+
0,
|
|
538
|
+
0,
|
|
539
|
+
0
|
|
540
|
+
],
|
|
541
|
+
[
|
|
542
|
+
0,
|
|
543
|
+
0,
|
|
544
|
+
0,
|
|
545
|
+
0
|
|
546
|
+
],
|
|
547
|
+
[
|
|
548
|
+
0,
|
|
549
|
+
0,
|
|
550
|
+
0,
|
|
551
|
+
0
|
|
552
|
+
],
|
|
553
|
+
[
|
|
554
|
+
0,
|
|
555
|
+
0,
|
|
556
|
+
0,
|
|
557
|
+
0
|
|
558
|
+
],
|
|
559
|
+
[
|
|
560
|
+
1,
|
|
561
|
+
2,
|
|
562
|
+
0,
|
|
563
|
+
3
|
|
564
|
+
],
|
|
565
|
+
[
|
|
566
|
+
0,
|
|
567
|
+
0,
|
|
568
|
+
0,
|
|
569
|
+
0
|
|
570
|
+
],
|
|
571
|
+
[
|
|
572
|
+
1,
|
|
573
|
+
3,
|
|
574
|
+
0,
|
|
575
|
+
2
|
|
576
|
+
],
|
|
577
|
+
[
|
|
578
|
+
0,
|
|
579
|
+
0,
|
|
580
|
+
0,
|
|
581
|
+
0
|
|
582
|
+
],
|
|
583
|
+
[
|
|
584
|
+
0,
|
|
585
|
+
0,
|
|
586
|
+
0,
|
|
587
|
+
0
|
|
588
|
+
],
|
|
589
|
+
[
|
|
590
|
+
0,
|
|
591
|
+
0,
|
|
592
|
+
0,
|
|
593
|
+
0
|
|
594
|
+
],
|
|
595
|
+
[
|
|
596
|
+
2,
|
|
597
|
+
3,
|
|
598
|
+
0,
|
|
599
|
+
1
|
|
600
|
+
],
|
|
601
|
+
[
|
|
602
|
+
2,
|
|
603
|
+
3,
|
|
604
|
+
1,
|
|
605
|
+
0
|
|
606
|
+
],
|
|
607
|
+
[
|
|
608
|
+
1,
|
|
609
|
+
0,
|
|
610
|
+
2,
|
|
611
|
+
3
|
|
612
|
+
],
|
|
613
|
+
[
|
|
614
|
+
1,
|
|
615
|
+
0,
|
|
616
|
+
3,
|
|
617
|
+
2
|
|
618
|
+
],
|
|
619
|
+
[
|
|
620
|
+
0,
|
|
621
|
+
0,
|
|
622
|
+
0,
|
|
623
|
+
0
|
|
624
|
+
],
|
|
625
|
+
[
|
|
626
|
+
0,
|
|
627
|
+
0,
|
|
628
|
+
0,
|
|
629
|
+
0
|
|
630
|
+
],
|
|
631
|
+
[
|
|
632
|
+
0,
|
|
633
|
+
0,
|
|
634
|
+
0,
|
|
635
|
+
0
|
|
636
|
+
],
|
|
637
|
+
[
|
|
638
|
+
2,
|
|
639
|
+
0,
|
|
640
|
+
3,
|
|
641
|
+
1
|
|
642
|
+
],
|
|
643
|
+
[
|
|
644
|
+
0,
|
|
645
|
+
0,
|
|
646
|
+
0,
|
|
647
|
+
0
|
|
648
|
+
],
|
|
649
|
+
[
|
|
650
|
+
2,
|
|
651
|
+
1,
|
|
652
|
+
3,
|
|
653
|
+
0
|
|
654
|
+
],
|
|
655
|
+
[
|
|
656
|
+
0,
|
|
657
|
+
0,
|
|
658
|
+
0,
|
|
659
|
+
0
|
|
660
|
+
],
|
|
661
|
+
[
|
|
662
|
+
0,
|
|
663
|
+
0,
|
|
664
|
+
0,
|
|
665
|
+
0
|
|
666
|
+
],
|
|
667
|
+
[
|
|
668
|
+
0,
|
|
669
|
+
0,
|
|
670
|
+
0,
|
|
671
|
+
0
|
|
672
|
+
],
|
|
673
|
+
[
|
|
674
|
+
0,
|
|
675
|
+
0,
|
|
676
|
+
0,
|
|
677
|
+
0
|
|
678
|
+
],
|
|
679
|
+
[
|
|
680
|
+
0,
|
|
681
|
+
0,
|
|
682
|
+
0,
|
|
683
|
+
0
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
0,
|
|
687
|
+
0,
|
|
688
|
+
0,
|
|
689
|
+
0
|
|
690
|
+
],
|
|
691
|
+
[
|
|
692
|
+
0,
|
|
693
|
+
0,
|
|
694
|
+
0,
|
|
695
|
+
0
|
|
696
|
+
],
|
|
697
|
+
[
|
|
698
|
+
0,
|
|
699
|
+
0,
|
|
700
|
+
0,
|
|
701
|
+
0
|
|
702
|
+
],
|
|
703
|
+
[
|
|
704
|
+
2,
|
|
705
|
+
0,
|
|
706
|
+
1,
|
|
707
|
+
3
|
|
708
|
+
],
|
|
709
|
+
[
|
|
710
|
+
0,
|
|
711
|
+
0,
|
|
712
|
+
0,
|
|
713
|
+
0
|
|
714
|
+
],
|
|
715
|
+
[
|
|
716
|
+
0,
|
|
717
|
+
0,
|
|
718
|
+
0,
|
|
719
|
+
0
|
|
720
|
+
],
|
|
721
|
+
[
|
|
722
|
+
0,
|
|
723
|
+
0,
|
|
724
|
+
0,
|
|
725
|
+
0
|
|
726
|
+
],
|
|
727
|
+
[
|
|
728
|
+
3,
|
|
729
|
+
0,
|
|
730
|
+
1,
|
|
731
|
+
2
|
|
732
|
+
],
|
|
733
|
+
[
|
|
734
|
+
3,
|
|
735
|
+
0,
|
|
736
|
+
2,
|
|
737
|
+
1
|
|
738
|
+
],
|
|
739
|
+
[
|
|
740
|
+
0,
|
|
741
|
+
0,
|
|
742
|
+
0,
|
|
743
|
+
0
|
|
744
|
+
],
|
|
745
|
+
[
|
|
746
|
+
3,
|
|
747
|
+
1,
|
|
748
|
+
2,
|
|
749
|
+
0
|
|
750
|
+
],
|
|
751
|
+
[
|
|
752
|
+
2,
|
|
753
|
+
1,
|
|
754
|
+
0,
|
|
755
|
+
3
|
|
756
|
+
],
|
|
757
|
+
[
|
|
758
|
+
0,
|
|
759
|
+
0,
|
|
760
|
+
0,
|
|
761
|
+
0
|
|
762
|
+
],
|
|
763
|
+
[
|
|
764
|
+
0,
|
|
765
|
+
0,
|
|
766
|
+
0,
|
|
767
|
+
0
|
|
768
|
+
],
|
|
769
|
+
[
|
|
770
|
+
0,
|
|
771
|
+
0,
|
|
772
|
+
0,
|
|
773
|
+
0
|
|
774
|
+
],
|
|
775
|
+
[
|
|
776
|
+
3,
|
|
777
|
+
1,
|
|
778
|
+
0,
|
|
779
|
+
2
|
|
780
|
+
],
|
|
781
|
+
[
|
|
782
|
+
0,
|
|
783
|
+
0,
|
|
784
|
+
0,
|
|
785
|
+
0
|
|
786
|
+
],
|
|
787
|
+
[
|
|
788
|
+
3,
|
|
789
|
+
2,
|
|
790
|
+
0,
|
|
791
|
+
1
|
|
792
|
+
],
|
|
793
|
+
[
|
|
794
|
+
3,
|
|
795
|
+
2,
|
|
796
|
+
1,
|
|
797
|
+
0
|
|
798
|
+
]
|
|
799
|
+
];
|
|
800
|
+
}
|
|
801
|
+
noise(e, t) {
|
|
802
|
+
let n, r, i, a = .5 * (Math.sqrt(3) - 1), o = (e + t) * a, s = Math.floor(e + o), c = Math.floor(t + o), l = (3 - Math.sqrt(3)) / 6, u = (s + c) * l, d = s - u, f = c - u, p = e - d, m = t - f, h, g;
|
|
803
|
+
p > m ? (h = 1, g = 0) : (h = 0, g = 1);
|
|
804
|
+
let _ = p - h + l, v = m - g + l, y = p - 1 + 2 * l, b = m - 1 + 2 * l, x = s & 255, S = c & 255, C = this.perm[x + this.perm[S]] % 12, w = this.perm[x + h + this.perm[S + g]] % 12, T = this.perm[x + 1 + this.perm[S + 1]] % 12, E = .5 - p * p - m * m;
|
|
805
|
+
E < 0 ? n = 0 : (E *= E, n = E * E * this._dot(this.grad3[C], p, m));
|
|
806
|
+
let D = .5 - _ * _ - v * v;
|
|
807
|
+
D < 0 ? r = 0 : (D *= D, r = D * D * this._dot(this.grad3[w], _, v));
|
|
808
|
+
let O = .5 - y * y - b * b;
|
|
809
|
+
return O < 0 ? i = 0 : (O *= O, i = O * O * this._dot(this.grad3[T], y, b)), 70 * (n + r + i);
|
|
810
|
+
}
|
|
811
|
+
noise3d(e, t, n) {
|
|
812
|
+
let r, i, a, o, s = (e + t + n) * (1 / 3), c = Math.floor(e + s), l = Math.floor(t + s), u = Math.floor(n + s), d = 1 / 6, f = (c + l + u) * d, p = c - f, m = l - f, h = u - f, g = e - p, _ = t - m, v = n - h, y, b, x, S, C, w;
|
|
813
|
+
g >= _ ? _ >= v ? (y = 1, b = 0, x = 0, S = 1, C = 1, w = 0) : g >= v ? (y = 1, b = 0, x = 0, S = 1, C = 0, w = 1) : (y = 0, b = 0, x = 1, S = 1, C = 0, w = 1) : _ < v ? (y = 0, b = 0, x = 1, S = 0, C = 1, w = 1) : g < v ? (y = 0, b = 1, x = 0, S = 0, C = 1, w = 1) : (y = 0, b = 1, x = 0, S = 1, C = 1, w = 0);
|
|
814
|
+
let T = g - y + d, E = _ - b + d, D = v - x + d, O = g - S + 2 * d, ee = _ - C + 2 * d, te = v - w + 2 * d, k = g - 1 + 3 * d, ne = _ - 1 + 3 * d, re = v - 1 + 3 * d, A = c & 255, j = l & 255, M = u & 255, N = this.perm[A + this.perm[j + this.perm[M]]] % 12, ie = this.perm[A + y + this.perm[j + b + this.perm[M + x]]] % 12, P = this.perm[A + S + this.perm[j + C + this.perm[M + w]]] % 12, ae = this.perm[A + 1 + this.perm[j + 1 + this.perm[M + 1]]] % 12, F = .6 - g * g - _ * _ - v * v;
|
|
815
|
+
F < 0 ? r = 0 : (F *= F, r = F * F * this._dot3(this.grad3[N], g, _, v));
|
|
816
|
+
let I = .6 - T * T - E * E - D * D;
|
|
817
|
+
I < 0 ? i = 0 : (I *= I, i = I * I * this._dot3(this.grad3[ie], T, E, D));
|
|
818
|
+
let L = .6 - O * O - ee * ee - te * te;
|
|
819
|
+
L < 0 ? a = 0 : (L *= L, a = L * L * this._dot3(this.grad3[P], O, ee, te));
|
|
820
|
+
let R = .6 - k * k - ne * ne - re * re;
|
|
821
|
+
return R < 0 ? o = 0 : (R *= R, o = R * R * this._dot3(this.grad3[ae], k, ne, re)), 32 * (r + i + a + o);
|
|
822
|
+
}
|
|
823
|
+
noise4d(e, t, n, r) {
|
|
824
|
+
let i = this.grad4, a = this.simplex, o = this.perm, s = (Math.sqrt(5) - 1) / 4, c = (5 - Math.sqrt(5)) / 20, l, u, d, f, p, m = (e + t + n + r) * s, h = Math.floor(e + m), g = Math.floor(t + m), _ = Math.floor(n + m), v = Math.floor(r + m), y = (h + g + _ + v) * c, b = h - y, x = g - y, S = _ - y, C = v - y, w = e - b, T = t - x, E = n - S, D = r - C, O = w > T ? 32 : 0, ee = w > E ? 16 : 0, te = T > E ? 8 : 0, k = w > D ? 4 : 0, ne = T > D ? 2 : 0, re = E > D ? 1 : 0, A = O + ee + te + k + ne + re, j = a[A][0] >= 3 ? 1 : 0, M = a[A][1] >= 3 ? 1 : 0, N = a[A][2] >= 3 ? 1 : 0, ie = a[A][3] >= 3 ? 1 : 0, P = a[A][0] >= 2 ? 1 : 0, ae = a[A][1] >= 2 ? 1 : 0, F = a[A][2] >= 2 ? 1 : 0, I = a[A][3] >= 2 ? 1 : 0, L = a[A][0] >= 1 ? 1 : 0, R = a[A][1] >= 1 ? 1 : 0, oe = a[A][2] >= 1 ? 1 : 0, se = a[A][3] >= 1 ? 1 : 0, z = w - j + c, ce = T - M + c, le = E - N + c, ue = D - ie + c, B = w - P + 2 * c, V = T - ae + 2 * c, de = E - F + 2 * c, fe = D - I + 2 * c, pe = w - L + 3 * c, me = T - R + 3 * c, he = E - oe + 3 * c, H = D - se + 3 * c, ge = w - 1 + 4 * c, _e = T - 1 + 4 * c, ve = E - 1 + 4 * c, ye = D - 1 + 4 * c, be = h & 255, xe = g & 255, Se = _ & 255, Ce = v & 255, we = o[be + o[xe + o[Se + o[Ce]]]] % 32, Te = o[be + j + o[xe + M + o[Se + N + o[Ce + ie]]]] % 32, Ee = o[be + P + o[xe + ae + o[Se + F + o[Ce + I]]]] % 32, De = o[be + L + o[xe + R + o[Se + oe + o[Ce + se]]]] % 32, Oe = o[be + 1 + o[xe + 1 + o[Se + 1 + o[Ce + 1]]]] % 32, U = .6 - w * w - T * T - E * E - D * D;
|
|
825
|
+
U < 0 ? l = 0 : (U *= U, l = U * U * this._dot4(i[we], w, T, E, D));
|
|
826
|
+
let W = .6 - z * z - ce * ce - le * le - ue * ue;
|
|
827
|
+
W < 0 ? u = 0 : (W *= W, u = W * W * this._dot4(i[Te], z, ce, le, ue));
|
|
828
|
+
let G = .6 - B * B - V * V - de * de - fe * fe;
|
|
829
|
+
G < 0 ? d = 0 : (G *= G, d = G * G * this._dot4(i[Ee], B, V, de, fe));
|
|
830
|
+
let K = .6 - pe * pe - me * me - he * he - H * H;
|
|
831
|
+
K < 0 ? f = 0 : (K *= K, f = K * K * this._dot4(i[De], pe, me, he, H));
|
|
832
|
+
let q = .6 - ge * ge - _e * _e - ve * ve - ye * ye;
|
|
833
|
+
return q < 0 ? p = 0 : (q *= q, p = q * q * this._dot4(i[Oe], ge, _e, ve, ye)), 27 * (l + u + d + f + p);
|
|
834
|
+
}
|
|
835
|
+
_dot(e, t, n) {
|
|
836
|
+
return e[0] * t + e[1] * n;
|
|
837
|
+
}
|
|
838
|
+
_dot3(e, t, n, r) {
|
|
839
|
+
return e[0] * t + e[1] * n + e[2] * r;
|
|
840
|
+
}
|
|
841
|
+
_dot4(e, t, n, r, i) {
|
|
842
|
+
return e[0] * t + e[1] * n + e[2] * r + e[3] * i;
|
|
843
|
+
}
|
|
844
|
+
}, Be = (e, t) => {
|
|
845
|
+
e.left = t.min.x, e.right = t.max.x, e.bottom = t.min.y, e.top = t.max.y, e.near = Math.min(-t.min.z, -t.max.z), e.far = Math.max(-t.min.z, -t.max.z), e.updateProjectionMatrix();
|
|
846
|
+
}, Ve = (e, t) => {
|
|
847
|
+
let r = Math.min(-t.min.z, -t.max.z), i = Math.max(-t.min.z, -t.max.z);
|
|
848
|
+
if (r < .001) return;
|
|
849
|
+
let a = Math.max(Math.abs(t.min.x), Math.abs(t.max.x)), o = Math.max(Math.abs(t.min.y), Math.abs(t.max.y));
|
|
850
|
+
e.aspect = a / o, e.fov = n.radToDeg(Math.atan2(o, r) * 2), e.near = r, e.far = i, e.updateProjectionMatrix();
|
|
851
|
+
}, He = class {
|
|
852
|
+
constructor() {
|
|
853
|
+
this.bounds = new I(new S(-1, -1, -1), new S(1, 1, 1)), this.size = new S(2, 2, 2), this.center = new S(0, 0, 0), this.maxSceneDistanceFromCenter = Math.sqrt(3), this.maxSceneDistanceFrom0 = Math.sqrt(3);
|
|
854
|
+
}
|
|
855
|
+
updateFromBox(e) {
|
|
856
|
+
this.bounds !== e && this.bounds.copy(e), this.bounds.getSize(this.size), this.bounds.getCenter(this.center), this.maxSceneDistanceFromCenter = this.size.length() / 2, this.maxSceneDistanceFrom0 = new S(Math.max(Math.abs(this.bounds.min.x), Math.abs(this.bounds.max.x)), Math.max(Math.abs(this.bounds.min.y), Math.abs(this.bounds.max.y)), Math.max(Math.abs(this.bounds.min.z), Math.abs(this.bounds.max.z))).length();
|
|
857
|
+
}
|
|
858
|
+
updateCameraViewVolumeFromBounds(e) {
|
|
859
|
+
e.updateMatrixWorld();
|
|
860
|
+
let n = this.bounds.clone().applyMatrix4(e.matrixWorldInverse);
|
|
861
|
+
e instanceof k ? Be(e, n) : e instanceof t && Ve(e, n);
|
|
862
|
+
}
|
|
863
|
+
getNearAndFarForPerspectiveCamera(e, t = 1) {
|
|
864
|
+
let n = e.clone().sub(this.center).length();
|
|
865
|
+
return [Math.max(.01, n - this.maxSceneDistanceFromCenter - .01), n + this.maxSceneDistanceFromCenter * t + .01];
|
|
866
|
+
}
|
|
867
|
+
}, Ue = (e) => V(e) ? e.capabilities.maxSamples : 16, We = class {
|
|
868
|
+
changed(e) {
|
|
869
|
+
let t = !this._lastCameraProjection?.equals(e.projectionMatrix) || !this._lastCameraWorld?.equals(e.matrixWorld);
|
|
870
|
+
return this._lastCameraProjection = e.projectionMatrix.clone(), this._lastCameraWorld = e.matrixWorld.clone(), t;
|
|
871
|
+
}
|
|
872
|
+
}, Ge = (e) => {
|
|
873
|
+
let t = Math.floor(e) % 2 == 0 ? Math.floor(e) + 1 : Math.floor(e), n = t * t, r = Array(n).fill(0), i = Math.floor(t / 2), a = t - 1;
|
|
874
|
+
for (let e = 1; e <= n;) {
|
|
875
|
+
if (i === -1 && a === t ? (a = t - 2, i = 0) : (a === t && (a = 0), i < 0 && (i = t - 1)), r[i * t + a] !== 0) {
|
|
876
|
+
a -= 2, i++;
|
|
877
|
+
continue;
|
|
878
|
+
} else r[i * t + a] = e++;
|
|
879
|
+
a++, i--;
|
|
880
|
+
}
|
|
881
|
+
return r;
|
|
882
|
+
}, Ke = (t) => {
|
|
883
|
+
let n = new ze(), r = Math.floor(t) % 2 == 0 ? Math.floor(t) + 1 : Math.floor(t), i = Ge(r), a = i.length, o = new Uint8Array(a * 4);
|
|
884
|
+
for (let e = 0; e < a; ++e) {
|
|
885
|
+
let r = i[e], s = 2 * Math.PI * r / a, c = new S(Math.cos(s), Math.sin(s), 0).normalize();
|
|
886
|
+
o[e * 4] = (c.x * .5 + .5) * 255, o[e * 4 + 1] = (c.y * .5 + .5) * 255, o[e * 4 + 2] = 127, o[e * 4 + 3] = (n.noise(e / t, e % t) * .5 + .5) * 255;
|
|
887
|
+
}
|
|
888
|
+
let c = new s(o, r, r);
|
|
889
|
+
return c.wrapS = e, c.wrapT = e, c.needsUpdate = !0, c;
|
|
890
|
+
}, qe = class {
|
|
891
|
+
constructor() {
|
|
892
|
+
this._originalClearColor = new N(), this._originalClearAlpha = 0, this._originalAutoClear = !1, this._originalRenderTarget = null, this._screenSpaceQuad = new Re(void 0), this._emptyScene = new F(), this._defaultCamera = new t();
|
|
893
|
+
}
|
|
894
|
+
renderWithOverrideMaterial(e, t, n, r, i, a, o) {
|
|
895
|
+
this._backup(e), this._prepareRenderer(e, i, a, o);
|
|
896
|
+
let s = t.overrideMaterial;
|
|
897
|
+
t.overrideMaterial = r, e.render(t, n), t.overrideMaterial = s, this._restore(e);
|
|
898
|
+
}
|
|
899
|
+
clear(e, t, n, r) {
|
|
900
|
+
this._backup(e), this._prepareRenderer(e, t, n, r), e.render(this._emptyScene, this._defaultCamera), this._restore(e);
|
|
901
|
+
}
|
|
902
|
+
render(e, t, n, r, i, a) {
|
|
903
|
+
this._backup(e), this._prepareRenderer(e, r, i, a), e.render(t, n), this._restore(e);
|
|
904
|
+
}
|
|
905
|
+
renderScreenSpace(e, t, n, r, i) {
|
|
906
|
+
this._backup(e), this._prepareRenderer(e, n, r, i), this._screenSpaceQuad.material = t, this._screenSpaceQuad.render(e), this._restore(e);
|
|
907
|
+
}
|
|
908
|
+
_prepareRenderer(e, t, n, r) {
|
|
909
|
+
e.setRenderTarget(t), e.autoClear = !1, n != null && (e.setClearColor(n), e.setClearAlpha(r || 0), e.clear());
|
|
910
|
+
}
|
|
911
|
+
_backup(e) {
|
|
912
|
+
e.getClearColor(this._originalClearColor), this._originalClearAlpha = e.getClearAlpha(), this._originalAutoClear = e.autoClear, this._originalRenderTarget = e.getRenderTarget();
|
|
913
|
+
}
|
|
914
|
+
_restore(e) {
|
|
915
|
+
e.setClearColor(this._originalClearColor), e.setClearAlpha(this._originalClearAlpha), e.setRenderTarget(this._originalRenderTarget), e.autoClear = this._originalAutoClear;
|
|
916
|
+
}
|
|
917
|
+
}, Je = class {
|
|
918
|
+
constructor(e, t) {
|
|
919
|
+
this._passRenderer = t?.passRenderer ?? new qe(), this._blurMaterial = new z(e ?? je), this._blurMaterial.depthTest = !1;
|
|
920
|
+
}
|
|
921
|
+
dispose() {
|
|
922
|
+
this._blurMaterial.dispose();
|
|
923
|
+
}
|
|
924
|
+
render(e, t, n, r) {
|
|
925
|
+
this._blurMaterial.uniforms.tDiffuse.value = t[0].texture, this._blurMaterial.uniforms.rangeMin.value.x = n[0], this._blurMaterial.uniforms.rangeMin.value.y = 0, this._blurMaterial.uniforms.rangeMax.value.x = r[0], this._blurMaterial.uniforms.rangeMax.value.y = 0, this._passRenderer.renderScreenSpace(e, this._blurMaterial, t[1]), this._blurMaterial.uniforms.tDiffuse.value = t[1].texture, this._blurMaterial.uniforms.rangeMin.value.x = 0, this._blurMaterial.uniforms.rangeMin.value.y = n[1], this._blurMaterial.uniforms.rangeMax.value.x = 0, this._blurMaterial.uniforms.rangeMax.value.y = r[1], this._passRenderer.renderScreenSpace(e, this._blurMaterial, t[2]);
|
|
926
|
+
}
|
|
927
|
+
}, Ye = class e extends x {
|
|
928
|
+
static {
|
|
929
|
+
this.alphaMap = !0;
|
|
930
|
+
}
|
|
931
|
+
constructor(t, n) {
|
|
932
|
+
super(new se(1, 1, 10, 10), new d({
|
|
933
|
+
color: e.alphaMap ? 0 : 16777215,
|
|
934
|
+
transparent: !0,
|
|
935
|
+
depthWrite: !1,
|
|
936
|
+
polygonOffset: !0,
|
|
937
|
+
name: "ShadowGroundPlaneMaterial"
|
|
938
|
+
})), this.name = "ShadowGroundPlane", this.userData.isFloor = !0, this.renderOrder = 1, this.receiveShadow = !1, this.layers.disableAll(), n && this.updateMaterial(n), this.setShadowMap(t);
|
|
939
|
+
}
|
|
940
|
+
setVisibility(e) {
|
|
941
|
+
this.visible = e, this.setVisibilityLayers(e);
|
|
942
|
+
}
|
|
943
|
+
setVisibilityLayers(e) {
|
|
944
|
+
e ? this.layers.enableAll() : this.layers.disableAll();
|
|
945
|
+
}
|
|
946
|
+
setDepthWrite(e) {
|
|
947
|
+
let t = this.material;
|
|
948
|
+
t.depthWrite = e, t.transparent = !e, t.needsUpdate = !0, this.setVisibility(e);
|
|
949
|
+
}
|
|
950
|
+
setReceiveShadow(e) {
|
|
951
|
+
this.receiveShadow = e, this.setVisibility(e);
|
|
952
|
+
}
|
|
953
|
+
setShadowMap(t) {
|
|
954
|
+
let n = this.material;
|
|
955
|
+
e.alphaMap ? (n.alphaMap = t, n.map = null, n.color.set(0)) : (n.alphaMap = null, n.map = t, n.color.set(16777215)), n.needsUpdate = !0;
|
|
956
|
+
}
|
|
957
|
+
updateMaterial(e) {
|
|
958
|
+
let t = this.material;
|
|
959
|
+
e.opacity && t.opacity !== e.opacity && (t.opacity = e.opacity), e.polygonOffset && t.polygonOffsetFactor !== e.polygonOffset && (t.polygonOffset = !0, t.polygonOffsetFactor = e.polygonOffset, t.polygonOffsetUnits = e.polygonOffset), t.needsUpdate = !0;
|
|
960
|
+
}
|
|
961
|
+
}, J = class extends Fe {
|
|
962
|
+
get renderPassManager() {
|
|
963
|
+
return this._renderPassManager;
|
|
964
|
+
}
|
|
965
|
+
get renderCacheManager() {
|
|
966
|
+
return this._renderPassManager.renderCacheManager;
|
|
967
|
+
}
|
|
968
|
+
get scene() {
|
|
969
|
+
return this._renderPassManager.scene;
|
|
970
|
+
}
|
|
971
|
+
get camera() {
|
|
972
|
+
return this._renderPassManager.camera;
|
|
973
|
+
}
|
|
974
|
+
get gBufferTextures() {
|
|
975
|
+
return this._renderPassManager.gBufferRenderPass;
|
|
976
|
+
}
|
|
977
|
+
get passRenderer() {
|
|
978
|
+
return this._renderPassManager.passRenderer;
|
|
979
|
+
}
|
|
980
|
+
constructor(e) {
|
|
981
|
+
super(), this._renderPassManager = e;
|
|
982
|
+
}
|
|
983
|
+
render(e, t, n, r, i) {
|
|
984
|
+
this.renderPass(e);
|
|
985
|
+
}
|
|
986
|
+
}, Y = {
|
|
987
|
+
INPUT_RGB_NORMAL: "inputRgbNormal",
|
|
988
|
+
FLOAT_BUFFER_NORMAL: "floatBufferNormal",
|
|
989
|
+
CONSTANT_Z: "constantZ"
|
|
990
|
+
}, X = {
|
|
991
|
+
SEPARATE_BUFFER: "separateBuffer",
|
|
992
|
+
NORMAL_VECTOR_ALPHA: "normalVectorAlpha"
|
|
993
|
+
}, Xe = {
|
|
994
|
+
SSAO: 0,
|
|
995
|
+
SAO: 1,
|
|
996
|
+
N8AO: 2,
|
|
997
|
+
HBAO: 3,
|
|
998
|
+
GTAO: 4
|
|
999
|
+
}, Ze = (e, t) => {
|
|
1000
|
+
let n = Qe(e, t), r = "vec4[SAMPLES](";
|
|
1001
|
+
for (let t = 0; t < e; t++) {
|
|
1002
|
+
let i = n[t];
|
|
1003
|
+
r += `vec4(${i.x}, ${i.y}, ${i.z}, ${i.w})${t < e - 1 ? "," : ")"}`;
|
|
1004
|
+
}
|
|
1005
|
+
return r;
|
|
1006
|
+
}, Qe = (e, t) => {
|
|
1007
|
+
let n = [];
|
|
1008
|
+
for (let r = 0; r < e; r++) {
|
|
1009
|
+
let i = r * Math.PI * (3 - Math.sqrt(5)), a = .01 + r / (e - 1) * .99, o = t ? Math.sqrt(1 - a * a) : 1 - a, s = Math.cos(i) * o, c = Math.sin(i) * o, l = Math.floor(e / 4), u = 1 - (Math.floor(r / 4) + r % 4 * l) / e;
|
|
1010
|
+
u = .1 + .9 * u, n.push(new B(s, c, a, u));
|
|
1011
|
+
}
|
|
1012
|
+
return n;
|
|
1013
|
+
}, $e = {
|
|
1014
|
+
name: "AOShader",
|
|
1015
|
+
defines: {
|
|
1016
|
+
PERSPECTIVE_CAMERA: 1,
|
|
1017
|
+
SAMPLES: 16,
|
|
1018
|
+
SAMPLE_VECTORS: Ze(16, !1),
|
|
1019
|
+
NORMAL_VECTOR_TYPE: 1,
|
|
1020
|
+
DEPTH_SWIZZLING: "x",
|
|
1021
|
+
AO_ALGORITHM: Xe.GTAO,
|
|
1022
|
+
NV_ALIGNED_SAMPLES: 1,
|
|
1023
|
+
SCREEN_SPACE_RADIUS: 0,
|
|
1024
|
+
SCREEN_SPACE_RADIUS_SCALE: 100,
|
|
1025
|
+
SCENE_CLIP_BOX: 0,
|
|
1026
|
+
NORMAL_VECTOR_ANTIALIAS: 2,
|
|
1027
|
+
DEPTH_BUFFER_ANTIALIAS: 1
|
|
1028
|
+
},
|
|
1029
|
+
uniforms: {
|
|
1030
|
+
tNormal: { value: null },
|
|
1031
|
+
tDepth: { value: null },
|
|
1032
|
+
tNoise: { value: null },
|
|
1033
|
+
resolution: { value: new m() },
|
|
1034
|
+
cameraNear: { value: null },
|
|
1035
|
+
cameraFar: { value: null },
|
|
1036
|
+
cameraProjectionMatrix: { value: new v() },
|
|
1037
|
+
cameraProjectionMatrixInverse: { value: new v() },
|
|
1038
|
+
cameraWorldMatrix: { value: new v() },
|
|
1039
|
+
radius: { value: 1 },
|
|
1040
|
+
distanceExponent: { value: 1 },
|
|
1041
|
+
thickness: { value: 1 },
|
|
1042
|
+
distanceFallOff: { value: 1 },
|
|
1043
|
+
bias: { value: .001 },
|
|
1044
|
+
scale: { value: 1 },
|
|
1045
|
+
sceneBoxMin: { value: new S(-1, -1, -1) },
|
|
1046
|
+
sceneBoxMax: { value: new S(1, 1, 1) }
|
|
1047
|
+
},
|
|
1048
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
|
|
1049
|
+
fragmentShader: "\n\n varying vec2 vUv;\n uniform highp sampler2D tNormal;\n uniform highp sampler2D tDepth;\n uniform sampler2D tNoise;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraProjectionMatrixInverse;\n uniform mat4 cameraWorldMatrix;\n uniform float radius;\n uniform float distanceExponent;\n uniform float thickness;\n uniform float distanceFallOff;\n uniform float bias;\n uniform float scale;\n #if SCENE_CLIP_BOX == 1\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n #endif\n\n #include <common>\n #include <packing>\n\n #ifndef FRAGMENT_OUTPUT\n #define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n #endif\n\n const vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n float getDepth(const vec2 uv) {\n #if DEPTH_BUFFER_ANTIALIAS == 1\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n vec2 depth = vec2(d0, 1.0);\n float d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n depth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n float d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n depth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n float d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n depth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n float d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n depth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n return depth.x / depth.y;\n #else\n return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n #endif\n }\n\n float fetchDepth(const ivec2 uv) {\n return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n }\n\n vec3 getViewNormal(const vec2 uv) {\n #if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n #elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n #else\n return computeNormalFromDepth(uv);\n #endif\n }\n\n vec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n #if NORMAL_VECTOR_TYPE == 2\n #if NORMAL_VECTOR_ANTIALIAS == 1\n vec2 uv = screenPosition;\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float c0 = texelFetch(tNormal, p, 0).a;\n float l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n float l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n float r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n float r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n float b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n float b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n float t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n float t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n #elif NORMAL_VECTOR_ANTIALIAS == 2\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n vec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n return normalize(normalVector);\n #else\n return texture2D(tNormal, screenPosition).xyz;\n #endif\n #elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n #else\n return computeNormalFromDepth(screenPosition);\n #endif\n }\n\n vec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n float sampleSceneDepth = getDepth(sampleUv);\n return vec3(sampleUv, sampleSceneDepth);\n }\n\n float sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n vec3 delta = point - pointOnPlane;\n float sinV = dot(planeNormal, normalize(delta));\n return sinV;\n }\n\n float getFallOff(float delta, float falloffDistance) {\n float fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n return fallOff;\n }\n\n void main() {\n float depth = getDepth(vUv.xy);\n if (depth >= 1.0) {\n discard;\n return;\n }\n vec3 viewPos = getViewPosition(vUv, depth);\n vec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n float radiusToUse = radius;\n float distanceFalloffToUse = thickness;\n #if SCREEN_SPACE_RADIUS == 1\n float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n radiusToUse *= radiusScale;\n distanceFalloffToUse *= radiusScale;\n #endif\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radiusToUse) {\n discard;\n return;\n }\n #endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n #if NV_ALIGNED_SAMPLES == 1\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n vec3 tangent = normalize(vec3(randomVec.xy, 0.));\n vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n #endif\n\n #if AO_ALGORITHM == 4\n const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n #elif AO_ALGORITHM == 3\n const int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n #else\n const int DIRECTIONS = SAMPLES;\n const int STEPS = 1;\n #endif\n\n float ao = 0.0, totalWeight = 0.0;\n for (int i = 0; i < DIRECTIONS; ++i) {\n\n #if AO_ALGORITHM == 4\n float angle = float(i) / float(DIRECTIONS) * PI;\n vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);\n #elif AO_ALGORITHM == 3\n float angle = float(i) / float(DIRECTIONS) * 2. * PI;\n vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);\n #else\n vec4 sampleDir = sampleKernel[i];\n #endif\n sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n vec3 viewDir = normalize(-viewPos.xyz);\n vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n vec3 sliceTangent = cross(sliceBitangent, viewDir);\n vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\n #if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n #if AO_ALGORITHM == 4\n vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n #else\n vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n #endif\n for (int j = 0; j < STEPS; ++j) {\n vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n vec3 sampleViewPos = viewPos + sampleViewOffset;\n #else\n vec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n #endif\n\n vec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n float sceneSampleDist = abs(sampleSceneViewPos.z);\n float sampleDist = abs(sampleViewPos.z);\n\n #if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n // HBAO || GTAO\n vec3 viewDelta = sampleSceneViewPos - viewPos;\n if (abs(viewDelta.z) < thickness) {\n vec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n float sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n }\n #if AO_ALGORITHM == 4\n sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n viewDelta = sampleSceneViewPos - viewPos;\n if (abs(viewDelta.z) < thickness) {\n vec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n float sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n }\n #endif\n #elif AO_ALGORITHM == 2\n // N8AO\n float weight = dot(viewNormal, sampleDir.xyz);\n float occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n #elif AO_ALGORITHM == 1\n // SAO\n vec3 viewDelta = sampleSceneViewPos - viewPos;\n float minResolution = 0.; // ?\n float scaledViewDist = length( viewDelta ) / scale;\n float weight = 1.;\n float occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n #else\n // SSAO\n float weight = 1.;\n float occlusion = step(sceneSampleDist + bias, sampleDist);\n #endif\n\n #if AO_ALGORITHM == 4\n }\n // GTAO\n vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n float nx = dot(normalInSlice, sliceTangent);\n float ny = dot(normalInSlice, viewDir);\n float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n float occlusion = nx * nxb + ny * nyb;\n ao += occlusion;\n }\n ao = clamp(ao / float(DIRECTIONS), 0., 1.);\n #elif AO_ALGORITHM == 3\n }\n totalWeight += 1.;\n ao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n }\n ao /= totalWeight + 1. - step(0., totalWeight);\n ao = clamp(1. - ao, 0., 1.);\n #else\n\n float fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n occlusion *= fallOff;\n vec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n occlusion *= step(1., dot(diff, diff));\n vec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n occlusion *= clipRangeCheck.x * clipRangeCheck.y;\n weight *= clipRangeCheck.x * clipRangeCheck.y;\n totalWeight += weight;\n ao += occlusion;\n }\n ao /= totalWeight + 1. - step(0., totalWeight);\n ao = clamp(1. - ao, 0., 1.);\n #endif\n\n #if SCENE_CLIP_BOX == 1\n ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n #endif\n #if AO_ALGORITHM != 1\n ao = pow(ao, scale);\n #endif\n gl_FragColor = FRAGMENT_OUTPUT;\n }"
|
|
1050
|
+
}, et = {
|
|
1051
|
+
resolutionScale: 1,
|
|
1052
|
+
algorithm: Xe.SSAO,
|
|
1053
|
+
samples: 32,
|
|
1054
|
+
radius: .25,
|
|
1055
|
+
distanceExponent: 2,
|
|
1056
|
+
thickness: .5,
|
|
1057
|
+
distanceFallOff: .5,
|
|
1058
|
+
scale: 1,
|
|
1059
|
+
bias: .01,
|
|
1060
|
+
screenSpaceRadius: !1
|
|
1061
|
+
}, tt = class {
|
|
1062
|
+
get texture() {
|
|
1063
|
+
return this._renderTarget ? this._renderTarget?.texture : null;
|
|
1064
|
+
}
|
|
1065
|
+
constructor(e, t, n, r, i) {
|
|
1066
|
+
this.needsUpdate = !0, this.parameters = { ...et }, this._width = 0, this._height = 0, this._samples = 0, this._gBufferAntiAliasing = !1, this._normalVectorSourceType = Y.FLOAT_BUFFER_NORMAL, this._depthValueSourceType = X.NORMAL_VECTOR_ALPHA, this._modulateRedChannel = !1, this.depthTexture = null, this.normalTexture = null, this._noiseTexture = null, this._renderTarget = null, this._passRenderer = new qe(), this._sceneClipBox = new I(new S(-1, -1, -1), new S(1, 1, 1)), this._sceneScale = 1, this._width = e, this._height = t, this._samples = n, this._gBufferAntiAliasing = r, this._normalVectorSourceType = i?.normalVectorSourceType || Y.FLOAT_BUFFER_NORMAL, this._depthValueSourceType = i?.depthValueSourceType || X.NORMAL_VECTOR_ALPHA, this._modulateRedChannel = i?.modulateRedChannel || !1, i?.aoParameters && (this.parameters = i.aoParameters), i && this.updateTextures(i);
|
|
1067
|
+
}
|
|
1068
|
+
_getNoiseTexture(t = 64) {
|
|
1069
|
+
if (!this._noiseTexture) {
|
|
1070
|
+
let n = new ze(), r = new Uint8Array(t * t * 4);
|
|
1071
|
+
for (let e = 0; e < t; e++) for (let i = 0; i < t; i++) {
|
|
1072
|
+
let a = e, o = i;
|
|
1073
|
+
r[(e * t + i) * 4] = (n.noise(a, o) + 1) * 127.5, r[(e * t + i) * 4 + 1] = (n.noise(a + t, o) + 1) * 127.5, r[(e * t + i) * 4 + 2] = (n.noise(a, o + t) + 1) * 127.5, r[(e * t + i) * 4 + 3] = (n.noise(a + t, o + t) + 1) * 127.5;
|
|
1074
|
+
}
|
|
1075
|
+
this._noiseTexture = new s(r, t, t, R, P), this._noiseTexture.wrapS = e, this._noiseTexture.wrapT = e, this._noiseTexture.needsUpdate = !0;
|
|
1076
|
+
}
|
|
1077
|
+
return this._noiseTexture;
|
|
1078
|
+
}
|
|
1079
|
+
_getMaterial(e, t) {
|
|
1080
|
+
let n = t;
|
|
1081
|
+
return this._aoMaterial || (this._aoMaterial = this._newAoMaterial(), n = !0), n && (this._updateShader(this._aoMaterial, e), this._aoMaterial.needsUpdate = !0), this._updateUniforms(this._aoMaterial, e, n), this._aoMaterial;
|
|
1082
|
+
}
|
|
1083
|
+
_newAoMaterial() {
|
|
1084
|
+
let e = new z({
|
|
1085
|
+
defines: Object.assign({}, $e.defines),
|
|
1086
|
+
uniforms: y.clone($e.uniforms),
|
|
1087
|
+
vertexShader: $e.vertexShader,
|
|
1088
|
+
fragmentShader: $e.fragmentShader,
|
|
1089
|
+
depthTest: !1,
|
|
1090
|
+
depthWrite: !1
|
|
1091
|
+
});
|
|
1092
|
+
return this._modulateRedChannel && (e.blending = 5, e.blendEquation = 103, e.blendEquationAlpha = null, e.blendSrc = 201, e.blendSrcAlpha = null, e.blendDst = 201, e.blendDstAlpha = null), e.defines.FRAGMENT_OUTPUT = this._modulateRedChannel ? "vec4(ao, 1., 1., 1.)" : void 0, e.uniforms.tNoise.value = Ke(5), e;
|
|
1093
|
+
}
|
|
1094
|
+
_updateShader(e, t) {
|
|
1095
|
+
e.defines.PERSPECTIVE_CAMERA = t.isPerspectiveCamera ? 1 : 0, e.defines.SAMPLES = this.parameters.samples, e.defines.SAMPLE_VECTORS = Ze(this.parameters.samples, this.parameters.algorithm === Xe.SSAO), e.defines.NORMAL_VECTOR_TYPE = this._normalVectorSourceType === Y.FLOAT_BUFFER_NORMAL ? 2 : 1, e.defines.DEPTH_SWIZZLING = this._depthValueSourceType === X.NORMAL_VECTOR_ALPHA ? "a" : "x", e.defines.AO_ALGORITHM = this.parameters.algorithm, e.defines.NV_ALIGNED_SAMPLES = this.parameters.algorithm === Xe.HBAO || this.parameters.algorithm === Xe.GTAO ? 0 : 1, e.defines.SCREEN_SPACE_RADIUS = this.parameters.screenSpaceRadius ? 1 : 0, e.defines.SCENE_CLIP_BOX = 1, e.defines.NORMAL_VECTOR_ANTIALIAS = this._gBufferAntiAliasing ? 2 : 0, e.defines.DEPTH_BUFFER_ANTIALIAS = this._gBufferAntiAliasing ? 1 : 0;
|
|
1096
|
+
}
|
|
1097
|
+
_updateUniforms(e, t, n) {
|
|
1098
|
+
let r = this.parameters.screenSpaceRadius ? 1 : this._sceneScale, i = this._depthValueSourceType === X.NORMAL_VECTOR_ALPHA ? this.normalTexture : this.depthTexture;
|
|
1099
|
+
e.uniforms.tNormal.value = this.normalTexture, e.uniforms.tDepth.value = i, e.uniforms.resolution.value.set(this._width, this._height), e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix), e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse), e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld);
|
|
1100
|
+
let a = t;
|
|
1101
|
+
e.uniforms.cameraNear.value = a.near, e.uniforms.cameraFar.value = a.far, n && (e.uniforms.radius.value = this.parameters.radius * r, e.uniforms.distanceExponent.value = this.parameters.distanceExponent, e.uniforms.thickness.value = this.parameters.thickness * r, e.uniforms.distanceFallOff.value = this.parameters.distanceFallOff, e.uniforms.scale.value = this.parameters.scale, this._sceneClipBox && (e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min), e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)));
|
|
1102
|
+
}
|
|
1103
|
+
_getRenderTargets() {
|
|
1104
|
+
return this._renderTarget ||= new u(this._width, this._height, {
|
|
1105
|
+
samples: this._samples,
|
|
1106
|
+
magFilter: this._samples > 1 ? w : p,
|
|
1107
|
+
minFilter: this._samples > 1 ? w : p
|
|
1108
|
+
}), this._renderTarget;
|
|
1109
|
+
}
|
|
1110
|
+
dispose() {
|
|
1111
|
+
this._noiseTexture?.dispose(), this._aoMaterial?.dispose(), this._renderTarget?.dispose();
|
|
1112
|
+
}
|
|
1113
|
+
setSize(e, t) {
|
|
1114
|
+
this._width = e, this._height = t, this._renderTarget?.setSize(e, t), this.needsUpdate = !0;
|
|
1115
|
+
}
|
|
1116
|
+
updateBounds(e, t) {
|
|
1117
|
+
this._sceneClipBox = new I().copy(e), this._sceneScale = t ?? 1, this.needsUpdate = !0;
|
|
1118
|
+
}
|
|
1119
|
+
updateParameters(e) {
|
|
1120
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t], this.needsUpdate = !0);
|
|
1121
|
+
}
|
|
1122
|
+
updateTextures(e) {
|
|
1123
|
+
e.depthTexture && (this.depthTexture = e.depthTexture, this.needsUpdate = !0), e.normalTexture && (this.normalTexture = e.normalTexture, this.needsUpdate = !0);
|
|
1124
|
+
}
|
|
1125
|
+
clear(e, t) {
|
|
1126
|
+
this._passRenderer.clear(e, t || this._getRenderTargets(), 16777215, 1);
|
|
1127
|
+
}
|
|
1128
|
+
render(e, t, n, r) {
|
|
1129
|
+
let i = this._getMaterial(t, this.needsUpdate);
|
|
1130
|
+
this.needsUpdate = !1, this._passRenderer.renderScreenSpace(e, i, r || this._getRenderTargets());
|
|
1131
|
+
}
|
|
1132
|
+
}, nt = {
|
|
1133
|
+
uniforms: {
|
|
1134
|
+
tDiffuse: { value: null },
|
|
1135
|
+
intensity: { value: new m(1, 1) }
|
|
1136
|
+
},
|
|
1137
|
+
vertexShader: "\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",
|
|
1138
|
+
fragmentShader: "\n uniform sampler2D tDiffuse;\n uniform vec2 intensity;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(tDiffuse, vUv);\n vec2 aoAndShadow = vec2(1.0) - intensity + intensity * textureColor.rg;\n gl_FragColor = vec4(vec3(aoAndShadow.r * aoAndShadow.g), 1.0);\n }"
|
|
1139
|
+
}, rt = class extends z {
|
|
1140
|
+
constructor(e) {
|
|
1141
|
+
super({
|
|
1142
|
+
uniforms: y.clone(nt.uniforms),
|
|
1143
|
+
vertexShader: nt.vertexShader,
|
|
1144
|
+
fragmentShader: nt.fragmentShader,
|
|
1145
|
+
transparent: !0,
|
|
1146
|
+
depthTest: !1,
|
|
1147
|
+
depthWrite: !1,
|
|
1148
|
+
blendSrc: 208,
|
|
1149
|
+
blendDst: 200,
|
|
1150
|
+
blendEquation: 100,
|
|
1151
|
+
blendSrcAlpha: 206,
|
|
1152
|
+
blendDstAlpha: 200,
|
|
1153
|
+
blendEquationAlpha: 100
|
|
1154
|
+
}), this._intensity = new m(1, 1), this.uniforms.intensity.value = this._intensity, this.update(e);
|
|
1155
|
+
}
|
|
1156
|
+
update(e) {
|
|
1157
|
+
return e?.texture !== void 0 && (this.uniforms.tDiffuse.value = e.texture), e?.blending !== void 0 && (this.blending = e.blending), e?.aoIntensity !== void 0 && (this._intensity.x = e.aoIntensity), e?.shadowIntensity !== void 0 && (this._intensity.y = e.shadowIntensity), this;
|
|
1158
|
+
}
|
|
1159
|
+
}, it = (e, t, n, r) => {
|
|
1160
|
+
let i = at(e, t, n, r), a = "vec3[SAMPLES](";
|
|
1161
|
+
for (let t = 0; t < e; t++) {
|
|
1162
|
+
let n = i[t];
|
|
1163
|
+
a += `vec3(${n.x}, ${n.y}, ${n.z})${t < e - 1 ? "," : ")"}`;
|
|
1164
|
+
}
|
|
1165
|
+
return a;
|
|
1166
|
+
}, at = (e, t, n, r) => {
|
|
1167
|
+
let i = [];
|
|
1168
|
+
for (let a = 0; a < e; a++) {
|
|
1169
|
+
let o = 2 * Math.PI * t * a / e, s = (1 + (n - 1) * (a / (e - 1)) ** r) / n;
|
|
1170
|
+
i.push(new S(Math.cos(o), Math.sin(o), s));
|
|
1171
|
+
}
|
|
1172
|
+
return i;
|
|
1173
|
+
}, ot = {
|
|
1174
|
+
name: "PoissonDenoiseShader",
|
|
1175
|
+
defines: {
|
|
1176
|
+
SAMPLES: 16,
|
|
1177
|
+
SAMPLE_VECTORS: it(16, 2.89, 4, 1.3),
|
|
1178
|
+
NV_ALIGNED_SAMPLES: 0,
|
|
1179
|
+
SAMPLE_DISTRIBUTION: 0,
|
|
1180
|
+
DEPTH_VALUE_SOURCE: 0,
|
|
1181
|
+
LUMINANCE_WEIGHTED: 1,
|
|
1182
|
+
LUMINANCE_TYPE: "float",
|
|
1183
|
+
SAMPLE_LUMINANCE: "dot(vec3(0.2125, 0.7154, 0.0721), a)",
|
|
1184
|
+
SCENE_CLIP_BOX: 0,
|
|
1185
|
+
FRAGMENT_OUTPUT: "vec4(vec3(denoised), 1.)"
|
|
1186
|
+
},
|
|
1187
|
+
uniforms: {
|
|
1188
|
+
tDiffuse: { value: null },
|
|
1189
|
+
tNormal: { value: null },
|
|
1190
|
+
tDepth: { value: null },
|
|
1191
|
+
tNoise: { value: null },
|
|
1192
|
+
resolution: { value: new m() },
|
|
1193
|
+
cameraProjectionMatrix: { value: new v() },
|
|
1194
|
+
cameraProjectionMatrixInverse: { value: new v() },
|
|
1195
|
+
cameraWorldMatrix: { value: new v() },
|
|
1196
|
+
lumaPhi: { value: 5 },
|
|
1197
|
+
depthPhi: { value: 1 },
|
|
1198
|
+
normalPhi: { value: 1 },
|
|
1199
|
+
radius: { value: 10 },
|
|
1200
|
+
radiusExponent: { value: 1.3 },
|
|
1201
|
+
iteration: { value: 0 },
|
|
1202
|
+
noOfIterations: { value: 2 },
|
|
1203
|
+
sceneBoxMin: { value: new S(-1, -1, -1) },
|
|
1204
|
+
sceneBoxMax: { value: new S(1, 1, 1) }
|
|
1205
|
+
},
|
|
1206
|
+
vertexShader: "\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
|
1207
|
+
fragmentShader: "\nvarying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tDepth;\nuniform sampler2D tNoise;\nuniform vec2 resolution;\nuniform mat4 cameraProjectionMatrix;\nuniform mat4 cameraProjectionMatrixInverse;\nuniform mat4 cameraWorldMatrix;\nuniform float lumaPhi;\nuniform float depthPhi;\nuniform float normalPhi;\nuniform float radius;\nuniform float radiusExponent;\nuniform int iteration;\nuniform int noOfIterations;\n#if SCENE_CLIP_BOX == 1\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\n\n#include <common>\n#include <packing>\n\n#if LUMINANCE_WEIGHTED == 1 \n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n#define WEIGHT_TYPE LUMINANCE_TYPE\n\n#else\n#define WEIGHT_TYPE float\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(vec3(denoised), 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout WEIGHT_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n float depthDiff = abs(dot(normalize(viewPos - viewPosSample), viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n #if LUMINANCE_WEIGHTED == 1 \n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n #else\n WEIGHT_TYPE w = depthSimilarity * normalSimilarity;\n #endif\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = fetchDepth(ivec2(vec2(textureSize(tDepth, 0)) * vUv.xy)); \n vec3 viewNormal = getViewNormal(vUv); \n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radius * 2.) {\n discard;\n return;\n }\n #endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[iteration % 4] * 2. * PI), cos(noiseTexel[iteration % 4] * 2. * PI));\n #if SAMPLE_DISTRIBUTION == 1\n vec3 randomVec = normalize(vec3(noiseVec.xy, 0.));\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n #endif\n\n WEIGHT_TYPE totalWeight = WEIGHT_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SAMPLE_DISTRIBUTION == 1\n vec3 offsetViewPos = viewPos + normalize(kernelMatrix * vec3(sampleDir.xy, 0.)) * sampleDir.z * radius * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #else\n vec2 offset = rotationMatrix * sampleDir.xy * (1. + sampleDir.z * (radius - 1.));\n offset *= mix(vec2(1.0), sqrt(1.0 - viewNormal.xy * viewNormal.xy), float(iteration) / float(noOfIterations-1));\n offset *= max(1.0, 1.0 / length(offset));\n vec2 sampleUv = vUv + offset / resolution;\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = FRAGMENT_OUTPUT;\n}"
|
|
1208
|
+
}, st = {
|
|
1209
|
+
iterations: 2,
|
|
1210
|
+
samples: 16,
|
|
1211
|
+
rings: 2.89,
|
|
1212
|
+
radiusExponent: 1.3,
|
|
1213
|
+
radius: 4,
|
|
1214
|
+
lumaPhi: 10,
|
|
1215
|
+
depthPhi: 2.5,
|
|
1216
|
+
normalPhi: .5,
|
|
1217
|
+
nvOrientatedSamples: !1
|
|
1218
|
+
}, ct = class {
|
|
1219
|
+
get texture() {
|
|
1220
|
+
return this.parameters.iterations > 0 && this._renderTargets.length > 0 ? this._renderTargets[this._outputRenderTargetIndex].texture : this._inputTexture;
|
|
1221
|
+
}
|
|
1222
|
+
set inputTexture(e) {
|
|
1223
|
+
this._inputTexture = e;
|
|
1224
|
+
}
|
|
1225
|
+
constructor(e, t, n, r) {
|
|
1226
|
+
this.needsUpdate = !0, this.parameters = { ...st }, this._width = 0, this._height = 0, this._samples = 0, this._normalVectorSourceType = Y.FLOAT_BUFFER_NORMAL, this._depthValueSourceType = X.NORMAL_VECTOR_ALPHA, this._inputTexture = null, this.depthTexture = null, this.normalTexture = null, this._noiseTexture = null, this._renderTargets = [], this._outputRenderTargetIndex = 0, this._passRenderer = new qe(), this._rgInputTexture = !1, this._luminanceWeighted = !0, this._width = e, this._height = t, this._samples = n, this._normalVectorSourceType = r?.normalVectorSourceType || Y.FLOAT_BUFFER_NORMAL, this._depthValueSourceType = r?.depthValueSourceType || X.NORMAL_VECTOR_ALPHA, this._inputTexture = r?.inputTexture || null, this.depthTexture = r?.depthTexture || null, this.normalTexture = r?.normalTexture || null, this._rgInputTexture = r?.rgInputTexture || !1, this._luminanceWeighted = r?.luminanceWeighted === !0, this._luminanceType = r?.luminanceType || "vec3", this._sampleLuminance = r?.sampleLuminance || "a", this._fragmentOutput = r?.fragmentOutput || "vec4(denoised.xyz, 1.)", r?.poissonDenoisePassParameters && (this.parameters = r.poissonDenoisePassParameters), r && this.updateTextures(r);
|
|
1227
|
+
}
|
|
1228
|
+
_getNoiseTexture(t = 64) {
|
|
1229
|
+
if (!this._noiseTexture) {
|
|
1230
|
+
let n = new ze(), r = new Uint8Array(t * t * 4);
|
|
1231
|
+
for (let e = 0; e < t; e++) for (let i = 0; i < t; i++) {
|
|
1232
|
+
let a = e, o = i;
|
|
1233
|
+
r[(e * t + i) * 4] = (n.noise(a, o) + 1) * 127.5, r[(e * t + i) * 4 + 1] = (n.noise(a + t, o) + 1) * 127.5, r[(e * t + i) * 4 + 2] = (n.noise(a, o + t) + 1) * 127.5, r[(e * t + i) * 4 + 3] = (n.noise(a + t, o + t) + 1) * 127.5;
|
|
1234
|
+
}
|
|
1235
|
+
this._noiseTexture = new s(r, t, t, R, P), this._noiseTexture.wrapS = e, this._noiseTexture.wrapT = e, this._noiseTexture.needsUpdate = !0;
|
|
1236
|
+
}
|
|
1237
|
+
return this._noiseTexture;
|
|
1238
|
+
}
|
|
1239
|
+
_getMaterial(e, t) {
|
|
1240
|
+
let n = t;
|
|
1241
|
+
return this._pdMaterial || (this._pdMaterial = new z({
|
|
1242
|
+
defines: Object.assign({}, ot.defines),
|
|
1243
|
+
uniforms: y.clone(ot.uniforms),
|
|
1244
|
+
vertexShader: ot.vertexShader,
|
|
1245
|
+
fragmentShader: ot.fragmentShader,
|
|
1246
|
+
depthTest: !1,
|
|
1247
|
+
depthWrite: !1
|
|
1248
|
+
}), this._pdMaterial.uniforms.tNoise.value = this._getNoiseTexture(), n = !0), n && this._updateShader(this._pdMaterial), this._updateUniforms(this._pdMaterial, e, n), this._pdMaterial;
|
|
1249
|
+
}
|
|
1250
|
+
_updateShader(e) {
|
|
1251
|
+
e.defines.SAMPLES = this.parameters.samples, e.defines.SAMPLE_VECTORS = it(this.parameters.samples, this.parameters.rings, this.parameters.radius, this.parameters.radiusExponent), e.defines.SAMPLE_DISTRIBUTION = this.parameters.nvOrientatedSamples ? 1 : 0, e.defines.NORMAL_VECTOR_TYPE = this._normalVectorSourceType === Y.FLOAT_BUFFER_NORMAL ? 2 : 1, e.defines.DEPTH_VALUE_SOURCE = this._depthValueSourceType === X.NORMAL_VECTOR_ALPHA ? 1 : 0, e.needsUpdate = !0, e.defines.LUMINANCE_WEIGHTED = this._luminanceWeighted ? 1 : 0, e.defines.LUMINANCE_TYPE = this._luminanceType, e.defines.SAMPLE_LUMINANCE = this._sampleLuminance, e.defines.FRAGMENT_OUTPUT = this._fragmentOutput, e.defines.SCENE_CLIP_BOX = this._sceneClipBox ? 1 : 0, e.needsUpdate = !0;
|
|
1252
|
+
}
|
|
1253
|
+
_updateUniforms(e, t, n) {
|
|
1254
|
+
let r = this._depthValueSourceType === X.NORMAL_VECTOR_ALPHA ? this.normalTexture : this.depthTexture;
|
|
1255
|
+
e.uniforms.tDiffuse.value = this._inputTexture, e.uniforms.tNormal.value = this.normalTexture, e.uniforms.tDepth.value = r, e.uniforms.resolution.value.set(this._width, this._height), e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix), e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse), e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld), n && (e.uniforms.lumaPhi.value = this.parameters.lumaPhi, e.uniforms.depthPhi.value = this.parameters.depthPhi, e.uniforms.normalPhi.value = this.parameters.normalPhi, e.uniforms.radius.value = this.parameters.radius, e.uniforms.radiusExponent.value = this.parameters.radiusExponent, this._sceneClipBox && (e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min), e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)));
|
|
1256
|
+
}
|
|
1257
|
+
_getRenderTargets() {
|
|
1258
|
+
return this._renderTargets.length < 2 && (this._renderTargets = [new u(this._width, this._height, {
|
|
1259
|
+
samples: this._samples,
|
|
1260
|
+
format: R,
|
|
1261
|
+
type: O,
|
|
1262
|
+
magFilter: p,
|
|
1263
|
+
minFilter: p
|
|
1264
|
+
}), new u(this._width, this._height, {
|
|
1265
|
+
samples: this._samples,
|
|
1266
|
+
format: R,
|
|
1267
|
+
type: O,
|
|
1268
|
+
magFilter: p,
|
|
1269
|
+
minFilter: p
|
|
1270
|
+
})]), this._renderTargets;
|
|
1271
|
+
}
|
|
1272
|
+
dispose() {
|
|
1273
|
+
this._noiseTexture?.dispose(), this._pdMaterial?.dispose(), this._renderTargets.forEach((e) => e.dispose());
|
|
1274
|
+
}
|
|
1275
|
+
setSize(e, t) {
|
|
1276
|
+
this._width = e, this._height = t, this._renderTargets.forEach((n) => n.setSize(e, t)), this.needsUpdate = !0;
|
|
1277
|
+
}
|
|
1278
|
+
updateBounds(e) {
|
|
1279
|
+
this._sceneClipBox = new I().copy(e), this.needsUpdate = !0;
|
|
1280
|
+
}
|
|
1281
|
+
updateParameters(e) {
|
|
1282
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t], this.needsUpdate = !0);
|
|
1283
|
+
}
|
|
1284
|
+
updateTextures(e) {
|
|
1285
|
+
e.inputTexture && (this._inputTexture = e.inputTexture, this.needsUpdate = !0), e.depthTexture && (this.depthTexture = e.depthTexture, this.needsUpdate = !0), e.normalTexture && (this.normalTexture = e.normalTexture, this.needsUpdate = !0);
|
|
1286
|
+
}
|
|
1287
|
+
render(e, t) {
|
|
1288
|
+
let n = this._getMaterial(t, this.needsUpdate);
|
|
1289
|
+
this.needsUpdate = !1;
|
|
1290
|
+
let r = this._getRenderTargets();
|
|
1291
|
+
n.uniforms.iteration.value = this.parameters.iterations;
|
|
1292
|
+
for (let t = 0; t < this.parameters.iterations; t++) {
|
|
1293
|
+
let i = r[(t + 1) % 2];
|
|
1294
|
+
this._outputRenderTargetIndex = t % 2;
|
|
1295
|
+
let a = r[this._outputRenderTargetIndex];
|
|
1296
|
+
n.uniforms.tDiffuse.value = t === 0 ? this._inputTexture : i.texture, n.uniforms.iteration.value = t, this._passRenderer.renderScreenSpace(e, n, a, 16777215, 1);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
renderToTarget(e, t, n) {
|
|
1300
|
+
let r = this._getMaterial(t, this.needsUpdate);
|
|
1301
|
+
this.needsUpdate = !1, this._passRenderer.renderScreenSpace(e, r, n, 16777215, 1);
|
|
1302
|
+
}
|
|
1303
|
+
}, Z = {
|
|
1304
|
+
OFF: "off",
|
|
1305
|
+
HARD: "hard",
|
|
1306
|
+
POISSON: "poisson",
|
|
1307
|
+
FULL: "full"
|
|
1308
|
+
}, lt = { shadowRadius: .05 }, Q = {
|
|
1309
|
+
enabled: !0,
|
|
1310
|
+
applyToMaterial: !0,
|
|
1311
|
+
aoIntensity: .5,
|
|
1312
|
+
shadowIntensity: .35,
|
|
1313
|
+
aoOnGround: !0,
|
|
1314
|
+
shadowOnGround: !1,
|
|
1315
|
+
alwaysUpdate: !1,
|
|
1316
|
+
progressiveDenoiseIterations: 0
|
|
1317
|
+
}, ut = class extends J {
|
|
1318
|
+
static {
|
|
1319
|
+
this.shadowTransform = new v().set(0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1);
|
|
1320
|
+
}
|
|
1321
|
+
get aoAndSoftShadowRenderTarget() {
|
|
1322
|
+
return this._aoAndSoftShadowRenderTarget = this._aoAndSoftShadowRenderTarget ?? new u(this._width, this._height, {
|
|
1323
|
+
samples: this._samples,
|
|
1324
|
+
format: 1030,
|
|
1325
|
+
magFilter: this._samples > 1 ? 1006 : 1003,
|
|
1326
|
+
minFilter: this._samples > 1 ? 1006 : 1003
|
|
1327
|
+
}), this._aoAndSoftShadowRenderTarget;
|
|
1328
|
+
}
|
|
1329
|
+
get aoRenderPass() {
|
|
1330
|
+
return this._aoPass ||= new tt(this._width, this._height, this._samples, !this.parameters.applyToMaterial, {
|
|
1331
|
+
normalVectorSourceType: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? Y.FLOAT_BUFFER_NORMAL : Y.INPUT_RGB_NORMAL,
|
|
1332
|
+
depthValueSourceType: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? X.NORMAL_VECTOR_ALPHA : X.SEPARATE_BUFFER,
|
|
1333
|
+
modulateRedChannel: !0,
|
|
1334
|
+
aoParameters: this.parameters.ao
|
|
1335
|
+
}), this._aoPass;
|
|
1336
|
+
}
|
|
1337
|
+
get softShadowPass() {
|
|
1338
|
+
if (!this._softShadowPass) this._softShadowPass = new ct(this._width, this._height, this._samples, {
|
|
1339
|
+
inputTexture: void 0,
|
|
1340
|
+
depthTexture: this.gBufferTextures.depthBufferTexture,
|
|
1341
|
+
normalTexture: this.gBufferTextures.gBufferTexture,
|
|
1342
|
+
normalVectorSourceType: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? Y.FLOAT_BUFFER_NORMAL : Y.INPUT_RGB_NORMAL,
|
|
1343
|
+
depthValueSourceType: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? X.NORMAL_VECTOR_ALPHA : X.SEPARATE_BUFFER,
|
|
1344
|
+
rgInputTexture: !0,
|
|
1345
|
+
luminanceWeighted: !1,
|
|
1346
|
+
fragmentOutput: "vec4(1.0, denoised.x, 0.0, 1.0)",
|
|
1347
|
+
poissonDenoisePassParameters: {
|
|
1348
|
+
iterations: 1,
|
|
1349
|
+
samples: 16,
|
|
1350
|
+
rings: 2.89,
|
|
1351
|
+
radiusExponent: 1,
|
|
1352
|
+
radius: this.parameters.shadow.shadowRadius,
|
|
1353
|
+
lumaPhi: 10,
|
|
1354
|
+
depthPhi: .1,
|
|
1355
|
+
normalPhi: 4,
|
|
1356
|
+
nvOrientatedSamples: !0
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
else {
|
|
1360
|
+
let e = this._softShadowPass;
|
|
1361
|
+
e.depthTexture = this.gBufferTextures.depthBufferTexture, e.normalTexture = this.gBufferTextures.gBufferTexture;
|
|
1362
|
+
}
|
|
1363
|
+
return this._softShadowPass;
|
|
1364
|
+
}
|
|
1365
|
+
get fadeRenderTarget() {
|
|
1366
|
+
return this._fadeRenderTarget = this._fadeRenderTarget ?? new u(this._width, this._height, {
|
|
1367
|
+
samples: this._samples,
|
|
1368
|
+
format: 1030,
|
|
1369
|
+
magFilter: this._samples > 1 ? 1006 : 1003,
|
|
1370
|
+
minFilter: this._samples > 1 ? 1006 : 1003
|
|
1371
|
+
}), this._fadeRenderTarget;
|
|
1372
|
+
}
|
|
1373
|
+
get denoisePass() {
|
|
1374
|
+
if (!this._poissonDenoisePass) this._poissonDenoisePass = new ct(this._width, this._height, this._samples, {
|
|
1375
|
+
inputTexture: this.aoAndSoftShadowRenderTarget.texture,
|
|
1376
|
+
depthTexture: this.gBufferTextures.depthBufferTexture,
|
|
1377
|
+
normalTexture: this.gBufferTextures.gBufferTexture,
|
|
1378
|
+
normalVectorSourceType: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? Y.FLOAT_BUFFER_NORMAL : Y.INPUT_RGB_NORMAL,
|
|
1379
|
+
depthValueSourceType: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? X.NORMAL_VECTOR_ALPHA : X.SEPARATE_BUFFER,
|
|
1380
|
+
rgInputTexture: !0,
|
|
1381
|
+
luminanceWeighted: !1,
|
|
1382
|
+
fragmentOutput: "vec4(denoised.xy, vec2(fract(depth * 1024.0), floor(depth * 1024.0)))",
|
|
1383
|
+
poissonDenoisePassParameters: this.parameters.poissonDenoise
|
|
1384
|
+
});
|
|
1385
|
+
else {
|
|
1386
|
+
let e = this._poissonDenoisePass;
|
|
1387
|
+
e.depthTexture = this.gBufferTextures.depthBufferTexture, e.normalTexture = this.gBufferTextures.gBufferTexture;
|
|
1388
|
+
}
|
|
1389
|
+
return this._poissonDenoisePass;
|
|
1390
|
+
}
|
|
1391
|
+
get denoiseRenderTargetTexture() {
|
|
1392
|
+
return this.denoisePass ? this.denoisePass.texture : null;
|
|
1393
|
+
}
|
|
1394
|
+
get finalTexture() {
|
|
1395
|
+
return this._finalTexture;
|
|
1396
|
+
}
|
|
1397
|
+
constructor(e, t, n, r, i) {
|
|
1398
|
+
super(e), this.needsUpdate = !0, this.renderToRenderTarget = !1, this.shadowAndAoPassSettings = {
|
|
1399
|
+
shadowMapTexture: null,
|
|
1400
|
+
shadowBlurType: Z.FULL,
|
|
1401
|
+
shadowFadeInBlurType: Z.FULL,
|
|
1402
|
+
shadowFadeInMix: 0,
|
|
1403
|
+
noOStaticFrames: 0
|
|
1404
|
+
}, this._cameraUpdate = new We(), this._finalTexture = null, this._onlyHardShadow = !1, this._width = t, this._height = n, this._samples = r, this.parameters = {
|
|
1405
|
+
enabled: i?.enabled ?? Q.enabled,
|
|
1406
|
+
applyToMaterial: i?.applyToMaterial ?? Q.applyToMaterial,
|
|
1407
|
+
aoIntensity: i?.aoIntensity ?? Q.aoIntensity,
|
|
1408
|
+
shadowIntensity: i?.shadowIntensity ?? Q.shadowIntensity,
|
|
1409
|
+
aoOnGround: i?.aoOnGround ?? Q.aoOnGround,
|
|
1410
|
+
shadowOnGround: i?.shadowOnGround ?? Q.shadowOnGround,
|
|
1411
|
+
alwaysUpdate: i?.alwaysUpdate ?? Q.alwaysUpdate,
|
|
1412
|
+
progressiveDenoiseIterations: i?.progressiveDenoiseIterations ?? Q.progressiveDenoiseIterations,
|
|
1413
|
+
shadow: { ...lt },
|
|
1414
|
+
ao: { ...et },
|
|
1415
|
+
poissonDenoise: { ...st }
|
|
1416
|
+
}, this._copyMaterial = new Ae(), this._blendMaterial = new Ae({}, ke.DEFAULT), this._blendAoAndShadowMaterial = new rt();
|
|
1417
|
+
}
|
|
1418
|
+
dispose() {
|
|
1419
|
+
super.dispose(), this._aoAndSoftShadowRenderTarget?.dispose(), this._softShadowPass?.dispose(), this._aoPass?.dispose(), this._fadeRenderTarget?.dispose(), this._poissonDenoisePass?.dispose(), this._copyMaterial?.dispose(), this._blendMaterial?.dispose(), this._blendAoAndShadowMaterial?.dispose();
|
|
1420
|
+
}
|
|
1421
|
+
setSize(e, t) {
|
|
1422
|
+
this._width = e, this._height = t, this._aoAndSoftShadowRenderTarget?.setSize(e, t), this._softShadowPass?.setSize(e, t), this._aoPass?.setSize(e, t), this._fadeRenderTarget?.setSize(e, t), this._poissonDenoisePass?.setSize(this._width, this._height), this.needsUpdate = !0;
|
|
1423
|
+
}
|
|
1424
|
+
updateParameters(e) {
|
|
1425
|
+
e.enabled !== void 0 && (this.parameters.enabled = e.enabled), e.applyToMaterial !== void 0 && (this.parameters.applyToMaterial = e.applyToMaterial), e.aoIntensity !== void 0 && (this.parameters.aoIntensity = e.aoIntensity), e.shadowIntensity !== void 0 && (this.parameters.shadowIntensity = e.shadowIntensity), e.aoOnGround !== void 0 && (this.parameters.aoOnGround = e.aoOnGround), e.shadowOnGround !== void 0 && (this.parameters.shadowOnGround = e.shadowOnGround), e.alwaysUpdate !== void 0 && (this.parameters.alwaysUpdate = e.alwaysUpdate), this._updatePassParameters(e);
|
|
1426
|
+
}
|
|
1427
|
+
_updatePassParameters(e) {
|
|
1428
|
+
if (e?.shadow) {
|
|
1429
|
+
for (let t in e.shadow) this.parameters.shadow.hasOwnProperty(t) && (this.parameters.shadow[t] = e.shadow[t]);
|
|
1430
|
+
this._softShadowPass && (this._softShadowPass.needsUpdate = !0);
|
|
1431
|
+
}
|
|
1432
|
+
if (e?.ao) {
|
|
1433
|
+
for (let t in e.ao) this.parameters.ao.hasOwnProperty(t) && (this.parameters.ao[t] = e.ao[t]);
|
|
1434
|
+
this._aoPass && this._aoPass?.updateParameters(e?.ao);
|
|
1435
|
+
}
|
|
1436
|
+
if (e?.poissonDenoise) if (this._poissonDenoisePass) this._poissonDenoisePass?.updateParameters(e?.poissonDenoise);
|
|
1437
|
+
else for (let t in e.poissonDenoise) this.parameters.poissonDenoise.hasOwnProperty(t) && (this.parameters.poissonDenoise[t] = e.poissonDenoise[t]);
|
|
1438
|
+
}
|
|
1439
|
+
updateBounds(e, t) {
|
|
1440
|
+
this._softShadowPass?.updateBounds(e.bounds), this._aoPass?.updateBounds(e.bounds, t);
|
|
1441
|
+
}
|
|
1442
|
+
_getRenderConditions(e = Z.FULL, t = 0, n = 0) {
|
|
1443
|
+
let r = e === Z.POISSON && t > .001, i = e === Z.HARD && t > .001 && t < .999;
|
|
1444
|
+
return {
|
|
1445
|
+
fadeInPoissonShadow: r,
|
|
1446
|
+
fadeInHardShadow: i,
|
|
1447
|
+
onlyHardShadow: e === Z.HARD && !i,
|
|
1448
|
+
progressiveDenoise: !r && !i && n > 1 && n <= this.parameters.progressiveDenoiseIterations + 1
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
renderPass(e) {
|
|
1452
|
+
if (!this._setRenderState()) return;
|
|
1453
|
+
let t = this._getRenderConditions(this.shadowAndAoPassSettings.shadowFadeInBlurType, this.shadowAndAoPassSettings.shadowFadeInMix, this.shadowAndAoPassSettings.noOStaticFrames), n = !1;
|
|
1454
|
+
!t.onlyHardShadow && this.shadowAndAoPassSettings.shadowBlurType === Z.FULL && this._evaluateIfUpdateIsNeeded(this.camera) && (this._renderShadowAndAo(e, this.scene, this.camera, this.shadowAndAoPassSettings.shadowMapTexture), n = !0);
|
|
1455
|
+
let r = t.onlyHardShadow ? this.shadowAndAoPassSettings.shadowMapTexture : this.denoiseRenderTargetTexture;
|
|
1456
|
+
t.fadeInPoissonShadow && (r = this._renderDynamicShadow(e, this.aoAndSoftShadowRenderTarget.texture, this.shadowAndAoPassSettings.shadowMapTexture, this.shadowAndAoPassSettings.shadowFadeInMix), n = !0), n ? r = this._renderDenoise(e, this.camera, t.fadeInPoissonShadow, !1) : t.progressiveDenoise && (r = this._renderDenoise(e, this.camera, !1, !0)), t.fadeInHardShadow && (r = this._renderDynamicShadow(e, this.denoiseRenderTargetTexture, this.shadowAndAoPassSettings.shadowMapTexture, this.shadowAndAoPassSettings.shadowFadeInMix)), this._finalTexture = r, this._onlyHardShadow = t.onlyHardShadow, this.renderToRenderTarget && this.renderToTarget(e);
|
|
1457
|
+
}
|
|
1458
|
+
_setRenderState() {
|
|
1459
|
+
return !this.parameters.enabled || !(this.parameters.ao.algorithm !== null || this.parameters.shadowIntensity >= .01) ? !1 : (this.needsUpdate && (this._aoPass && (this._aoPass.needsUpdate = !0), this._poissonDenoisePass && (this._poissonDenoisePass.needsUpdate = !0)), !0);
|
|
1460
|
+
}
|
|
1461
|
+
_evaluateIfUpdateIsNeeded(e) {
|
|
1462
|
+
e.updateProjectionMatrix();
|
|
1463
|
+
let t = this.parameters.alwaysUpdate || this.needsUpdate || e != null && this._cameraUpdate.changed(e);
|
|
1464
|
+
return this.needsUpdate = !1, t;
|
|
1465
|
+
}
|
|
1466
|
+
_renderShadowAndAo(e, t, n, r) {
|
|
1467
|
+
let i = this.parameters.ao.algorithm !== null && this.parameters.aoIntensity > .01;
|
|
1468
|
+
i || this._aoPass?.clear(e, this.aoAndSoftShadowRenderTarget), this._renderSoftShadow(e, n, r), i && this._renderAo(e, t, n);
|
|
1469
|
+
}
|
|
1470
|
+
_renderAo(e, t, n) {
|
|
1471
|
+
let r = this.gBufferTextures.depthBufferTexture, i = this.gBufferTextures.gBufferTexture, a = this._aoAndSoftShadowRenderTarget, o = e.autoClear;
|
|
1472
|
+
e.autoClear = !1;
|
|
1473
|
+
let s = this.aoRenderPass;
|
|
1474
|
+
s.depthTexture = r, s.normalTexture = i, s.render(e, n, t, a), e.autoClear = o;
|
|
1475
|
+
}
|
|
1476
|
+
_renderSoftShadow(e, t, n) {
|
|
1477
|
+
let r = this.softShadowPass;
|
|
1478
|
+
r.parameters.radius = this.parameters.shadow.shadowRadius, r.inputTexture = n, this.softShadowPass.renderToTarget(e, t, this.aoAndSoftShadowRenderTarget);
|
|
1479
|
+
}
|
|
1480
|
+
_renderDynamicShadow(e, t, n, r = 1) {
|
|
1481
|
+
let i = r < .999;
|
|
1482
|
+
return i && (this._copyMaterial.update({
|
|
1483
|
+
texture: t,
|
|
1484
|
+
blending: 0,
|
|
1485
|
+
colorTransform: Te,
|
|
1486
|
+
colorBase: W,
|
|
1487
|
+
multiplyChannels: 0
|
|
1488
|
+
}), this.passRenderer.renderScreenSpace(e, this._copyMaterial, this.fadeRenderTarget)), r > .001 && (this._blendMaterial.update({
|
|
1489
|
+
texture: n,
|
|
1490
|
+
blending: i ? 5 : 0,
|
|
1491
|
+
colorTransform: new v().set(0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, i ? r : 1),
|
|
1492
|
+
multiplyChannels: 0
|
|
1493
|
+
}), this.passRenderer.renderScreenSpace(e, this._blendMaterial, this.fadeRenderTarget)), this.fadeRenderTarget.texture;
|
|
1494
|
+
}
|
|
1495
|
+
_renderDenoise(e, t, n, r) {
|
|
1496
|
+
let i = this.denoisePass;
|
|
1497
|
+
return i.inputTexture = n ? this.fadeRenderTarget.texture : r ? i.texture : this.aoAndSoftShadowRenderTarget.texture, i.render(e, t), i.texture;
|
|
1498
|
+
}
|
|
1499
|
+
renderToTarget(e) {
|
|
1500
|
+
let t = this._onlyHardShadow ? this.parameters.shadowIntensity : this.parameters.aoIntensity, n = this._onlyHardShadow ? 0 : this.parameters.shadowIntensity;
|
|
1501
|
+
this.passRenderer.renderScreenSpace(e, this._blendAoAndShadowMaterial.update({
|
|
1502
|
+
texture: this._finalTexture,
|
|
1503
|
+
blending: 5,
|
|
1504
|
+
aoIntensity: t,
|
|
1505
|
+
shadowIntensity: n
|
|
1506
|
+
}), e.getRenderTarget());
|
|
1507
|
+
}
|
|
1508
|
+
}, dt = class {
|
|
1509
|
+
get isOutlinePassActivated() {
|
|
1510
|
+
return this.outlinePassActivated;
|
|
1511
|
+
}
|
|
1512
|
+
get outlinePass() {
|
|
1513
|
+
return this._renderPassManager.outlinePass;
|
|
1514
|
+
}
|
|
1515
|
+
constructor(e, t, n) {
|
|
1516
|
+
this._effectComposer = null, this.outlinePassActivated = !1, this._renderPassManager = e, this._effectComposer = t, this.parameters = {
|
|
1517
|
+
enabled: !0,
|
|
1518
|
+
edgeStrength: 2,
|
|
1519
|
+
edgeGlow: 1,
|
|
1520
|
+
edgeThickness: 2,
|
|
1521
|
+
pulsePeriod: 0,
|
|
1522
|
+
usePatternTexture: !1,
|
|
1523
|
+
visibleEdgeColor: 16777215,
|
|
1524
|
+
hiddenEdgeColor: 16777215,
|
|
1525
|
+
...n
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
updateParameters(e) {
|
|
1529
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t]);
|
|
1530
|
+
}
|
|
1531
|
+
applyParameters() {
|
|
1532
|
+
this.outlinePass && (this.outlinePass.edgeStrength = this.parameters.edgeStrength, this.outlinePass.edgeGlow = this.parameters.edgeGlow, this.outlinePass.edgeThickness = this.parameters.edgeThickness, this.outlinePass.pulsePeriod = this.parameters.pulsePeriod, this.outlinePass.usePatternTexture = this.parameters.usePatternTexture, this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor), this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor));
|
|
1533
|
+
}
|
|
1534
|
+
activateOutline(e, t) {
|
|
1535
|
+
if (!this.parameters.enabled) {
|
|
1536
|
+
this.deactivateOutline();
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
let n = this.outlinePass?.renderCamera && t.isPerspectiveCamera !== this.outlinePass.renderCamera.isPerspectiveCamera;
|
|
1540
|
+
this.outlinePass && (this.outlinePass.renderScene = e, this.outlinePass.renderCamera = t), !(!n && this.outlinePassActivated) && ((n || !this.outlinePass) && this._renderPassManager.createOutlinePass(), this.applyParameters(), this._effectComposer && this._effectComposer.addPass(this.outlinePass), this.outlinePassActivated = !0);
|
|
1541
|
+
}
|
|
1542
|
+
deactivateOutline() {
|
|
1543
|
+
this.outlinePassActivated &&= (this.outlinePass && this._effectComposer && this._effectComposer.removePass(this.outlinePass), !1);
|
|
1544
|
+
}
|
|
1545
|
+
updateOutline(e, t, n) {
|
|
1546
|
+
n.length > 0 ? (this.activateOutline(e, t), this.outlinePass && (this.outlinePass.selectedObjects = n)) : this.deactivateOutline();
|
|
1547
|
+
}
|
|
1548
|
+
}, ft = {
|
|
1549
|
+
DEFAULT: "default",
|
|
1550
|
+
BRIGHT: "bright"
|
|
1551
|
+
}, pt = {
|
|
1552
|
+
shadowType: "PCFShadowMap",
|
|
1553
|
+
shAndAoPassParameters: {
|
|
1554
|
+
aoIntensity: .3,
|
|
1555
|
+
shadow: { shadowRadius: .1 },
|
|
1556
|
+
ao: {
|
|
1557
|
+
algorithm: Xe.SSAO,
|
|
1558
|
+
samples: 32,
|
|
1559
|
+
radius: .02,
|
|
1560
|
+
distanceExponent: 2,
|
|
1561
|
+
thickness: .1,
|
|
1562
|
+
distanceFallOff: 1,
|
|
1563
|
+
bias: .01
|
|
1564
|
+
},
|
|
1565
|
+
poissonDenoise: {
|
|
1566
|
+
iterations: 2,
|
|
1567
|
+
samples: 16,
|
|
1568
|
+
rings: 2.89,
|
|
1569
|
+
radius: 4,
|
|
1570
|
+
radiusExponent: 1.3,
|
|
1571
|
+
depthPhi: 2.5,
|
|
1572
|
+
normalPhi: .5
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
groundReflectionParameters: { brightness: .5 }
|
|
1576
|
+
}, mt = (...e) => {
|
|
1577
|
+
if (e.length === 0) return null;
|
|
1578
|
+
if (e.length === 1) return e[0];
|
|
1579
|
+
let t = e[0];
|
|
1580
|
+
for (let n = 1; n < e.length; n++) t = de(t, e[n]);
|
|
1581
|
+
return t;
|
|
1582
|
+
}, ht = (e) => e ? { groundReflectionParameters: { enabled: !1 } } : null, gt = (e) => !e || e === ft.DEFAULT ? null : e === ft.BRIGHT ? pt : null, $ = (e) => Math.max(0, Math.min(1, e)), _t = (e) => {
|
|
1583
|
+
let t = {
|
|
1584
|
+
shAndAoPassParameters: {
|
|
1585
|
+
ao: {},
|
|
1586
|
+
shadow: {}
|
|
1587
|
+
},
|
|
1588
|
+
groundReflectionParameters: {},
|
|
1589
|
+
bakedGroundContactShadowParameters: {}
|
|
1590
|
+
};
|
|
1591
|
+
return vt(t, e), yt(t, e), bt(t, e), t;
|
|
1592
|
+
}, vt = (e, t) => {
|
|
1593
|
+
t.aoIntensity !== void 0 && (e.shAndAoPassParameters.aoIntensity = $(t.aoIntensity)), t.aoExtent !== void 0 && (e.shAndAoPassParameters.ao.radius = $(t.aoExtent) * .3, e.shAndAoPassParameters.ao.thickness = .1 + $(t.aoExtent) * .2);
|
|
1594
|
+
}, yt = (e, t) => {
|
|
1595
|
+
t.shBakedOnGround ? (e.bakedGroundContactShadowParameters.enabled = !0, e.shAndAoPassParameters.shadowIntensity = 0, t.shadowIntensity !== void 0 && (e.bakedGroundContactShadowParameters.opacity = $(t.shadowIntensity)), t.shadowIntensity !== void 0 && (e.bakedGroundContactShadowParameters.blurMax = $(t.shadowIntensity) * .1, e.bakedGroundContactShadowParameters.blurMin = e.bakedGroundContactShadowParameters.blurMax * .01)) : (t.shBakedOnGround !== void 0 && (e.bakedGroundContactShadowParameters.enabled = !1), t.shadowIntensity !== void 0 && (e.shAndAoPassParameters.shadowIntensity = $(t.shadowIntensity)), t.shadowSoftening !== void 0 && (e.shAndAoPassParameters.shadow.shadowRadius = .001 + $(t.shadowSoftening) * .2));
|
|
1596
|
+
}, bt = (e, t) => {
|
|
1597
|
+
t.grReflectIntensity !== void 0 && (e.groundReflectionParameters.enabled = t.grReflectIntensity > 0, e.groundReflectionParameters.intensity = $(t.grReflectIntensity)), t.grReflectFadeOut !== void 0 && (e.groundReflectionParameters.fadeOutDistance = (1 - $(t.grReflectFadeOut)) * 4);
|
|
1598
|
+
}, xt = (e, t) => Array.isArray(e) ? e.some((e) => xt(e, t)) : e.transparent && e.opacity < t || e.alphaTest > 0, St = (e) => Array.isArray(e) ? e.some((e) => St(e)) : e instanceof d && e.transmission > 0, Ct = class {
|
|
1599
|
+
constructor(e) {
|
|
1600
|
+
this.needsUpdate = !0, this._cache = null, this._cache = e;
|
|
1601
|
+
}
|
|
1602
|
+
dispose() {
|
|
1603
|
+
this._cache?.dispose();
|
|
1604
|
+
}
|
|
1605
|
+
clear() {
|
|
1606
|
+
this._cache?.clear(), this.needsUpdate = !0;
|
|
1607
|
+
}
|
|
1608
|
+
update(e) {
|
|
1609
|
+
!this.needsUpdate || !this._cache || (e.traverse((e) => {
|
|
1610
|
+
e.isLine || e.isPoints ? this._cache?.addLineOrPoint(e) : e.isMesh ? this._cache?.addMesh(e) : this._cache?.addObject(e);
|
|
1611
|
+
}), this.needsUpdate = !1);
|
|
1612
|
+
}
|
|
1613
|
+
onBeforeRender() {
|
|
1614
|
+
this._cache?.onBeforeRender();
|
|
1615
|
+
}
|
|
1616
|
+
onAfterRender() {
|
|
1617
|
+
this._cache?.onAfterRender();
|
|
1618
|
+
}
|
|
1619
|
+
}, wt = class {
|
|
1620
|
+
constructor() {
|
|
1621
|
+
this._cacheMap = /* @__PURE__ */ new Map();
|
|
1622
|
+
}
|
|
1623
|
+
dispose() {
|
|
1624
|
+
this._cacheMap.forEach((e) => {
|
|
1625
|
+
e.dispose();
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
registerCache(e, t) {
|
|
1629
|
+
this._cacheMap.set(e, new Ct(t));
|
|
1630
|
+
}
|
|
1631
|
+
clearCache() {
|
|
1632
|
+
this._cacheMap.forEach((e) => {
|
|
1633
|
+
e.clear();
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
clearObjectCache(e) {
|
|
1637
|
+
let t = this._cacheMap.get(e);
|
|
1638
|
+
t && t.clear();
|
|
1639
|
+
}
|
|
1640
|
+
onBeforeRender(e, t) {
|
|
1641
|
+
let n = this._cacheMap.get(e);
|
|
1642
|
+
n && (n.update(t), n.onBeforeRender());
|
|
1643
|
+
}
|
|
1644
|
+
onAfterRender(e) {
|
|
1645
|
+
let t = this._cacheMap.get(e);
|
|
1646
|
+
t && t.onAfterRender();
|
|
1647
|
+
}
|
|
1648
|
+
render(e, t, n) {
|
|
1649
|
+
let r = this._cacheMap.get(e);
|
|
1650
|
+
r && (r.update(t), r.onBeforeRender()), n(), r && r.onAfterRender();
|
|
1651
|
+
}
|
|
1652
|
+
}, Tt = class {
|
|
1653
|
+
constructor(e) {
|
|
1654
|
+
this._visibilityCache = /* @__PURE__ */ new Map(), this._isObjectInvisible = e;
|
|
1655
|
+
}
|
|
1656
|
+
dispose() {
|
|
1657
|
+
this._visibilityCache.clear();
|
|
1658
|
+
}
|
|
1659
|
+
clear() {
|
|
1660
|
+
this._visibilityCache.clear();
|
|
1661
|
+
}
|
|
1662
|
+
addLineOrPoint(e) {
|
|
1663
|
+
this._visibilityCache.set(e, e.visible);
|
|
1664
|
+
}
|
|
1665
|
+
addMesh(e) {
|
|
1666
|
+
this._isObjectInvisible && this._isObjectInvisible(e) && this._visibilityCache.set(e, e.visible);
|
|
1667
|
+
}
|
|
1668
|
+
addObject(e) {
|
|
1669
|
+
this._isObjectInvisible && this._isObjectInvisible(e) && this._visibilityCache.set(e, e.visible);
|
|
1670
|
+
}
|
|
1671
|
+
onBeforeRender() {
|
|
1672
|
+
this._visibilityCache.forEach((e, t) => {
|
|
1673
|
+
t.visible = !1;
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
onAfterRender() {
|
|
1677
|
+
this._visibilityCache.forEach((e, t) => {
|
|
1678
|
+
t.visible = e;
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
}, Et = class {
|
|
1682
|
+
constructor(e) {
|
|
1683
|
+
this._depthWriteCache = /* @__PURE__ */ new Set(), this._doNotWriteDepth = e;
|
|
1684
|
+
}
|
|
1685
|
+
dispose() {
|
|
1686
|
+
this._depthWriteCache.clear();
|
|
1687
|
+
}
|
|
1688
|
+
clear() {
|
|
1689
|
+
this._depthWriteCache.clear();
|
|
1690
|
+
}
|
|
1691
|
+
addLineOrPoint(e) {}
|
|
1692
|
+
addObject(e) {}
|
|
1693
|
+
addMesh(e) {
|
|
1694
|
+
this._doNotWriteDepth && this._doNotWriteDepth(e) && e.material instanceof E && e.material.depthWrite && this._depthWriteCache.add(e.material);
|
|
1695
|
+
}
|
|
1696
|
+
onBeforeRender() {
|
|
1697
|
+
this._depthWriteCache.forEach((e) => {
|
|
1698
|
+
e.depthWrite = !1;
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
onAfterRender() {
|
|
1702
|
+
this._depthWriteCache.forEach((e) => {
|
|
1703
|
+
e.depthWrite = !0;
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
}, Dt = class {
|
|
1707
|
+
constructor() {
|
|
1708
|
+
this._objectCache = /* @__PURE__ */ new Map();
|
|
1709
|
+
}
|
|
1710
|
+
clear() {
|
|
1711
|
+
this._objectCache.clear();
|
|
1712
|
+
}
|
|
1713
|
+
onBeforeRender() {
|
|
1714
|
+
this._objectCache.forEach((e, t) => {
|
|
1715
|
+
t instanceof x && (t.material !== e.originalObjectData.material && t.material !== e.updateObjectData.material && (e.originalObjectData.material = t.material), t.receiveShadow !== e.originalObjectData.receiveShadow && (e.originalObjectData.receiveShadow = t.receiveShadow), t.castShadow !== e.originalObjectData.castShadow && (e.originalObjectData.castShadow = t.castShadow), t.visible !== e.originalObjectData.visible && (e.originalObjectData.visible = t.visible)), this._updateObject(t, e.updateObjectData);
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
onAfterRender() {
|
|
1719
|
+
this._objectCache.forEach((e, t) => {
|
|
1720
|
+
this._updateObject(t, e.originalObjectData);
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
addToCache(e, t) {
|
|
1724
|
+
this._objectCache.set(e, {
|
|
1725
|
+
originalObjectData: {
|
|
1726
|
+
visible: e.visible,
|
|
1727
|
+
castShadow: e.castShadow,
|
|
1728
|
+
receiveShadow: e instanceof x ? e.receiveShadow : void 0,
|
|
1729
|
+
material: e instanceof x ? e.material : void 0
|
|
1730
|
+
},
|
|
1731
|
+
updateObjectData: t
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
_updateObject(e, t) {
|
|
1735
|
+
t.visible !== void 0 && (e.visible = t.visible), t.castShadow !== void 0 && (e.castShadow = t.castShadow), e instanceof x && t.receiveShadow !== void 0 && (e.receiveShadow = t.receiveShadow), e instanceof x && t.material !== void 0 && (e.material = t.material);
|
|
1736
|
+
}
|
|
1737
|
+
}, Ot = (e) => {
|
|
1738
|
+
if (!e.isMesh || !e.castShadow && !e.userData?.meshId) return !1;
|
|
1739
|
+
let t = e.material;
|
|
1740
|
+
return !t.transparent || t.opacity > .5;
|
|
1741
|
+
}, kt = class extends J {
|
|
1742
|
+
static {
|
|
1743
|
+
this.addTestMesh = !1;
|
|
1744
|
+
}
|
|
1745
|
+
get shadowGroundPlane() {
|
|
1746
|
+
let e = this._sharedShadowGroundPlane;
|
|
1747
|
+
return e ||= (this._shadowGroundPlane ??= new Ye(this.renderTarget.texture, this.parameters), this._shadowGroundPlane), e.parent !== this._groundGroup && this._groundGroup.add(e), e;
|
|
1748
|
+
}
|
|
1749
|
+
constructor(e, t, n, r) {
|
|
1750
|
+
super(e), this.limitPlaneSize = !0, this.needsUpdate = !0, this.noNeedOfUpdateCount = 0, this._blurScale = 1, this._shadowScale = 1, this._groundGroup = n, this.shadowMapSize = r.shadowMapSize ?? 2048, this.parameters = this._getDefaultParameters(r), this._groundShadowFar = this.parameters.cameraFar, this._renderer = t, this.renderCacheManager?.registerCache(this, new Tt((e) => e.isMesh && !Ot(e) || e.name !== void 0 && ["Ground", "Floor"].includes(e.name))), this.renderTarget = new u(this.shadowMapSize, this.shadowMapSize), this.renderTarget.texture.generateMipmaps = !1, this._renderTargetBlur = new u(this.shadowMapSize, this.shadowMapSize), this._renderTargetBlur.texture.generateMipmaps = !1, this._sharedShadowGroundPlane = r?.sharedShadowGroundPlane, this.shadowGroundPlane.setShadowMap(this.renderTarget.texture), this.shadowGroundPlane.updateMaterial(this.parameters), this._groundContactCamera = new At(), this._groundGroup.add(this._groundContactCamera), this._depthMaterial = new f(), this._depthMaterial.userData.fadeoutBias = { value: this.parameters.fadeoutBias }, this._depthMaterial.userData.fadeoutFalloff = { value: this.parameters.fadeoutFalloff }, this._depthMaterial.onBeforeCompile = (e) => {
|
|
1751
|
+
e.uniforms.fadeoutBias = this._depthMaterial.userData.fadeoutBias, e.uniforms.fadeoutFalloff = this._depthMaterial.userData.fadeoutFalloff, e.fragmentShader = `
|
|
1752
|
+
uniform float fadeoutBias;
|
|
1753
|
+
uniform float fadeoutFalloff;
|
|
1754
|
+
${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );", Ye.alphaMap ? "gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));" : "gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}
|
|
1755
|
+
`;
|
|
1756
|
+
}, this._depthMaterial.side = 2, this._depthMaterial.depthTest = !0, this._depthMaterial.depthWrite = !0, this._blurPass = new Je(je, {
|
|
1757
|
+
...r,
|
|
1758
|
+
passRenderer: this.renderPassManager.passRenderer
|
|
1759
|
+
}), this.updatePlaneAndShadowCamera();
|
|
1760
|
+
}
|
|
1761
|
+
_getDefaultParameters(e) {
|
|
1762
|
+
return {
|
|
1763
|
+
enabled: !0,
|
|
1764
|
+
cameraHelper: !1,
|
|
1765
|
+
alwaysUpdate: !1,
|
|
1766
|
+
fadeIn: !1,
|
|
1767
|
+
blurMin: .001,
|
|
1768
|
+
blurMax: .1,
|
|
1769
|
+
fadeoutFalloff: .9,
|
|
1770
|
+
fadeoutBias: .03,
|
|
1771
|
+
opacity: .5,
|
|
1772
|
+
maximumPlaneSize: 40,
|
|
1773
|
+
planeSize: 10,
|
|
1774
|
+
cameraFar: 3,
|
|
1775
|
+
hardLayers: null,
|
|
1776
|
+
softLayers: null,
|
|
1777
|
+
polygonOffset: 2,
|
|
1778
|
+
excludeGroundObjects: !0,
|
|
1779
|
+
...e
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
dispose() {
|
|
1783
|
+
this.renderTarget.dispose(), this._renderTargetBlur.dispose(), this._blurPass.dispose(), this._depthMaterial.dispose();
|
|
1784
|
+
}
|
|
1785
|
+
updateParameters(e) {
|
|
1786
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t]);
|
|
1787
|
+
e.cameraFar !== void 0 && (this._groundShadowFar = this.parameters.cameraFar);
|
|
1788
|
+
}
|
|
1789
|
+
applyParameters() {
|
|
1790
|
+
this.shadowGroundPlane.updateMaterial(this.parameters), this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper), this._groundContactCamera.far !== this.parameters.cameraFar && this.updatePlaneAndShadowCamera();
|
|
1791
|
+
let e = this.parameters.fadeoutFalloff;
|
|
1792
|
+
this._depthMaterial.userData.fadeoutFalloff.value !== e && (this._depthMaterial.userData.fadeoutFalloff.value = this.parameters.fadeoutFalloff);
|
|
1793
|
+
let t = this.parameters.fadeoutBias / this._groundContactCamera.far;
|
|
1794
|
+
this._depthMaterial.userData.fadeoutBias.value !== t && (this._depthMaterial.userData.fadeoutBias.value = t), this.needsUpdate = !0;
|
|
1795
|
+
}
|
|
1796
|
+
setScale(e, t) {
|
|
1797
|
+
this._blurScale = e, this._shadowScale = t ?? e, this.needsUpdate = !0;
|
|
1798
|
+
}
|
|
1799
|
+
updateBounds(e, t) {
|
|
1800
|
+
this._groundShadowFar = this.parameters.cameraFar, this._groundShadowFar < e.size.z && (this._groundShadowFar = e.size.z * 1.01);
|
|
1801
|
+
let n = Math.max(e.size.x, e.size.z);
|
|
1802
|
+
this.parameters.planeSize = n + 2 * Math.max(this._blurScale, this._shadowScale ?? 1, 1), this.limitPlaneSize && this.parameters.planeSize > this.parameters.maximumPlaneSize ? (this.parameters.planeSize = this.parameters.maximumPlaneSize, this._groundGroup.position.set(0, t ?? 0, 0)) : this._groundGroup.position.set(e.center.x, t ?? 0, e.center.z), this._groundGroup.updateMatrixWorld(), this.updatePlaneAndShadowCamera();
|
|
1803
|
+
}
|
|
1804
|
+
updatePlaneAndShadowCamera() {
|
|
1805
|
+
let e = this.parameters.planeSize;
|
|
1806
|
+
this.shadowGroundPlane.scale.x = e, this.shadowGroundPlane.scale.y = e, this._groundContactCamera.updateCameraFormPlaneSize(e, this._groundShadowFar), this.needsUpdate = !0;
|
|
1807
|
+
}
|
|
1808
|
+
setGroundVisibilityLayers(e) {
|
|
1809
|
+
this.shadowGroundPlane.setVisibilityLayers(e);
|
|
1810
|
+
}
|
|
1811
|
+
renderPass(e) {
|
|
1812
|
+
if (this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper, this.scene), !this.parameters.enabled) {
|
|
1813
|
+
this.needsUpdate && (this.needsUpdate = !1, this.passRenderer.clear(e, this.renderTarget, 0, 1));
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
if (this.shadowGroundPlane.visible = this.parameters.enabled, this.parameters.alwaysUpdate || this.needsUpdate) this.noNeedOfUpdateCount = 0;
|
|
1817
|
+
else if (this.noNeedOfUpdateCount++, this.noNeedOfUpdateCount >= 10) return;
|
|
1818
|
+
this.needsUpdate = !1;
|
|
1819
|
+
let t = this.shadowGroundPlane.material;
|
|
1820
|
+
t.opacity = this.parameters.alwaysUpdate || !this.parameters.fadeIn ? this.parameters.opacity : this.parameters.opacity * (this.noNeedOfUpdateCount + 2) / 12;
|
|
1821
|
+
let n = this._renderer.getClearAlpha();
|
|
1822
|
+
this._renderer.setClearAlpha(0), this._groundGroup.visible = !1, this.shadowGroundPlane.visible = !1, this._groundContactCamera.setCameraHelperVisibility(!1), this.noNeedOfUpdateCount === 0 ? (this._renderGroundContact(this.scene), this._renderBlur()) : this.noNeedOfUpdateCount === 1 && this._renderBlur(), this._renderReduceBandingBlur(), this._renderer.setRenderTarget(null), this._renderer.setClearAlpha(n), this._groundGroup.visible = !0, this.shadowGroundPlane.visible = this.parameters.enabled, this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper);
|
|
1823
|
+
}
|
|
1824
|
+
_renderGroundContact(e) {
|
|
1825
|
+
let t = e.background;
|
|
1826
|
+
e.background = null, e.overrideMaterial = this._depthMaterial, this._renderer.setRenderTarget(this.renderTarget), this._renderer.clear();
|
|
1827
|
+
let n = this._renderer.autoClear;
|
|
1828
|
+
this._renderer.autoClear = !1, this.parameters.hardLayers && (this._groundContactCamera.layers.mask = this.parameters.hardLayers.mask, this._groundContactCamera.updateCameraFarPlane(10), this._depthMaterial.userData.fadeoutBias.value = .99, this._renderer.render(e, this._groundContactCamera), this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar), this._depthMaterial.userData.fadeoutBias.value = this.parameters.fadeoutBias / this._groundShadowFar), this._groundContactCamera.layers.enableAll(), this.parameters.softLayers && (this._groundContactCamera.layers.mask = this.parameters.softLayers.mask), this.renderCacheManager ? this.renderCacheManager.render(this, e, () => {
|
|
1829
|
+
this._renderer.render(e, this._groundContactCamera);
|
|
1830
|
+
}) : this._renderer.render(e, this._groundContactCamera), this._renderer.autoClear = n, e.overrideMaterial = null, e.background = t;
|
|
1831
|
+
}
|
|
1832
|
+
_renderBlur() {
|
|
1833
|
+
this._renderBlurPass(this._blurScale * this.parameters.blurMin / this.parameters.planeSize, this._blurScale * this.parameters.blurMax / this.parameters.planeSize);
|
|
1834
|
+
}
|
|
1835
|
+
_renderReduceBandingBlur() {
|
|
1836
|
+
let e = this._blurScale * .01 / this.parameters.planeSize;
|
|
1837
|
+
this._renderBlurPass(e, e);
|
|
1838
|
+
}
|
|
1839
|
+
_renderBlurPass(e, t) {
|
|
1840
|
+
this._blurPass.render(this._renderer, [
|
|
1841
|
+
this.renderTarget,
|
|
1842
|
+
this._renderTargetBlur,
|
|
1843
|
+
this.renderTarget
|
|
1844
|
+
], [e, e], [t, t]);
|
|
1845
|
+
}
|
|
1846
|
+
}, At = class extends k {
|
|
1847
|
+
constructor() {
|
|
1848
|
+
super(-1, 1, -1, 1, -1, 1), this.rotation.x = Math.PI;
|
|
1849
|
+
}
|
|
1850
|
+
updateCameraFormPlaneSize(e, t) {
|
|
1851
|
+
this.left = -e / 2, this.right = e / 2, this.top = -e / 2, this.bottom = e / 2, this.near = 0, this.far = t, this.updateProjectionMatrix(), this.cameraHelper?.update();
|
|
1852
|
+
}
|
|
1853
|
+
updateCameraFarPlane(e) {
|
|
1854
|
+
this.far = e, this.updateProjectionMatrix(), this.cameraHelper?.update();
|
|
1855
|
+
}
|
|
1856
|
+
updateCameraHelper(e, t) {
|
|
1857
|
+
e ? (this.cameraHelper = this.cameraHelper ?? new re(this), this.cameraHelper.visible = !0, t?.add(this.cameraHelper)) : this.cameraHelper?.parent && this.cameraHelper?.removeFromParent();
|
|
1858
|
+
}
|
|
1859
|
+
setCameraHelperVisibility(e) {
|
|
1860
|
+
this.cameraHelper && (this.cameraHelper.visible = e);
|
|
1861
|
+
}
|
|
1862
|
+
}, jt = "varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }", Mt = "varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }", Nt = class e extends z {
|
|
1863
|
+
static {
|
|
1864
|
+
this._normalAndDepthShader = {
|
|
1865
|
+
uniforms: {
|
|
1866
|
+
cameraNear: { value: .1 },
|
|
1867
|
+
cameraFar: { value: 1 }
|
|
1868
|
+
},
|
|
1869
|
+
defines: {
|
|
1870
|
+
FLOAT_BUFFER: 0,
|
|
1871
|
+
LINEAR_DEPTH: 0
|
|
1872
|
+
},
|
|
1873
|
+
vertexShader: jt,
|
|
1874
|
+
fragmentShader: Mt
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
constructor(t) {
|
|
1878
|
+
super({
|
|
1879
|
+
defines: Object.assign({
|
|
1880
|
+
...e._normalAndDepthShader.defines,
|
|
1881
|
+
FLOAT_BUFFER: t?.floatBufferType ? 1 : 0,
|
|
1882
|
+
LINEAR_DEPTH: t?.linearDepth ? 1 : 0
|
|
1883
|
+
}),
|
|
1884
|
+
uniforms: y.clone(e._normalAndDepthShader.uniforms),
|
|
1885
|
+
vertexShader: e._normalAndDepthShader.vertexShader,
|
|
1886
|
+
fragmentShader: e._normalAndDepthShader.fragmentShader,
|
|
1887
|
+
blending: t?.blending ?? 0
|
|
1888
|
+
}), this.update(t);
|
|
1889
|
+
}
|
|
1890
|
+
update(e) {
|
|
1891
|
+
if (e?.camera !== void 0) {
|
|
1892
|
+
let t = e?.camera || e?.camera;
|
|
1893
|
+
this.uniforms.cameraNear.value = t.near, this.uniforms.cameraFar.value = t.far;
|
|
1894
|
+
}
|
|
1895
|
+
return this;
|
|
1896
|
+
}
|
|
1897
|
+
}, Pt = class extends J {
|
|
1898
|
+
set groundDepthWrite(e) {
|
|
1899
|
+
this._gBufferMaterialCache && (this._gBufferMaterialCache.groundDepthWrite = e);
|
|
1900
|
+
}
|
|
1901
|
+
get isFloatGBufferWithRgbNormalAlphaDepth() {
|
|
1902
|
+
return this.floatRgbNormalAlphaDepth;
|
|
1903
|
+
}
|
|
1904
|
+
get gBufferTexture() {
|
|
1905
|
+
return this.depthNormalRenderTarget.texture;
|
|
1906
|
+
}
|
|
1907
|
+
get depthBufferTexture() {
|
|
1908
|
+
return this.copyToSeparateDepthBuffer && this.floatRgbNormalAlphaDepth ? this.separateDeptRenderTarget.texture : this.depthNormalRenderTarget.depthTexture;
|
|
1909
|
+
}
|
|
1910
|
+
get textureWithDepthValue() {
|
|
1911
|
+
return this.floatRgbNormalAlphaDepth ? this.depthNormalRenderTarget.texture : this.depthNormalRenderTarget.depthTexture;
|
|
1912
|
+
}
|
|
1913
|
+
updateGBufferRenderMaterial(e) {
|
|
1914
|
+
return this._gBufferRenderMaterial = this._gBufferRenderMaterial ?? (this.floatRgbNormalAlphaDepth ? new Nt({
|
|
1915
|
+
blending: 0,
|
|
1916
|
+
floatBufferType: !0,
|
|
1917
|
+
linearDepth: !1
|
|
1918
|
+
}) : new i({ blending: 0 })), this._gBufferRenderMaterial instanceof Nt && this._gBufferRenderMaterial.update({ camera: e }), this._gBufferRenderMaterial;
|
|
1919
|
+
}
|
|
1920
|
+
get depthNormalRenderTarget() {
|
|
1921
|
+
if (!this._depthNormalRenderTarget) if (this.floatRgbNormalAlphaDepth) this._depthNormalRenderTarget = new u(this._width * this.parameters.depthNormalScale, this._height * this.parameters.depthNormalScale, {
|
|
1922
|
+
minFilter: this._targetMinificationTextureFilter,
|
|
1923
|
+
magFilter: this._targetMagnificationTextureFilter,
|
|
1924
|
+
type: T,
|
|
1925
|
+
samples: this._samples
|
|
1926
|
+
});
|
|
1927
|
+
else {
|
|
1928
|
+
let e = new _(this._width * this.parameters.depthNormalScale, this._height * this.parameters.depthNormalScale);
|
|
1929
|
+
e.format = h, e.type = ie, this._depthNormalRenderTarget = new u(this._width * this.parameters.depthNormalScale, this._height * this.parameters.depthNormalScale, {
|
|
1930
|
+
minFilter: this._targetMinificationTextureFilter,
|
|
1931
|
+
magFilter: this._targetMagnificationTextureFilter,
|
|
1932
|
+
depthTexture: e
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
return this._depthNormalRenderTarget;
|
|
1936
|
+
}
|
|
1937
|
+
get separateDeptRenderTarget() {
|
|
1938
|
+
return this._separateDeptRenderTarget ||= new u(this._width * this.parameters.depthNormalScale, this._height * this.parameters.depthNormalScale, {
|
|
1939
|
+
minFilter: this._targetMinificationTextureFilter,
|
|
1940
|
+
magFilter: this._targetMagnificationTextureFilter,
|
|
1941
|
+
type: T,
|
|
1942
|
+
samples: 0
|
|
1943
|
+
}), this._separateDeptRenderTarget;
|
|
1944
|
+
}
|
|
1945
|
+
constructor(e, t) {
|
|
1946
|
+
super(e), this.floatRgbNormalAlphaDepth = !1, this.linearDepth = !1, this.copyToSeparateDepthBuffer = !1, this.needsUpdate = !0, this.drawGround = !0, this.floatRgbNormalAlphaDepth = t?.capabilities?.isWebGL2 ?? !1, this.renderCacheManager && (this._gBufferMaterialCache = new Ft(), this.renderCacheManager.registerCache(this, this._gBufferMaterialCache)), this.parameters = { depthNormalScale: t?.depthNormalScale ?? 1 }, this._targetMinificationTextureFilter = t?.textureMinificationFilter ?? 1003, this._targetMagnificationTextureFilter = t?.textureMagnificationFilter ?? 1003, this._width = t?.width ?? 1024, this._height = t?.height ?? 1024, this._samples = t?.samples ?? 0, this._shared = t?.shared ?? !1;
|
|
1947
|
+
}
|
|
1948
|
+
dispose() {
|
|
1949
|
+
super.dispose(), this._gBufferRenderMaterial?.dispose(), this._depthNormalRenderTarget?.dispose();
|
|
1950
|
+
}
|
|
1951
|
+
setSize(e, t) {
|
|
1952
|
+
this._width = e, this._height = t, this._depthNormalRenderTarget?.setSize(this._width * this.parameters.depthNormalScale, this._height * this.parameters.depthNormalScale);
|
|
1953
|
+
}
|
|
1954
|
+
renderPass(e) {
|
|
1955
|
+
this._shared && !this.needsUpdate || (this.needsUpdate = !1, this.renderPassManager.setGroundVisibility(this.drawGround), this.renderCacheManager ? this.renderCacheManager.render(this, this.scene, () => {
|
|
1956
|
+
this._renderGBuffer(e, this.scene, this.camera);
|
|
1957
|
+
}) : this._renderGBuffer(e, this.scene, this.camera), this.renderPassManager.setGroundVisibility(!1), this.floatRgbNormalAlphaDepth && this.copyToSeparateDepthBuffer && this._copyDepthToSeparateDepthTexture(e, this.depthNormalRenderTarget));
|
|
1958
|
+
}
|
|
1959
|
+
_renderGBuffer(e, t, n) {
|
|
1960
|
+
this.passRenderer.renderWithOverrideMaterial(e, t, n, this.updateGBufferRenderMaterial(n), this.depthNormalRenderTarget, 7829503, 1);
|
|
1961
|
+
}
|
|
1962
|
+
getCopyMaterial(e) {
|
|
1963
|
+
return this._copyMaterial ??= new Ae(), this._copyMaterial.update(e);
|
|
1964
|
+
}
|
|
1965
|
+
_copyDepthToSeparateDepthTexture(e, t) {
|
|
1966
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
1967
|
+
texture: t.texture,
|
|
1968
|
+
blending: 0,
|
|
1969
|
+
colorTransform: De,
|
|
1970
|
+
colorBase: G,
|
|
1971
|
+
multiplyChannels: 0,
|
|
1972
|
+
uvTransform: K
|
|
1973
|
+
}), this.separateDeptRenderTarget);
|
|
1974
|
+
}
|
|
1975
|
+
}, Ft = class extends Dt {
|
|
1976
|
+
set groundDepthWrite(e) {
|
|
1977
|
+
this._groundDepthWrite = e;
|
|
1978
|
+
}
|
|
1979
|
+
constructor() {
|
|
1980
|
+
super(), this._groundDepthWrite = !0;
|
|
1981
|
+
}
|
|
1982
|
+
dispose() {}
|
|
1983
|
+
addLineOrPoint(e) {
|
|
1984
|
+
this.addToCache(e, { visible: !1 });
|
|
1985
|
+
}
|
|
1986
|
+
addMesh(e) {
|
|
1987
|
+
e.userData.isFloor ? this.addToCache(e, { visible: this._groundDepthWrite }) : e.visible && (xt(e.material, .7) || St(e.material)) && this.addToCache(e, { visible: !1 });
|
|
1988
|
+
}
|
|
1989
|
+
addObject(e) {
|
|
1990
|
+
e.name === "dimensioning" && this.addToCache(e, { visible: !1 });
|
|
1991
|
+
}
|
|
1992
|
+
}, It = class extends J {
|
|
1993
|
+
get reflectionRenderTarget() {
|
|
1994
|
+
return this._reflectionRenderTarget = this._reflectionRenderTarget ?? this._newRenderTarget(!0), this._reflectionRenderTarget;
|
|
1995
|
+
}
|
|
1996
|
+
get intensityRenderTarget() {
|
|
1997
|
+
return this._intensityRenderTarget = this._intensityRenderTarget ?? this._newRenderTarget(!1), this._intensityRenderTarget;
|
|
1998
|
+
}
|
|
1999
|
+
get blurRenderTarget() {
|
|
2000
|
+
return this._blurRenderTarget = this._blurRenderTarget ?? this._newRenderTarget(!1), this._blurRenderTarget;
|
|
2001
|
+
}
|
|
2002
|
+
constructor(e, t, n, r, i) {
|
|
2003
|
+
super(e), this.reflectionFadeInScale = 1, this._width = t, this._height = n, this._samples = r ?? 1, this.parameters = {
|
|
2004
|
+
enabled: !1,
|
|
2005
|
+
intensity: .25,
|
|
2006
|
+
fadeOutDistance: 1,
|
|
2007
|
+
fadeOutExponent: 4,
|
|
2008
|
+
brightness: 1,
|
|
2009
|
+
blurHorizontal: 3,
|
|
2010
|
+
blurVertical: 6,
|
|
2011
|
+
blurAscent: 0,
|
|
2012
|
+
groundLevel: 0,
|
|
2013
|
+
groundReflectionScale: 1,
|
|
2014
|
+
renderTargetDownScale: 4,
|
|
2015
|
+
...i
|
|
2016
|
+
}, this._copyMaterial = new Ae({}, ke.ADDITIVE, !0, !0), this._updateCopyMaterial(null), this._reflectionIntensityMaterial = new zt({
|
|
2017
|
+
width: this._width / this.parameters.renderTargetDownScale,
|
|
2018
|
+
height: this._height / this.parameters.renderTargetDownScale
|
|
2019
|
+
}), this._blurPass = new Je(je, {
|
|
2020
|
+
...i,
|
|
2021
|
+
passRenderer: this.renderPassManager.passRenderer
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
_newRenderTarget(e) {
|
|
2025
|
+
let t = this._width / this.parameters.renderTargetDownScale, n = this._height / this.parameters.renderTargetDownScale, r = {};
|
|
2026
|
+
return e ? (r.depthTexture = new _(t, n), r.samples = this._samples) : r.samples = 1, new u(t, n, {
|
|
2027
|
+
format: R,
|
|
2028
|
+
...r
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
dispose() {
|
|
2032
|
+
super.dispose(), this._reflectionRenderTarget?.dispose(), this._intensityRenderTarget?.dispose(), this._blurRenderTarget?.dispose(), this._blurPass.dispose(), this._reflectionIntensityMaterial.dispose(), this._copyMaterial.dispose();
|
|
2033
|
+
}
|
|
2034
|
+
setSize(e, t) {
|
|
2035
|
+
this._width = e, this._height = t, this._reflectionRenderTarget?.setSize(this._width / this.parameters.renderTargetDownScale, this._height / this.parameters.renderTargetDownScale), this._intensityRenderTarget?.setSize(this._width / this.parameters.renderTargetDownScale, this._height / this.parameters.renderTargetDownScale), this._blurRenderTarget?.setSize(this._width / this.parameters.renderTargetDownScale, this._height / this.parameters.renderTargetDownScale), this._reflectionIntensityMaterial?.update({
|
|
2036
|
+
width: this._width / this.parameters.renderTargetDownScale,
|
|
2037
|
+
height: this._height / this.parameters.renderTargetDownScale
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
updateParameters(e) {
|
|
2041
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t]);
|
|
2042
|
+
}
|
|
2043
|
+
updateBounds(e, t) {
|
|
2044
|
+
this.parameters.groundLevel = e, this.parameters.groundReflectionScale = t;
|
|
2045
|
+
}
|
|
2046
|
+
_updateCopyMaterial(e, t = 1) {
|
|
2047
|
+
let n = this.parameters.intensity * t, r = this.parameters.brightness;
|
|
2048
|
+
this._copyMaterial.update({
|
|
2049
|
+
texture: e?.texture ?? void 0,
|
|
2050
|
+
colorTransform: new v().set(r, 0, 0, 0, 0, r, 0, 0, 0, 0, r, 0, 0, 0, 0, n),
|
|
2051
|
+
multiplyChannels: 0,
|
|
2052
|
+
uvTransform: q
|
|
2053
|
+
}), this._copyMaterial.depthTest = !0, this._copyMaterial.depthWrite = !1;
|
|
2054
|
+
}
|
|
2055
|
+
renderPass(e) {
|
|
2056
|
+
if (!this.parameters.enabled || !(this.camera instanceof t)) return;
|
|
2057
|
+
let n = this._createGroundReflectionCamera(this.camera);
|
|
2058
|
+
this.renderCacheManager.render("groundReflection", this.scene, () => {
|
|
2059
|
+
this._renderGroundReflection(e, this.scene, n, this.reflectionRenderTarget);
|
|
2060
|
+
}), this._renderGroundReflectionIntensity(e, n, this.intensityRenderTarget), (this.parameters.blurHorizontal > 0 || this.parameters.blurVertical > 0) && this.blurReflection(e, this.camera, [
|
|
2061
|
+
this.intensityRenderTarget,
|
|
2062
|
+
this.blurRenderTarget,
|
|
2063
|
+
this.intensityRenderTarget
|
|
2064
|
+
]), this._updateCopyMaterial(this.intensityRenderTarget, this.reflectionFadeInScale), this.passRenderer.renderScreenSpace(e, this._copyMaterial, e.getRenderTarget());
|
|
2065
|
+
}
|
|
2066
|
+
_renderGroundReflection(e, t, n, r) {
|
|
2067
|
+
let i = e.getRenderTarget();
|
|
2068
|
+
r && (e.setRenderTarget(r), this.passRenderer.clear(e, r, 0, 0)), e.render(t, n), r && e.setRenderTarget(i);
|
|
2069
|
+
}
|
|
2070
|
+
_renderGroundReflectionIntensity(e, t, n) {
|
|
2071
|
+
let r = e.getRenderTarget();
|
|
2072
|
+
e.setRenderTarget(n), this.passRenderer.renderScreenSpace(e, this._reflectionIntensityMaterial.update({
|
|
2073
|
+
texture: this.reflectionRenderTarget.texture,
|
|
2074
|
+
depthTexture: this.reflectionRenderTarget.depthTexture,
|
|
2075
|
+
camera: t,
|
|
2076
|
+
groundLevel: this.parameters.groundLevel,
|
|
2077
|
+
fadeOutDistance: this.parameters.fadeOutDistance * this.parameters.groundReflectionScale,
|
|
2078
|
+
fadeOutExponent: this.parameters.fadeOutExponent
|
|
2079
|
+
}), e.getRenderTarget()), e.setRenderTarget(r);
|
|
2080
|
+
}
|
|
2081
|
+
blurReflection(e, t, n) {
|
|
2082
|
+
let r = new S(t.matrixWorld.elements[4], t.matrixWorld.elements[5], t.matrixWorld.elements[6]), i = this.parameters.blurHorizontal / this._width, a = this.parameters.blurVertical / this._height * Math.abs(r.dot(new S(0, 0, 1)));
|
|
2083
|
+
this._blurPass.render(e, n, [i * 4, a * 4], [i * 4 * (1 + this.parameters.blurAscent), a * 4 * (1 + this.parameters.blurAscent)]);
|
|
2084
|
+
}
|
|
2085
|
+
_createGroundReflectionCamera(e) {
|
|
2086
|
+
let t = e.clone(), n = t;
|
|
2087
|
+
return n._offset &&= {
|
|
2088
|
+
left: n._offset.left,
|
|
2089
|
+
top: 1 - n._offset.bottom,
|
|
2090
|
+
right: n._offset.right,
|
|
2091
|
+
bottom: 1 - n._offset.top
|
|
2092
|
+
}, t.position.set(e.position.x, -e.position.y + 2 * this.parameters.groundLevel, e.position.z), t.rotation.set(-e.rotation.x, e.rotation.y, -e.rotation.z), t.updateMatrixWorld(), t.updateProjectionMatrix(), t;
|
|
2093
|
+
}
|
|
2094
|
+
}, Lt = "\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }", Rt = "\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include <packing>\n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec2 diffuseTextureSize = vec2(textureSize(tDiffuse, 0 ));\n vec4 fragColor = texelFetch(tDiffuse, ivec2(uv * diffuseTextureSize), 0).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha * step(depth, 0.9999);\n #if PREMULTIPLIED_ALPHA == 1\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n #else\n gl_FragColor = fragColor;\n #endif\n }", zt = class e extends z {
|
|
2095
|
+
static {
|
|
2096
|
+
this.shader = {
|
|
2097
|
+
uniforms: {
|
|
2098
|
+
tDiffuse: { value: null },
|
|
2099
|
+
tDepth: { value: null },
|
|
2100
|
+
resolution: { value: new m() },
|
|
2101
|
+
cameraNear: { value: .1 },
|
|
2102
|
+
cameraFar: { value: 1 },
|
|
2103
|
+
cameraProjectionMatrix: { value: new v() },
|
|
2104
|
+
cameraInverseProjectionMatrix: { value: new v() },
|
|
2105
|
+
inverseViewMatrix: { value: new v() },
|
|
2106
|
+
groundLevel: { value: 0 },
|
|
2107
|
+
fadeOutDistance: { value: 1 },
|
|
2108
|
+
fadeOutExponent: { value: 1 }
|
|
2109
|
+
},
|
|
2110
|
+
defines: {
|
|
2111
|
+
PERSPECTIVE_CAMERA: 1,
|
|
2112
|
+
LINEAR_TO_SRGB: 0,
|
|
2113
|
+
PREMULTIPLIED_ALPHA: 1
|
|
2114
|
+
},
|
|
2115
|
+
vertexShader: Lt,
|
|
2116
|
+
fragmentShader: Rt
|
|
2117
|
+
};
|
|
2118
|
+
}
|
|
2119
|
+
constructor(t) {
|
|
2120
|
+
super({
|
|
2121
|
+
defines: Object.assign({}, e.shader.defines),
|
|
2122
|
+
uniforms: y.clone(e.shader.uniforms),
|
|
2123
|
+
vertexShader: e.shader.vertexShader,
|
|
2124
|
+
fragmentShader: e.shader.fragmentShader,
|
|
2125
|
+
blending: 0
|
|
2126
|
+
}), this.update(t);
|
|
2127
|
+
}
|
|
2128
|
+
update(e) {
|
|
2129
|
+
if (e?.texture !== void 0 && (this.uniforms.tDiffuse.value = e?.texture), e?.depthTexture !== void 0 && (this.uniforms.tDepth.value = e?.depthTexture), e?.width || e?.height) {
|
|
2130
|
+
let t = e?.width ?? this.uniforms.resolution.value.x, n = e?.height ?? this.uniforms.resolution.value.y;
|
|
2131
|
+
this.uniforms.resolution.value.set(t, n);
|
|
2132
|
+
}
|
|
2133
|
+
if (e?.camera !== void 0) {
|
|
2134
|
+
let t = e?.camera || e?.camera;
|
|
2135
|
+
this.uniforms.cameraNear.value = t.near, this.uniforms.cameraFar.value = t.far, this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix), this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse), this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld);
|
|
2136
|
+
}
|
|
2137
|
+
return e?.groundLevel !== void 0 && (this.uniforms.groundLevel.value = e?.groundLevel), e?.fadeOutDistance !== void 0 && (this.uniforms.fadeOutDistance.value = e?.fadeOutDistance), e?.fadeOutExponent !== void 0 && (this.uniforms.fadeOutExponent.value = e?.fadeOutExponent), this;
|
|
2138
|
+
}
|
|
2139
|
+
}, Bt = class extends M {
|
|
2140
|
+
constructor(e, t) {
|
|
2141
|
+
let n = [
|
|
2142
|
+
1,
|
|
2143
|
+
1,
|
|
2144
|
+
0,
|
|
2145
|
+
-1,
|
|
2146
|
+
1,
|
|
2147
|
+
0,
|
|
2148
|
+
-1,
|
|
2149
|
+
-1,
|
|
2150
|
+
0,
|
|
2151
|
+
1,
|
|
2152
|
+
-1,
|
|
2153
|
+
0,
|
|
2154
|
+
1,
|
|
2155
|
+
1,
|
|
2156
|
+
0
|
|
2157
|
+
], r = new ae();
|
|
2158
|
+
r.setAttribute("position", new l(n, 3)), r.computeBoundingSphere();
|
|
2159
|
+
let i = new ce({ fog: !1 });
|
|
2160
|
+
super(r, i), this.light = e, this.color = t, this.type = "RectAreaLightHelper";
|
|
2161
|
+
let a = [
|
|
2162
|
+
1,
|
|
2163
|
+
1,
|
|
2164
|
+
0,
|
|
2165
|
+
-1,
|
|
2166
|
+
1,
|
|
2167
|
+
0,
|
|
2168
|
+
-1,
|
|
2169
|
+
-1,
|
|
2170
|
+
0,
|
|
2171
|
+
1,
|
|
2172
|
+
1,
|
|
2173
|
+
0,
|
|
2174
|
+
-1,
|
|
2175
|
+
-1,
|
|
2176
|
+
0,
|
|
2177
|
+
1,
|
|
2178
|
+
-1,
|
|
2179
|
+
0
|
|
2180
|
+
], o = new ae();
|
|
2181
|
+
o.setAttribute("position", new l(a, 3)), o.computeBoundingSphere(), this.add(new x(o, new c({
|
|
2182
|
+
side: 1,
|
|
2183
|
+
fog: !1
|
|
2184
|
+
})));
|
|
2185
|
+
}
|
|
2186
|
+
updateMatrixWorld() {
|
|
2187
|
+
if (this.scale.set(.5 * this.light.width, .5 * this.light.height, 1), this.color !== void 0) this.material.color.set(this.color), this.children[0].material.color.set(this.color);
|
|
2188
|
+
else {
|
|
2189
|
+
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
|
|
2190
|
+
let e = this.material.color, t = Math.max(e.r, e.g, e.b);
|
|
2191
|
+
t > 1 && e.multiplyScalar(1 / t), this.children[0].material.color.copy(this.material.color);
|
|
2192
|
+
}
|
|
2193
|
+
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld), this.children[0].matrixWorld.copy(this.matrixWorld);
|
|
2194
|
+
}
|
|
2195
|
+
dispose() {
|
|
2196
|
+
this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
|
|
2197
|
+
}
|
|
2198
|
+
}, Vt = class e extends C {
|
|
2199
|
+
static {
|
|
2200
|
+
this._enableGroundBoundary = !1;
|
|
2201
|
+
}
|
|
2202
|
+
static {
|
|
2203
|
+
this._shadowFadeOut = new m(.1, 20);
|
|
2204
|
+
}
|
|
2205
|
+
static {
|
|
2206
|
+
this._sceneBoxMin = new S(-1, -1, -1);
|
|
2207
|
+
}
|
|
2208
|
+
static {
|
|
2209
|
+
this._sceneBoxMax = new S(1, 1, 1);
|
|
2210
|
+
}
|
|
2211
|
+
static {
|
|
2212
|
+
this._distributionProperties = new B(1, 1, 1, 1);
|
|
2213
|
+
}
|
|
2214
|
+
constructor(e) {
|
|
2215
|
+
super(e), this.customProgramCacheKey = this._customProgramCacheKey, this.onBeforeCompile = this._onBeforeCompile;
|
|
2216
|
+
}
|
|
2217
|
+
static setShadowParameters(t, n, r, i, a, o, s) {
|
|
2218
|
+
this._enableGroundBoundary = t, e._distributionProperties.set(n, r, i, a), e._shadowFadeOut.set(o, s);
|
|
2219
|
+
}
|
|
2220
|
+
static setBoundingBox(t) {
|
|
2221
|
+
e._sceneBoxMin.copy(t.min), e._sceneBoxMax.copy(t.max);
|
|
2222
|
+
}
|
|
2223
|
+
_customProgramCacheKey() {
|
|
2224
|
+
return e._enableGroundBoundary ? "GROUND_BOUNDARY" : "NO_GROUND_BOUNDARY";
|
|
2225
|
+
}
|
|
2226
|
+
_onBeforeCompile(t, n) {
|
|
2227
|
+
t.vertexShader = Ht, t.fragmentShader = Ut, t.defines = Object.assign({
|
|
2228
|
+
...t.defines,
|
|
2229
|
+
DYNAMIC_SHADOW_RADIUS: "",
|
|
2230
|
+
GROUND_BOUNDARY: e._enableGroundBoundary ? 1 : 0
|
|
2231
|
+
});
|
|
2232
|
+
let r = t.uniforms;
|
|
2233
|
+
r && (r.distributionProperties = { value: e._distributionProperties }, r.shadowFadeOut = { value: e._shadowFadeOut }, r.sceneBoxMin = { value: e._sceneBoxMin }, r.sceneBoxMax = { value: e._sceneBoxMax });
|
|
2234
|
+
}
|
|
2235
|
+
}, Ht = "\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n\n vViewPosition = - mvPosition.xyz;\n\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n", Ut = "\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include <common>\n#include <packing>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\n\n#if defined( SHADOWMAP_TYPE_PCF )\nfloat getShadowDynamicRadius(sampler2DShadow shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n#else\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n#endif\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n #include <clipping_planes_fragment>\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n\n #include <logdepthbuf_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n\n // accumulation\n\n vec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n\n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif\n\n // modulation\n\n vec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n #include <opaque_fragment>\n #include <premultiplied_alpha_fragment>\n}\n", Wt = {
|
|
2236
|
+
DIRECTION_LIGHT_SHADOW: "DirectionalLightShadow",
|
|
2237
|
+
SPOT_LIGHT_SHADOW: "SpotLightShadow"
|
|
2238
|
+
}, Gt = {
|
|
2239
|
+
alwaysUpdate: !1,
|
|
2240
|
+
enableShadowMap: !0,
|
|
2241
|
+
enableGroundBoundary: !0,
|
|
2242
|
+
layers: null,
|
|
2243
|
+
shadowLightSourceType: Wt.DIRECTION_LIGHT_SHADOW,
|
|
2244
|
+
maximumNumberOfLightSources: -1,
|
|
2245
|
+
directionalDependency: 1,
|
|
2246
|
+
directionalExponent: 1,
|
|
2247
|
+
groundBoundary: 1,
|
|
2248
|
+
fadeOutDistance: .1,
|
|
2249
|
+
fadeOutBlur: 5
|
|
2250
|
+
}, Kt = class extends J {
|
|
2251
|
+
get shadowTexture() {
|
|
2252
|
+
return this._shadowRenderTarget.texture;
|
|
2253
|
+
}
|
|
2254
|
+
set shadowOnGround(e) {
|
|
2255
|
+
this._shadowMapPassOverrideMaterialCache.shadowOnGround = e;
|
|
2256
|
+
}
|
|
2257
|
+
constructor(e, t, n) {
|
|
2258
|
+
super(e), this.needsUpdate = !1, this.drawGround = !0, this.shadowTypeNeedsUpdate = !0, this.shadowConfiguration = new Yt(), this._shadowLightSources = [], this._shadowScale = 1, this._groundMapScale = 1, this._cameraUpdate = new We(), this._viewportSize = new m(t.x, t.y), this._samples = n?.samples ?? 0, this._shadowMapSize = n?.shadowMapSize ?? 1024, this.parameters = this._getScreenSpaceShadowMapParameters(n), this.castShadow = this.parameters.enableShadowMap, this._shadowMapPassOverrideMaterialCache = new Jt(), this.renderCacheManager?.registerCache(this, this._shadowMapPassOverrideMaterialCache);
|
|
2259
|
+
let r = this._samples;
|
|
2260
|
+
this._shadowRenderTarget = new u(this._viewportSize.x, this._viewportSize.y, {
|
|
2261
|
+
samples: r,
|
|
2262
|
+
format: ee,
|
|
2263
|
+
magFilter: this._samples > 0 ? w : p,
|
|
2264
|
+
minFilter: this._samples > 0 ? w : p
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
_getScreenSpaceShadowMapParameters(e) {
|
|
2268
|
+
return {
|
|
2269
|
+
...Gt,
|
|
2270
|
+
...e
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2273
|
+
dispose() {
|
|
2274
|
+
super.dispose(), this._shadowLightSources.forEach((e) => e.dispose()), this._shadowRenderTarget.dispose(), this._shadowMapPassOverrideMaterialCache.dispose();
|
|
2275
|
+
}
|
|
2276
|
+
updateParameters(e) {
|
|
2277
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t]);
|
|
2278
|
+
}
|
|
2279
|
+
updateBounds(e, t) {
|
|
2280
|
+
let n = this._shadowScale;
|
|
2281
|
+
if (this._shadowScale = t, Math.abs(n - this._shadowScale) > 1e-5 && (this.shadowTypeNeedsUpdate = !0), this._shadowLightSources.forEach((t) => t.updateBounds(e)), this._shadowLightSources.length > 0) {
|
|
2282
|
+
let e = this._shadowLightSources[0].getShadowLight().shadow?.camera;
|
|
2283
|
+
e instanceof k && (this._groundMapScale = 2 * this._shadowMapSize / (Math.abs(e.right - e.left) + Math.abs(e.top - e.bottom)));
|
|
2284
|
+
} else this._groundMapScale = 1;
|
|
2285
|
+
this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds);
|
|
2286
|
+
}
|
|
2287
|
+
forceShadowUpdate() {
|
|
2288
|
+
this._shadowLightSources.forEach((e) => e.forceShadowUpdate()), this.needsUpdate = !0;
|
|
2289
|
+
}
|
|
2290
|
+
getShadowLightSources() {
|
|
2291
|
+
return this._shadowLightSources.map((e) => e.getShadowLight());
|
|
2292
|
+
}
|
|
2293
|
+
findShadowLightSource(e) {
|
|
2294
|
+
return this._shadowLightSources.find((t) => t.getOriginalLight() === e)?.getShadowLight();
|
|
2295
|
+
}
|
|
2296
|
+
addRectAreaLight(e, t) {
|
|
2297
|
+
let n = new Zt(e, {
|
|
2298
|
+
shadowMapSize: this._shadowMapSize,
|
|
2299
|
+
shadowLightSourceType: this.parameters.shadowLightSourceType
|
|
2300
|
+
});
|
|
2301
|
+
this._shadowLightSources.push(n), n.addTo(t), n.updatePositionAndTarget(), this.needsUpdate = !0;
|
|
2302
|
+
}
|
|
2303
|
+
updateRectAreaLights(e, t) {
|
|
2304
|
+
let n = this._shadowLightSources;
|
|
2305
|
+
this._shadowLightSources = this._createShadowLightSourceArray(!1);
|
|
2306
|
+
for (let r of n) {
|
|
2307
|
+
if (r instanceof Zt) {
|
|
2308
|
+
let t = r.getRectAreaLight();
|
|
2309
|
+
e.includes(t) && (r.updatePositionAndTarget(), this._shadowLightSources.push(r));
|
|
2310
|
+
}
|
|
2311
|
+
r.removeFrom(t), r.dispose();
|
|
2312
|
+
}
|
|
2313
|
+
e.forEach((e) => {
|
|
2314
|
+
this._shadowLightSources.find((t) => t instanceof Zt && t.getRectAreaLight() === e) || this.addRectAreaLight(e, t);
|
|
2315
|
+
}), this.needsUpdate = !0, this.shadowTypeNeedsUpdate = !0;
|
|
2316
|
+
}
|
|
2317
|
+
createShadowFromLightSources(e, t) {
|
|
2318
|
+
for (let t of this._shadowLightSources) t.removeFrom(e), t.dispose();
|
|
2319
|
+
this._shadowLightSources = this._createShadowLightSourceArray(!0);
|
|
2320
|
+
let n = 1 / (t.length > 0 ? Math.max(...t.map((e) => e.maxIntensity)) : 1);
|
|
2321
|
+
this._addShadowFromLightSources(t, n), this._shadowLightSources.forEach((t) => {
|
|
2322
|
+
t.addTo(e), t.updatePositionAndTarget();
|
|
2323
|
+
}), this.needsUpdate = !0, this.shadowTypeNeedsUpdate = !0;
|
|
2324
|
+
}
|
|
2325
|
+
_addShadowFromLightSources(e, t) {
|
|
2326
|
+
e.forEach((e) => {
|
|
2327
|
+
let n = e.maxIntensity * t;
|
|
2328
|
+
if (n >= .1 && e.position.z >= 0) {
|
|
2329
|
+
let t = new Qt(new S(e.position.x, e.position.z, e.position.y).multiplyScalar(7), n, {
|
|
2330
|
+
shadowMapSize: this._shadowMapSize,
|
|
2331
|
+
shadowLightSourceType: this.parameters.shadowLightSourceType
|
|
2332
|
+
});
|
|
2333
|
+
this._shadowLightSources.push(t);
|
|
2334
|
+
}
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
_createShadowLightSourceArray(e) {
|
|
2338
|
+
let t = [];
|
|
2339
|
+
if (e) {
|
|
2340
|
+
let e = new $t(new S(0, 7, 0), { shadowMapSize: this._shadowMapSize });
|
|
2341
|
+
t.push(e);
|
|
2342
|
+
}
|
|
2343
|
+
return this.parameters.enableGroundBoundary = e, t;
|
|
2344
|
+
}
|
|
2345
|
+
setSize(e, t) {
|
|
2346
|
+
this._viewportSize = new m(e, t), this._shadowRenderTarget.setSize(this._viewportSize.x, this._viewportSize.y);
|
|
2347
|
+
}
|
|
2348
|
+
updatePositionAndTarget() {
|
|
2349
|
+
this._shadowLightSources.forEach((e) => e.updatePositionAndTarget());
|
|
2350
|
+
}
|
|
2351
|
+
renderPass(e) {
|
|
2352
|
+
if (!(this.needsUpdate || this.parameters.alwaysUpdate || this._cameraUpdate.changed(this.camera))) return;
|
|
2353
|
+
this.needsUpdate = !1, this.shadowTypeNeedsUpdate && (this.shadowTypeNeedsUpdate = !1, this.needsUpdate = !0, this._updateShadowType(e));
|
|
2354
|
+
let t = this.scene.background, n = this.scene.environment, r = this.camera.layers.mask;
|
|
2355
|
+
this.scene.environment = null, this.scene.background = null, this.parameters.layers && (this.camera.layers.mask = this.parameters.layers.mask), this.renderPassManager.setGroundVisibility(this.drawGround), this._renderSimpleShadowMapFromShadowLightSources(e, this.scene, this.camera), this.renderPassManager.setGroundVisibility(!1), this.camera.layers.mask = r, this.scene.environment = n, this.scene.background = t;
|
|
2356
|
+
}
|
|
2357
|
+
_renderSimpleShadowMapFromShadowLightSources(e, t, n) {
|
|
2358
|
+
this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary, this.parameters.directionalDependency, this.parameters.directionalExponent, this.parameters.groundBoundary, this._groundMapScale, this.parameters.fadeOutDistance * this._shadowScale, this.parameters.fadeOutBlur);
|
|
2359
|
+
let r = this._getSortedShadowLightSources();
|
|
2360
|
+
r.length === 0 ? this.passRenderer.clear(e, this._shadowRenderTarget, 16777215, 1) : (this._setShadowLightSourcesIntensity(r), this.renderCacheManager?.render(this, t, () => {
|
|
2361
|
+
this.passRenderer.render(e, t, n, this._shadowRenderTarget, 16777215, 1);
|
|
2362
|
+
}), this._shadowLightSources.forEach((e) => e.finishRenderShadow()));
|
|
2363
|
+
}
|
|
2364
|
+
_getSortedShadowLightSources() {
|
|
2365
|
+
let e = [];
|
|
2366
|
+
return this._shadowLightSources.forEach((t) => e.push(...t.prepareRenderShadow())), e.sort((e, t) => e.light.castShadow && !t.light.castShadow || e.groundShadow && !t.groundShadow ? -1 : !e.light.castShadow && t.light.castShadow || !e.groundShadow && t.groundShadow ? 1 : t.intensity - e.intensity), e;
|
|
2367
|
+
}
|
|
2368
|
+
_setShadowLightSourcesIntensity(e) {
|
|
2369
|
+
let t = 0, n = this.parameters.maximumNumberOfLightSources, r = 0;
|
|
2370
|
+
e.forEach((e) => {
|
|
2371
|
+
(n < 0 || r < n) && (t += e.groundShadow ? 0 : e.intensity, e.groundShadow || r++);
|
|
2372
|
+
}), r = 0, e.forEach((e) => {
|
|
2373
|
+
(this.parameters.enableGroundBoundary || !e.groundShadow) && (n < 0 || r < n) ? (e.light.visible = !0, e.light.intensity = e.groundShadow ? e.intensity : e.intensity / t, e.light.castShadow &&= this.castShadow) : (e.light.visible = !1, e.light.intensity = 0, e.light.castShadow = !1), e.groundShadow || r++;
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
_updateShadowType(e) {
|
|
2377
|
+
e.shadowMap.type = this.shadowConfiguration.currentConfiguration.type;
|
|
2378
|
+
let t = this.parameters.enableShadowMap && this.shadowConfiguration.currentConfiguration.castShadow;
|
|
2379
|
+
e.shadowMap.enabled = t, e.shadowMap.needsUpdate = !0, this.castShadow = t && this.shadowConfiguration.currentConfiguration.castShadow, this._shadowLightSources.forEach((e) => e._updateShadowType(this.shadowConfiguration.currentConfiguration, this._shadowScale));
|
|
2380
|
+
}
|
|
2381
|
+
switchType(e) {
|
|
2382
|
+
return this.shadowConfiguration.switchType(e) ? (this.needsUpdate = !0, this.shadowTypeNeedsUpdate = !0, !0) : !1;
|
|
2383
|
+
}
|
|
2384
|
+
}, qt = {
|
|
2385
|
+
DEFAULT: "default",
|
|
2386
|
+
UNLIT: "unlit",
|
|
2387
|
+
EMISSIVE: "emissive",
|
|
2388
|
+
SHADOW: "shadow"
|
|
2389
|
+
}, Jt = class e extends Dt {
|
|
2390
|
+
static {
|
|
2391
|
+
this.useModifiedMaterial = !0;
|
|
2392
|
+
}
|
|
2393
|
+
set shadowOnGround(e) {
|
|
2394
|
+
this._shadowOnGround = e;
|
|
2395
|
+
}
|
|
2396
|
+
constructor() {
|
|
2397
|
+
super(), this._boundingBoxSet = !1, this._shadowOnGround = !0, this._shadowObjectMaterial = this._createShadowMaterial(qt.DEFAULT), this._unlitMaterial = this._createShadowMaterial(qt.UNLIT), this._emissiveMaterial = this._createShadowMaterial(qt.EMISSIVE), this._receiveShadowMaterial = this._createShadowMaterial(qt.SHADOW);
|
|
2398
|
+
}
|
|
2399
|
+
dispose() {
|
|
2400
|
+
this._shadowObjectMaterial.dispose(), this._unlitMaterial.dispose(), this._emissiveMaterial.dispose(), this._receiveShadowMaterial.dispose();
|
|
2401
|
+
}
|
|
2402
|
+
setShadowParameters(e, t, n, r, i, a, o) {
|
|
2403
|
+
Vt.setShadowParameters(e, t, n, r, i, a, o);
|
|
2404
|
+
}
|
|
2405
|
+
setBoundingBox(e) {
|
|
2406
|
+
this._boundingBoxSet = !0, Vt.setBoundingBox(e);
|
|
2407
|
+
}
|
|
2408
|
+
_createShadowMaterial(t) {
|
|
2409
|
+
let n;
|
|
2410
|
+
return n = t === qt.EMISSIVE || t === qt.UNLIT ? new c({
|
|
2411
|
+
color: 16777215,
|
|
2412
|
+
side: 2
|
|
2413
|
+
}) : t === qt.SHADOW ? new A({ side: 2 }) : e.useModifiedMaterial ? this._createCustomerShadowMaterial() : new D({
|
|
2414
|
+
color: 16777215,
|
|
2415
|
+
shininess: 0,
|
|
2416
|
+
polygonOffsetFactor: 0,
|
|
2417
|
+
polygonOffsetUnits: 0,
|
|
2418
|
+
side: 2
|
|
2419
|
+
}), n;
|
|
2420
|
+
}
|
|
2421
|
+
_createCustomerShadowMaterial() {
|
|
2422
|
+
return new Vt({ side: 2 });
|
|
2423
|
+
}
|
|
2424
|
+
addLineOrPoint(e) {
|
|
2425
|
+
this.addToCache(e, { visible: !1 });
|
|
2426
|
+
}
|
|
2427
|
+
addMesh(e) {
|
|
2428
|
+
e.visible && this._setMeshMaterialAndVisibility(e);
|
|
2429
|
+
}
|
|
2430
|
+
addObject(e) {
|
|
2431
|
+
e.isLight && !e.userData.shadowLightSource && this.addToCache(e, { visible: !1 });
|
|
2432
|
+
}
|
|
2433
|
+
_setMeshMaterialAndVisibility(e) {
|
|
2434
|
+
e.userData.isFloor ? this._setMeshShadowFloorMaterial(e) : e.material && e.receiveShadow && !Array.isArray(e.material) && !(e.material.transparent === !0 && e.material.opacity < .9) ? this._setShadowMaterialForOpaqueObject(e) : xt(e.material, .9) ? this.addToCache(e, { visible: !1 }) : e.receiveShadow ? this.addToCache(e, {
|
|
2435
|
+
castShadow: !1,
|
|
2436
|
+
material: this._receiveShadowMaterial
|
|
2437
|
+
}) : this.addToCache(e, { visible: !1 });
|
|
2438
|
+
}
|
|
2439
|
+
_setShadowMaterialForOpaqueObject(e) {
|
|
2440
|
+
let t = e.material;
|
|
2441
|
+
t instanceof ce || t instanceof c ? this.addToCache(e, { material: this._unlitMaterial }) : t instanceof E ? this._setMeshShadowStandardMaterial(e, t) : this.addToCache(e, { material: e.receiveShadow ? this._shadowObjectMaterial : this._unlitMaterial });
|
|
2442
|
+
}
|
|
2443
|
+
_setMeshShadowStandardMaterial(e, t) {
|
|
2444
|
+
let n = t.emissiveIntensity > 0 && (t.emissive.r > 0 || t.emissive.g > 0 || t.emissive.b > 0);
|
|
2445
|
+
this.addToCache(e, {
|
|
2446
|
+
castShadow: n ? !1 : e.castShadow,
|
|
2447
|
+
material: n ? this._emissiveMaterial : e.receiveShadow ? this._shadowObjectMaterial : this._unlitMaterial
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
_setMeshShadowFloorMaterial(e) {
|
|
2451
|
+
this._boundingBoxSet && this._shadowOnGround ? this.addToCache(e, {
|
|
2452
|
+
visible: !0,
|
|
2453
|
+
castShadow: !1,
|
|
2454
|
+
receiveShadow: !0,
|
|
2455
|
+
material: this._shadowObjectMaterial
|
|
2456
|
+
}) : this.addToCache(e, { visible: !1 });
|
|
2457
|
+
}
|
|
2458
|
+
}, Yt = class e {
|
|
2459
|
+
constructor() {
|
|
2460
|
+
this.types = new Map([
|
|
2461
|
+
["off", e._noShadow],
|
|
2462
|
+
["BasicShadowMap", e._basicShadow],
|
|
2463
|
+
["PCFShadowMap", e._pcfShadow],
|
|
2464
|
+
["VSMShadowMap", e._vcmShadow]
|
|
2465
|
+
]), this.shadowType = "PCFShadowMap", this.currentConfiguration = this.types.get(this.shadowType) ?? e._defaultType;
|
|
2466
|
+
}
|
|
2467
|
+
static {
|
|
2468
|
+
this._noShadow = {
|
|
2469
|
+
castShadow: !1,
|
|
2470
|
+
type: 1,
|
|
2471
|
+
bias: 0,
|
|
2472
|
+
normalBias: 0,
|
|
2473
|
+
radius: 0
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
static {
|
|
2477
|
+
this._basicShadow = {
|
|
2478
|
+
castShadow: !0,
|
|
2479
|
+
type: 0,
|
|
2480
|
+
bias: -5e-5,
|
|
2481
|
+
normalBias: .005,
|
|
2482
|
+
radius: 0
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
static {
|
|
2486
|
+
this._pcfShadow = {
|
|
2487
|
+
castShadow: !0,
|
|
2488
|
+
type: 1,
|
|
2489
|
+
bias: -5e-5,
|
|
2490
|
+
normalBias: .01,
|
|
2491
|
+
radius: 4
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
static {
|
|
2495
|
+
this._vcmShadow = {
|
|
2496
|
+
castShadow: !0,
|
|
2497
|
+
type: 3,
|
|
2498
|
+
bias: 1e-4,
|
|
2499
|
+
normalBias: 0,
|
|
2500
|
+
radius: 15
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
static {
|
|
2504
|
+
this._defaultType = e._pcfShadow;
|
|
2505
|
+
}
|
|
2506
|
+
switchType(t) {
|
|
2507
|
+
return this.types.has(t) ? (this.currentConfiguration = this.types.get(t) ?? e._defaultType, !0) : !1;
|
|
2508
|
+
}
|
|
2509
|
+
}, Xt = class {
|
|
2510
|
+
constructor(e, t) {
|
|
2511
|
+
this._isVisibleBackup = !0, this._castShadowBackup = !0, this._shadowMapSize = t?.shadowMapSize ?? 1024, this._blurSamples = t?.blurSamples ?? 8, this._shadowLightSource = e, this._shadowLightSource.visible = !1, this._shadowLightSource.castShadow = !0, this._shadowLightSource.shadow && (this._shadowLightSource.shadow.mapSize = new m(this._shadowMapSize, this._shadowMapSize), this._shadowLightSource.shadow.blurSamples = this._blurSamples, this._shadowLightSource.shadow.autoUpdate = !1), this._shadowLightSource.userData.shadowLightSource = this;
|
|
2512
|
+
}
|
|
2513
|
+
getPosition() {
|
|
2514
|
+
return this._shadowLightSource.position;
|
|
2515
|
+
}
|
|
2516
|
+
getShadowLight() {
|
|
2517
|
+
return this._shadowLightSource;
|
|
2518
|
+
}
|
|
2519
|
+
getOriginalLight() {
|
|
2520
|
+
return null;
|
|
2521
|
+
}
|
|
2522
|
+
dispose() {
|
|
2523
|
+
this._shadowLightSource.dispose();
|
|
2524
|
+
}
|
|
2525
|
+
addTo(e) {
|
|
2526
|
+
e.add(this._shadowLightSource);
|
|
2527
|
+
}
|
|
2528
|
+
removeFrom(e) {
|
|
2529
|
+
e.remove(this._shadowLightSource);
|
|
2530
|
+
}
|
|
2531
|
+
updatePositionAndTarget() {
|
|
2532
|
+
this._updateShadowPositionAndTarget(this.getPosition(), new S(0, 0, 0));
|
|
2533
|
+
}
|
|
2534
|
+
updateBounds(e) {
|
|
2535
|
+
if (this._shadowLightSource instanceof ne) {
|
|
2536
|
+
let t = this._shadowLightSource.shadow.camera, n = e.bounds.clone().applyMatrix4(t.matrixWorldInverse), r = Math.max(.001, Math.min(-n.min.z, -n.max.z)), i = Math.max(-n.min.z, -n.max.z), a = Math.max(Math.abs(n.min.x), Math.abs(n.max.x)), o = Math.max(Math.abs(n.min.y), Math.abs(n.max.y)), s = Math.atan2(Math.hypot(o, a) * 1.05, r);
|
|
2537
|
+
t.aspect = 1, t.near = r, t.far = i, this._shadowLightSource.angle = s;
|
|
2538
|
+
} else if (this._shadowLightSource.shadow) {
|
|
2539
|
+
let t = this._shadowLightSource.shadow.camera;
|
|
2540
|
+
e.updateCameraViewVolumeFromBounds(t);
|
|
2541
|
+
let n = t;
|
|
2542
|
+
n.far += n.far - n.near, n.updateProjectionMatrix();
|
|
2543
|
+
}
|
|
2544
|
+
this._shadowLightSource.shadow && (this._shadowLightSource.shadow.needsUpdate = !0);
|
|
2545
|
+
}
|
|
2546
|
+
forceShadowUpdate() {
|
|
2547
|
+
this._shadowLightSource.shadow && (this._shadowLightSource.shadow.needsUpdate = !0);
|
|
2548
|
+
}
|
|
2549
|
+
_updateShadowPositionAndTarget(e, t) {
|
|
2550
|
+
if (this._shadowLightSource instanceof ne) {
|
|
2551
|
+
let n = t.clone().sub(e), r = n.length();
|
|
2552
|
+
n.normalize();
|
|
2553
|
+
let i = t.clone().sub(n.clone().multiplyScalar(r * 4));
|
|
2554
|
+
this._shadowLightSource.shadow.camera.position.copy(i), this._shadowLightSource.shadow.camera.position.copy(i), this._shadowLightSource.shadow.camera.lookAt(t), this._shadowLightSource.position.copy(i), this._shadowLightSource.lookAt(t);
|
|
2555
|
+
} else this._shadowLightSource.position.copy(e), this._shadowLightSource.lookAt(t), this._shadowLightSource.shadow?.camera.position.copy(e), this._shadowLightSource.shadow?.camera.lookAt(t);
|
|
2556
|
+
this._shadowLightSource.shadow?.camera.updateMatrixWorld(), this._shadowLightSource.updateMatrixWorld();
|
|
2557
|
+
}
|
|
2558
|
+
_updateShadowType(e, t) {
|
|
2559
|
+
let n = this._shadowLightSource.shadow;
|
|
2560
|
+
n && (n.bias = e.bias, n.normalBias = e.normalBias * t, n.radius = e.radius, n.needsUpdate = !0);
|
|
2561
|
+
}
|
|
2562
|
+
prepareRenderShadow() {
|
|
2563
|
+
return [];
|
|
2564
|
+
}
|
|
2565
|
+
finishRenderShadow() {}
|
|
2566
|
+
}, Zt = class extends Xt {
|
|
2567
|
+
constructor(e, t) {
|
|
2568
|
+
let n;
|
|
2569
|
+
switch (t?.shadowLightSourceType) {
|
|
2570
|
+
default:
|
|
2571
|
+
case Wt.DIRECTION_LIGHT_SHADOW:
|
|
2572
|
+
n = new b(16777215, 1);
|
|
2573
|
+
break;
|
|
2574
|
+
case Wt.SPOT_LIGHT_SHADOW:
|
|
2575
|
+
n = new ne(16777215, 1, 0, Math.PI / 4, 0);
|
|
2576
|
+
break;
|
|
2577
|
+
}
|
|
2578
|
+
n.position.copy(e.position), n.lookAt(0, 0, 0), super(n, t), this._rectAreaLight = e, this._rectAreaLight.userData.shadowLightSource = this, t?.addHelper && (this._rectLightHelper = new Bt(this._rectAreaLight), this._rectLightHelper.material.depthWrite = !1, this._rectAreaLight.add(this._rectLightHelper));
|
|
2579
|
+
}
|
|
2580
|
+
getPosition() {
|
|
2581
|
+
return this._rectAreaLight.position;
|
|
2582
|
+
}
|
|
2583
|
+
getRectAreaLight() {
|
|
2584
|
+
return this._rectAreaLight;
|
|
2585
|
+
}
|
|
2586
|
+
getOriginalLight() {
|
|
2587
|
+
return this._rectAreaLight;
|
|
2588
|
+
}
|
|
2589
|
+
prepareRenderShadow() {
|
|
2590
|
+
return this._isVisibleBackup = this._rectAreaLight.visible, this._castShadowBackup = this._shadowLightSource.castShadow, this._shadowLightSource.visible = this._rectAreaLight.visible, this._rectAreaLight.visible = !1, this._shadowLightSource.visible ? [{
|
|
2591
|
+
light: this._shadowLightSource,
|
|
2592
|
+
intensity: this._rectAreaLight.intensity,
|
|
2593
|
+
groundShadow: !1
|
|
2594
|
+
}] : [];
|
|
2595
|
+
}
|
|
2596
|
+
finishRenderShadow() {
|
|
2597
|
+
this._shadowLightSource.visible = !1, this._shadowLightSource.castShadow = this._castShadowBackup, this._rectAreaLight.visible = this._isVisibleBackup;
|
|
2598
|
+
}
|
|
2599
|
+
}, Qt = class extends Xt {
|
|
2600
|
+
constructor(e, t, n) {
|
|
2601
|
+
let r = new b(16777215, t);
|
|
2602
|
+
r.position.copy(e), r.lookAt(0, 0, 0), r.updateMatrix(), r.castShadow = !0, super(r, n), this._position = e.clone(), this._intensity = t;
|
|
2603
|
+
}
|
|
2604
|
+
getPosition() {
|
|
2605
|
+
return this._position;
|
|
2606
|
+
}
|
|
2607
|
+
prepareRenderShadow() {
|
|
2608
|
+
return this._castShadowBackup = this._shadowLightSource.castShadow, this._shadowLightSource.visible = !0, [{
|
|
2609
|
+
light: this._shadowLightSource,
|
|
2610
|
+
intensity: this._intensity,
|
|
2611
|
+
groundShadow: !1
|
|
2612
|
+
}];
|
|
2613
|
+
}
|
|
2614
|
+
finishRenderShadow() {
|
|
2615
|
+
this._shadowLightSource.castShadow = this._castShadowBackup, this._shadowLightSource.visible = !1;
|
|
2616
|
+
}
|
|
2617
|
+
}, $t = class extends Xt {
|
|
2618
|
+
constructor(e, t) {
|
|
2619
|
+
let n = new b(16777215, 1);
|
|
2620
|
+
n.position.copy(e), n.lookAt(0, 0, 0), n.updateMatrix(), n.castShadow = !0, super(n, t), this._position = e.clone();
|
|
2621
|
+
}
|
|
2622
|
+
getPosition() {
|
|
2623
|
+
return this._position;
|
|
2624
|
+
}
|
|
2625
|
+
prepareRenderShadow() {
|
|
2626
|
+
return this._castShadowBackup = this._shadowLightSource.castShadow, this._shadowLightSource.visible = !0, [{
|
|
2627
|
+
light: this._shadowLightSource,
|
|
2628
|
+
intensity: 1,
|
|
2629
|
+
groundShadow: !0
|
|
2630
|
+
}];
|
|
2631
|
+
}
|
|
2632
|
+
finishRenderShadow() {
|
|
2633
|
+
this._shadowLightSource.castShadow = this._castShadowBackup, this._shadowLightSource.visible = !1;
|
|
2634
|
+
}
|
|
2635
|
+
}, en = {
|
|
2636
|
+
name: "CopyShader",
|
|
2637
|
+
uniforms: {
|
|
2638
|
+
tDiffuse: { value: null },
|
|
2639
|
+
opacity: { value: 1 }
|
|
2640
|
+
},
|
|
2641
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
2642
|
+
fragmentShader: "\n\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 texel = texture2D( tDiffuse, vUv );\n gl_FragColor = opacity * texel;\n\n\n }"
|
|
2643
|
+
}, tn = {
|
|
2644
|
+
name: "FXAAShader",
|
|
2645
|
+
uniforms: {
|
|
2646
|
+
tDiffuse: { value: null },
|
|
2647
|
+
resolution: { value: new m(1 / 1024, 1 / 512) }
|
|
2648
|
+
},
|
|
2649
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
2650
|
+
fragmentShader: "\n\n uniform sampler2D tDiffuse;\n uniform vec2 resolution;\n varying vec2 vUv;\n\n #define EDGE_STEP_COUNT 6\n #define EDGE_GUESS 8.0\n #define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n float _ContrastThreshold = 0.0312;\n float _RelativeThreshold = 0.063;\n float _SubpixelBlending = 1.0;\n\n vec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n return texture( tex2D, uv );\n\n }\n\n float SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n }\n\n float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n uv += texSize * vec2(uOffset, vOffset);\n return SampleLuminance(tex2D, uv);\n\n }\n\n struct LuminanceData {\n\n float m, n, e, s, w;\n float ne, nw, se, sw;\n float highest, lowest, contrast;\n\n };\n\n LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n LuminanceData l;\n l.m = SampleLuminance( tex2D, uv );\n l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n l.contrast = l.highest - l.lowest;\n return l;\n\n }\n\n bool ShouldSkipPixel( LuminanceData l ) {\n\n float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n return l.contrast < threshold;\n\n }\n\n float DeterminePixelBlendFactor( LuminanceData l ) {\n\n float f = 2.0 * ( l.n + l.e + l.s + l.w );\n f += l.ne + l.nw + l.se + l.sw;\n f *= 1.0 / 12.0;\n f = abs( f - l.m );\n f = clamp( f / l.contrast, 0.0, 1.0 );\n\n float blendFactor = smoothstep( 0.0, 1.0, f );\n return blendFactor * blendFactor * _SubpixelBlending;\n\n }\n\n struct EdgeData {\n\n bool isHorizontal;\n float pixelStep;\n float oppositeLuminance, gradient;\n\n };\n\n EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n EdgeData e;\n float horizontal =\n abs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n abs( l.ne + l.se - 2.0 * l.e ) +\n abs( l.nw + l.sw - 2.0 * l.w );\n float vertical =\n abs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n abs( l.ne + l.nw - 2.0 * l.n ) +\n abs( l.se + l.sw - 2.0 * l.s );\n e.isHorizontal = horizontal >= vertical;\n\n float pLuminance = e.isHorizontal ? l.n : l.e;\n float nLuminance = e.isHorizontal ? l.s : l.w;\n float pGradient = abs( pLuminance - l.m );\n float nGradient = abs( nLuminance - l.m );\n\n e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\n if (pGradient < nGradient) {\n\n e.pixelStep = -e.pixelStep;\n e.oppositeLuminance = nLuminance;\n e.gradient = nGradient;\n\n } else {\n\n e.oppositeLuminance = pLuminance;\n e.gradient = pGradient;\n\n }\n\n return e;\n\n }\n\n float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n vec2 uvEdge = uv;\n vec2 edgeStep;\n if (e.isHorizontal) {\n\n uvEdge.y += e.pixelStep * 0.5;\n edgeStep = vec2( texSize.x, 0.0 );\n\n } else {\n\n uvEdge.x += e.pixelStep * 0.5;\n edgeStep = vec2( 0.0, texSize.y );\n\n }\n\n float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n float gradientThreshold = e.gradient * 0.25;\n\n vec2 puv = uvEdge + edgeStep * edgeSteps[0];\n float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n puv += edgeStep * edgeSteps[i];\n pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n }\n\n if ( !pAtEnd ) {\n\n puv += edgeStep * EDGE_GUESS;\n\n }\n\n vec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n nuv -= edgeStep * edgeSteps[i];\n nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n }\n\n if ( !nAtEnd ) {\n\n nuv -= edgeStep * EDGE_GUESS;\n\n }\n\n float pDistance, nDistance;\n if ( e.isHorizontal ) {\n\n pDistance = puv.x - uv.x;\n nDistance = uv.x - nuv.x;\n\n } else {\n\n pDistance = puv.y - uv.y;\n nDistance = uv.y - nuv.y;\n\n }\n\n float shortestDistance;\n bool deltaSign;\n if ( pDistance <= nDistance ) {\n\n shortestDistance = pDistance;\n deltaSign = pLuminanceDelta >= 0.0;\n\n } else {\n\n shortestDistance = nDistance;\n deltaSign = nLuminanceDelta >= 0.0;\n\n }\n\n if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n return 0.0;\n\n }\n\n return 0.5 - shortestDistance / ( pDistance + nDistance );\n\n }\n\n vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n if ( ShouldSkipPixel( luminance ) ) {\n\n return Sample( tex2D, uv );\n\n }\n\n float pixelBlend = DeterminePixelBlendFactor( luminance );\n EdgeData edge = DetermineEdge( texSize, luminance );\n float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n float finalBlend = max( pixelBlend, edgeBlend );\n\n if (edge.isHorizontal) {\n\n uv.y += edge.pixelStep * finalBlend;\n\n } else {\n\n uv.x += edge.pixelStep * finalBlend;\n\n }\n\n return Sample( tex2D, uv );\n\n }\n\n void main() {\n\n gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\n }"
|
|
2651
|
+
}, nn = class e extends J {
|
|
2652
|
+
static {
|
|
2653
|
+
this.BlurDirectionX = new m(1, 0);
|
|
2654
|
+
}
|
|
2655
|
+
static {
|
|
2656
|
+
this.BlurDirectionY = new m(0, 1);
|
|
2657
|
+
}
|
|
2658
|
+
static {
|
|
2659
|
+
this.highlightLines = !0;
|
|
2660
|
+
}
|
|
2661
|
+
constructor(e, t, n, r, i, a) {
|
|
2662
|
+
super(e), this.patternTexture = null, this.clearBackground = !1, this.renderScene = n, this.renderCamera = r, this.selectedObjects = i === void 0 ? [] : i, this.visibleEdgeColor = new N(1, 1, 1), this.hiddenEdgeColor = new N(.1, .04, .02), this.edgeGlow = 0, this.usePatternTexture = !1, this.edgeThickness = 1, this.edgeStrength = 3, this.downSampleRatio = a?.downSampleRatio || 2, this.pulsePeriod = 0, this.edgeDetectionFxaa = a?.edgeDetectionFxaa || !1, this._visibilityCache = /* @__PURE__ */ new Map(), this.resolution = t === void 0 ? new m(256, 256) : new m(t.x, t.y);
|
|
2663
|
+
let o = Math.round(this.resolution.x / this.downSampleRatio), s = Math.round(this.resolution.y / this.downSampleRatio);
|
|
2664
|
+
this.renderTargetMaskBuffer = new u(this.resolution.x, this.resolution.y), this.renderTargetMaskBuffer.texture.name = "OutlinePass.mask", this.renderTargetMaskBuffer.texture.generateMipmaps = !1, this.prepareMaskMaterial = this._getPrepareMaskMaterial(this.gBufferTextures?.isFloatGBufferWithRgbNormalAlphaDepth), this.prepareMaskMaterial.side = 2, this.prepareMaskMaterial.fragmentShader = l(this.prepareMaskMaterial.fragmentShader, this.renderCamera), this.edgeDetectionFxaa && (this.fxaaRenderMaterial = new z(tn), this.fxaaRenderMaterial.uniforms.tDiffuse.value = this.renderTargetMaskBuffer.texture, this.fxaaRenderMaterial.uniforms.resolution.value.set(1 / this.resolution.x, 1 / this.resolution.y), this.renderTargetFxaaBuffer = new u(this.resolution.x, this.resolution.y), this.renderTargetFxaaBuffer.texture.name = "OutlinePass.fxaa", this.renderTargetFxaaBuffer.texture.generateMipmaps = !1), this.renderTargetMaskDownSampleBuffer = new u(o, s), this.renderTargetMaskDownSampleBuffer.texture.name = "OutlinePass.depthDownSample", this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = !1, this.renderTargetBlurBuffer1 = new u(o, s), this.renderTargetBlurBuffer1.texture.name = "OutlinePass.blur1", this.renderTargetBlurBuffer1.texture.generateMipmaps = !1, this.renderTargetBlurBuffer2 = new u(Math.round(o / 2), Math.round(s / 2)), this.renderTargetBlurBuffer2.texture.name = "OutlinePass.blur2", this.renderTargetBlurBuffer2.texture.generateMipmaps = !1, this.edgeDetectionMaterial = this._getEdgeDetectionMaterial(), this.renderTargetEdgeBuffer1 = new u(o, s), this.renderTargetEdgeBuffer1.texture.name = "OutlinePass.edge1", this.renderTargetEdgeBuffer1.texture.generateMipmaps = !1, this.renderTargetEdgeBuffer2 = new u(Math.round(o / 2), Math.round(s / 2)), this.renderTargetEdgeBuffer2.texture.name = "OutlinePass.edge2", this.renderTargetEdgeBuffer2.texture.generateMipmaps = !1, this.separableBlurMaterial1 = this._getSeperableBlurMaterial(4), this.separableBlurMaterial1.uniforms.texSize.value.set(o, s), this.separableBlurMaterial1.uniforms.kernelRadius.value = 1, this.separableBlurMaterial2 = this._getSeperableBlurMaterial(4), this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(o / 2), Math.round(s / 2)), this.separableBlurMaterial2.uniforms.kernelRadius.value = 4, this.overlayMaterial = this._getOverlayMaterial();
|
|
2665
|
+
let c = en;
|
|
2666
|
+
this.copyUniforms = y.clone(c.uniforms), this.copyUniforms.opacity.value = 1, this.materialCopy = new z({
|
|
2667
|
+
uniforms: this.copyUniforms,
|
|
2668
|
+
vertexShader: c.vertexShader,
|
|
2669
|
+
fragmentShader: c.fragmentShader,
|
|
2670
|
+
blending: 0,
|
|
2671
|
+
depthTest: !1,
|
|
2672
|
+
depthWrite: !1,
|
|
2673
|
+
transparent: !0
|
|
2674
|
+
}), this.enabled = !0, this.needsSwap = !1, this.oldClearColor = new N(), this.oldClearAlpha = 1, this.fsQuad = new Re(void 0), this.tempPulseColor1 = new N(), this.tempPulseColor2 = new N(), this.textureMatrix = new v();
|
|
2675
|
+
function l(e, t) {
|
|
2676
|
+
let n = t.isPerspectiveCamera ? "perspective" : "orthographic";
|
|
2677
|
+
return e.replace(/DEPTH_TO_VIEW_Z/g, n + "DepthToViewZ");
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
dispose() {
|
|
2681
|
+
super.dispose(), this.renderTargetMaskBuffer.dispose(), this.renderTargetFxaaBuffer?.dispose(), this.renderTargetMaskDownSampleBuffer.dispose(), this.renderTargetBlurBuffer1.dispose(), this.renderTargetBlurBuffer2.dispose(), this.renderTargetEdgeBuffer1.dispose(), this.renderTargetEdgeBuffer2.dispose(), this.prepareMaskMaterial.dispose(), this.fxaaRenderMaterial?.dispose(), this.edgeDetectionMaterial.dispose(), this.separableBlurMaterial1.dispose(), this.separableBlurMaterial2.dispose(), this.overlayMaterial.dispose(), this.materialCopy.dispose(), this.fsQuad.dispose();
|
|
2682
|
+
}
|
|
2683
|
+
setSize(e, t) {
|
|
2684
|
+
this.renderTargetMaskBuffer.setSize(e, t);
|
|
2685
|
+
let n = Math.round(e / this.downSampleRatio), r = Math.round(t / this.downSampleRatio);
|
|
2686
|
+
this.renderTargetMaskDownSampleBuffer.setSize(n, r), this.renderTargetBlurBuffer1.setSize(n, r), this.renderTargetEdgeBuffer1.setSize(n, r), this.separableBlurMaterial1.uniforms.texSize.value.set(n, r), n = Math.round(n / 2), r = Math.round(r / 2), this.renderTargetBlurBuffer2.setSize(n, r), this.renderTargetEdgeBuffer2.setSize(n, r), this.separableBlurMaterial2.uniforms.texSize.value.set(n, r), this.fxaaRenderMaterial?.uniforms.resolution.value.set(1 / this.resolution.x, 1 / this.resolution.y), this.renderTargetFxaaBuffer?.setSize(e, t);
|
|
2687
|
+
}
|
|
2688
|
+
_canBeHighlighted(t) {
|
|
2689
|
+
return t.isMesh || e.highlightLines && t.isLine;
|
|
2690
|
+
}
|
|
2691
|
+
_changeVisibilityOfSelectedObjects(e) {
|
|
2692
|
+
let t = this._visibilityCache;
|
|
2693
|
+
this.selectedObjects.forEach((n) => n.traverse((n) => {
|
|
2694
|
+
this._canBeHighlighted(n) && (e === !0 ? n.visible = t.get(n) : (t.set(n, n.visible), n.visible = e));
|
|
2695
|
+
}));
|
|
2696
|
+
}
|
|
2697
|
+
_changeVisibilityOfNonSelectedObjects(e) {
|
|
2698
|
+
let t = this._visibilityCache, n = [];
|
|
2699
|
+
this.selectedObjects.forEach((e) => e.traverse((e) => {
|
|
2700
|
+
this._canBeHighlighted(e) && n.push(e);
|
|
2701
|
+
})), this.renderScene.traverse((r) => {
|
|
2702
|
+
if (this._canBeHighlighted(r) || r.isSprite) {
|
|
2703
|
+
if (n.some((e) => e.id === r.id) === !1) {
|
|
2704
|
+
let n = r.visible;
|
|
2705
|
+
(e === !1 || t.get(r) === !0) && (r.visible = e), t.set(r, n);
|
|
2706
|
+
}
|
|
2707
|
+
} else r.isPoints && (e === !0 ? r.visible = t.get(r) : (t.set(r, r.visible), r.visible = e));
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2710
|
+
_updateTextureMatrix() {
|
|
2711
|
+
this.textureMatrix.set(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1), this.textureMatrix.multiply(this.renderCamera.projectionMatrix), this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse);
|
|
2712
|
+
}
|
|
2713
|
+
render(t, n, r, i, a) {
|
|
2714
|
+
if (this.selectedObjects.length > 0) {
|
|
2715
|
+
t.getClearColor(this.oldClearColor), this.oldClearAlpha = t.getClearAlpha();
|
|
2716
|
+
let n = t.autoClear;
|
|
2717
|
+
this.clearBackground && (t.setClearColor(0, 255), t.clear(!0, !1, !1)), t.autoClear = !1, a && t.state.buffers.stencil.setTest(!1), t.setClearColor(16777215, 1), this._changeVisibilityOfSelectedObjects(!1);
|
|
2718
|
+
let i = this.renderScene.background;
|
|
2719
|
+
this.renderScene.background = null, this._changeVisibilityOfSelectedObjects(!0), this._visibilityCache.clear(), this._updateTextureMatrix(), this._changeVisibilityOfNonSelectedObjects(!1), this.renderScene.overrideMaterial = this.prepareMaskMaterial, this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near, this.renderCamera.far), this.prepareMaskMaterial.uniforms.depthTexture.value = this.gBufferTextures.textureWithDepthValue, this.prepareMaskMaterial.uniforms.textureMatrix.value = this.textureMatrix, t.setRenderTarget(this.renderTargetMaskBuffer), t.clear(), t.render(this.renderScene, this.renderCamera), this.renderScene.overrideMaterial = null, this._changeVisibilityOfNonSelectedObjects(!0), this._visibilityCache.clear(), this.renderScene.background = i;
|
|
2720
|
+
let o = this.renderTargetMaskBuffer;
|
|
2721
|
+
if (this.edgeDetectionFxaa && this.fxaaRenderMaterial && this.renderTargetFxaaBuffer && (this.fxaaRenderMaterial.uniforms.tDiffuse.value = this.renderTargetMaskBuffer.texture, this.fsQuad.material = this.fxaaRenderMaterial, t.setRenderTarget(this.renderTargetFxaaBuffer), t.clear(), this.fsQuad.render(t), o = this.renderTargetFxaaBuffer), this.fsQuad.material = this.materialCopy, this.copyUniforms.tDiffuse.value = o.texture, t.setRenderTarget(this.renderTargetMaskDownSampleBuffer), t.clear(), this.fsQuad.render(t), this.tempPulseColor1.copy(this.visibleEdgeColor), this.tempPulseColor2.copy(this.hiddenEdgeColor), this.pulsePeriod > 0) {
|
|
2722
|
+
let e = 1.25 / 2 + Math.cos(performance.now() * .01 / this.pulsePeriod) * .75 / 2;
|
|
2723
|
+
this.tempPulseColor1.multiplyScalar(e), this.tempPulseColor2.multiplyScalar(e);
|
|
2724
|
+
}
|
|
2725
|
+
this.fsQuad.material = this.edgeDetectionMaterial, this.edgeDetectionMaterial.uniforms.maskTexture.value = this.renderTargetMaskDownSampleBuffer.texture, this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height), this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value = this.tempPulseColor1, this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value = this.tempPulseColor2, t.setRenderTarget(this.renderTargetEdgeBuffer1), t.clear(), this.fsQuad.render(t), this.fsQuad.material = this.separableBlurMaterial1, this.separableBlurMaterial1.uniforms.colorTexture.value = this.renderTargetEdgeBuffer1.texture, this.separableBlurMaterial1.uniforms.direction.value = e.BlurDirectionX, this.separableBlurMaterial1.uniforms.kernelRadius.value = this.edgeThickness, t.setRenderTarget(this.renderTargetBlurBuffer1), t.clear(), this.fsQuad.render(t), this.separableBlurMaterial1.uniforms.colorTexture.value = this.renderTargetBlurBuffer1.texture, this.separableBlurMaterial1.uniforms.direction.value = e.BlurDirectionY, t.setRenderTarget(this.renderTargetEdgeBuffer1), t.clear(), this.fsQuad.render(t), this.fsQuad.material = this.separableBlurMaterial2, this.separableBlurMaterial2.uniforms.colorTexture.value = this.renderTargetEdgeBuffer1.texture, this.separableBlurMaterial2.uniforms.direction.value = e.BlurDirectionX, t.setRenderTarget(this.renderTargetBlurBuffer2), t.clear(), this.fsQuad.render(t), this.separableBlurMaterial2.uniforms.colorTexture.value = this.renderTargetBlurBuffer2.texture, this.separableBlurMaterial2.uniforms.direction.value = e.BlurDirectionY, t.setRenderTarget(this.renderTargetEdgeBuffer2), t.clear(), this.fsQuad.render(t), this.fsQuad.material = this.overlayMaterial, this.overlayMaterial.uniforms.maskTexture.value = o.texture, this.overlayMaterial.uniforms.edgeTexture1.value = this.renderTargetEdgeBuffer1.texture, this.overlayMaterial.uniforms.edgeTexture2.value = this.renderTargetEdgeBuffer2.texture, this.overlayMaterial.uniforms.patternTexture.value = this.patternTexture, this.overlayMaterial.uniforms.edgeStrength.value = this.edgeStrength, this.overlayMaterial.uniforms.edgeGlow.value = this.edgeGlow, this.overlayMaterial.uniforms.usePatternTexture.value = this.usePatternTexture, a && t.state.buffers.stencil.setTest(!0), t.setRenderTarget(r), this.fsQuad.render(t), t.setClearColor(this.oldClearColor, this.oldClearAlpha), t.autoClear = n;
|
|
2726
|
+
}
|
|
2727
|
+
this.renderToScreen && r && (this.fsQuad.material = this.materialCopy, this.copyUniforms.tDiffuse.value = r.texture, t.setRenderTarget(null), this.fsQuad.render(t));
|
|
2728
|
+
}
|
|
2729
|
+
renderPass(e) {
|
|
2730
|
+
this.render(e, null, null, 0, !1);
|
|
2731
|
+
}
|
|
2732
|
+
_getPrepareMaskMaterial(e) {
|
|
2733
|
+
return new z({
|
|
2734
|
+
uniforms: {
|
|
2735
|
+
depthTexture: { value: null },
|
|
2736
|
+
cameraNearFar: { value: new m(.5, .5) },
|
|
2737
|
+
textureMatrix: { value: null }
|
|
2738
|
+
},
|
|
2739
|
+
defines: { FLOAT_ALPHA_DEPTH: e ? 1 : 0 },
|
|
2740
|
+
vertexShader: "#include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n\n varying vec4 projTexCoord;\n varying vec4 vPosition;\n uniform mat4 textureMatrix;\n\n void main() {\n\n #include <skinbase_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n\n vPosition = mvPosition;\n\n vec4 worldPosition = vec4( transformed, 1.0 );\n\n #ifdef USE_INSTANCING\n\n worldPosition = instanceMatrix * worldPosition;\n\n #endif\n \n worldPosition = modelMatrix * worldPosition;\n\n projTexCoord = textureMatrix * worldPosition;\n\n }",
|
|
2741
|
+
fragmentShader: "#include <packing>\n varying vec4 vPosition;\n varying vec4 projTexCoord;\n uniform sampler2D depthTexture;\n uniform vec2 cameraNearFar;\n\n void main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n }"
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
_getEdgeDetectionMaterial() {
|
|
2745
|
+
return new z({
|
|
2746
|
+
uniforms: {
|
|
2747
|
+
maskTexture: { value: null },
|
|
2748
|
+
texSize: { value: new m(.5, .5) },
|
|
2749
|
+
visibleEdgeColor: { value: new S(1, 1, 1) },
|
|
2750
|
+
hiddenEdgeColor: { value: new S(1, 1, 1) }
|
|
2751
|
+
},
|
|
2752
|
+
vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
|
|
2753
|
+
fragmentShader: "varying vec2 vUv;\n\n uniform sampler2D maskTexture;\n uniform vec2 texSize;\n uniform vec3 visibleEdgeColor;\n uniform vec3 hiddenEdgeColor;\n\n void main() {\n vec2 invSize = 1.0 / texSize;\n vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n float diff1 = (c1.r - c2.r)*0.5;\n float diff2 = (c3.r - c4.r)*0.5;\n float d = length( vec2(diff1, diff2) );\n float a1 = min(c1.g, c2.g);\n float a2 = min(c3.g, c4.g);\n float visibilityFactor = min(a1, a2);\n vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n }"
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
_getSeperableBlurMaterial(e) {
|
|
2757
|
+
return new z({
|
|
2758
|
+
defines: { MAX_RADIUS: e },
|
|
2759
|
+
uniforms: {
|
|
2760
|
+
colorTexture: { value: null },
|
|
2761
|
+
texSize: { value: new m(.5, .5) },
|
|
2762
|
+
direction: { value: new m(.5, .5) },
|
|
2763
|
+
kernelRadius: { value: 1 }
|
|
2764
|
+
},
|
|
2765
|
+
vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
|
|
2766
|
+
fragmentShader: "#include <common>\n varying vec2 vUv;\n uniform sampler2D colorTexture;\n uniform vec2 texSize;\n uniform vec2 direction;\n uniform float kernelRadius;\n\n float gaussianPdf(in float x, in float sigma) {\n return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n }\n\n void main() {\n vec2 invSize = 1.0 / texSize;\n float sigma = kernelRadius/2.0;\n float weightSum = gaussianPdf(0.0, sigma);\n vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n vec2 uvOffset = delta;\n for( int i = 1; i <= MAX_RADIUS; i ++ ) {\n float x = kernelRadius * float(i) / float(MAX_RADIUS);\n float w = gaussianPdf(x, sigma);\n vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n diffuseSum += ((sample1 + sample2) * w);\n weightSum += (2.0 * w);\n uvOffset += delta;\n }\n gl_FragColor = diffuseSum/weightSum;\n }"
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
_getOverlayMaterial() {
|
|
2770
|
+
return new z({
|
|
2771
|
+
uniforms: {
|
|
2772
|
+
maskTexture: { value: null },
|
|
2773
|
+
edgeTexture1: { value: null },
|
|
2774
|
+
edgeTexture2: { value: null },
|
|
2775
|
+
patternTexture: { value: null },
|
|
2776
|
+
edgeStrength: { value: 1 },
|
|
2777
|
+
edgeGlow: { value: 1 },
|
|
2778
|
+
usePatternTexture: { value: 0 }
|
|
2779
|
+
},
|
|
2780
|
+
vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
|
|
2781
|
+
fragmentShader: "varying vec2 vUv;\n\n uniform sampler2D maskTexture;\n uniform sampler2D edgeTexture1;\n uniform sampler2D edgeTexture2;\n uniform sampler2D patternTexture;\n uniform float edgeStrength;\n uniform float edgeGlow;\n uniform bool usePatternTexture;\n\n void main() {\n vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n vec4 maskColor = texture2D(maskTexture, vUv);\n vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n if(usePatternTexture)\n finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n gl_FragColor = finalColor;\n }",
|
|
2782
|
+
blending: 2,
|
|
2783
|
+
depthTest: !1,
|
|
2784
|
+
depthWrite: !1,
|
|
2785
|
+
transparent: !0
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
}, rn = {
|
|
2789
|
+
uniforms: { tDiffuse: { value: null } },
|
|
2790
|
+
vertexShader: "\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",
|
|
2791
|
+
fragmentShader: "\n uniform highp sampler2D tDiffuse;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(tDiffuse, vUv);\n float aoPassDepth = dot(textureColor.wz, vec2(1.0/1024.0));\n gl_FragColor = vec4(vec3(aoPassDepth * aoPassDepth), 1.0);\n }"
|
|
2792
|
+
}, an = class extends z {
|
|
2793
|
+
constructor(e) {
|
|
2794
|
+
super({
|
|
2795
|
+
uniforms: y.clone(rn.uniforms),
|
|
2796
|
+
vertexShader: rn.vertexShader,
|
|
2797
|
+
fragmentShader: rn.fragmentShader,
|
|
2798
|
+
transparent: !0,
|
|
2799
|
+
depthTest: !1,
|
|
2800
|
+
depthWrite: !1,
|
|
2801
|
+
blendSrc: 208,
|
|
2802
|
+
blendDst: 200,
|
|
2803
|
+
blendEquation: 100,
|
|
2804
|
+
blendSrcAlpha: 206,
|
|
2805
|
+
blendDstAlpha: 200,
|
|
2806
|
+
blendEquationAlpha: 100
|
|
2807
|
+
}), this._intensity = new m(1, 1), this.update(e);
|
|
2808
|
+
}
|
|
2809
|
+
update(e) {
|
|
2810
|
+
return e?.texture !== void 0 && (this.uniforms.tDiffuse.value = e.texture), e?.blending !== void 0 && (this.blending = e.blending), this;
|
|
2811
|
+
}
|
|
2812
|
+
}, on = (e) => new m(Math.atan2(e.y, e.x) / (2 * Math.PI) + .5, Math.asin(e.z) / Math.PI + .5), sn = class {
|
|
2813
|
+
get colorRenderTarget() {
|
|
2814
|
+
return this._colorRenderTarget = this._colorRenderTarget ?? new u(), this._colorRenderTarget;
|
|
2815
|
+
}
|
|
2816
|
+
environmentMapDecodeTarget(e) {
|
|
2817
|
+
let t = V(e) && e.capabilities.isWebGL2 ? T : P;
|
|
2818
|
+
return this._environmentMapDecodeTarget = this._environmentMapDecodeTarget ?? new u(1, 1, { type: t }), this._environmentMapDecodeTarget;
|
|
2819
|
+
}
|
|
2820
|
+
environmentMapDecodeMaterial(e) {
|
|
2821
|
+
return e ? (this._equirectangularDecodeMaterial = this._equirectangularDecodeMaterial ?? new ln(!0, !1), this._equirectangularDecodeMaterial) : (this._pmremDecodeMaterial = this._pmremDecodeMaterial ?? new ln(!1, !1), this._pmremDecodeMaterial);
|
|
2822
|
+
}
|
|
2823
|
+
get camera() {
|
|
2824
|
+
return this._camera = this._camera ?? new k(-1, 1, 1, -1, -1, 1), this._camera;
|
|
2825
|
+
}
|
|
2826
|
+
scaleTexture(e, t, n, r) {
|
|
2827
|
+
this.colorRenderTarget.setSize(n, r), this._planeMesh = this._planeMesh ?? new x(new se(2, 2), new c({ map: t }));
|
|
2828
|
+
let i = e.getRenderTarget();
|
|
2829
|
+
e.setRenderTarget(this.colorRenderTarget), e.render(this._planeMesh, this.camera), e.setRenderTarget(i);
|
|
2830
|
+
let a = this.environmentMapDecodeTarget(e).texture, o = new Uint8Array(n * r * 4);
|
|
2831
|
+
return e.readRenderTargetPixels(this.colorRenderTarget, 0, 0, n, r, o), {
|
|
2832
|
+
texture: a,
|
|
2833
|
+
pixels: o,
|
|
2834
|
+
sRgbaPixels: !1
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
newGrayscaleTexture(e, t, n, r) {
|
|
2838
|
+
let i = this.environmentMapDecodeMaterial(t.name === "PMREM.cubeUv"), a = this.environmentMapDecodeTarget(e);
|
|
2839
|
+
a.setSize(n, r), i.setSourceTexture(t), this._planeMesh = this._planeMesh ?? new x(new se(2, 2), i);
|
|
2840
|
+
let o = e.getRenderTarget();
|
|
2841
|
+
e.setRenderTarget(a), e.render(this._planeMesh, this.camera), e.setRenderTarget(o);
|
|
2842
|
+
let s = a.texture, c = a.texture.type === T, l = c ? new Float32Array(n * r * 4) : new Uint8Array(n * r * 4);
|
|
2843
|
+
return e.readRenderTargetPixels(a, 0, 0, n, r, l), {
|
|
2844
|
+
texture: s,
|
|
2845
|
+
pixels: l,
|
|
2846
|
+
sRgbaPixels: c
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
}, cn = {
|
|
2850
|
+
uniforms: { tDiffuse: { value: null } },
|
|
2851
|
+
vertexShader: "\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",
|
|
2852
|
+
fragmentShader: "\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }"
|
|
2853
|
+
}, ln = class extends z {
|
|
2854
|
+
constructor(e, t) {
|
|
2855
|
+
super({
|
|
2856
|
+
uniforms: y.clone(cn.uniforms),
|
|
2857
|
+
vertexShader: cn.vertexShader,
|
|
2858
|
+
fragmentShader: cn.fragmentShader,
|
|
2859
|
+
defines: {
|
|
2860
|
+
PMREM_DECODE: e ? 1 : 0,
|
|
2861
|
+
GRAYSCALE_CONVERT: t ? 1 : 0
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
}
|
|
2865
|
+
setSourceTexture(e) {
|
|
2866
|
+
this.uniforms.tDiffuse.value = e;
|
|
2867
|
+
}
|
|
2868
|
+
}, un = class {
|
|
2869
|
+
constructor(e) {
|
|
2870
|
+
this.samplePoints = [], this.sampleUVs = [], this.grayscaleTexture = {
|
|
2871
|
+
texture: new a(),
|
|
2872
|
+
pixels: new Uint8Array(),
|
|
2873
|
+
sRgbaPixels: !1
|
|
2874
|
+
}, this.detectorTexture = new a(), this.detectorArray = new Float32Array(), this.lightSamples = [], this.lightGraph = new fn(0), this.lightSources = [], this._grayScale = new S(.2126, .7152, .0722), this._createEquirectangularSamplePoints = (e) => {
|
|
2875
|
+
let t = [];
|
|
2876
|
+
for (let n = 0; n < e; n++) {
|
|
2877
|
+
let r = n * Math.PI * (3 - Math.sqrt(5)), i = 1 - n / (e - 1) * 2, a = Math.sqrt(1 - i * i), o = Math.cos(r) * a, s = Math.sin(r) * a;
|
|
2878
|
+
t.push(new S(o, s, i));
|
|
2879
|
+
}
|
|
2880
|
+
return t;
|
|
2881
|
+
}, this._numberOfSamples = e?.numberOfSamples ?? 1e3, this._width = e?.width ?? 1024, this._height = e?.height ?? 512, this._sampleThreshold = e?.sampleThreshold ?? .707, this.pointDistance = Math.sqrt(4 * Math.PI) / Math.sqrt(this._numberOfSamples), this.pixelDistance = Math.sqrt(2) * Math.PI * 2 / this._width, this.samplePoints = this._createEquirectangularSamplePoints(this._numberOfSamples), this.sampleUVs = this.samplePoints.map((e) => on(e));
|
|
2882
|
+
}
|
|
2883
|
+
detectLightSources(e, t, n) {
|
|
2884
|
+
this.textureData = n, this._textureConverter = this._textureConverter ?? new sn(), this.grayscaleTexture = this._textureConverter.newGrayscaleTexture(e, t, this._width, this._height), this.detectorArray = this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels, this.grayscaleTexture.sRgbaPixels), this.detectorTexture = this._grayscaleTextureFromFloatArray(this.detectorArray, this._width, this._height), this.lightSamples = this._filterLightSamples(this._sampleThreshold), this.lightGraph = this._findClusterSegments(this.lightSamples, this._sampleThreshold), this.lightGraph.findConnectedComponents(), this.lightSources = this.createLightSourcesFromLightGraph(this.lightSamples, this.lightGraph), this.lightSources.sort((e, t) => t.maxIntensity - e.maxIntensity);
|
|
2885
|
+
}
|
|
2886
|
+
_redFromRgbaToNormalizedFloatArray(e, t, n) {
|
|
2887
|
+
let r = new Float32Array(e.length / 4), i = 1, a = 0;
|
|
2888
|
+
for (let t = 0; t < e.length / 4; ++t) {
|
|
2889
|
+
let n = new N(...e.slice(t * 4, t * 4 + 3));
|
|
2890
|
+
e instanceof Float32Array && n.convertSRGBToLinear();
|
|
2891
|
+
let o = new S(n.r, n.g, n.b).dot(this._grayScale);
|
|
2892
|
+
i = Math.min(i, o), a = Math.max(a, o), r[t] = o;
|
|
2893
|
+
}
|
|
2894
|
+
if (n) for (let e = 0; e < r.length; ++e) r[e] = (t ? r[e] : (r[e] - i) / (a - i)) ** +n;
|
|
2895
|
+
else if (!t) for (let e = 0; e < r.length; ++e) r[e] = (r[e] - i) / (a - i);
|
|
2896
|
+
return r;
|
|
2897
|
+
}
|
|
2898
|
+
_grayscaleTextureFromFloatArray(e, t, n) {
|
|
2899
|
+
let r = t * n, i = new Uint8Array(4 * r);
|
|
2900
|
+
for (let t = 0; t < r; t++) {
|
|
2901
|
+
let n = e[t] * 255;
|
|
2902
|
+
i[t * 4 + 0] = n, i[t * 4 + 1] = n, i[t * 4 + 2] = n, i[t * 4 + 3] = 255;
|
|
2903
|
+
}
|
|
2904
|
+
let a = new s(i, t, n);
|
|
2905
|
+
return a.needsUpdate = !0, a;
|
|
2906
|
+
}
|
|
2907
|
+
_filterLightSamples(e) {
|
|
2908
|
+
let t = [];
|
|
2909
|
+
for (let n = 0; n < this.sampleUVs.length; n++) {
|
|
2910
|
+
let r = this.sampleUVs[n];
|
|
2911
|
+
this._detectorTextureLuminanceValueFromUV(r) > e && t.push(new dn(this.samplePoints[n], r));
|
|
2912
|
+
}
|
|
2913
|
+
return t;
|
|
2914
|
+
}
|
|
2915
|
+
_detectorTextureLuminanceValueFromUV(e) {
|
|
2916
|
+
let t = Math.floor(e.x * this._width), n = Math.floor(e.y * this._height) * this._width + t;
|
|
2917
|
+
return this.detectorArray[n];
|
|
2918
|
+
}
|
|
2919
|
+
_originalLuminanceValueFromUV(e) {
|
|
2920
|
+
if (!this.textureData || !this.textureData.data || !this.textureData._width || !this.textureData._height) return this._detectorTextureLuminanceValueFromUV(e) * 256;
|
|
2921
|
+
let t = Math.floor(e.x * this.textureData._width), n = Math.floor(e.y * this.textureData._height), r = 0;
|
|
2922
|
+
for (let e = Math.max(0, t - 2); e < Math.max(0, t + 2); ++e) for (let t = Math.max(0, n - 2); t < Math.max(0, n + 2); ++t) {
|
|
2923
|
+
let n = t * this.textureData._width + e, i = (this.textureData.data[n * 4] + this.textureData.data[n * 4 + 1] + this.textureData.data[n * 4 + 2]) / 3;
|
|
2924
|
+
r = Math.max(r, i);
|
|
2925
|
+
}
|
|
2926
|
+
return r;
|
|
2927
|
+
}
|
|
2928
|
+
_findClusterSegments(e, t) {
|
|
2929
|
+
let n = this.pixelDistance * 2, r = this.pointDistance * 1.5, i = new fn(e.length);
|
|
2930
|
+
for (let a = 0; a < e.length; a++) for (let o = a + 1; o < e.length; o++) if (e[a].position.angleTo(e[o].position) < r) {
|
|
2931
|
+
let r = e[o].position.clone().sub(e[a].position), s = Math.floor(r.length() / n), c = !0, l = 0;
|
|
2932
|
+
for (let n = 1; n < s; n++) {
|
|
2933
|
+
let i = r.clone().multiplyScalar(n / s), o = on(e[a].position.clone().add(i).normalize());
|
|
2934
|
+
if (this._detectorTextureLuminanceValueFromUV(o) < t) {
|
|
2935
|
+
if (l++, l > 1) {
|
|
2936
|
+
c = !1;
|
|
2937
|
+
break;
|
|
2938
|
+
}
|
|
2939
|
+
} else l = 0;
|
|
2940
|
+
}
|
|
2941
|
+
c && (i.adjacent[a].push(o), i.adjacent[o].push(a), i.edges.push([a, o]));
|
|
2942
|
+
}
|
|
2943
|
+
return i;
|
|
2944
|
+
}
|
|
2945
|
+
createLightSourcesFromLightGraph(e, t) {
|
|
2946
|
+
let n = t.components.filter((e) => e.length > 1).map((t) => new pn(t.map((t) => e[t])));
|
|
2947
|
+
return n.forEach((e) => e.calculateLightSourceProperties((e) => this._originalLuminanceValueFromUV(e))), n;
|
|
2948
|
+
}
|
|
2949
|
+
}, dn = class {
|
|
2950
|
+
constructor(e, t) {
|
|
2951
|
+
this.position = e, this.uv = t;
|
|
2952
|
+
}
|
|
2953
|
+
}, fn = class {
|
|
2954
|
+
constructor(e) {
|
|
2955
|
+
this.edges = [], this.adjacent = [], this.components = [], this.noOfNodes = e;
|
|
2956
|
+
for (let t = 0; t < e; t++) this.adjacent.push([]);
|
|
2957
|
+
}
|
|
2958
|
+
findConnectedComponents() {
|
|
2959
|
+
let e = Array(this.noOfNodes).fill(!1);
|
|
2960
|
+
this.components = [];
|
|
2961
|
+
for (let t = 0; t < this.noOfNodes; t++) if (!e[t]) {
|
|
2962
|
+
let n = [];
|
|
2963
|
+
this._dfs(t, e, n), this.components.push(n);
|
|
2964
|
+
}
|
|
2965
|
+
this.components.sort((e, t) => t.length - e.length);
|
|
2966
|
+
}
|
|
2967
|
+
_dfs(e, t, n) {
|
|
2968
|
+
t[e] = !0, n.push(e);
|
|
2969
|
+
for (let r of this.adjacent[e]) t[r] || this._dfs(r, t, n);
|
|
2970
|
+
}
|
|
2971
|
+
}, pn = class {
|
|
2972
|
+
constructor(e) {
|
|
2973
|
+
this.position = new S(), this.uv = new m(), this.averageIntensity = 0, this.maxIntensity = 0, this.size = 0, this.lightSamples = e;
|
|
2974
|
+
}
|
|
2975
|
+
calculateLightSourceProperties(e) {
|
|
2976
|
+
this.position = new S(), this.averageIntensity = 0, this.maxIntensity = 0;
|
|
2977
|
+
for (let t of this.lightSamples) {
|
|
2978
|
+
this.position.add(t.position);
|
|
2979
|
+
let n = e(t.uv);
|
|
2980
|
+
this.averageIntensity += n, this.maxIntensity = Math.max(this.maxIntensity, n);
|
|
2981
|
+
}
|
|
2982
|
+
this.averageIntensity /= this.lightSamples.length, this.position.normalize(), this.uv = on(this.position);
|
|
2983
|
+
let t = 0;
|
|
2984
|
+
for (let e of this.lightSamples) t += e.position.distanceTo(this.position);
|
|
2985
|
+
t /= this.lightSamples.length, this.size = t / Math.PI;
|
|
2986
|
+
}
|
|
2987
|
+
}, mn = class extends J {
|
|
2988
|
+
constructor(e) {
|
|
2989
|
+
super(e), this.debugOutput = "", this._environmentMapDecodeMaterial = new ln(!0, !1), this._environmentMapDecodeMaterial.blending = 0, this._environmentMapDecodeMaterial.depthTest = !1;
|
|
2990
|
+
}
|
|
2991
|
+
dispose() {
|
|
2992
|
+
this._depthRenderMaterial?.dispose(), this._copyMaterial?.dispose(), this._srgbToLinearCopyMaterial?.dispose();
|
|
2993
|
+
}
|
|
2994
|
+
getCopyMaterial(e) {
|
|
2995
|
+
return this._copyMaterial = this._copyMaterial ?? new Ae(), this._copyMaterial.update(e);
|
|
2996
|
+
}
|
|
2997
|
+
getBlendAoAndShadowMaterial(e) {
|
|
2998
|
+
return this._blendAoAndShadowMaterial = this._blendAoAndShadowMaterial ?? new rt({ blending: 0 }), this._blendAoAndShadowMaterial.update(e);
|
|
2999
|
+
}
|
|
3000
|
+
getBlendAoPassDepthMaterial(e) {
|
|
3001
|
+
return this._blendAoPassDepthMaterial = this._blendAoPassDepthMaterial ?? new an({ blending: 0 }), this._blendAoPassDepthMaterial.update(e);
|
|
3002
|
+
}
|
|
3003
|
+
getSrgbToLinearCopyMaterial(e) {
|
|
3004
|
+
return this._srgbToLinearCopyMaterial = this._copyMaterial ?? new Ae({}, ke.ADDITIVE, !0, !0), this._srgbToLinearCopyMaterial.update(e);
|
|
3005
|
+
}
|
|
3006
|
+
_getDepthRenderMaterial(e) {
|
|
3007
|
+
return this._depthRenderMaterial = this._depthRenderMaterial ?? new Pe({
|
|
3008
|
+
depthTexture: this.gBufferTextures.textureWithDepthValue,
|
|
3009
|
+
depthFilter: this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? new B(0, 0, 0, 1) : new B(1, 0, 0, 0)
|
|
3010
|
+
}), this._depthRenderMaterial.update({ camera: e });
|
|
3011
|
+
}
|
|
3012
|
+
renderPass(e) {
|
|
3013
|
+
switch (this.debugOutput) {
|
|
3014
|
+
default: break;
|
|
3015
|
+
case "lineardepth":
|
|
3016
|
+
this.passRenderer.renderScreenSpace(e, this._getDepthRenderMaterial(this.camera), null);
|
|
3017
|
+
break;
|
|
3018
|
+
case "g-normal":
|
|
3019
|
+
this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3020
|
+
texture: this.gBufferTextures?.gBufferTexture,
|
|
3021
|
+
blending: 0,
|
|
3022
|
+
colorTransform: new v().set(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, .5, 0, 0, 0, 0, 0),
|
|
3023
|
+
colorBase: new B(.5, .5, .5, 1),
|
|
3024
|
+
multiplyChannels: 0,
|
|
3025
|
+
uvTransform: K
|
|
3026
|
+
}), null) : this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3027
|
+
texture: this.gBufferTextures?.gBufferTexture,
|
|
3028
|
+
blending: 0,
|
|
3029
|
+
colorTransform: Ee,
|
|
3030
|
+
colorBase: G,
|
|
3031
|
+
multiplyChannels: 0,
|
|
3032
|
+
uvTransform: K
|
|
3033
|
+
}), null);
|
|
3034
|
+
break;
|
|
3035
|
+
case "g-depth":
|
|
3036
|
+
this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth ? this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3037
|
+
texture: this.gBufferTextures?.gBufferTexture,
|
|
3038
|
+
blending: 0,
|
|
3039
|
+
colorTransform: De,
|
|
3040
|
+
colorBase: G,
|
|
3041
|
+
multiplyChannels: 0,
|
|
3042
|
+
uvTransform: K
|
|
3043
|
+
}), null) : this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3044
|
+
texture: this.gBufferTextures?.depthBufferTexture,
|
|
3045
|
+
blending: 0,
|
|
3046
|
+
colorTransform: Oe,
|
|
3047
|
+
colorBase: G,
|
|
3048
|
+
multiplyChannels: 0,
|
|
3049
|
+
uvTransform: K
|
|
3050
|
+
}), null);
|
|
3051
|
+
break;
|
|
3052
|
+
case "ssao":
|
|
3053
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3054
|
+
texture: this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,
|
|
3055
|
+
blending: 0,
|
|
3056
|
+
colorTransform: U,
|
|
3057
|
+
colorBase: W,
|
|
3058
|
+
multiplyChannels: 0,
|
|
3059
|
+
uvTransform: K
|
|
3060
|
+
}), null);
|
|
3061
|
+
break;
|
|
3062
|
+
case "ssaodenoise":
|
|
3063
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3064
|
+
texture: this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,
|
|
3065
|
+
blending: 0,
|
|
3066
|
+
colorTransform: U,
|
|
3067
|
+
colorBase: W,
|
|
3068
|
+
multiplyChannels: 0,
|
|
3069
|
+
uvTransform: K
|
|
3070
|
+
}), null);
|
|
3071
|
+
break;
|
|
3072
|
+
case "shadowmap":
|
|
3073
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3074
|
+
texture: this.renderPassManager.screenSpaceShadowMapPass.shadowTexture,
|
|
3075
|
+
blending: 0,
|
|
3076
|
+
colorTransform: U,
|
|
3077
|
+
colorBase: W,
|
|
3078
|
+
multiplyChannels: 0,
|
|
3079
|
+
uvTransform: K
|
|
3080
|
+
}), null);
|
|
3081
|
+
break;
|
|
3082
|
+
case "shadowsoft":
|
|
3083
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3084
|
+
texture: this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,
|
|
3085
|
+
blending: 0,
|
|
3086
|
+
colorTransform: ut.shadowTransform,
|
|
3087
|
+
colorBase: W,
|
|
3088
|
+
multiplyChannels: 0,
|
|
3089
|
+
uvTransform: K
|
|
3090
|
+
}), null);
|
|
3091
|
+
break;
|
|
3092
|
+
case "shadowdenoise":
|
|
3093
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3094
|
+
texture: this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,
|
|
3095
|
+
blending: 0,
|
|
3096
|
+
colorTransform: ut.shadowTransform,
|
|
3097
|
+
colorBase: W,
|
|
3098
|
+
multiplyChannels: 0,
|
|
3099
|
+
uvTransform: K
|
|
3100
|
+
}), null);
|
|
3101
|
+
break;
|
|
3102
|
+
case "shadowfadein":
|
|
3103
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3104
|
+
texture: this.renderPassManager.shadowAndAoPass.fadeRenderTarget.texture,
|
|
3105
|
+
blending: 0,
|
|
3106
|
+
colorTransform: ut.shadowTransform,
|
|
3107
|
+
colorBase: W,
|
|
3108
|
+
multiplyChannels: 0,
|
|
3109
|
+
uvTransform: K
|
|
3110
|
+
}), null);
|
|
3111
|
+
break;
|
|
3112
|
+
case "shadowandao":
|
|
3113
|
+
this.passRenderer.renderScreenSpace(e, this.getBlendAoAndShadowMaterial({
|
|
3114
|
+
texture: this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,
|
|
3115
|
+
blending: 0,
|
|
3116
|
+
aoIntensity: this.renderPassManager.shadowAndAoPass.parameters.aoIntensity,
|
|
3117
|
+
shadowIntensity: this.renderPassManager.shadowAndAoPass.parameters.shadowIntensity
|
|
3118
|
+
}), null);
|
|
3119
|
+
break;
|
|
3120
|
+
case "shadowandaodepth":
|
|
3121
|
+
this.passRenderer.renderScreenSpace(e, this.getBlendAoPassDepthMaterial({
|
|
3122
|
+
texture: this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,
|
|
3123
|
+
blending: 0
|
|
3124
|
+
}), null);
|
|
3125
|
+
break;
|
|
3126
|
+
case "materialao":
|
|
3127
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3128
|
+
texture: this.renderPassManager.aoPassMapTexture,
|
|
3129
|
+
blending: 0,
|
|
3130
|
+
colorTransform: Te,
|
|
3131
|
+
colorBase: W,
|
|
3132
|
+
multiplyChannels: 0,
|
|
3133
|
+
uvTransform: K
|
|
3134
|
+
}), null);
|
|
3135
|
+
break;
|
|
3136
|
+
case "groundreflection":
|
|
3137
|
+
this.passRenderer.renderScreenSpace(e, this.getSrgbToLinearCopyMaterial({
|
|
3138
|
+
texture: this.renderPassManager.groundReflectionPass.reflectionRenderTarget.texture,
|
|
3139
|
+
blending: 0,
|
|
3140
|
+
colorTransform: Te,
|
|
3141
|
+
colorBase: W,
|
|
3142
|
+
multiplyChannels: 0,
|
|
3143
|
+
uvTransform: q
|
|
3144
|
+
}), null);
|
|
3145
|
+
break;
|
|
3146
|
+
case "groundreflectionfinal":
|
|
3147
|
+
this.passRenderer.renderScreenSpace(e, this.getSrgbToLinearCopyMaterial({
|
|
3148
|
+
texture: this.renderPassManager.groundReflectionPass.intensityRenderTarget.texture,
|
|
3149
|
+
blending: 0,
|
|
3150
|
+
colorTransform: Te,
|
|
3151
|
+
colorBase: W,
|
|
3152
|
+
multiplyChannels: 0,
|
|
3153
|
+
uvTransform: q
|
|
3154
|
+
}), null);
|
|
3155
|
+
break;
|
|
3156
|
+
case "bakedgroundshadow":
|
|
3157
|
+
this.passRenderer.renderScreenSpace(e, this.getCopyMaterial({
|
|
3158
|
+
texture: this.renderPassManager.bakedGroundContactShadowPass.renderTarget.texture,
|
|
3159
|
+
blending: 0,
|
|
3160
|
+
colorTransform: Te,
|
|
3161
|
+
colorBase: W,
|
|
3162
|
+
multiplyChannels: 0,
|
|
3163
|
+
uvTransform: K
|
|
3164
|
+
}), null);
|
|
3165
|
+
break;
|
|
3166
|
+
case "environmentmap":
|
|
3167
|
+
this._environmentMapDecodeMaterial.setSourceTexture(this.scene.environment), this.passRenderer.renderScreenSpace(e, this._environmentMapDecodeMaterial, null);
|
|
3168
|
+
break;
|
|
3169
|
+
case "lightsourcedetection":
|
|
3170
|
+
if (this.scene.userData?.environmentDefinition) {
|
|
3171
|
+
let t = this.renderPassManager.aspect, n = new k(-1, 1, 1 / t, -1 / t, -1, 1), r = this.scene.userData?.environmentDefinition.createDebugScene(e, this.scene, this.renderPassManager.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources);
|
|
3172
|
+
r.background = new N(16777215), e.render(r, n);
|
|
3173
|
+
}
|
|
3174
|
+
break;
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
}, hn = class extends J {
|
|
3178
|
+
constructor(e) {
|
|
3179
|
+
super(e), this.drawGround = !0, this.drawWithDebugMaterial = !1, this.grayDebugMaterial = new E({
|
|
3180
|
+
color: 12632256,
|
|
3181
|
+
side: 2,
|
|
3182
|
+
envMapIntensity: .4
|
|
3183
|
+
});
|
|
3184
|
+
}
|
|
3185
|
+
dispose() {
|
|
3186
|
+
super.dispose(), this.grayDebugMaterial.dispose();
|
|
3187
|
+
}
|
|
3188
|
+
renderPass(e) {
|
|
3189
|
+
this.renderCacheManager.onBeforeRender("floorDepthWrite", this.scene), this.renderPassManager.setGroundVisibility(this.drawGround), this.drawWithDebugMaterial ? this.renderCacheManager.render("debug", this.scene, () => {
|
|
3190
|
+
this.passRenderer.renderWithOverrideMaterial(e, this.scene, this.camera, this.grayDebugMaterial, null, 0, 1);
|
|
3191
|
+
}) : e.render(this.scene, this.camera), this.renderPassManager.setGroundVisibility(!1), this.renderCacheManager.onAfterRender("floorDepthWrite");
|
|
3192
|
+
}
|
|
3193
|
+
}, gn = class e {
|
|
3194
|
+
constructor() {
|
|
3195
|
+
this.applyAoAndShadowToAlpha = !1, this._aoPassMapUniform = { value: null }, this._aoPassMapScaleUniform = { value: 1 }, this._aoPassMapIntensityUniform = { value: 1 }, this._shPassMapIntensityUniform = { value: 1 }, this._reflectionPassMapUniform = { value: null }, this._reflectionPassMapScaleUniform = { value: 1 }, this._reflectionPassMapIntensityUniform = { value: 0 }, this.applyReflectionPassMap = !1;
|
|
3196
|
+
}
|
|
3197
|
+
set aoPassMap(e) {
|
|
3198
|
+
this._aoPassMapUniform.value = e;
|
|
3199
|
+
}
|
|
3200
|
+
set aoPassMapScale(e) {
|
|
3201
|
+
this._aoPassMapScaleUniform.value = e;
|
|
3202
|
+
}
|
|
3203
|
+
set aoPassMapIntensity(e) {
|
|
3204
|
+
this._aoPassMapIntensityUniform.value = e;
|
|
3205
|
+
}
|
|
3206
|
+
set shPassMapIntensity(e) {
|
|
3207
|
+
this._shPassMapIntensityUniform.value = e;
|
|
3208
|
+
}
|
|
3209
|
+
set reflectionPassMap(e) {
|
|
3210
|
+
this._reflectionPassMapUniform.value = e;
|
|
3211
|
+
}
|
|
3212
|
+
set reflectionPassMapScale(e) {
|
|
3213
|
+
this._reflectionPassMapScaleUniform.value = e;
|
|
3214
|
+
}
|
|
3215
|
+
set reflectionPassMapIntensity(e) {
|
|
3216
|
+
this._reflectionPassMapIntensityUniform.value = e;
|
|
3217
|
+
}
|
|
3218
|
+
static addPlugin(t) {
|
|
3219
|
+
if (St(t)) return null;
|
|
3220
|
+
if (t.userData.postProcessingMaterialPlugin !== void 0) return t.userData.postProcessingMaterialPlugin instanceof e ? t.userData.postProcessingMaterialPlugin : null;
|
|
3221
|
+
let n = new e();
|
|
3222
|
+
return t.userData.postProcessingMaterialPlugin = n, t.onBeforeCompile = (e, t) => n._onBeforeCompile(e, t), t.customProgramCacheKey = () => n._customProgramCacheKey(), n;
|
|
3223
|
+
}
|
|
3224
|
+
_isEnabled() {
|
|
3225
|
+
return this._aoPassMapUniform.value !== void 0 && this._aoPassMapUniform.value !== null;
|
|
3226
|
+
}
|
|
3227
|
+
_customProgramCacheKey() {
|
|
3228
|
+
let e = "";
|
|
3229
|
+
return this._isEnabled() && (e += "aoPassMap" + (this.applyAoAndShadowToAlpha ? "Alpha" : "")), this.applyReflectionPassMap && (e += "reflectionPassMap"), e;
|
|
3230
|
+
}
|
|
3231
|
+
_onBeforeCompile(e, t) {
|
|
3232
|
+
if (this._isEnabled() || this.applyReflectionPassMap) {
|
|
3233
|
+
let t = this.applyAoAndShadowToAlpha ? "#define USE_APPLY_AO_AND_SHADOW_TO_ALPHA\n" : "";
|
|
3234
|
+
t += this.applyReflectionPassMap ? "#define USE_REFLECTION_PASS_MAP\n" : "", t += _n, e.fragmentShader = e.fragmentShader.replace("#include <aomap_pars_fragment>", t), e.fragmentShader = e.fragmentShader.replace("#include <aomap_fragment>", vn), this._initUniforms(e);
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
_initUniforms(e) {
|
|
3238
|
+
e && (e.uniforms.tAoPassMap = this._aoPassMapUniform, e.uniforms.aoPassMapScale = this._aoPassMapScaleUniform, e.uniforms.aoPassMapIntensity = this._aoPassMapIntensityUniform, e.uniforms.shPassMapIntensity = this._shPassMapIntensityUniform, e.uniforms.tReflectionPassMap = this._reflectionPassMapUniform, e.uniforms.reflectionPassMapScale = this._reflectionPassMapScaleUniform, e.uniforms.reflectionPassMapIntensity = this._reflectionPassMapIntensityUniform);
|
|
3239
|
+
}
|
|
3240
|
+
}, _n = "\n#ifdef USE_AOMAP\n\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n\n#endif\n\n uniform highp sampler2D tAoPassMap;\n uniform float aoPassMapScale;\n uniform float aoPassMapIntensity;\n uniform float shPassMapIntensity;\n uniform sampler2D tReflectionPassMap;\n uniform float reflectionPassMapScale;\n uniform float reflectionPassMapIntensity;\n", vn = "\n#ifndef AOPASSMAP_SWIZZLE\n #define AOPASSMAP_SWIZZLE rg\n#endif\n\nfloat ambientOcclusion = 1.0;\nfloat shadowValue = 1.0;\n\n#ifdef USE_AOMAP\n\n // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n ambientOcclusion = texture2D( aoMap, vAoMapUv ).r;\n ambientOcclusion = ( ambientOcclusion - 1.0 ) * aoMapIntensity + 1.0;\n\n#endif\n\n vec4 aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ), 0 );\n vec2 aoAndShadow = aoAndShadowMap.rg;\n float depthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n const ivec2 aoOffsetArray[8] = ivec2[8](\n ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1), ivec2(1, 1), ivec2(-1, 1), ivec2(1, -1), ivec2(-1, -1));\n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n if (testDepthDelta < depthDelta) {\n aoAndShadow = aoAndShadowMap.rg;\n depthDelta = testDepthDelta;\n }\n }\n\n float aoPassMapValue = aoPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.r - 1.0) * aoPassMapIntensity + 1.0);\n shadowValue = shPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.g - 1.0) * shPassMapIntensity + 1.0);\n\n #ifdef USE_REFLECTION_PASS_MAP\n\n ivec2 reflectionPassMapSize = textureSize( tReflectionPassMap, 0 );\n vec2 reflectionPassMapUv = vec2( gl_FragCoord.x * reflectionPassMapScale, float(reflectionPassMapSize.y) - gl_FragCoord.y * reflectionPassMapScale );\n vec4 reflectionPassMapColor = texture2D( tReflectionPassMap, reflectionPassMapUv / vec2(reflectionPassMapSize) );\n if (reflectionPassMapColor.a > 0.0) reflectionPassMapColor.rgb /= reflectionPassMapColor.a;\n vec3 diffuseReflectionPassMapColor = reflectionPassMapColor.rgb * material.diffuseColor;\n reflectedLight.indirectDiffuse += diffuseReflectionPassMapColor * reflectionPassMapColor.a * reflectionPassMapIntensity;\n //reflectedLight.indirectDiffuse = mix(reflectedLight.indirectDiffuse, diffuseReflectionPassMapColor, reflectionPassMapColor.a * reflectionPassMapIntensity);\n\n #endif\n\n #if defined ( USE_APPLY_AO_AND_SHADOW_TO_ALPHA )\n diffuseColor.a = 1.0 - (1.0 - diffuseColor.a) * aoPassMapValue * shadowValue;\n #else\n ambientOcclusion = min( ambientOcclusion, aoPassMapValue );\n #endif\n\n reflectedLight.indirectDiffuse *= ambientOcclusion * shadowValue;\n\n #if defined( USE_CLEARCOAT )\n clearcoatSpecularIndirect *= ambientOcclusion * shadowValue;\n #endif\n\n #if defined( USE_SHEEN )\n sheenSpecularIndirect *= ambientOcclusion * shadowValue;\n #endif\n\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\n float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion * shadowValue, material.roughness );\n reflectedLight.indirectSpecular *= specularOcclusion;\n\n #ifdef USE_REFLECTION_PASS_MAP\n reflectedLight.indirectSpecular += material.specularColor * reflectionPassMapColor.rgb * reflectionPassMapColor.a * reflectionPassMapIntensity * specularOcclusion;\n #endif\n\n #endif\n", yn = class extends Fe {
|
|
3241
|
+
constructor(e, t = "tDiffuse") {
|
|
3242
|
+
super(), this.textureID = t, this.uniforms = null, this.material = null, e instanceof z ? (this.uniforms = e.uniforms, this.material = e) : e && (this.uniforms = y.clone(e.uniforms), this.material = new z({
|
|
3243
|
+
name: e.name === void 0 ? "unspecified" : e.name,
|
|
3244
|
+
defines: Object.assign({}, e.defines),
|
|
3245
|
+
uniforms: this.uniforms,
|
|
3246
|
+
vertexShader: e.vertexShader,
|
|
3247
|
+
fragmentShader: e.fragmentShader
|
|
3248
|
+
})), this._fsQuad = new Re(this.material);
|
|
3249
|
+
}
|
|
3250
|
+
render(e, t, n) {
|
|
3251
|
+
this.uniforms[this.textureID] && (this.uniforms[this.textureID].value = n.texture), this._fsQuad.material = this.material, this.renderToScreen ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(t), this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), this._fsQuad.render(e));
|
|
3252
|
+
}
|
|
3253
|
+
dispose() {
|
|
3254
|
+
this.material.dispose(), this._fsQuad.dispose();
|
|
3255
|
+
}
|
|
3256
|
+
}, bn = {
|
|
3257
|
+
name: "LUTShader",
|
|
3258
|
+
uniforms: {
|
|
3259
|
+
lut: { value: null },
|
|
3260
|
+
lutSize: { value: 0 },
|
|
3261
|
+
tDiffuse: { value: null },
|
|
3262
|
+
intensity: { value: 1 }
|
|
3263
|
+
},
|
|
3264
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",
|
|
3265
|
+
fragmentShader: "\n\n uniform float lutSize;\n uniform sampler3D lut;\n\n varying vec2 vUv;\n uniform float intensity;\n uniform sampler2D tDiffuse;\n void main() {\n\n vec4 val = texture2D( tDiffuse, vUv );\n vec4 lutVal;\n\n // pull the sample in by half a pixel so the sample begins\n // at the center of the edge pixels.\n float pixelWidth = 1.0 / lutSize;\n float halfPixelWidth = 0.5 / lutSize;\n vec3 uvw = vec3( halfPixelWidth ) + val.rgb * ( 1.0 - pixelWidth );\n\n\n lutVal = vec4( texture( lut, uvw ).rgb, val.a );\n\n gl_FragColor = vec4( mix( val, lutVal, intensity ) );\n\n }\n\n "
|
|
3266
|
+
}, xn = class extends yn {
|
|
3267
|
+
constructor(e = {}) {
|
|
3268
|
+
super(bn), this.lut = e.lut || null, this.intensity = "intensity" in e ? e.intensity : 1;
|
|
3269
|
+
}
|
|
3270
|
+
set lut(e) {
|
|
3271
|
+
let t = this.material;
|
|
3272
|
+
e !== this.lut && (t.uniforms.lut.value = null, e && (t.uniforms.lutSize.value = e.image.width, t.uniforms.lut.value = e));
|
|
3273
|
+
}
|
|
3274
|
+
get lut() {
|
|
3275
|
+
return this.material.uniforms.lut.value;
|
|
3276
|
+
}
|
|
3277
|
+
set intensity(e) {
|
|
3278
|
+
this.material.uniforms.intensity.value = e;
|
|
3279
|
+
}
|
|
3280
|
+
get intensity() {
|
|
3281
|
+
return this.material.uniforms.intensity.value;
|
|
3282
|
+
}
|
|
3283
|
+
}, Sn = class extends o {
|
|
3284
|
+
constructor(e) {
|
|
3285
|
+
super(e), this.type = P;
|
|
3286
|
+
}
|
|
3287
|
+
setType(e) {
|
|
3288
|
+
return this.type = e, this;
|
|
3289
|
+
}
|
|
3290
|
+
load(e, t, n, i) {
|
|
3291
|
+
let a = new r(this.manager);
|
|
3292
|
+
a.setPath(this.path), a.setResponseType("text"), a.load(e, (n) => {
|
|
3293
|
+
try {
|
|
3294
|
+
t(this.parse(n));
|
|
3295
|
+
} catch (t) {
|
|
3296
|
+
i ? i(t) : console.error(t), this.manager.itemError(e);
|
|
3297
|
+
}
|
|
3298
|
+
}, n, i);
|
|
3299
|
+
}
|
|
3300
|
+
parse(e) {
|
|
3301
|
+
let t = /TITLE +"([^"]*)"/, n = /LUT_3D_SIZE +(\d+)/, r = /DOMAIN_MIN +([\d.]+) +([\d.]+) +([\d.]+)/, i = /DOMAIN_MAX +([\d.]+) +([\d.]+) +([\d.]+)/, a = /^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm, o = t.exec(e), s = o === null ? null : o[1];
|
|
3302
|
+
if (o = n.exec(e), o === null) throw Error("LUTCubeLoader: Missing LUT_3D_SIZE information");
|
|
3303
|
+
let c = Number(o[1]), l = c ** 3 * 4, u = this.type === 1009 ? new Uint8Array(l) : new Float32Array(l), d = new S(0, 0, 0), f = new S(1, 1, 1);
|
|
3304
|
+
if (o = r.exec(e), o !== null && d.set(Number(o[1]), Number(o[2]), Number(o[3])), o = i.exec(e), o !== null && f.set(Number(o[1]), Number(o[2]), Number(o[3])), d.x > f.x || d.y > f.y || d.z > f.z) throw Error("LUTCubeLoader: Invalid input domain");
|
|
3305
|
+
let p = this.type === 1009 ? 255 : 1, m = 0;
|
|
3306
|
+
for (; (o = a.exec(e)) !== null;) u[m++] = Number(o[1]) * p, u[m++] = Number(o[2]) * p, u[m++] = Number(o[3]) * p, u[m++] = p;
|
|
3307
|
+
let h = new le();
|
|
3308
|
+
return h.image.data = u, h.image.width = c, h.image.height = c, h.image.depth = c, h.type = this.type, h.magFilter = w, h.minFilter = w, h.wrapS = L, h.wrapT = L, h.wrapR = L, h.generateMipmaps = !1, h.needsUpdate = !0, {
|
|
3309
|
+
title: s,
|
|
3310
|
+
size: c,
|
|
3311
|
+
domainMin: d,
|
|
3312
|
+
domainMax: f,
|
|
3313
|
+
texture3D: h
|
|
3314
|
+
};
|
|
3315
|
+
}
|
|
3316
|
+
}, Cn = class extends o {
|
|
3317
|
+
constructor(e) {
|
|
3318
|
+
super(e), this.flip = !1;
|
|
3319
|
+
}
|
|
3320
|
+
load(e, t, n, r) {
|
|
3321
|
+
let i = new ue(this.manager);
|
|
3322
|
+
i.setCrossOrigin(this.crossOrigin), i.setPath(this.path), i.load(e, (n) => {
|
|
3323
|
+
try {
|
|
3324
|
+
let e;
|
|
3325
|
+
e = n.image.width < n.image.height ? this._getImageData(n) : this._horz2Vert(n), t(this.parse(e.data, Math.min(n.image.width, n.image.height)));
|
|
3326
|
+
} catch (t) {
|
|
3327
|
+
r ? r(t) : console.error(t), this.manager.itemError(e);
|
|
3328
|
+
}
|
|
3329
|
+
}, n, r);
|
|
3330
|
+
}
|
|
3331
|
+
parse(e, t) {
|
|
3332
|
+
let n = new Uint8Array(e), r = new le();
|
|
3333
|
+
return r.image.data = n, r.image.width = t, r.image.height = t, r.image.depth = t, r.format = R, r.type = P, r.magFilter = w, r.minFilter = w, r.wrapS = L, r.wrapT = L, r.wrapR = L, r.generateMipmaps = !1, r.needsUpdate = !0, {
|
|
3334
|
+
size: t,
|
|
3335
|
+
texture3D: r
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3338
|
+
_getImageData(e) {
|
|
3339
|
+
let t = e.image.width, n = e.image.height, r = document.createElement("canvas");
|
|
3340
|
+
r.width = t, r.height = n;
|
|
3341
|
+
let i = r.getContext("2d");
|
|
3342
|
+
return this.flip === !0 && (i.scale(1, -1), i.translate(0, -n)), i.drawImage(e.image, 0, 0), i.getImageData(0, 0, t, n);
|
|
3343
|
+
}
|
|
3344
|
+
_horz2Vert(e) {
|
|
3345
|
+
let t = e.image.height, n = e.image.width, r = document.createElement("canvas");
|
|
3346
|
+
r.width = t, r.height = n;
|
|
3347
|
+
let i = r.getContext("2d");
|
|
3348
|
+
this.flip === !0 && (i.scale(1, -1), i.translate(0, -n));
|
|
3349
|
+
for (let r = 0; r < t; r++) {
|
|
3350
|
+
let a = r * t, o = this.flip ? n - r * t : r * t;
|
|
3351
|
+
i.drawImage(e.image, a, 0, t, t, 0, o, t, t);
|
|
3352
|
+
}
|
|
3353
|
+
return i.getImageData(0, 0, t, n);
|
|
3354
|
+
}
|
|
3355
|
+
}, wn = class extends o {
|
|
3356
|
+
constructor(e) {
|
|
3357
|
+
super(e), this.type = P;
|
|
3358
|
+
}
|
|
3359
|
+
setType(e) {
|
|
3360
|
+
return this.type = e, this;
|
|
3361
|
+
}
|
|
3362
|
+
load(e, t, n, i) {
|
|
3363
|
+
let a = new r(this.manager);
|
|
3364
|
+
a.setPath(this.path), a.setResponseType("text"), a.load(e, (n) => {
|
|
3365
|
+
try {
|
|
3366
|
+
t(this.parse(n));
|
|
3367
|
+
} catch (t) {
|
|
3368
|
+
i ? i(t) : console.error(t), this.manager.itemError(e);
|
|
3369
|
+
}
|
|
3370
|
+
}, n, i);
|
|
3371
|
+
}
|
|
3372
|
+
parse(e) {
|
|
3373
|
+
let t = /^[\d ]+$/m, n = /^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm, r = t.exec(e);
|
|
3374
|
+
if (r === null) throw Error("LUT3dlLoader: Missing grid information");
|
|
3375
|
+
let i = r[0].trim().split(/\s+/g).map(Number), a = i[1] - i[0], o = i.length, s = o ** 2;
|
|
3376
|
+
for (let e = 1, t = i.length; e < t; ++e) if (a !== i[e] - i[e - 1]) throw Error("LUT3dlLoader: Inconsistent grid size");
|
|
3377
|
+
let c = new Float32Array(o ** 3 * 4), l = 0, u = 0;
|
|
3378
|
+
for (; (r = n.exec(e)) !== null;) {
|
|
3379
|
+
let e = Number(r[1]), t = Number(r[2]), n = Number(r[3]);
|
|
3380
|
+
l = Math.max(l, e, t, n);
|
|
3381
|
+
let i = u % o, a = Math.floor(u / o) % o, d = Math.floor(u / s) % o, f = (i * s + a * o + d) * 4;
|
|
3382
|
+
c[f + 0] = e, c[f + 1] = t, c[f + 2] = n, ++u;
|
|
3383
|
+
}
|
|
3384
|
+
let d = 2 ** Math.ceil(Math.log2(l)), f = this.type === 1009 ? new Uint8Array(c.length) : c, p = this.type === 1009 ? 255 : 1;
|
|
3385
|
+
for (let e = 0, t = f.length; e < t; e += 4) {
|
|
3386
|
+
let t = e + 1, n = e + 2, r = e + 3;
|
|
3387
|
+
f[e] = c[e] / d * p, f[t] = c[t] / d * p, f[n] = c[n] / d * p, f[r] = p;
|
|
3388
|
+
}
|
|
3389
|
+
let m = new le();
|
|
3390
|
+
return m.image.data = f, m.image.width = o, m.image.height = o, m.image.depth = o, m.format = R, m.type = this.type, m.magFilter = w, m.minFilter = w, m.wrapS = L, m.wrapT = L, m.wrapR = L, m.generateMipmaps = !1, m.needsUpdate = !0, {
|
|
3391
|
+
size: o,
|
|
3392
|
+
texture3D: m
|
|
3393
|
+
};
|
|
3394
|
+
}
|
|
3395
|
+
}, Tn = {
|
|
3396
|
+
name: "OutputShader",
|
|
3397
|
+
uniforms: {
|
|
3398
|
+
tDiffuse: { value: null },
|
|
3399
|
+
toneMappingExposure: { value: 1 }
|
|
3400
|
+
},
|
|
3401
|
+
vertexShader: "\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
3402
|
+
fragmentShader: "\n\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n varying vec2 vUv;\n\n void main() {\n\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n // tone mapping\n\n #ifdef LINEAR_TONE_MAPPING\n\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\n #elif defined( REINHARD_TONE_MAPPING )\n\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\n #elif defined( CINEON_TONE_MAPPING )\n\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\n #elif defined( AGX_TONE_MAPPING )\n\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\n #elif defined( NEUTRAL_TONE_MAPPING )\n\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\n #elif defined( CUSTOM_TONE_MAPPING )\n\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\n #endif\n\n // color space\n\n #ifdef SRGB_TRANSFER\n\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n\n #endif\n\n }"
|
|
3403
|
+
}, En = class extends Fe {
|
|
3404
|
+
constructor() {
|
|
3405
|
+
super(), this.isOutputPass = !0, this.uniforms = y.clone(Tn.uniforms), this.material = new oe({
|
|
3406
|
+
name: Tn.name,
|
|
3407
|
+
uniforms: this.uniforms,
|
|
3408
|
+
vertexShader: Tn.vertexShader,
|
|
3409
|
+
fragmentShader: Tn.fragmentShader
|
|
3410
|
+
}), this._fsQuad = new Re(this.material), this._outputColorSpace = null, this._toneMapping = null;
|
|
3411
|
+
}
|
|
3412
|
+
render(e, t, n) {
|
|
3413
|
+
this.uniforms.tDiffuse.value = n.texture, this.uniforms.toneMappingExposure.value = e.toneMappingExposure, (this._outputColorSpace !== e.outputColorSpace || this._toneMapping !== e.toneMapping) && (this._outputColorSpace = e.outputColorSpace, this._toneMapping = e.toneMapping, this.material.defines = {}, j.getTransfer(this._outputColorSpace) === "srgb" && (this.material.defines.SRGB_TRANSFER = ""), this._toneMapping === 1 ? this.material.defines.LINEAR_TONE_MAPPING = "" : this._toneMapping === 2 ? this.material.defines.REINHARD_TONE_MAPPING = "" : this._toneMapping === 3 ? this.material.defines.CINEON_TONE_MAPPING = "" : this._toneMapping === 4 ? this.material.defines.ACES_FILMIC_TONE_MAPPING = "" : this._toneMapping === 6 ? this.material.defines.AGX_TONE_MAPPING = "" : this._toneMapping === 7 ? this.material.defines.NEUTRAL_TONE_MAPPING = "" : this._toneMapping === 5 && (this.material.defines.CUSTOM_TONE_MAPPING = ""), this.material.needsUpdate = !0), this.renderToScreen === !0 ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(t), this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), this._fsQuad.render(e));
|
|
3414
|
+
}
|
|
3415
|
+
dispose() {
|
|
3416
|
+
this.material.dispose(), this._fsQuad.dispose();
|
|
3417
|
+
}
|
|
3418
|
+
}, Dn = {
|
|
3419
|
+
enabled: !1,
|
|
3420
|
+
intensity: 1,
|
|
3421
|
+
lut: "Bourbon 64"
|
|
3422
|
+
}, On = class {
|
|
3423
|
+
get passRenderer() {
|
|
3424
|
+
return this._passRenderer;
|
|
3425
|
+
}
|
|
3426
|
+
get scene() {
|
|
3427
|
+
return this._scene;
|
|
3428
|
+
}
|
|
3429
|
+
get camera() {
|
|
3430
|
+
return this._camera;
|
|
3431
|
+
}
|
|
3432
|
+
get aspect() {
|
|
3433
|
+
return this._sceneRenderer.width / this._sceneRenderer.height;
|
|
3434
|
+
}
|
|
3435
|
+
get cameraChanged() {
|
|
3436
|
+
return this._cameraChanged;
|
|
3437
|
+
}
|
|
3438
|
+
get noOStaticFrames() {
|
|
3439
|
+
return this._noOStaticFrames;
|
|
3440
|
+
}
|
|
3441
|
+
get renderCacheManager() {
|
|
3442
|
+
return this._sceneRenderer.renderCacheManager;
|
|
3443
|
+
}
|
|
3444
|
+
get parameters() {
|
|
3445
|
+
return this._sceneRenderer.parameters;
|
|
3446
|
+
}
|
|
3447
|
+
get sceneRenderPass() {
|
|
3448
|
+
return this._sceneRenderPass;
|
|
3449
|
+
}
|
|
3450
|
+
get bakedGroundContactShadowPass() {
|
|
3451
|
+
return this._bakedGroundContactShadowPass;
|
|
3452
|
+
}
|
|
3453
|
+
get gBufferRenderPass() {
|
|
3454
|
+
return this._gBufferRenderPass;
|
|
3455
|
+
}
|
|
3456
|
+
get groundReflectionPass() {
|
|
3457
|
+
return this._groundReflectionPass;
|
|
3458
|
+
}
|
|
3459
|
+
get screenSpaceShadowMapPass() {
|
|
3460
|
+
return this._screenSpaceShadowMapPass;
|
|
3461
|
+
}
|
|
3462
|
+
get shadowAndAoPass() {
|
|
3463
|
+
return this._shadowAndAoPass;
|
|
3464
|
+
}
|
|
3465
|
+
get lutPassParameters() {
|
|
3466
|
+
return this._lutPassParameters;
|
|
3467
|
+
}
|
|
3468
|
+
get lutMaps() {
|
|
3469
|
+
return Array.from(this._lutMap.keys());
|
|
3470
|
+
}
|
|
3471
|
+
get outlinePass() {
|
|
3472
|
+
return this._outlinePass;
|
|
3473
|
+
}
|
|
3474
|
+
get outlineRenderer() {
|
|
3475
|
+
return this._sceneRenderer.outlineRenderer;
|
|
3476
|
+
}
|
|
3477
|
+
get debugPass() {
|
|
3478
|
+
return this._debugPass ??= new mn(this), this._debugPass;
|
|
3479
|
+
}
|
|
3480
|
+
get debugOutput() {
|
|
3481
|
+
return this._sceneRenderer.debugOutput;
|
|
3482
|
+
}
|
|
3483
|
+
constructor(e, t) {
|
|
3484
|
+
this.materialsNeedUpdate = !0, this._passRenderer = new qe(), this._outlinePass = null, this._debugPass = null, this._cameraUpdate = new We(), this._cameraChanged = !0, this._noUpdateNeededCount = 0, this._noOStaticFrames = 0, this._maxSamples = 1, this._passUpdateStates = {
|
|
3485
|
+
updateGroundReflection: !1,
|
|
3486
|
+
updateGBuffer: !1,
|
|
3487
|
+
updateScreenSpaceShadow: !1,
|
|
3488
|
+
updateShadowAndAoPass: !1,
|
|
3489
|
+
updateOutlinePass: !1,
|
|
3490
|
+
updateDebugPass: !1
|
|
3491
|
+
}, this.aoPassMapTexture = null, this._lutMap = /* @__PURE__ */ new Map(), this._lutPassParameters = Dn, this.lutPassNeedsUpdate = !1, this._renderToRenderTarget = !1, this._creator_ = e, this._sceneRenderer = t, this._maxSamples = Ue(this._sceneRenderer.renderer);
|
|
3492
|
+
let n = this._sceneRenderer.linearAoFilter, r = n ? this._maxSamples : 0, i = n ? this._maxSamples : 0;
|
|
3493
|
+
this._sceneRenderPass = new hn(this), this._bakedGroundContactShadowPass = new kt(this, this._sceneRenderer.renderer, this._sceneRenderer.groundGroup, { sharedShadowGroundPlane: this._sceneRenderer.shadowAndAoGroundPlane }), this._gBufferRenderPass = new Pt(this, {
|
|
3494
|
+
shared: !0,
|
|
3495
|
+
capabilities: this._sceneRenderer.renderer.capabilities,
|
|
3496
|
+
width: this._sceneRenderer.width,
|
|
3497
|
+
height: this._sceneRenderer.height,
|
|
3498
|
+
samples: r,
|
|
3499
|
+
textureMinificationFilter: n ? w : p,
|
|
3500
|
+
textureMagnificationFilter: n ? w : p
|
|
3501
|
+
}), this._groundReflectionPass = new It(this, this._sceneRenderer.width, this._sceneRenderer.height, this._maxSamples, {}), this._screenSpaceShadowMapPass = new Kt(this, new m(this._sceneRenderer.width, this._sceneRenderer.height), {
|
|
3502
|
+
samples: i,
|
|
3503
|
+
alwaysUpdate: !1
|
|
3504
|
+
}), this._shadowAndAoPass = new ut(this, this._sceneRenderer.width, this._sceneRenderer.height, r), this._lutPass = new xn({
|
|
3505
|
+
lut: void 0,
|
|
3506
|
+
intensity: 1
|
|
3507
|
+
}), this._outputPass = new En();
|
|
3508
|
+
}
|
|
3509
|
+
dispose() {
|
|
3510
|
+
this._sceneRenderPass.dispose(), this._bakedGroundContactShadowPass.dispose(), this._gBufferRenderPass.dispose(), this._groundReflectionPass.dispose(), this._screenSpaceShadowMapPass.dispose(), this._shadowAndAoPass.dispose(), this._outlinePass?.dispose(), this._lutPass.dispose(), this._outputPass.dispose(), this._passRenderTarget?.dispose(), this._passPassRenderTarget?.dispose();
|
|
3511
|
+
}
|
|
3512
|
+
setSize(e, t) {
|
|
3513
|
+
this._gBufferRenderPass.setSize(e, t), this._groundReflectionPass.setSize(e, t), this._screenSpaceShadowMapPass.setSize(e, t), this._shadowAndAoPass.setSize(e, t), this._outlinePass?.setSize(e, t);
|
|
3514
|
+
let n = this._sceneRenderer.renderer.getPixelRatio(), r = e * n, i = t * n;
|
|
3515
|
+
this._lutPass.setSize(r, i), this._outputPass.setSize(r, i), this._passRenderTarget?.setSize(r, i), this._passPassRenderTarget?.setSize(r, i);
|
|
3516
|
+
}
|
|
3517
|
+
loadLutImage(e, t) {
|
|
3518
|
+
this._lutMap.set(e, null), new Cn().load(t, (t) => {
|
|
3519
|
+
this._lutMap.set(e, t);
|
|
3520
|
+
});
|
|
3521
|
+
}
|
|
3522
|
+
loadLutCube(e, t) {
|
|
3523
|
+
this._lutMap.set(e, null), new Sn().load(t, (t) => {
|
|
3524
|
+
this._lutMap.set(e, t);
|
|
3525
|
+
});
|
|
3526
|
+
}
|
|
3527
|
+
loadLut3dl(e, t) {
|
|
3528
|
+
this._lutMap.set(e, null), new wn().load(t, (t) => {
|
|
3529
|
+
this._lutMap.set(e, t);
|
|
3530
|
+
});
|
|
3531
|
+
}
|
|
3532
|
+
createOutlinePass() {
|
|
3533
|
+
return this._outlinePass ||= new nn(this, new m(this._sceneRenderer.width, this._sceneRenderer.height), this.scene, this.camera, [], {
|
|
3534
|
+
downSampleRatio: 2,
|
|
3535
|
+
edgeDetectionFxaa: !0
|
|
3536
|
+
}), this._outlinePass;
|
|
3537
|
+
}
|
|
3538
|
+
getRenderPassRenderTarget(e) {
|
|
3539
|
+
return this._lutPassParameters.enabled ? (this._passRenderTarget = this._passRenderTarget ?? new u(this._sceneRenderer.width * e.getPixelRatio(), this._sceneRenderer.height * e.getPixelRatio(), {
|
|
3540
|
+
type: 1016,
|
|
3541
|
+
samples: this._maxSamples
|
|
3542
|
+
}), this._passRenderTarget) : null;
|
|
3543
|
+
}
|
|
3544
|
+
getPostPassRenderTarget(e) {
|
|
3545
|
+
return this._lutPassParameters.enabled ? (this._passPassRenderTarget = this._passPassRenderTarget ?? new u(this._sceneRenderer.width * e.getPixelRatio(), this._sceneRenderer.height * e.getPixelRatio(), { type: 1016 }), this._passPassRenderTarget) : null;
|
|
3546
|
+
}
|
|
3547
|
+
setGroundVisibility(e) {
|
|
3548
|
+
this._sceneRenderer.shadowAndAoGroundPlane.setVisibility(e);
|
|
3549
|
+
}
|
|
3550
|
+
updatePasses(e, t, n) {
|
|
3551
|
+
this._scene = t, this._camera = n, this._cameraChanged = this._cameraUpdate.changed(n);
|
|
3552
|
+
let r = this._evaluateIfShadowAndAoUpdateIsNeeded();
|
|
3553
|
+
this._renderToRenderTarget = this._lutPassParameters.enabled, this._updateSceneRenderPass(), this._updateBakedGroundContactShadowPass(), this._updateGBufferPass(r), this._updateGroundReflectionPass(r), this._updateScreenSpaceShadowPass(r), this._updateShadowAndAoPass(r), this._updateLutPass(), this._updateOutlinePass(), this._updateDebugPass();
|
|
3554
|
+
}
|
|
3555
|
+
_evaluateIfShadowAndAoUpdateIsNeeded() {
|
|
3556
|
+
let e = this._shadowAndAoPass.parameters.alwaysUpdate || this._screenSpaceShadowMapPass.needsUpdate || this._screenSpaceShadowMapPass.shadowTypeNeedsUpdate, t = (this._shadowAndAoPass.parameters.enabled || this._groundReflectionPass.parameters.enabled) && this._cameraChanged, n = 1;
|
|
3557
|
+
t && (this._noUpdateNeededCount = 0, this._noOStaticFrames = 0), e || (this._noUpdateNeededCount++, t = this._noUpdateNeededCount >= this.parameters.effectSuspendFrames, n = Math.max(0, Math.min(1, (this._noUpdateNeededCount - this.parameters.effectSuspendFrames) / this.parameters.effectFadeInFrames))), !e && n === 1 && this._noOStaticFrames++, t = e || t;
|
|
3558
|
+
let r = !t || n < .99 ? this.parameters.shadowOnCameraChange : Z.OFF;
|
|
3559
|
+
return {
|
|
3560
|
+
needsUpdate: t,
|
|
3561
|
+
shadowOnCameraChange: r,
|
|
3562
|
+
intensityScale: n
|
|
3563
|
+
};
|
|
3564
|
+
}
|
|
3565
|
+
_dynamicChanges(e) {
|
|
3566
|
+
return e.needsUpdate || e.shadowOnCameraChange !== Z.OFF;
|
|
3567
|
+
}
|
|
3568
|
+
_updateSceneRenderPass() {
|
|
3569
|
+
this._sceneRenderPass.drawWithDebugMaterial = !1;
|
|
3570
|
+
}
|
|
3571
|
+
_updateBakedGroundContactShadowPass() {
|
|
3572
|
+
let e = this._bakedGroundContactShadowPass.limitPlaneSize;
|
|
3573
|
+
this._bakedGroundContactShadowPass.limitPlaneSize = this._bakedGroundContactShadowPass.parameters.enabled, (e !== this._bakedGroundContactShadowPass.limitPlaneSize || this._bakedGroundContactShadowPass.needsUpdate) && this._bakedGroundContactShadowPass.updateBounds(this._sceneRenderer.boundingVolume, this._sceneRenderer.groundLevel), this._sceneRenderPass.drawGround = this._bakedGroundContactShadowPass.parameters.enabled || this._shadowAndAoPass.parameters.applyToMaterial;
|
|
3574
|
+
}
|
|
3575
|
+
_updateGBufferPass(e) {
|
|
3576
|
+
this._passUpdateStates.updateGBuffer = !1, this._gBufferRenderPass.needsUpdate = e.needsUpdate || e.shadowOnCameraChange === Z.POISSON, this.gBufferRenderPass.drawGround = this._sceneRenderer.boundingVolumeSet && this._shadowAndAoPass.parameters.aoOnGround;
|
|
3577
|
+
}
|
|
3578
|
+
_updateGroundReflectionPass(e) {
|
|
3579
|
+
this._passUpdateStates.updateGroundReflection = !1, this._groundReflectionPass.parameters.enabled && this._dynamicChanges(e) && (!this.parameters.suspendGroundReflection || e.needsUpdate) && (this._groundReflectionPass.reflectionFadeInScale = this.parameters.suspendGroundReflection ? e.intensityScale : 1, this._passUpdateStates.updateGroundReflection = !0);
|
|
3580
|
+
}
|
|
3581
|
+
_updateScreenSpaceShadowPass(e) {
|
|
3582
|
+
if (!this._dynamicChanges(e)) {
|
|
3583
|
+
this._passUpdateStates.updateScreenSpaceShadow = !1;
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
this._screenSpaceShadowMapPass.parameters.alwaysUpdate = this._shadowAndAoPass.parameters.alwaysUpdate, this._screenSpaceShadowMapPass.drawGround = this._shadowAndAoPass.parameters.shadowOnGround, this._passUpdateStates.updateScreenSpaceShadow = this._shadowAndAoPass.parameters.shadowIntensity > 0, this._passUpdateStates.updateScreenSpaceShadow = !0, this._passUpdateStates.updateGBuffer = !0;
|
|
3587
|
+
}
|
|
3588
|
+
_updateShadowAndAoPass(e) {
|
|
3589
|
+
if (!this._dynamicChanges(e)) {
|
|
3590
|
+
this._passUpdateStates.updateShadowAndAoPass = !1;
|
|
3591
|
+
return;
|
|
3592
|
+
}
|
|
3593
|
+
this._shadowAndAoPass.shadowAndAoPassSettings = {
|
|
3594
|
+
shadowMapTexture: this._screenSpaceShadowMapPass.shadowTexture,
|
|
3595
|
+
shadowBlurType: e.needsUpdate ? Z.FULL : e.shadowOnCameraChange,
|
|
3596
|
+
shadowFadeInBlurType: e.shadowOnCameraChange,
|
|
3597
|
+
shadowFadeInMix: 1 - e.intensityScale,
|
|
3598
|
+
noOStaticFrames: this.noOStaticFrames
|
|
3599
|
+
}, this._passUpdateStates.updateShadowAndAoPass = !0, this._passUpdateStates.updateGBuffer = !0;
|
|
3600
|
+
}
|
|
3601
|
+
_updateLutPass() {
|
|
3602
|
+
if (!(!this._lutPassParameters.enabled || !this.lutPassNeedsUpdate) && (this.lutPassNeedsUpdate = !1, this._lutPass.enabled = this._lutPassParameters.enabled, this._lutPass.intensity = this._lutPassParameters.intensity, this._lutMap.has(this._lutPassParameters.lut))) {
|
|
3603
|
+
let e = this._lutMap.get(this._lutPassParameters.lut);
|
|
3604
|
+
e?.texture3D && (this._lutPass.lut = e.texture3D);
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
_updateOutlinePass() {
|
|
3608
|
+
if (!this.outlineRenderer.outlinePassActivated || !this.outlineRenderer.outlinePass) {
|
|
3609
|
+
this._passUpdateStates.updateOutlinePass = !1;
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
this.outlineRenderer.outlinePass.renderToScreen = !1, this.outlineRenderer.outlinePass.clearBackground = !1, this._passUpdateStates.updateOutlinePass = !0, this._passUpdateStates.updateGBuffer = !0;
|
|
3613
|
+
}
|
|
3614
|
+
_updateDebugPass() {
|
|
3615
|
+
if (!this.debugOutput || this.debugOutput === "" || this.debugOutput === "off") {
|
|
3616
|
+
this._passUpdateStates.updateDebugPass = !1;
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
if (this.debugOutput === "outline" && this.outlineRenderer.outlinePass) {
|
|
3620
|
+
this.outlineRenderer.outlinePass.clearBackground = !0, this._passUpdateStates.updateDebugPass = !1;
|
|
3621
|
+
return;
|
|
3622
|
+
}
|
|
3623
|
+
if (this.debugOutput === "color" || this.debugOutput === "grayscale") {
|
|
3624
|
+
this._passUpdateStates.updateGroundReflection = !1, this._passUpdateStates.updateGBuffer = !1, this._passUpdateStates.updateScreenSpaceShadow = !1, this._passUpdateStates.updateShadowAndAoPass = !1, this._passUpdateStates.updateOutlinePass = !1, this._passUpdateStates.updateDebugPass = !1, this._sceneRenderPass.drawWithDebugMaterial = this.debugOutput === "grayscale";
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
this.debugPass.debugOutput = this.debugOutput, this._passUpdateStates.updateDebugPass = !0;
|
|
3628
|
+
}
|
|
3629
|
+
_updateMaterials(e, t) {
|
|
3630
|
+
if (!this.materialsNeedUpdate || !this._shadowAndAoPass.parameters.applyToMaterial) return;
|
|
3631
|
+
this.aoPassMapTexture = this._shadowAndAoPass.denoiseRenderTargetTexture;
|
|
3632
|
+
let n = e.getPixelRatio();
|
|
3633
|
+
this.materialsNeedUpdate = !1, t.traverse((e) => {
|
|
3634
|
+
if (e.isMesh) {
|
|
3635
|
+
let t = e.material;
|
|
3636
|
+
t instanceof E && this._updateMaterial(e, t, n);
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
_updateMaterial(e, t, n) {
|
|
3641
|
+
let r = gn.addPlugin(t);
|
|
3642
|
+
r && (this._updatePlugInAo(r, e, t, n), this._updatePlugInReflection(r, e), t.needsUpdate = !1);
|
|
3643
|
+
}
|
|
3644
|
+
_updatePlugInAo(e, t, n, r) {
|
|
3645
|
+
let i = this._shadowAndAoPass.parameters.enabled && this._shadowAndAoPass.parameters.applyToMaterial && this.aoPassMapTexture !== null && (n.name === "ShadowGroundPlaneMaterial" || t.receiveShadow && (!n.transparent || n.alphaTest >= .9)), a = i && this._shadowAndAoPass.parameters.aoIntensity > .01, o = i && this._screenSpaceShadowMapPass.enabled && this._shadowAndAoPass.parameters.shadowIntensity > .01;
|
|
3646
|
+
e.applyAoAndShadowToAlpha = n.name === "ShadowGroundPlaneMaterial", e.aoPassMapIntensity = a ? this._shadowAndAoPass.parameters.aoIntensity * 2 : -1, e.shPassMapIntensity = o ? this._shadowAndAoPass.parameters.shadowIntensity * 2 : -1, e.aoPassMapScale = 1 / r, e.aoPassMap = this.aoPassMapTexture;
|
|
3647
|
+
}
|
|
3648
|
+
_updatePlugInReflection(e, t) {
|
|
3649
|
+
let n = this._groundReflectionPass.intensityRenderTarget.texture, r = t.userData.isPlanFloor && this._groundReflectionPass.parameters.enabled && (n !== null || n !== void 0), i = this._groundReflectionPass.parameters.intensity;
|
|
3650
|
+
e.applyReflectionPassMap = r, e.reflectionPassMapIntensity = r ? i ** .5 : 0, e.reflectionPassMapScale = 1 / (this._groundReflectionPass.parameters.renderTargetDownScale * devicePixelRatio), e.reflectionPassMap = r ? n : null;
|
|
3651
|
+
}
|
|
3652
|
+
renderPasses(e, t) {
|
|
3653
|
+
let n = this.getRenderPassRenderTarget(e), r = this.getPostPassRenderTarget(e);
|
|
3654
|
+
e.setRenderTarget(n);
|
|
3655
|
+
let i = V(e);
|
|
3656
|
+
i && this._bakedGroundContactShadowPass.renderPass(e), this._passUpdateStates.updateGBuffer && i && this._gBufferRenderPass.renderPass(e), this._passUpdateStates.updateScreenSpaceShadow && i && this._screenSpaceShadowMapPass.renderPass(e), this._passUpdateStates.updateShadowAndAoPass && i && this._shadowAndAoPass.renderPass(e), this._updateMaterials(e, t), this._sceneRenderPass.renderPass(e), this._passUpdateStates.updateGroundReflection && i && this._groundReflectionPass.renderPass(e), this._passUpdateStates.updateShadowAndAoPass && !this._shadowAndAoPass.parameters.applyToMaterial && i && this._shadowAndAoPass.renderToTarget(e), this._lutPassParameters.enabled && (e.setRenderTarget(r), this._outputPass.renderToScreen = !1, this._outputPass.render(e, e.getRenderTarget(), n, 0, !1), e.setRenderTarget(null), this._lutPass.renderToScreen = !0, this._lutPass.render(e, e.getRenderTarget(), r, 0, !1)), this._passUpdateStates.updateOutlinePass && i && this._outlinePass?.renderPass(e), this._passUpdateStates.updateDebugPass && i && this._debugPass?.renderPass(e);
|
|
3657
|
+
}
|
|
3658
|
+
};
|
|
3659
|
+
me([pe, fe("design:type", Object)], On.prototype, "_initData", void 0);
|
|
3660
|
+
//#endregion
|
|
3661
|
+
//#region packages/common-core/src/webgl/renderer/scene-renderer.ts
|
|
3662
|
+
var kn = {
|
|
3663
|
+
HIGHEST: "highest",
|
|
3664
|
+
HIGH: "high",
|
|
3665
|
+
MEDIUM: "medium",
|
|
3666
|
+
LOW: "low"
|
|
3667
|
+
}, An = class {
|
|
3668
|
+
get sceneRenderPass() {
|
|
3669
|
+
return this._renderPassManager.sceneRenderPass;
|
|
3670
|
+
}
|
|
3671
|
+
get bakedGroundContactShadowPass() {
|
|
3672
|
+
return this._renderPassManager.bakedGroundContactShadowPass;
|
|
3673
|
+
}
|
|
3674
|
+
get gBufferRenderPass() {
|
|
3675
|
+
return this._renderPassManager.gBufferRenderPass;
|
|
3676
|
+
}
|
|
3677
|
+
get groundReflectionPass() {
|
|
3678
|
+
return this._renderPassManager.groundReflectionPass;
|
|
3679
|
+
}
|
|
3680
|
+
get screenSpaceShadowMapPass() {
|
|
3681
|
+
return this._renderPassManager.screenSpaceShadowMapPass;
|
|
3682
|
+
}
|
|
3683
|
+
get shadowAndAoPass() {
|
|
3684
|
+
return this._renderPassManager.shadowAndAoPass;
|
|
3685
|
+
}
|
|
3686
|
+
get lutPassParameters() {
|
|
3687
|
+
return this._renderPassManager.lutPassParameters;
|
|
3688
|
+
}
|
|
3689
|
+
get lutMaps() {
|
|
3690
|
+
return this._renderPassManager.lutMaps;
|
|
3691
|
+
}
|
|
3692
|
+
get debugPass() {
|
|
3693
|
+
return this._renderPassManager.debugPass;
|
|
3694
|
+
}
|
|
3695
|
+
get shadowAndAoGroundPlane() {
|
|
3696
|
+
return this._shadowAndAoGroundPlane;
|
|
3697
|
+
}
|
|
3698
|
+
constructor(e, t, n, r, i) {
|
|
3699
|
+
this.debugOutput = "off", this.outputColorSpace = "", this.toneMapping = "", this.linearAoFilter = !0, this.environmentLights = !1, this.enableObjectSelection = !0, this.groundLevel = 0, this.uiInteractionMode = !1, this.width = 0, this.height = 0, this.boundingVolume = new He(), this.boundingVolumeSet = !1, this.renderCacheManager = new wt(), this.selectedObjects = [], this.groundGroup = new te(), this._shadingType = ft.DEFAULT, this._qualityLevel = kn.HIGHEST, this._qualityMap = /* @__PURE__ */ new Map(), this._customShadingParameters = null, this._creator_ = e, this.width = n, this.height = r, this.linearAoFilter = i ?? !0, this.renderer = t, this.renderCacheManager.registerCache("inivisibleGround", new Tt((e) => e === this.groundGroup)), this.renderCacheManager.registerCache("groundReflection", new Tt((e) => e === this.groundGroup || e.name === "dimensioning" ? !0 : !!(e instanceof x && St(e.material)))), this.renderCacheManager.registerCache("debug", new Tt()), this.renderCacheManager.registerCache("floorDepthWrite", new Et((e) => e.userData?.isFloor)), this._shadowAndAoGroundPlane = new Ye(null), this.groundGroup.rotateX(-Math.PI / 2), this._renderPassManager = new On(e, this), this.outlineRenderer = new dt(this._renderPassManager, null, {}), this.parameters = {
|
|
3700
|
+
gBufferRenderTargetParameters: this.gBufferRenderPass.parameters,
|
|
3701
|
+
bakedGroundContactShadowParameters: this.bakedGroundContactShadowPass.parameters,
|
|
3702
|
+
screenSpaceShadowMapParameters: this.screenSpaceShadowMapPass.parameters,
|
|
3703
|
+
shAndAoPassParameters: this.shadowAndAoPass.parameters,
|
|
3704
|
+
groundReflectionParameters: this.groundReflectionPass.parameters,
|
|
3705
|
+
outlineParameters: this.outlineRenderer.parameters,
|
|
3706
|
+
effectSuspendFrames: 0,
|
|
3707
|
+
effectFadeInFrames: 0,
|
|
3708
|
+
suspendGroundReflection: !1,
|
|
3709
|
+
shadowOnCameraChange: Z.OFF
|
|
3710
|
+
}, this._addEventListeners(this.renderer);
|
|
3711
|
+
}
|
|
3712
|
+
_addEventListeners(e) {
|
|
3713
|
+
e.domElement && (e.domElement.addEventListener("webglcontextlost", () => {
|
|
3714
|
+
console.log("webglcontextlost");
|
|
3715
|
+
}), e.domElement.addEventListener("webglcontextrestored", () => {
|
|
3716
|
+
console.log("webglcontextrestored"), this._forceEnvironmentMapUpdate(this.renderer);
|
|
3717
|
+
}));
|
|
3718
|
+
}
|
|
3719
|
+
dispose() {
|
|
3720
|
+
this._copyMaterial?.dispose(), this._renderPassManager.dispose(), this.renderer.dispose();
|
|
3721
|
+
}
|
|
3722
|
+
setSize(e, t) {
|
|
3723
|
+
this.width = e, this.height = t, this._renderPassManager.setSize(e, t), this.renderer.setSize(e, t);
|
|
3724
|
+
}
|
|
3725
|
+
loadLutImages(e) {
|
|
3726
|
+
for (let t of e) {
|
|
3727
|
+
let e = t.url;
|
|
3728
|
+
t.type === "image" ? this._renderPassManager.loadLutImage(t.name, e) : t.type === "cube" ? this._renderPassManager.loadLutCube(t.name, e) : t.type === "3dl" && this._renderPassManager.loadLut3dl(t.name, e);
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
getQualityLevel() {
|
|
3732
|
+
return this._qualityLevel;
|
|
3733
|
+
}
|
|
3734
|
+
setShadingType(e) {
|
|
3735
|
+
this._shadingType !== e && (this._shadingType = e, this.applyCurrentParameters());
|
|
3736
|
+
}
|
|
3737
|
+
setQualityLevel(e) {
|
|
3738
|
+
this._qualityLevel !== e && (this._qualityMap.has(this._qualityLevel) && (this._qualityLevel = e), this.applyCurrentParameters());
|
|
3739
|
+
}
|
|
3740
|
+
setQualityMap(e) {
|
|
3741
|
+
this._qualityMap = e, this.applyCurrentParameters();
|
|
3742
|
+
}
|
|
3743
|
+
setCustomShadingParameters(e) {
|
|
3744
|
+
this._customShadingParameters = e, this.applyCurrentParameters(), this.requestUpdateOfPasses();
|
|
3745
|
+
}
|
|
3746
|
+
setQualityMapAndShadingParameters(e, t) {
|
|
3747
|
+
this._qualityMap = e, this._customShadingParameters = t, this.applyCurrentParameters(), this.requestUpdateOfPasses();
|
|
3748
|
+
}
|
|
3749
|
+
applyCurrentParameters() {
|
|
3750
|
+
let e = [];
|
|
3751
|
+
this._qualityMap.has(this._qualityLevel) && e.push(this._qualityMap.get(this._qualityLevel));
|
|
3752
|
+
let t = gt(this._shadingType);
|
|
3753
|
+
t && e.push(t);
|
|
3754
|
+
let n = ht(this.uiInteractionMode);
|
|
3755
|
+
if (n && e.push(n), this._customShadingParameters && e.push(_t(this._customShadingParameters)), e.length > 0) {
|
|
3756
|
+
let t = mt(...e);
|
|
3757
|
+
this.updateParameters(t), this.bakedGroundContactShadowPass.applyParameters();
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
requestUpdateOfPasses() {
|
|
3761
|
+
this.gBufferRenderPass.needsUpdate = !0, this.screenSpaceShadowMapPass.needsUpdate = !0, this.shadowAndAoPass.needsUpdate = !0, this.shadowAndAoPass.softShadowPass.needsUpdate = !0, this._renderPassManager.materialsNeedUpdate = !0;
|
|
3762
|
+
}
|
|
3763
|
+
clearCache() {
|
|
3764
|
+
this.renderCacheManager.clearCache(), this._renderPassManager.materialsNeedUpdate = !0;
|
|
3765
|
+
}
|
|
3766
|
+
forceShadowUpdates(e) {
|
|
3767
|
+
this.clearCache(), this.gBufferRenderPass.needsUpdate = !0, this.screenSpaceShadowMapPass.forceShadowUpdate(), this.shadowAndAoPass.needsUpdate = !0, e && (this.bakedGroundContactShadowPass.needsUpdate = !0);
|
|
3768
|
+
}
|
|
3769
|
+
forceLutPassUpdate() {
|
|
3770
|
+
this._renderPassManager.lutPassNeedsUpdate = !0, this._renderPassManager.materialsNeedUpdate = !0;
|
|
3771
|
+
}
|
|
3772
|
+
updateParameters(e) {
|
|
3773
|
+
e.shadowType && this.screenSpaceShadowMapPass.switchType(e.shadowType), e.shAndAoPassParameters !== void 0 && this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters), e.bakedGroundContactShadowParameters !== void 0 && this.bakedGroundContactShadowPass.updateParameters(e.bakedGroundContactShadowParameters), e.screenSpaceShadowMapParameters !== void 0 && this.screenSpaceShadowMapPass.updateParameters(e.screenSpaceShadowMapParameters), e.groundReflectionParameters !== void 0 && this.groundReflectionPass.updateParameters(e.groundReflectionParameters), e.outlineParameters !== void 0 && this.outlineRenderer.updateParameters(e.outlineParameters), e.effectSuspendFrames !== void 0 && (this.parameters.effectSuspendFrames = e.effectSuspendFrames), e.effectFadeInFrames !== void 0 && (this.parameters.effectFadeInFrames = e.effectFadeInFrames), e.suspendGroundReflection !== void 0 && (this.parameters.suspendGroundReflection = e.suspendGroundReflection), e.shadowOnCameraChange !== void 0 && (this.parameters.shadowOnCameraChange = e.shadowOnCameraChange);
|
|
3774
|
+
}
|
|
3775
|
+
addRectAreaLight(e, t) {
|
|
3776
|
+
this.environmentLights = !1, this.screenSpaceShadowMapPass.addRectAreaLight(e, t), this.shadowAndAoPass.needsUpdate = !0;
|
|
3777
|
+
}
|
|
3778
|
+
updateRectAreaLights(e, t) {
|
|
3779
|
+
e.length > 0 && (this.environmentLights = !1), this.screenSpaceShadowMapPass.updateRectAreaLights(e, t), this.shadowAndAoPass.needsUpdate = !0;
|
|
3780
|
+
}
|
|
3781
|
+
createShadowFromLightSources(e, t) {
|
|
3782
|
+
this.environmentLights = !0, this.screenSpaceShadowMapPass.createShadowFromLightSources(e, t), this.shadowAndAoPass.needsUpdate = !0;
|
|
3783
|
+
}
|
|
3784
|
+
selectObjects(e) {
|
|
3785
|
+
this.selectedObjects = e;
|
|
3786
|
+
}
|
|
3787
|
+
updateBounds(e, t) {
|
|
3788
|
+
this.clearCache();
|
|
3789
|
+
let n = e.clone();
|
|
3790
|
+
n.min.y > this.groundLevel && (n.min.y = this.groundLevel), this.boundingVolumeSet = !0, this.gBufferRenderPass.groundDepthWrite = this.shadowAndAoPass.parameters.aoOnGround, this.boundingVolume.updateFromBox(n);
|
|
3791
|
+
let r = this.boundingVolume.size, i = (r.x + r.y + r.z) / 3, a = Math.min(r.x, r.y, r.z), o = Math.max(r.x, r.y, r.z), s = a < .5 ? a / .5 : r.z > 5 ? r.z / 5 : 1;
|
|
3792
|
+
this.bakedGroundContactShadowPass.setScale(t ? i : s, i), this.groundReflectionPass.updateBounds(this.groundLevel, Math.min(1, o)), this.screenSpaceShadowMapPass.updateBounds(this.boundingVolume, i), this.shadowAndAoPass.updateBounds(this.boundingVolume, t ? i : Math.min(1, o * 2));
|
|
3793
|
+
}
|
|
3794
|
+
updateNearAndFarPlaneOfPerspectiveCamera(e, t) {
|
|
3795
|
+
let n = this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position, 3);
|
|
3796
|
+
e.near = Math.max(1e-5, n[0] * .9), e.far = Math.max(t ?? e.near, n[1]), e.updateProjectionMatrix();
|
|
3797
|
+
}
|
|
3798
|
+
_forceEnvironmentMapUpdate(e) {
|
|
3799
|
+
let t = e.userData;
|
|
3800
|
+
if (t?.environmentTexture) {
|
|
3801
|
+
let e = t.environmentTexture;
|
|
3802
|
+
t.environmentTexture = void 0, e.dispose();
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
_updateEnvironment(e, t) {
|
|
3806
|
+
if (!t.userData?.environmentDefinition) return;
|
|
3807
|
+
e.userData ||= {};
|
|
3808
|
+
let n = e.userData;
|
|
3809
|
+
if (t.userData?.environmentDefinition.needsUpdate || !n.environmentTexture || n.environmentDefinition !== t.userData.environmentDefinition) {
|
|
3810
|
+
let r = t.userData.environmentDefinition;
|
|
3811
|
+
if (n.environmentDefinition = r, n.environmentTexture = r.createNewEnvironment(e), t.userData.shadowFromEnvironment && V(e)) {
|
|
3812
|
+
let e = r.maxNoOfLightSources;
|
|
3813
|
+
e !== void 0 && (this.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources = e), this.createShadowFromLightSources(t, r.lightSources);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
t.environment = n?.environmentTexture, t.userData.showEnvironmentBackground ? t.background = t.environment : t.background === t.environment && (t.background = null);
|
|
3817
|
+
}
|
|
3818
|
+
render(e, t) {
|
|
3819
|
+
e.add(this.groundGroup), this._updateEnvironment(this.renderer, e), this.outlineRenderer.updateOutline(e, t, this.enableObjectSelection ? this.selectedObjects : []), this._renderPassManager.updatePasses(this.renderer, e, t), this._renderPassManager.renderPasses(this.renderer, e), e.remove(this.groundGroup);
|
|
3820
|
+
}
|
|
3821
|
+
};
|
|
3822
|
+
me([pe, fe("design:type", Object)], An.prototype, "_initData", void 0);
|
|
3823
|
+
//#endregion
|
|
3824
|
+
export { Bt as a, Xe as c, Ce as d, un as i, be as l, An as n, ft as o, ln as r, Z as s, kn as t, xe as u };
|
|
3825
|
+
|
|
3826
|
+
//# sourceMappingURL=scene-renderer-D8HkTFeZ.mjs.map
|