@roomle/web-sdk 2.94.0 → 2.95.0
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/.releaserc.json +7 -5
- package/lib/TextGeometry-259292ec.nomodule.js +2 -0
- package/lib/TextGeometry-259292ec.nomodule.js.map +1 -0
- package/lib/TextGeometry-dc304c0e.js +2 -0
- package/lib/TextGeometry-dc304c0e.js.map +1 -0
- package/lib/{banana-for-scale-8479c8a1.js → banana-for-scale-886a33b5.js} +2 -2
- package/lib/{banana-for-scale-8479c8a1.js.map → banana-for-scale-886a33b5.js.map} +1 -1
- package/lib/{banana-for-scale-1f451414.nomodule.js → banana-for-scale-c207aeb2.nomodule.js} +2 -2
- package/lib/{banana-for-scale-1f451414.nomodule.js.map → banana-for-scale-c207aeb2.nomodule.js.map} +1 -1
- package/lib/{budgeteer-measure-f6505461.js → budgeteer-measure-7662ae7e.js} +2 -2
- package/lib/{budgeteer-measure-f6505461.js.map → budgeteer-measure-7662ae7e.js.map} +1 -1
- package/lib/budgeteer-measure.nomodule.js +1 -1
- package/lib/camera-behaviour-36f6a5bd.js +2 -0
- package/lib/camera-behaviour-36f6a5bd.js.map +1 -0
- package/lib/camera-behaviour-ae68711d.nomodule.js +2 -0
- package/lib/camera-behaviour-ae68711d.nomodule.js.map +1 -0
- package/lib/{component-dimensioning-9cc86304.nomodule.js → component-dimensioning-a732eb90.nomodule.js} +2 -2
- package/lib/component-dimensioning-a732eb90.nomodule.js.map +1 -0
- package/lib/{component-dimensioning-aa4cd8f4.js → component-dimensioning-ac10c0f7.js} +2 -2
- package/lib/component-dimensioning-ac10c0f7.js.map +1 -0
- package/lib/{component-raycast-helper-163d42ba.nomodule.js → component-raycast-helper-22535913.nomodule.js} +2 -2
- package/lib/component-raycast-helper-22535913.nomodule.js.map +1 -0
- package/lib/{component-raycast-helper-479486e8.js → component-raycast-helper-33186630.js} +2 -2
- package/lib/component-raycast-helper-33186630.js.map +1 -0
- package/lib/{configurator-9333ac17.js → configurator-2d3c177e.js} +2 -2
- package/lib/configurator-2d3c177e.js.map +1 -0
- package/lib/{configurator-b5e4a5ee.nomodule.js → configurator-9931ebbb.nomodule.js} +2 -2
- package/lib/configurator-9931ebbb.nomodule.js.map +1 -0
- package/lib/configurator-main-82cad2a3.js +2 -0
- package/lib/configurator-main-82cad2a3.js.map +1 -0
- package/lib/configurator-main.nomodule.js +1 -1
- package/lib/{continuous-drawing-helper-6f2f4c78.nomodule.js → continuous-drawing-helper-85412138.nomodule.js} +2 -2
- package/lib/continuous-drawing-helper-85412138.nomodule.js.map +1 -0
- package/lib/{continuous-drawing-helper-f8a966d9.js → continuous-drawing-helper-dd3f6839.js} +2 -2
- package/lib/continuous-drawing-helper-dd3f6839.js.map +1 -0
- package/lib/{default-light-setting-6425c714.js → default-light-setting-523ddfa7.js} +2 -2
- package/lib/default-light-setting-523ddfa7.js.map +1 -0
- package/lib/{default-light-setting-99036b6f.nomodule.js → default-light-setting-eeedb89b.nomodule.js} +2 -2
- package/lib/default-light-setting-eeedb89b.nomodule.js.map +1 -0
- package/lib/definitions/common-core/src/cameracontrol/camera-control.d.ts +1 -0
- package/lib/definitions/common-core/src/configurator-kernel-access.d.ts +0 -1
- package/lib/definitions/common-core/src/rapi-access.d.ts +5 -1
- package/lib/definitions/common-core/src/utils/init-data.d.ts +2 -0
- package/lib/definitions/common-core/src/utils/shims.d.ts +15 -1
- package/lib/definitions/common-core/src/view-model/plan-element-view-model.d.ts +1 -1
- package/lib/definitions/common-core/src/webgl/renderer/scene-renderer.d.ts +2 -1
- package/lib/definitions/common-core/src/webgl/roomle-webgl-renderer.d.ts +1 -1
- package/lib/definitions/configurator-core/src/roomle-configurator.d.ts +9 -2
- package/lib/definitions/configurator-core/src/services/configurator-ui-callback.d.ts +2 -1
- package/lib/definitions/configurator-core/src/utils/imos-ix-poc-export-helper.d.ts +43 -0
- package/lib/definitions/configurator-core/src/utils/selection-handler.d.ts +4 -1
- package/lib/definitions/configurator-core/src/webgl/configurator-scene-event-handler.d.ts +5 -2
- package/lib/definitions/configurator-core/src/webgl/configurator-scene-manager.d.ts +3 -2
- package/lib/definitions/packages/common-core/src/cameracontrol/camera-control.d.ts +1 -0
- package/lib/definitions/packages/common-core/src/configurator-kernel-access.d.ts +0 -1
- package/lib/definitions/packages/common-core/src/rapi-access.d.ts +5 -1
- package/lib/definitions/packages/common-core/src/utils/init-data.d.ts +2 -0
- package/lib/definitions/packages/common-core/src/utils/shims.d.ts +15 -1
- package/lib/definitions/packages/common-core/src/view-model/plan-element-view-model.d.ts +1 -1
- package/lib/definitions/packages/common-core/src/webgl/renderer/scene-renderer.d.ts +2 -1
- package/lib/definitions/packages/common-core/src/webgl/roomle-webgl-renderer.d.ts +1 -1
- package/lib/definitions/packages/configurator-core/src/roomle-configurator.d.ts +9 -2
- package/lib/definitions/packages/configurator-core/src/services/configurator-ui-callback.d.ts +2 -1
- package/lib/definitions/packages/configurator-core/src/utils/imos-ix-poc-export-helper.d.ts +43 -0
- package/lib/definitions/packages/configurator-core/src/utils/selection-handler.d.ts +4 -1
- package/lib/definitions/packages/configurator-core/src/webgl/configurator-scene-event-handler.d.ts +5 -2
- package/lib/definitions/packages/configurator-core/src/webgl/configurator-scene-manager.d.ts +3 -2
- package/lib/definitions/packages/planner-core/src/camera-control/camera-control-first-person.d.ts +1 -0
- package/lib/definitions/packages/planner-core/src/external-object-api-callbacks.d.ts +26 -12
- package/lib/definitions/packages/planner-core/src/external-object-api.d.ts +10 -3
- package/lib/definitions/packages/planner-core/src/roomle-planner-ui-callback.d.ts +10 -5
- package/lib/definitions/packages/planner-core/src/roomle-planner.d.ts +63 -7
- package/lib/definitions/packages/planner-core/src/services/planner-kernel-access.d.ts +11 -11
- package/lib/definitions/packages/planner-core/src/utils/planner-scene-manager.d.ts +1 -1
- package/lib/definitions/packages/planner-core/src/view-model/plan-view-model.d.ts +8 -0
- package/lib/definitions/packages/planner-core/src/view-model/wall-attic-plan-element-view-model.d.ts +9 -0
- package/lib/definitions/packages/planner-core/src/view-model/wall-plan-element-view-model.d.ts +4 -0
- package/lib/definitions/packages/planner-core/src/webgl/planner-scene-event-handler.d.ts +1 -0
- package/lib/definitions/packages/planner-core/src/webgl/planner-scene-manager.d.ts +6 -0
- package/lib/definitions/packages/typings/kernel.d.ts +15 -0
- package/lib/definitions/packages/typings/planner.d.ts +39 -4
- package/lib/definitions/planner-core/src/camera-control/camera-control-first-person.d.ts +1 -0
- package/lib/definitions/planner-core/src/external-object-api-callbacks.d.ts +26 -12
- package/lib/definitions/planner-core/src/external-object-api.d.ts +10 -3
- package/lib/definitions/planner-core/src/roomle-planner-ui-callback.d.ts +10 -5
- package/lib/definitions/planner-core/src/roomle-planner.d.ts +63 -7
- package/lib/definitions/planner-core/src/services/planner-kernel-access.d.ts +11 -11
- package/lib/definitions/planner-core/src/utils/planner-scene-manager.d.ts +1 -1
- package/lib/definitions/planner-core/src/view-model/plan-view-model.d.ts +8 -0
- package/lib/definitions/planner-core/src/view-model/wall-attic-plan-element-view-model.d.ts +9 -0
- package/lib/definitions/planner-core/src/view-model/wall-plan-element-view-model.d.ts +4 -0
- package/lib/definitions/planner-core/src/webgl/planner-scene-event-handler.d.ts +1 -0
- package/lib/definitions/planner-core/src/webgl/planner-scene-manager.d.ts +6 -0
- package/lib/definitions/typings/kernel.d.ts +15 -0
- package/lib/definitions/typings/planner.d.ts +39 -4
- package/lib/dimensioning-helper-7f7462be.nomodule.js +2 -0
- package/lib/dimensioning-helper-7f7462be.nomodule.js.map +1 -0
- package/lib/dimensioning-helper-81a797df.js +2 -0
- package/lib/{dimensioning-helper-318b729d.js.map → dimensioning-helper-81a797df.js.map} +1 -1
- package/lib/{glb-viewer-2d94a287.nomodule.js → glb-viewer-247b792e.nomodule.js} +2 -2
- package/lib/{glb-viewer-2d94a287.nomodule.js.map → glb-viewer-247b792e.nomodule.js.map} +1 -1
- package/lib/{glb-viewer-camera-behaviour-169bee0e.js → glb-viewer-camera-behaviour-24918301.js} +2 -2
- package/lib/glb-viewer-camera-behaviour-24918301.js.map +1 -0
- package/lib/{glb-viewer-camera-behaviour-0aba3eb3.nomodule.js → glb-viewer-camera-behaviour-d3292fba.nomodule.js} +2 -2
- package/lib/glb-viewer-camera-behaviour-d3292fba.nomodule.js.map +1 -0
- package/lib/{glb-viewer-66869df0.js → glb-viewer-ee8125c3.js} +2 -2
- package/lib/{glb-viewer-66869df0.js.map → glb-viewer-ee8125c3.js.map} +1 -1
- package/lib/glb-viewer-main-7c4d464d.js +2 -0
- package/lib/glb-viewer-main-7c4d464d.js.map +1 -0
- package/lib/glb-viewer-main.nomodule.js +1 -1
- package/lib/imos-ix-poc-export-helper-2bfc5629.js +2 -0
- package/lib/imos-ix-poc-export-helper-2bfc5629.js.map +1 -0
- package/lib/imos-ix-poc-export-helper-80a379ab.nomodule.js +2 -0
- package/lib/imos-ix-poc-export-helper-80a379ab.nomodule.js.map +1 -0
- package/lib/legacy/TextGeometry-7a5a6f22.legacy.js +2 -0
- package/lib/legacy/TextGeometry-7a5a6f22.legacy.js.map +1 -0
- package/lib/legacy/{banana-for-scale-a28854f7.legacy.js → banana-for-scale-6ab75722.legacy.js} +2 -2
- package/lib/legacy/{banana-for-scale-a28854f7.legacy.js.map → banana-for-scale-6ab75722.legacy.js.map} +1 -1
- package/lib/legacy/budgeteer-measure.legacy.js +1 -1
- package/lib/legacy/camera-behaviour-90995e3f.legacy.js +2 -0
- package/lib/legacy/camera-behaviour-90995e3f.legacy.js.map +1 -0
- package/lib/legacy/{component-dimensioning-a3182494.legacy.js → component-dimensioning-33a4aeea.legacy.js} +2 -2
- package/lib/legacy/component-dimensioning-33a4aeea.legacy.js.map +1 -0
- package/lib/legacy/{component-raycast-helper-17b7f665.legacy.js → component-raycast-helper-7db43d10.legacy.js} +2 -2
- package/lib/legacy/component-raycast-helper-7db43d10.legacy.js.map +1 -0
- package/lib/legacy/{configurator-c69e87db.legacy.js → configurator-1eb7b492.legacy.js} +2 -2
- package/lib/legacy/configurator-1eb7b492.legacy.js.map +1 -0
- package/lib/legacy/configurator-main.legacy.js +1 -1
- package/lib/legacy/{continuous-drawing-helper-bb050ff2.legacy.js → continuous-drawing-helper-7af713b1.legacy.js} +2 -2
- package/lib/legacy/continuous-drawing-helper-7af713b1.legacy.js.map +1 -0
- package/lib/legacy/{default-light-setting-086a7648.legacy.js → default-light-setting-3a12f49d.legacy.js} +2 -2
- package/lib/legacy/default-light-setting-3a12f49d.legacy.js.map +1 -0
- package/lib/legacy/dimensioning-helper-f7ff715b.legacy.js +2 -0
- package/lib/legacy/dimensioning-helper-f7ff715b.legacy.js.map +1 -0
- package/lib/legacy/{glb-viewer-4a69cf11.legacy.js → glb-viewer-069aafef.legacy.js} +2 -2
- package/lib/legacy/{glb-viewer-4a69cf11.legacy.js.map → glb-viewer-069aafef.legacy.js.map} +1 -1
- package/lib/legacy/{glb-viewer-camera-behaviour-a0bd3636.legacy.js → glb-viewer-camera-behaviour-d5b1df96.legacy.js} +2 -2
- package/lib/legacy/glb-viewer-camera-behaviour-d5b1df96.legacy.js.map +1 -0
- package/lib/legacy/glb-viewer-main.legacy.js +1 -1
- package/lib/legacy/imos-ix-poc-export-helper-5298ee0b.legacy.js +2 -0
- package/lib/legacy/imos-ix-poc-export-helper-5298ee0b.legacy.js.map +1 -0
- package/lib/legacy/main-thread-to-worker-6115d235.legacy.js +7 -0
- package/lib/legacy/main-thread-to-worker-6115d235.legacy.js.map +1 -0
- package/lib/legacy/{material-viewer-aec0f3b7.legacy.js → material-viewer-430e1c4d.legacy.js} +2 -2
- package/lib/legacy/material-viewer-430e1c4d.legacy.js.map +1 -0
- package/lib/legacy/material-viewer-main.legacy.js +1 -1
- package/lib/legacy/planner-315d4dca.legacy.js +2 -0
- package/lib/legacy/planner-315d4dca.legacy.js.map +1 -0
- package/lib/legacy/planner-main.legacy.js +1 -1
- package/lib/legacy/{query-params-helper-aca6a1b1.legacy.js → query-params-helper-28b451be.legacy.js} +2 -2
- package/lib/legacy/query-params-helper-28b451be.legacy.js.map +1 -0
- package/lib/legacy/roomle-configurator-97b98cfa.legacy.js +2 -0
- package/lib/legacy/roomle-configurator-97b98cfa.legacy.js.map +1 -0
- package/lib/legacy/roomle-dependency-injection-68a248dd.legacy.js +9 -0
- package/lib/legacy/roomle-dependency-injection-68a248dd.legacy.js.map +1 -0
- package/lib/legacy/roomle-sdk.legacy.js +1 -1
- package/lib/legacy/{script-loader-d6b10e8e.legacy.js → script-loader-980083de.legacy.js} +2 -2
- package/lib/legacy/script-loader-980083de.legacy.js.map +1 -0
- package/lib/legacy/static/ConfiguratorKernel-224f3e49bcca1cee.wasm +0 -0
- package/lib/legacy/static/{ConfiguratorKernel-2ddc08f9542fc91f.js → ConfiguratorKernel-f5baba2ad8da5981.js} +3 -3
- package/lib/legacy/static/{RoomleCore-f2d7b1b87640ef15.js → RoomleCore-df3ed2b0c7211584.js} +50 -50
- package/lib/legacy/static/RoomleCore-f35e0972ad5263e7.wasm +0 -0
- package/lib/legacy/static/RoomleToolsCore-c263aadc8e58a52f.wasm +0 -0
- package/lib/legacy/static/default-external-object-api-configuration-c4294f96099e0d09.json +70 -0
- package/lib/legacy/{stats-helper-4d796606.legacy.js → stats-helper-29035b3e.legacy.js} +2 -2
- package/lib/legacy/stats-helper-29035b3e.legacy.js.map +1 -0
- package/lib/legacy/{tools-core-15dc1d58.legacy.js → tools-core-5428168a.legacy.js} +2 -2
- package/lib/legacy/tools-core-5428168a.legacy.js.map +1 -0
- package/lib/main-thread-to-worker-352ff4b1.js +8 -0
- package/lib/main-thread-to-worker-352ff4b1.js.map +1 -0
- package/lib/main-thread-to-worker-7f1cb5ea.nomodule.js +8 -0
- package/lib/main-thread-to-worker-7f1cb5ea.nomodule.js.map +1 -0
- package/lib/{material-viewer-c9197111.js → material-viewer-7feaa1d3.js} +2 -2
- package/lib/material-viewer-7feaa1d3.js.map +1 -0
- package/lib/{material-viewer-2c8625ff.nomodule.js → material-viewer-b3c02419.nomodule.js} +2 -2
- package/lib/material-viewer-b3c02419.nomodule.js.map +1 -0
- package/lib/material-viewer-main-fc34ed92.js +2 -0
- package/lib/material-viewer-main-fc34ed92.js.map +1 -0
- package/lib/material-viewer-main.nomodule.js +1 -1
- package/lib/planner-02fab4b9.js +2 -0
- package/lib/planner-02fab4b9.js.map +1 -0
- package/lib/planner-63ca8da8.nomodule.js +2 -0
- package/lib/planner-63ca8da8.nomodule.js.map +1 -0
- package/lib/planner-main-ea18f55f.js +2 -0
- package/lib/planner-main-ea18f55f.js.map +1 -0
- package/lib/planner-main.nomodule.js +1 -1
- package/lib/{query-params-helper-c9492f35.js → query-params-helper-28405b8d.js} +2 -2
- package/lib/query-params-helper-28405b8d.js.map +1 -0
- package/lib/{query-params-helper-51a53f8c.nomodule.js → query-params-helper-4f855064.nomodule.js} +2 -2
- package/lib/query-params-helper-4f855064.nomodule.js.map +1 -0
- package/lib/roomle-configurator-473bd629.js +2 -0
- package/lib/roomle-configurator-473bd629.js.map +1 -0
- package/lib/roomle-configurator-a595bc07.nomodule.js +2 -0
- package/lib/roomle-configurator-a595bc07.nomodule.js.map +1 -0
- package/lib/roomle-dependency-injection-3e8891d7.nomodule.js +9 -0
- package/lib/roomle-dependency-injection-3e8891d7.nomodule.js.map +1 -0
- package/lib/roomle-dependency-injection-64b1a781.js +9 -0
- package/lib/roomle-dependency-injection-64b1a781.js.map +1 -0
- package/lib/{roomle-sdk-6ccf3ded.js → roomle-sdk-9d9aec07.js} +2 -2
- package/lib/roomle-sdk-9d9aec07.js.map +1 -0
- package/lib/roomle-sdk.nomodule.js +1 -1
- package/lib/{script-loader-8964e022.js → script-loader-34075a2c.js} +2 -2
- package/lib/script-loader-34075a2c.js.map +1 -0
- package/lib/{script-loader-b4e814f2.nomodule.js → script-loader-b3df4e67.nomodule.js} +2 -2
- package/lib/script-loader-b3df4e67.nomodule.js.map +1 -0
- package/lib/static/ConfiguratorKernel-224f3e49bcca1cee.wasm +0 -0
- package/lib/static/{ConfiguratorKernel-2ddc08f9542fc91f.js → ConfiguratorKernel-f5baba2ad8da5981.js} +1 -1
- package/lib/static/{ConfiguratorKernel-2ddc08f9542fc91f.js.map → ConfiguratorKernel-f5baba2ad8da5981.js.map} +1 -1
- package/lib/static/RoomleCore-df3ed2b0c7211584.js +1 -0
- package/lib/static/RoomleCore-df3ed2b0c7211584.js.map +1 -0
- package/lib/static/RoomleCore-f35e0972ad5263e7.wasm +0 -0
- package/lib/static/RoomleToolsCore-c263aadc8e58a52f.wasm +0 -0
- package/lib/static/default-external-object-api-configuration-c4294f96099e0d09.json +70 -0
- package/lib/{stats-helper-510ddd65.js → stats-helper-24757914.js} +2 -2
- package/lib/stats-helper-24757914.js.map +1 -0
- package/lib/{stats-helper-86728f77.nomodule.js → stats-helper-e98784e8.nomodule.js} +2 -2
- package/lib/stats-helper-e98784e8.nomodule.js.map +1 -0
- package/lib/{tools-core-bae4492f.js → tools-core-03a4da8c.js} +2 -2
- package/lib/tools-core-03a4da8c.js.map +1 -0
- package/lib/{tools-core-0f3ae134.nomodule.js → tools-core-40fa6f90.nomodule.js} +2 -2
- package/lib/tools-core-40fa6f90.nomodule.js.map +1 -0
- package/package.json +3 -3
- package/lib/TextGeometry-ab643210.js +0 -2
- package/lib/TextGeometry-ab643210.js.map +0 -1
- package/lib/TextGeometry-cd81779b.nomodule.js +0 -2
- package/lib/TextGeometry-cd81779b.nomodule.js.map +0 -1
- package/lib/camera-behaviour-27b6ce79.nomodule.js +0 -2
- package/lib/camera-behaviour-27b6ce79.nomodule.js.map +0 -1
- package/lib/camera-behaviour-b9a52002.js +0 -2
- package/lib/camera-behaviour-b9a52002.js.map +0 -1
- package/lib/component-dimensioning-9cc86304.nomodule.js.map +0 -1
- package/lib/component-dimensioning-aa4cd8f4.js.map +0 -1
- package/lib/component-raycast-helper-163d42ba.nomodule.js.map +0 -1
- package/lib/component-raycast-helper-479486e8.js.map +0 -1
- package/lib/configurator-9333ac17.js.map +0 -1
- package/lib/configurator-b5e4a5ee.nomodule.js.map +0 -1
- package/lib/configurator-main-d0382ff8.js +0 -2
- package/lib/configurator-main-d0382ff8.js.map +0 -1
- package/lib/continuous-drawing-helper-6f2f4c78.nomodule.js.map +0 -1
- package/lib/continuous-drawing-helper-f8a966d9.js.map +0 -1
- package/lib/default-light-setting-6425c714.js.map +0 -1
- package/lib/default-light-setting-99036b6f.nomodule.js.map +0 -1
- package/lib/dimensioning-helper-318b729d.js +0 -2
- package/lib/dimensioning-helper-49404687.nomodule.js +0 -2
- package/lib/dimensioning-helper-49404687.nomodule.js.map +0 -1
- package/lib/glb-viewer-camera-behaviour-0aba3eb3.nomodule.js.map +0 -1
- package/lib/glb-viewer-camera-behaviour-169bee0e.js.map +0 -1
- package/lib/glb-viewer-main-1b2e5764.js +0 -2
- package/lib/glb-viewer-main-1b2e5764.js.map +0 -1
- package/lib/legacy/TextGeometry-f4299b59.legacy.js +0 -2
- package/lib/legacy/TextGeometry-f4299b59.legacy.js.map +0 -1
- package/lib/legacy/camera-behaviour-e6ce4b6d.legacy.js +0 -2
- package/lib/legacy/camera-behaviour-e6ce4b6d.legacy.js.map +0 -1
- package/lib/legacy/component-dimensioning-a3182494.legacy.js.map +0 -1
- package/lib/legacy/component-raycast-helper-17b7f665.legacy.js.map +0 -1
- package/lib/legacy/configurator-c69e87db.legacy.js.map +0 -1
- package/lib/legacy/continuous-drawing-helper-bb050ff2.legacy.js.map +0 -1
- package/lib/legacy/default-light-setting-086a7648.legacy.js.map +0 -1
- package/lib/legacy/dimensioning-helper-fb07be35.legacy.js +0 -2
- package/lib/legacy/dimensioning-helper-fb07be35.legacy.js.map +0 -1
- package/lib/legacy/glb-viewer-camera-behaviour-a0bd3636.legacy.js.map +0 -1
- package/lib/legacy/main-thread-to-worker-7c2b8bc9.legacy.js +0 -7
- package/lib/legacy/main-thread-to-worker-7c2b8bc9.legacy.js.map +0 -1
- package/lib/legacy/material-viewer-aec0f3b7.legacy.js.map +0 -1
- package/lib/legacy/planner-2bc74cf2.legacy.js +0 -2
- package/lib/legacy/planner-2bc74cf2.legacy.js.map +0 -1
- package/lib/legacy/query-params-helper-aca6a1b1.legacy.js.map +0 -1
- package/lib/legacy/roomle-configurator-d5ea14c2.legacy.js +0 -2
- package/lib/legacy/roomle-configurator-d5ea14c2.legacy.js.map +0 -1
- package/lib/legacy/roomle-dependency-injection-500dbf0d.legacy.js +0 -9
- package/lib/legacy/roomle-dependency-injection-500dbf0d.legacy.js.map +0 -1
- package/lib/legacy/script-loader-d6b10e8e.legacy.js.map +0 -1
- package/lib/legacy/static/ConfiguratorKernel-793e445c9d64ee4b.wasm +0 -0
- package/lib/legacy/static/RoomleCore-7d39e007d6f9b788.wasm +0 -0
- package/lib/legacy/static/RoomleToolsCore-9c348432c6d79392.wasm +0 -0
- package/lib/legacy/static/default-external-object-api-configuration-1e7103889f664a3f.json +0 -16
- package/lib/legacy/stats-helper-4d796606.legacy.js.map +0 -1
- package/lib/legacy/tools-core-15dc1d58.legacy.js.map +0 -1
- package/lib/main-thread-to-worker-2529fa31.nomodule.js +0 -2
- package/lib/main-thread-to-worker-2529fa31.nomodule.js.map +0 -1
- package/lib/main-thread-to-worker-ee3036b3.js +0 -2
- package/lib/main-thread-to-worker-ee3036b3.js.map +0 -1
- package/lib/material-viewer-2c8625ff.nomodule.js.map +0 -1
- package/lib/material-viewer-c9197111.js.map +0 -1
- package/lib/material-viewer-main-8787208d.js +0 -2
- package/lib/material-viewer-main-8787208d.js.map +0 -1
- package/lib/planner-5fb6f448.js +0 -2
- package/lib/planner-5fb6f448.js.map +0 -1
- package/lib/planner-65127889.nomodule.js +0 -2
- package/lib/planner-65127889.nomodule.js.map +0 -1
- package/lib/planner-main-d8ae156a.js +0 -2
- package/lib/planner-main-d8ae156a.js.map +0 -1
- package/lib/query-params-helper-51a53f8c.nomodule.js.map +0 -1
- package/lib/query-params-helper-c9492f35.js.map +0 -1
- package/lib/roomle-configurator-9fe534c7.js +0 -2
- package/lib/roomle-configurator-9fe534c7.js.map +0 -1
- package/lib/roomle-configurator-ebb94f0f.nomodule.js +0 -2
- package/lib/roomle-configurator-ebb94f0f.nomodule.js.map +0 -1
- package/lib/roomle-dependency-injection-4e221caa.js +0 -9
- package/lib/roomle-dependency-injection-4e221caa.js.map +0 -1
- package/lib/roomle-dependency-injection-5fd128b0.nomodule.js +0 -9
- package/lib/roomle-dependency-injection-5fd128b0.nomodule.js.map +0 -1
- package/lib/roomle-sdk-6ccf3ded.js.map +0 -1
- package/lib/script-loader-8964e022.js.map +0 -1
- package/lib/script-loader-b4e814f2.nomodule.js.map +0 -1
- package/lib/static/ConfiguratorKernel-793e445c9d64ee4b.wasm +0 -0
- package/lib/static/RoomleCore-7d39e007d6f9b788.wasm +0 -0
- package/lib/static/RoomleCore-f2d7b1b87640ef15.js +0 -1
- package/lib/static/RoomleCore-f2d7b1b87640ef15.js.map +0 -1
- package/lib/static/RoomleToolsCore-9c348432c6d79392.wasm +0 -0
- package/lib/static/default-external-object-api-configuration-1e7103889f664a3f.json +0 -16
- package/lib/stats-helper-510ddd65.js.map +0 -1
- package/lib/stats-helper-86728f77.nomodule.js.map +0 -1
- package/lib/tools-core-0f3ae134.nomodule.js.map +0 -1
- package/lib/tools-core-bae4492f.js.map +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{g as getAssetPath,A as AmbientLight,D as DirectionalLight,V as Vector2,a as Vector3,R as RectAreaLight,S as SpotLight,C as Color$1,M as MainThreadToWorker,B as BufferGeometry,b as BufferAttribute,T as TrianglesDrawMode,c as TriangleFanDrawMode,d as TriangleStripDrawMode,L as Loader,e as LoaderUtils,F as FileLoader,f as LinearSRGBColorSpace,P as PointLight,h as MeshBasicMaterial,i as SRGBColorSpace,j as MeshPhysicalMaterial,k as Matrix4,Q as Quaternion,I as InstancedMesh,l as InstancedBufferAttribute,O as Object3D,m as TextureLoader,n as ImageBitmapLoader,o as InterleavedBuffer,p as LinearFilter,q as LinearMipmapLinearFilter,r as RepeatWrapping,s as PointsMaterial,t as Material,u as LineBasicMaterial,v as MeshStandardMaterial,w as DoubleSide,x as PropertyBinding,y as SkinnedMesh,z as Mesh,E as LineSegments,G as Line,H as LineLoop,J as Points,K as Group,N as PerspectiveCamera,U as MathUtils,W as OrthographicCamera,X as Skeleton,Y as AnimationClip,Z as Bone,_ as InterpolateLinear,$ as ColorManagement,a0 as NearestFilter,a1 as NearestMipmapNearestFilter,a2 as LinearMipmapNearestFilter,a3 as NearestMipmapLinearFilter,a4 as ClampToEdgeWrapping,a5 as MirroredRepeatWrapping,a6 as InterpolateDiscrete,a7 as FrontSide,a8 as InterleavedBufferAttribute,a9 as Texture,aa as VectorKeyframeTrack,ab as NumberKeyframeTrack,ac as QuaternionKeyframeTrack,ad as Box3,ae as Sphere,af as Interpolant,ag as Euler,ah as CubeTexture,ai as RGBAFormat,aj as DataTexture,ak as getValue,al as Scene,am as Frustum,an as Vector4,ao as Matrix3,ap as ShaderMaterial,aq as DstColorFactor,ar as ZeroFactor,as as AddEquation,at as DstAlphaFactor,au as UniformsUtils,av as NoBlending,aw as Float32BufferAttribute,ax as UnsignedByteType,ay as CustomBlending,az as MinEquation,aA as OneFactor,aB as WebGLRenderTarget,aC as deepMerge,aD as ROOMLE_HIGHLIGHTNG,aE as CAMERA_TYPE,aF as getColor,aG as isThreeJsColor,aH as ROOMLE_COLORS,aI as setWriteable,aJ as setDescriptor,aK as Uint32BufferAttribute,aL as createBenchmarkMaterial,aM as createBenchmarkTexture,aN as ShapePath,aO as removeItem,aP as BoxGeometry,aQ as hashCode,aR as getGlbUrl,aS as SphereGeometry,aT as RingGeometry,aU as wait,aV as objectArrayToMap,aW as roundWithPrecision,aX as uuid,aY as rearrangeArrayByIdOrder,aZ as handleJsonResponse,a_ as EdgesGeometry,a$ as CircleGeometry,b0 as ConeGeometry,b1 as isString,b2 as DataTextureLoader,b3 as HalfFloatType,b4 as FloatType,b5 as RedFormat,b6 as NoColorSpace,b7 as DataUtils,b8 as EquirectangularReflectionMapping,b9 as PlaneGeometry,ba as RGFormat,bb as CameraHelper,bc as MeshDepthMaterial,bd as MeshNormalMaterial,be as DepthTexture,bf as DepthStencilFormat,bg as UnsignedInt248Type,bh as BackSide,bi as MeshLambertMaterial,bj as PCFShadowMap,bk as BasicShadowMap,bl as PCFSoftShadowMap,bm as VSMShadowMap,bn as ShadowMaterial,bo as MeshPhongMaterial,bp as AdditiveBlending,bq as NoToneMapping,br as LinearToneMapping,bs as ReinhardToneMapping,bt as CineonToneMapping,bu as ACESFilmicToneMapping,bv as Layers,bw as WebGLRenderer}from"./main-thread-to-worker-ee3036b3.js";class Container{constructor(){this._context=new Map,this._lookups=new Map,this._singletons=new Map}getContext(e){if(this._context.has(e)){const t=this._context.get(e);return this._context.set(e,t+1),e+t}return this._context.set(e,1),e+0}addDependencyInjectionAssignments(e){e.forEach(e=>{this._lookups.set(e.className,e)})}lookup(e,t){if(!this._lookups.has(e))return null;const n=this._lookups.get(e);if(1===n.type&&void 0===t){const t="Dependency "+e+" has definition context but no context was defined!";return console.trace(t),console.error(t),null}let a=t&&1===n.type?t:"global";if(a+="_"+e,2===n.type)return new n.classDefinition;if(this._singletons.has(a))return this._singletons.get(a);const r=new n.classDefinition(t);return this._singletons.set(a,r),r}cleanUp(e){if(e){let t=[];this._singletons.forEach((n,a)=>{a.startsWith(e)&&t.push(a)}),t.forEach(e=>{this._singletons.delete(e)})}else this._singletons.clear(),this._singletons=new Map}}class DependencyInjectionAssignment{constructor(e,t,n){this.className=e,this.classDefinition=t,this.type=void 0===n?0:n}}const IMAGE_FORMATS={JPG:".jpg",JPEG:".jpeg",PNG:".png",GIF:".gif"};class FormDataUtil{_base64toBlob(e,t){t=t||"";const n=atob(e),a=n.length,r=Math.ceil(a/1024),i=new Array(r);for(let e=0;e<r;++e){let t=1024*e,r=Math.min(t+1024,a);const s=new Array(r-t);for(let e=t,a=0;e<r;++a,++e)s[a]=n[e].charCodeAt(0);i[e]=new Uint8Array(s)}return new Blob(i,{type:t})}_createFormData(e,t,n,a){const r=new FormData;-1!==e.indexOf(",")&&(e=e.substr(e.indexOf(",")+1));const i=-1===Object.keys(IMAGE_FORMATS).map(e=>IMAGE_FORMATS[e]).indexOf(n)?"application":"image",s=this._base64toBlob(e,i+"/"+n.substr(1));return r.append(a,s,t+n),r}create(e,t,n,a){return this._createFormData(e,t,n,a)}}const PREDEFINED_LIGHTSETTING={SOFA:"sofa",SHELF:"shelf",SHELF_FRONT:"shelf_front",BAKED:"baked",CAMERA:"camera",EQUAL:"equal"};class DynamicLightSettingLoader{static createDynamicLightSettingSource(e,t){let n={};if(e)n.url=e;else if(t)switch(t){case PREDEFINED_LIGHTSETTING.SHELF:n.url=getAssetPath()+"static/shelf-2975dd3f2fa9c763.json";break;case PREDEFINED_LIGHTSETTING.SHELF_FRONT:n.url=getAssetPath()+"static/shelf_front-8c9566a4512f0de8.json";break;case PREDEFINED_LIGHTSETTING.SOFA:n.url=getAssetPath()+"static/sofa-997b116bc5f2e92e.json";break;case PREDEFINED_LIGHTSETTING.BAKED:n.url=getAssetPath()+"static/baked-6485a2b1daeb69e8.json";break;case PREDEFINED_LIGHTSETTING.CAMERA:n.url=getAssetPath()+"static/camera-05824b47cdb951e4.json";break;case PREDEFINED_LIGHTSETTING.EQUAL:n.url=getAssetPath()+"static/equal-319f6b83c827913f.json";break;default:n.url=getAssetPath()+"static/camera-05824b47cdb951e4.json"}else n=null;return n}parse(e){let t=JSON.parse(e);return t.lights?this.load(t):[]}load(e){let t=[];return e.lights?(e.lights.forEach(e=>{let n;switch(e.type){case"ambient":n=this._parseAmbientLight(e);break;case"rectarea":n=this._parseRectAreaLight(e);break;case"spot":n=this._parseSpotLight(e);break;case"directional":n=this._parseDirectionalLight(e)}n&&t.push(n)}),t):[]}_parseAmbientLight(e){let t=new AmbientLight;return this._parseCommon(t,e),t}_parseRectAreaLight(e){let{intensity:t,castShadow:n,target:a,width:r,height:i}=e,s=null;if(n&&DynamicLightSettingLoader.rectAreaLightReplacement){const n=new DirectionalLight;this._parseCommon(n,e),s=n,n.castShadow=!0,n.shadow.camera.near=.1,n.shadow.camera.far=100,n.shadow.mapSize=new Vector2(1024,1024),n.shadow.bias=-5e-5,n.shadow.normalBias=.01,n.intensity=t?t/100:1,n.lookAt(a?new Vector3(a.x,a.y,a.z):new Vector3(0,0,0))}else{const n=new RectAreaLight;this._parseCommon(n,e),s=n,n.width=r||.8,n.height=i||.8,n.castShadow=!1,n.matrixAutoUpdate=!0,n.intensity=(t||240)/((r||.8)*(i||.8)),n.lookAt(a?new Vector3(a.x,a.y,a.z):new Vector3(0,0,0)),DynamicLightSettingLoader.rectAreaLightLoadingListener&&DynamicLightSettingLoader.rectAreaLightLoadingListener(n)}return s}_parseSpotLight(e){let t=new SpotLight;this._parseCommon(t,e);let{angle:n,penumbra:a,target:r,castShadow:i}=e;return t.angle=(n||100)*Math.PI/180,t.penumbra=a||.5,t.lookAt(r?new Vector3(r.x,r.y,r.z):new Vector3(0,0,0)),t.shadow.camera.near=.1,t.shadow.camera.far=10,t.shadow.mapSize=new Vector2(1024,1024),t.castShadow=i||!1,t}_parseDirectionalLight(e){let t=new DirectionalLight;this._parseCommon(t,e);let{target:n,castShadow:a}=e;return t.castShadow=a||!1,t.shadow.camera.near=.1,t.shadow.camera.far=100,t.shadow.mapSize=new Vector2(1024,1024),t.shadow.bias=-5e-5,t.lookAt(n?new Vector3(n.x,n.y,n.z):new Vector3(0,0,0)),t}_parseCommon(e,t){let{name:n,intensity:a,color:r,position:i,movesWithCamera:s}=t;e.name=n||"",e.intensity=a||1,e.color=new Color$1(r||"#ffffff"),e.position.copy(i?new Vector3(i.x,i.y,i.z):new Vector3(0,0,0)),e.visible=!0,e.layers.set(1),e.userData.movesWithCamera=s}}DynamicLightSettingLoader.rectAreaLightReplacement=!0;const getHostname=()=>{var e;const t=(()=>{if(window.__RML__ENV__&&window.__RML__ENV__.skipIframeCheck)return!1;try{return window.self!==window.top}catch(e){return!0}})();let n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href;if(!n)return null;if(t){if(!document.referrer)return null;n=document.referrer}const{hostname:a}=new URL(n);return a},NAMES_FOR_LOCALHOST=["127.0.0.1","localhost","0.0.0.0"],isIdItemId=function(e){return!(!e||"string"!=typeof e||e.split(":").length>2)},getCatalogIdFromItemOrConfigurationId=e=>{if(!e||"string"!=typeof e)return null;const t=e.split(":");return t.length<2?null:t[0]},kernelPartToPriceId=({articleNr:e,componentId:t})=>e&&""!==e?t.split(":")[0]+":"+e:null,wasRequestSuccess=(e,t)=>null!=e?"string"==typeof e?"true"===e:!0===e:("string"==typeof t&&(t=parseInt(t,10)),t>=200&&t<300);class NetworkLayer{constructor(){this._queue=[],this._pendingRequests=0}_nextSlot(){if(this._pendingRequests-=1,!this._queue.length)return;const{request:e,resolve:t,reject:n}=this._queue.shift();this._fetch(e).then(t,n)}_fetch(e,t={},n={}){return this._pendingRequests+=1,new Promise((a,r)=>{self.fetch(e,t).then(async function(e){this._nextSlot();const t=!n.checkResponse||!1!==await n.checkResponse(e);if(wasRequestSuccess(e.ok,e.status)&&t)a(...arguments);else{const t=(null==e?void 0:e.url)||"URL unknown";r(new Error(e.statusText||'Http error "'+(e&&e.status?e.status:"unknown")+'", for "'+t+'"'))}}.bind(this),e=>{this._nextSlot(),r(e)})})}fetch(e,t={},n={}){return this._pendingRequests>=40?new Promise((t,n)=>this._queue.push({request:e,resolve:t,reject:n})):this._fetch(e,t,n)}}function __decorate(e,t,n,a){var r,i=arguments.length,s=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(s=(i<3?r(s):i>3?r(t,n,s):r(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}"function"==typeof SuppressedError&&SuppressedError;const dashCase=function(e){return e.startsWith("_")&&(e=e.substr(1)),e.replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(function(e,t){return(t>0?"-":"")+e.toLowerCase()}))};function inject(e,t){const n=Symbol("property-cache");Object.defineProperty(e,t,{get(){if(!this[n]){const e=window.__RML__DI__.lookup(dashCase(t),this._creator_);e?this[n]=e:console.error("Dependency "+dashCase(t)+" not found! Add dependency to /utils/injectables.ts")}return this[n]}})}class Logger{info(...e){console}log(...e){console}warn(...e){console.warn.apply(console,e)}error(...e){console.warn.apply(console,e)}}class KernelIo extends Logger{constructor(e){super(),this._creator_=e}setMeta(e){this._meta=e}get meta(){return this._meta?this._meta:{}}throw(e){const t="[Kernel Exception]: "+e;this._globalCallback.onKernelMsg("exception",e,this.meta),this.error(t)}error(e){this._globalCallback.onKernelMsg("error",e,this.meta),super.error(e)}warn(e){this._globalCallback.onKernelMsg("warning",e,this.meta),super.warn(e)}}__decorate([inject],KernelIo.prototype,"_globalCallback",void 0);const ASSET_CACHE=new Map,SYNCED_CATALOGS=new Map,SYNCED_FLOORS_TAGS=new Map,SYNCED_TYPE_CHANGE_TAGS=new Map;class DataSyncer{constructor(e){this._bootCallbacks=[],this._isStarted=!1,this._isStarting=!1,this._alwaysUseCache=!1,this._creator_=e}start(e){return this._configuratorUiCallbacks.onSyncStarted(),this._startWorker().then(()=>this._handleCatalog(e)).then(()=>{const{typeChangeTag:e,floorMaterialsTag:t}=this._initData;Promise.all([this._syncFloorTag(t),this._syncTypeChangeTag(e)]).then(()=>{SYNCED_TYPE_CHANGE_TAGS.set(e,!0),this._configuratorUiCallbacks.onSyncDone()})})}syncCatalog(e){return this._startWorker().then(()=>this._handleCatalog(e))}syncFloorTag(e){return this._startWorker().then(()=>this._syncFloorTag(e))}syncTypeChangeTag(e){return this._startWorker().then(()=>this._syncTypeChangeTag(e))}_syncFloorTag(e){const t=[];return e&&!SYNCED_FLOORS_TAGS.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{t.push(this._handleMaterialsAndTextures(e))}),this._singlePromiseFactory.create(1,e,n=>{Promise.all(t).then(()=>{SYNCED_FLOORS_TAGS.set(e,!0),n()},e=>this._softReject(n,'_syncFloorTag error: "'+e+'"'))})):Promise.resolve()}_syncTypeChangeTag(e){const t=[];return e&&!SYNCED_TYPE_CHANGE_TAGS.get(e)?(t.push(this._handleTags([e])),this._rapiAccess.getTag(e).then(e=>{this._rapiAccess.getItems(e.items).then(e=>{e.forEach(e=>{this.getIsCatalogSynced(e.catalog)&&t.push(this._handleCatalog(e.catalog))})})}),this._singlePromiseFactory.create(2,e,n=>{Promise.all(t).then(()=>{SYNCED_FLOORS_TAGS.set(e,!0),n()},e=>this._softReject(n,'_syncTypeChangeTag error: "'+e+'"'))})):Promise.resolve()}getIsCatalogSynced(e){return!!SYNCED_CATALOGS.get(e)}_startWorker(){return new Promise((e,t)=>{if(this._isStarted)return e();this._bootCallbacks.push({resolve:e,reject:t}),this._isStarting||(this._worker=new Worker(getAssetPath()+"static/asset-loader.worker-1735a5fb1e401244.js"),this._mainThreadToWorker=new MainThreadToWorker(this,this._worker),this._isStarting=!0,this._mainThreadToWorker.sendToWorker(1))})}onCommand(e,t,n){switch(e){case 4:this._isStarted=!0,this._bootCallbacks.forEach(({resolve:e})=>e());break;case 3:this._mainThreadToWorker.resolvePromises(t,n)}}_handleCatalog(e){return this._singlePromiseFactory.create(0,e,t=>this.getIsCatalogSynced(e)?t():this._rapiAccess.getCatalog(e).then(e=>Promise.all([this._handleContentWithAssets(this._rapiAccess.getComponentsOf(e),["perspectiveImage"]),this._handleItemsAndAdditionalContents(e),this._handleMaterialsAndTextures(e),this._handleExternalMeshes(e),this._handleTags(e.tags)])).then(()=>{SYNCED_CATALOGS.set(e,!0),t()},e=>this._softReject(t,'Catalog sync error: "'+e+'"')))}_handleTags(e){return this._handleContentWithAssets(this._rapiAccess.getTags(e),["pngIcon","svgIcon"])}_handleExternalMeshes(e){return new Promise(t=>{this._rapiAccess.getMeshesOfCatalog(e.id).then(e=>{const n=[];e.forEach(e=>{n.push(this._handleContentWithAssets(Promise.all([this._rapiAccess.getMesh(e.id)]),["url"]))}),Promise.all(n).then(t,e=>this._softReject(t,'Sync crt files error: "'+e+'"'))},e=>this._softReject(t,'getMeshesOfCatalog error: "'+e+'"'))})}_handleItemsAndAdditionalContents(e){return new Promise(t=>{this._rapiAccess.getItemsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["perspectiveImage"])),this._rapiAccess.getAdditionalContentsOfItems(e).then(e=>{const t=e.filter(e=>-1!==[5,6,4].indexOf(e.type));n.push(this._handleContentWithAssets(Promise.resolve(t),["content"]))},e=>this._softReject(t,'getAdditionalContentsOfItems error: "'+e+'"')),Promise.all(n).then(t,e=>this._softReject(t,'AdditionalContent image sync error:"'+e+'"'))})})}_handleMaterialsAndTextures(e){return new Promise(t=>{this._rapiAccess.getMaterialsOf(e).then(e=>{const n=[];n.push(this._handleContentWithAssets(Promise.resolve(e),["thumbnail"])),e.forEach(e=>{n.push(this._handleContentWithAssets(this._rapiAccess.getTexturesOf(e),["image"]))}),Promise.all(n).then(t,e=>this._softReject(t,'getTexturesOf error: "'+e+'"'))},e=>this._softReject(t,'getMaterialsOf error: "'+e+'"'))})}_handleContentWithAssets(e,t){return new Promise(n=>e.then(e=>this._fetchAssets(e,t).then(n,e=>this._softReject(n,'_handleContentWithAssets error: "'+e+'"')),e=>this._softReject(n,'_handleContentWithAssets promise error: "'+e+'"')))}_fetchAssets(e,t){const n=[];e||(e=[]);for(let a=0,r=e.length;a<r;a++){const r=e[a];t.forEach(e=>{const t=r[e];t&&n.push(this._preCacheAsset(t))})}return Promise.all(n)}_preCacheAsset(e){return new Promise(t=>{if(ASSET_CACHE.get(e))return t();this._assetUrlToBase64(e).then(n=>{ASSET_CACHE.set(e,n),t()},e=>this._softReject(t,'_preCacheAsset error: "'+e+'"'))})}_assetUrlToBase64(e){return new Promise(t=>{this._mainThreadToWorker.sendToWorker(5,e,t,e=>this._softReject(t,'_assetUrlToBase64 error: "'+e+'"'))})}_softReject(e,t){this._errorHandler.softReject(e,t,2)}requestAsset(e,t=!1){return navigator.onLine&&!this._alwaysUseCache?e:ASSET_CACHE.get(e)||(t?e:null)}setAlwaysUseCache(e){this._alwaysUseCache=e}preFillAssetCache(e,t){ASSET_CACHE.set(e,t)}}__decorate([inject],DataSyncer.prototype,"_rapiAccess",void 0),__decorate([inject],DataSyncer.prototype,"_singlePromiseFactory",void 0),__decorate([inject],DataSyncer.prototype,"_errorHandler",void 0),__decorate([inject],DataSyncer.prototype,"_configuratorUiCallbacks",void 0),__decorate([inject],DataSyncer.prototype,"_initData",void 0);class AsyncGuard{constructor(e){this.info=e,this._init()}_init(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){e&&this._resolve(e),this._resolve()}reject(e){this._reject(e)}wait(){return this._promise}reset(){this._init()}}function mergeGeometries(e,t=!1){const n=null!==e[0].index,a=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),i={},s={},o=e[0].morphTargetsRelative,l=new BufferGeometry;let d=0;for(let c=0;c<e.length;++c){const h=e[c];let u=0;if(n!==(null!==h.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in h.attributes){if(!a.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===i[e]&&(i[e]=[]),i[e].push(h.attributes[e]),u++}if(u!==a.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in h.morphAttributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===s[e]&&(s[e]=[]),s[e].push(h.morphAttributes[e])}if(t){let e;if(n)e=h.index.count;else{if(void 0===h.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;e=h.attributes.position.count}l.addGroup(d,e,c),d+=e}}if(n){let t=0;const n=[];for(let a=0;a<e.length;++a){const r=e[a].index;for(let e=0;e<r.count;++e)n.push(r.getX(e)+t);t+=e[a].attributes.position.count}l.setIndex(n)}for(const e in i){const t=mergeAttributes(i[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(const e in s){const t=s[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let a=0;a<s[e].length;++a)t.push(s[e][a][n]);const a=mergeAttributes(t);if(!a)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(a)}}return l}function mergeAttributes(e){let t,n,a,r=-1,i=0;for(let s=0;s<e.length;++s){const o=e[s];if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===a&&(a=o.normalized),a!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=o.gpuType),r!==o.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;i+=o.count*n}const s=new t(i),o=new BufferAttribute(s,n,a);let l=0;for(let t=0;t<e.length;++t){const a=e[t];if(a.isInterleavedBufferAttribute){const e=l/n;for(let t=0,r=a.count;t<r;t++)for(let r=0;r<n;r++){const n=a.getComponent(t,r);o.setComponent(t+e,r,n)}}else s.set(a.array,l);l+=a.count*n}return void 0!==r&&(o.gpuType=r),o}function toTrianglesDrawMode(e,t){if(t===TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===TriangleFanDrawMode||t===TriangleStripDrawMode){let n=e.getIndex();if(null===n){const t=[],a=e.getAttribute("position");if(void 0===a)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<a.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const a=n.count-2,r=[];if(t===TriangleFanDrawMode)for(let e=1;e<=a;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<a;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==a&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=e.clone();return i.setIndex(r),i.clearGroups(),i}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class GLTFLoader extends Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFMaterialsDispersionExtension(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,n,a){const r=this;let i;if(""!==this.resourcePath)i=this.resourcePath;else if(""!==this.path){const t=LoaderUtils.extractUrlBase(e);i=LoaderUtils.resolveURL(t,this.path)}else i=LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const s=function(t){a?a(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},o=new FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{r.parse(n,i,(function(n){t(n),r.manager.itemEnd(e)}),s)}catch(e){s(e)}}),n,s)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,a){let r;const i={},s={},o=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{i[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(a&&a(e))}r=JSON.parse(i[EXTENSIONS.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e));else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new GLTFParser(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),s[t.name]=t,i[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],n=r.extensionsRequired||[];switch(t){case EXTENSIONS.KHR_MATERIALS_UNLIT:i[t]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:i[t]=new GLTFDracoMeshCompressionExtension(r,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:i[t]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:i[t]=new GLTFMeshQuantizationExtension;break;default:n.indexOf(t)>=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(i),l.setPlugins(s),l.parse(n,a)}parseAsync(e,t){const n=this;return new Promise((function(a,r){n.parse(e,t,a,r)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,a=t.length;n<a;n++){const a=t[n];a.extensions&&a.extensions[this.name]&&void 0!==a.extensions[this.name].light&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let a=t.cache.get(n);if(a)return a;const r=t.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let s;const o=new Color$1(16777215);void 0!==i.color&&o.setRGB(i.color[0],i.color[1],i.color[2],LinearSRGBColorSpace);const l=void 0!==i.range?i.range:0;switch(i.type){case"directional":s=new DirectionalLight(o),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new PointLight(o),s.distance=l;break;case"spot":s=new SpotLight(o),s.distance=l,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,s.angle=i.spot.outerConeAngle,s.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return s.position.set(0,0,0),s.decay=2,assignExtrasToUserData(s,i),void 0!==i.intensity&&(s.intensity=i.intensity),s.name=t.createUniqueName(i.name||"light_"+e),a=Promise.resolve(s),t.cache.add(n,a),a}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,a=n.json.nodes[e],r=(a.extensions&&a.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(e,t,n){const a=[];e.color=new Color$1(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],LinearSRGBColorSpace),e.opacity=t[3]}void 0!==r.baseColorTexture&&a.push(n.assignTexture(e,"map",r.baseColorTexture,SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const a=n.extensions[this.name].emissiveStrength;return void 0!==a&&(t.emissiveIntensity=a),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Vector2(e,e)}return Promise.all(r)}}class GLTFMaterialsDispersionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const a=n.extensions[this.name];return t.dispersion=void 0!==a.dispersion?a.dispersion:0,Promise.resolve()}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&r.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&r.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Color$1(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=a.extensions[this.name];if(void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],LinearSRGBColorSpace)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&r.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,SRGBColorSpace)),void 0!==i.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const s=i.attenuationColor||[1,1,1];return t.attenuationColor=(new Color$1).setRGB(s[0],s[1],s[2],LinearSRGBColorSpace),Promise.all(r)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const a=n.extensions[this.name];return t.ior=void 0!==a.ior?a.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const s=i.specularColorFactor||[1,1,1];return t.specularColor=(new Color$1).setRGB(s[0],s[1],s[2],LinearSRGBColorSpace),void 0!==i.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,SRGBColorSpace)),Promise.all(r)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&r.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(r)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,a=n.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&r.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,a=n.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const r=a.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,a=n.json,r=a.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],s=a.images[i.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,i.source,o);if(a.extensionsRequired&&a.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,a=n.json,r=a.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],s=a.images[i.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,i.source,o);if(a.extensionsRequired&&a.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],a=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return a.then((function(t){const n=e.byteOffset||0,a=e.byteLength||0,i=e.count,s=e.byteStride,o=new Uint8Array(t,n,a);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(i,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(i*s);return r.decodeGltfBuffer(new Uint8Array(t),i,s,o,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const a=t.meshes[n.mesh];for(const e of a.primitives)if(e.mode!==WEBGL_CONSTANTS.TRIANGLES&&e.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&e.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,i=[],s={};for(const e in r)i.push(this.parser.getDependency("accessor",r[e]).then(t=>(s[e]=t,s[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],a=e[0].count,r=[];for(const e of n){const t=new Matrix4,n=new Vector3,i=new Quaternion,o=new Vector3(1,1,1),l=new InstancedMesh(e.geometry,e.material,a);for(let e=0;e<a;e++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&i.fromBufferAttribute(s.ROTATION,e),s.SCALE&&o.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,t.compose(n,i,o));for(const t in s)if("_COLOR_0"===t){const e=s[t];l.instanceColor=new InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,s[t]);Object3D.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),r.push(l)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF";class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-12,r=new DataView(e,12);let i=0;for(;i<a;){const t=r.getUint32(i,!0);i+=4;const a=r.getUint32(i,!0);if(i+=4,1313821514===a){const a=new Uint8Array(e,12+i,t);this.content=n.decode(a)}else if(5130562===a){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,a=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,s={},o={},l={};for(const e in i){const t=ATTRIBUTES[e]||e.toLowerCase();s[t]=i[e]}for(const t in e.attributes){const a=ATTRIBUTES[t]||t.toLowerCase();if(void 0!==i[t]){const r=n.accessors[e.attributes[t]],i=WEBGL_COMPONENT_TYPES[r.componentType];l[a]=i.name,o[a]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t,n){a.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],a=o[t];void 0!==a&&(n.normalized=a)}t(e)}),s,l,LinearSRGBColorSpace,n)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,n,a){super(e,t,n,a)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,a=this.valueSize,r=e*a*3+a;for(let e=0;e!==a;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,a){const r=this.resultBuffer,i=this.sampleValues,s=this.valueSize,o=2*s,l=3*s,d=a-t,c=(n-t)/d,h=c*c,u=h*c,p=e*l,m=p-l,g=-2*u+3*h,_=u-h,f=1-g,v=_-h+c;for(let e=0;e!==s;e++){const t=i[m+e+s],n=i[m+e+o]*d,a=i[p+e+s],l=i[p+e]*d;r[e]=f*t+v*n+g*a+_*l}return r}}const _q=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,n,a){const r=super.interpolate_(e,t,n,a);return _q.fromArray(r).normalize().toArray(r),r}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:NearestFilter,9729:LinearFilter,9984:NearestMipmapNearestFilter,9985:LinearMipmapNearestFilter,9986:NearestMipmapLinearFilter,9987:LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:ClampToEdgeWrapping,33648:MirroredRepeatWrapping,10497:RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:InterpolateLinear,STEP:InterpolateDiscrete};function addUnknownExtensionsToUserData(e,t,n){for(const a in n.extensions)void 0===e[a]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[a]=n.extensions[a])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,a=t.weights.length;n<a;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const n=e.extensions&&e.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,a=e.targets.length;n<a;n++)t+=":"+createAttributesKey(e.targets[n]);return t}function createAttributesKey(e){let t="";const n=Object.keys(e).sort();for(let a=0,r=n.length;a<r;a++)t+=n[a]+":"+e[n[a]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const _identityMatrix=new Matrix4;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,a=-1,r=!1,i=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);a=n&&t?parseInt(t[1],10):-1,r=e.indexOf("Firefox")>-1,i=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&a<17||r&&i<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,a=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const i={scene:t[0][a.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:a.asset,parser:n,userData:{}};return addUnknownExtensionsToUserData(r,i,a),assignExtrasToUserData(i,a),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(i)}))).then((function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,a=t.length;n<a;n++){const a=t[n].joints;for(let t=0,n=a.length;t<n;t++)e[a[t]].isBone=!0}for(let t=0,a=e.length;t<a;t++){const a=e[t];void 0!==a.mesh&&(this._addNodeRef(this.meshCache,a.mesh),void 0!==a.skin&&(n[a.mesh].isSkinnedMesh=!0)),void 0!==a.camera&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const a=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,a]of e.children.entries())r(a,t.children[n])};return r(n,a),a.name+="_instance_"+e.uses[t]++,a}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const a=e(t[n]);if(a)return a}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let a=0;a<t.length;a++){const r=e(t[a]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let a=this.cache.get(n);if(!a){switch(e){case"scene":a=this.loadScene(t);break;case"node":a=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":a=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":a=this.loadAccessor(t);break;case"bufferView":a=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":a=this.loadBuffer(t);break;case"material":a=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":a=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":a=this.loadSkin(t);break;case"animation":a=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":a=this.loadCamera(t);break;default:if(a=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!a)throw new Error("Unknown type: "+e)}this.cache.add(n,a)}return a}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,a=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(a.map((function(t,a){return n.getDependency(e,a)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise((function(e,r){n.load(LoaderUtils.resolveURL(t.uri,a.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,a=t.byteOffset||0;return e.slice(a,a+n)}))}loadAccessor(e){const t=this,n=this.json,a=this.json.accessors[e];if(void 0===a.bufferView&&void 0===a.sparse){const e=WEBGL_TYPE_SIZES[a.type],t=WEBGL_COMPONENT_TYPES[a.componentType],n=!0===a.normalized,r=new t(a.count*e);return Promise.resolve(new BufferAttribute(r,e,n))}const r=[];return void 0!==a.bufferView?r.push(this.getDependency("bufferView",a.bufferView)):r.push(null),void 0!==a.sparse&&(r.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],i=WEBGL_TYPE_SIZES[a.type],s=WEBGL_COMPONENT_TYPES[a.componentType],o=s.BYTES_PER_ELEMENT,l=o*i,d=a.byteOffset||0,c=void 0!==a.bufferView?n.bufferViews[a.bufferView].byteStride:void 0,h=!0===a.normalized;let u,p;if(c&&c!==l){const e=Math.floor(d/c),n="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+e+":"+a.count;let l=t.cache.get(n);l||(u=new s(r,e*c,a.count*c/o),l=new InterleavedBuffer(u,c/o),t.cache.add(n,l)),p=new InterleavedBufferAttribute(l,i,d%c/o,h)}else u=null===r?new s(a.count*i):new s(r,d,a.count*i),p=new BufferAttribute(u,i,h);if(void 0!==a.sparse){const t=WEBGL_TYPE_SIZES.SCALAR,n=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],o=a.sparse.indices.byteOffset||0,l=a.sparse.values.byteOffset||0,d=new n(e[1],o,a.sparse.count*t),c=new s(e[2],l,a.sparse.count*i);null!==r&&(p=new BufferAttribute(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=d.length;e<t;e++){const t=d[e];if(p.setX(t,c[e*i]),i>=2&&p.setY(t,c[e*i+1]),i>=3&&p.setZ(t,c[e*i+2]),i>=4&&p.setW(t,c[e*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,a=t.textures[e].source,r=t.images[a];let i=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(i=e)}return this.loadTextureImage(e,a,i)}loadTextureImage(e,t,n){const a=this,r=this.json,i=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=i.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);const n=(r.samplers||{})[i.sampler]||{};return t.magFilter=WEBGL_FILTERS[n.magFilter]||LinearFilter,t.minFilter=WEBGL_FILTERS[n.minFilter]||LinearMipmapLinearFilter,t.wrapS=WEBGL_WRAPPINGS[n.wrapS]||RepeatWrapping,t.wrapT=WEBGL_WRAPPINGS[n.wrapT]||RepeatWrapping,a.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,a=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const r=n.images[e],i=self.URL||self.webkitURL;let s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:r.mimeType});return s=i.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let i=n;!0===t.isImageBitmapLoader&&(i=function(e){const t=new Texture(e);t.needsUpdate=!0,n(t)}),t.load(LoaderUtils.resolveURL(e,a.path),i,void 0,r)}))})).then((function(e){var t;return!0===o&&i.revokeObjectURL(s),assignExtrasToUserData(e,r),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,a){const r=this;return this.getDependency("texture",n.index).then((function(i){if(!i)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((i=i.clone()).channel=n.texCoord),r.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(i);i=r.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),r.associations.set(i,t)}}return void 0!==a&&(i.colorSpace=a),e[t]=i,i}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const a=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(a||r||i){let e="ClonedMaterial:"+n.uuid+":";a&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),i&&(t.flatShading=!0),a&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,a=this.extensions,r=n.materials[e];let i;const s={},o=[];if((r.extensions||{})[EXTENSIONS.KHR_MATERIALS_UNLIT]){const e=a[EXTENSIONS.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),o.push(e.extendParams(s,r,t))}else{const n=r.pbrMetallicRoughness||{};if(s.color=new Color$1(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],LinearSRGBColorSpace),s.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(s,"map",n.baseColorTexture,SRGBColorSpace)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),i=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===r.doubleSided&&(s.side=DoubleSide);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===l&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&i!==MeshBasicMaterial&&(o.push(t.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new Vector2(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==r.occlusionTexture&&i!==MeshBasicMaterial&&(o.push(t.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&i!==MeshBasicMaterial){const e=r.emissiveFactor;s.emissive=(new Color$1).setRGB(e[0],e[1],e[2],LinearSRGBColorSpace)}return void 0!==r.emissiveTexture&&i!==MeshBasicMaterial&&o.push(t.assignTexture(s,"emissiveMap",r.emissiveTexture,SRGBColorSpace)),Promise.all(o).then((function(){const n=new i(s);return r.name&&(n.name=r.name),assignExtrasToUserData(n,r),t.associations.set(n,{materials:e}),r.extensions&&addUnknownExtensionsToUserData(a,n,r),n}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,a=this.primitiveCache;function r(e){return n[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return addPrimitiveAttributes(n,e,t)}))}const i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n],o=createPrimitiveKey(s),l=a[o];if(l)i.push(l.promise);else{let e;e=s.extensions&&s.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?r(s):addPrimitiveAttributes(new BufferGeometry,s,t),a[o]={primitive:s,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,a=this.extensions,r=n.meshes[e],i=r.primitives,s=[];for(let e=0,t=i.length;e<t;e++){const t=void 0===i[e].material?(void 0===(o=this.cache).DefaultMaterial&&(o.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:FrontSide})),o.DefaultMaterial):this.getDependency("material",i[e].material);s.push(t)}var o;return s.push(t.loadGeometries(i)),Promise.all(s).then((function(n){const s=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,d=o.length;n<d;n++){const d=o[n],c=i[n];let h;const u=s[n];if(c.mode===WEBGL_CONSTANTS.TRIANGLES||c.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||c.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||void 0===c.mode)h=!0===r.isSkinnedMesh?new SkinnedMesh(d,u):new Mesh(d,u),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),c.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?h.geometry=toTrianglesDrawMode(h.geometry,TriangleStripDrawMode):c.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(h.geometry=toTrianglesDrawMode(h.geometry,TriangleFanDrawMode));else if(c.mode===WEBGL_CONSTANTS.LINES)h=new LineSegments(d,u);else if(c.mode===WEBGL_CONSTANTS.LINE_STRIP)h=new Line(d,u);else if(c.mode===WEBGL_CONSTANTS.LINE_LOOP)h=new LineLoop(d,u);else{if(c.mode!==WEBGL_CONSTANTS.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);h=new Points(d,u)}Object.keys(h.geometry.morphAttributes).length>0&&updateMorphTargets(h,r),h.name=t.createUniqueName(r.name||"mesh_"+e),assignExtrasToUserData(h,r),c.extensions&&addUnknownExtensionsToUserData(a,h,c),t.assignFinalMaterial(h),l.push(h)}for(let n=0,a=l.length;n<a;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return r.extensions&&addUnknownExtensionsToUserData(a,l[0],r),l[0];const d=new Group;r.extensions&&addUnknownExtensionsToUserData(a,d,r),t.associations.set(d,{meshes:e});for(let e=0,t=l.length;e<t;e++)d.add(l[e]);return d}))}loadCamera(e){let t;const n=this.json.cameras[e],a=n[n.type];if(a)return"perspective"===n.type?t=new PerspectiveCamera(MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):"orthographic"===n.type&&(t=new OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),assignExtrasToUserData(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,a=t.joints.length;e<a;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),a=e,r=[],i=[];for(let e=0,s=a.length;e<s;e++){const s=a[e];if(s){r.push(s);const t=new Matrix4;null!==n&&t.fromArray(n.array,16*e),i.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Skeleton(r,i)}))}loadAnimation(e){const t=this.json,n=this,a=t.animations[e],r=a.name?a.name:"animation_"+e,i=[],s=[],o=[],l=[],d=[];for(let e=0,t=a.channels.length;e<t;e++){const t=a.channels[e],n=a.samplers[t.sampler],r=t.target,c=r.node,h=void 0!==a.parameters?a.parameters[n.input]:n.input,u=void 0!==a.parameters?a.parameters[n.output]:n.output;void 0!==r.node&&(i.push(this.getDependency("node",c)),s.push(this.getDependency("accessor",h)),o.push(this.getDependency("accessor",u)),l.push(n),d.push(r))}return Promise.all([Promise.all(i),Promise.all(s),Promise.all(o),Promise.all(l),Promise.all(d)]).then((function(e){const t=e[0],a=e[1],i=e[2],s=e[3],o=e[4],l=[];for(let e=0,r=t.length;e<r;e++){const r=t[e],d=a[e],c=i[e],h=s[e],u=o[e];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const p=n._createAnimationTracks(r,d,c,h,u);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}return new AnimationClip(r,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,a=t.nodes[e];return void 0===a.mesh?null:n.getDependency("mesh",a.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,a.mesh,e);return void 0!==a.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=a.weights.length;t<n;t++)e.morphTargetInfluences[t]=a.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],a=t._loadNodeShallow(e),r=[],i=n.children||[];for(let e=0,n=i.length;e<n;e++)r.push(t.getDependency("node",i[e]));const s=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([a,Promise.all(r),s]).then((function(e){const t=e[0],n=e[1],a=e[2];null!==a&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(a,_identityMatrix)}));for(let e=0,a=n.length;e<a;e++)t.add(n[e]);return t}))}_loadNodeShallow(e){const t=this.json,n=this.extensions,a=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const r=t.nodes[e],i=r.name?a.createUniqueName(r.name):"",s=[],o=a._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&s.push(o),void 0!==r.camera&&s.push(a.getDependency("camera",r.camera).then((function(e){return a._getNodeRef(a.cameraCache,r.camera,e)}))),a._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){s.push(e)})),this.nodeCache[e]=Promise.all(s).then((function(t){let s;if(s=!0===r.isBone?new Bone:t.length>1?new Group:1===t.length?t[0]:new Object3D,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(r.name&&(s.userData.name=r.name,s.name=i),assignExtrasToUserData(s,r),r.extensions&&addUnknownExtensionsToUserData(n,s,r),void 0!==r.matrix){const e=new Matrix4;e.fromArray(r.matrix),s.applyMatrix4(e)}else void 0!==r.translation&&s.position.fromArray(r.translation),void 0!==r.rotation&&s.quaternion.fromArray(r.rotation),void 0!==r.scale&&s.scale.fromArray(r.scale);return a.associations.has(s)||a.associations.set(s,{}),a.associations.get(s).nodes=e,s})),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],a=this,r=new Group;n.name&&(r.name=a.createUniqueName(n.name)),assignExtrasToUserData(r,n),n.extensions&&addUnknownExtensionsToUserData(t,r,n);const i=n.nodes||[],s=[];for(let e=0,t=i.length;e<t;e++)s.push(a.getDependency("node",i[e]));return Promise.all(s).then((function(e){for(let t=0,n=e.length;t<n;t++)r.add(e[t]);return a.associations=(e=>{const t=new Map;for(const[e,n]of a.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,n);return e.traverse(e=>{const n=a.associations.get(e);null!=n&&t.set(e,n)}),t})(r),r}))}_createAnimationTracks(e,t,n,a,r){const i=[],s=e.name?e.name:e.uuid,o=[];let l;switch(PATH_PROPERTIES[r.path]===PATH_PROPERTIES.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(s),PATH_PROPERTIES[r.path]){case PATH_PROPERTIES.weights:l=NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:l=QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:l=VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:l=NumberKeyframeTrack;break;case 2:case 3:default:l=VectorKeyframeTrack}}const d=void 0!==a.interpolation?INTERPOLATION[a.interpolation]:InterpolateLinear,c=this._getArrayFromAccessor(n);for(let e=0,n=o.length;e<n;e++){const n=new l(o[e]+"."+PATH_PROPERTIES[r.path],t.array,c,d);"CUBICSPLINE"===a.interpolation&&this._createCubicSplineTrackInterpolant(n),i.push(n)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),n=new Float32Array(t.length);for(let a=0,r=t.length;a<r;a++)n[a]=t[a]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,n){const a=t.attributes,r=[];function i(t,a){return n.getDependency("accessor",t).then((function(t){e.setAttribute(a,t)}))}for(const t in a){const n=ATTRIBUTES[t]||t.toLowerCase();n in e.attributes||r.push(i(a[t],n))}if(void 0!==t.indices&&!e.index){const a=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(a)}return ColorManagement.workingColorSpace!==LinearSRGBColorSpace&&"COLOR_0"in a&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),function(e,t,n){const a=t.attributes,r=new Box3;if(void 0===a.POSITION)return;{const e=n.json.accessors[a.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new Vector3(t[0],t[1],t[2]),new Vector3(i[0],i[1],i[2])),e.normalized){const t=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const i=t.targets;if(void 0!==i){const e=new Vector3,t=new Vector3;for(let a=0,r=i.length;a<r;a++){const r=i[a];if(void 0!==r.POSITION){const a=n.json.accessors[r.POSITION],i=a.min,s=a.max;if(void 0!==i&&void 0!==s){if(t.setX(Math.max(Math.abs(i[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(i[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(i[2]),Math.abs(s[2]))),a.normalized){const e=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[a.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const s=new Sphere;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=s}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){let a=!1,r=!1,i=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(a=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(i=!0),a&&r&&i)break}if(!a&&!r&&!i)return Promise.resolve(e);const s=[],o=[],l=[];for(let d=0,c=t.length;d<c;d++){const c=t[d];if(a){const t=void 0!==c.POSITION?n.getDependency("accessor",c.POSITION):e.attributes.position;s.push(t)}if(r){const t=void 0!==c.NORMAL?n.getDependency("accessor",c.NORMAL):e.attributes.normal;o.push(t)}if(i){const t=void 0!==c.COLOR_0?n.getDependency("accessor",c.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l)]).then((function(t){const n=t[0],s=t[1],o=t[2];return a&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=s),i&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}const _taskCache=new WeakMap;class DRACOLoader extends Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,a){const r=new FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,e=>{this.parse(e,t,a)},n,a)}parse(e,t,n=(()=>{})){this.decodeDracoFile(e,t,null,null,SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,a,r=LinearSRGBColorSpace,i=(()=>{})){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:a||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,s).then(t).catch(i)}decodeGeometry(e,t){const n=JSON.stringify(t);if(_taskCache.has(e)){const t=_taskCache.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let a;const r=this.workerNextTaskID++,i=e.byteLength,s=this._getWorker(r,i).then(n=>(a=n,new Promise((n,i)=>{a._callbacks[r]={resolve:n,reject:i},a.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return s.catch(()=>!0).then(()=>{a&&r&&this._releaseTask(a,r)}),_taskCache.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new BufferGeometry;e.index&&t.setIndex(new BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const a=e.attributes[n],r=a.name,i=a.array,s=a.itemSize,o=new BufferAttribute(i,s);"color"===r&&(this._assignVertexColorSpace(o,a.vertexColorSpace),o.normalized=i instanceof Float32Array==0),t.setAttribute(r,o)}return t}_assignVertexColorSpace(e,t){if(t!==SRGBColorSpace)return;const n=new Color$1;for(let t=0,a=e.count;t<a;t++)n.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((t,a)=>{n.load(e,t,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const a=DRACOWorker.toString(),r=["/* draco decoder */",n,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){this.workerPool.map(e=>e._taskLoad)}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function DRACOWorker(){let e,t;function n(e,t,n,a,r,i){const s=i.num_components(),o=n.num_points()*s,l=o*r.BYTES_PER_ELEMENT,d=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,i,d,l,c);const h=new r(e.HEAPF32.buffer,c,o).slice();return e._free(c),{name:a,array:h,itemSize:s}}onmessage=function(a){const r=a.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const a=r.buffer,i=r.taskConfig;t.then(e=>{const t=e.draco,s=new t.Decoder;try{const e=function(e,t,a,r){const i=r.attributeIDs,s=r.attributeTypes;let o,l;const d=t.GetEncodedGeometryType(a);if(d===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(a,a.byteLength,o);else{if(d!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(a,a.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const c={index:null,attributes:[]};for(const a in i){const l=self[s[a]];let d,h;if(r.useUniqueIDs)h=i[a],d=t.GetAttributeByUniqueId(o,h);else{if(h=t.GetAttributeId(o,e[i[a]]),-1===h)continue;d=t.GetAttribute(o,h)}const u=n(e,t,o,a,l,d);"color"===a&&(u.vertexColorSpace=r.vertexColorSpace),c.attributes.push(u)}return d===e.TRIANGULAR_MESH&&(c.index=function(e,t,n){const a=3*n.num_faces(),r=4*a,i=e._malloc(r);t.GetTrianglesUInt32Array(n,r,i);const s=new Uint32Array(e.HEAPF32.buffer,i,a).slice();return e._free(i),{array:s,itemSize:1}}(e,t,o)),e.destroy(o),c}(t,s,new Int8Array(a),i),o=e.attributes.map(e=>e.array.buffer);e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}})}}}const DRACO_LIB_FILES={"draco_wasm_wrapper.js":"static/draco_wasm_wrapper-6263f3a4b71cdf3b.js","draco_decoder.wasm":"static/draco_decoder-b048235474cbf09e.wasm","draco_decoder.js":"static/draco_decoder-dc7f397e2a2ebac4.js"};class LocalStorageHelper{constructor(e){this._context_=e}getStore(e="rml_default"){return this._localStorage.getItem(e)||{entries:[]}}saveStore(e,t){this._localStorage.setItem(e,t)}addItem(e,t,n="rml_default",a=5){const r=this.getStore(n),i=r.entries.find(t=>t.id===e);if(i?(i.payload=t,i.date=Date.now()):r.entries.push({id:e,date:Date.now(),payload:t}),r.entries.length>a)for(r.entries.sort((e,t)=>t.date-e.date);r.entries.length>a;)r.entries.pop();this.saveStore(n,r)}getItem(e,t="rml_default"){const n=this.getStore(t).entries.find(t=>t.id===e);return n?n.payload:null}}__decorate([inject],LocalStorageHelper.prototype,"_localStorage",void 0);const toRadiant=function(e){return e*(Math.PI/180)},toDegrees=function(e){return e*(180/Math.PI)},getIdealDistance=function(e,t,n,a,r,i){e=Math.sqrt(e*e+n*n);const s=r/i,o=2*Math.atan(Math.tan(a*Math.PI/180/2)*s)*180/Math.PI,l=toRadiant(a),d=t/2/Math.tan(l/2),c=e/(2*Math.atan(Math.PI*o/360));return Math.max(d,c)},round=function(e){return Math.round(1e3*e)/1e3},getDelta=function(e,t){return Math.abs(e.y-t.y)+Math.abs(e.x-t.x)},convertToTHREE=e=>new Vector3(e.x/1e3,e.z/1e3,e.y/-1e3),convertToEuler=e=>new Euler(e.x,e.z,-e.y),convertToThreeDimensions=e=>new Vector3(e.x/1e3,e.z/1e3,e.y/1e3),convertToKernel=e=>({x:Math.round(1e3*e.x),y:Math.round(-1e3*e.z),z:Math.round(1e3*e.y)}),utilityStringToUTF16=e=>decodeURIComponent(encodeURIComponent(e)),convertCObject=e=>{if(!e){const t=typeof e;return"number"===t||"boolean"===t?e:null}if(!e.hasOwnProperty("size")&&e.size&&"function"==typeof e.size){let t=utilityToArray(e);for(let e=0;e<t.length;e++)t[e]=convertCObject(t[e]);return"string"==typeof t?utilityStringToUTF16(t):t}if("object"==typeof e)for(let t in e)e.hasOwnProperty(t)&&(e[t]=convertCObject(e[t]));return"string"==typeof e?utilityStringToUTF16(e):e},utilityToArray=e=>{let t=[];if(e){let n=e.size();for(let a=0;a<n;a++)t.push(e.get(a))}return t},convertToThreeMatrix=e=>{let t=new Matrix4,n=convertCObject(e);return t.fromArray(n),t.transpose(),(e=>{let t=new Matrix4;t.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),t.scale(new Vector3(.001,.001,.001));let n=new Matrix4;return n.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),n.scale(new Vector3(1e3,1e3,1e3)),t.multiply(e).multiply(n)})(t)},convertToThreeUVMatrix=e=>{const t=new Matrix4;return t.set(e[0],e[2],0,e[4],e[1],e[3],0,e[5],0,0,1,0,0,0,0,1),t};function colorToString(e,t){var n=e.__state.conversionName.toString(),a=Math.round(e.r),r=Math.round(e.g),i=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),d=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+a+","+r+","+i+")":"CSS_RGBA"===n?"rgba("+a+","+r+","+i+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+a+","+r+","+i+"]":"RGBA_ARRAY"===n?"["+a+","+r+","+i+","+s+"]":"RGB_OBJ"===n?"{r:"+a+",g:"+r+",b:"+i+"}":"RGBA_OBJ"===n?"{r:"+a+",g:"+r+",b:"+i+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+d+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+d+",a:"+s+"}":"unknown format"}var ARR_EACH=Array.prototype.forEach,ARR_SLICE=Array.prototype.slice,Common={BREAK:{},extend:function(e){return this.each(ARR_SLICE.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(ARR_SLICE.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=ARR_SLICE.call(arguments);return function(){for(var t=ARR_SLICE.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(ARR_EACH&&e.forEach&&e.forEach===ARR_EACH)e.forEach(t,n);else if(e.length===e.length+0){var a,r=void 0;for(r=0,a=e.length;r<a;r++)if(r in e&&t.call(n,e[r],r)===this.BREAK)return}else for(var i in e)if(t.call(n,e[i],i)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var a=void 0;return function(){var r=this,i=arguments;function s(){a=null,n||e.apply(r,i)}var o=n||!a;clearTimeout(a),a=setTimeout(s,t),o&&e.apply(r,i)}},toArray:function(e){return e.toArray?e.toArray():ARR_SLICE.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},INTERPRETATIONS=[{litmus:Common.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:colorToString},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:colorToString},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:colorToString},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:colorToString}}},{litmus:Common.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:Common.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:Common.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(Common.isNumber(e.r)&&Common.isNumber(e.g)&&Common.isNumber(e.b)&&Common.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(Common.isNumber(e.r)&&Common.isNumber(e.g)&&Common.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(Common.isNumber(e.h)&&Common.isNumber(e.s)&&Common.isNumber(e.v)&&Common.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(Common.isNumber(e.h)&&Common.isNumber(e.s)&&Common.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],result=void 0,toReturn=void 0,interpret=function(){toReturn=!1;var e=arguments.length>1?Common.toArray(arguments):arguments[0];return Common.each(INTERPRETATIONS,(function(t){if(t.litmus(e))return Common.each(t.conversions,(function(t,n){if(result=t.read(e),!1===toReturn&&!1!==result)return toReturn=result,result.conversionName=n,result.conversion=t,Common.BREAK})),Common.BREAK})),toReturn},tmpComponent=void 0,ColorMath={hsv_to_rgb:function(e,t,n){var a=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),i=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,i],[s,n,i],[i,n,o],[i,s,n],[o,i,n],[n,i,s]][a];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var a=Math.min(e,t,n),r=Math.max(e,t,n),i=r-a,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/i:t===r?2+(n-e)/i:4+(e-t)/i,(s/=6)<0&&(s+=1),{h:360*s,s:i/r,v:r/255})},rgb_to_hex:function(e,t,n){var a=this.hex_with_component(0,2,e);return a=this.hex_with_component(a,1,t),this.hex_with_component(a,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(tmpComponent=8*t)|e&~(255<<tmpComponent)}},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),get=function e(t,n,a){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,n,a)}if("value"in r)return r.value;var s=r.get;return void 0!==s?s.call(a):void 0},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},Color=function(){function e(){if(classCallCheck(this,e),this.__state=interpret.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return createClass(e,[{key:"toString",value:function(){return colorToString(this)}},{key:"toHexString",value:function(){return colorToString(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function defineRGBComponent(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||Color.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(Color.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function defineHSVComponent(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||Color.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(Color.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}Color.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=ColorMath.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Common.extend(e.__state,ColorMath.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},Color.recalculateHSV=function(e){var t=ColorMath.rgb_to_hsv(e.r,e.g,e.b);Common.extend(e.__state,{s:t.s,v:t.v}),Common.isNaN(t.h)?Common.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},Color.COMPONENTS=["r","g","b","h","s","v","hex","a"],defineRGBComponent(Color.prototype,"r",2),defineRGBComponent(Color.prototype,"g",1),defineRGBComponent(Color.prototype,"b",0),defineHSVComponent(Color.prototype,"h"),defineHSVComponent(Color.prototype,"s"),defineHSVComponent(Color.prototype,"v"),Object.defineProperty(Color.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(Color.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=ColorMath.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var Controller=function(){function e(t,n){classCallCheck(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return createClass(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),EVENT_MAP_INV={};Common.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(e,t){Common.each(e,(function(e){EVENT_MAP_INV[e]=t}))}));var CSS_VALUE_PIXELS=/(\d+(\.\d+)?)px/;function cssValueToPixels(e){if("0"===e||Common.isUndefined(e))return 0;var t=e.match(CSS_VALUE_PIXELS);return Common.isNull(t)?0:parseFloat(t[1])}var dom={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var a=n,r=t;Common.isUndefined(r)&&(r=!0),Common.isUndefined(a)&&(a=!0),e.style.position="absolute",r&&(e.style.left=0,e.style.right=0),a&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,a){var r=n||{},i=EVENT_MAP_INV[t];if(!i)throw new Error("Event type "+t+" not supported.");var s=document.createEvent(i);switch(i){case"MouseEvents":var o=r.x||r.clientX||0,l=r.y||r.clientY||0;s.initMouseEvent(t,r.bubbles||!1,r.cancelable||!0,window,r.clickCount||1,0,0,o,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var d=s.initKeyboardEvent||s.initKeyEvent;Common.defaults(r,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),d(t,r.bubbles||!1,r.cancelable,window,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,r.keyCode,r.charCode);break;default:s.initEvent(t,r.bubbles||!1,r.cancelable||!0)}Common.defaults(s,a),e.dispatchEvent(s)},bind:function(e,t,n,a){var r=a||!1;return e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on"+t,n),dom},unbind:function(e,t,n,a){var r=a||!1;return e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on"+t,n),dom},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return dom},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),a=n.indexOf(t);-1!==a&&(n.splice(a,1),e.className=n.join(" "))}else e.className=void 0;return dom},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return cssValueToPixels(t["border-left-width"])+cssValueToPixels(t["border-right-width"])+cssValueToPixels(t["padding-left"])+cssValueToPixels(t["padding-right"])+cssValueToPixels(t.width)},getHeight:function(e){var t=getComputedStyle(e);return cssValueToPixels(t["border-top-width"])+cssValueToPixels(t["border-bottom-width"])+cssValueToPixels(t["padding-top"])+cssValueToPixels(t["padding-bottom"])+cssValueToPixels(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},BooleanController=function(e){function t(e,n){classCallCheck(this,t);var a=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=a;return a.__prev=a.getValue(),a.__checkbox=document.createElement("input"),a.__checkbox.setAttribute("type","checkbox"),dom.bind(a.__checkbox,"change",(function(){r.setValue(!r.__prev)}),!1),a.domElement.appendChild(a.__checkbox),a.updateDisplay(),a}return inherits(t,Controller),createClass(t,[{key:"setValue",value:function(e){var n=get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),OptionController=function(e){function t(e,n,a){classCallCheck(this,t);var r=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=a,s=r;if(r.__select=document.createElement("select"),Common.isArray(i)){var o={};Common.each(i,(function(e){o[e]=e})),i=o}return Common.each(i,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),s.__select.appendChild(n)})),r.updateDisplay(),dom.bind(r.__select,"change",(function(){var e=this.options[this.selectedIndex].value;s.setValue(e)})),r.domElement.appendChild(r.__select),r}return inherits(t,Controller),createClass(t,[{key:"setValue",value:function(e){var n=get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return dom.isActive(this.__select)?this:(this.__select.value=this.getValue(),get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(),StringController=function(e){function t(e,n){classCallCheck(this,t);var a=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=a;function i(){r.setValue(r.__input.value)}return a.__input=document.createElement("input"),a.__input.setAttribute("type","text"),dom.bind(a.__input,"keyup",i),dom.bind(a.__input,"change",i),dom.bind(a.__input,"blur",(function(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())})),dom.bind(a.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),a.updateDisplay(),a.domElement.appendChild(a.__input),a}return inherits(t,Controller),createClass(t,[{key:"updateDisplay",value:function(){return dom.isActive(this.__input)||(this.__input.value=this.getValue()),get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function numDecimals(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var NumberController=function(e){function t(e,n,a){classCallCheck(this,t);var r=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=a||{};return r.__min=i.min,r.__max=i.max,r.__step=i.step,Common.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=numDecimals(r.__impliedStep),r}return inherits(t,Controller),createClass(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=numDecimals(e),this}}]),t}(),NumberControllerBox=function(e){function t(e,n,a){classCallCheck(this,t);var r=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,a));r.__truncationSuspended=!1;var i=r,s=void 0;function o(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())}function l(e){var t=s-e.clientY;i.setValue(i.getValue()+t*i.__impliedStep),s=e.clientY}function d(){dom.unbind(window,"mousemove",l),dom.unbind(window,"mouseup",d),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),dom.bind(r.__input,"change",(function(){var e=parseFloat(i.__input.value);Common.isNaN(e)||i.setValue(e)})),dom.bind(r.__input,"blur",(function(){o()})),dom.bind(r.__input,"mousedown",(function(e){dom.bind(window,"mousemove",l),dom.bind(window,"mouseup",d),s=e.clientY})),dom.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(i.__truncationSuspended=!0,this.blur(),i.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return inherits(t,NumberController),createClass(t,[{key:"updateDisplay",value:function(){var e,n,a;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,a=Math.pow(10,n),Math.round(e*a)/a),get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function map(e,t,n,a,r){return a+(e-t)/(n-t)*(r-a)}var NumberControllerSlider=function(e){function t(e,n,a,r,i){classCallCheck(this,t);var s=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:a,max:r,step:i})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(map(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function d(){dom.unbind(window,"mousemove",l),dom.unbind(window,"mouseup",d),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function c(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(map(t,n.left,n.right,o.__min,o.__max))}function h(){dom.unbind(window,"touchmove",c),dom.unbind(window,"touchend",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),dom.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),dom.bind(window,"mousemove",l),dom.bind(window,"mouseup",d),l(e)})),dom.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(dom.bind(window,"touchmove",c),dom.bind(window,"touchend",h),c(e))})),dom.addClass(s.__background,"slider"),dom.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return inherits(t,NumberController),createClass(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),FunctionController=function(e){function t(e,n,a){classCallCheck(this,t);var r=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===a?"Fire":a,dom.bind(r.__button,"click",(function(e){return e.preventDefault(),i.fire(),!1})),dom.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return inherits(t,Controller),createClass(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(),ColorController=function(e){function t(e,n){classCallCheck(this,t);var a=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));a.__color=new Color(a.getValue()),a.__temp=new Color(0);var r=a;a.domElement=document.createElement("div"),dom.makeSelectable(a.domElement,!1),a.__selector=document.createElement("div"),a.__selector.className="selector",a.__saturation_field=document.createElement("div"),a.__saturation_field.className="saturation-field",a.__field_knob=document.createElement("div"),a.__field_knob.className="field-knob",a.__field_knob_border="2px solid ",a.__hue_knob=document.createElement("div"),a.__hue_knob.className="hue-knob",a.__hue_field=document.createElement("div"),a.__hue_field.className="hue-field",a.__input=document.createElement("input"),a.__input.type="text",a.__input_textShadow="0 1px 1px ",dom.bind(a.__input,"keydown",(function(e){13===e.keyCode&&h.call(this)})),dom.bind(a.__input,"blur",h),dom.bind(a.__selector,"mousedown",(function(){dom.addClass(this,"drag").bind(window,"mouseup",(function(){dom.removeClass(r.__selector,"drag")}))})),dom.bind(a.__selector,"touchstart",(function(){dom.addClass(this,"drag").bind(window,"touchend",(function(){dom.removeClass(r.__selector,"drag")}))}));var i,s=document.createElement("div");function o(e){p(e),dom.bind(window,"mousemove",p),dom.bind(window,"touchmove",p),dom.bind(window,"mouseup",d),dom.bind(window,"touchend",d)}function l(e){m(e),dom.bind(window,"mousemove",m),dom.bind(window,"touchmove",m),dom.bind(window,"mouseup",c),dom.bind(window,"touchend",c)}function d(){dom.unbind(window,"mousemove",p),dom.unbind(window,"touchmove",p),dom.unbind(window,"mouseup",d),dom.unbind(window,"touchend",d),u()}function c(){dom.unbind(window,"mousemove",m),dom.unbind(window,"touchmove",m),dom.unbind(window,"mouseup",c),dom.unbind(window,"touchend",c),u()}function h(){var e=interpret(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,a=n.clientX,i=n.clientY,s=(a-t.left)/(t.right-t.left),o=1-(i-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function m(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Common.extend(a.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Common.extend(a.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:a.__field_knob_border+(a.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Common.extend(a.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Common.extend(a.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Common.extend(s.style,{width:"100%",height:"100%",background:"none"}),linearGradient(s,"top","rgba(0,0,0,0)","#000"),Common.extend(a.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(i=a.__hue_field).style.background="",i.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",i.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Common.extend(a.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:a.__input_textShadow+"rgba(0,0,0,0.7)"}),dom.bind(a.__saturation_field,"mousedown",o),dom.bind(a.__saturation_field,"touchstart",o),dom.bind(a.__field_knob,"mousedown",o),dom.bind(a.__field_knob,"touchstart",o),dom.bind(a.__hue_field,"mousedown",l),dom.bind(a.__hue_field,"touchstart",l),a.__saturation_field.appendChild(s),a.__selector.appendChild(a.__field_knob),a.__selector.appendChild(a.__saturation_field),a.__selector.appendChild(a.__hue_field),a.__hue_field.appendChild(a.__hue_knob),a.domElement.appendChild(a.__input),a.domElement.appendChild(a.__selector),a.updateDisplay(),a}return inherits(t,Controller),createClass(t,[{key:"updateDisplay",value:function(){var e=interpret(this.getValue());if(!1!==e){var t=!1;Common.each(Color.COMPONENTS,(function(n){if(!Common.isUndefined(e[n])&&!Common.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Common.extend(this.__color.__state,e)}Common.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,a=255-n;Common.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,linearGradient(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Common.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+a+","+a+","+a+",.7)"})}}]),t}(),vendors=["-moz-","-o-","-webkit-","-ms-",""];function linearGradient(e,t,n,a){e.style.background="",Common.each(vendors,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+a+" 100%); "}))}var saveDialogContents='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>',ControllerFactory=function(e,t){var n=e[t];return Common.isArray(arguments[2])||Common.isObject(arguments[2])?new OptionController(e,t,arguments[2]):Common.isNumber(n)?Common.isNumber(arguments[2])&&Common.isNumber(arguments[3])?Common.isNumber(arguments[4])?new NumberControllerSlider(e,t,arguments[2],arguments[3],arguments[4]):new NumberControllerSlider(e,t,arguments[2],arguments[3]):Common.isNumber(arguments[4])?new NumberControllerBox(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new NumberControllerBox(e,t,{min:arguments[2],max:arguments[3]}):Common.isString(n)?new StringController(e,t):Common.isFunction(n)?new FunctionController(e,t,""):Common.isBoolean(n)?new BooleanController(e,t):null},requestAnimationFrame$1=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},CenteredDiv=function(){function e(){classCallCheck(this,e),this.backgroundElement=document.createElement("div"),Common.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),dom.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Common.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;dom.bind(this.backgroundElement,"click",(function(){t.hide()}))}return createClass(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Common.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",dom.unbind(e.domElement,"webkitTransitionEnd",t),dom.unbind(e.domElement,"transitionend",t),dom.unbind(e.domElement,"oTransitionEnd",t)};dom.bind(this.domElement,"webkitTransitionEnd",t),dom.bind(this.domElement,"transitionend",t),dom.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-dom.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-dom.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=document,a=document.createElement("style");a.type="text/css",a.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(a)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var SUPPORTS_LOCAL_STORAGE=function(){try{return!!window.localStorage}catch(e){return!1}}(),SAVE_DIALOGUE=void 0,autoPlaceVirgin=!0,autoPlaceContainer=void 0,hide=!1,hideableGuis=[],GUI=function e(t){var n=this,a=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),dom.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],a=Common.defaults(a,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),a=Common.defaults(a,{resizable:a.autoPlace,hideable:a.autoPlace}),Common.isUndefined(a.load)?a.load={preset:"Default"}:a.preset&&(a.load.preset=a.preset),Common.isUndefined(a.parent)&&a.hideable&&hideableGuis.push(this),a.resizable=Common.isUndefined(a.parent)&&a.resizable,a.autoPlace&&Common.isUndefined(a.scrollable)&&(a.scrollable=!0);var r,i=SUPPORTS_LOCAL_STORAGE&&"true"===localStorage.getItem(getLocalStorageHash(0,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return a.parent}},scrollable:{get:function(){return a.scrollable}},autoPlace:{get:function(){return a.autoPlace}},closeOnTop:{get:function(){return a.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:a.load.preset},set:function(e){n.parent?n.getRoot().preset=e:a.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return a.width},set:function(e){a.width=e,setWidth(n,e)}},name:{get:function(){return a.name},set:function(e){a.name=e,o&&(o.innerHTML=a.name)}},closed:{get:function(){return a.closed},set:function(t){a.closed=t,a.closed?dom.addClass(n.__ul,e.CLASS_CLOSED):dom.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return a.load}},useLocalStorage:{get:function(){return i},set:function(e){SUPPORTS_LOCAL_STORAGE&&(i=e,e?dom.bind(window,"unload",s):dom.unbind(window,"unload",s),localStorage.setItem(getLocalStorageHash(0,"isLocal"),e))}}}),Common.isUndefined(a.parent)){if(this.closed=a.closed||!1,dom.addClass(this.domElement,e.CLASS_MAIN),dom.makeSelectable(this.domElement,!1),SUPPORTS_LOCAL_STORAGE&&i){n.useLocalStorage=!0;var l=localStorage.getItem(getLocalStorageHash(0,"gui"));l&&(a.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,dom.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),a.closeOnTop?(dom.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(dom.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),dom.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===a.closed&&(a.closed=!0);var d=document.createTextNode(a.name);dom.addClass(d,"controller-name"),o=addRow(n,d),dom.addClass(this.__ul,e.CLASS_CLOSED),dom.addClass(o,"title"),dom.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),a.closed||(this.closed=!1)}a.autoPlace&&(Common.isUndefined(a.parent)&&(autoPlaceVirgin&&(autoPlaceContainer=document.createElement("div"),dom.addClass(autoPlaceContainer,"dg"),dom.addClass(autoPlaceContainer,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(autoPlaceContainer),autoPlaceVirgin=!1),autoPlaceContainer.appendChild(this.domElement),dom.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||setWidth(n,a.width)),this.__resizeHandler=function(){n.onResizeDebounced()},dom.bind(window,"resize",this.__resizeHandler),dom.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),dom.bind(this.__ul,"transitionend",this.__resizeHandler),dom.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),a.resizable&&addResizeHandle(this),s=function(){SUPPORTS_LOCAL_STORAGE&&"true"===localStorage.getItem(getLocalStorageHash(0,"isLocal"))&&localStorage.setItem(getLocalStorageHash(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,a.parent||((r=n.getRoot()).width+=1,Common.defer((function(){r.width-=1})))};function addRow(e,t,n){var a=document.createElement("li");return t&&a.appendChild(t),n?e.__ul.insertBefore(a,n):e.__ul.appendChild(a),e.onResize(),a}function removeListeners(e){dom.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&dom.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function markPresetModified(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function recallSavedValue(e,t){var n=e.getRoot(),a=n.__rememberedObjects.indexOf(t.object);if(-1!==a){var r=n.__rememberedObjectIndecesToControllers[a];if(void 0===r&&(r={},n.__rememberedObjectIndecesToControllers[a]=r),r[t.property]=t,n.load&&n.load.remembered){var i=n.load.remembered,s=void 0;if(i[e.preset])s=i[e.preset];else{if(!i.Default)return;s=i.Default}if(s[a]&&void 0!==s[a][t.property]){var o=s[a][t.property];t.initialValue=o,t.setValue(o)}}}}function _add(e,t,n,a){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var r=void 0;if(a.color)r=new ColorController(t,n);else{var i=[t,n].concat(a.factoryArgs);r=ControllerFactory.apply(e,i)}a.before instanceof Controller&&(a.before=a.before.__li),recallSavedValue(e,r),dom.addClass(r.domElement,"c");var s=document.createElement("span");dom.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=addRow(e,o,a.before);return dom.addClass(l,GUI.CLASS_CONTROLLER_ROW),r instanceof ColorController?dom.addClass(l,"color"):dom.addClass(l,_typeof(r.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,Common.extend(n,{options:function(t){if(arguments.length>1){var a=n.__li.nextElementSibling;return n.remove(),_add(e,n.object,n.property,{before:a,factoryArgs:[Common.toArray(arguments)]})}if(Common.isArray(t)||Common.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),_add(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof NumberControllerSlider){var a=new NumberControllerBox(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Common.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=a[e];n[e]=a[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(a,e),t.apply(n,e)}})),dom.addClass(t,"has-slider"),n.domElement.insertBefore(a.domElement,n.domElement.firstElementChild)}else if(n instanceof NumberControllerBox){var r=function(t){if(Common.isNumber(n.__min)&&Common.isNumber(n.__max)){var a=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var i=_add(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return i.name(a),r&&i.listen(),i}return t};n.min=Common.compose(r,n.min),n.max=Common.compose(r,n.max)}else n instanceof BooleanController?(dom.bind(t,"click",(function(){dom.fakeEvent(n.__checkbox,"click")})),dom.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof FunctionController?(dom.bind(t,"click",(function(){dom.fakeEvent(n.__button,"click")})),dom.bind(t,"mouseover",(function(){dom.addClass(n.__button,"hover")})),dom.bind(t,"mouseout",(function(){dom.removeClass(n.__button,"hover")}))):n instanceof ColorController&&(dom.addClass(t,"color"),n.updateDisplay=Common.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Common.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&markPresetModified(e.getRoot(),!0),t}),n.setValue)}(e,l,r),e.__controllers.push(r),r}function getLocalStorageHash(e,t){return document.location.href+"."+t}function addPresetOption(e,t,n){var a=document.createElement("option");a.innerHTML=t,a.value=t,e.__preset_select.appendChild(a),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function showHideExplain(e,t){t.style.display=e.useLocalStorage?"block":"none"}function addSaveMenu(e){var t=e.__save_row=document.createElement("li");dom.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),dom.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",dom.addClass(n,"button gears");var a=document.createElement("span");a.innerHTML="Save",dom.addClass(a,"button"),dom.addClass(a,"save");var r=document.createElement("span");r.innerHTML="New",dom.addClass(r,"button"),dom.addClass(r,"save-as");var i=document.createElement("span");i.innerHTML="Revert",dom.addClass(i,"button"),dom.addClass(i,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Common.each(e.load.remembered,(function(t,n){addPresetOption(e,n,n===e.preset)})):addPresetOption(e,"Default",!1),dom.bind(s,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(s),t.appendChild(n),t.appendChild(a),t.appendChild(r),t.appendChild(i),SUPPORTS_LOCAL_STORAGE){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(getLocalStorageHash(0,"isLocal"))&&l.setAttribute("checked","checked"),showHideExplain(e,o),dom.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,showHideExplain(e,o)}))}var d=document.getElementById("dg-new-constructor");dom.bind(d,"keydown",(function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||SAVE_DIALOGUE.hide()})),dom.bind(n,"click",(function(){d.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),SAVE_DIALOGUE.show(),d.focus(),d.select()})),dom.bind(a,"click",(function(){e.save()})),dom.bind(r,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),dom.bind(i,"click",(function(){e.revert()}))}function addResizeHandle(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function a(){dom.removeClass(e.__closeButton,GUI.CLASS_DRAG),dom.unbind(window,"mousemove",n),dom.unbind(window,"mouseup",a)}function r(r){return r.preventDefault(),t=r.clientX,dom.addClass(e.__closeButton,GUI.CLASS_DRAG),dom.bind(window,"mousemove",n),dom.bind(window,"mouseup",a),!1}e.__resize_handle=document.createElement("div"),Common.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),dom.bind(e.__resize_handle,"mousedown",r),dom.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function setWidth(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function getCurrentPreset(e,t){var n={};return Common.each(e.__rememberedObjects,(function(a,r){var i={},s=e.__rememberedObjectIndecesToControllers[r];Common.each(s,(function(e,n){i[n]=t?e.initialValue:e.getValue()})),n[r]=i})),n}GUI.toggleHide=function(){hide=!hide,Common.each(hideableGuis,(function(e){e.domElement.style.display=hide?"none":""}))},GUI.CLASS_AUTO_PLACE="a",GUI.CLASS_AUTO_PLACE_CONTAINER="ac",GUI.CLASS_MAIN="main",GUI.CLASS_CONTROLLER_ROW="cr",GUI.CLASS_TOO_TALL="taller-than-window",GUI.CLASS_CLOSED="closed",GUI.CLASS_CLOSE_BUTTON="close-button",GUI.CLASS_CLOSE_TOP="close-top",GUI.CLASS_CLOSE_BOTTOM="close-bottom",GUI.CLASS_DRAG="drag",GUI.DEFAULT_WIDTH=245,GUI.TEXT_CLOSED="Close Controls",GUI.TEXT_OPEN="Open Controls",GUI._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||GUI.toggleHide()},dom.bind(window,"keydown",GUI._keydownHandler,!1),Common.extend(GUI.prototype,{add:function(e,t){return _add(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return _add(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Common.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&autoPlaceContainer.removeChild(this.domElement);var e=this;Common.each(this.__folders,(function(t){e.removeFolder(t)})),dom.unbind(window,"keydown",GUI._keydownHandler,!1),removeListeners(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new GUI(t);this.__folders[e]=n;var a=addRow(this,n.domElement);return dom.addClass(a,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],removeListeners(e);var t=this;Common.each(e.__folders,(function(t){e.removeFolder(t)})),Common.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=dom.getOffset(e.__ul).top,n=0;Common.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=dom.getHeight(t))})),window.innerHeight-t-20<n?(dom.addClass(e.domElement,GUI.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(dom.removeClass(e.domElement,GUI.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&Common.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:Common.debounce((function(){this.onResize()}),50),remember:function(){if(Common.isUndefined(SAVE_DIALOGUE)&&((SAVE_DIALOGUE=new CenteredDiv).domElement.innerHTML=saveDialogContents),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Common.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&addSaveMenu(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&setWidth(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=getCurrentPreset(this)),e.folders={},Common.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=getCurrentPreset(this),markPresetModified(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=getCurrentPreset(this,!0)),this.load.remembered[e]=getCurrentPreset(this),this.preset=e,addPresetOption(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Common.each(this.__controllers,(function(t){this.getRoot().load.remembered?recallSavedValue(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Common.each(this.__folders,(function(e){e.revert(e)})),e||markPresetModified(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&requestAnimationFrame$1.call(window,(function(){e(t)})),Common.each(t,(function(e){e.updateDisplay()}))}(this.__listening)},updateDisplay:function(){Common.each(this.__controllers,(function(e){e.updateDisplay()})),Common.each(this.__folders,(function(e){e.updateDisplay()}))}});var GUI$1=GUI;class MaterialCreator{static createMeshPhysicalMaterial(e){return new MeshPhysicalMaterial(e)}static createMeshStandardMaterial(e){return new MeshStandardMaterial(e)}}const PREVIEW_LINE_MATERIAL_OPACITY=.4,PREVIEW_MATERIAL_COLOR="#DDDDDD",PREVIEW_MATERIAL_OPACITY=1,DOCK_PREVIEW_MATERIAL_ROUGHNESS=1,DOCK_PREVIEW_MATERIAL_METALNESS=0,DOCK_PREVIEW_MATERIAL_OPACITY=.8,DOCK_PREVIEW_MATERIAL_OPACITY_HOVERED=.9,getScreenXY=(e,t,n,a)=>{if(!e||!t||0===n||0===a)return new Vector3;let r=e.clone(),i=n/2,s=a/2;return r.project(t),r.x=Math.floor(r.x*i+i),r.y=Math.floor(-r.y*s+s),r.z=e.distanceTo(t.position),r},kernelBoxToThreeBox=(e,t)=>{t||(t=new Vector3(0,0,0));let n=new Vector3(e.size.x/1e3,e.size.z/1e3,e.size.y/1e3),a=new Vector3(e.origin.x/1e3,e.origin.z/1e3,e.origin.y/-1e3),r=new Vector3(0,0,-n.z).add(a).sub(t),i=new Vector3(n.x,n.y,0).add(a).add(t);return new Box3(r,i)},position3VectorsAreEqual=(e,t)=>{let n=round(e.x),a=round(e.y),r=round(e.z),i=round(t.x),s=round(t.y),o=round(t.z);return n===i&&a===s&&r===o},rotationQuaternionsAreEqual=(e,t)=>{let n=round(e.w),a=round(e.x),r=round(e.y),i=round(e.z),s=round(t.w),o=round(t.x),l=round(t.y),d=round(t.z);return n===s&&a===o&&r===l&&i===d},position2VectorsAreEqual=(e,t)=>{let n=round(e.x),a=round(e.y),r=round(t.x),i=round(t.y);return n===r&&a===i};let whiteTexture=null;const getWhiteTexture=()=>{if(whiteTexture)return whiteTexture;const e=new Uint8Array(4);for(let t=0;t<1;t++){const n=4*t;e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=255}const t=new DataTexture(e,1,1,RGBAFormat);return t.needsUpdate=!0,t},createColorTexture=(e,t,n,a)=>{const r=new Uint8Array(4),i=Math.floor(255*e),s=Math.floor(255*t),o=Math.floor(255*n),l=Math.floor(255*a);for(let e=0;e<4;e++){const t=4*e;r[t]=i,r[t+1]=s,r[t+2]=o,r[t+3]=l}const d=new DataTexture(r,1,1,RGBAFormat);return d.needsUpdate=!0,d},createMaterial=e=>setMaterial(null,e),setMaterial=(e,t)=>{var n;e||(e=createMeshPhysicalMaterial()),e.name=t.id?t.id.toString():"";const a="2"===t.shading.version||(null===(n=t.shading.version)||void 0===n?void 0:n.startsWith("2."));return(e=a?_setMaterialV2Properties(e,t):_setMaterialV1Properties(e,t)).userData.materialVersion=a?2:1,e.map||(whiteTexture||(whiteTexture=getWhiteTexture()),e.map=whiteTexture),e},_setMaterialV1Properties=(e,t)=>{void 0!==t.shading.metallic&&(e.metalness=1===t.shading.metallic?1:.5,e.reflectivity=getValue(t.shading.metallic,.5));let n=!1;return t.shading.transmission&&t.shading.transmission>0?(e.opacity=1-t.shading.transmission,e.transparent=!0,e.depthWrite=!1,e.metalness=0,n=!0):void 0!==t.shading.alpha&&t.shading.alpha<1&&(e.transparent=t.shading.alpha<1,e.opacity=t.shading.alpha,e.depthWrite=t.shading.alpha>=1,e.metalness=.5*Math.max(0,t.shading.alpha),n=!0),e.aoMapIntensity=getValue(t.shading.occlusion,1),e.roughness=getValue(t.shading.roughness,.5),e.alphaTest=getValue(t.shading.alphaCutoff,0),_setColor(e.color,t.shading.basecolor),n||t.shading.doubleSided?e.side=DoubleSide:e.side=FrontSide,e},_setMaterialV2Properties=(e,t)=>{var n,a,r,i,s,o,l,d,c,h,u,p,m,g;let _=!1;return void 0!==t.shading.alpha&&t.shading.alpha<1?(e.transparent=!0,e.opacity=t.shading.alpha,e.depthWrite=!1,_=!0):(e.transparent=!1,e.opacity=1,e.depthWrite=!0),e.alphaTest=null!==(n=t.shading.alphaCutoff)&&void 0!==n?n:0,_setColor(e.color,t.shading.basecolor),e.transmission=null!==(a=t.shading.transmission)&&void 0!==a?a:0,e.ior=null!==(r=Math.max(1,Math.min(2.33,t.shading.transmissionIOR)))&&void 0!==r?r:1.5,e.metalness=null!==(i=t.shading.metallic)&&void 0!==i?i:0,_setColor(e.specularColor,t.shading.specularColor),e.specularIntensity=null!==(s=t.shading.specularity)&&void 0!==s?s:1,e.roughness=null!==(o=t.shading.roughness)&&void 0!==o?o:0,e.aoMapIntensity=null!==(l=t.shading.occlusion)&&void 0!==l?l:1,_setColor(e.emissive,t.shading.emissiveColor),e.emissiveIntensity=null!==(d=t.shading.emissiveIntensity)&&void 0!==d?d:1,e.clearcoat=null!==(c=t.shading.clearcoatIntensity)&&void 0!==c?c:0,e.clearcoatRoughness=null!==(h=t.shading.clearcoatRoughness)&&void 0!==h?h:0,e.clearcoatNormalScale.setScalar(null!==(u=t.shading.clearcoatNormalScale)&&void 0!==u?u:1),_setColor(e.sheenColor,t.shading.sheenColor),e.sheen=null!==(p=t.shading.sheenIntensity)&&void 0!==p?p:1,e.sheenRoughness=null!==(m=t.shading.sheenRoughness)&&void 0!==m?m:1,e.thickness=null!==(g=t.shading.thicknessFactor)&&void 0!==g?g:0,_setColor(e.attenuationColor,t.shading.attenuationColor),t.shading.attenuationDistance&&(e.attenuationDistance=t.shading.attenuationDistance),e.side=_||t.shading.doubleSided?DoubleSide:FrontSide,e},createMeshPhysicalMaterial=()=>MaterialCreator.createMeshPhysicalMaterial({}),getMaterialShading=(e,t=1)=>2===t?_getMaterialShadingV2(e):_getMaterialShadingV1(e),_getMaterialShadingV1=e=>{let t={alpha:e.opacity,metallic:e.reflectivity,basecolor:_getColor(e.color),roughness:e.roughness,doubleSided:e.side===DoubleSide,alphaCutoff:e.alphaTest,transmission:e.transmission};return 1===e.metalness?t.metallic=1:t.metallic=e.reflectivity,t},_getMaterialShadingV2=e=>({version:"2.0.0",alpha:e.opacity,alphaCutoff:e.alphaTest,basecolor:_getColor(e.color),transmission:e.transmission,transmissionIOR:e.ior,metallic:e.metalness,doubleSided:e.side===DoubleSide,specularColor:_getColor(e.specularColor),specularity:e.specularIntensity,roughness:e.roughness,occlusion:e.aoMapIntensity,emissiveColor:_getColor(e.emissive),emissiveIntensity:e.emissiveIntensity,clearcoatIntensity:e.clearcoat,clearcoatRoughness:e.clearcoatRoughness,clearcoatNormalScale:e.clearcoatNormalScale.x,sheenColor:_getColor(e.sheenColor),sheenIntensity:e.sheen,sheenRoughness:e.sheenRoughness,thicknessFactor:e.thickness,attenuationColor:_getColor(e.attenuationColor),attenuationDistance:e.attenuationDistance}),_setColor=(e,t)=>{if(void 0!==t){const n=new Color$1(t.r,t.g,t.b);e.copy(n.convertSRGBToLinear())}},_getColor=e=>{const t=e.clone().convertLinearToSRGB();return{r:t.r,g:t.g,b:t.b}};let textureLoader=null;const addTexture=(e,t,n,a,r,i,s=16)=>(textureLoader||(textureLoader=new TextureLoader,textureLoader.crossOrigin=""),new Promise((o,l)=>{if(!e)return console.warn("trying to add a texture without image",t),void o();textureLoader.load(e,e=>{addExistingTexture(e,t,n,a,r,i,s),o()},l)})),addExistingTexture=(e,t,n,a,r,i,s=16)=>{e.anisotropy=a,e.wrapS=RepeatWrapping,e.wrapT=RepeatWrapping,s<=8&&["ORM","EMRGB","CCRG","CCXYZ","SHRGBA","SPRGBA","TTRG"].includes(t.mapping)?console.warn("ORM maps are not supported on devices with only "+s+" texture units"):(e.repeat.set(r,i),_setMaterialMaps(e,t,n),"RGBA"===t.mapping&&(n.transparent=!0,1===n.userData.materialVersion)&&n.name.includes("glow")&&(n.emissiveIntensity=.5,n.emissive=new Color$1(16777215),n.emissiveMap=n.map),n.needsUpdate=!0)},_setMaterialMaps=(e,t,n)=>{"XYZ"===t.mapping?(n.normalMap=e,n.map===getWhiteTexture()&&(n.map=null)):"ORM"===t.mapping?(n.aoMap=e,n.roughnessMap=e,n.metalnessMap=e):"EMRGB"===t.mapping?n.emissiveMap=e:"CCRG"===t.mapping?(n.clearcoatMap=e,n.clearcoatRoughnessMap=e):"CCXYZ"===t.mapping?n.clearcoatNormalMap=e:"SHRGBA"===t.mapping?(n.sheenColorMap=e,n.sheenRoughnessMap=e):"SPRGBA"===t.mapping?(n.specularColorMap=e,n.specularIntensityMap=e):"TTRG"===t.mapping?(n.transmissionMap=e,n.thicknessMap=e):(e.colorSpace=SRGBColorSpace,n.map=e)},getGUI=(e=!0)=>(window.__RML_GUI__||(window.__RML_GUI__=new GUI$1({autoPlace:e})),window.__RML_GUI__),hideWallsBasedOnCamera=(e,t)=>{let n=!1;for(const a of t){const t=a.getKernelObject();let r;2===t.wallType.value&&(r=convertToTHREE(t.rightNormal)),1===t.wallType.value&&(r=convertToTHREE(t.leftNormal));let i=!0;if(r){let t=convertToTHREE(a.getPlanElement().getCenter());t=t.applyMatrix4(e.matrixWorldInverse),r=r.transformDirection(e.matrixWorldInverse),i=t.dot(r)>=0}i!==a.getContainer().visible&&(n=!0),i?a.show():a.isSelected||a.hide()}return n},setWallTransparency=(e,t,n=!0)=>{if(!e.userData.tween)if(t)if(e.transparent=!0,n){let t={opacity:1};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:.2},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.userData.tween=!1}).start()}else e.opacity=.2;else if(n){let t={opacity:.2};e.userData.tween=!0,new TWEEN.Tween(t).to({opacity:1},400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{e.opacity=t.opacity}).onComplete(()=>{e.transparent=!1,e.userData.tween=!1}).start()}else e.opacity=1,e.transparent=!1},animateMeshMatrix=(e,t,n,a)=>{const r=calculateBaseMatrix(t,n),i=n.clone(),s=r.clone().invert(),o=s.clone().multiply(t),l=s.clone().multiply(n),d={t:0};new TWEEN.Tween(d).to({t:1},400).easing(TWEEN.Easing.Quadratic.InOut).onUpdate(()=>{const t=circularInterpolateMatrix(o,l,d.t),n=r.clone().multiply(t);setMeshMatrix(e,n),a&&a()}).onComplete(()=>{setMeshMatrix(e,i),a&&a()}).start()},calculateBaseMatrix=(e,t)=>{const n=e.clone().invert().clone().multiply(t),a=new Vector3,r=new Quaternion;n.decompose(a,r,new Vector3);const i=getAxisAndAngleFromQuaternion(r),s=i.axis;if(a.length()<.001||Math.abs(i.angleRad)<.001||s.length()<.001)return(new Matrix4).identity();const o=(new Vector3).setFromMatrixPosition(e),l=(new Vector3).setFromMatrixPosition(t);let d=o.clone().sub(l);const c=d.length(),h=(new Vector3).crossVectors(s,d).normalize();d=(new Vector3).crossVectors(h,s).normalize();let u=o.clone().add(l).multiplyScalar(.5);return u=u.sub(h.clone().multiplyScalar(.5*c/Math.tan(.5*i.angleRad))),(new Matrix4).makeBasis(h,s,d).setPosition(u)},getAxisAndAngleFromQuaternion=e=>{const t=Math.sqrt(1-e.w*e.w);return{axis:new Vector3(e.x,e.y,e.z).multiplyScalar(0===t?1:1/t),angleRad:2*Math.acos(e.w)}},setMeshMatrix=(e,t)=>{e.updateMatrix(),t.multiply(e.matrix.clone().invert()),e.applyMatrix4(t),e.updateMatrix()},circularInterpolateMatrix=(e,t,n)=>{const a=new Vector3,r=new Quaternion,i=new Vector3;e.decompose(a,r,i);const s=new Vector3,o=new Quaternion,l=new Vector3;t.decompose(s,o,l);let d=(new Vector3).lerpVectors(a,s,n);const c=(new Quaternion).slerpQuaternions(r,o,n),h=r.clone().conjugate().multiply(o),u=getAxisAndAngleFromQuaternion(h);if(u.angleRad>Math.PI&&(u.angleRad-=2*Math.PI),Math.abs(u.angleRad)>toRadiant(1)&&a.length()>.001&&s.length()>.001){const e=a.clone().normalize().dot(s.clone().normalize());if(Math.abs(e)<.999){const t=(new Vector3).crossVectors(a,s),r=(new Quaternion).setFromAxisAngle(t.normalize(),Math.acos(e)*n),i=a.length()*n+s.length()*(1-n);d=a.applyQuaternion(r).normalize().multiplyScalar(i)}}const p=(new Vector3).lerpVectors(i,l,n),m=new Matrix4;return m.compose(d,c,p),m},getColorFromInt=e=>{let t=new Color$1;return t.setRGB((e>>16)/255,(e>>8&255)/255,(e>>0&255)/255),t},applyFinalMaterialState=(e,t)=>{t.transparent||(e.transparent=t.transparent,delete e.userData.postProcessingMaterialPlugin),e.opacity=t.opacity,e.needsUpdate=!0},transitionTransparencyOfMaterial=(e,t)=>new Promise(n=>{e.traverse(e=>{if(e instanceof Mesh&&TWEEN){const a=e.material;e.userData.tween&&e.userData.tween.stop();const r={opacity:a.opacity};t.transparent&&(a.transparent=t.transparent);const i=new TWEEN.Tween(r);i.toJSON=()=>{},e.userData.tween=i,i.to(t,250).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{a.opacity=r.opacity}).onStop(()=>{applyFinalMaterialState(a,t),e.userData.tween=void 0}).onComplete(()=>{applyFinalMaterialState(a,t),e.userData.tween=void 0,n()}).start()}})}),fadeIn=e=>{e.traverse(e=>{if(e instanceof Mesh&&TWEEN){let t=e.material;if(0===t.opacity)return;let n={opacity:0,transparent:!0},a={opacity:t.opacity,transparent:t.transparent};t.transparent=n.transparent,t.opacity=n.opacity,new TWEEN.Tween(n).to(a,500).easing(TWEEN.Easing.Linear.None).onUpdate(()=>{t.opacity=n.opacity}).onComplete(()=>{t.transparent=a.transparent}).start()}})},dispose=e=>{"Mesh"===e.type?disposeMesh(e):disposeObject(e)},disposeObject=e=>{e&&e.children&&0!==e.children.length&&e.children.forEach(e=>{disposeMesh(e)})},disposeMesh=e=>{e&&(e.material&&disposeMaterial(e.material),e.geometry&&disposeGeometry(e.geometry),e.children&&e.children.length>0&&disposeObject(e))},disposeGeometry=e=>{e&&e.dispose()},disposeMaterial=e=>{e&&(e.map&&e.map.dispose(),e.normalMap&&e.normalMap.dispose(),e.dispose())};let boundingBoxMaterial,debugBoundingBoxMaterial;const getDebugBoundingBoxMaterial=e=>(debugBoundingBoxMaterial||(debugBoundingBoxMaterial=MaterialCreator.createMeshStandardMaterial({color:e||"#FF0000",transparent:!0,opacity:.5,visible:!0})),debugBoundingBoxMaterial),vectorIsZero=e=>0===e.x&&0===e.y&&0===e.z,getMaterialId=(e,t)=>{let n="";return e||""===e?(e.materialId&&""!==e.materialId?n=e.materialId:e.catalogItemId&&""!==e.catalogItemId?n=e.catalogItemId:e.rgbValue>0?n="rgb"+JSON.stringify(e.rgbValue):e.length>0?n=e:t&&1===t.value?n="default_wall_material_"+e.getSourceType().value:t&&7===t.value&&(n="default_ceiling_material_"+e.getSourceType().value),n):null},getYRotationOfObject=e=>{let t=e.getWorldDirection(new Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n},compareBox3Size=(e,t)=>{if(!e||!t)return 0;const n=e.clone().expandByScalar(.001).containsBox(t),a=t.clone().expandByScalar(.001).containsBox(e);return a&&n||!a&&!n?0:!0===n?1:-1},isUVIdentityMatrix=e=>1===e[0]&&0===e[1]&&0===e[2]&&1===e[3]&&0===e[4]&&0===e[5],getDrawingMinBounds=(e,t,n,a=1)=>{const r=t>n,i=r?15:0,s=r?0:10,o=e.getSize(new Vector3),l=e.getCenter(new Vector3);let d=o.x>2*i?o.x/2:i,c=o.z>2*s?o.z/2:s;return d*=a,c*=a,new Box3(new Vector3(l.x-d,l.y,l.z-c),new Vector3(l.x+d,l.y,l.z+c))},threeVectorToTransferableXY=e=>{const{x:t,y:n}=e;return{x:t,y:n}},threeVectorToTransferableXYZ=e=>{const{x:t,y:n,z:a}=e;return{x:t,y:n,z:a}},viewSpacePositionFromUV=(e,t,n)=>(new Vector3).setFromSphericalCoords(e,Math.PI*(1-n),2*Math.PI*(1-t)),createEmptySceneFromCurrent=e=>{const t=new Scene;return e.environment&&(t.environment=e.environment.clone()),e.userData.environmentDefinition&&(t.userData.environmentDefinition=e.userData.environmentDefinition.clone()),t.userData.shadowFromEnvironment=e.userData.shadowFromEnvironment,t},isBox3InFrustum=(e,t)=>{const n=new Frustum,a=(new Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);n.setFromProjectionMatrix(a);const r=t.getCenter(new Vector3);return n.containsPoint(r)},normalizeRotation=e=>Math.atan2(Math.sin(e),Math.cos(e)),DRAW_PREVIEW_MODES={DEFAULT:"default",VECTOR:"vector"};var ENV_HDR_256_FILE_NAME="static/default_256-f1c66a2764f88cc0.exr";const CopyTransformShader={uniforms:{tDiffuse:{value:null},colorTransform:{value:new Matrix4},colorBase:{value:new Vector4(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new Matrix3}},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 }",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 }"},DEFAULT_TRANSFORM=new Matrix4,RGB_TRANSFORM=(new Matrix4).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),ALPHA_TRANSFORM=(new Matrix4).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),RED_TRANSFORM=(new Matrix4).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1);(new Matrix4).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new Matrix4).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1);const GRAYSCALE_TRANSFORM=(new Matrix4).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),ZERO_RGBA=new Vector4(0,0,0,0),ALPHA_RGBA=new Vector4(0,0,0,1),DEFAULT_UV_TRANSFORM=new Matrix3,FLIP_Y_UV_TRANSFORM=(new Matrix3).set(1,0,0,0,-1,1,0,0,1);class CopyTransformMaterial extends ShaderMaterial{constructor(e,t="additive",n=!1,a=!1){const r="additive"===t?{blendSrc:DstColorFactor,blendDst:ZeroFactor,blendEquation:AddEquation,blendSrcAlpha:DstAlphaFactor,blendDstAlpha:ZeroFactor,blendEquationAlpha:AddEquation}:{};super({uniforms:UniformsUtils.clone(CopyTransformShader.uniforms),vertexShader:CopyTransformShader.vertexShader,fragmentShader:CopyTransformShader.fragmentShader,defines:{LINEAR_TO_SRGB:n?1:0,PREMULTIPLIED_ALPHA:a?1:0},transparent:!0,depthTest:!1,depthWrite:!1,...r}),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const BlurShader={uniforms:{tDiffuse:{value:null},rangeMin:{value:new Vector2(1/512,1/512)},rangeMax:{value:new Vector2(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",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 }"};new Vector2(.1,.9),new Vector2(.1,.9);class LinearDepthRenderMaterial extends ShaderMaterial{constructor(e){super({defines:Object.assign({},LinearDepthRenderMaterial._linearDepthShader.defines),uniforms:UniformsUtils.clone(LinearDepthRenderMaterial._linearDepthShader.uniforms),vertexShader:LinearDepthRenderMaterial._linearDepthShader.vertexShader,fragmentShader:LinearDepthRenderMaterial._linearDepthShader.fragmentShader,blending:NoBlending}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}LinearDepthRenderMaterial._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new Vector4(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"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 }"};const _camera=new OrthographicCamera(-1,1,1,-1,0,1),_geometry=new class extends BufferGeometry{constructor(){super(),this.setAttribute("position",new Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Float32BufferAttribute([0,2,0,0,2,0],2))}};class FullScreenQuad{constructor(e){this._mesh=new Mesh(_geometry,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,_camera)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class SimplexNoise{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,a){return e[0]*t+e[1]*n+e[2]*a}dot4(e,t,n,a,r){return e[0]*t+e[1]*n+e[2]*a+e[3]*r}noise(e,t){let n,a,r;const i=(e+t)*(.5*(Math.sqrt(3)-1)),s=Math.floor(e+i),o=Math.floor(t+i),l=(3-Math.sqrt(3))/6,d=(s+o)*l,c=e-(s-d),h=t-(o-d);let u,p;c>h?(u=1,p=0):(u=0,p=1);const m=c-u+l,g=h-p+l,_=c-1+2*l,f=h-1+2*l,v=255&s,S=255&o,w=this.perm[v+this.perm[S]]%12,b=this.perm[v+u+this.perm[S+p]]%12,C=this.perm[v+1+this.perm[S+1]]%12;let y=.5-c*c-h*h;y<0?n=0:(y*=y,n=y*y*this.dot(this.grad3[w],c,h));let M=.5-m*m-g*g;M<0?a=0:(M*=M,a=M*M*this.dot(this.grad3[b],m,g));let P=.5-_*_-f*f;return P<0?r=0:(P*=P,r=P*P*this.dot(this.grad3[C],_,f)),70*(n+a+r)}noise3d(e,t,n){let a,r,i,s;const o=(e+t+n)*(1/3),l=Math.floor(e+o),d=Math.floor(t+o),c=Math.floor(n+o),h=(l+d+c)*(1/6),u=e-(l-h),p=t-(d-h),m=n-(c-h);let g,_,f,v,S,w;u>=p?p>=m?(g=1,_=0,f=0,v=1,S=1,w=0):u>=m?(g=1,_=0,f=0,v=1,S=0,w=1):(g=0,_=0,f=1,v=1,S=0,w=1):p<m?(g=0,_=0,f=1,v=0,S=1,w=1):u<m?(g=0,_=1,f=0,v=0,S=1,w=1):(g=0,_=1,f=0,v=1,S=1,w=0);const b=u-g+1/6,C=p-_+1/6,y=m-f+1/6,M=u-v+1/6*2,P=p-S+1/6*2,T=m-w+1/6*2,A=u-1+.5,E=p-1+.5,x=m-1+.5,R=255&l,I=255&d,D=255&c,O=this.perm[R+this.perm[I+this.perm[D]]]%12,L=this.perm[R+g+this.perm[I+_+this.perm[D+f]]]%12,N=this.perm[R+v+this.perm[I+S+this.perm[D+w]]]%12,k=this.perm[R+1+this.perm[I+1+this.perm[D+1]]]%12;let B=.6-u*u-p*p-m*m;B<0?a=0:(B*=B,a=B*B*this.dot3(this.grad3[O],u,p,m));let U=.6-b*b-C*C-y*y;U<0?r=0:(U*=U,r=U*U*this.dot3(this.grad3[L],b,C,y));let F=.6-M*M-P*P-T*T;F<0?i=0:(F*=F,i=F*F*this.dot3(this.grad3[N],M,P,T));let G=.6-A*A-E*E-x*x;return G<0?s=0:(G*=G,s=G*G*this.dot3(this.grad3[k],A,E,x)),32*(a+r+i+s)}noise4d(e,t,n,a){const r=this.grad4,i=this.simplex,s=this.perm,o=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20;let d,c,h,u,p;const m=(e+t+n+a)*o,g=Math.floor(e+m),_=Math.floor(t+m),f=Math.floor(n+m),v=Math.floor(a+m),S=(g+_+f+v)*l,w=e-(g-S),b=t-(_-S),C=n-(f-S),y=a-(v-S),M=(w>b?32:0)+(w>C?16:0)+(b>C?8:0)+(w>y?4:0)+(b>y?2:0)+(C>y?1:0),P=i[M][0]>=3?1:0,T=i[M][1]>=3?1:0,A=i[M][2]>=3?1:0,E=i[M][3]>=3?1:0,x=i[M][0]>=2?1:0,R=i[M][1]>=2?1:0,I=i[M][2]>=2?1:0,D=i[M][3]>=2?1:0,O=i[M][0]>=1?1:0,L=i[M][1]>=1?1:0,N=i[M][2]>=1?1:0,k=i[M][3]>=1?1:0,B=w-P+l,U=b-T+l,F=C-A+l,G=y-E+l,V=w-x+2*l,j=b-R+2*l,H=C-I+2*l,z=y-D+2*l,W=w-O+3*l,K=b-L+3*l,Y=C-N+3*l,q=y-k+3*l,X=w-1+4*l,Q=b-1+4*l,Z=C-1+4*l,J=y-1+4*l,$=255&g,ee=255&_,te=255&f,ne=255&v,ae=s[$+s[ee+s[te+s[ne]]]]%32,re=s[$+P+s[ee+T+s[te+A+s[ne+E]]]]%32,ie=s[$+x+s[ee+R+s[te+I+s[ne+D]]]]%32,se=s[$+O+s[ee+L+s[te+N+s[ne+k]]]]%32,oe=s[$+1+s[ee+1+s[te+1+s[ne+1]]]]%32;let le=.6-w*w-b*b-C*C-y*y;le<0?d=0:(le*=le,d=le*le*this.dot4(r[ae],w,b,C,y));let de=.6-B*B-U*U-F*F-G*G;de<0?c=0:(de*=de,c=de*de*this.dot4(r[re],B,U,F,G));let ce=.6-V*V-j*j-H*H-z*z;ce<0?h=0:(ce*=ce,h=ce*ce*this.dot4(r[ie],V,j,H,z));let he=.6-W*W-K*K-Y*Y-q*q;he<0?u=0:(he*=he,u=he*he*this.dot4(r[se],W,K,Y,q));let ue=.6-X*X-Q*Q-Z*Z-J*J;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(r[oe],X,Q,Z,J)),27*(d+c+h+u+p)}}new TextureLoader;class SceneVolume{constructor(){this.bounds=new Box3(new Vector3(-1,-1,-1),new Vector3(1,1,1)),this.size=new Vector3(2,2,2),this.center=new Vector3(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){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 Vector3(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()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof OrthographicCamera?((e,t)=>{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()})(e,t):e instanceof PerspectiveCamera&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),a=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const r=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),i=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=r/i,e.fov=MathUtils.radToDeg(2*Math.atan2(i,n)),e.near=n,e.far=a,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}class CameraUpdate{changed(e){var t,n;const a=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),a}}class PassRenderer{constructor(){this._originalClearColor=new Color$1,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new FullScreenQuad(void 0),this._emptyScene=new Scene,this._defaultCamera=new PerspectiveCamera}renderWithOverrideMaterial(e,t,n,a,r,i,s){this._backup(e),this._prepareRenderer(e,r,i,s);const o=t.overrideMaterial;t.overrideMaterial=a,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,a){this._backup(e),this._prepareRenderer(e,t,n,a),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,a,r,i){this._backup(e),this._prepareRenderer(e,a,r,i),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,a,r){this._backup(e),this._prepareRenderer(e,n,a,r),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,a){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(a||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class BlurPass{constructor(e,t){var n;this._passRenderer=null!==(n=null==t?void 0:t.passRenderer)&&void 0!==n?n:new PassRenderer,this._blurMaterial=new ShaderMaterial(null!=e?e:BlurShader),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,a){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=a[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=a[1],this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[2])}}const generateAoSampleKernelInitializer=(e,t)=>{const n=generateAoSamples(e,t);let a="vec4[SAMPLES](";for(let t=0;t<e;t++){const r=n[t];a+=`vec4(${r.x}, ${r.y}, ${r.z}, ${r.w})${t<e-1?",":")"}`}return a},generateAoSamples=(e,t)=>{const n=[];for(let a=0;a<e;a++){const r=a*Math.PI*(3-Math.sqrt(5)),i=.01+a/(e-1)*.99,s=t?Math.sqrt(1-i*i):1-i,o=Math.cos(r)*s,l=Math.sin(r)*s,d=4,c=Math.floor(e/d);let h=1-(Math.floor(a/d)+a%d*c)/e;h=.1+.9*h,n.push(new Vector4(o,l,i,h))}return n},AOShader={name:"AOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,SAMPLE_VECTORS:generateAoSampleKernelInitializer(16,!1),NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",AO_ALGORITHM:4,NV_ALIGNED_SAMPLES:1,SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0,NORMAL_VECTOR_ANTIALIAS:2,DEPTH_BUFFER_ANTIALIAS:1},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new Matrix4},cameraProjectionMatrixInverse:{value:new Matrix4},cameraWorldMatrix:{value:new Matrix4},radius:{value:1},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},bias:{value:.001},scale:{value:1},sceneBoxMin:{value:new Vector3(-1,-1,-1)},sceneBoxMax:{value:new Vector3(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float bias;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 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\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},defaultAORenderPassParameters={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class AORenderPass{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n,a,r){this.needsUpdate=!0,this.parameters={...defaultAORenderPassParameters},this._width=0,this._height=0,this._samples=0,this._gBufferAntiAliasing=!1,this._normalVectorSourceType="floatBufferNormal",this._depthValueSourceType="normalVectorAlpha",this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._passRenderer=new PassRenderer,this._sceneClipBox=new Box3(new Vector3(-1,-1,-1),new Vector3(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._samples=n,this._gBufferAntiAliasing=a,this._normalVectorSourceType=(null==r?void 0:r.normalVectorSourceType)||"floatBufferNormal",this._depthValueSourceType=(null==r?void 0:r.depthValueSourceType)||"normalVectorAlpha",this._modulateRedChannel=(null==r?void 0:r.modulateRedChannel)||!1,(null==r?void 0:r.aoParameters)&&(this.parameters=r.aoParameters),r&&this.updateTextures(r)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new SimplexNoise,n=new Uint8Array(e*e*4);for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=a,s=r;n[4*(a*e+r)]=127.5*(t.noise(i,s)+1),n[4*(a*e+r)+1]=127.5*(t.noise(i+e,s)+1),n[4*(a*e+r)+2]=127.5*(t.noise(i,s+e)+1),n[4*(a*e+r)+3]=127.5*(t.noise(i+e,s+e)+1)}this._noiseTexture=new DataTexture(n,e,e,RGBAFormat,UnsignedByteType),this._noiseTexture.wrapS=RepeatWrapping,this._noiseTexture.wrapT=RepeatWrapping,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;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}_newAoMaterial(){const e=new ShaderMaterial({defines:Object.assign({},AOShader.defines),uniforms:UniformsUtils.clone(AOShader.uniforms),vertexShader:AOShader.vertexShader,fragmentShader:AOShader.fragmentShader,depthTest:!1,depthWrite:!1});return this._modulateRedChannel&&(e.blending=CustomBlending,e.blendEquation=MinEquation,e.blendEquationAlpha=null,e.blendSrc=OneFactor,e.blendSrcAlpha=null,e.blendDst=OneFactor,e.blendDstAlpha=null),e.defines.FRAGMENT_OUTPUT=this._modulateRedChannel?"vec4(ao, 1., 1., 1.)":void 0,e.uniforms.tNoise.value=(e=>{const t=new SimplexNoise,n=Math.floor(5)%2==0?Math.floor(5)+1:Math.floor(5),a=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,a=Array(n).fill(0);let r=Math.floor(t/2),i=t-1;for(let e=1;e<=n;)-1===r&&i===t?(i=t-2,r=0):(i===t&&(i=0),r<0&&(r=t-1)),0===a[r*t+i]?(a[r*t+i]=e++,i++,r--):(i-=2,r++);return a})(n),r=a.length,i=new Uint8Array(4*r);for(let e=0;e<r;++e){const n=a[e],s=2*Math.PI*n/r,o=new Vector3(Math.cos(s),Math.sin(s),0).normalize();i[4*e]=255*(.5*o.x+.5),i[4*e+1]=255*(.5*o.y+.5),i[4*e+2]=127,i[4*e+3]=255*(.5*t.noise(e/5,e%5)+.5)}const s=new DataTexture(i,n,n);return s.wrapS=RepeatWrapping,s.wrapT=RepeatWrapping,s.needsUpdate=!0,s})(),e}_updateShader(e,t){e.defines.PERSPECTIVE_CAMERA=t.isPerspectiveCamera?1:0,e.defines.SAMPLES=this.parameters.samples,e.defines.SAMPLE_VECTORS=generateAoSampleKernelInitializer(this.parameters.samples,0===this.parameters.algorithm),e.defines.NORMAL_VECTOR_TYPE="floatBufferNormal"===this._normalVectorSourceType?2:1,e.defines.DEPTH_SWIZZLING="normalVectorAlpha"===this._depthValueSourceType?"a":"x",e.defines.AO_ALGORITHM=this.parameters.algorithm,e.defines.NV_ALIGNED_SAMPLES=3===this.parameters.algorithm||4===this.parameters.algorithm?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}_updateUniforms(e,t,n){const a=this.parameters.screenSpaceRadius?1:this._sceneScale,r="normalVectorAlpha"===this._depthValueSourceType?this.normalTexture:this.depthTexture;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);const i=t;e.uniforms.cameraNear.value=i.near,e.uniforms.cameraFar.value=i.far,n&&(e.uniforms.radius.value=this.parameters.radius*a,e.uniforms.distanceExponent.value=this.parameters.distanceExponent,e.uniforms.thickness.value=this.parameters.thickness*a,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)))}_getRenderTargets(){return this._renderTarget||(this._renderTarget=new WebGLRenderTarget(this._width,this._height,{samples:this._samples,magFilter:LinearFilter,minFilter:LinearFilter})),this._renderTarget}dispose(){var e,t,n;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._aoMaterial)||void 0===t||t.dispose(),null===(n=this._renderTarget)||void 0===n||n.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._renderTarget)||void 0===n||n.setSize(e,t),this.needsUpdate=!0}updateBounds(e,t){this._sceneClipBox=(new Box3).copy(e),this._sceneScale=null!=t?t:1,this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}clear(e,t){this._passRenderer.clear(e,t||this._getRenderTargets(),16777215,1)}render(e,t,n,a){const r=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._passRenderer.renderScreenSpace(e,r,a||this._getRenderTargets())}}const brightSceneShadingParameters={shadowType:"PCFSoftShadowMap",shAndAoPassParameters:{aoIntensity:.3,shadow:{shadowRadius:.1},ao:{algorithm:0,samples:32,radius:.02,distanceExponent:2,thickness:.1,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,rings:2.89,radius:4,radiusExponent:1.3,depthPhi:2.5,normalPhi:.5}},groundReflectionParameters:{brightness:.5}},_clamp=e=>Math.max(0,Math.min(1,e));class InitData{constructor(e){return this.autoQuality=!1,this.colors=(e=>{const t={},n=Object.keys(e);for(const a of n){const n=e[a];t[a]=isThreeJsColor(n)?n:getColor(n)}return t})(ROOMLE_COLORS),this.unit=null,this.unitStringType=null,this.meshSelection=!0,this.stats=!1,this._measureTraffic=!1,this.disableDebugGUI=!1,this.disableEnvMap=!1,this.envMapUrl="static/default_256-f1c66a2764f88cc0.exr",this.envMapIntensity=1.5,this.envMapRotation=0,this.maxLightSources=-1,this.legacyLight=!1,this.sceneLight=null,this.shading="default",this.restrictionLevel=0,this.highlighting=ROOMLE_HIGHLIGHTNG.SMART,this.dls=null,this.ls=null,this.cameraSpacing=0,this.animateCamera=!0,this.transparentHighlighting=!0,this.transparentBackground=!1,this.configureInRoom=!1,this.discardExternalObjectsWhenLoadingPlan=!1,this.featureFlags={pulsePreview:!1,reDock:!1,advancedDocking:!1,drawPreviewMode:DRAW_PREVIEW_MODES.VECTOR},this.mode=CAMERA_TYPE.CAMERA_3D,this.edit=!1,this.moc=!1,this.callbacksOnlyIfGeometryIsReady=!0,this._creator_=e,new Proxy(this,{get:(e,t)=>"colors"===t?e.colors?new Proxy(e.colors,{get:(e,t)=>getColor(e[t]),set:(t,n,a)=>(e.colors[n]=getColor(a),!0)}):e.colors:e[t]})}setOverrides(e){deepMerge(this,e)}}const BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN=["language","browserLanguage","userLanguage","systemLanguage"],isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);class GlobalInitData{constructor(e){this.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,n=BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN.length;e<n;e++){const n=t[BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN[e]];if(n)return n.substr(0,2)}return"en"})()||"en",this.overrideCountry=null,this.e2e=!1,this.e2eRoomleRendererForImages=!1,this._creator_=e}setOverrides(e){deepMerge(this,e)}}class UiCallback{_setMute(e){setWriteable(this,"_isMute",!0),this._isMute=e,setWriteable(this,"_isMute",!1)}mute(){this._setMute(!0)}unmute(){this._setMute(!1)}constructor(e){return this._isMute=!1,this.cameraStartsMoving=()=>{},this.onReadyForRender=()=>{},this._creator_=e,setDescriptor(this,"_isMute",{enumerable:!1,writable:!1}),setDescriptor(UiCallback.prototype,"_setMute",{enumerable:!1,writable:!1}),setDescriptor(UiCallback.prototype,"mute",{enumerable:!1,writable:!1}),setDescriptor(UiCallback.prototype,"unmute",{enumerable:!1,writable:!1}),new Proxy(this,this)}get(e,t){return this._isMute&&"function"==typeof this[t]&&"on"===t.substr(0,2)?()=>{}:this[t]}}class GlobalCallback extends UiCallback{constructor(){super(...arguments),this.onNetworkRequest=(e,t,n)=>{},this.onKernelMsg=(e,t,n={})=>{},this.onCheckExternalCache=async(e,t)=>Promise.resolve(null),this.onValidateNetworkResponse=(e,t)=>Promise.resolve(!0),this.onApiJsonReceived=async(e,t,n)=>Promise.resolve(void 0),this.onReadyForRender=()=>{}}}const CANVAS_ID={HSC:"rml-configurator",HSP:"rml-hsp",GLB:"rml-glb",RMV:"rml-mv"};class DomHelper{get element(){return this._container}constructor(e){this._creator_=e,this._lifeCycleManager.addEventListener(this)}setDomElement(e){if(!this._container){this._container=document.createElement("div"),this._container.classList.add("rml-threejs-canvas-container"),this._container.setAttribute("ondragover","return false"),this._container.style.position="relative",this._container.style.width="100%",this._container.style.height="100%";const t=document.createElement("style");t.innerText=".rml-threejs-canvas-container canvas{position:absolute;top:0;left:0;right:0;bottom:0;z-index:100; opacity:1;}",this._container.appendChild(t),e.appendChild(this._container)}this._element=e}getClientDimensions(){return new Vector2(this._element.clientWidth,this._element.clientHeight)}_removeDomElement(e){if(!e)return;const t=e.parentElement;t&&t.removeChild(e)}reset(){this._element=null,this._removeDomElement(this._container),this._container=null}pause(){this.reset()}resume(){}destroy(){}}__decorate([inject],DomHelper.prototype,"_lifeCycleManager",void 0);class ScenePluginDefaultImplementation{constructor(e){this._creator_=e}setScene(e){}setUiScene(e){}updateBounds(e){}clearScene(e,t){}moveCameraEnd(e){}moveCameraStart(e){}needsUiScene(){return!1}}class PluginSystem{constructor(e){this._plugins=[],this._creator_=e}async init(e,t,n){this._scene=e,this._uiScene=t,this._cameraPosition=n;const{bananaForScale:a}=this._initData;a&&await import("./banana-for-scale-8479c8a1.js").then(({default:e})=>this._plugins.push(new e(this._creator_))),this._plugins.forEach(e=>e.setScene(this._scene)),this._plugins.forEach(e=>e.setUiScene(this._uiScene)),this._plugins.forEach(e=>e.updateBounds(this._bounds)),this._plugins.forEach(e=>e.moveCameraEnd(this._cameraPosition))}addPlugin(e){this._plugins.push(e),e.setScene(this._scene),e.setUiScene(this._uiScene),e.updateBounds(this._bounds),e.moveCameraEnd(this._cameraPosition)}updateBounds(e){this._bounds=e,this._plugins.forEach(t=>t.updateBounds(e))}clearScene(e,t){this._plugins.forEach(n=>n.clearScene(e,t))}getActivePlugins(){return this._plugins}getPlugin(e){for(let t of this._plugins)if(t instanceof e)return t;return null}moveCameraEnd(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraEnd(e))}moveCameraStart(e){this._cameraPosition=e,this._plugins.forEach(t=>t.moveCameraStart(e))}needsUiScene(){return this._plugins.map(e=>e.needsUiScene()).reduce((e,t)=>e||t,!1)}}__decorate([inject],PluginSystem.prototype,"_initData",void 0);class PromiseQueue{constructor(e,t){this._waitingPromises=[],this._finishPromiseExecutor=[],this._errorCallback=()=>{},Promise.allSettled=Promise.allSettled||(e=>Promise.all(e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e}))))),e&&this.registerCallback(e),t&&(this._errorCallback=t)}push(e){this._waitingPromises.push(e),Promise.all(this._waitingPromises).then(e=>{e.length===this._waitingPromises.length&&(this._callback&&this._callback(e),this._waitingPromises=[])},this._errorCallback)}finished(e=!1){return new Promise((t,n)=>{this._finishPromiseExecutor.push({resolve:t,reject:n});const a=e?"allSettled":"all";Promise[a](this._waitingPromises).then(e=>{if("allSettled"===a){const t=[];e.forEach(({value:e,status:n})=>{"fulfilled"===n&&t.push(e)}),this._resolveAllExecutors(t)}else this._resolveAllExecutors(e)},e=>{this._rejectAllExecutors(e)})})}registerCallback(e){this._callback=e}unregisterCallback(){this._callback=null}_resolveAllExecutors(e){this._finishPromiseExecutor.forEach(({resolve:t})=>t(e)),this._finishPromiseExecutor=[]}_rejectAllExecutors(e){this._finishPromiseExecutor.forEach(({reject:t})=>t(e)),this._finishPromiseExecutor=[]}clear(){const e=this._waitingPromises.length>0;this._waitingPromises=[],e?this._rejectAllExecutors(new Error("Promise queue has been cleared")):this._resolveAllExecutors([])}get length(){return this._waitingPromises.length}}class MeshGenerator{constructor(e){this.materialQueue=new PromiseQueue,this._geometryComponentMaterialCache=new Map,this._maxAnisotropy=1,this._maxTextures=16,this._textureLoader=new TextureLoader,this._configuratorPreviewMaterial=MaterialCreator.createMeshStandardMaterial({color:"#DDDDDD",transparent:!0,opacity:1,roughness:1,envMap:null,polygonOffset:!0,polygonOffsetFactor:-1}),this._creator_=e,this._previewMaterial=MaterialCreator.createMeshStandardMaterial({color:"#DDDDDD",roughness:1,metalness:0})}getGeometry(e){return e&&this._cacheHolder.geometryCache.has(e)?this._cacheHolder.geometryCache.get(e):null}_generateGeometry(e,t,n,a,r){let i;return e&&this._cacheHolder.geometryCache.has(e)?i=this._cacheHolder.geometryCache.get(e):(i=new BufferGeometry,i.setIndex(new Uint32BufferAttribute(n,1)),i.setAttribute("position",new Float32BufferAttribute(t,3)),i.setAttribute("normal",new Float32BufferAttribute(r,3)),i.setAttribute("uv",new Float32BufferAttribute(a,2)),i.scale(.001,.001,.001),i.rotateX(-Math.PI/2),e&&this._cacheHolder.geometryCache.set(e,i)),i}changeMaterialOfMesh(e,t,n){e&&t?(e.material=t,e.material.transparent||0===e.material.opacity||e.material.transmission>0?(e.castShadow=!1,e.receiveShadow=!1):(e.castShadow=!0,e.receiveShadow=!0),e.material.needsUpdate=!0,this._materialLoaded&&this._materialLoaded(t),this._updateMaterialProperties(e,n)):console.warn("could not assign material to mesh",{mesh:e},{material:t})}_updateMaterialProperties(e,t){var n;if(t&&Object.keys(t).length>0&&e.material instanceof MeshStandardMaterial){const a=e.material.clone();a.userData.materialAttributes=t,this._updateStandardMaterialProperties(a,t),a instanceof MeshPhysicalMaterial&&this._updatePhysicalMaterialProperties(a,t),a.transparent=a.opacity<1;const r=e.material;e.material=a,(null===(n=r.userData)||void 0===n?void 0:n.materialAttributes)&&r.dispose()}}_updateStandardMaterialProperties(e,t){t.color&&(e.color=new Color$1(t.color)),t.alpha&&(e.opacity=parseFloat(t.alpha)),t.roughness&&(e.roughness=parseFloat(t.roughness)),t.metallic&&(e.metalness=parseFloat(t.metallic)),t.normalScale&&e.normalScale.setScalar(parseFloat(t.normalScale)),t.alphaCutoff&&(e.alphaTest=parseFloat(t.alphaCutoff)),t.doubleSided&&(e.side=t.doubleSided?DoubleSide:FrontSide),t.occlusion&&(e.aoMapIntensity=parseFloat(t.occlusion)),t.emissiveColor&&(e.emissive=new Color$1(t.emissiveColor)),t.emissiveIntensity&&(e.emissiveIntensity=parseFloat(t.emissiveIntensity))}_updatePhysicalMaterialProperties(e,t){t.transmission&&(e.transmission=parseFloat(t.transmission)),t.specularColor&&(e.specularColor=new Color$1(t.specularColor)),t.specularity&&(e.specularIntensity=parseFloat(t.specularity)),t.clearcoatIntensity&&(e.clearcoat=parseFloat(t.clearcoatIntensity)),t.clearcoatRoughness&&(e.clearcoatRoughness=parseFloat(t.clearcoatRoughness)),t.clearcoatNormalScale&&e.clearcoatNormalScale.setScalar(parseFloat(t.clearcoatNormalScale)),t.sheenColor&&(e.sheenColor=new Color$1(t.sheenColor)),t.sheenIntensity&&(e.sheen=parseFloat(t.sheenIntensity)),t.sheenRoughness&&(e.sheenRoughness=parseFloat(t.sheenRoughness)),t.thicknessFactor&&(e.thickness=parseFloat(t.thicknessFactor)),t.attenuationColor&&(e.attenuationColor=new Color$1(t.attenuationColor)),t.attenuationDistance&&(e.attenuationDistance=parseFloat(t.attenuationDistance))}_createMaterial(e,t,n,a,r){if(this._cacheHolder.materialCache.has(e))t();else if(e.startsWith("benchmarkMaterial")){let i=createBenchmarkMaterial(e),s=createMaterial(i);this._loadBenchmarkTextures(i,s,a,r).then(t,n)}else this._rapiAccess.getMaterial(e).then(e=>{let i=createMaterial(e);this._loadTextures(e,i,a,r).then(t,n)},n)}_loadBenchmarkTextures(e,t,n=1,a=1){return new Promise((r,i)=>{const s=createBenchmarkTexture(e.id);addTexture(this._dataSyncer.requestAsset(s.image,!0),s,t,this._maxAnisotropy,n/(0===s.mmWidth?1:s.mmWidth),a/(0===s.mmHeight?1:s.mmHeight),this._maxTextures).then(()=>{this._cacheHolder.materialCache.set(e.id,t),r()},i)})}_loadTextures(e,t,n=1,a=1){return new Promise((r,i)=>{if(!e.textures||e.textures&&0===e.textures.length)return this._cacheHolder.materialCache.set(e.id,t),r();this._rapiAccess.getTexturesOf(e).then(s=>{let o=[];s.forEach(e=>{o.push(addTexture(this._dataSyncer.requestAsset(e.image,!0),e,t,this._maxAnisotropy,n/(0===e.mmWidth?1:e.mmWidth),a/(0===e.mmHeight?1:e.mmHeight),this._maxTextures))}),Promise.all(o).then(()=>{this._cacheHolder.materialCache.set(e.id,t),r()},i)})})}_loadMaterial(e,t,n){return new Promise((a,r)=>{this._singlePromiseFactory.create(6,e,(a,r)=>this._createMaterial(e,a,r,t,n)).then(()=>{setTimeout(()=>a(this._cacheHolder.materialCache.get(e)),0)},r)})}_assignMaterial(e,t,n){return this._cacheHolder.materialCache.has(t)?(this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t),n),Promise.resolve()):new Promise((a,r)=>{this._loadMaterial(t).then(r=>{e.userData.materialId===t&&this.changeMaterialOfMesh(e,r,n),a()},r)})}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy=e}get maxTextures(){return this._maxTextures}set maxTextures(e){this._maxTextures=e}clear(){this._cacheHolder.clear()}_assignRGB(e,t){return new Promise(n=>{let a,r="rgb"+JSON.stringify(t);this._cacheHolder.materialCache.has(r)?a=this._cacheHolder.materialCache.get(r):(a=MaterialCreator.createMeshPhysicalMaterial({color:t}),this._cacheHolder.materialCache.set(r,a)),this.changeMaterialOfMesh(e,a),setTimeout(()=>n(),0)})}_assignItem(e,t){return new Promise((n,a)=>{if(this._cacheHolder.materialCache.has(t))return this.changeMaterialOfMesh(e,this._cacheHolder.materialCache.get(t)),void n();this._rapiAccess.getItem(t).then(r=>{if(r.topImage)this._textureLoader.load(r.topImage,a=>{a.anisotropy=this._maxAnisotropy,a.wrapS=RepeatWrapping,a.wrapT=RepeatWrapping;let i=new Vector2(1,1);r.width>0&&(i.x=1/r.width),r.depth>0&&(i.y=1/r.depth),a.repeat.set(i.x,i.y);const s=MaterialCreator.createMeshPhysicalMaterial({map:a,roughness:.5,metalness:.1});this._cacheHolder.materialCache.set(t,s),this.changeMaterialOfMesh(e,s),setTimeout(()=>n(),0)});else{const e="can not set material, catalog item top image is not set";console.warn(e),a(e)}},a)})}setMaterialLoadedListener(e){this._materialLoaded=e}removeMaterialLoadedListener(){this._materialLoaded=void 0}_createMesh(e,t,n){if(e&&t){const a=this._getComponentMeshId(e,t);if(this._geometryComponentMaterialCache.has(a)){const e=this._geometryComponentMaterialCache.get(a);if(this._cacheHolder.materialCache.has(e)){const t=this._cacheHolder.materialCache.get(e);return new Mesh(n,t)}}}return new Mesh(n,this._configuratorPreviewMaterial.clone())}_getComponentMeshId(e,t){return e+"_"+t}}__decorate([inject],MeshGenerator.prototype,"_initData",void 0),__decorate([inject],MeshGenerator.prototype,"_rapiAccess",void 0),__decorate([inject],MeshGenerator.prototype,"_dataSyncer",void 0),__decorate([inject],MeshGenerator.prototype,"_singlePromiseFactory",void 0),__decorate([inject],MeshGenerator.prototype,"_cacheHolder",void 0),__decorate([inject],MeshGenerator.prototype,"_plannerMeshGenerator",void 0);class ConfiguratorMeshGenerator extends MeshGenerator{constructor(e){super(e)}generateMesh(e=0,t=null,n,a,r,i,s,o=!1,l){let d;d=o?this._generateGeometry(t,a,r,i,s).clone():this._generateGeometry(t,a,r,i,s);const c=this._createMesh(e,t,d);return c.userData.materialId=n,c.layers.set(4),n&&this.materialQueue.push(this._assignMaterial(c,n,l).then(()=>{e&&t&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n)})),c}setMaterial(e,t,n,a){return this._assignMaterial(e,t,a)}loadMaterial(e,t,n){return super._loadMaterial(e,t,n)}loadTextures(e,t,n,a){return super._loadTextures(e,t,n,a)}}class EventDispatcher{constructor(){this._listeners={},this._disabled=!1}_addEventListener(e,t,n){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push({callback:t,scope:n})}addEventListener(e,t,n){this._addEventListener(e,t,n)}dispatchEvent(e,t){if(!this._listeners[e]||this._disabled)return;const n=this._listeners[e];for(let a=0;a<this._listeners[e].length;a++){const e=n[a];t?e.callback.apply(e.scope,[t]):e.callback.call(e.scope)}}removeEventListener(e,t){const n=this._listeners[e];if(n)for(let e=0,a=n.length;e<a;e++)if(n[e].callback===t)return void n.splice(e,1)}enableEvents(){this._disabled=!1}disableEvents(){this._disabled=!0}}const BROWSER_EVENTS={SCROLL:"scroll",MOUSE_MOVE:"mousemove",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_LEAVE:"mouseleave",MOUSE_ENTER:"mouseenter",MOUSE_WHEEL:"wheel",TOUCH_MOVE:"touchmove",TOUCH_START:"touchstart",TOUCH_END:"touchend",CONTEXT_MENU:"contextmenu",DOUBLE_CLICK:"dblclick"},INPUT_DELAY_TYPE={DRAG:50};class InputEvent{constructor(e,t,n,a,r){this.position=e,this.positionRelative=t,this.type=n,this.rotation=a,this.event=r}}const MIN_MOVE_DISTANCE=5*window.devicePixelRatio,MIN_DOLLY_DISTANCE=4*window.devicePixelRatio;class InputManager extends EventDispatcher{constructor(e){super(),this._elementHit=!1,this._delta=-1,this._state=0,this._pinchDistance=-1,this._rotationAngle=-1,this._lastMouseWheelEvent=null,this._lastTouchEvent=null,this._events=Object.keys(BROWSER_EVENTS).map(e=>BROWSER_EVENTS[e]),this._boundingClientRectInvalid=!0,this._creator_=e,this._downPosition={x:0,y:0},this._downPositionRelative={x:0,y:0},this._boundingClientRect=this._getBoundingClientRect()}enableDragIn(e){this._setState(1),this._dragEnabled=!0,e&&(this._dragMV=this._dragM.bind(this),this._dragEV=this._dragE.bind(this),this._dragTarget=e.currentTarget||e.target,this._delta=-1,this._dragMVName="drag",this._dragEVName="dragend",window.TouchEvent&&e instanceof TouchEvent?(this._dragMVName="touchmove",this._dragEVName="touchend"):e.dataTransfer&&e.dataTransfer.setData&&e.dataTransfer.setData("text/plain"," "),this._firefoxDragPosition={x:0,y:0},document.ondragover=e=>{e=e||window.event,this._firefoxDragPosition.x=e.pageX,this._firefoxDragPosition.y=e.pageY},this._dragTarget.addEventListener(this._dragMVName,this._dragMV,!1),this._dragTarget.addEventListener(this._dragEVName,this._dragEV,!1))}isMouseUp(){return 0===this._state}_dragM(e){let t=e,n=null,a=null;window.TouchEvent&&e instanceof TouchEvent?(n=this._getTouchPosition(t),a=this._getTouchPositionRelative(t)):(n=this._getMousePosition(t),a=this._getMousePositionRelative(t)),n.x>0&&n.y>0&&this._move(n,a)}_dragE(e){var t,n;let a=e;document.ondragover=null,this._firefoxDragPosition=null,null===(t=this._dragTarget)||void 0===t||t.removeEventListener(this._dragMVName,this._dragMV),null===(n=this._dragTarget)||void 0===n||n.removeEventListener(this._dragEVName,this._dragEV),window.TouchEvent&&e instanceof TouchEvent?this._onUp(this._getTouchPosition(a),this._getTouchPositionRelative(a),2):this._onUp(this._getMousePosition(a),this._getMousePositionRelative(a),1)}addEvents(e){this._events.forEach(t=>e.addEventListener(t,this,!1)),null===window||void 0===window||window.addEventListener("scroll",this,!1)}removeEvents(e){this._events.forEach(t=>e.removeEventListener(t,this)),null===window||void 0===window||window.removeEventListener("scroll",this)}_move2(e){if(this._lastTouchEvent&&e.timeStamp-this._lastTouchEvent.timeStamp<16)return;const t=e.touches[0],n=e.touches[1],a=t.pageX-n.pageX,r=t.pageY-n.pageY,i=Math.abs(a)+Math.abs(r);this._pinchDistance>-1&&(i>this._pinchDistance+MIN_DOLLY_DISTANCE?(this._setState(3),this.dispatchEvent(7,new InputEvent(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):i<this._pinchDistance-MIN_DOLLY_DISTANCE?(this._setState(3),this.dispatchEvent(8,new InputEvent(this._getTouchPosition(e),this._getTouchPositionRelative(e)))):i<=this._pinchDistance+MIN_DOLLY_DISTANCE&&i>=this._pinchDistance-MIN_DOLLY_DISTANCE&&3!==this._state&&(this._setState(5),this.dispatchEvent(11,new InputEvent(this._getTouchPosition(e),this._getTouchPositionRelative(e))))),this._pinchDistance=i,this._lastTouchEvent=e}_setState(e){this._state=e}_move(e,t,n,a){void 0===n&&(n=0),void 0===this._dragEnabled&&(this._dragEnabled=!1),1===this._state&&this._canDrag(n)&&(this._delta=this._getDelta(e),(this._delta>MIN_MOVE_DISTANCE||this._elementHit)&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new InputEvent(this._downPosition,this._downPositionRelative)))),2===this._state&&this.dispatchEvent(1,new InputEvent(e,t)),this.dispatchEvent(6,new InputEvent(e,t,n,null,a))}_longClick(e){2!==e&&(this._setState(2),this._longClickTimer&&clearTimeout(this._longClickTimer),this.dispatchEvent(0,new InputEvent(this._downPosition,this._downPositionRelative)),this.dispatchEvent(1,new InputEvent(this._downPosition,this._downPositionRelative))),this.dispatchEvent(14,new InputEvent(this._downPosition,this._downPositionRelative,2))}_onUp(e,t,n){var a,r;this.dispatchEvent(4,new InputEvent(e,t,n)),this._getDelta(e)<=MIN_MOVE_DISTANCE&&this.dispatchEvent(5,new InputEvent(e,t)),2===this._state&&this.dispatchEvent(2,new InputEvent(e,t)),4===this._state&&(this.dispatchEvent(10,new InputEvent(e,t)),this._rotationAngle=-1),3!==this._state&&5!==this._state||(this._pinchDistance=-1),this._lastTouchEvent=null,this._setState(0),null===(a=this._dragTarget)||void 0===a||a.removeEventListener(this._dragMVName,this._dragMV),null===(r=this._dragTarget)||void 0===r||r.removeEventListener(this._dragEVName,this._dragEV),this._dragTarget=null,this._elementHit=!1,this._longClickTimer&&clearTimeout(this._longClickTimer)}_getTouchPosition(e){if(e.touches.length){let{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>1){const a=e.touches[1],r=a.clientX,i=a.clientY;t=(t+r)/2,n=(n+i)/2}return{x:t,y:n}}const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}_getTouchPositionRelative(e){const t=this._getBoundingClientRect(),{clientWidth:n,clientHeight:a}=this._domHelper.element;if(e.touches.length){const{clientX:r,clientY:i}=e.touches[0];return{x:(r-t.left)/n*2-1,y:-(i-t.top)/a*2+1}}const r=e.changedTouches[0];return{x:(r.clientX-t.left)/n*2-1,y:-(r.clientY-t.top)/a*2+1}}_getMousePosition(e){if(0!==e.clientX&&0!==e.clientY)return{x:e.clientX,y:e.clientY};{let{x:t,y:n}=this._getFireFoxMousePosition(e);return{x:t,y:n}}}_getFireFoxMousePosition(e){let{x:t,y:n}=this._domHelper.getClientDimensions();return{x:t-(t+e.offsetX),y:n-(n+e.offsetY)}}_getMousePositionRelative(e){const t=this._getBoundingClientRect();return 0!==e.clientX&&0!==e.clientY?{x:(e.clientX-t.left)/this._domHelper.element.clientWidth*2-1,y:-(e.clientY-t.top)/this._domHelper.element.clientHeight*2+1}:this._firefoxDragPosition&&0!==this._firefoxDragPosition.x&&0!==this._firefoxDragPosition.y?{x:(this._firefoxDragPosition.x-t.left)/this._domHelper.element.clientWidth*2-1,y:-(this._firefoxDragPosition.y-t.top)/this._domHelper.element.clientHeight*2+1}:{x:0,y:0}}_getDelta(e){return Math.abs(this._downPosition.y-e.y)+Math.abs(this._downPosition.x-e.x)}setDragEnabled(e){this._dragEnabled=e}handleEvent(e){switch(e.type){case BROWSER_EVENTS.SCROLL:this._boundingClientRectInvalid=!0;break;case BROWSER_EVENTS.MOUSE_MOVE:this._onMouseMove(e);break;case BROWSER_EVENTS.DOUBLE_CLICK:this._onDoubleClick(e);break;case BROWSER_EVENTS.MOUSE_DOWN:this._onMouseDown(e);break;case BROWSER_EVENTS.MOUSE_UP:this._onMouseUp(e);break;case BROWSER_EVENTS.MOUSE_LEAVE:this._onMouseLeave(e);break;case BROWSER_EVENTS.MOUSE_ENTER:this._onMouseEnter(e);break;case BROWSER_EVENTS.MOUSE_WHEEL:this._onMouseWheel(e);break;case BROWSER_EVENTS.TOUCH_MOVE:this._onTouchMove(e);break;case BROWSER_EVENTS.TOUCH_START:this._onTouchStart(e);break;case BROWSER_EVENTS.TOUCH_END:this._onTouchEnd(e);break;case BROWSER_EVENTS.CONTEXT_MENU:this._onContextMenu(e)}}_onMouseDown(e){if(e.preventDefault(),2===e.detail)return;let{x:t,y:n}=this._getMousePosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getMousePositionRelative(e),this.dispatchEvent(3,new InputEvent({x:t,y:n},this._downPositionRelative,1)),this._setState(1)}_onMouseUp(e){e.preventDefault(),2!==e.detail&&this._onUp(this._getMousePosition(e),this._getMousePositionRelative(e),1)}_onMouseMove(e){e.preventDefault(),this._move(this._getMousePosition(e),this._getMousePositionRelative(e),1,e)}_onDoubleClick(e){e.preventDefault(),this.dispatchEvent(12,new InputEvent(this._getMousePosition(e),this._getMousePositionRelative(e),1))}_onMouseLeave(e){var t;this._delta=-1,(null===(t=e.relatedTarget)||void 0===t?void 0:t.closest('[data-rml-sdk="ignore-mouse-leave"]'))||this._onMouseUp(e)}_onMouseEnter(e){e.preventDefault()}_onMouseWheel(e){if(this._lastMouseWheelEvent&&e.timeStamp-this._lastMouseWheelEvent.timeStamp<40)return e.preventDefault(),void e.stopPropagation();e.deltaY<0?this.dispatchEvent(7,new InputEvent(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)):this.dispatchEvent(8,new InputEvent(this._getMousePosition(e),this._getMousePositionRelative(e),1,0,e)),this._lastMouseWheelEvent=e}_onTouchMove(e){if(e.preventDefault(),!this._dragTarget)if(1===e.touches.length)this._move(this._getTouchPosition(e),this._getTouchPositionRelative(e),2);else if(2===e.touches.length)if(this._elementHit||4===this._state){const a=e.touches[0],r=e.touches[1],i=function(e){let t=toDegrees(e);return t<0&&(t=180+(180+t)),t}((t={x:a.pageX,y:a.pageY},n={x:r.pageX,y:r.pageY},Math.atan2(n.y-t.y,n.x-t.x)));this._rotationAngle<0&&(this._rotationAngle=i);const s=i-this._rotationAngle;this._rotationAngle=i,this.dispatchEvent(9,new InputEvent(this._getTouchPosition(e),this._getTouchPositionRelative(e),2,toRadiant(s))),this._setState(4)}else this._move2(e);var t,n}_onTouchStart(e){if(e.preventDefault(),1===e.touches.length){let{x:t,y:n}=this._getTouchPosition(e);this._downPosition={x:t,y:n},this._downPositionRelative=this._getTouchPositionRelative(e),this.dispatchEvent(3,new InputEvent({x:t,y:n},this._downPositionRelative,2)),this._setState(1),this._longClickTimer=window.setTimeout(this._longClick.bind(this,2),350)}else 2===e.touches.length&&(1!==this._state&&2!==this._state||this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2))}_onTouchEnd(e){e.preventDefault(),this.dispatchEvent(13,new InputEvent(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)),this._onUp(this._getTouchPosition(e),this._getTouchPositionRelative(e),2)}_onContextMenu(e){e.preventDefault()}_canDrag(e){return this._dragEnabled}onElementHit(){this._elementHit=!0}_getBoundingClientRect(){return this._boundingClientRectInvalid&&(this._boundingClientRect=this._domHelper.element.getBoundingClientRect(),this._boundingClientRectInvalid=!1),this._boundingClientRect}updateSize(){this._boundingClientRectInvalid=!0}}__decorate([inject],InputManager.prototype,"_domHelper",void 0);class SelectionHandlerEvent{constructor(e){const{component:t,resetCamera:n,consecutive:a}=e;this.component=t,this.resetCamera=void 0===n||n,this.consecutive=void 0===a||a}}class FontLoader extends Loader{constructor(e){super(e)}load(e,t,n,a){const r=this,i=new FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(function(e){const n=r.parse(JSON.parse(e));t&&t(n)}),n,a)}parse(e){return new Font(e)}}class Font{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],a=function(e,t,n){const a=Array.from(e),r=t/n.resolution,i=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,s=[];let o=0,l=0;for(let e=0;e<a.length;e++){const t=a[e];if("\n"===t)o=0,l-=i;else{const e=createPath(t,r,o,l,n);o+=e.offsetX,s.push(e.path)}}return s}(e,t,this.data);for(let e=0,t=a.length;e<t;e++)n.push(...a[e].toShapes());return n}}function createPath(e,t,n,a,r){const i=r.glyphs[e]||r.glyphs["?"];if(!i)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+r.familyName+".");const s=new ShapePath;let o,l,d,c,h,u,p,m;if(i.o){const e=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let r=0,i=e.length;r<i;)switch(e[r++]){case"m":o=e[r++]*t+n,l=e[r++]*t+a,s.moveTo(o,l);break;case"l":o=e[r++]*t+n,l=e[r++]*t+a,s.lineTo(o,l);break;case"q":d=e[r++]*t+n,c=e[r++]*t+a,h=e[r++]*t+n,u=e[r++]*t+a,s.quadraticCurveTo(h,u,d,c);break;case"b":d=e[r++]*t+n,c=e[r++]*t+a,h=e[r++]*t+n,u=e[r++]*t+a,p=e[r++]*t+n,m=e[r++]*t+a,s.bezierCurveTo(h,u,p,m,d,c)}}return{offsetX:i.ha*t,path:s}}const PROMISE_CALLBACKS=new Map,RESOURCES=new Map;class AsyncDependencyLoader{static loadFont(e){if(RESOURCES.has(e))return new Promise(t=>{t(RESOURCES.get(e))});if(PROMISE_CALLBACKS.has(e))return new Promise((t,n)=>{PROMISE_CALLBACKS.get(e).push({resolve:t,reject:n})});let t=new FontLoader;return new Promise((n,a)=>{PROMISE_CALLBACKS.set(e,[{resolve:n,reject:a}]),t.load(getAssetPath()+e,t=>{RESOURCES.set(e,t),AsyncDependencyLoader._resolveAll(e,t)})})}static _resolveAll(e,t){PROMISE_CALLBACKS.has(e)&&PROMISE_CALLBACKS.get(e).forEach(e=>e.resolve(t)),PROMISE_CALLBACKS.delete(e)}}class ComponentDimensioningHelper{constructor(e){this._activeComponents=[],this._componentDimensioningsExist=new Map,this._creator_=e}setCamera(e){this._camera=e}add(e){if(this._componentDimensioningsExist.has(e.runtimeId)&&!this._componentDimensioningsExist.get(e.runtimeId))return!1;const t=this._plannerKernelAccess.kernelInstance.getComponent(e.runtimeId),n=t.dimensionings;if(this._componentDimensioningsExist.set(e.runtimeId,n.length>0),!n||0===n.length||this._camera.position.z<0)return!1;const a=kernelBoxToThreeBox(t.boxForMeasurement),r={x:this._camera.position.x,y:this._camera.position.z};return import("./component-dimensioning-aa4cd8f4.js").then(t=>{AsyncDependencyLoader.loadFont("static/lato_regular-16ba9d6f2866947d.json").then(i=>{n.forEach(n=>{var s;e.add(new t.default(((s=n).from=s.from/1e3,s.to=s.to/1e3,1===s.type.value?(s.type={value:2},s.from*=-1,s.to*=-1):2===s.type.value&&(s.type={value:1}),s),a,i,r))})})}),this._activeComponents.push(e),!0}remove(e,t=!0){return new Promise(n=>{import("./component-dimensioning-aa4cd8f4.js").then(a=>{let r=[];e.children.forEach(e=>{e instanceof a.default&&r.push(e)}),r.forEach(t=>{e.remove(t),dispose(t)}),t&&removeItem(this._activeComponents,e),n()})})}hasComponentDimensions(){return this._activeComponents.length>0}async reset(){for(const e of this._activeComponents)await this.remove(e);this._activeComponents=[]}invalidateDimensioningsCache(e){e?this._componentDimensioningsExist.delete(e):this._componentDimensioningsExist.clear()}}__decorate([inject],ComponentDimensioningHelper.prototype,"_plannerKernelAccess",void 0);const CONFIGURATION_TYPE={STATIC:0,CORE:1,EXTERNAL:2},CORE_CHILD_ENTITY_MODE={OFF:0,GROUND_COMPONENTS:1,ALL_COMPONENTS:2},toConstructionMeasurementTransferable=e=>transformMeasurement(e),transformMeasurement=e=>({...e,fromPosition3d:threeVectorToTransferableXYZ(e.fromPosition3d),toPosition3d:threeVectorToTransferableXYZ(e.toPosition3d),textPosition3d:threeVectorToTransferableXYZ(e.textPosition3d),fromPosition2d:threeVectorToTransferableXY(e.fromPosition2d),toPosition2d:threeVectorToTransferableXY(e.toPosition2d),textPosition2d:threeVectorToTransferableXY(e.textPosition2d),textDirection:threeVectorToTransferableXYZ(e.textDirection),textRotation:e.textRotation,length:e.length}),calculateWallPlanPoints=(e,t)=>{let n,a;0===t.value?(n=convertToTHREE(e.getCornerFromLeft()),a=convertToTHREE(e.getCornerToLeft())):1===t.value&&(n=convertToTHREE(e.getCornerFromRight()),a=convertToTHREE(e.getCornerToRight()));const r=n.clone().add(a).divideScalar(2);return{from:n,to:a,middle:r}},getConstructionElemMiddlePoints=e=>{const t=convertToTHREE(e.getCornerFromLeft()),n=convertToTHREE(e.getCornerToLeft()),a=convertToTHREE(e.getCornerFromRight()),r=convertToTHREE(e.getCornerToRight());return{centerFrom:t.clone().add(a).divideScalar(2),centerTo:n.clone().add(r).divideScalar(2)}},getTextDirectionAndRotation=e=>{const t=e.clone();e.dot(new Vector3(1,0,0))<0&&t.multiplyScalar(-1);const n=Math.atan2(t.z,t.x);let a=n;return n>=Math.PI/2&&n<3*Math.PI/2&&(a+=Math.PI),{textDirection:t,textRotation:a}},calculateShiftingFactor=(e,t,n,a=23)=>{const r=t/n,i=r>1.77;let s=1080,o=a;return r<1?o="0.7"===r.toFixed(1)?30:20:i&&(s=1188,o=2===Math.round(r)?25:30),o/n*(n/(e*s))},convertToStandardArray=e=>{const t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));return t},calculateConstructionElementMeasurements=(e,t,n,a)=>{let r;if(!e.getPlanElement()||!("getAttachedWall"in e.getPlanElement())||!(r=e.getPlanElement().getAttachedWall()))return null;const i=r.getPreferredSide(),s=e.getPlanElement().getPreferredSide(),o=convertToTHREE(r.getCenter()),{from:l,to:d,middle:c}=calculateWallPlanPoints(r,i);let{from:h,to:u}=calculateWallPlanPoints(e.getPlanElement(),s);l.y=0,d.y=0,h.y=0,u.y=0;const{wallFromCenterPoint:p,wallToCenterPoint:m}=getWallCenterPoints(e,l,h,d,u),{centerFrom:g,centerTo:_}=getConstructionElemMiddlePoints(e.getPlanElement()),f=u.clone().sub(h),v=f.clone().cross(new Vector3(0,1,0)).normalize();v.clone().dot(c.clone().sub(o))<0&&v.multiplyScalar(-1);const{textDirection:S,textRotation:w}=getTextDirectionAndRotation(f),b=calculateShiftingFactor(t,n,a),C=v.clone().multiplyScalar(b),y=new Vector3(0,0,0),M={fromPosition2d:y,toPosition2d:y,textPosition2d:y};return{leftMeasurement:{fromPosition3d:h,toPosition3d:l,textDirection:v,textRotation:w,textPosition3d:g.clone().add(p).divideScalar(2),length:1e3*h.distanceTo(l),...M},rightMeasurement:{fromPosition3d:u,toPosition3d:d,textDirection:v,textRotation:w,textPosition3d:_.clone().add(m).divideScalar(2),length:1e3*u.distanceTo(d),...M},elementRange:{fromPosition3d:h,toPosition3d:u,textDirection:S,textRotation:w,textPosition3d:h.clone().add(u).divideScalar(2).add(C),length:1e3*f.length(),...M}}},getWallCenterPoints=(e,t,n,a,r)=>{const i=t.clone().sub(n),s=a.clone().sub(r),o=i.length(),l=s.length(),d=i.clone().normalize().multiplyScalar(o),c=s.clone().normalize().multiplyScalar(l),{centerFrom:h,centerTo:u}=getConstructionElemMiddlePoints(e.getPlanElement());return{wallFromCenterPoint:h.clone().add(d),wallToCenterPoint:u.clone().add(c)}};class Waiter{constructor(){this._promiseExecutors=[]}create(){return new Promise((e,t)=>{this._promiseExecutors.push({resolve:e,reject:t})})}resolve(e){return new Promise(t=>{this._promiseExecutors.forEach(t=>t.resolve(e)),this._promiseExecutors=[],t(e)})}reject(e){return new Promise((t,n)=>{this._promiseExecutors.forEach(t=>t.reject(e)),this._promiseExecutors=[],n(e)})}}class PlanElementViewModel extends class{constructor(e){this._coreReference=e.clone()}clearReference(){this._coreReference.delete(),this._coreReference=null}getKernelObject(){return this._coreReference}}{constructor(e){super(e),this._objectWaiter=new Waiter,this._topView=!1,this.isActivatedDuringDragIn=!1;const t=convertToTHREE(e.getCenter());this._container=new Object3D,this._container.visible=!e.hidden,this._container.position.copy(t),this._boundingBox=this._generateBoundingBox(),fadeIn(this._boundingBox),this._container.add(this._boundingBox),2!==this.getPlanElement().getType().value&&(this._object=new Object3D,this._container.add(this._object))}getSize(){return this._object?(new Box3).setFromObject(this._object).getSize(new Vector3):new Vector3}update(){this._container.visible=!this.getPlanElement().hidden,this._container.position.copy(convertToTHREE(this.getPlanElement().getMeshCenter())),this._boundingBox&&this._updateBoundingBox()}_updateBoundingBox(){const e=this.getSize();this._boundingBox.geometry=new BoxGeometry(e.x,e.y,e.z),this._setPositionOfBoundingBox(e,this._boundingBox)}getPosition(){return this._container.position}getRotation(){return this._container.rotation.y}getBounds(){let e;const t=this.getPlanElement();return(null==t?void 0:t.boxForMeasurement)?(e=kernelBoxToThreeBox(t.boxForMeasurement),e.applyMatrix4(this.getContainer().matrix)):(e=new Box3,e.setFromObject(this._container)),e}getBoundingBox(){return this._boundingBox}getPlanElement(){return this._coreReference}setObject(e){this._object=e,this._objectWaiter.resolve(e)}getObject(){return this._object}async getObjectAsync(){return this._object?Promise.resolve(this._object):this._objectWaiter.create()}addMesh(e){this._object.add(e),this.hidePreviewBox()}getMesh(e){if(!this._object||0===this._object.children.length)return null;const t=getMaterialId(e,this.getPlanElement().getType());return this._object.children.find(e=>e.userData.material===t)}getContainer(){return this._container}getId(){var e,t;return null!==(t=null===(e=this.getPlanElement())||void 0===e?void 0:e.getId())&&void 0!==t?t:0}clear(){dispose(this._container),this._selectionMesh&&dispose(this._selectionMesh)}remove(){var e;null===(e=this._container.parent)||void 0===e||e.remove(this._container),this.clear()}hidePreviewBox(){var e;this._container&&this._boundingBox&&(this._boundingBox.material=(null===(e=window.__RML__DEBUG__)||void 0===e?void 0:e.boundingBox)?getDebugBoundingBoxMaterial():(boundingBoxMaterial||(boundingBoxMaterial=new MeshBasicMaterial,boundingBoxMaterial.visible=!1),boundingBoxMaterial))}_generateBoundingBox(){var e;const t=this.getSize(),n=new BoxGeometry(t.x,t.y,t.z);let a=new Color$1("#DDDDDD");const r=this.getPlanElement().customColor;r>0&&(a=getColorFromInt(r));let i=(null===(e=window.__RML__DEBUG__)||void 0===e?void 0:e.boundingBox)?getDebugBoundingBoxMaterial():MaterialCreator.createMeshStandardMaterial({color:a,opacity:1,transparent:!0}),s=new Mesh(n,i);return s.name="bounding box",s.castShadow=!1,s.receiveShadow=!1,s.layers.set(6),this._setPositionOfBoundingBox(t,s),s}_setPositionOfBoundingBox(e,t){const n=this.getPlanElement(),a=convertToTHREE(n.getMeshOffsetRelativeToObject());t.position.set(-a.x,e.y/2-a.y,-a.z)}select(){this._isSelected=!0,this._selectionMesh&&this._container.add(this._selectionMesh)}deselect(){this._isSelected=!1,this._selectionMesh&&this._container.remove(this._selectionMesh)}hoverOn(){}hoverOff(){}setTopView(e){this._topView=e}toJSON(){return{rootElementId:this.getPlanElement().getId()}}getName(){return this._container.name}}const objectToWallDimensionToTransferable=e=>({...transformMeasurement(e)});class PlanObjectViewModel extends PlanElementViewModel{constructor(e){super(e),this._initDone=!1,this._initFailed=null,this._initWaiter=new Waiter,this._container.rotation.y=e.rotation}finishInit(){return this._initDone=!0,this._initFailed=null,this._initWaiter.resolve()}failInit(e){return this._initFailed=e,this._initDone=!1,this._initWaiter.reject(this._initFailed)}isInitDone(){return this._initDone?Promise.resolve():this._initFailed?Promise.reject(this._initFailed):this._initWaiter.create()}getPlanObject(){return this.getPlanElement()}getSize(){return convertToThreeDimensions(this.getPlanObject().size)}getObjectMeasurements(e,t,n){const a=this.getPlanObject(),r=a.getRectangle(),{referencePoints:i,size:s,center:o}=r;if(!i)return null;const l=(a,r,i=!1,s=0)=>{const l=convertToTHREE(a),d=convertToTHREE(r);let c=l.clone().add(d).divideScalar(2);const h=l.clone().sub(d),{textDirection:u,textRotation:p}=getTextDirectionAndRotation(h);if(i){const a=h.clone().cross(new Vector3(0,1,0)).normalize(),r=c.clone().sub(convertToTHREE(o));a.dot(r)<0&&a.multiplyScalar(-1);const i=calculateShiftingFactor(e,t,n),s=a.multiplyScalar(i);c.add(s)}return{fromPosition3d:l,toPosition3d:d,textPosition3d:c,textDirection:u,textRotation:p,length:s}},d=[{from:i.topLeft,to:i.topRight},{from:i.topRight,to:i.bottomRight},{from:i.bottomRight,to:i.bottomLeft},{from:i.bottomLeft,to:i.topLeft}].map(e=>l(e.from,e.to)),c=[{from:i.topLeft,to:i.topRight,length:s.x},{from:i.topRight,to:i.bottomRight,length:s.y}].map(e=>{const t=l(e.from,e.to,!0);return t.length=e.length,t}),h=convertToStandardArray(a.getWallDistances());return{rectMeasurements:d,objectMeasurements:c,objectToWallsMeasurements:h?h.map(e=>({...l(e.startPoint,e.endPoint,!1,e.length),id:hashCode(e.angle+"_"+e.length)})):null}}update(){super.update(),this._container.rotation.y=this.getPlanObject().rotation}}class ConfiguratorPlanObjectViewModel extends PlanObjectViewModel{constructor(e){super(e),this._container.name="Configurable "+this._container.name}addRootComponent(e){this.setObject(e),e.isChildPlanObject=!0,this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId,this._container.add(this.getObject())}addChildEntityComponent(e){this.setObject(e),e.isChildPlanObject=!0,this._rootComponentId=e.id,this._rootComponentRuntimeId=e.runtimeId}getConfigurationRuntimeId(){var e,t;return null!==(t=null===(e=this.getPlanObject())||void 0===e?void 0:e.getConfigurationRuntimeId())&&void 0!==t?t:-1}getRootComponentId(){return this._rootComponentId}getRootComponentRuntimeId(){return this._rootComponentRuntimeId}finishConstruction(){return this.finishInit()}failConstruction(){return this.failInit(new Error("Construction of configuration failed"))}toJSON(){return{...super.toJSON(),rootComponentRuntimeId:this._rootComponentRuntimeId}}}let settings=JSON.parse(JSON.stringify({isProduction:!0,isUnitTesting:!1,environment:"production",detailEnvironment:"development",features:{},APP:{RAPI:{server:"https://www.roomle.com/api/v2",localReverseProxy:"https://www.roomle.com/api/v2",liveServer:"https://www.roomle.com/api/v2",testServer:"https://www.test.roomle.com/api/v2",headers:{apiKey:"roomle_portal_v2",currentTenant:9,locale:"en",language:"en",device:1,token:"anonymous",platform:"web"},itemHeaders:{assetRevision:"glb",assetFileFormat:"glb"}},SHORTENER_URL:"http://rml.co/"},environments:{PRODUCTION:"production",DEVELOPMENT:"development",TEST:"test",TEST_SERVER:"test_server",ALPHA:"alpha"}}));settings.isUnitTesting=!1,"undefined"!=typeof module&&module.exports||(window.IS_DEBUG=!0);const configs={ENV_DEBUG:function(e=!1){if(e){let e=JSON.parse(JSON.stringify(settings));const t={...e.APP,SHORTENER_URL:"http://localhost:4747/?isItem=false&id="},n={...e.features};return{...e,isProduction:!1,APP:t,features:n}}}(),ENV_PRODUCTION:JSON.parse(JSON.stringify(settings))};var Env=configs[configs.ENV_DEBUG&&"development"===configs.ENV_DEBUG.environment?"ENV_DEBUG":"ENV_PRODUCTION"];class StaticPlanObjectViewModel extends PlanObjectViewModel{constructor(e){super(e),this._originalSize=new Vector3,this._container.name="Static "+this._container.name}setRapiItem(e){return this._rapiItem?this.isInitDone():this._addStaticItem(e)}async _addStaticItem(e){this._rapiItem=e;let t=this.getPlanObject();if(this._glbUrl=getGlbUrl(e),!this._glbUrl)return Promise.reject("No glb url found");let n=e.scaleable?convertToThreeDimensions(t.size):void 0,a=new Vector3(1,1,1);t.flipX&&(a.x*=-1),t.flipY&&(a.z*=-1);try{const r=await this._staticItemLoader.loadGLB(this._glbUrl,void 0,void 0,n,a,t.customColor,e.colorable);this._originalSize.copy(r.boundingBox.getSize(new Vector3)),r.scene.name=e.label,this.setObject(r.scene),((e,t)=>{let n=(new Box3).setFromObject(e),a=n.getSize(new Vector3),r=Math.min(a.x,a.y,a.z),i=!0;r>5&&(console.warn("GLB seems to be too big ("+r+")",t),i=!1),n.min.y<-.01&&(console.warn("GLB seems to be under the floor ("+n.min.y+"): ",t),i=!1)})(r.scene,this._glbUrl),fadeIn(r.scene),this._container.add(this.getObject()),this.hidePreviewBox(),await this.finishInit()}catch(e){await this.failInit(e)}}getRapiItem(){return this._rapiItem}needsRapiItem(){return!this._glbUrl}getGLBUrl(){return this._glbUrl}update(){super.update();const e=convertToThreeDimensions(this.getPlanElement().size),t=this.getObject();if(!t)return;if(e){const{x:n,y:a,z:r}=this._originalSize;let i=new Vector3(e.x/n,e.y/a,e.z/r);t.scale.copy(i)}this.getPlanElement().flipX&&(t.scale.x*=-1),this.getPlanElement().flipY&&(t.scale.z*=-1);const n=this.getPlanElement().customColor;t.traverse(e=>{if(e instanceof Mesh&&e.material instanceof MeshStandardMaterial){const t=e.material;if(this._rapiItem.colorable&&n&&n>0){let e=new Color$1(n);t.color=e.copySRGBToLinear(e)}t.needsUpdate=!0}})}}__decorate([inject],StaticPlanObjectViewModel.prototype,"_staticItemLoader",void 0);class DraggableNode extends Object3D{constructor(e,t=.05){super(),this.name=e,this._sphereSize=t,this._innerRingRadius=this._sphereSize,this._outerRingRadius=this._innerRingRadius+.02,this._initNodeMesh()}_initNodeMesh(){const e=new SphereGeometry(this._sphereSize,32),t=new MeshBasicMaterial({color:16777215});this._sphere=new Mesh(e,t),this._sphere.name="Sphere mesh";const n=new RingGeometry(this._innerRingRadius,this._outerRingRadius,32),a=new MeshBasicMaterial({color:0,side:DoubleSide});this._innerRingMesh=new Mesh(n,a),this._innerRingMesh.name="Inner ring mesh",this._innerRingMesh.rotation.set(Math.PI/2,0,0);const r=new RingGeometry(this._outerRingRadius,this._outerRingRadius+.01,32),i=new MeshBasicMaterial({color:16777215,side:DoubleSide});this._outerRingMesh=new Mesh(r,i),this._outerRingMesh.name="Outer ring mesh",this._outerRingMesh.rotation.set(Math.PI/2,0,0),this.add(this._sphere),this.add(this._innerRingMesh),this.add(this._outerRingMesh)}getSize(){return(new Box3).setFromObject(this).getSize(new Vector3)}hoverOn(){this._sphere.geometry=new SphereGeometry(this._sphereSize+.02,32),this._innerRingMesh.geometry=new RingGeometry(this._innerRingRadius+.02,this._outerRingRadius+.02,32),this._outerRingMesh.geometry=new RingGeometry(this._outerRingRadius+.02,this._outerRingRadius+.01+.02,32)}hoverOff(){this._sphere.geometry=new SphereGeometry(this._sphereSize,32),this._innerRingMesh.geometry=new RingGeometry(this._innerRingRadius,this._outerRingRadius,32),this._outerRingMesh.geometry=new RingGeometry(this._outerRingRadius,this._outerRingRadius+.01,32)}select(e){this._innerRingMesh.material=new MeshBasicMaterial({color:e,side:DoubleSide})}deselect(e){this._innerRingMesh.material=new MeshBasicMaterial({color:e,side:DoubleSide})}}const wallDimensionToTransferable=e=>({...transformMeasurement(e),id:e.id,isCurrentlyDrawn:e.isCurrentlyDrawn,fromWithoutPadding:threeVectorToTransferableXYZ(e.fromWithoutPadding),toWithoutPadding:threeVectorToTransferableXYZ(e.toWithoutPadding),lengthFormatted:e.lengthFormatted});let WALL_TOP_VIEW_MATERIAL;const getTopViewMaterial=()=>(WALL_TOP_VIEW_MATERIAL||(WALL_TOP_VIEW_MATERIAL=MaterialCreator.createMeshPhysicalMaterial({color:0})),WALL_TOP_VIEW_MATERIAL);class WallPlanElementViewModel extends PlanElementViewModel{constructor(e){super(e),this._container.name="Wall Plan Element";const t=this.getPlanElement();0!==t.height&&0!==t.thickness||this.hidePreviewBox(),t.thickness>=0&&t.thickness<=10&&this._addThinLineForInvisibleWall()}get isSelected(){return this._isSelected}getWallDimension(e,t,n){const a=this.getPlanElement(),r=convertToTHREE(a.getCenter()),i=a.getPreferredSide(),{from:s,to:o,middle:l}=calculateWallPlanPoints(a,i),d=s.clone().sub(o),c=d.clone().cross(new Vector3(0,1,0)).normalize();c.clone().dot(l.clone().sub(r))<0&&c.multiplyScalar(-1);const h=parseFloat(calculateShiftingFactor(e,t,n).toFixed(3)),{textDirection:u,textRotation:p}=getTextDirectionAndRotation(d),m=c.clone().multiplyScalar(h),g=s.clone().add(m),_=o.clone().add(m),f=c.clone().multiplyScalar(h/2),v=s.clone().add(f),S=o.clone().add(f),w=g.clone().add(_).divideScalar(2);return{id:a.getId(),fromPosition3d:g,toPosition3d:_,textPosition3d:w,textDirection:u,textRotation:p,length:a.getLength(i),fromWithoutPadding:v,toWithoutPadding:S}}addMesh(e){e.traverse(e=>{this._setMaterial(e)}),e.layers.set(9),this._setBoundingBoxValues(this._boundingBox),super.addMesh(e)}show(){var e,t;this.getContainer().visible=!0,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.set(9)}),null===(t=this.getBoundingBox())||void 0===t||t.layers.set(6)}hide(){var e,t;this.getContainer().visible=!1,null===(e=this.getObject())||void 0===e||e.traverse(e=>{e.layers.disableAll()}),null===(t=this.getBoundingBox())||void 0===t||t.layers.disableAll()}_enableTopView(){this._container.traverse(e=>{this._setTopMaterial(e)})}_setTopMaterial(e){e instanceof Line&&e===this._lineForInvisibleWall?e.material.opacity=.8:e instanceof Mesh&&!e.userData.originalMaterial&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial=e.material,e.material=getTopViewMaterial())}_disableTopView(){this._container.traverse(e=>{e instanceof Line&&e===this._lineForInvisibleWall?e.material.opacity=0:e instanceof Mesh&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial)})}setTopView(e){super.setTopView(e),e?this._enableTopView():this._disableTopView(),this._updateBoundingBox()}getKernelObject(){return super.getKernelObject()}_setMaterial(e){e instanceof Mesh&&e.material&&e!==this._boundingBox&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),this._topView&&this._isSelected?e.material=new MeshBasicMaterial({color:10526880,side:DoubleSide}):this._topView&&!this._isSelected?e.material=getTopViewMaterial():(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial))}select(){super.select(),this._container.traverse(e=>{this._setMaterial(e)})}deselect(){super.deselect(),this._container.traverse(e=>{this._setMaterial(e)})}_updateBoundingBox(){this._setBoundingBoxValues(this._boundingBox)}_setBoundingBoxValues(e){const t=this.getPlanElement(),n=convertToTHREE(t.getFrom().getCenter());n.y=0;const a=convertToTHREE(t.getTo().getCenter());a.y=0;const r=this._topView?Math.max(t.thickness/1e3+.4,.6):Math.max(t.thickness/1e3,.01),i=n.clone().sub(a),s=i.length()-.14,o=Math.atan2(-i.z,i.x);let l=this._topView?.01:t.height/1e3;e.geometry=new BoxGeometry(s,l,r),e.rotation.y=o,e.position.y=l/2,e.layers.set(9)}_generateBoundingBox(){let e=new Color$1("#DDDDDD");const t=this.getPlanElement().customColor;t>0&&(e=getColorFromInt(t));let n=MaterialCreator.createMeshStandardMaterial({color:e,opacity:1,transparent:!0}),a=new Mesh(new BoxGeometry(0,0,0),n);return a.name="bounding box",a.castShadow=!1,a.receiveShadow=!1,this._setBoundingBoxValues(a),a}_computeLineVertices(){const e=this.getWallDimension(1/0,1,1),t=e.fromWithoutPadding.clone(),n=e.toWithoutPadding.clone(),a=new Vector3;return this._container.getWorldPosition(a),t.sub(a),n.sub(a),new Float32Array([t.x,t.y,t.z,n.x,n.y,n.z])}_createLineForInvisibleWall(e){const t=new BufferGeometry;t.setAttribute("position",new Float32BufferAttribute(e,3));const n=new LineBasicMaterial({color:0,transparent:!0,opacity:0});this._lineForInvisibleWall=new Line(t,n),this._container.add(this._lineForInvisibleWall)}_updateLineGeometry(e){if(!this._lineForInvisibleWall)return void console.warn("Attempted to update a line that does not exist.");const t=this._lineForInvisibleWall.geometry;t.setAttribute("position",new Float32BufferAttribute(e,3)),t.attributes.position.needsUpdate=!0}_addThinLineForInvisibleWall(){if(this._lineForInvisibleWall)return;const e=this._computeLineVertices();this._createLineForInvisibleWall(e)}_updateThinLine(){const e=this._computeLineVertices();this._updateLineGeometry(e)}_removeThinLineForInvisibleWall(){this._lineForInvisibleWall&&(this._container.remove(this._lineForInvisibleWall),this._lineForInvisibleWall.geometry.dispose(),this._lineForInvisibleWall=null)}update(){super.update();const e=this.getPlanElement();e.thickness>=0&&e.thickness<=10?this._addThinLineForInvisibleWall():this._removeThinLineForInvisibleWall(),this._updateThinLine()}}const toFloorAreaDataTransferable=e=>({area:e.area,formattedArea:e.formattedArea||null,textPosition3d:threeVectorToTransferableXYZ(e.textPosition3d),textPosition2d:e.textPosition2d?threeVectorToTransferableXYZ(e.textPosition2d):{x:0,y:0,z:0},isTextVisible:e.isTextVisible});class FloorPlanElementViewModel extends PlanElementViewModel{constructor(e){super(e),this._container.name="Floor Plan Element"}addMesh(e){this.getObject().clear(),super.addMesh(e),e.layers.set(9),e.castShadow=!1,e.position.y=-.001}getFloorData(e){const t=this.getKernelObject(),n=(new Box3).setFromObject(this._container),a=convertToTHREE(t.getLabelPosition()),r=this.calculateTextVisibility(n,e);return{area:t.area,formattedArea:"",textPosition3d:a,textPosition2d:new Vector3,isTextVisible:r}}calculateTextVisibility(e,t){const n=new Vector3;return e.getSize(n),n.length()*t>.2}}class CeilingPlanElementViewModel extends PlanElementViewModel{constructor(e){super(e),this._container.name="Ceiling Plan Element"}addMesh(e){super.addMesh(e),e.castShadow=!1;const t=(new Box3).setFromObject(this.getObject()).getSize(new Vector3);this._boundingBox.geometry=new BoxGeometry(t.x,.01,t.z)}}const META_INFO=new Map;class Benchmark{static start(e){if(!window.performance||!window.performance.getEntriesByName)return"";let t=window.performance.getEntriesByName(e).length++,n="";t<100&&(n="0"),t<10&&(n="0"+n);const a=t>0?e+"_"+n+t:e,r=a+"_start";return window.performance.mark(r),a}static addMeta(e,t){const n=Benchmark.getMeta(e);META_INFO.set(e,Object.assign(n,t))}static getMeta(e){return META_INFO.get(e)||{}}static end(e){}static getMeasure(e){return[]}static showBenchmarks(e){const t=window.performance.getEntriesByType("measure");t.sort((function(e,t){return e.startTime-t.startTime}));const n=[];for(let a=0,r=t.length;a<r;a++){const r=t[a];e&&-1===r.name.indexOf(e)||n.push({Start:parseFloat(r.startTime.toFixed(2)),Name:r.name,Duration:parseFloat(r.duration.toFixed(2))})}console.table(n)}}class AppContext{static init(e={}){const{kernelInstance:t,kernelContainer:n,planObjectId:a}=e;AppContext.kernelInstance=t,AppContext.kernelContainer=n,AppContext.planObjectId=a}static cleanUp(){AppContext.useHDGeometry=!1,AppContext.kernelInstance=null,AppContext.kernelContainer=null,AppContext.planObjectId=null}}AppContext.useHDGeometry=!1,AppContext.kernelInstance=null,AppContext.kernelContainer=null,AppContext.planObjectId=null;const WAITERS=new Map,_endOperation=function(e,t,n){let a=WAITERS.get(e);if(a){const r=n?[n]:void 0;a.forEach(({resolve:e,reject:n})=>t?e.apply(e,r):n.apply(n,r)),WAITERS.delete(e)}};class AsyncHelper{static finishOperation(e,t){_endOperation(e,!0,t)}static failOperation(e,t){_endOperation(e,!1,t)}static waitFor(e,t){return new Promise((n,a)=>{let r=WAITERS.get(e);r||(WAITERS.set(e,[]),r=WAITERS.get(e)),r.push({resolve:n,reject:a}),"function"==typeof t&&t.apply(t)})}}const isRange=function(e){return e.validRange&&"string"==typeof e.validRange.type},isOptions=function(e){return e.validValues&&e.validValues.length>0},isMaterial=function(e){return"Material"===e.type};let WASM_URL,WASM_LOADER,CACHE_COMPILATION;const KERNEL_PATHS={WASM_MODERN:{CONFIGURATOR:{URL:"static/ConfiguratorKernel-793e445c9d64ee4b.wasm",LOADER:"static/ConfiguratorKernel-2ddc08f9542fc91f.js"},PLANNER:{URL:"static/RoomleCore-7d39e007d6f9b788.wasm",LOADER:"static/RoomleCore-f2d7b1b87640ef15.js"}}},USE_WASM=!!window.WebAssembly;class CommonKernelAccess{_utilityToLongArray(e){const t=new this._kernelContainer.LongArray;return e.forEach(e=>t.push_back(e)),t}constructor(e){this._requestedItemIds=[],this._requestedMaterialIds=[],this._configuratorKernelCallbackListener=new Set,this._cachedGroupIds=[],this._waitingForGroups=!1,this._subComponentsWaiters=new Map,this._shouldWait=!0,this._creator_=e,window.KernelCallback={isReady:this.isReady.bind(this)},this._lifeCycleManager.addEventListener(this)}init(e){this._kernelType=e,this._setupKernelPaths(e),this._setupEmsModule(e),this._useWASM=USE_WASM,this._kernelPath=USE_WASM?WASM_LOADER:void 0}_initKernel(){const{restrictionLevel:e}=this._initData,t=!1!==this._initData.callbacksOnlyIfGeometryIsReady;this._kernelInstance.setUpdateCallbacksOnlyIfGeometryIsReady(t),this._kernelInstance.setLevel(e),this._unitFormatter.init(this._kernelContainer),this._kernelInstance.setEnvironmentVariable("unit",this._unitFormatter._actualUnitString||"cm"),this._kernelInstance.setEnvironmentVariable("unitString","short"),this._kernelInstance.useEnvironmentGeometry(1===this._kernelType),this._kernelInstance.setDockInsertPreviewBoxParameters(80,50,100,10);const{overrideCountry:n,locale:a}=this._globalInitData;n&&(this._kernelInstance.resetPriceListIds(),this._kernelInstance.addPriceList(n)),this._kernelInstance.setEnvironmentVariable("language",a),this._kernelInstance.setEnvironmentVariable("visibleInPlannerDefault","1")}get kernelContainer(){return this._kernelContainer}get kernelInstance(){return this._kernelInstance}get configurationExporter(){return this._configurationExporter||(this._configurationExporter=this._kernelContainer.newConfigurationExporter()),this._configurationExporter}_setupKernelPaths(e){const t=0===e?"PLANNER":"CONFIGURATOR";WASM_URL=KERNEL_PATHS.WASM_MODERN[t].URL,WASM_LOADER=KERNEL_PATHS.WASM_MODERN[t].LOADER,CACHE_COMPILATION=!0}_setupEmsModule(e){const t=this;this._kernelContainer={locateFile(t){const n=0===e?/RoomleCoreJs[\-a-z0-9]*\.js\.mem/:/ConfiguratorKernelJs[\-a-z0-9]*\.js\.mem/;return t.match(n)?getAssetPath()+void 0:t},wasmBinaryFile:getAssetPath()+WASM_URL,preRun:[],postRun:[],setStatus:null,print(e){t._kernelIo.log(e)},printErr(e){t._kernelIo.error(e)},quit(e){0!==e&&t._kernelIo.throw(e&&e.toString?e.toString():"Unknown error while C/C++ main executes")}},CACHE_COMPILATION&&USE_WASM&&(this._kernelContainer.instantiateWasm=function(e,t){return((e,t,n)=>{const a="function"==typeof WebAssembly.instantiateStreaming;Benchmark.addMeta("kernel_is_ready",{cachedInIndexedDB:!1});let r=null;a?(Benchmark.start("kernel_stream_compile"),r=WebAssembly.instantiateStreaming(fetch(getAssetPath()+e),t)):(Benchmark.start("kernel_legacy_compile"),r=fetch(getAssetPath()+e).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,t))),Benchmark.addMeta("kernel_is_ready",{instantiateStreaming:a}),r.then(e=>{n(e.instance)},e=>console.error(e))})(WASM_URL,e,t),{}})}_passSubComponentsToKernel(e,t){const n=e.id,a=t.get(n);if(a)for(let t=0,r=a.length;t<r;t++)this._kernelIo.setMeta({componentId:n}),this._kernelInstance.assetsLoaded({type:{value:1},id:n,data:e.configuration})}_fetchSubComponents(e){let t=[...e.keys()];t.length&&this._rapiAccess.getComponents(t).then(t=>{for(let n=0,a=t.length;n<a;n++)this._passSubComponentsToKernel(t[n],e);this._flushSubComponentsWaiters()})}_flushSubComponentsWaiters(){this._fetchSubComponents(this._subComponentsWaiters),this._subComponentsWaiters=new Map,this._shouldWait=!1}isReady(){this._kernelContainer.setExternalHelpers(this._kernelIo,{convertCObject}),Env.isProduction||Env.isUnitTesting||this.addDebugInfo(),window.KernelCallback&&(window.KernelCallback=null,delete window.KernelCallback)}addDebugInfo(){const e=function(t,n=[]){const a=Object.getPrototypeOf(t),r=a?Object.getOwnPropertyNames(a):[],i=t?Object.getOwnPropertyNames(t):[];return a?e(a,[...n,...i,...r]):[...i,...r,...n]},t=e(this),n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","valueOf"];[...new Set(t)].forEach(e=>{if(!e.startsWith("_")&&"function"==typeof this[e]&&-1===n.indexOf(e))try{const t=this[e].bind(this);this[e]=function(...n){return this._kernelIo.log("[ KernelCommunication ]: "+e),t(...n)}}catch(e){}})}getConfigurationData(e){return new Promise(t=>{var n;const a=this.kernelInstance.getPlanObject(e),r=(new Date).toISOString(),i=this.kernelInstance.getComponentId(e),s=getCatalogIdFromItemOrConfigurationId(i),o=(null===(n=a.boxForMeasurement)||void 0===n?void 0:n.size)||a.bounds;t({created:r,lastAccess:r,configuration:this.kernelInstance.getSerializedConfiguration(e),configurationHash:this.kernelInstance.getHashOfConfiguration(e),parts:JSON.stringify(this.kernelInstance.getPartList(e)),rootComponentId:i,width:o.x,height:o.z,depth:o.y,catalog:s,orderable:!1,requestable:!1})})}requestAssets(e){const t=e.filter(e=>0===e.type.value).map(e=>e.id),n=e.filter(e=>1===e.type.value).map(e=>e.id),a=e.filter(e=>3===e.type.value).map(e=>e.id),r=e.filter(e=>4===e.type.value).map(e=>e.id),i=e.filter(e=>2===e.type.value).map(e=>({meshId:e.id,quality:e.value})),s=e.filter(e=>5===e.type.value||6===e.type.value);this.loadItemConfigurations(t),this.loadComponent(n),this.requestMaterialProperties(a),this.requestMaterialsInGroup(r),this.requestExternalMesh(i),this._requestAssetByExternalUrl(s)}loadComponent(e){for(const t of e)this._rapiAccess.getComponent(t).then(e=>{var n;let a=e.configuration;a||(a="error",null===(n=this._configuratorUiCallbacks)||void 0===n||n.onContentProblem({rapiPath:"components",ids:[t],message:t+" has no configuration"})),this._kernelIo.setMeta({componentId:t}),this._kernelInstance.assetsLoaded({type:{value:1},id:t,data:a}),this._flushSubComponentsWaiters()},e=>{var n;this._kernelInstance.assetsLoaded({type:{value:1},id:t,data:"error"}),this.onLoadComponentError(e,t),null===(n=this._configuratorUiCallbacks)||void 0===n||n.onError(new Error(`Component with id "${t}" can not be loaded. "${e}"`)),this._flushSubComponentsWaiters()})}async loadItemConfigurations(e){let t=Array.isArray(e)?e:[e];if(!t.length)return;if(this._requestedItemIds.push(...t),await wait(0),!this._requestedItemIds.length)return;const n=[...this._requestedItemIds];this._requestedItemIds=[],(await this._rapiAccess.getItems(n)).forEach(e=>{this._kernelInstance.assetsLoaded({type:{value:0},id:e.id,data:e.configuration})})}requestDeleteComponent(e){var t,n;e&&((null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)?this._kernelInstance.deletePlanComponent(e):this._kernelInstance.deleteComponent(e))}dockComponentWithPosition(e,t,n,a,r){var i;this._kernelInstance.dockComponentWithPosition(n,a,e,t,r);const s=this._kernelInstance.getComponentId(n),o=this._kernelInstance.getComponentId(e);null===(i=this._configuratorUiCallbacks)||void 0===i||i.onUserInitiatedDockDone(s,a,o,t,r)}Editor3dAddMesh(e,t,n,a,r,i){this._configuratorKernelCallbackListener.forEach(s=>s.Editor3dAddMesh(e,t,n,a,r,i))}Editor3ChangedMesh(e,t,n,a){this._configuratorKernelCallbackListener.forEach(r=>r.Editor3ChangedMesh(e,t,n,a))}Editor3dRemoveMesh(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dRemoveMesh(e,t))}Editor3dBeginConstruction(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dBeginConstruction(e,t))}Editor3dEndConstruction(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dEndConstruction(e))}Editor3dComponentCreated(e,t,n,a,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,a,r))}Editor3dComponentDocked(e,t,n,a,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentDocked(e,t,n,a,r))}Editor3dGeometryReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryReady(e)),this.requestPlanComponentConstruction(e),this._configuratorUiCallbacks.onGeometryReady(e)}Editor3dGeometryNotReady(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dGeometryNotReady(e)),this._configuratorUiCallbacks.onGeometryNotReady(e)}componentDeleted(e){this._configuratorKernelCallbackListener.forEach(t=>t.componentDeleted(e))}componentMetaUpdated(e){let t=this._kernelInstance.getComponent(e);this._configuratorKernelCallbackListener.forEach(e=>e.componentMetaUpdated(t))}sceneCleared(){this._configuratorKernelCallbackListener.forEach(e=>e.sceneCleared())}requestMaterialsInGroup(e){let t=Array.isArray(e)?e:[e];t.length&&(t.forEach(e=>{-1===this._cachedGroupIds.indexOf(e)&&this._cachedGroupIds.push(e)}),this._waitingForGroups||(this._waitingForGroups=!0,AsyncHelper.waitFor(4).then(()=>{this._rapiAccess.getMaterialsByGroup(this._cachedGroupIds).then(e=>{let t=[];e.forEach(e=>{const n=[];e.materials.forEach(e=>n.push(e.id));const a=e.legacyId||e.id;e.legacyId||console.warn("Material group has no legacy id, please check content why this is the case"),t.push({type:{value:4},id:a,data:n})}),t.length&&this._kernelInstance.assetsLoaded(t),this._cachedGroupIds=[]},e=>{var t;console.error(e),null===(t=this._configuratorUiCallbacks)||void 0===t||t.onError(new Error(`Material group with ids "${this._cachedGroupIds.join(",")}" can not be loaded. "${e}"`)),this._cachedGroupIds=[]})})))}requestPlanComponentConstruction(e,t=!0){t?this._kernelInstance.requestDeltaPlanComponentConstruction(e):this._kernelInstance.requestPlanComponentConstruction(e)}addConfiguratorListener(e){this._configuratorKernelCallbackListener.add(e)}removeConfiguratorListener(e){this._configuratorKernelCallbackListener.delete(e)}cleanUpCallbacks(){"function"==typeof this._kernelContainer.unregisterConfiguratorCallback&&this._kernelContainer.unregisterConfiguratorCallback(this)}async requestMaterialProperties(e){let t=Array.isArray(e)?e:[e];if(!t.length)return;if(this._requestedMaterialIds.push(...t),await wait(0),!this._requestedMaterialIds.length)return;const n=[...this._requestedMaterialIds];this._requestedMaterialIds=[];const a=await this._rapiAccess.getMaterials(n);let r=[];a.forEach(e=>{const t=new this._kernelContainer.StringStringMap,n=e.properties||{};for(let e in n)n.hasOwnProperty(e)&&t.set(e,n[e]);t.size()&&r.push({type:{value:3},id:e.id,value:0,data:t})}),r.length&&this._kernelInstance.assetsLoaded(r)}registerCallbacks(){this._kernelContainer.registerConfiguratorCallback(this)}pause(){this.cleanUpCallbacks()}resume(){this.cleanUpCallbacks(),this.registerCallbacks()}destroy(){}_handleCortoMesh(e,t,n){var a;try{this._kernelInstance.assetsLoaded({type:{value:2},id:t,value:n,data:new Uint8Array(e)})}catch(e){console.error(e),null===(a=this._configuratorUiCallbacks)||void 0===a||a.onMemoryCorruption()}}async _requestAssetByExternalUrl(e){for(const t of e){let e="";try{const n=await fetch(t.id);n.status<300&&(e=await n.text())}catch(e){this._configuratorUiCallbacks.onError(new Error(`Asset with url "${t.id}" breaks. "${e}"`)),console.error(e)}e.length>0?this._kernelInstance.assetsLoaded({type:t.type,id:t.id,value:t.value,data:e}):this._handleInvalidAsset(t.type,t.id,t.value)}}_handleInvalidAsset(e,t,n){try{this._kernelInstance.setAssetInvalid(e,t,n)}catch(e){console.error(e)}}calcPartsPriceSum(e){return this._calcPrice(e)}_calcPrice(e){const t=new Map;e||(e=this._kernelInstance.getFullPartList());const n=!!e&&!!e.fullList&&!!e.fullList.length;if(this._initData.useRoomlePrice&&n){const n=e.fullList[0].currencySymbol,a=e.fullList.reduce((e,t)=>e+(t.count?t.count:0)*(t.price?t.price:0),0),r=roundWithPrecision(a,2);return this._configuratorUiCallbacks.onUpdatePrice(n,r),Promise.resolve({totalSum:r,partMap:t})}if(this._initData.usePriceService&&n){const n=e.fullList.reduce((e,n)=>{const a=kernelPartToPriceId(n);return a&&(t.set(a,n),e.push(a)),e},[]);return new Promise((a,r)=>{this._rapiAccess.getPrices(n).then(n=>{if(!n.length)return r(new Error("prices are empty"));let i=0;const s=objectArrayToMap(n,"priceId");for(const t of e.fullList){const e=kernelPartToPriceId(t);if(!s.has(e)){console.warn("PriceId: "+e+" has no corresponding kernel-part");continue}const{price:n,currencySymbol:a}=s.get(e);t.price=n,t.currencySymbol=a,i+=n*t.count}return i=roundWithPrecision(i,2),this._configuratorUiCallbacks.onUpdatePrice(n[0].currencySymbol,i),a({totalSum:i,partMap:t})},e=>{console.error(e),r(e)})})}return Promise.resolve({totalSum:0,partMap:t})}async addUiDataAndPriceToPartList(e,t){const{fullList:n,originPart:a,perMainComponent:r}=e;let i;this.addUiDataToPartList(n,t);try{const t=await this._calcPrice(e);i=t.partMap}catch(e){console.error(e),i=new Map}const s=this._initData.usePriceService||this._initData.useRoomlePrice,o=e=>{s||(e.price=null,e.currencySymbol=null);const t=kernelPartToPriceId(e);if(!t)return;if(!i.has(t))return;const{price:n,currencySymbol:a}=i.get(t);"number"==typeof n&&(e.price=n,e.currencySymbol=a)};return n.forEach(o),r.forEach(({fullList:e,originPart:n,perMainComponent:a})=>{a.length>0&&console.error("Not implemented! perMainComponent is deeper than one level"),this.addUiDataToPartList(e,t),this.addLabelToKernelComponent(n),e.forEach(o)}),{fullList:n,perMainComponent:r,originPart:a}}addLabelToKernelComponent(e){const t=this._rapiAccess.peekComponent(e.componentId);!t||e.labelIsCalculated&&e.label||(e.label=t.label)}addUiDataToPartList(e,t){const n=[];return e.forEach(e=>{const t=this._rapiAccess.peekComponent(e.componentId);!t||e.labelIsCalculated&&e.label||(e.label=t.label),e.parameters.forEach(e=>{if(this._unitFormatter.formatPartListParameter(e),isMaterial(e)){const t=this._rapiAccess.peekMaterial(e.value);t?e.valueLabel=t.label||t.name||e.value:-1===n.indexOf(e.value)&&n.push(e.value)}})}),n.length&&this._rapiAccess.getMaterials(n).then(e=>{const n=this._lastPartListHash!==t;Array.isArray(e)&&e.length&&n&&(this._lastPartListHash=t,this.requestPartListAndUpdatePricesOfParts())}),e}requestExternalMesh(e){}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const a=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(a,btoa(e))}}__decorate([inject],CommonKernelAccess.prototype,"_rapiAccess",void 0),__decorate([inject],CommonKernelAccess.prototype,"_scriptLoader",void 0),__decorate([inject],CommonKernelAccess.prototype,"_kernelIo",void 0),__decorate([inject],CommonKernelAccess.prototype,"_dataSyncer",void 0),__decorate([inject],CommonKernelAccess.prototype,"_lifeCycleManager",void 0),__decorate([inject],CommonKernelAccess.prototype,"_configuratorUiCallbacks",void 0),__decorate([inject],CommonKernelAccess.prototype,"_globalCallback",void 0),__decorate([inject],CommonKernelAccess.prototype,"_initData",void 0),__decorate([inject],CommonKernelAccess.prototype,"_unitFormatter",void 0),__decorate([inject],CommonKernelAccess.prototype,"_configuratorContext",void 0),__decorate([inject],CommonKernelAccess.prototype,"_globalInitData",void 0);const{APP}=Env,{RAPI}=APP,headers=RAPI.headers,itemHeaders=RAPI.itemHeaders,TOKEN_IDENTIFIER=headers.token,isPlanSnapshotId=e=>e.startsWith("ps_"),LEGACY_GROUP_INDICATOR=uuid();let RAPI_MATERIAL_GROUP_CACHE=new Map,ITEM_ADDITIONAL_CONTENT_CACHE=new Map,RAPI_RELATIONS_CACHE=new Map,RAPI_CACHE=new Map,MESHES_TO_CATALOG_CACHE=new Map,RAPI_PACKAGE_CACHE=new Map,RAPI_PRELOAD_CACHE=new Map,WAITERS_FOR_URL=new Map,RAPI_ERROR_CACHE=new Map;const getCachedMaterialGroup=e=>RAPI_MATERIAL_GROUP_CACHE.get(e)||RAPI_MATERIAL_GROUP_CACHE.get(LEGACY_GROUP_INDICATOR+e),hasMaterialTags=e=>e&&e.tags&&e.tags.length,materialHasNoTagsButGroup=e=>!hasMaterialTags(e)&&e.group;class RapiAccess{constructor(e){this._itemLoaded=!1,this._currentToken=null,this._creator_=e,window.addEventListener("online",this._flushOfflineQueue.bind(this))}async setConfiguratorSettings(){const e=this._configurator?await this._configurator:null;e&&e.id===this._globalInitData.configuratorId||(this._configurator=new Promise(e=>{this._fetchJson("/configurators/"+(this._globalInitData.configuratorId||"demoConfigurator"),"configurators",{method:"GET",additionalHeaders:{currentTenant:this._globalInitData.overrideTenant||9},resolve:e,reject:t=>{console.error(t),console.error("resetting to default configurator"),e({configurator:{id:"demoConfigurator",allowedHosts:"*",tenant:9,settings:{}}})}})}))}async getTenantId(){let e=9;return this._configurator&&(e=(await this._configurator).tenant),void 0!==this._globalInitData.overrideTenant&&(e=this._globalInitData.overrideTenant),e}getPreloadForItem(e){return this._getPreload(e,!0)}getPreloadForConfiguration(e){return this._getPreload(e,!1)}_getPreload(e,t){return new Promise((n,a)=>{if(!navigator.onLine)return n();if(this._dataSyncer.getIsCatalogSynced(getCatalogIdFromItemOrConfigurationId(e)))return n();if(RAPI_PRELOAD_CACHE.get(e))return n();const r=t?"?itemId=":"?configurationId=";this._get("/preloads/components/"+r+e,"preloads/components").then(t=>{if(RAPI_PRELOAD_CACHE.get(e))return n();t.forEach(e=>{this._prepareData(e,"components")}),RAPI_PRELOAD_CACHE.set(e,!0),n()},a)})}changeUseOfHDGeometry(){const e=RAPI_CACHE.get("components");RAPI_PRELOAD_CACHE.clear(),RAPI_PACKAGE_CACHE.clear(),e&&RAPI_CACHE.delete("components")}getHSCPackage(e){return new Promise((t,n)=>{if(RAPI_PACKAGE_CACHE.get(e))return t();this._get("/catalogs/"+e+"/package","package").then(n=>{if(RAPI_PACKAGE_CACHE.get(e))return t(n);n.components.forEach(e=>{this._prepareData(e,"components")}),n.materials.forEach(e=>{this._prepareData(e,"materials"),this._prepareGroups(e)}),n.textures.forEach(e=>{this._prepareData(e,"textures")}),RAPI_PACKAGE_CACHE.set(e,!0),t(n)},n)})}getComponent(e){return this._getById(e,"components")}getConfiguration(e){return this._getById(e,"configurations")}getConfigurations(e){return this._getByIds(e,"configurations")}getItem(e){return this._getById(e,"items",{additionalHeaders:itemHeaders})}getComponents(e){return this._getByIds(e,"components")}getItems(e){return this._getByIds(e,"items",{additionalHeaders:itemHeaders})}getTag(e){return this._getById(e,"tags")}getTags(e){return this._getByIds(e,"tags")}getTexture(e){return this._getById(e,"textures")}getCatalog(e){return this._getById(e,"catalogs")}getMesh(e,t="crt",n=50){return this._getById(e,"meshes",{pathSuffix:"/data?format="+t+"&targetQuality="+n.toString()})}getMeshesOfCatalog(e){return new Promise((t,n)=>{const a=MESHES_TO_CATALOG_CACHE.get(e);a?t(a):this._get("/meshes?catalog="+e,"catalogMeshes").then(n=>{MESHES_TO_CATALOG_CACHE.set(e,n),t(n)},n)})}getTexturesOf(e){return this._getRelationData(e,{rapiPath:"textures"})}getItemsOf(e){return this._getRelationData(e,{rapiPath:"items"})}async getMaterialsOf(e){return(await this._getRelationData(e,{rapiPath:"materials"},{embed:["textures"]})).filter(e=>e.active)}getComponentsOf(e){return this._getRelationData(e,{rapiPath:"components"})}getAdditionalContentsOfItems(e){const t=[],n=[],a=[];return e.forEach(e=>{const r=e.id.toString(),i=ITEM_ADDITIONAL_CONTENT_CACHE.get(r);i?n.push(...i):t.push(r),a.push(r)}),new Promise((e,r)=>{0!==t.length?this._getByIdsPackets(t,"itemAdditionalContents",{filterKey:"itemIds"}).then(t=>{t.forEach(e=>{let t=ITEM_ADDITIONAL_CONTENT_CACHE.get(e.itemId);t||(t=[]);for(let n=0,a=t.length;n<a;n++)if(t[n].id===e.id)return;t.push(e),ITEM_ADDITIONAL_CONTENT_CACHE.set(e.itemId,t)}),e(rearrangeArrayByIdOrder(a,[...t,...n],"itemId"))},r):e(n)})}getMaterial(e){return this._getById(e,"materials",{embed:["textures"]})}peekMaterial(e){return this._peekData(e,"materials")}peekComponent(e){return this._peekData(e,"components")}peekItem(e){return this._peekData(e,"items")}peekConfiguration(e){return this._peekData(e,"configurations")}async getMaterials(e){return(await this._getByIds(e,"materials",{embed:["textures"]})).filter(e=>e.active)}getPlan(e){return this._getById(e,"plans")}getPlanSnapshot(e){return this._getById(e,"planSnapshots")}static clearCaches(){RAPI_MATERIAL_GROUP_CACHE=new Map,RAPI_RELATIONS_CACHE=new Map,RAPI_CACHE=new Map,RAPI_PACKAGE_CACHE=new Map,RAPI_PRELOAD_CACHE=new Map,WAITERS_FOR_URL=new Map,ITEM_ADDITIONAL_CONTENT_CACHE=new Map}cleanUp(){RapiAccess.clearCaches()}getMaterialsByGroup(e){const t=e.slice(),n=[];let a=t.length;for(let e=0;e<a;e++){const r=getCachedMaterialGroup(t[e]);if(r){const i=r.length;for(let e=0;e<i;e++){const t=this._getCache("materials").get(r[e]);n.push(t)}t.splice(e,1),a--,e--}}return new Promise((e,a)=>{0!==t.length&&navigator.onLine?this._getByIdsPackets(t,"materials",{filterKey:"groups",embed:["textures"]}).then(t=>{e(this.combineMaterialsToGroups([...t,...n]))},a):e(this.combineMaterialsToGroups(n))})}_flushOfflineQueue(){return new Promise((e,t)=>{const n=this._localStorage.getItem("hsc_configurations_offline_queue_v1"),a=[];for(let e in n)if(n.hasOwnProperty(e)){const t=n[e];a.push(new Promise((e,n)=>{this.saveConfiguration(t.data).then(a=>{let r=t.perspectiveImage,i=t.topImage;r=r&&!a.perspectiveImage?t.perspectiveImage:null,i=i&&!a.topImage?t.topImage:null,r||i?this.saveConfigurationImage(a,r,"perspectiveImage",i,"topImage").then(()=>e(),e=>n(e)):e()},e=>n(e))}))}Promise.all(a).then(()=>{this._localStorage.setItem("hsc_configurations_offline_queue_v1",{}),e()},t)})}_setQueuedConfiguration(e,t={}){const n=e.configurationHash,{perspectiveImage:a,topImage:r}=t;let i=this._localStorage.getItem("hsc_configurations_offline_queue_v1")||{},s=i[n]||{};s.data=e,s.perspectiveImage=a,s.topImage=r,i[n]=s,this._localStorage.setItem("hsc_configurations_offline_queue_v1",i)}async saveConfiguration(e){return navigator.onLine?await this._save("/configurations",{configuration:e},"configurations",{accept:"application/json",contentType:"application/json; charset=UTF-8"}):(e.perspectiveImage=null,e.topImage=null,this._setQueuedConfiguration(e),this._markConfigurationAsLocally(e),Promise.resolve(e))}getShortUrl(e,t){return new Promise((n,a)=>this._fetchJson("/shortIds","shortIds",{method:"POST",resolve:n,reject:a,data:JSON.stringify({shortId:{type:t,referencedId:e}}),accept:"application/json",contentType:"application/json; charset=UTF-8"}))}async resolveShortUrl(e){return new Promise((t,n)=>{this._fetchJson("/shortIds/"+e,"shortIds",{method:"GET",resolve:t,reject:n})})}_peekData(e,t){const n=RAPI_CACHE.get(t);return n&&n.get(e)||null}_createAssetsFormData(e,t,n,a,r){const i=this._formDataUtil.create(t.image,e,IMAGE_FORMATS.PNG,"file");if(i.append("type",n),r&&a){const t=this._formDataUtil.create(a.image,e,IMAGE_FORMATS.PNG,"file2");i.append("file2",t.get("file2")),i.append("type2",r)}return i}saveConfigurationImage(e,t,n,a,r){if(!navigator.onLine){const i={};return t&&n&&(i[n]=t,e[n]=t.image),a&&r&&(i[r]=a,e[r]=a.image),this._setQueuedConfiguration(e,i),this._markConfigurationAsLocally(e),Promise.resolve(e)}const i=this._createAssetsFormData(e.configurationHash,t,n,a,r);return this._save("/configurations/"+e.id,i,"configurations",{accept:"application/json",method:"PUT"})}savePlanSnapshotImage(e,t,n,a,r){const i=this._createAssetsFormData(e.id,t,n,a,r);return this._save("/planSnapshots/"+e.id,i,"planSnapshots",{accept:"application/json",method:"PUT"})}_markConfigurationAsLocally(e){e.isLocally=!0,e.id=e.configurationHash}_save(e,t,n,a={}){const r=t instanceof FormData?t:JSON.stringify(t);return new Promise((t,i)=>{const s={method:a.method||"POST",data:r,resolve:t,reject:i};a.contentType&&(s.contentType=a.contentType),a.accept&&(s.accept=a.accept),this._fetchJson(e,n,s)})}combineMaterialsToGroups(e){return new Promise((t,n)=>{const a=new Map,r={id:null,label:null,materials:[]},i=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],s=n.tags&&n.tags.length?n.tags.map(e=>({isTag:!0,id:e})):[];n.group&&s.push({isTag:!1,id:LEGACY_GROUP_INDICATOR+n.group,legacyId:n.group}),s.length||s.push({isTag:!1,id:null}),n.tags&&n.tags.length&&n.tags.forEach(e=>-1===i.indexOf(e)?i.push(e):null),s.forEach(({isTag:e,id:t,legacyId:i})=>{const s=n.id;let o=t?getCachedMaterialGroup(t):[];o||(RAPI_MATERIAL_GROUP_CACHE.set(t,[]),o=getCachedMaterialGroup(t)),-1===o.indexOf(s.toString())&&o.push(s.toString());const l=hasMaterialTags(n),d=l&&e,c=materialHasNoTagsButGroup(n);if(d||c&&!e||!l&&!c&&!t){let e=t?a.get(t):r;e||(a.set(t,{id:t,label:n.groupLabel,legacyId:i,materials:[]}),e=a.get(t)),e.materials.push(n)}})}const s=r.materials.length?[r]:[];this.getTags(i).then(e=>{const n=e.reduce((e,t)=>(e[t.id]=t,e),{});return a.forEach((e,t)=>{s.push({id:t,label:n[t]?n[t].label:e.label,materials:e.materials,legacyId:e.legacyId,sort:n[t]?n[t].sort:void 0})}),t(s)},n)})}_getByIds(e,t,n={}){if(1===e.length&&"prices"!==t)return this._getById(e[0],t,n).then(e=>Array.isArray(e)?e:[e]);const a=this._getCache(t),r=this._getErrorCache(t),i=[],s=[...new Set(e)];let o=s.length;if(a&&a.size){const e=(new Date).getTime();for(let t=0;t<o;t++){const n=s[t],l=a.get(n),d=r.get(n);let c=!1;null!=l?(i.push(l),c=!0):c=void 0!==d&&(e-d.timestamp<6e4||!1===navigator.onLine),c&&(s.splice(t,1),o--,t--)}}return new Promise((a,r)=>{0!==s.length&&navigator.onLine?this._getByIdsPackets(s,t,n).then(t=>{a(rearrangeArrayByIdOrder(e,[...t,...i]))},r):a(i)})}_getByIdsPackets(e,t,n={}){e.sort();const a=n.filterKey||"ids";let r,i="/"+t+"/",s="?",o=[];const l=e.length;if(!l)return new Promise(e=>e([]));let d=!0,c=[];for(r=0;r<l;r++){d=!1;const n=e[r],l=s+a+"[]="+n,h=l.length+i.length;c.push(n),s="&",h<=1500?i+=l:(h>1500&&(c.pop(),r--),o.push({url:i,ids:c}),d=!0,i="/"+t+"/",s="?",c=[])}d||o.push({url:i,ids:c});const h=[];return o.forEach(e=>h.push(this._getByIdsSingle(e.ids,e.url,t,n))),new Promise((e,t)=>{Promise.all(h).then(t=>{const n=[];t.length&&t.forEach(e=>n.push(...e)),e(n)},t)})}_getByIdsSingle(e,t,n,a={}){return e.sort(),new Promise((r,i)=>{this._get(t,n,a).then(t=>{for(let n=0,r=t.length;n<r;n++){const r=a&&a.cacheKey?t[n][a.cacheKey]:t[n].id,i=e.indexOf(r.toString());-1!==i&&e.splice(i,1)}const i=e.length;if(i){const t=this._getCache(n),a=this._getErrorCache(n),r=(new Date).getTime();for(let n=0;n<i;n++)a.set(e[n],{code:0,timestamp:r}),t.delete(e[n]);this._errorHandler.dispatch(2,[n,e.map(e=>'"'+e+'"').join(",")])}r(t)},i)})}_getById(e,t,n={}){if(!e||""===e||"string"!=typeof e)return console.error("no id passed to _getById"),Promise.reject(new Error("no id passed to _getById"));const a=this._getCache(t).get(e);if(a)return new Promise(e=>e(a));if(!navigator.onLine)return Promise.reject("Nothing cached but tried to fetch in offline mode");const r={...n,id:e},i=n.pathSuffix||"";return this._get("/"+t+"/"+e+i,t,r)}_get(e,t,n={}){const a=AppContext.useHDGeometry?"includeGeometryHD=true":"";let r=-1===e.indexOf("?")?"?":"&";return""!==a&&(e+=r+a),n.embed&&Array.isArray(n.embed)&&n.embed.forEach(t=>{e+=r+"embed"+(t[0].toUpperCase()+t.substr(1))+"=true",r="&"}),new Promise((a,r)=>{const i=WAITERS_FOR_URL.get(e);Array.isArray(i)&&i.length>0?i.push({resolve:a,reject:r}):(WAITERS_FOR_URL.set(e,[{resolve:a,reject:r}]),this._fetchJson(e,t,n))})}async _fetchJson(e,t,n={}){try{n.additionalHeaders||(n.additionalHeaders={}),n.additionalHeaders.currentTenant||(n.additionalHeaders.currentTenant=await this.getTenantId());const a=await this._fetch(e,n),r=await handleJsonResponse(a);return await this._handleJson(e,t,n)(r)}catch(t){this._handleError(e,n)(t)}}async _fetch(e,t){const n={method:t.method?t.method:"GET",headers:this._createHeaders(t),mode:"cors",cache:"default"};t.data&&(n.body=t.data);let a=RAPI.server;const r=this._globalInitData.overrideRapi;r&&(a="live"===r?RAPI.liveServer:RAPI.testServer),(this._globalInitData.customApiUrl||""===this._globalInitData.customApiUrl)&&(a=this._globalInitData.customApiUrl);const i=new Request(a+e,n);this._globalCallback.onNetworkRequest(e,n,t);const s=await this._globalCallback.onCheckExternalCache(e,n);return s?{headers:{get:()=>"application/json"},json:()=>Promise.resolve(s)}:this._networkLayer.fetch(i,{},{checkResponse:e=>this._globalCallback.onValidateNetworkResponse("rapi-access",e)})}_createHeaders(e={}){const t={...headers};this._globalInitData.overrideCountry&&(t.country=this._globalInitData.overrideCountry);const n=this._globalInitData.locale||"en";t.language=n,t.locale=n;const{contentType:a,accept:r,additionalHeaders:i,data:s}=e;if(a&&(t["content-type"]=e.contentType),r&&(t.accept=e.accept),i)for(let e in i)i.hasOwnProperty(e)&&(t[e]=i[e]);this._globalInitData.configuratorId&&(t.configurator=this._globalInitData.configuratorId);const o=this._currentToken||TOKEN_IDENTIFIER;t.token="03-"+window.btoa((new Date).toISOString()+";"+o+";"+headers.apiKey);const l=new Headers(t);return s instanceof FormData&&l.delete("content-type"),l}_handleJson(e,t,n={}){return async a=>{const r=await this._globalCallback.onApiJsonReceived(e,t,a);null!=r&&(a=r);let i=null,s=null;"number"==typeof a&&(i=a);for(let e in a)"meta"!==e&&a.hasOwnProperty(e)&&(i=a[e],s=e);if("error"===s)return this._handleError(e,n)(new Error(JSON.stringify(i)));if(!i)throw new TypeError("RAPI returned empty JSON");if(Array.isArray(i))for(let e=0,a=i.length;e<a;e++)this._prepareData(i[e],t,n),this._prepareEmbeddedData(i[e],t,n);else this._prepareData(i,t,n),this._prepareEmbeddedData(i,t,n);n.resolve?n.resolve(i):this._notifyWaiters(e,null,i)}}_prepareEmbeddedData(e,t,n={}){n.embed&&Array.isArray(n.embed)&&n.embed.forEach(a=>{const r=e[a.slice(0,-1)+"Objects"];if(Array.isArray(r)){for(let e=0,t=r.length;e<t;e++)this._prepareData(r[e],a,n);this._prepareRelationalData(t,a,e.id,r)}else r&&(this._prepareData(r,a,n),this._prepareRelationalData(t,a,e.id,[r]))})}_getCache(e){return this._getCacheFrom(e,RAPI_CACHE)}_getErrorCache(e){return this._getCacheFrom(e,RAPI_ERROR_CACHE)}_getCacheFrom(e,t){let n=t.get(e);return n||(t.set(e,new Map),n=t.get(e)),n}_setCache(e,t,n){n.set(e.toString(),t)}_prepareData(e,t,n=null){let a=this._getCache(t);const r=n&&n.cacheKey?e[n.cacheKey]:e.id;if(r||n&&n.id||"tenants/me"===t)if("tenants/me"!==t){{const t=r||n.id;this._setCache(t,e,a)}e.__rapi_path__=t}else this._setCache("0",e,a);else"shortIds"!==t&&console.error("Can not cache because there is no ID!")}_getRelationsCacheFor(e,t,n){let a=RAPI_RELATIONS_CACHE.get(t);if(!a){const r=new Map,i=new Map;i.set(n,void 0),r.set(e,i),RAPI_RELATIONS_CACHE.set(t,r),a=RAPI_RELATIONS_CACHE.get(t)}let r=a.get(e);if(!r){const t=new Map;t.set(n,void 0),a.set(e,t),r=a.get(e)}return r.get(n)}_prepareGroups(e){const t=e.group,n=e.id;let a=getCachedMaterialGroup(t);a||(RAPI_MATERIAL_GROUP_CACHE.set(t,[]),a=getCachedMaterialGroup(t)),-1===a.indexOf(n.toString())&&a.push(n.toString())}_handleError(e,t={}){return n=>{navigator.onLine?(n.rmlErrorCode=1,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(1,[n])):(n.rmlErrorCode=0,n.message='Failed to load "'+e+'" because of "'+n.message+'"',this._errorHandler.dispatch(0,[n])),t.reject?t.reject(n):this._notifyWaiters(e,n,null)}}_getRelationData(e,t,n={}){const a=e.id;if(!a)return Promise.resolve([]);const r=e.__rapi_path__,i=t.rapiPath;let s=this._getCache(i),o=this._getRelationsCacheFor(a.toString(),r,i),l=[];return o?(o.forEach(e=>l.push(s.get(e))),new Promise(e=>e(l))):navigator.onLine?new Promise((e,t)=>{this._get("/"+r+"/"+a+"/"+i,i,n).then(t=>{this._prepareRelationalData(r,i,a,t),e(t)},t)}):Promise.resolve([])}_prepareRelationalData(e,t,n,a){RAPI_RELATIONS_CACHE.has(e)||RAPI_RELATIONS_CACHE.set(e,new Map);let r=RAPI_RELATIONS_CACHE.get(e);const i=n.toString();r.has(i)||r.set(i,new Map);let s=r.get(i),o=this._getCache(t),l=[];for(let e=0,t=a.length;e<t;e++){const t=a[e],n=t.id.toString();l.push(n),o.set(n,t)}s.set(t,l)}_notifyWaiters(e,t,n){const a=WAITERS_FOR_URL.get(e);if(a&&a.length){for(let e=0,r=a.length;e<r;e++)t?a[e].reject(t):a[e].resolve(n);WAITERS_FOR_URL.delete(e)}}_tenantMe(){return new Promise((e,t)=>{const n=this._getCache("tenants/me"),a=this._globalInitData.overrideTenant?this._globalInitData.overrideTenant:n.get("0");if(a)return e(a);this._fetchJson("/tenants/me","tenants/me",{resolve:t=>e(t),reject:t})})}async getTenant(e){return e||(e=await this._tenantMe()),this._getById(e.toString(),"tenants")}getCurrentSkin(){return this._tenantMe().then(e=>this._getById(e.toString(),"tenants").then(e=>this._getById(e.skin.toString(),"skins")))}getPrices(e){return this._getByIds(e,"prices",{filterKey:"priceIds",cacheKey:"priceId"})}async getConfiguratorSettings(){return await this._configurator}sendUserAction(e){return this._save("/userActions",{userAction:e},"userActions",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}_share(e,t,n,a,r){const i=(e=>{if(!e||0===Object.keys(e).length)return!0;const t={},n=/^[a-zA-Z0-9-_:@\.]+$/;for(const a in e)if(e.hasOwnProperty(a)){const r=e[a];if(Array.isArray(r)){const e=r.map(e=>e.trim());if(!e.every(e=>n.test(e)))return null;t[a]=e}else{if("string"!=typeof r)return null;{const e=r.trim();if(!n.test(a)||!n.test(e))return null;t[a]=e}}}return t})(r);if(!i)return Promise.reject(new Error("Invalid URL parameters"));let s=`/${a}/${e}/shares`;const o=new FormData;return o.append("email",t),o.append("type",n.toString()),i&&Object.keys(i).length>0&&o.append("params",JSON.stringify(i)),new Promise((e,t)=>{const n={method:"POST",data:o,resolve:e,reject:t,accept:"application/json",contentType:"application/json; charset=UTF-8"};this._fetch(s,n).then(n.resolve,n.reject)})}shareConfiguration(e,t,n,a){return this._share(e,t,n,"configurations",a)}sharePlanSnapshot(e,t,n,a){return this._share(e,t,n,"planSnapshots",a)}export3D(e,t,n,a={}){const r="/"+(isPlanSnapshotId(e)?"planSnapshots":"configurations")+"/"+e+"/3d-exports",i={formats:[{file_format:n,pack_external_data:!0,...a}]},s=JSON.stringify(i),o=new FormData;return o.append("email",t),o.append("settings",s),new Promise((e,t)=>{const n={method:"POST",data:o,resolve:e,reject:t};this._fetch(r,n).then(n.resolve,n.reject)})}async trackView(e){if(this._itemLoaded||(t=getHostname())&&(NAMES_FOR_LOCALHOST.includes(t)||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")||t.endsWith("codesandbox.io")||t.endsWith("stackblitz.com")||/^(admin.*.roomle.com)$/.test(t)))return;var t;const{configuratorId:n}=this._globalInitData,a={module:3,action:1,actionId:e,actionLabel:n};await this.sendUserAction(a),this._itemLoaded=!0}signinUser(e,t){return new Promise((n,a)=>{const r={method:"POST",accept:"application/json",contentType:"application/json; charset=UTF-8",data:JSON.stringify({identification:e,passwordMD5:t}),cacheKey:"token",resolve:n,reject:a};this._fetchJson("/auth/signin","auth",r)})}async signoutUser(e){const t=this._currentToken;t!==e&&this.setCurrentToken(e),await this._fetch("/auth/signout",{}),t&&t!==e?this.setCurrentToken(t):this.removeCurrentToken()}async savePlan(e){const t=e.id?"/plans/"+e.id:"/plans";return this._save(t,{plan:e},"plans",{method:e.id?"PUT":"POST",accept:"application/json",contentType:"application/json; charset=UTF-8"})}async savePlanSnapshot(e){return this._save("/planSnapshots",{planSnapshot:e},"planSnapshots",{accept:"application/json",contentType:"application/json; charset=UTF-8"})}setCurrentToken(e){this._currentToken=e}removeCurrentToken(){this._currentToken=null}createNewPlan(){return{name:"",description:"",changeDate:(new Date).toISOString(),created:(new Date).toISOString(),draftId:null,thumbnail:"data:image/png;base64,missing",planObjects:null,active:!0,open:0,planDirectory:0,changed:0,version:2,floorLevel:0,visibility:9,user:null,tenant:null,assets:[],parent:null,setting:null}}updateCache(e,t){const n=this._getCache(e);this._setCache(t.id,t,n)}}__decorate([inject],RapiAccess.prototype,"_formDataUtil",void 0),__decorate([inject],RapiAccess.prototype,"_errorHandler",void 0),__decorate([inject],RapiAccess.prototype,"_dataSyncer",void 0),__decorate([inject],RapiAccess.prototype,"_networkLayer",void 0),__decorate([inject],RapiAccess.prototype,"_localStorage",void 0),__decorate([inject],RapiAccess.prototype,"_globalInitData",void 0),__decorate([inject],RapiAccess.prototype,"_globalCallback",void 0);const DOCKING_CONVERSATION_ID=10,DEFAULT_CONVERSATION_ID=9,sortBySort=(e,t)=>e.sort||t.sort?e.sort?t.sort?e.sort-t.sort:-1:1:0,sortByString=(e,t)=>e&&!t?1:!e&&t?-1:e&&t?e.localeCompare(t):0,ASYNC_PARAMTER_CHANGES=["material"];class ConfiguratorKernelAccess extends CommonKernelAccess{constructor(e){super(e),this.externalMeshQueue=new PromiseQueue,this.muteKernelCallbacks=!1,this.listOfVariants=(e,t)=>{}}init(e){super.init(e),Benchmark.addMeta("kernel_is_ready",{isWasm:this._useWASM}),AppContext.kernelInstance?(this._kernelContainer=AppContext.kernelContainer,setTimeout(()=>this._loadSuccess(),0)):this._scriptLoader.fetch(this._kernelPath,{id:"kernel"}).then(this._loadSuccess.bind(this),this._loadError.bind(this))}_loadSuccess(){Benchmark.start("kernel_is_ready"),window.ConfiguratorKernel&&(AppContext.kernelInstance?setTimeout(()=>this.isReady(),0):(window.ConfiguratorKernel(this._kernelContainer),window.ConfiguratorKernel=null))}_loadError(){this._configuratorKernelAccessCallback.loadError()}selectedComponent(e){this._updateComponentDependencies(e)}uiRequestConfiguration(e){const t=this._kernelInstance.getSerializedConfiguration(e);AsyncHelper.finishOperation(1,t)}getComponentParameters(e){const t=this._kernelInstance.getComponentParameters(e),n=this._kernelInstance.getPlanComponentAnimations(e);return this._addAnimationParameters(t,n),t}getPlanObjectParameters(e){const t=this._kernelInstance.getPlanObjectParameters(e),n=this._kernelInstance.getPlanObjectAnimations(e);return this._addAnimationParameters(t,n),t}_addAnimationParameters(e,t){var n;for(const a of null!=t?t:[]){const t=[];let r="origin";for(const e of a.actions)t.push({value:e.key,label:e.label,thumbnail:null,type:e.type}),"origin"===e.type&&(r=e.key);const i={key:"animation:"+a.key,enabled:a.enabled,label:a.label,visibleInPlanner:a.visibleInPlanner,type:"String",value:r,sort:0,unitType:"unknown",validGroups:[""],validRange:null,validValues:t,group:null!==(n=a.group)&&void 0!==n?n:""};e.push(i)}(null==t?void 0:t.length)>0&&e.sort(sortBySort)}_updateComponentParameters(e){let t=this.getComponentParameters(e);const n=this._kernelInstance.getComponent(e);this._configuratorKernelAccessCallback.updateParameters(t,n.parameterGroups,e,1)}selectionChange(e,t){let n=!1,a=[];if(e){let t=this._kernelInstance.getComponent(e);t.componentId=this._kernelInstance.getComponentId(e),t&&t.childIds&&t.childIds.length>0&&(n=!0),a.push(t);const r=this._kernelInstance.getPlanObjectFromPlanComponent(e);r&&this._componentSelectionChanged(r,t,!0)}this._configuratorUiCallbacks.onSelectionChange("standard",t,n,a)}_componentSelectionChanged(e,t,n){}_externalObjectParameterChanged(e,t,n){}multiSelectionChange(e,t){this._updateCommonComponentDependencies(e);let n=!1,a=!1,r=[];e&&e.forEach(e=>{let i=this._kernelInstance.getComponent(e);i.componentId=this._kernelInstance.getComponentId(e),i&&i.childIds&&i.childIds.length>0&&(n=!0),i.id===t&&(a=!0),r.push(i)}),this._configuratorUiCallbacks.onSelectionChange("multiselect",a,n,r)}_updateCommonComponentDependencies(e){const{parameters:t,parameterGroups:n,animations:a}=this._kernelInstance.getCommonPlanComponentParameters(this._utilityToLongArray(e));this._addAnimationParameters(t,a),this._configuratorKernelAccessCallback.updateParameters(t,n,e,2)}_updateComponentChildren(e){const t=this._kernelInstance.getPlanComponentPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,1)}_updateComponentDependencies(e){this._updateComponentParameters(e),this._updateComponentChildren(e)}_updatePlanObjectParameters(e){let t,n=this.getPlanObjectParameters(e);if(0===n.length){let a=this._kernelInstance.getRootPlanComponentIdFromObjectId(e);n=this.getComponentParameters(a),this._enableRootComponentParametersAsGlobal(),t=this._kernelInstance.getComponent(a)}else this._configuratorContext.rootComponentParametersAsGlobal=!1,t=this._kernelInstance.getPlanObject(e);this._configuratorKernelAccessCallback.updateParameters(n,t.parameterGroups,e,0)}_enableRootComponentParametersAsGlobal(){this._configuratorContext.selectedRuntimeComponentId||(this._configuratorContext.rootComponentParametersAsGlobal=!0)}_updatePlanObjectChildren(e){const t=this._kernelInstance.getPlanObjectPossibleChildren(e);this._configuratorKernelAccessCallback.updatePossibleChildren(e,t,0)}updatePlanObjectDependencies(e){this._updatePlanObjectParameters(e),this._updatePlanObjectChildren(e)}_updateConfigurationHasChildren(e,t=null){t||(t=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e)));const n=t.childIds.size?t.childIds.size():t.childIds.length;this._configuratorUiCallbacks.onConfigurationHasChildren(n>0)}dockComponent(e,t,n,a){const r=this._kernelInstance.getComponentId(n),i=this._kernelInstance.getComponentId(e);this._kernelInstance.dockComponent(n,a,e,t),this._configuratorUiCallbacks.onUserInitiatedDockDone(r,a,i,t,null)}dockExternalObjectComponent(e,t,n,a){}changeUseOfHDGeometry(e,t){this._rapiAccess.changeUseOfHDGeometry();const n=e.planObjectId,a=e.lastLoadedRapiId?e.lastLoadedRapiId:this._kernelInstance.getComponentId(n),r=this._kernelInstance.getSerializedConfiguration(n);this._kernelInstance.clearAll(),this._kernelInstance.useHDGeometry(t),AsyncHelper.finishOperation(3,[r,a])}webGlPreviewDockings(e,t){this._kernelInstance.isExternalPlanObject(e.planObjectId)?this.webGlPreviewDockingsForExternalObjects(e,t):this.webGlPreviewDockingsForKernelObjects(e,t)}webGlPreviewDockingsForKernelObjects(e,t){AsyncHelper.waitFor(4).then(({componentId:n})=>{var a,r,i;t&&this.requestPlanComponentConstruction(n),this._kernelInstance.requestPreviewGeometry(n,e.planObjectId,null!==(i=null===(r=null===(a=this._initData)||void 0===a?void 0:a.featureFlags)||void 0===r?void 0:r.advancedDocking)&&void 0!==i&&i)}),e.lastPossibleChild&&e.lastPossibleChild.isComponent&&(this._kernelIo.setMeta({componentId:e.lastPossibleChild.id}),this._kernelInstance.loadPlainComponent(10,e.lastPossibleChild.id,e.lastPossibleChild.configuration)),e.lastPossibleChild&&e.lastPossibleChild.isItem&&this._kernelInstance.loadFreeFlyingConfiguration(10,e.lastPossibleChild.configuration)}webGlPreviewDockingsForExternalObjects(e,t){var n,a,r;this._kernelInstance.requestPreviewGeometryForExternalObject(e.lastPossibleChild.id,e.planObjectId,null!==(r=null===(a=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===a?void 0:a.advancedDocking)&&void 0!==r&&r)}previewDockingsWithDrag(e,t){var n,a,r;this._kernelInstance.requestPreviewGeometry(e,t,null!==(r=null===(a=null===(n=this._initData)||void 0===n?void 0:n.featureFlags)||void 0===a?void 0:a.advancedDocking)&&void 0!==r&&r)}cancelDocking(e){var t,n,a;this._kernelInstance.cancelDocking(e,null!==(a=null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.advancedDocking)&&void 0!==a&&a)}loadConfiguration(e){this._initData.id?this._memoryManager.loadingConfiguration(this._initData.id):this._memoryManager.loadingConfigurationString(),this._memoryManager.shouldHardReset()?this._kernelInstance.clearAll():this._kernelInstance.clearScene(),this._kernelInstance.loadConfiguration(9,e,{x:0,y:0,z:0})}changeCommonComponentParameter(e,t,n,a,r,i){if("string"==typeof a){const n=[];for(const r of e)this._kernelInstance.isExternalPlanObject(r)?n.push(r):this._kernelInstance.setComponentParameter(r,t,a);this._kernelInstance.setPlanComponentParameters(this._utilityToLongArray(n),t,a)}else console.warn("tried to set a parameter to a none string value!",a,t,n);this._finishParameterChange(n,r,i),this._updateCommonComponentDependencies(e)}changeComponentParameter(e,t,n,a,r,i){var s,o,l;if(t.startsWith("animation:")){const n=null===(s=this._kernelInstance.getComponent(e).animations)||void 0===s?void 0:s.find(e=>e.key===t.split(":")[1]),r=null!==(o=null==n?void 0:n.applyToChildren)&&void 0!==o&&o,i=null!==(l=null==n?void 0:n.animate)&&void 0!==l&&l;this.changeAnimationValue(e,t,a,r,i),this._updateCommonComponentDependencies([e]),this._configuratorContext.planObjectId&&this.updatePlanObjectDependencies(this._configuratorContext.planObjectId)}else"string"==typeof a?this._kernelInstance.isExternalPlanObject(e)?this._externalObjectParameterChanged(e,t,a):this._kernelInstance.setComponentParameter(e,t,a):console.warn("tried to set a parameter to a none string value!",a,t,n);this._finishParameterChange(n,r,i),this._updateComponentDependencies(e)}changePlanObjectParameter(e,t,n,a,r,i){var s,o,l;if(t.startsWith("animation:")){const n=null===(s=this._kernelInstance.getPlanObject(e).animations)||void 0===s?void 0:s.find(e=>e.key===t.split(":")[1]),r=null===(o=null==n?void 0:n.applyToChildren)||void 0===o||o,i=null!==(l=null==n?void 0:n.animate)&&void 0!==l&&l;this.changeAnimationValue(e,t,a,r,i),this.updatePlanObjectDependencies(e)}else"string"==typeof a?this._kernelInstance.isExternalPlanObject(e)?this._externalObjectParameterChanged(e,t,a):this._kernelInstance.setPlanObjectParameter(e,t,a):console.warn("tried to set a parameter to a none string value!",a,t,n);this._finishParameterChange(n,r,i)}updateAnimationParameters(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.updateAnimationParameters(e,t))}changeAnimationValue(e,t,n,a,r){this._configuratorKernelCallbackListener.forEach(i=>i.changeAnimationValue(e,t,n,a,r))}_finishParameterChange(e,t,n){-1===ASYNC_PARAMTER_CHANGES.indexOf(e)?setTimeout(()=>t(),0):this._configuratorKernelCallbackListener.forEach(e=>e.finishParameterChange(t,n))}requestDeleteComponents(e){e&&this._kernelInstance.deletePlanComponents(this._utilityToLongArray(e))}requestDeletePlanComponent(e){var t,n;e&&(null===(n=null===(t=this._initData)||void 0===t?void 0:t.featureFlags)||void 0===n?void 0:n.reDock)&&this._kernelInstance.deletePlanComponent(e)}loadComponentIntoKernel(e,t){this._kernelIo.setMeta({componentId:t}),this._kernelInstance.loadComponentDefinition(10,e)}async requestPartListAndUpdatePricesOfParts(e,t){let n=this._kernelInstance.getFullPartList();e||(e=this._kernelInstance.getHashOfConfiguration(this._configuratorContext.planObjectId));const a=await this.addUiDataAndPriceToPartList(n,e);this._configuratorUiCallbacks.onPartListUpdate(a,btoa(e))}requestSync(e,t){this.planObjectCreated(e,t),this._kernelInstance.syncPlanObjectToView(e,t)}getGlobalParameters(e,t){return new Promise(n=>{n(t?this.getComponentParameters(this._kernelInstance.getRootPlanComponentIdFromObjectId(e)):this.getPlanObjectParameters(e))})}getPartList(){return new Promise(e=>{e(this._kernelInstance.getFullPartList())})}getConfigurationHash(e){return new Promise(t=>t(this._kernelInstance.getHashOfConfiguration(e.planObjectId)))}requestPlanObjectConstruction(e){this._kernelInstance.requestPlanObjectConstruction(e)}isReady(){super.isReady(),this._setupKernel(),Env.isProduction||(window.__RML__DEBUG__||(window.__RML__DEBUG__={}),window.__RML__DEBUG__.Kernel=this._kernelInstance,window.__RML__DEBUG__.KernelContainer=this._kernelContainer,window.__RML__DEBUG__.Helper={convertCObject}),this._configuratorKernelAccessCallback.isReady(),this._configuratorUiCallbacks.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),AppContext.planObjectId&&this.planObjectCreated(-1,AppContext.planObjectId)}_setupKernel(){1===this._kernelType&&(Benchmark.start("kernel_create_instance"),AppContext.kernelInstance?this._kernelInstance=AppContext.kernelInstance:this._kernelInstance=new this._kernelContainer.Kernel),this._initKernel()}onLoadComponentError(e,t){this._configuratorUiCallbacks.onComponentLoadError(e,t)}configurationLoaded(e,t,n,a,r,i){AsyncHelper.finishOperation(4,{conversationId:e,objectId:t,componentId:n,hash:a,errors:convertCObject(r)}),this._configuratorKernelCallbackListener.forEach(i=>i.configurationLoaded(e,t,n,a,r))}componentDefinitionLoaded(e,t){AsyncHelper.finishOperation(0,t)}componentDefinitionLoadingError(e,t){this._kernelIo.error(t),AsyncHelper.failOperation(0,new Error(t))}configurationLoadingError(e,t){let n="Configuration loading error";if(t){const e=convertCObject(t);Array.isArray(e)&&(n=e.join("\n"),e.forEach(e=>this._kernelIo.error(e)))}AsyncHelper.failOperation(4,new Error(n)),AsyncHelper.failOperation(2,new Error(n))}componentConfigurationUpdated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.componentConfigurationUpdated(e,t)),this._kernelInstance.requestDeltaPlanComponentConstruction(e)}setActiveGroupInView(e){this._kernelInstance.setActiveGroupInView(e)}setActiveGroupInViewForPlanObject(e,t){this._kernelInstance.setActiveGroupInViewForPlanObject(e,t||this._configuratorContext.planObjectId)}componentParameters(){}requestComponentDimensions(){}planObjectCreated(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.planObjectCreated(e,t))}planObjectUpdated(e,t){const n=this._kernelInstance.getPlanObject(e);this._onBoundsUpdate(n),this._configuratorKernelCallbackListener.forEach(e=>e.planObjectUpdated(n,t))}planObjectConfigurationUpdated(e,t,n,a,r,i){this.updatePlanObjectDependencies(e);let s=this._kernelInstance.getComponent(this._kernelInstance.getRootPlanComponentIdFromObjectId(e));this._configuratorKernelCallbackListener.forEach(a=>a.planObjectConfigurationUpdated(e,t,n,i));const o=this._kernelInstance.getPlanObject(e);return this._onBoundsUpdate(o),i||this._configuratorHistory.push(t),this._updateConfigurationHasChildren(e,s),this.requestPartListAndUpdatePricesOfParts(n)}_onBoundsUpdate(e){if(!e.boxForMeasurement)return;const t={width:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.x),height:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.z),depth:this._unitFormatter.formatMMValueToUnitString(e.boxForMeasurement.size.y),kernelBounds:e.boxForMeasurement};this._configuratorUiCallbacks.onBoundsUpdate(t)}planObjectDeleted(){}requestPlanObjectDimensions(){}async requestExternalMesh(e){for(const t of e){const{meshId:e,quality:n}=t;let a=()=>{};const r=new Promise((e,t)=>{a=e});let i;this.externalMeshQueue.push(r),this._configuratorUiCallbacks.onRequestExternalMesh(e,n);try{i=await this._rapiAccess.getMesh(e,"crt",n)}catch(t){return this._handleInvalidAsset({value:2},e,n),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" can not be loaded. "${t}"`)),void console.error(t)}try{const t=await fetch(new Request(this._dataSyncer.requestAsset(i.url,!0))),r=await t.arrayBuffer();this._handleCortoMesh(r,e,n),a()}catch(t){return this._handleInvalidAsset({value:2},e,n),this._configuratorUiCallbacks.onError(new Error(`Mesh with id "${e}" breaks. "${t}"`)),void console.error(t)}}}Editor3dComponentCreated(e,t,n,a,r){this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentCreated(e,t,n,a,r)),!a&&parent&&r>0&&this._configuratorKernelCallbackListener.forEach(i=>i.Editor3dComponentDocked(e,a,r,t,n))}Editor3dPlanObjectConstructionDone(e){this._configuratorKernelCallbackListener.forEach(t=>t.Editor3dPlanObjectConstructionDone(e)),this.updatePlanObjectDependencies(e),this._updateConfigurationHasChildren(e),this._initData.moc||this._calcPrice()}Editor3dBeginGroup(){}Editor3dEndGroup(){}Editor3dSetMaterial(){}Editor3dLoadMaterial(){}Editor3dAddDockPreview(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dAddDockPreview(e,t))}Editor3dSetPreviewPointAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewPointAssociations(e,t))}Editor3dSetPreviewLineAssociations(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dSetPreviewLineAssociations(e,t))}Editor3dPreviewConstructionDone(e,t){this._configuratorKernelCallbackListener.forEach(n=>n.Editor3dPreviewConstructionDone(e,t))}Editor3dTranslateBy(){}Editor3dRotateBy(){}Editor3dRotateAround(){}Editor3dAddCube(){}Editor3dAddCubeUVMod(){}Editor3dAddSphere(){}Editor3dAddSphereUVMod(){}Editor3dAddRectangle(){}Editor3dAddRectangleUVMod(){}Editor3dAddMeshUVMod(){}Editor3dAddMeshUVCoord(){}Editor3dAddCylinder(){}Editor3dAddCylinderUVMod(){}Editor3dAddPrism(){}Editor3dAddPrismUVMod(){}Editor3dAddFittingPoint(){}Editor3dAddFittingLine(){}Editor3dSelectObject(){}Editor3dCopy(){}Editor3dUpdatePlanObjectPosition(){}Editor3dUpdatePlanObjectRotation(){}Editor3dUpdatePlanObjectTransform(){}Editor3dUpdatePlanComponentPosition(){}Editor3dUpdatePlanComponentRotation(){}Editor3dUpdatePlanComponentTransform(){}getRuntimeComponentIdOfRootComponent(e){return this._kernelInstance?this._kernelInstance.getRootPlanComponentIdFromObjectId(e):(console.warn("this._kernelInstance not ready now"),0)}getRuntimeComponentId(e){return this._kernelInstance.getComponentId(e)}getParameterGroups(){if(!this._configuratorContext.planObjectId)return[];const e=this._kernelInstance.getRootPlanComponentIdFromObjectId(this._configuratorContext.planObjectId);return this._kernelInstance.getComponent(e).parameterGroups}resume(){this.muteKernelCallbacks||super.resume()}getSerializedConfiguration(e){return this._kernelInstance.getSerializedConfiguration(e)}createNewSerializedConfiguration(e){return this._kernelInstance.createNewSerializedConfiguration(e)}getCurrentConfigurationHash(e){return this._kernelInstance.getHashOfConfiguration(e)}isExternalObjectOrComponent(e){var t,n;return null!==(n=null===(t=this._kernelInstance)||void 0===t?void 0:t.isExternalPlanObject(e))&&void 0!==n&&n}listOfVariantsError(e,t){this._kernelIo.setMeta({rapiId:e}),this._kernelIo.error(t)}addDebugClient(e){this._kernelInstance.registerDebugClient(e)}}__decorate([inject],ConfiguratorKernelAccess.prototype,"_memoryManager",void 0),__decorate([inject],ConfiguratorKernelAccess.prototype,"_configuratorKernelAccessCallback",void 0),__decorate([inject],ConfiguratorKernelAccess.prototype,"_initData",void 0),__decorate([inject],ConfiguratorKernelAccess.prototype,"_configuratorHistory",void 0);class NodePlanElementViewModel extends PlanElementViewModel{constructor(e){super(e);const t=this.getPlanElement().getMaxWallHeight();this._container.position.y=(t<0?2800:t)/1e3+.1,this._container.name="Node Plan Element",this._nodeUiMesh=new DraggableNode("Wall draggable node"),this.addMesh(this._nodeUiMesh)}update(){super.update(),this._container.position.y=this.getPlanElement().getMaxWallHeight()/1e3+.1}setTopView(e){super.setTopView(e),e||(this._nodeUiMesh.visible=!1),this._updateBoundingBox()}getSize(){return this._topView?this._nodeUiMesh.getSize():new Vector3}show(){this._nodeUiMesh.visible=this._topView}hide(){this._nodeUiMesh.visible=!1}select(){this._nodeUiMesh.select(10526880),super.select()}deselect(){this._nodeUiMesh.select(0),super.deselect()}hoverOn(){this._nodeUiMesh.hoverOn(),super.hoverOn()}hoverOff(){this._nodeUiMesh.hoverOff(),super.hoverOff()}_generateBoundingBox(){const e=super._generateBoundingBox();return e.layers.set(9),e}setZoom(e){this._nodeUiMesh.scale.setScalar(e),this._updateBoundingBox()}}const TOP_BLACK_MATERIAL=MaterialCreator.createMeshStandardMaterial({transparent:!0,opacity:1,color:0}),GREY_DOOR_MATERIAL=MaterialCreator.createMeshStandardMaterial({transparent:!0,opacity:1,color:new Color$1("#B1B1B1"),side:DoubleSide}),GREY_ARCH_MATERIAL=MaterialCreator.createMeshStandardMaterial({transparent:!0,opacity:.4,color:new Color$1("#B1B1B1"),side:DoubleSide}),ARCH_OUTLINE_MATERIAL=new LineBasicMaterial({color:new Color$1("#7B7B7B")});class ConstructionTopView extends Object3D{constructor(e,t){super(),this._topDoorMeshes=[],this._topDoorOutlines=[],this._debugCircles=[],this._planElement=e,this._rapiItem=t,this._init()}_init(){var e;const t=this._planElement,n="door"===t.getObjectType(),a="window"===t.getObjectType(),{x:r,z:i}=convertToThreeDimensions(t.size),s=new BoxGeometry(r,.01,i);this._topGreyMesh=new Mesh(s,GREY_DOOR_MATERIAL),this.add(this._topGreyMesh);const o=new EdgesGeometry(s);this._topGreyMeshOutline=new LineSegments(o,ARCH_OUTLINE_MATERIAL),this._topGreyMesh.add(this._topGreyMeshOutline);const l=null===(e=t.getDoorArches)||void 0===e?void 0:e.call(t);if("door"===t.getObjectType()&&0===(null==l?void 0:l.size()))this._createSlidingBars(r,i);else if(l&&l.size()>0)for(let e=0;e<l.size();e++){const t=l.get(e),i=convertToThreeDimensions(t.getStartPointRelativeToObject()),s=convertToThreeDimensions(t.getEndPointRelativeToObject());if(a){const e=new BoxGeometry(r,.02,.03);this._topBlackMesh=new Mesh(e,TOP_BLACK_MATERIAL),this.add(this._topBlackMesh)}else if(n){const t=[new Vector3(i.x,i.y+.01,i.z),new Vector3(s.x,s.y+.01,s.z)],n=(new BufferGeometry).setFromPoints(t),a=new Line(n);a.geometry.computeBoundingSphere();const r=a.geometry.boundingSphere.radius,o=new CircleGeometry(2*r,16,0,Math.PI/2);this._topDoorMeshes[e]=new Mesh(o,GREY_ARCH_MATERIAL),this._topDoorMeshes[e].position.copy(i),this._topGreyMesh.add(this._topDoorMeshes[e]);const l=new EdgesGeometry(this._topDoorMeshes[e].geometry);this._topDoorOutlines[e]=new LineSegments(l,ARCH_OUTLINE_MATERIAL),this._topDoorMeshes[e].add(this._topDoorOutlines[e])}}this._updateDoor(),this.position.y=5}setTopView(e){this.visible=e}_createSlidingBars(e,t){const n=.55*e,a=new BoxGeometry(n,.005,.03);this._topSlidingBar1=new Mesh(a,TOP_BLACK_MATERIAL),this._topSlidingBar1.position.set(.225*-e,.005,t/5),this._topGreyMesh.add(this._topSlidingBar1);const r=new BoxGeometry(n,.005,.03);this._topSlidingBar2=new Mesh(r,TOP_BLACK_MATERIAL),this._topSlidingBar2.position.set(.225*e,.995,-t/5),this._topGreyMesh.add(this._topSlidingBar2);const i=new ConeGeometry(.03,.06,32),s=new MeshStandardMaterial({color:3355443}),o=new Mesh(i,s);o.position.set(-n/2,0,0),o.rotation.z=Math.PI/2,this._topSlidingBar2.add(o)}_createDoorArchesOnUpdate(e,t,n){const a=(new BufferGeometry).setFromPoints(t),r=new Line(a);r.geometry.computeBoundingSphere();const i=r.geometry.boundingSphere.radius,s=new CircleGeometry(2*i,16,0,Math.PI/2),o=new Mesh(s,GREY_ARCH_MATERIAL),l=new LineSegments(new EdgesGeometry(s),ARCH_OUTLINE_MATERIAL);o.position.copy(n),o.add(l),this._topGreyMesh.add(o),this._topDoorMeshes[e]=o,this._topDoorOutlines[e]=l}_updateDoor(){var e;const t=this._planElement;if("window"===t.getObjectType())return;const n=null===(e=t.getDoorArches)||void 0===e?void 0:e.call(t);if(n){for(let e=0;e<n.size();e++){const t=n.get(e),a=t.getOpeningDirection().value,r=convertToThreeDimensions(t.getStartPointRelativeToObject()),i=convertToThreeDimensions(t.getEndPointRelativeToObject()),s=[new Vector3(r.x,r.y+.01,r.z),new Vector3(i.x,i.y+.01,i.z)];this._topDoorMeshes[e]||this._createDoorArchesOnUpdate(e,s,r);const o=(new BufferGeometry).setFromPoints(s),l=new Line(o);l.geometry.computeBoundingSphere();const d=l.geometry.boundingSphere.radius;switch(this._topDoorMeshes[e].geometry=new CircleGeometry(2*d,16,0,Math.PI/2),a){case 0:this._topDoorMeshes[e].scale.set(1,-1,1),this._topDoorMeshes[e].position.copy(r);break;case 1:this._topDoorMeshes[e].scale.set(1,1,1),this._topDoorMeshes[e].position.copy(r);break;case 2:this._topDoorMeshes[e].scale.set(-1,1,1),this._topDoorMeshes[e].position.copy(i);break;case 3:this._topDoorMeshes[e].scale.set(-1,-1,1),this._topDoorMeshes[e].position.copy(i)}this._topDoorMeshes[e].rotation.x=-Math.PI/2,this._topDoorOutlines[e].geometry=new EdgesGeometry(this._topDoorMeshes[e].geometry)}for(let e=n.size();e<this._topDoorMeshes.length;e++)this._topGreyMesh.remove(this._topDoorMeshes[e]),this._topDoorMeshes.splice(e,1),this._topDoorOutlines.splice(e,1)}}_updateSlidingBars(){const{x:e,z:t}=convertToThreeDimensions(this._planElement.size),n=.55*e;this._topSlidingBar1.position.set(.225*-e,.005,t/5),this._topSlidingBar1.geometry=new BoxGeometry(n,.005,.03),this._topSlidingBar2.position.set(.225*e,1.005,-t/5),this._topSlidingBar2.geometry=new BoxGeometry(n,.005,.03);const a=this._topSlidingBar2.children.find(e=>e instanceof Mesh&&e.geometry instanceof ConeGeometry);a&&(a.position.set(-n/2,0,0),a.rotation.z=Math.PI/2)}_resetTopDoorMesh(e){e.position.y=-.01,e.position.x=0,e.rotation.x=0}update(){const{x:e,z:t}=convertToThreeDimensions(this._planElement.size);this._topGreyMesh.geometry=new BoxGeometry(e,.01,t),this._topGreyMeshOutline.geometry=new EdgesGeometry(this._topGreyMesh.geometry),this._topSlidingBar1&&this._topSlidingBar2&&this._updateSlidingBars(),this._topBlackMesh&&(this._topBlackMesh.geometry=new BoxGeometry(e,.02,.03)),this._updateDoor()}}class ConstructionPlanObjectViewModel extends StaticPlanObjectViewModel{constructor(e){super(e),this._container.name="Static Construction "+this._container.name}async setTopView(e){var t;super.setTopView(e),e&&!this._constructionTopView&&(await this.isInitDone(),this._constructionTopView=new ConstructionTopView(this.getPlanElement(),this.getRapiItem()),this._container.add(this._constructionTopView)),null===(t=this._constructionTopView)||void 0===t||t.setTopView(e),this.update()}getPlanElement(){return super.getPlanElement()}_generateBoundingBox(){const e=super._generateBoundingBox(),t=this.getSize();return e.geometry=new BoxGeometry(t.x,this._topView?5:t.y,t.z),e}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new BoxGeometry(this._topView?e.x+.2:e.x,this._topView?5:e.y,this._topView?e.z+.2:e.z)}getTopViewContainer(){return this._constructionTopView}getConstructionElementMeasurements(e,t,n){return calculateConstructionElementMeasurements(this,e,t,n)}update(){var e;super.update(),this.getObject()&&(this.getObject().visible=!this._topView),null===(e=this._constructionTopView)||void 0===e||e.update()}_setPositionOfBoundingBox(e,t){t.position.y=e.y/2}}const toMeasurementLineDimensionToTransferable=e=>({...transformMeasurement(e),id:e.id,lengthFormatted:e.lengthFormatted}),MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME={POINT1:"point1",POINT2:"point2"};class MeasurementLinePlanElementViewModel extends PlanElementViewModel{constructor(e){super(e),this._initializeContainer(),this._initializeLines(),this._initializeDraggables()}_initializeContainer(){this._container.name="Measurement Line Plan Element",this._container.position.copy(new Vector3(0,5,0))}_initializeLines(){this._lineMesh=this._createLine(0),this._subLine1=this._createLine(0),this._subLine2=this._createLine(0)}_createDraggableNodeBoundBox(e){const t=(new Box3).setFromObject(e).getSize(new Vector3),n=new BoxGeometry(t.x+.2,t.y,t.z+.2);let a=new Color$1("#DDDDDD");const r=this.getPlanElement().customColor;r>0&&(a=getColorFromInt(r));let i=MaterialCreator.createMeshStandardMaterial({color:a,opacity:1,transparent:!0});i.visible=!1;let s=new Mesh(n,i);return s.name="bounding box for draggable node",s.position.copy(e.position),s.castShadow=!1,s.receiveShadow=!1,s.layers.set(6),s}_initializeDraggables(){this._point1Draggable=new DraggableNode("point1 draggable"),this._point1Draggable.layers.set(6),this._point2Draggable=new DraggableNode("point2 draggable");const[e,t]=this._getMainLinePoints();this._point1Draggable.position.copy(e),this._point2Draggable.position.copy(t),this._point1BoundingBox=this._createDraggableNodeBoundBox(this._point1Draggable),this._point2BoundingBox=this._createDraggableNodeBoundBox(this._point2Draggable),this._point2Draggable.layers.set(6),this.addMesh(this._point1Draggable),this.addMesh(this._point2Draggable),this.addMesh(this._point1BoundingBox),this.addMesh(this._point2BoundingBox)}_createLine(e){const t=new LineBasicMaterial({color:e,linewidth:1}),n=new BufferGeometry,a=new Line(n,t);return a.layers.set(6),a.frustumCulled=!1,this.addMesh(a),a}getMeasurementLineDimension(){const[e,t]=this._getMainLinePoints(),n=e.clone().sub(t),{textDirection:a,textRotation:r}=getTextDirectionAndRotation(n),i=e.clone().add(t).divideScalar(2);return{id:this.getPlanElement().getId(),length:e.clone().multiplyScalar(1e3).distanceTo(t.clone().multiplyScalar(1e3)),textPosition3d:i,textRotation:r,fromPosition3d:e,toPosition3d:t,textDirection:a}}show(){this._container.visible=!0}hide(){this._container.visible=!1}hideAllSubLines(){this._subLine1.material.visible=!1,this._subLine2.material.visible=!1}showAllSubLines(){this._subLine1.material.visible=!0,this._subLine2.material.visible=!0}hideDraggableNodes(){this._point1Draggable.visible=!1,this._point2Draggable.visible=!1,this.showAllSubLines()}showDraggableNodes(){this._point1Draggable.visible=!0,this._point2Draggable.visible=!0,this.hideAllSubLines()}showPoint1DraggableNode(){this._point1Draggable.visible=!0,this._subLine2.material.visible=!0}showPoint2DraggableNode(){this._point2Draggable.visible=!0,this._subLine1.material.visible=!0}hidePoint1DraggableNode(){this._point1Draggable.visible=!1,this._subLine2.material.visible=!1}hidePoint2DraggableNode(){this._point2Draggable.visible=!1,this._subLine1.material.visible=!1}setTopView(e){super.setTopView(e),e?(this.show(),this.update()):this.hide()}update(){const[e,t]=this._getMainLinePoints(),n=this._calculateNormalVector(e,t);this._updateSubLineGeometry(this._subLine1,e,n),this._updateSubLineGeometry(this._subLine2,t,n),this.updatePointDraggableGeometry(this._point1Draggable,e),this.updatePointDraggableGeometry(this._point2Draggable,t),this._lineMesh.geometry.setFromPoints([e,t]),this._lineMesh.name="main measurement line",this._boundingBox.geometry=this._getGeometry(),this._point1BoundingBox.position.copy(e),this._point2BoundingBox.position.copy(t),this._point1BoundingBox.material.visible=!1,this._point2BoundingBox.material.visible=!1,this._point1BoundingBox.position.y=3.1,this._point2BoundingBox.position.y=3.1}_generateBoundingBox(){let e=new Color$1("#DDDDDD");const t=this.getPlanElement().customColor;t>0&&(e=getColorFromInt(t));let n=MaterialCreator.createMeshStandardMaterial({color:e,opacity:1,transparent:!0,side:DoubleSide}),a=new Mesh(this._getGeometry(),n);return a.name="bounding box",a.position.y=3,a.castShadow=!1,a.receiveShadow=!1,a.layers.set(6),a}_getGeometry(){const[e,t]=this._getMainLinePoints(),n=this._calculateNormalVector(e,t),a=e.clone().add(n.clone().multiplyScalar(.1)),r=e.clone().add(n.clone().multiplyScalar(-.1)),i=t.clone().add(n.clone().multiplyScalar(.1)),s=t.clone().add(n.clone().multiplyScalar(-.1)),o=new BufferGeometry,l=[a,i,s,r].reduce((e,t)=>[...e,t.x,t.y,t.z],[]);return o.setAttribute("position",new Float32BufferAttribute(l,3)),o.setIndex([0,1,2,2,3,0]),o.computeVertexNormals(),o}_getMainLinePoints(){const e=this.getPlanElement();return[convertToTHREE(e.getPoint1()),convertToTHREE(e.getPoint2())]}_calculateNormalVector(e,t){return e.clone().sub(t).cross(new Vector3(0,1,0)).normalize()}_updateSubLineGeometry(e,t,n){const a=t.clone().add(n.clone().multiplyScalar(.1)),r=t.clone().add(n.clone().multiplyScalar(-.1));e.geometry.setFromPoints([r,a])}updatePointDraggableGeometry(e,t){e.position.copy(t)}getPoint1Draggable(){return this._point1Draggable}getPoint2Draggable(){return this._point2Draggable}getPoint1DraggableBoundingBox(){return this._point1BoundingBox}getPoint2DraggableBoundingBox(){return this._point2BoundingBox}hidePreviewBox(){this._container&&this._boundingBox&&(this._boundingBox.material.visible=!1)}selectPoint1Draggable(){this._point1Draggable.select(10526880),super.select()}selectPoint2Draggable(){this._point2Draggable.select(10526880),super.select()}deselectPoint1Draggable(){this._point1Draggable.select(0),super.deselect()}deselectPoint2Draggable(){this._point2Draggable.select(0),super.deselect()}selectAllDraggablePoints(){this._point1Draggable.select(10526880),this._point2Draggable.select(10526880),super.select()}deselectAllDraggablePoints(){this._point1Draggable.select(0),this._point2Draggable.select(0),super.deselect()}hoverOnDragPoint1(){this._point1Draggable.hoverOn(),super.hoverOn()}hoverOnDragPoint2(){this._point2Draggable.hoverOn(),super.hoverOn()}hoverOffDragPoint1(){this._point1Draggable.hoverOff(),super.hoverOff()}hoverOffDragPoint2(){this._point2Draggable.hoverOff(),super.hoverOff()}selectPointOnDragStart(e){this.showAllSubLines(),e.deselectAllDraggablePoints(),e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT1?e.selectPoint1Draggable():e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT2&&e.selectPoint2Draggable()}hideDraggablePointsOnDragStart(e,t){e.deselectAllDraggablePoints(),t===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT1?(e.hidePoint1DraggableNode(),e.selectPoint1Draggable()):t===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT2&&(e.hidePoint2DraggableNode(),e.selectPoint2Draggable())}showDraggablePointsOnDragEnd(e,t){t===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT1?e.showPoint1DraggableNode():t===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT2&&e.showPoint2DraggableNode(),this.hideAllSubLines()}handleDraggablePointsSelection(e){e.deselectAllDraggablePoints(),e.currentPoint&&e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT1?e.selectPoint1Draggable():e.currentPoint&&e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT2&&e.selectPoint2Draggable()}showDraggablePointsOnHoverOn(e){e.currentPoint&&e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT1?e.hoverOnDragPoint1():e.currentPoint&&e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT2&&e.hoverOnDragPoint2()}showDraggablePointsOnHoverOff(e){e.currentPoint&&e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT1?e.hoverOffDragPoint1():e.currentPoint&&e.currentPoint===MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME.POINT2&&e.hoverOffDragPoint2()}}class ConfigurableConstructionPlanObjectViewModel extends ConfiguratorPlanObjectViewModel{constructor(e){super(e),this._container.name="Configurable Construction "+this._container.name}getConstructionElementMeasurements(e,t,n){return calculateConstructionElementMeasurements(this,e,t,n)}setRapiItem(e){this._rapiItem=e}_updateBoundingBox(){super._updateBoundingBox();const e=this.getSize();this._boundingBox.geometry=new BoxGeometry(this._topView?e.x+.2:e.x,this._topView?5:e.y,this._topView?e.z+.2:e.z)}async setTopView(e){var t;super.setTopView(e),e&&!this._constructionTopView&&(await this.isInitDone(),this._constructionTopView=new ConstructionTopView(this.getPlanElement(),this._rapiItem),this._container.add(this._constructionTopView)),null===(t=this._constructionTopView)||void 0===t||t.setTopView(e),this.update()}getTopViewContainer(){return this._constructionTopView}update(){var e;super.update(),this.getObject()&&(this.getObject().visible=!this._topView),null===(e=this._constructionTopView)||void 0===e||e.update(),this._container.position.copy(convertToTHREE(this._topView?this.getPlanElement().getCenter():this.getPlanElement().getMeshCenter()))}getPlanElement(){return super.getPlanElement()}_setPositionOfBoundingBox(e,t){t.position.y=e.y/2}}class PlannerKernelAccess extends ConfiguratorKernelAccess{get kernelContainer(){return this._kernelContainer}constructor(e){super(e),this._plannerKernelCallbackListener=new Set}_loadSuccess(){super._loadSuccess(),window.RoomleCore&&window.RoomleCore(this._kernelContainer)}_loadError(){super._loadError(),console.error("kernel load error")}_createPlanInteractionHandler(){var e,t,n;this._planInteractionHandler=new this._kernelContainer.PlanInteractionHandler;const a=null!==(n=null===(t=null===(e=this._initData)||void 0===e?void 0:e.featureFlags)||void 0===t?void 0:t.advancedDocking)&&void 0!==n&&n,r=a?this._kernelContainer.SnapMode.ON_COLLISION_ROTATE_WITHIN_DISTANCE:this._kernelContainer.SnapMode.ON_COLLISION;this._planInteractionHandler.init(this._planInteractionHandler,1,50,r,r,this._initData.snappingEnabled,this._kernelContainer.DrawingType.CLICK_PER_CLICK),this._planInteractionHandler.enableSnap=!0,this._planInteractionHandler.dockWhenSnap=a,this._planInteractionHandler.unDockOnMove=a,this._planInteractionHandler.enableRaster=!0,this._planInteractionHandler.unit=this._initData.unit||"cm",this._planInteractionHandler.showChildrenOfPlanObjects={value:CORE_CHILD_ENTITY_MODE.OFF},a&&(this._planInteractionHandler.enableSnap=!0),this._roomlePlannerUiCallback.onPlanInteractionHandlerCreated(this._planInteractionHandler)}addPlannerListener(e){this._plannerKernelCallbackListener.add(e)}removePlannerListener(e){this._plannerKernelCallbackListener.delete(e)}isReady(){super.isReady(),this.registerCallbacks(),this._roomlePlannerUiCallback.onPlannerKernelIsReady(this._kernelContainer),this._roomlePlannerUiCallback.onConfiguratorKernelIsReady(this._kernelContainer,this._kernelInstance),Env.isProduction||(window.__RML__DEBUG__.ConfiguratorKernel=this._kernelInstance,window.__RML__DEBUG__.PlannerKernelContainer=this._kernelContainer),this._kernelAccessCallback.isReady()}_setupKernel(){0===this._kernelType&&(this._createPlanInteractionHandler(),AppContext.kernelInstance?this._kernelInstance=AppContext.kernelInstance:this._kernelInstance=this._planInteractionHandler.getConfiguratorKernel()),super._setupKernel()}get callbacks(){return this._roomlePlannerUiCallback}get planInteractionHandler(){return this._planInteractionHandler}get planModelViewHelper(){return this._kernelContainer.PlanModelViewHelper}catalogItemLoaded(e){var t;const n=this._rapiItemToKernelItem(e);null===(t=this.planInteractionHandler)||void 0===t||t.catalogItemLoaded(n)}async insertItems(e){this.planInteractionHandler.startInteraction();let t=new this._kernelContainer.CatalogItemPtrList;e.forEach(e=>{let n=e.count||1;for(let a=0;a<n;a++)e.count||(e.count=0),t.push_back(this._rapiItemToKernelItem(e))});const n=this.planInteractionHandler.getPlan().extRef.jsObject,a=n.getPlanObjectViewModelsFromRapiId().reduce((e,t)=>(e[t.getId()]=!0,e),{});this.planInteractionHandler.addPlanObjects(t,!0),await Promise.allSettled([Promise.allSettled(n.getStaticPlanObjectViewModels().map(async e=>{if(e.needsRapiItem()){const t=await this._rapiAccess.getItem(e.getPlanObject().getCatalogItemId());e.setRapiItem(t)}})),Promise.allSettled([...n.getConfigurablePlanObjectViewModels().map(e=>e.isInitDone()),...n.getConfigurableConstructionPlanObjectViewModels().map(async e=>{if(e instanceof ConfigurableConstructionPlanObjectViewModel){const t=await this._rapiAccess.getItem(e.getPlanObject().getCatalogItemId());e.setRapiItem(t)}return e.isInitDone()})])]);const r=n.getPlanObjectViewModelsFromRapiId().filter(e=>{const t=e.getObject();return(null==t?void 0:t.isRootComponent)||!(null==t?void 0:t.isChildPlanObject)}).map(e=>e.getId()).filter(e=>!a[e]);return this.planInteractionHandler.endInteraction(),r}duplicateItems(e){const t=new this.kernelContainer.PlanObjectPtrList;return e.forEach(e=>{t.push_back(e)}),this.planInteractionHandler.duplicatePlanObjects(t,1,!0)}_rapiItemToKernelItem(e){let t=new this._kernelContainer.CatalogItem(e.id),n=t.size;return n.x=e.width||0,n.y=e.depth||0,n.z=e.height||0,t.size=n,t.flipable=e.flipable,e.layer&&(t.layer=e.layer),t.orderable=e.orderable,t.scaleable=e.scaleable,t.type=e.type||"other",t.detailType=e.detailType||t.type||"other",t.configuration=e.configuration||"",t}planObjectDeleted(){}requestPlanObjectDimensions(){}cleanUpCallbacks(){var e;super.cleanUpCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.unregisterPlannerCallback)&&this._kernelContainer.unregisterPlannerCallback(this)}registerCallbacks(){var e;super.registerCallbacks(),(null===(e=this._kernelContainer)||void 0===e?void 0:e.registerPlannerCallback)&&this._kernelContainer.registerPlannerCallback(this)}planElementRemoved(e){this._plannerKernelCallbackListener.forEach(t=>t.planElementRemoved(e)),this._plannerKernelCallbackListener.forEach(t=>t.removePlanObjectFromScene(e.extRef.jsObject)),this._decoupleReferences(e)}handlerSwitchedPlans(e,t){this._decoupleReferences(e),t&&this._plannerKernelCallbackListener.forEach(n=>n.handlerSwitchedPlans(e,t))}planBoundsChanged(){this._plannerKernelCallbackListener.forEach(e=>e.planBoundsChanged())}planCleared(){this._plannerKernelCallbackListener.forEach(e=>e.planCleared())}planCompletelyLoaded(e){this._plannerKernelCallbackListener.forEach(t=>t.planCompletelyLoaded(e))}planElement3dMeshChanged(e,t){if(t.extRef){const e=t.extRef.jsObject;for(let t=e.getObject().children.length-1;t>=0;t--)e.getObject().remove(e.getObject().children[t])}this.planModelViewHelper.requestMesh3d(t)}async _onStaticItemAdded(e,t){let n;n=this.isConstructionPlanElement(t)?new ConstructionPlanObjectViewModel(t):new StaticPlanObjectViewModel(t),this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n);const a=t.getCatalogItemId();if(a){const e=await this._rapiAccess.getItem(a);n.setRapiItem(e),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}}_onConfigurableItemAdded(e,t){const n=new ConfiguratorPlanObjectViewModel(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}_onConfigurableConstructionItemAdded(e,t){const n=new ConfigurableConstructionPlanObjectViewModel(t);this.coupleReferences(n,t),e.extRef.jsObject.addPlanElementViewModel(n),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(n))}async planElementAdded(e,t){if(e&&e.extRef)if(t.getType()===this._kernelContainer.PlanElementType.OBJECT){const n=t.getConfigurationRuntimeId();t.hasConfiguration()||n>0?"door"===t.getObjectType()||"window"===t.getObjectType()?this._onConfigurableConstructionItemAdded(e,t):this._onConfigurableItemAdded(e,t):await this._onStaticItemAdded(e,t)}else{const n=t;let a;if(t.getType()===this._kernelContainer.PlanElementType.WALL?a=new WallPlanElementViewModel(n):t.getType()===this._kernelContainer.PlanElementType.FLOOR?a=new FloorPlanElementViewModel(n):t.getType()===this._kernelContainer.PlanElementType.CEILING?a=new CeilingPlanElementViewModel(n):t.getType()===this._kernelContainer.PlanElementType.NODE?a=new NodePlanElementViewModel(n):t.getType()===this._kernelContainer.PlanElementType.MEASURE&&(a=new MeasurementLinePlanElementViewModel(n)),!a)return;this.coupleReferences(a,n),e.extRef.jsObject.addPlanElementViewModel(a),this.planModelViewHelper.requestMesh3d(t),this._plannerKernelCallbackListener.forEach(e=>e.addPlanObjectToScene(null))}}planElementChanged(e,t){if(t.extRef){let n=t.extRef.jsObject;n.update(),this._plannerKernelCallbackListener.forEach(t=>t.planElementChanged(e,n))}}planHistoryStateChanged(){this.planInteractionHandler&&(this._plannerKernelCallbackListener.forEach(e=>e.planHistoryStateChanged()),this._roomlePlannerUiCallback.onHistoryChange(this.planInteractionHandler.isUndoPossible(),this.planInteractionHandler.isRedoPossible()))}planObjectConfigurationCreated(e,t){}externalObjectConfigurationChanged(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();this._kernelInstance.isExternalPlanObject(e)&&this._externalObjectConfigurationChanged(e,n)}}externalObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();this._kernelInstance.isExternalPlanObject(e)&&this._externalObjectConfigurationLoaded(e,n)}}externalObjectConfigurationDeleted(e,t,n){e&&e.extRef&&t&&n&&this._externalObjectConfigurationDeleted(n)}externalObjectComponentDeleted(e,t,n,a){e&&e.extRef&&t&&this._externalObjectComponentDeleted(n,a)}externalObjectConfigurationDuplicated(e,t,n,a){e&&e.extRef&&t&&n&&this._externalObjectConfigurationDuplicated(n,a)}externalObjectConfigurationMoved(e,t,n){e&&e.extRef&&t&&n.groupId&&this._externalObjectConfigurationsMoved(n)}externalObjectConfigurationsMerged(e,t,n,a){e&&e.extRef&&t&&n.groupId&&a&&this._externalObjectConfigurationsMerged(n,a)}externalObjectComponentSplitOff(e,t,n){e&&e.extRef&&t&&n.length>0&&this._externalObjectComponentSplitOff(n)}externalObjectArrangementChanged(e,t,n){e&&e.extRef&&t&&this._externalObjectArrangementChanged(n)}async planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let a=t.extRef.jsObject,r=a.getPlanObject().getConfigurationRuntimeId();if(a instanceof ConfigurableConstructionPlanObjectViewModel){const e=t.getCatalogItemId();if(e){const t=await this._rapiAccess.getItem(e);a.setRapiItem(t)}}r>0&&this._plannerKernelCallbackListener.forEach(a=>a.planObjectConfigurationLoaded(e,t,n))}}requestCatalogItem(e){this._plannerKernelCallbackListener.forEach(t=>t.requestCatalogItem(e))}startedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.startedDrawing())}stoppedDrawing(){this._plannerKernelCallbackListener.forEach(e=>e.stoppedDrawing())}updateMesh2d(){}beginConstruction(){}addMesh(e,t,n,a,r,i){this._plannerKernelCallbackListener.forEach(s=>s.addMesh(e,t,n,a,r,i))}endConstruction(){}beginPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.beginPlanConstruction(e))}addPlanMesh(e,t,n,a,r,i,s){this._plannerKernelCallbackListener.forEach(o=>o.addPlanMesh(e,t,n,a,r,i,s))}endPlanConstruction(e){this._plannerKernelCallbackListener.forEach(t=>t.endPlanConstruction(e))}createPlanFromObject(e,t,n){return n=n||0===n?n:0,t=t||{x:0,y:0,z:0},this._planInteractionHandler.createPlanWithObjectFromItem(this._rapiItemToKernelItem(e),t,n)}async addPlanObjectFromItem(e,t,n){if(!t&&!n){const t=await this.insertItems([e]);if(1!==t.length)throw new Error("It was expected that 1 element is added but"+t.length+"were added");return t[0]}n=n||0===n?n:0,t=t||{x:0,y:0,z:0};const a=this._planInteractionHandler.addPlanObjectFromItem(this._rapiItemToKernelItem(e),t,n,!1),r=this._planInteractionHandler.getPlan().extRef.jsObject;let i;return a.hasConfiguration()?(i=r.getConfigurablePlanObjectForId(a.getId()),i||console.warn("Could not find configuration")):(i=r.getStaticPlanObjectViewModelForId(a.getId()),i?await i.setRapiItem(e):console.warn("Could not find static item")),await i.isInitDone(),i.getId()}coupleReferences(e,t){let n=new this._kernelContainer.EMSReference;n.jsObject=e,t.extRef=n}_decoupleReferences(e){e&&e.extRef&&(e.extRef.jsObject.clearReference(),e.extRef.jsObject=null,e.extRef.delete(),e.extRef=null)}isConstructionPlanElement(e){return e instanceof this.kernelContainer.ConstructionObject}planObjectSelectionChanged(e,t){if(!this._kernelInstance.isExternalPlanObject(e))return;const n=this._kernelInstance.getPlanObject(e);if(0===n.id)return;const a=e===t?n.rootPlanComponentId:t,r=this._kernelInstance.getComponent(a);this._componentSelectionChanged(n,r,!1)}_componentSelectionChanged(e,t,n){if(t.externalComponent){const e=this._planInteractionHandler.getPlan(),a=n?this._kernelInstance.getExternalComponentModuleIds(t.id):this.planModelViewHelper.getExternalComponentModuleIdsForSelection(e,t.hash,"");this._roomlePlannerUiCallback.onExternalObjectModuleSelected(a.groupId,""===a.rootModuleId?null:a.rootModuleId,""===a.subModuleId?null:a.subModuleId)}}_externalObjectParameterChanged(e,t,n){let a,r=this._kernelInstance.getPlanObject(e);0===r.id?(r=this._kernelInstance.getPlanObjectFromPlanComponent(e),a=this._kernelInstance.getComponent(e)):a=this._kernelInstance.getComponent(r.rootPlanComponentId),r.externalId,a.hash,this._roomlePlannerUiCallback.onExternalObjectAttributeChanged(r.externalId,a.hash,t,n)}_externalObjectConfigurationChanged(e,t){let n=this._kernelInstance.getPlanObject(e);n.externalId,n.id,this._roomlePlannerUiCallback.onExternalObjectGroupChanged(t)}_externalObjectConfigurationLoaded(e,t){let n=this._kernelInstance.getPlanObject(e);n.externalId,n.id,this._roomlePlannerUiCallback.onExternalObjectGroupLoaded(t)}_externalObjectConfigurationDeleted(e){this._roomlePlannerUiCallback.onDeleteExternalObjectGroup(e)}_externalObjectComponentDeleted(e,t){Array.isArray(e)?this._roomlePlannerUiCallback.onDeleteExternalObjectRootModule(e[0],t,e.slice(1)):this._roomlePlannerUiCallback.onDeleteExternalObjectRootModule(e,t)}_externalObjectConfigurationDuplicated(e,t){this._roomlePlannerUiCallback.onDuplicateExternalObjectGroup(e,t)}_externalObjectConfigurationsMoved(e){e.groupId,this._roomlePlannerUiCallback.onMovedExternalObjectGroup(e)}_externalObjectConfigurationsMerged(e,t){e.groupId,this._roomlePlannerUiCallback.onMergeExternalObjectGroup(e,t)}_externalObjectComponentSplitOff(e){if(e.length>1){e[0].groupId;const t=e.slice(1);this._roomlePlannerUiCallback.onSplitExternalObjectGroup(e[0],1===t.length?t[0]:t)}}_externalObjectArrangementChanged(e){e.groupId,this._roomlePlannerUiCallback.onExternalObjectGroupArrangementChanged(e)}planSnapshotCreated(e){e.id,this._roomlePlannerUiCallback.onPlanSnapshotCreated(e.id)}requestDeleteComponents(e){const t=[],n=[];for(const a of e)this._kernelInstance.isExternalPlanObject(a)?n.push(a):t.push(a);t.length>0&&super.requestDeleteComponents(t);for(const e of n)this._externalPlanComponentDeleted(e)}requestDeleteComponent(e){this._kernelInstance.isExternalPlanObject(e)?this._externalPlanComponentDeleted(e):super.requestDeleteComponent(e)}requestDeletePlanComponent(e){this._kernelInstance.isExternalPlanObject(e)?this._externalPlanComponentDeleted(e):super.requestDeletePlanComponent(e)}_externalPlanComponentDeleted(e){const t=this._planInteractionHandler.getPlan(),n=this.planModelViewHelper.getObjectComponent(t,e);if(0!==n.runtimeId){const e=n.configurationHash,t=n.componentId;2===n.type.value?this._planInteractionHandler.removeObjectWithId(t):this._roomlePlannerUiCallback.onDeleteExternalObjectSubModule(e,t)}}dockExternalObjectComponent(e,t,n,a){const r=this._kernelInstance.getExternalObjectDocking(n,a,e,t);r.groupId&&(r.groupId,r.parentModuleId,r.moduleName)}}__decorate([inject],PlannerKernelAccess.prototype,"_kernelAccessCallback",void 0),__decorate([inject],PlannerKernelAccess.prototype,"_roomlePlannerUiCallback",void 0);class PlannerMeshGenerator extends MeshGenerator{constructor(e){super(e),this._wallMeshes=[],this._defaultMaterial=MaterialCreator.createMeshPhysicalMaterial({color:"#ffffff",side:DoubleSide})}generateGeometry(e=null,t,n,a,r,i=!1){let s;return s=i?this._generateGeometry(e,t,n,a,r).clone():this._generateGeometry(e,t,n,a,r),s}generateMesh(e=0,t=null,n,a,r,i,s,o,l=!1,d){let c;c=l?this._generateGeometry(t,a,r,i,s).clone():this._generateGeometry(t,a,r,i,s);const h=this._createMesh(e,t,c);return h.userData.materialId=n,h.layers.set(4),h.userData.isPlanFloor=o&&3===o.value,h.userData.isPlanWall=o&&1===o.value,n&&this.setMaterial(h,n,o,d).then(()=>{e&&t&&n&&this._geometryComponentMaterialCache.set(this._getComponentMeshId(e,t),n),h.castShadow=!h.userData.isPlanFloor&&!h.userData.isPlanWall}),this._checkWallMaterial(h,o),h}async setMaterial(e,t,n,a){if(e.userData.materialId=getMaterialId(t,n),isString(t))t?await this._assignMaterial(e,t,a):(console.warn("Used default material because material is empty"),this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)));else{if(!t)return void this.changeMaterialOfMesh(e,this._configuratorPreviewMaterial);2===(t=t).getSourceType().value?await this._assignMaterial(e,t.materialId,a):1===t.getSourceType().value?await this._assignItem(e,t.catalogItemId):3===t.getSourceType().value?await this._assignRGB(e,t.rgbValue):0===t.getSourceType().value?this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)):(this.changeMaterialOfMesh(e,this._getDefaultMaterial(n)),1!==n.value&&7!==n.value&&3!==n.value&&console.warn("Used default material because material is not supported",t))}}_getDefaultMaterial(e){return 3===(null==e?void 0:e.value)?this._defaultMaterialFloor:this._defaultMaterial}set maxAnisotropy(e){this._maxAnisotropy=e}_checkWallMaterial(e,t){t&&1===t.value&&(e.renderOrder=5,this._wallMeshes.push(e))}clear(){super.clear(),this.clearWallMeshes()}clearWallMeshes(){this._wallMeshes.forEach(e=>{disposeMesh(e)}),this._wallMeshes=[]}get wallMeshes(){return this._wallMeshes}}let KERNEL_UNIT={InchFeet:null,Feet:null,MM:null,CM:null,Inch:null},KERNEL_UNIT_STRING_TYPE={NoUnitString:null,LongUnitString:null,ShortUnitString:null};const METRIC_UNIT_TYPES=["mm","cm","feet"],IMPERIAL_UNIT_TYPES=["inch","inchfeet"];class UnitFormatter{constructor(e){this._formatter=null,this._precision=0,this._creator_=e}init(e){const t=new e.UnitMeasureFormatter;KERNEL_UNIT=e.Unit,KERNEL_UNIT_STRING_TYPE=e.UnitStringType,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType();const{precisionCm:n,precisionInch:a}=this._initData;this._actualUnit===KERNEL_UNIT.InchFeet?this._precision=void 0!==a?parseInt(a,10):2:this._actualUnit===KERNEL_UNIT.CM&&(this._precision=void 0!==n?parseInt(n,10):1),t.init("mm","cm","'","ft",'"',"inch","m²","sqft",!0,this._precision,!0),this._formatter=t}_initMeasurementSystemType(){let{measurementSystem:e,unit:t}=this._initData;if(this._actualMeasurementString=e,e||!t){if("metric"===e){t||(t="cm");const e=METRIC_UNIT_TYPES.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not a metric unit, using CM"),this._actualUnit=KERNEL_UNIT.CM,this._actualUnitString="cm")}if("imperial"===e){t||(t="inch");const e=IMPERIAL_UNIT_TYPES.find(e=>e===t);e?(this._actualUnit=this._getKernelUnitEnum(t),this._actualUnitString=e):(console.warn("Unit is not an imperial unit, using Inches"),this._actualUnit=KERNEL_UNIT.Inch,this._actualUnitString="inch")}}else{this._actualUnitString=t;const e=METRIC_UNIT_TYPES.find(e=>e===t);this._actualMeasurementString=e?"metric":"imperial"}}_initActualUnit(){const{unit:e}=this._initData;this._actualUnit=this._getKernelUnitEnum(e)}_getKernelUnitEnum(e){switch(e){case"cm":return KERNEL_UNIT.CM;case"mm":return KERNEL_UNIT.MM;case"inchfeet":return KERNEL_UNIT.InchFeet;case"feet":return KERNEL_UNIT.Feet;case"inch":return KERNEL_UNIT.Inch;default:return KERNEL_UNIT.CM}}_initActualUnitStringType(){const{unitStringType:e}=this._initData;e&&"short"!==e&&console.warn("Only short unit strings is supported at the moment"),this._actualUnitStringType=KERNEL_UNIT_STRING_TYPE.ShortUnitString}_isFormatterReady(){return!!this._formatter||(console.warn("Formatter is not ready..."),!1)}formatAngleValueToUnitString(e,t){const n="Integer"===t.type?0:2;return e.toFixed(n)+"°"}parseAngleValueFromUnitString(e){return e.replace("°","").replace(/\s/g,"")}parseValue(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?e:"length"===t.unitType?this.parseMMValueFromUnitString(e,t.unitType):"angle"===t.unitType||"area"===t.unitType?this.parseAngleValueFromUnitString(e):e}formatValueToUnitString(e,t){return null===t.unitType||"unknown"===t.unitType||"count"===t.unitType?"Integer"===t.type?e.toString():parseFloat(e.toString()).toFixed(2):"length"===t.unitType?this.formatMMValueToUnitString(e,t.unitType):"angle"===t.unitType?this.formatAngleValueToUnitString(e,t):"area"===t.unitType?this.formatSquareMMValueToUnitString(e):e}isParseableNumber(e){return this._isFormatterReady()?this._formatter.isParseableNumber(e):null}isParseableUnitString(e,t){return this._isFormatterReady()?"angle"===t.unitType?this._formatter.isParseableUnitString(this.parseAngleValueFromUnitString(e),this._actualUnit):this._formatter.isParseableUnitString(e,this._actualUnit):null}parseMMValueFromUnitString(e,t){return this._isFormatterReady()?"count"===t?parseFloat(e):this._formatter.parseMMValueFromUnitString(e,this._actualUnit):null}parseNumber(e){return this._isFormatterReady()?this._formatter.parseNumber(e):null}formatNumber(e,t=0){return this._isFormatterReady()?this._formatter.formatNumber(e,t):null}formatSquareMMValueToUnitString(e){return this._isFormatterReady()?this._formatter.formatSquareMMValueToUnitString(e,this._actualUnit):null}formatMMValueToUnitString(e,t){return this._isFormatterReady()?"count"===t?e.toString():this._formatter.formatMMValueToUnitString(e,this._actualUnit,this._actualUnitStringType):null}formatMMValueWithReqMaxLength(e,t){return this._isFormatterReady()?this._formatter.formatMMValueWithReqMaxLength(e,this._actualUnit,t):null}_formatParameterValue(e,t){return"length"===t?this.formatMMValueToUnitString(parseFloat(e)):"area"===t?this.formatSquareMMValueToUnitString(parseFloat(e)):e}formatPartListParameter(e){(function(e){return"length"===e.unitType||"area"===e.unitType})(e)&&(e.valueLabel=this._formatParameterValue(e.value,e.unitType))}formatParameter(e){if(e.valueLabel=this._formatParameterValue(e.value,e.unitType),isMaterial(e))e.uiType="Material";else if(function(e){return"Boolean"===e.type}(e))e.uiType="Boolean";else if(isRange(e)){e.uiType="Range";const t=null!==e.validRange.valueFrom?e.validRange.valueFrom:Number.MIN_SAFE_INTEGER,n=null!==e.validRange.valueTo?e.validRange.valueTo:Number.MAX_SAFE_INTEGER;e.validRangeLabels={valueFrom:this._formatParameterValue(t.toString(),e.unitType),valueTo:this._formatParameterValue(n.toString(),e.unitType),type:e.validRange.type}}else isOptions(e)?(e.uiType="Options",function(e){return!!isOptions(e)&&Array.isArray(e.validValues)&&e.validValues.length>0&&"string"==typeof e.validValues[0].thumbnail}(e)&&(e.uiType="Thumbnails")):(console.error("Could not detect uiType of param"),e.uiType=null)}isInch(){return this._actualUnit===KERNEL_UNIT.InchFeet}getActualUnitString(){return this._actualUnitString}getActualMeasurementString(){return this._actualMeasurementString}getUnitStringType(){return this._initData.unitStringType}getPrecision(){return this._precision}getAllowedDelta(){const e=1/Math.pow(10,this._precision);return this.isInch()?25.4*e:e}setUnitInitData(e,t=""){this._initData.unit=e,this._initData.measurementSystem=t,this._initActualUnit(),this._initMeasurementSystemType(),this._initActualUnitStringType(),this._plannerKernelAccess.kernelInstance.setEnvironmentVariable("unit",this._actualUnitString)}}__decorate([inject],UnitFormatter.prototype,"_initData",void 0),__decorate([inject],UnitFormatter.prototype,"_plannerKernelAccess",void 0);class ConfiguratorHistory{constructor(e){this._history=[],this._index=0,this._creator_=e}undo(){if(!this.canUndo())return null;this._index++;const[e]=this._history.slice(this._index);return this._index===this._history.length-1?this._configuratorUiCallbacks.onHistoryChange(!1,!0):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}redo(){if(!this.canRedo())return null;this._index--;const[e]=this._history.slice(this._index);return 0===this._index?this._configuratorUiCallbacks.onHistoryChange(!0,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!0),e}push(e){const[t]=this._history.slice(this._index);t!==e&&(this._history=this._history.slice(this._index),this._history.unshift(e),this._index=0,1===this._history.length?this._configuratorUiCallbacks.onHistoryChange(!1,!1):this._configuratorUiCallbacks.onHistoryChange(!0,!1))}canUndo(){return this._index!==this._history.length-1}canRedo(){return 0!==this._index}getHistory(){return this._history}clearHistory(){this._history=[],this._index=0,this._configuratorUiCallbacks.onHistoryChange(!1,!1)}}__decorate([inject],ConfiguratorHistory.prototype,"_configuratorUiCallbacks",void 0);const PLAN_ELEMENT_CHANGE_TYPES={ADDED:"added",CHANGED:"changed",REMOVED:"removed"};class RoomleToolsCore{constructor(e){this._kernelCallbacks={isReady:()=>{},throw:e=>console.error("Kernel exception",e),log:e=>{},error:(e,t,n,a)=>{},message:e=>{this._analyzeComponentCallback&&this._analyzeComponentCallback(e)}},this._creator_=e}async init(){if(this._toolsCoreInstance)return Promise.resolve();const e=this,t={locateFile:e=>"RoomleToolsCore.wasm"===e?getAssetPath()+"static/RoomleToolsCore-9c348432c6d79392.wasm":e,wasmBinaryFile:getAssetPath()+"static/RoomleToolsCore-9c348432c6d79392.wasm",preRun:[],postRun:[],setStatus:null,print(t){e._kernelIo.log(t)},printErr(t){e._kernelIo.error(t)},quit(t){0!==t&&e._kernelIo.throw(t&&t.toString?t.toString():"Unknown error while C/C++ main executes")}};await this._scriptLoader.fetch("static/RoomleToolsCore-5dffa0f3345223bd.js",{id:"core-tool"});const n=await window.RoomleToolsCore(t);n.setContext(this._kernelCallbacks),this._toolsCoreInstance=new n.ToolsCore}analyzeComponent(e,t){const n=[];return this._analyzeComponentCallback=e=>{n.push(e)},this._toolsCoreInstance.analyzeComponent(e,t),this._analyzeComponentCallback=null,Promise.resolve(n)}}__decorate([inject],RoomleToolsCore.prototype,"_scriptLoader",void 0),__decorate([inject],RoomleToolsCore.prototype,"_kernelIo",void 0);
|
|
2
|
-
/*!
|
|
3
|
-
fflate - fast JavaScript compression/decompression
|
|
4
|
-
<https://101arrowz.github.io/fflate>
|
|
5
|
-
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
6
|
-
version 0.8.2
|
|
7
|
-
*/
|
|
8
|
-
var u8=Uint8Array,u16=Uint16Array,i32=Int32Array,fleb=new u8([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fdeb=new u8([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),clim=new u8([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(e,t){for(var n=new u16(31),a=0;a<31;++a)n[a]=t+=1<<e[a-1];var r=new i32(n[30]);for(a=1;a<30;++a)for(var i=n[a];i<n[a+1];++i)r[i]=i-n[a]<<5|a;return{b:n,r}},_a=freb(fleb,2),fl=_a.b,revfl=_a.r;fl[28]=258,revfl[258]=28;for(var fd=freb(fdeb,0).b,rev=new u16(32768),i=0;i<32768;++i){var x=(43690&i)>>1|(21845&i)<<1;x=(61680&(x=(52428&x)>>2|(13107&x)<<2))>>4|(3855&x)<<4,rev[i]=((65280&x)>>8|(255&x)<<8)>>1}var hMap=function(e,t,n){for(var a=e.length,r=0,i=new u16(t);r<a;++r)e[r]&&++i[e[r]-1];var s,o=new u16(t);for(r=1;r<t;++r)o[r]=o[r-1]+i[r-1]<<1;if(n){s=new u16(1<<t);var l=15-t;for(r=0;r<a;++r)if(e[r])for(var d=r<<4|e[r],c=t-e[r],h=o[e[r]-1]++<<c,u=h|(1<<c)-1;h<=u;++h)s[rev[h]>>l]=d}else for(s=new u16(a),r=0;r<a;++r)e[r]&&(s[r]=rev[o[e[r]-1]++]>>15-e[r]);return s},flt=new u8(288);for(i=0;i<144;++i)flt[i]=8;for(i=144;i<256;++i)flt[i]=9;for(i=256;i<280;++i)flt[i]=7;for(i=280;i<288;++i)flt[i]=8;var fdt=new u8(32);for(i=0;i<32;++i)fdt[i]=5;var flrm=hMap(flt,9,1),fdrm=hMap(fdt,5,1),max=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},bits=function(e,t,n){var a=t/8|0;return(e[a]|e[a+1]<<8)>>(7&t)&n},bits16=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},ec=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],err=function(e,t,n){var a=new Error(t||ec[e]);if(a.code=e,Error.captureStackTrace&&Error.captureStackTrace(a,err),!n)throw a;return a},et=new u8(0);function unzlibSync(e,t){return function(e,t,n,a){var r=e.length,i=a?a.length:0;if(!r||t.f&&!t.l)return n||new u8(0);var s=!n,o=s||2!=t.i,l=t.i;s&&(n=new u8(3*r));var d=function(e){var t=n.length;if(e>t){var a=new u8(Math.max(2*t,e));a.set(n),n=a}},c=t.f||0,h=t.p||0,u=t.b||0,p=t.l,m=t.d,g=t.m,_=t.n,f=8*r;do{if(!p){c=bits(e,h,1);var v=bits(e,h+1,3);if(h+=3,!v){var S=e[(R=4+((h+7)/8|0))-4]|e[R-3]<<8,w=R+S;if(w>r){l&&err(0);break}o&&d(u+S),n.set(e.subarray(R,w),u),t.b=u+=S,t.p=h=8*w,t.f=c;continue}if(1==v)p=flrm,m=fdrm,g=9,_=5;else if(2==v){var b=bits(e,h,31)+257,C=bits(e,h+10,15)+4,y=b+bits(e,h+5,31)+1;h+=14;for(var M=new u8(y),P=new u8(19),T=0;T<C;++T)P[clim[T]]=bits(e,h+3*T,7);h+=3*C;var A=max(P),E=(1<<A)-1,x=hMap(P,A,1);for(T=0;T<y;){var R,I=x[bits(e,h,E)];if(h+=15&I,(R=I>>4)<16)M[T++]=R;else{var D=0,O=0;for(16==R?(O=3+bits(e,h,3),h+=2,D=M[T-1]):17==R?(O=3+bits(e,h,7),h+=3):18==R&&(O=11+bits(e,h,127),h+=7);O--;)M[T++]=D}}var L=M.subarray(0,b),N=M.subarray(b);g=max(L),_=max(N),p=hMap(L,g,1),m=hMap(N,_,1)}else err(1);if(h>f){l&&err(0);break}}o&&d(u+131072);for(var k=(1<<g)-1,B=(1<<_)-1,U=h;;U=h){var F=(D=p[bits16(e,h)&k])>>4;if((h+=15&D)>f){l&&err(0);break}if(D||err(2),F<256)n[u++]=F;else{if(256==F){U=h,p=null;break}var G=F-254;if(F>264){var V=fleb[T=F-257];G=bits(e,h,(1<<V)-1)+fl[T],h+=V}var j=m[bits16(e,h)&B],H=j>>4;if(j||err(3),h+=15&j,N=fd[H],H>3&&(V=fdeb[H],N+=bits16(e,h)&(1<<V)-1,h+=V),h>f){l&&err(0);break}o&&d(u+131072);var z=u+G;if(u<N){var W=i-N,K=Math.min(N,z);for(W+u<0&&err(3);u<K;++u)n[u]=a[W+u]}for(;u<z;++u)n[u]=n[u-N]}}t.l=p,t.p=U,t.b=u,t.f=c,p&&(c=1,t.m=g,t.d=m,t.n=_)}while(!c);return u!=n.length&&s?function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new u8(e.subarray(t,n))}(n,0,u):n.subarray(0,u)}(e.subarray((n=e,a=t&&t.dictionary,(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&err(6,"invalid zlib data"),(n[1]>>5&1)==+!a&&err(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},t&&t.out,t&&t.dictionary);var n,a}var td="undefined"!=typeof TextDecoder&&new TextDecoder;try{td.decode(et,{stream:!0})}catch(e){}class EXRLoader extends DataTextureLoader{constructor(e){super(e),this.type=HalfFloatType}parse(e){const t=Math.pow(2.7182818,2.2),n={l:0,c:0,lc:0};function a(e,t,a,r,i){for(;a<e;)t=t<<8|L(r,i),a+=8;a-=e,n.l=t>>a&(1<<e)-1,n.c=t,n.lc=a}const r=new Array(59);function i(e){return 63&e}function s(e){return e>>6}const o={c:0,lc:0};function l(e,t,n,a){e=e<<8|L(n,a),t+=8,o.c=e,o.lc=t}const d={c:0,lc:0};function c(e,t,n,a,r,i,s,c,h){if(e==t){a<8&&(l(n,a,r,i),n=o.c,a=o.lc);let e=n>>(a-=8);if(e=new Uint8Array([e])[0],c.value+e>h)return!1;const t=s[c.value-1];for(;e-- >0;)s[c.value++]=t}else{if(!(c.value<h))return!1;s[c.value++]=e}d.c=n,d.lc=a}function h(e){return 65535&e}function u(e){const t=h(e);return t>32767?t-65536:t}const p={a:0,b:0};function m(e,t){const n=u(e),a=u(t),r=n+(1&a)+(a>>1),i=r,s=r-a;p.a=i,p.b=s}function g(e,t){const n=h(e),a=h(t),r=n-(a>>1)&65535,i=a+r-32768&65535;p.a=i,p.b=r}function _(e,t,n,a,r,i,s){const o=s<16384,l=n>r?r:n;let d,c,h=1;for(;h<=l;)h<<=1;for(h>>=1,d=h,h>>=1;h>=1;){c=0;const s=c+i*(r-d),l=i*h,u=i*d,_=a*h,f=a*d;let v,S,w,b;for(;c<=s;c+=u){let r=c;const i=c+a*(n-d);for(;r<=i;r+=f){const n=r+_,a=r+l,i=a+_;o?(m(e[r+t],e[a+t]),v=p.a,w=p.b,m(e[n+t],e[i+t]),S=p.a,b=p.b,m(v,S),e[r+t]=p.a,e[n+t]=p.b,m(w,b),e[a+t]=p.a,e[i+t]=p.b):(g(e[r+t],e[a+t]),v=p.a,w=p.b,g(e[n+t],e[i+t]),S=p.a,b=p.b,g(v,S),e[r+t]=p.a,e[n+t]=p.b,g(w,b),e[a+t]=p.a,e[i+t]=p.b)}if(n&h){const n=r+l;o?m(e[r+t],e[n+t]):g(e[r+t],e[n+t]),v=p.a,e[n+t]=p.b,e[r+t]=v}}if(r&h){let r=c;const i=c+a*(n-d);for(;r<=i;r+=f){const n=r+_;o?m(e[r+t],e[n+t]):g(e[r+t],e[n+t]),v=p.a,e[n+t]=p.b,e[r+t]=v}}d=h,h>>=1}return c}function f(e,t,h,u,p,m){const g=h.value,_=O(t,h),f=O(t,h);h.value+=4;const v=O(t,h);if(h.value+=4,_<0||_>=65537||f<0||f>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const S=new Array(65537),w=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(w),function(e,t,i,s,o,l){const d=t;let c=0,h=0;for(;s<=o;s++){if(d.value-t.value>i)return!1;a(6,c,h,e,d);const r=n.l;if(c=n.c,h=n.lc,l[s]=r,63==r){if(d.value-t.value>i)throw new Error("Something wrong with hufUnpackEncTable");a(8,c,h,e,d);let r=n.l+6;if(c=n.c,h=n.lc,s+r>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;r--;)l[s++]=0;s--}else if(r>=59){let e=r-59+2;if(s+e>o+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)l[s++]=0;s--}}!function(e){for(let e=0;e<=58;++e)r[e]=0;for(let t=0;t<65537;++t)r[e[t]]+=1;let t=0;for(let e=58;e>0;--e){const n=t+r[e]>>1;r[e]=t,t=n}for(let t=0;t<65537;++t){const n=e[t];n>0&&(e[t]=n|r[n]++<<6)}}(l)}(e,h,u-(h.value-g),_,f,S),v>8*(u-(h.value-g)))throw new Error("Something wrong with hufUncompress");!function(e,t,n,a){for(;t<=n;t++){const n=s(e[t]),r=i(e[t]);if(n>>r)throw new Error("Invalid table entry");if(r>14){const e=a[n>>r-14];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n<e.lit-1;++n)e.p[n]=t[n]}else e.p=new Array(1);e.p[e.lit-1]=t}else if(r){let e=0;for(let i=1<<14-r;i>0;i--){const i=a[(n<<14-r)+e];if(i.len||i.p)throw new Error("Invalid table entry");i.len=r,i.lit=t,e++}}}}(S,_,f,w),function(e,t,n,a,r,h,u,p,m){let g=0,_=0;const f=u,v=Math.trunc(a.value+(r+7)/8);for(;a.value<v;)for(l(g,_,n,a),g=o.c,_=o.lc;_>=14;){const r=t[g>>_-14&16383];if(r.len)_-=r.len,c(r.lit,h,g,_,n,a,p,m,f),g=d.c,_=d.lc;else{if(!r.p)throw new Error("hufDecode issues");let t;for(t=0;t<r.lit;t++){const u=i(e[r.p[t]]);for(;_<u&&a.value<v;)l(g,_,n,a),g=o.c,_=o.lc;if(_>=u&&s(e[r.p[t]])==(g>>_-u&(1<<u)-1)){_-=u,c(r.p[t],h,g,_,n,a,p,m,f),g=d.c,_=d.lc;break}}if(t==r.lit)throw new Error("hufDecode issues")}}const S=8-r&7;for(g>>=S,_-=S;_>0;){const e=t[g<<14-_&16383];if(!e.len)throw new Error("hufDecode issues");_-=e.len,c(e.lit,h,g,_,n,a,p,m,f),g=d.c,_=d.lc}}(S,w,e,h,v,f,m,p,{value:0})}function v(e){for(let t=1;t<e.length;t++){const n=e[t-1]+e[t]-128;e[t]=n}}function S(e,t){let n=0,a=Math.floor((e.length+1)/2),r=0;const i=e.length-1;for(;!(r>i||(t[r++]=e[n++],r>i));)t[r++]=e[a++]}function w(e){let t=e.byteLength;const n=new Array;let a=0;const r=new DataView(e);for(;t>0;){const e=r.getInt8(a++);if(e<0){const i=-e;t-=i+1;for(let e=0;e<i;e++)n.push(r.getUint8(a++))}else{const i=e;t-=2;const s=r.getUint8(a++);for(let e=0;e<i+1;e++)n.push(s)}}return n}function b(e,t,n){let a,r=1;for(;r<64;)a=t[e.value],65280==a?r=64:a>>8==255?r+=255&a:(n[r]=a,r++),e.value++}function C(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),a=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),i=.5*Math.cos(.981746875),s=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),d=new Array(4),c=new Array(4),h=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=a*e[p+2],l[1]=s*e[p+2],l[2]=a*e[p+6],l[3]=s*e[p+6],d[0]=n*e[p+1]+r*e[p+3]+i*e[p+5]+o*e[p+7],d[1]=r*e[p+1]-o*e[p+3]-n*e[p+5]-i*e[p+7],d[2]=i*e[p+1]-n*e[p+3]+o*e[p+5]+r*e[p+7],d[3]=o*e[p+1]-i*e[p+3]+r*e[p+5]-n*e[p+7],c[0]=t*(e[p+0]+e[p+4]),c[3]=t*(e[p+0]-e[p+4]),c[1]=l[0]+l[3],c[2]=l[1]-l[2],h[0]=c[0]+c[1],h[1]=c[3]+c[2],h[2]=c[3]-c[2],h[3]=c[0]-c[1],e[p+0]=h[0]+d[0],e[p+1]=h[1]+d[1],e[p+2]=h[2]+d[2],e[p+3]=h[3]+d[3],e[p+4]=h[3]-d[3],e[p+5]=h[2]-d[2],e[p+6]=h[1]-d[1],e[p+7]=h[0]-d[0]}for(let u=0;u<8;++u)l[0]=a*e[16+u],l[1]=s*e[16+u],l[2]=a*e[48+u],l[3]=s*e[48+u],d[0]=n*e[8+u]+r*e[24+u]+i*e[40+u]+o*e[56+u],d[1]=r*e[8+u]-o*e[24+u]-n*e[40+u]-i*e[56+u],d[2]=i*e[8+u]-n*e[24+u]+o*e[40+u]+r*e[56+u],d[3]=o*e[8+u]-i*e[24+u]+r*e[40+u]-n*e[56+u],c[0]=t*(e[u]+e[32+u]),c[3]=t*(e[u]-e[32+u]),c[1]=l[0]+l[3],c[2]=l[1]-l[2],h[0]=c[0]+c[1],h[1]=c[3]+c[2],h[2]=c[3]-c[2],h[3]=c[0]-c[1],e[0+u]=h[0]+d[0],e[8+u]=h[1]+d[1],e[16+u]=h[2]+d[2],e[24+u]=h[3]+d[3],e[32+u]=h[3]-d[3],e[40+u]=h[2]-d[2],e[48+u]=h[1]-d[1],e[56+u]=h[0]-d[0]}function y(e){for(let t=0;t<64;++t){const n=e[0][t],a=e[1][t],r=e[2][t];e[0][t]=n+1.5747*r,e[1][t]=n-.1873*a-.4682*r,e[2][t]=n+1.8556*a}}function M(e,n,a){for(let i=0;i<64;++i)n[a+i]=DataUtils.toHalfFloat((r=e[i])<=1?Math.sign(r)*Math.pow(Math.abs(r),2.2):Math.sign(r)*Math.pow(t,Math.abs(r)-1));var r}function P(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function T(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(w(t)),a=new Uint8Array(n.length);return v(n),S(n,a),new DataView(a.buffer)}function A(e){const t=unzlibSync(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return v(t),S(t,n),new DataView(n.buffer)}function E(e){const t=e.viewer,n={value:e.offset.value},a=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),r=new Uint8Array(8192);let i=0;const s=new Array(e.inputChannels.length);for(let t=0,n=e.inputChannels.length;t<n;t++)s[t]={},s[t].start=i,s[t].end=s[t].start,s[t].nx=e.columns,s[t].ny=e.lines,s[t].size=e.type,i+=s[t].nx*s[t].ny*s[t].size;const o=G(t,n),l=G(t,n);if(l>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let e=0;e<l-o+1;e++)r[e+o]=N(t,n);const d=new Uint16Array(65536),c=function(e,t){let n=0;for(let a=0;a<65536;++a)(0==a||e[a>>3]&1<<(7&a))&&(t[n++]=a);const a=n-1;for(;n<65536;)t[n++]=0;return a}(r,d),h=O(t,n);f(e.array,t,n,h,a,i);for(let t=0;t<e.inputChannels.length;++t){const e=s[t];for(let n=0;n<s[t].size;++n)_(a,e.start+n,e.nx,e.size,e.ny,e.nx*e.size,c)}!function(e,t,n){for(let a=0;a<n;++a)t[a]=e[t[a]]}(d,a,i);let u=0;const p=new Uint8Array(a.buffer.byteLength);for(let t=0;t<e.lines;t++)for(let t=0;t<e.inputChannels.length;t++){const e=s[t],n=e.nx*e.size,r=new Uint8Array(a.buffer,2*e.end,2*n);p.set(r,u),u+=2*n,e.end+=n}return new DataView(p.buffer)}function x(e){const t=unzlibSync(e.array.slice(e.offset.value,e.offset.value+e.size)),n=e.inputChannels.length*e.lines*e.columns*e.totalBytes,a=new ArrayBuffer(n),r=new DataView(a);let i=0,s=0;const o=new Array(4);for(let n=0;n<e.lines;n++)for(let n=0;n<e.inputChannels.length;n++){let a=0;switch(e.inputChannels[n].pixelType){case 1:o[0]=i,o[1]=o[0]+e.columns,i=o[1]+e.columns;for(let n=0;n<e.columns;++n)a+=t[o[0]++]<<8|t[o[1]++],r.setUint16(s,a,!0),s+=2;break;case 2:o[0]=i,o[1]=o[0]+e.columns,o[2]=o[1]+e.columns,i=o[2]+e.columns;for(let n=0;n<e.columns;++n)a+=t[o[0]++]<<24|t[o[1]++]<<16|t[o[2]++]<<8,r.setUint32(s,a,!0),s+=4}}return r}function R(e){const t=e.viewer,n={value:e.offset.value},a=new Uint8Array(e.columns*e.lines*(e.inputChannels.length*e.type*2)),r={version:k(t,n),unknownUncompressedSize:k(t,n),unknownCompressedSize:k(t,n),acCompressedSize:k(t,n),dcCompressedSize:k(t,n),rleCompressedSize:k(t,n),rleUncompressedSize:k(t,n),rleRawSize:k(t,n),totalAcUncompressedCount:k(t,n),totalDcUncompressedCount:k(t,n),acCompression:k(t,n)};if(r.version<2)throw new Error("EXRLoader.parse: "+X.compression+" version "+r.version+" is unsupported");const i=new Array;let s=G(t,n)-2;for(;s>0;){const e=I(t.buffer,n),a=N(t,n),r=a>>2&3,o=new Int8Array([(a>>4)-1])[0],l=N(t,n);i.push({name:e,index:o,type:l,compression:r}),s-=e.length+3}const o=X.channels,l=new Array(e.inputChannels.length);for(let t=0;t<e.inputChannels.length;++t){const n=l[t]={},a=o[t];n.name=a.name,n.compression=0,n.decoded=!1,n.type=a.pixelType,n.pLinear=a.pLinear,n.width=e.columns,n.height=e.lines}const d={idx:new Array(3)};for(let t=0;t<e.inputChannels.length;++t){const e=l[t];for(let n=0;n<i.length;++n){const a=i[n];e.name==a.name&&(e.compression=a.compression,a.index>=0&&(d.idx[a.index]=t),e.offset=t)}}let c,h,u;if(r.acCompressedSize>0)switch(r.acCompression){case 0:c=new Uint16Array(r.totalAcUncompressedCount),f(e.array,t,n,r.acCompressedSize,c,r.totalAcUncompressedCount);break;case 1:const a=unzlibSync(e.array.slice(n.value,n.value+r.totalAcUncompressedCount));c=new Uint16Array(a.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const t={array:e.array,offset:n,size:r.dcCompressedSize};h=new Uint16Array(A(t).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(u=w(unzlibSync(e.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const m=new Array(l.length);for(let e=0;e<m.length;++e)m[e]=new Array;for(let t=0;t<e.lines;++t)for(let t=0;t<l.length;++t)m[t].push(p),p+=l[t].width*e.type*2;!function(e,t,n,a,r,i){let s=new DataView(i.buffer);const o=n[e.idx[0]].width,l=n[e.idx[0]].height,d=Math.floor(o/8),c=Math.ceil(o/8),h=Math.ceil(l/8),u=o-8*(c-1),p=l-8*(h-1),m={value:0},g=new Array(3),_=new Array(3),f=new Array(3),v=new Array(3),S=new Array(3);for(let n=0;n<3;++n)S[n]=t[e.idx[n]],g[n]=n<1?0:g[n-1]+c*h,_[n]=new Float32Array(64),f[n]=new Uint16Array(64),v[n]=new Uint16Array(64*c);for(let t=0;t<h;++t){let i=8;t==h-1&&(i=p);let o=8;for(let e=0;e<c;++e){e==c-1&&(o=u);for(let e=0;e<3;++e)f[e].fill(0),f[e][0]=r[g[e]++],b(m,a,f[e]),w=f[e],(P=_[e])[0]=F(w[0]),P[1]=F(w[1]),P[2]=F(w[5]),P[3]=F(w[6]),P[4]=F(w[14]),P[5]=F(w[15]),P[6]=F(w[27]),P[7]=F(w[28]),P[8]=F(w[2]),P[9]=F(w[4]),P[10]=F(w[7]),P[11]=F(w[13]),P[12]=F(w[16]),P[13]=F(w[26]),P[14]=F(w[29]),P[15]=F(w[42]),P[16]=F(w[3]),P[17]=F(w[8]),P[18]=F(w[12]),P[19]=F(w[17]),P[20]=F(w[25]),P[21]=F(w[30]),P[22]=F(w[41]),P[23]=F(w[43]),P[24]=F(w[9]),P[25]=F(w[11]),P[26]=F(w[18]),P[27]=F(w[24]),P[28]=F(w[31]),P[29]=F(w[40]),P[30]=F(w[44]),P[31]=F(w[53]),P[32]=F(w[10]),P[33]=F(w[19]),P[34]=F(w[23]),P[35]=F(w[32]),P[36]=F(w[39]),P[37]=F(w[45]),P[38]=F(w[52]),P[39]=F(w[54]),P[40]=F(w[20]),P[41]=F(w[22]),P[42]=F(w[33]),P[43]=F(w[38]),P[44]=F(w[46]),P[45]=F(w[51]),P[46]=F(w[55]),P[47]=F(w[60]),P[48]=F(w[21]),P[49]=F(w[34]),P[50]=F(w[37]),P[51]=F(w[47]),P[52]=F(w[50]),P[53]=F(w[56]),P[54]=F(w[59]),P[55]=F(w[61]),P[56]=F(w[35]),P[57]=F(w[36]),P[58]=F(w[48]),P[59]=F(w[49]),P[60]=F(w[57]),P[61]=F(w[58]),P[62]=F(w[62]),P[63]=F(w[63]),C(_[e]);y(_);for(let t=0;t<3;++t)M(_[t],v[t],64*e)}let l=0;for(let a=0;a<3;++a){const r=n[e.idx[a]].type;for(let e=8*t;e<8*t+i;++e){l=S[a][e];for(let t=0;t<d;++t){const n=64*t+8*(7&e);s.setUint16(l+0*r,v[a][n+0],!0),s.setUint16(l+2*r,v[a][n+1],!0),s.setUint16(l+4*r,v[a][n+2],!0),s.setUint16(l+6*r,v[a][n+3],!0),s.setUint16(l+8*r,v[a][n+4],!0),s.setUint16(l+10*r,v[a][n+5],!0),s.setUint16(l+12*r,v[a][n+6],!0),s.setUint16(l+14*r,v[a][n+7],!0),l+=16*r}}if(d!=c)for(let e=8*t;e<8*t+i;++e){const t=S[a][e]+8*d*2*r,n=64*d+8*(7&e);for(let e=0;e<o;++e)s.setUint16(t+2*e*r,v[a][n+e],!0)}}}var w,P;const T=new Uint16Array(o);s=new DataView(i.buffer);for(let t=0;t<3;++t){n[e.idx[t]].decoded=!0;const a=n[e.idx[t]].type;if(2==n[t].type)for(let e=0;e<l;++e){const n=S[t][e];for(let e=0;e<o;++e)T[e]=s.getUint16(n+2*e*a,!0);for(let e=0;e<o;++e)s.setFloat32(n+2*e*a,F(T[e]),!0)}}}(d,m,l,c,h,a);for(let t=0;t<l.length;++t){const n=l[t];if(!n.decoded)switch(n.compression){case 2:let r=0,i=0;for(let s=0;s<e.lines;++s){let e=m[t][r];for(let t=0;t<n.width;++t){for(let t=0;t<2*n.type;++t)a[e++]=u[i+t*n.width*n.height];i++}r++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(a.buffer)}function I(e,t){const n=new Uint8Array(e);let a=0;for(;0!=n[t.value+a];)a+=1;const r=(new TextDecoder).decode(n.slice(t.value,t.value+a));return t.value=t.value+a+1,r}function D(e,t){const n=e.getInt32(t.value,!0);return t.value=t.value+4,n}function O(e,t){const n=e.getUint32(t.value,!0);return t.value=t.value+4,n}function L(e,t){const n=e[t.value];return t.value=t.value+1,n}function N(e,t){const n=e.getUint8(t.value);return t.value=t.value+1,n}const k=function(e,t){let n;return n="getBigInt64"in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,n};function B(e,t){const n=e.getFloat32(t.value,!0);return t.value+=4,n}function U(e,t){return DataUtils.toHalfFloat(B(e,t))}function F(e){const t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function G(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function V(e,t){return F(G(e,t))}function j(e,t,n,a,r){return"string"===a||"stringvector"===a||"iccProfile"===a?function(e,t,n){const a=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,a}(t,n,r):"chlist"===a?function(e,t,n,a){const r=n.value,i=[];for(;n.value<r+a-1;){const a=I(t,n),r=D(e,n),s=N(e,n);n.value+=3;const o=D(e,n),l=D(e,n);i.push({name:a,pixelType:r,pLinear:s,xSampling:o,ySampling:l})}return n.value+=1,i}(e,t,n,r):"chromaticities"===a?function(e,t){return{redX:B(e,t),redY:B(e,t),greenX:B(e,t),greenY:B(e,t),blueX:B(e,t),blueY:B(e,t),whiteX:B(e,t),whiteY:B(e,t)}}(e,n):"compression"===a?function(e,t){return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][N(e,t)]}(e,n):"box2i"===a?function(e,t){return{xMin:D(e,t),yMin:D(e,t),xMax:D(e,t),yMax:D(e,t)}}(e,n):"envmap"===a?function(e,t){return["ENVMAP_LATLONG","ENVMAP_CUBE"][N(e,t)]}(e,n):"tiledesc"===a?function(e,t){const n=O(e,t),a=O(e,t),r=N(e,t);return{xSize:n,ySize:a,levelMode:["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"][15&r],roundingMode:["ROUND_DOWN","ROUND_UP"][r>>4]}}(e,n):"lineOrder"===a?function(e,t){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][N(e,t)]}(e,n):"float"===a?B(e,n):"v2f"===a?function(e,t){return[B(e,t),B(e,t)]}(e,n):"v3f"===a?function(e,t){return[B(e,t),B(e,t),B(e,t)]}(e,n):"int"===a?D(e,n):"rational"===a?function(e,t){return[D(e,t),O(e,t)]}(e,n):"timecode"===a?function(e,t){return[O(e,t),O(e,t)]}(e,n):"preview"===a?(n.value+=r,"skipped"):void(n.value+=r)}function H(e,t,n,a){const r=new Array(e);for(let i=0;i<e;i++){const e=1<<i;let s=t/e|0;"ROUND_UP"==a&&s*e<t&&(s+=1);const o=Math.max(s,1);r[i]=(o+n-1)/n|0}return r}function z(){const e=this,t=e.offset,n={value:0};for(let a=0;a<e.tileCount;a++){const a=D(e.viewer,t),r=D(e.viewer,t);t.value+=8,e.size=O(e.viewer,t);const i=a*e.blockWidth,s=r*e.blockHeight;e.columns=i+e.blockWidth>e.width?e.width-i:e.blockWidth,e.lines=s+e.blockHeight>e.height?e.height-s:e.blockHeight;const o=e.columns*e.totalBytes,l=e.size<e.lines*o?e.uncompress(e):P(e);t.value+=e.size;for(let t=0;t<e.lines;t++){const a=t*e.columns*e.totalBytes;for(let r=0;r<e.inputChannels.length;r++){const o=X.channels[r].name,d=e.channelByteOffsets[o]*e.columns,c=e.decodeChannels[o];if(void 0===c)continue;n.value=a+d;const h=(e.height-(1+s+t))*e.outLineWidth;for(let t=0;t<e.columns;t++){const a=h+(t+i)*e.outputChannels+c;e.byteArray[a]=e.getter(l,n)}}}}}function W(){const e=this,t=e.offset,n={value:0};for(let a=0;a<e.height/e.blockHeight;a++){const r=D(e.viewer,t)-X.dataWindow.yMin;e.size=O(e.viewer,t),e.lines=r+e.blockHeight>e.height?e.height-r:e.blockHeight;const i=e.columns*e.totalBytes,s=e.size<e.lines*i?e.uncompress(e):P(e);t.value+=e.size;for(let t=0;t<e.blockHeight;t++){const r=a*e.blockHeight,o=t+e.scanOrder(r);if(o>=e.height)continue;const l=t*i,d=(e.height-1-o)*e.outLineWidth;for(let t=0;t<e.inputChannels.length;t++){const a=X.channels[t].name,r=e.channelByteOffsets[a]*e.columns,i=e.decodeChannels[a];if(void 0!==i){n.value=l+r;for(let t=0;t<e.columns;t++){const a=d+t*e.outputChannels+i;e.byteArray[a]=e.getter(s,n)}}}}}}const K={value:0},Y=new DataView(e),q=new Uint8Array(e),X=function(e,t,n){const a={};if(20000630!=e.getUint32(0,!0))throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");a.version=e.getUint8(4);const r=e.getUint8(5);a.spec={singleTile:!!(2&r),longName:!!(4&r),deepFormat:!!(8&r),multiPart:!!(16&r)},n.value=8;let i=!0;for(;i;){const r=I(t,n);if(0==r)i=!1;else{const i=I(t,n),s=j(e,t,n,i,O(e,n));void 0===s?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${i}'.`):a[r]=s}}if(0!=(-7&r))throw console.error("THREE.EXRHeader:",a),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return a}(Y,e,K),Q=function(e,t,n,a,r){const i={size:0,viewer:t,array:n,offset:a,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,inputChannels:e.channels,channelByteOffsets:{},scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:LinearSRGBColorSpace};switch(e.compression){case"NO_COMPRESSION":i.blockHeight=1,i.uncompress=P;break;case"RLE_COMPRESSION":i.blockHeight=1,i.uncompress=T;break;case"ZIPS_COMPRESSION":i.blockHeight=1,i.uncompress=A;break;case"ZIP_COMPRESSION":i.blockHeight=16,i.uncompress=A;break;case"PIZ_COMPRESSION":i.blockHeight=32,i.uncompress=E;break;case"PXR24_COMPRESSION":i.blockHeight=16,i.uncompress=x;break;case"DWAA_COMPRESSION":i.blockHeight=32,i.uncompress=R;break;case"DWAB_COMPRESSION":i.blockHeight=256,i.uncompress=R;break;default:throw new Error("EXRLoader.parse: "+e.compression+" is unsupported")}const s={};for(const t of e.channels)switch(t.name){case"Y":case"R":case"G":case"B":case"A":s[t.name]=!0,i.type=t.pixelType}let o=!1;if(s.R&&s.G&&s.B)o=!s.A,i.outputChannels=4,i.decodeChannels={R:0,G:1,B:2,A:3};else{if(!s.Y)throw new Error("EXRLoader.parse: file contains unsupported data channels.");i.outputChannels=1,i.decodeChannels={Y:0}}if(1==i.type)switch(r){case FloatType:i.getter=V;break;case HalfFloatType:i.getter=G}else{if(2!=i.type)throw new Error("EXRLoader.parse: unsupported pixelType "+i.type+" for "+e.compression+".");switch(r){case FloatType:i.getter=B;break;case HalfFloatType:i.getter=U}}i.columns=i.width;const l=i.width*i.height*i.outputChannels;switch(r){case FloatType:i.byteArray=new Float32Array(l),o&&i.byteArray.fill(1,0,l);break;case HalfFloatType:i.byteArray=new Uint16Array(l),o&&i.byteArray.fill(15360,0,l);break;default:console.error("THREE.EXRLoader: unsupported type: ",r)}let d=0;for(const t of e.channels)void 0!==i.decodeChannels[t.name]&&(i.channelByteOffsets[t.name]=d),d+=2*t.pixelType;if(i.totalBytes=d,i.outLineWidth=i.width*i.outputChannels,"INCREASING_Y"===e.lineOrder?i.scanOrder=e=>e:i.scanOrder=e=>i.height-1-e,4==i.outputChannels?(i.format=RGBAFormat,i.colorSpace=LinearSRGBColorSpace):(i.format=RedFormat,i.colorSpace=NoColorSpace),e.spec.singleTile){i.blockHeight=e.tiles.ySize,i.blockWidth=e.tiles.xSize;const n=function(e,t,n){let a=0;switch(e.levelMode){case"ONE_LEVEL":a=1;break;case"MIPMAP_LEVELS":a=function(e,t){const n=Math.log2(e);return"ROUND_DOWN"==t?Math.floor(n):Math.ceil(n)}(Math.max(t,n),e.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return a}(e.tiles,i.width,i.height),r=H(n,i.width,e.tiles.xSize,e.tiles.roundingMode),s=H(n,i.height,e.tiles.ySize,e.tiles.roundingMode);i.tileCount=r[0]*s[0];for(let e=0;e<n;e++)for(let n=0;n<s[e];n++)for(let n=0;n<r[e];n++)k(t,a);i.decode=z.bind(i)}else{i.blockWidth=i.width;const e=Math.ceil(i.height/i.blockHeight);for(let n=0;n<e;n++)k(t,a);i.decode=W.bind(i)}return i}(X,Y,q,K,this.type);return Q.decode(),{header:X,width:Q.width,height:Q.height,data:Q.byteArray,format:Q.format,colorSpace:Q.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,a){return super.load(e,(function(e,n){e.colorSpace=n.colorSpace,e.minFilter=LinearFilter,e.magFilter=LinearFilter,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,n)}),n,a)}}class RGBELoader extends DataTextureLoader{constructor(e){super(e),this.type=HalfFloatType}parse(e){const t=function(e,t){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},n=function(e,t,n){t=t||1024;let a=e.pos,r=-1,i=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));for(;0>(r=o.indexOf("\n"))&&i<t&&a<e.byteLength;)s+=o,i+=o.length,a+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));return-1<r&&(!1!==n&&(e.pos+=i+r+1),s+o.slice(0,r))},a=function(e,t,n,a){const r=e[t+3],i=Math.pow(2,r-128)/255;n[a+0]=e[t+0]*i,n[a+1]=e[t+1]*i,n[a+2]=e[t+2]*i,n[a+3]=1},r=function(e,t,n,a){const r=e[t+3],i=Math.pow(2,r-128)/255;n[a+0]=DataUtils.toHalfFloat(Math.min(e[t+0]*i,65504)),n[a+1]=DataUtils.toHalfFloat(Math.min(e[t+1]*i,65504)),n[a+2]=DataUtils.toHalfFloat(Math.min(e[t+2]*i,65504)),n[a+3]=DataUtils.toHalfFloat(1)},i=new Uint8Array(e);i.pos=0;const s=function(e){const a=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,d;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(d=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=d[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((d=l.match(a))&&(o.gamma=parseFloat(d[1])),(d=l.match(r))&&(o.exposure=parseFloat(d[1])),(d=l.match(i))&&(o.valid|=2,o.format=d[1]),(d=l.match(s))&&(o.valid|=4,o.height=parseInt(d[1],10),o.width=parseInt(d[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(i),o=s.width,l=s.height,d=function(e,n,a){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);r!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const i=new Uint8Array(4*n*a);i.length||t(4,"unable to allocate buffer space");let s=0,o=0;const l=4*r,d=new Uint8Array(4),c=new Uint8Array(l);let h=a;for(;h>0&&o<e.byteLength;){o+4>e.byteLength&&t(1),d[0]=e[o++],d[1]=e[o++],d[2]=e[o++],d[3]=e[o++],2==d[0]&&2==d[1]&&(d[2]<<8|d[3])==r||t(3,"bad rgbe scanline format");let n,a=0;for(;a<l&&o<e.byteLength;){n=e[o++];const r=n>128;if(r&&(n-=128),(0===n||a+n>l)&&t(3,"bad scanline data"),r){const t=e[o++];for(let e=0;e<n;e++)c[a++]=t}else c.set(e.subarray(o,o+n),a),a+=n,o+=n}const u=r;for(let e=0;e<u;e++){let t=0;i[s]=c[e+t],t+=r,i[s+1]=c[e+t],t+=r,i[s+2]=c[e+t],t+=r,i[s+3]=c[e+t],s+=4}h--}return i}(i.subarray(i.pos),o,l);let c,h,u;switch(this.type){case FloatType:u=d.length/4;const e=new Float32Array(4*u);for(let t=0;t<u;t++)a(d,4*t,e,4*t);c=e,h=FloatType;break;case HalfFloatType:u=d.length/4;const t=new Uint16Array(4*u);for(let e=0;e<u;e++)r(d,4*e,t,4*e);c=t,h=HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:o,height:l,data:c,header:s.string,gamma:s.gamma,exposure:s.exposure,type:h}}setDataType(e){return this.type=e,this}load(e,t,n,a){return super.load(e,(function(e,n){switch(e.type){case FloatType:case HalfFloatType:e.colorSpace=LinearSRGBColorSpace,e.minFilter=LinearFilter,e.magFilter=LinearFilter,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,a)}}class ShadowGroundPlane extends Mesh{constructor(e,t){super(new PlaneGeometry(1,1,10,10),new MeshPhysicalMaterial({color:ShadowGroundPlane.alphaMap?0:16777215,transparent:!0,depthWrite:!1,polygonOffset:!0,name:"ShadowGroundPlaneMaterial"})),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;ShadowGroundPlane.alphaMap?(t.alphaMap=e,t.map=null,t.color.set(0)):(t.alphaMap=null,t.map=e,t.color.set(16777215)),t.needsUpdate=!0}updateMaterial(e){const t=this.material;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}}ShadowGroundPlane.alphaMap=!0;class RenderPass extends class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}{get renderPassManager(){return this._renderPassManager}get renderCacheManager(){return this._renderPassManager.renderCacheManager}get scene(){return this._renderPassManager.scene}get camera(){return this._renderPassManager.camera}get gBufferTextures(){return this._renderPassManager.gBufferRenderPass}get passRenderer(){return this._renderPassManager.passRenderer}constructor(e){super(),this._renderPassManager=e}render(e,t,n,a,r){this.renderPass(e)}}const BlendAoAndAShadowShader={uniforms:{tDiffuse:{value:null},intensity:{value:new Vector2(1,1)}},vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",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 }"};class BlendAoAndAShadowMaterial extends ShaderMaterial{constructor(e){super({uniforms:UniformsUtils.clone(BlendAoAndAShadowShader.uniforms),vertexShader:BlendAoAndAShadowShader.vertexShader,fragmentShader:BlendAoAndAShadowShader.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:DstColorFactor,blendDst:ZeroFactor,blendEquation:AddEquation,blendSrcAlpha:DstAlphaFactor,blendDstAlpha:ZeroFactor,blendEquationAlpha:AddEquation}),this._intensity=new Vector2(1,1),this.uniforms.intensity.value=this._intensity,this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=e.texture),void 0!==(null==e?void 0:e.blending)&&(this.blending=e.blending),void 0!==(null==e?void 0:e.aoIntensity)&&(this._intensity.x=e.aoIntensity),void 0!==(null==e?void 0:e.shadowIntensity)&&(this._intensity.y=e.shadowIntensity),this}}const generatePdSamplePointInitializer=(e,t,n,a)=>{const r=generateDenoiseSamples(e,t,n,a);let i="vec3[SAMPLES](";for(let t=0;t<e;t++){const n=r[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?",":")"}`}return i},generateDenoiseSamples=(e,t,n,a)=>{const r=[];for(let i=0;i<e;i++){const s=2*Math.PI*t*i/e,o=(1+(n-1)*Math.pow(i/(e-1),a))/n;r.push(new Vector3(Math.cos(s),Math.sin(s),o))}return r},poissonDenoiseShader={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:generatePdSamplePointInitializer(16,2.89,4,1.3),NV_ALIGNED_SAMPLES:0,SAMPLE_DISTRIBUTION:0,DEPTH_VALUE_SOURCE:0,LUMINANCE_WEIGHTED:1,LUMINANCE_TYPE:"float",SAMPLE_LUMINANCE:"dot(vec3(0.2125, 0.7154, 0.0721), a)",SCENE_CLIP_BOX:0,FRAGMENT_OUTPUT:"vec4(vec3(denoised), 1.)"},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new Vector2},cameraProjectionMatrix:{value:new Matrix4},cameraProjectionMatrixInverse:{value:new Matrix4},cameraWorldMatrix:{value:new Matrix4},lumaPhi:{value:5},depthPhi:{value:1},normalPhi:{value:1},radius:{value:10},radiusExponent:{value:1.3},iteration:{value:0},noOfIterations:{value:2},sceneBoxMin:{value:new Vector3(-1,-1,-1)},sceneBoxMax:{value:new Vector3(1,1,1)}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",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));\t\n vec3 viewNormal = getViewNormal(vUv);\t\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\t\t#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}"},defaultPoissonDenoisePassParameters={iterations:2,samples:16,rings:2.89,radiusExponent:1.3,radius:4,lumaPhi:10,depthPhi:2.5,normalPhi:.5,nvOrientatedSamples:!1};class PoissonDenoiseRenderPass{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n,a){this.needsUpdate=!0,this.parameters={...defaultPoissonDenoisePassParameters},this._width=0,this._height=0,this._samples=0,this._normalVectorSourceType="floatBufferNormal",this._depthValueSourceType="normalVectorAlpha",this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._passRenderer=new PassRenderer,this._rgInputTexture=!1,this._luminanceWeighted=!0,this._width=e,this._height=t,this._samples=n,this._normalVectorSourceType=(null==a?void 0:a.normalVectorSourceType)||"floatBufferNormal",this._depthValueSourceType=(null==a?void 0:a.depthValueSourceType)||"normalVectorAlpha",this._inputTexture=(null==a?void 0:a.inputTexture)||null,this.depthTexture=(null==a?void 0:a.depthTexture)||null,this.normalTexture=(null==a?void 0:a.normalTexture)||null,this._rgInputTexture=(null==a?void 0:a.rgInputTexture)||!1,this._luminanceWeighted=!0===(null==a?void 0:a.luminanceWeighted),this._luminanceType=(null==a?void 0:a.luminanceType)||"vec3",this._sampleLuminance=(null==a?void 0:a.sampleLuminance)||"a",this._fragmentOutput=(null==a?void 0:a.fragmentOutput)||"vec4(denoised.xyz, 1.)",(null==a?void 0:a.poissonDenoisePassParameters)&&(this.parameters=a.poissonDenoisePassParameters),a&&this.updateTextures(a)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new SimplexNoise,n=new Uint8Array(e*e*4);for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=a,s=r;n[4*(a*e+r)]=127.5*(t.noise(i,s)+1),n[4*(a*e+r)+1]=127.5*(t.noise(i+e,s)+1),n[4*(a*e+r)+2]=127.5*(t.noise(i,s+e)+1),n[4*(a*e+r)+3]=127.5*(t.noise(i+e,s+e)+1)}this._noiseTexture=new DataTexture(n,e,e,RGBAFormat,UnsignedByteType),this._noiseTexture.wrapS=RepeatWrapping,this._noiseTexture.wrapT=RepeatWrapping,this._noiseTexture.needsUpdate=!0}return this._noiseTexture}_getMaterial(e,t){let n=t;return this._pdMaterial||(this._pdMaterial=new ShaderMaterial({defines:Object.assign({},poissonDenoiseShader.defines),uniforms:UniformsUtils.clone(poissonDenoiseShader.uniforms),vertexShader:poissonDenoiseShader.vertexShader,fragmentShader:poissonDenoiseShader.fragmentShader,depthTest:!1,depthWrite:!1}),this._pdMaterial.uniforms.tNoise.value=this._getNoiseTexture(),n=!0),n&&this._updateShader(this._pdMaterial),this._updateUniforms(this._pdMaterial,e,n),this._pdMaterial}_updateShader(e){e.defines.SAMPLES=this.parameters.samples,e.defines.SAMPLE_VECTORS=generatePdSamplePointInitializer(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="floatBufferNormal"===this._normalVectorSourceType?2:1,e.defines.DEPTH_VALUE_SOURCE="normalVectorAlpha"===this._depthValueSourceType?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}_updateUniforms(e,t,n){const a="normalVectorAlpha"===this._depthValueSourceType?this.normalTexture:this.depthTexture;e.uniforms.tDiffuse.value=this._inputTexture,e.uniforms.tNormal.value=this.normalTexture,e.uniforms.tDepth.value=a,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)))}_getRenderTargets(){return this._renderTargets.length<2&&(this._renderTargets=[new WebGLRenderTarget(this._width,this._height,{samples:this._samples,format:RGBAFormat,type:HalfFloatType,magFilter:NearestFilter,minFilter:NearestFilter}),new WebGLRenderTarget(this._width,this._height,{samples:this._samples,format:RGBAFormat,type:HalfFloatType,magFilter:NearestFilter,minFilter:NearestFilter})]),this._renderTargets}dispose(){var e,t;null===(e=this._noiseTexture)||void 0===e||e.dispose(),null===(t=this._pdMaterial)||void 0===t||t.dispose(),this._renderTargets.forEach(e=>e.dispose())}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach(n=>n.setSize(e,t)),this.needsUpdate=!0}updateBounds(e){this._sceneClipBox=(new Box3).copy(e),this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){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)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const a=this._getRenderTargets();n.uniforms.iteration.value=this.parameters.iterations;for(let t=0;t<this.parameters.iterations;t++){const r=a[(t+1)%2];this._outputRenderTargetIndex=t%2;const i=a[this._outputRenderTargetIndex];n.uniforms.tDiffuse.value=0===t?this._inputTexture:r.texture,n.uniforms.iteration.value=t,this._passRenderer.renderScreenSpace(e,n,i,16777215,1)}}renderToTarget(e,t,n){const a=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1,this._passRenderer.renderScreenSpace(e,a,n,16777215,1)}}const defaultShadowParameters={shadowRadius:.05};class ShadowAndAoPass extends RenderPass{get aoAndSoftShadowRenderTarget(){var e;return this._aoAndSoftShadowRenderTarget=null!==(e=this._aoAndSoftShadowRenderTarget)&&void 0!==e?e:new WebGLRenderTarget(this._width,this._height,{samples:this._samples,format:RGFormat,magFilter:NearestFilter,minFilter:NearestFilter}),this._aoAndSoftShadowRenderTarget}get aoRenderPass(){return this._aoPass||(this._aoPass=new AORenderPass(this._width,this._height,this._samples,!this.parameters.applyToMaterial,{normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",modulateRedChannel:!0,aoParameters:this.parameters.ao})),this._aoPass}get softShadowPass(){if(this._softShadowPass){const e=this._softShadowPass;e.depthTexture=this.gBufferTextures.depthBufferTexture,e.normalTexture=this.gBufferTextures.gBufferTexture}else this._softShadowPass=new PoissonDenoiseRenderPass(this._width,this._height,this._samples,{inputTexture:void 0,depthTexture:this.gBufferTextures.depthBufferTexture,normalTexture:this.gBufferTextures.gBufferTexture,normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",rgInputTexture:!0,luminanceWeighted:!1,fragmentOutput:"vec4(1.0, denoised.x, 0.0, 1.0)",poissonDenoisePassParameters:{iterations:1,samples:16,rings:2.89,radiusExponent:1,radius:this.parameters.shadow.shadowRadius,lumaPhi:10,depthPhi:.1,normalPhi:4,nvOrientatedSamples:!0}});return this._softShadowPass}get fadeRenderTarget(){var e;return this._fadeRenderTarget=null!==(e=this._fadeRenderTarget)&&void 0!==e?e:new WebGLRenderTarget(this._width,this._height,{samples:this._samples,format:RGFormat,magFilter:NearestFilter,minFilter:NearestFilter}),this._fadeRenderTarget}get denoisePass(){if(this._poissonDenoisePass){const e=this._poissonDenoisePass;e.depthTexture=this.gBufferTextures.depthBufferTexture,e.normalTexture=this.gBufferTextures.gBufferTexture}else this._poissonDenoisePass=new PoissonDenoiseRenderPass(this._width,this._height,this._samples,{inputTexture:this.aoAndSoftShadowRenderTarget.texture,depthTexture:this.gBufferTextures.depthBufferTexture,normalTexture:this.gBufferTextures.gBufferTexture,normalVectorSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"floatBufferNormal":"inputRgbNormal",depthValueSourceType:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?"normalVectorAlpha":"separateBuffer",rgInputTexture:!0,luminanceWeighted:!1,fragmentOutput:"vec4(denoised.xy, vec2(fract(depth * 1024.0), floor(depth * 1024.0)))",poissonDenoisePassParameters:this.parameters.poissonDenoise});return this._poissonDenoisePass}get denoiseRenderTargetTexture(){return this.denoisePass?this.denoisePass.texture:null}get finalTexture(){return this._finalTexture}constructor(e,t,n,a,r){var i,s,o,l,d,c,h,u;super(e),this.needsUpdate=!0,this.renderToRenderTarget=!1,this.shadowAndAoPassSettings={shadowMapTexture:null,shadowBlurType:"full",shadowFadeInBlurType:"full",shadowFadeInMix:0,noOStaticFrames:0},this._cameraUpdate=new CameraUpdate,this._finalTexture=null,this._onlyHardShadow=!1,this._width=t,this._height=n,this._samples=a,this.parameters={enabled:null===(i=null==r?void 0:r.enabled)||void 0===i||i,applyToMaterial:null===(s=null==r?void 0:r.applyToMaterial)||void 0===s||s,aoIntensity:null!==(o=null==r?void 0:r.aoIntensity)&&void 0!==o?o:.5,shadowIntensity:null!==(l=null==r?void 0:r.shadowIntensity)&&void 0!==l?l:.35,aoOnGround:null===(d=null==r?void 0:r.aoOnGround)||void 0===d||d,shadowOnGround:null!==(c=null==r?void 0:r.shadowOnGround)&&void 0!==c&&c,alwaysUpdate:null!==(h=null==r?void 0:r.alwaysUpdate)&&void 0!==h&&h,progressiveDenoiseIterations:null!==(u=null==r?void 0:r.progressiveDenoiseIterations)&&void 0!==u?u:0,shadow:{...defaultShadowParameters},ao:{...defaultAORenderPassParameters},poissonDenoise:{...defaultPoissonDenoisePassParameters}},this._copyMaterial=new CopyTransformMaterial,this._blendMaterial=new CopyTransformMaterial({},"default"),this._blendAoAndShadowMaterial=new BlendAoAndAShadowMaterial}dispose(){var e,t,n,a,r,i,s,o;super.dispose(),null===(e=this._aoAndSoftShadowRenderTarget)||void 0===e||e.dispose(),null===(t=this._softShadowPass)||void 0===t||t.dispose(),null===(n=this._aoPass)||void 0===n||n.dispose(),null===(a=this._fadeRenderTarget)||void 0===a||a.dispose(),null===(r=this._poissonDenoisePass)||void 0===r||r.dispose(),null===(i=this._copyMaterial)||void 0===i||i.dispose(),null===(s=this._blendMaterial)||void 0===s||s.dispose(),null===(o=this._blendAoAndShadowMaterial)||void 0===o||o.dispose()}setSize(e,t){var n,a,r,i,s;this._width=e,this._height=t,null===(n=this._aoAndSoftShadowRenderTarget)||void 0===n||n.setSize(e,t),null===(a=this._softShadowPass)||void 0===a||a.setSize(e,t),null===(r=this._aoPass)||void 0===r||r.setSize(e,t),null===(i=this._fadeRenderTarget)||void 0===i||i.setSize(e,t),null===(s=this._poissonDenoisePass)||void 0===s||s.setSize(this._width,this._height),this.needsUpdate=!0}updateParameters(e){void 0!==e.enabled&&(this.parameters.enabled=e.enabled),void 0!==e.applyToMaterial&&(this.parameters.applyToMaterial=e.applyToMaterial),void 0!==e.aoIntensity&&(this.parameters.aoIntensity=e.aoIntensity),void 0!==e.shadowIntensity&&(this.parameters.shadowIntensity=e.shadowIntensity),void 0!==e.aoOnGround&&(this.parameters.aoOnGround=e.aoOnGround),void 0!==e.shadowOnGround&&(this.parameters.shadowOnGround=e.shadowOnGround),void 0!==e.alwaysUpdate&&(this.parameters.alwaysUpdate=e.alwaysUpdate),this._updatePassParameters(e)}_updatePassParameters(e){var t,n;if(null==e?void 0:e.shadow){for(const t in e.shadow)this.parameters.shadow.hasOwnProperty(t)&&(this.parameters.shadow[t]=e.shadow[t]);this._softShadowPass&&(this._softShadowPass.needsUpdate=!0)}if(null==e?void 0:e.ao){for(const t in e.ao)this.parameters.ao.hasOwnProperty(t)&&(this.parameters.ao[t]=e.ao[t]);this._aoPass&&(null===(t=this._aoPass)||void 0===t||t.updateParameters(null==e?void 0:e.ao))}if(null==e?void 0:e.poissonDenoise)if(this._poissonDenoisePass)null===(n=this._poissonDenoisePass)||void 0===n||n.updateParameters(null==e?void 0:e.poissonDenoise);else for(const t in e.poissonDenoise)this.parameters.poissonDenoise.hasOwnProperty(t)&&(this.parameters.poissonDenoise[t]=e.poissonDenoise[t])}updateBounds(e,t){var n,a;null===(n=this._softShadowPass)||void 0===n||n.updateBounds(e.bounds),null===(a=this._aoPass)||void 0===a||a.updateBounds(e.bounds,t)}_getRenderConditions(e="full",t=0,n=0){const a="poisson"===e&&t>.001,r="hard"===e&&t>.001&&t<.999;return{fadeInPoissonShadow:a,fadeInHardShadow:r,onlyHardShadow:"hard"===e&&!r,progressiveDenoise:!a&&!r&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}renderPass(e){if(!this._setRenderState())return;const t=this._getRenderConditions(this.shadowAndAoPassSettings.shadowFadeInBlurType,this.shadowAndAoPassSettings.shadowFadeInMix,this.shadowAndAoPassSettings.noOStaticFrames);let n=!1;!t.onlyHardShadow&&"full"===this.shadowAndAoPassSettings.shadowBlurType&&this._evaluateIfUpdateIsNeeded(this.camera)&&(this._renderShadowAndAo(e,this.scene,this.camera,this.shadowAndAoPassSettings.shadowMapTexture),n=!0);let a=t.onlyHardShadow?this.shadowAndAoPassSettings.shadowMapTexture:this.denoiseRenderTargetTexture;t.fadeInPoissonShadow&&(a=this._renderDynamicShadow(e,this.aoAndSoftShadowRenderTarget.texture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix),n=!0),n?a=this._renderDenoise(e,this.camera,t.fadeInPoissonShadow,!1):t.progressiveDenoise&&(a=this._renderDenoise(e,this.camera,!1,!0)),t.fadeInHardShadow&&(a=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix)),this._finalTexture=a,this._onlyHardShadow=t.onlyHardShadow,this.renderToRenderTarget&&this.renderToTarget(e)}_setRenderState(){return!(!this.parameters.enabled||!(null!==this.parameters.ao.algorithm||this.parameters.shadowIntensity>=.01)||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,a){var r;const i=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;i||null===(r=this._aoPass)||void 0===r||r.clear(e,this.aoAndSoftShadowRenderTarget),this._renderSoftShadow(e,n,a),i&&this._renderAo(e,t,n)}_renderAo(e,t,n){const a=this.gBufferTextures.depthBufferTexture,r=this.gBufferTextures.gBufferTexture,i=this._aoAndSoftShadowRenderTarget,s=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=a,o.normalTexture=r,o.render(e,n,t,i),e.autoClear=s}_renderSoftShadow(e,t,n){const a=this.softShadowPass;a.parameters.radius=this.parameters.shadow.shadowRadius,a.inputTexture=n,this.softShadowPass.renderToTarget(e,t,this.aoAndSoftShadowRenderTarget)}_renderDynamicShadow(e,t,n,a=1){const r=a<.999;return r&&(this._copyMaterial.update({texture:t,blending:NoBlending,colorTransform:DEFAULT_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),a>.001&&(this._blendMaterial.update({texture:n,blending:r?CustomBlending:NoBlending,colorTransform:(new Matrix4).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,r?a:1),multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,a){const r=this.denoisePass;return r.inputTexture=n?this.fadeRenderTarget.texture:a?r.texture:this.aoAndSoftShadowRenderTarget.texture,r.render(e,t),r.texture}renderToTarget(e){const t=this._onlyHardShadow?this.parameters.shadowIntensity:this.parameters.aoIntensity,n=this._onlyHardShadow?0:this.parameters.shadowIntensity;this.passRenderer.renderScreenSpace(e,this._blendAoAndShadowMaterial.update({texture:this._finalTexture,blending:CustomBlending,aoIntensity:t,shadowIntensity:n}),e.getRenderTarget())}}ShadowAndAoPass.shadowTransform=(new Matrix4).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class OutlineRenderer{get isOutlinePassActivated(){return this.outlinePassActivated}get outlinePass(){return this._renderPassManager.outlinePass}constructor(e,t,n){this._effectComposer=null,this.outlinePassActivated=!1,this._renderPassManager=e,this._effectComposer=t,this.parameters={enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215,...n}}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){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))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const a=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!a&&this.outlinePassActivated||(!a&&this.outlinePass||this._renderPassManager.createOutlinePass(),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class RenderCacheMapItem{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse(e=>{var t,n,a;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(a=this._cache)||void 0===a||a.addObject(e)}),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class RenderCacheManager{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach(e=>{e.dispose()})}registerCache(e,t){this._cacheMap.set(e,new RenderCacheMapItem(t))}clearCache(){this._cacheMap.forEach(e=>{e.clear()})}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const a=this._cacheMap.get(e);a&&(a.update(t),a.onBeforeRender()),n(),a&&a.onAfterRender()}}class VisibilityRenderCache{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach((e,t)=>{t.visible=!1})}onAfterRender(){this._visibilityCache.forEach((e,t)=>{t.visible=e})}}class DepthWriteRenderCache{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof MeshStandardMaterial&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!1})}onAfterRender(){this._depthWriteCache.forEach(e=>{e.depthWrite=!0})}}class ObjectRenderCache{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach((e,t)=>{t instanceof Mesh&&(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)})}onAfterRender(){this._objectCache.forEach((e,t)=>{this._updateObject(t,e.originalObjectData)})}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof Mesh?e.receiveShadow:void 0,material:e instanceof Mesh?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof Mesh&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof Mesh&&void 0!==t.material&&(e.material=t.material)}}class BakedGroundContactShadowPass extends RenderPass{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new ShadowGroundPlane(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n,a){var r,i;super(e),this.limitPlaneSize=!0,this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=n,this.shadowMapSize=null!==(r=a.shadowMapSize)&&void 0!==r?r:2048,this.parameters=this._getDefaultParameters(a),this._groundShadowFar=this.parameters.cameraFar,this._renderer=t,null===(i=this.renderCacheManager)||void 0===i||i.registerCache(this,new VisibilityRenderCache(e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name))),this.renderTarget=new WebGLRenderTarget(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new WebGLRenderTarget(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==a?void 0:a.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new GroundContactCamera,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new MeshDepthMaterial,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",ShadowGroundPlane.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));")}\n `},this._depthMaterial.side=DoubleSide,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new BlurPass(BlurShader,{...a,passRenderer:this.renderPassManager.passRenderer}),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return{enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0,...e}}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFar<e.size.z&&(this._groundShadowFar=1.01*e.size.z);const a=Math.max(e.size.x,e.size.z);this.parameters.planeSize=a+2*Math.max(this._blurScale,null!==(n=this._shadowScale)&&void 0!==n?n:1,1),this.limitPlaneSize&&this.parameters.planeSize>this.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}renderPass(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,this.scene),!this.parameters.enabled)return void(this.needsUpdate&&(this.needsUpdate=!1,this.passRenderer.clear(e,this.renderTarget,0,1)));if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(this.scene),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;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,()=>{this._renderer.render(e,this._groundContactCamera)}):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}BakedGroundContactShadowPass.addTestMesh=!1;class GroundContactCamera extends OrthographicCamera{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,a,r;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new CameraHelper(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(a=this.cameraHelper)||void 0===a?void 0:a.parent)&&(null===(r=this.cameraHelper)||void 0===r||r.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}class NormalAndDepthRenderMaterial extends ShaderMaterial{constructor(e){var t;super({defines:Object.assign({...NormalAndDepthRenderMaterial._normalAndDepthShader.defines,FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0}),uniforms:UniformsUtils.clone(NormalAndDepthRenderMaterial._normalAndDepthShader.uniforms),vertexShader:NormalAndDepthRenderMaterial._normalAndDepthShader.vertexShader,fragmentShader:NormalAndDepthRenderMaterial._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:NoBlending}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}NormalAndDepthRenderMaterial._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"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 }",fragmentShader:"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 }"};class GBufferRenderPass extends RenderPass{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new NormalAndDepthRenderMaterial({blending:NoBlending,floatBufferType:!0,linearDepth:!1}):new MeshNormalMaterial({blending:NoBlending}),this._gBufferRenderMaterial instanceof NormalAndDepthRenderMaterial&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new WebGLRenderTarget(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:FloatType,samples:this._samples});else{const e=new DepthTexture(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=DepthStencilFormat,e.type=UnsignedInt248Type,this._depthNormalRenderTarget=new WebGLRenderTarget(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new WebGLRenderTarget(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:FloatType,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,a,r,i,s,o,l,d,c;super(e),this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.drawGround=!0,this.floatRgbNormalAlphaDepth=null!==(a=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==a&&a,this.renderCacheManager&&(this._gBufferMaterialCache=new GBufferMaterialCache,this.renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(r=null==t?void 0:t.depthNormalScale)&&void 0!==r?r:1},this._targetMinificationTextureFilter=null!==(i=null==t?void 0:t.textureMinificationFilter)&&void 0!==i?i:NearestFilter,this._targetMagnificationTextureFilter=null!==(s=null==t?void 0:t.textureMagnificationFilter)&&void 0!==s?s:NearestFilter,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(d=null==t?void 0:t.samples)&&void 0!==d?d:0,this._shared=null!==(c=null==t?void 0:t.shared)&&void 0!==c&&c}dispose(){var e,t;super.dispose(),null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}renderPass(e){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this.renderPassManager.setGroundVisibility(this.drawGround),this.renderCacheManager?this.renderCacheManager.render(this,this.scene,()=>{this._renderGBuffer(e,this.scene,this.camera)}):this._renderGBuffer(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this.passRenderer.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new CopyTransformMaterial),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:NoBlending,colorTransform:ALPHA_TRANSFORM,colorBase:ALPHA_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),this.separateDeptRenderTarget)}}class GBufferMaterialCache extends ObjectRenderCache{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof Material&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof MeshPhysicalMaterial&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class GroundReflectionPass extends RenderPass{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n,a,r){super(e),this.reflectionFadeInScale=1,this._width=t,this._height=n,this._samples=null!=a?a:1,this.parameters={enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4,...r},this._copyMaterial=new CopyTransformMaterial({},"additive",!0,!0),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new GroundReflectionIntensityMaterial({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new BlurPass(BlurShader,{...r,passRenderer:this.renderPassManager.passRenderer})}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale,a={};if(e){const e=new DepthTexture(t,n);a.depthTexture=e,a.samples=this._samples}else a.samples=1;return new WebGLRenderTarget(t,n,{format:RGBAFormat,...a})}dispose(){var e,t,n;super.dispose(),null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,a,r,i;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._intensityRenderTarget)||void 0===a||a.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._blurRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._reflectionIntensityMaterial)||void 0===i||i.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const a=this.parameters.intensity*t,r=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new Matrix4).set(r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,a),multiplyChannels:0,uvTransform:FLIP_Y_UV_TRANSFORM}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}renderPass(e){if(!(this.parameters.enabled&&this.camera instanceof PerspectiveCamera))return;const t=this._createGroundReflectionCamera(this.camera);this.renderCacheManager.render("inivisibleGround",this.scene,()=>{this._renderGroundReflection(e,this.scene,t,this.reflectionRenderTarget)}),this._renderGroundReflectionIntensity(e,t,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,this.camera,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,this.reflectionFadeInScale),this.passRenderer.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,a){const r=e.getRenderTarget();a&&(e.setRenderTarget(a),this.passRenderer.clear(e,a,0,0)),e.render(t,n),a&&e.setRenderTarget(r)}_renderGroundReflectionIntensity(e,t,n){const a=e.getRenderTarget();e.setRenderTarget(n),this.passRenderer.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(a)}blurReflection(e,t,n){const a=new Vector3(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),r=this.parameters.blurHorizontal/this._width,i=this.parameters.blurVertical/this._height*Math.abs(a.dot(new Vector3(0,0,1)));this._blurPass.render(e,n,[4*r,4*i],[4*r*(1+this.parameters.blurAscent),4*i*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),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}}class GroundReflectionIntensityMaterial extends ShaderMaterial{constructor(e){super({defines:Object.assign({},GroundReflectionIntensityMaterial.shader.defines),uniforms:UniformsUtils.clone(GroundReflectionIntensityMaterial.shader.uniforms),vertexShader:GroundReflectionIntensityMaterial.shader.vertexShader,fragmentShader:GroundReflectionIntensityMaterial.shader.fragmentShader,blending:NoBlending}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const a=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(a,r)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);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)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}GroundReflectionIntensityMaterial.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new Vector2},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new Matrix4},cameraInverseProjectionMatrix:{value:new Matrix4},inverseViewMatrix:{value:new Matrix4},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:0,PREMULTIPLIED_ALPHA:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\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 }"};class RectAreaLightHelper extends Line{constructor(e,t){const n=new BufferGeometry;n.setAttribute("position",new Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new LineBasicMaterial({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const a=new BufferGeometry;a.setAttribute("position",new Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),a.computeBoundingSphere(),this.add(new Mesh(a,new MeshBasicMaterial({side:BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class IlluminationBufferMaterial extends MeshLambertMaterial{constructor(e){super(e),this.customProgramCacheKey=this._customProgramCacheKey,this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,a,r,i,s){this._enableGroundBoundary=e,IlluminationBufferMaterial._distributionProperties.set(t,n,a,r),IlluminationBufferMaterial._shadowFadeOut.set(i,s)}static setBoundingBox(e){IlluminationBufferMaterial._sceneBoxMin.copy(e.min),IlluminationBufferMaterial._sceneBoxMax.copy(e.max)}_customProgramCacheKey(){return IlluminationBufferMaterial._enableGroundBoundary?"GROUND_BOUNDARY":"NO_GROUND_BOUNDARY"}_onBeforeCompile(e,t){e.vertexShader=screenSpaceShadowMaterialVertexShader,e.fragmentShader=screenSpaceShadowMaterialFragmentShader,e.defines=Object.assign({...e.defines,DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:IlluminationBufferMaterial._enableGroundBoundary?1:0});const n=e.uniforms;n&&(n.distributionProperties={value:IlluminationBufferMaterial._distributionProperties},n.shadowFadeOut={value:IlluminationBufferMaterial._shadowFadeOut},n.sceneBoxMin={value:IlluminationBufferMaterial._sceneBoxMin},n.sceneBoxMax={value:IlluminationBufferMaterial._sceneBoxMax})}}IlluminationBufferMaterial._enableGroundBoundary=!1,IlluminationBufferMaterial._shadowFadeOut=new Vector2(.1,20),IlluminationBufferMaterial._sceneBoxMin=new Vector3(-1,-1,-1),IlluminationBufferMaterial._sceneBoxMax=new Vector3(1,1,1),IlluminationBufferMaterial._distributionProperties=new Vector4(1,1,1,1);const screenSpaceShadowMaterialVertexShader="\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\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#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",screenSpaceShadowMaterialFragmentShader="\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\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\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\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include <logdepthbuf_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\t// accumulation\n\n\tvec3 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\t// modulation\n\n\tvec3 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\t#include <opaque_fragment>\n\t#include <premultiplied_alpha_fragment>\n}\n",defaultScreenSpaceShadowMapParameters={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:"DirectionalLightShadow",maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class ScreenSpaceShadowMapPass extends RenderPass{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var a,r,i;super(e),this.needsUpdate=!1,this.drawGround=!0,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new ShadowTypeConfiguration,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._cameraUpdate=new CameraUpdate,this._viewportSize=new Vector2(t.x,t.y),this._samples=null!==(a=null==n?void 0:n.samples)&&void 0!==a?a:0,this._shadowMapSize=null!==(r=null==n?void 0:n.shadowMapSize)&&void 0!==r?r:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new ShadowMapPassOverrideMaterialCache,null===(i=this.renderCacheManager)||void 0===i||i.registerCache(this,this._shadowMapPassOverrideMaterialCache);const s=this._samples;this._shadowRenderTarget=new WebGLRenderTarget(this._viewportSize.x,this._viewportSize.y,{samples:s,format:RedFormat,magFilter:NearestFilter,minFilter:NearestFilter})}_getScreenSpaceShadowMapParameters(e){return{...defaultScreenSpaceShadowMapParameters,...e}}dispose(){super.dispose(),this._shadowLightSources.forEach(e=>e.dispose()),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const a=this._shadowScale;if(this._shadowScale=t,Math.abs(a-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach(t=>t.updateBounds(e)),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof OrthographicCamera&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach(e=>e.forceShadowUpdate()),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map(e=>e.getShadowLight())}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find(t=>t.getOriginalLight()===e))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new RectAreaShadowLightSource(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){const n=this._shadowLightSources;this._shadowLightSources=this._createShadowLightSourceArray(!1);for(const a of n){if(a instanceof RectAreaShadowLightSource){const t=a.getRectAreaLight();e.includes(t)&&(a.updatePositionAndTarget(),this._shadowLightSources.push(a))}a.removeFrom(t),a.dispose()}e.forEach(e=>{this._shadowLightSources.find(t=>t instanceof RectAreaShadowLightSource&&t.getRectAreaLight()===e)||this.addRectAreaLight(e,t)}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){for(const t of this._shadowLightSources)t.removeFrom(e),t.dispose();this._shadowLightSources=this._createShadowLightSourceArray(!0);const n=1/(t.length>0?Math.max(...t.map(e=>e.maxIntensity)):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach(t=>{t.addTo(e),t.updatePositionAndTarget()}),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach(e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new Vector3(e.position.x,e.position.z,e.position.y).multiplyScalar(7),a=new EnvironmentShadowLightSource(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(a)}})}_createShadowLightSourceArray(e){const t=[];if(e){const e=new GroundShadowLightSource(new Vector3(0,7,0),{shadowMapSize:this._shadowMapSize});t.push(e)}return this.parameters.enableGroundBoundary=e,t}setSize(e,t){this._viewportSize=new Vector2(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach(e=>e.updatePositionAndTarget())}renderPass(e){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(this.camera)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const t=this.scene.background,n=this.scene.environment,a=this.camera.layers.mask;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=a,this.scene.environment=n,this.scene.background=t}_renderSimpleShadowMapFromShadowLightSources(e,t,n){var a;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);const r=this._getSortedShadowLightSources();0===r.length?this.passRenderer.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(r),null===(a=this.renderCacheManager)||void 0===a||a.render(this,t,()=>{this.passRenderer.render(e,t,n,this._shadowRenderTarget,16777215,1)}),this._shadowLightSources.forEach(e=>e.finishRenderShadow()))}_getSortedShadowLightSources(){const e=[];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}_setShadowLightSourcesIntensity(e){let t=0;const n=this.parameters.maximumNumberOfLightSources;let a=0;e.forEach(e=>{(n<0||a<n)&&(t+=e.groundShadow?0:e.intensity,e.groundShadow||a++)}),a=0,e.forEach(e=>{var r;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||a<n)?(e.light.visible=!1,e.light.intensity=0,e.light.castShadow=!1):(e.light.visible=!0,e.light.intensity=e.groundShadow?e.intensity:e.intensity/t,(r=e.light).castShadow&&(r.castShadow=this.castShadow)),e.groundShadow||a++})}_updateShadowType(e){e.shadowMap.type=this.shadowConfiguration.currentConfiguration.type;const t=this.parameters.enableShadowMap&&this.shadowConfiguration.currentConfiguration.castShadow;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))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}class ShadowMapPassOverrideMaterialCache extends ObjectRenderCache{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial("default"),this._unlitMaterial=this._createShadowMaterial("unlit"),this._emissiveMaterial=this._createShadowMaterial("emissive"),this._receiveShadowMaterial=this._createShadowMaterial("shadow")}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,a,r,i,s){IlluminationBufferMaterial.setShadowParameters(e,t,n,a,r,i,s)}setBoundingBox(e){this._boundingBoxSet=!0,IlluminationBufferMaterial.setBoundingBox(e)}_createShadowMaterial(e){let t;return t="emissive"===e||"unlit"===e?new MeshBasicMaterial({color:16777215,side:DoubleSide}):"shadow"===e?new ShadowMaterial({side:DoubleSide}):ShadowMapPassOverrideMaterialCache.useModifiedMaterial?this._createCustomerShadowMaterial():new MeshPhongMaterial({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:DoubleSide}),t}_createCustomerShadowMaterial(){return new IlluminationBufferMaterial({side:DoubleSide})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof LineBasicMaterial||t instanceof MeshBasicMaterial?this.addToCache(e,{material:this._unlitMaterial}):t instanceof MeshStandardMaterial?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}ShadowMapPassOverrideMaterialCache.useModifiedMaterial=!0;class ShadowTypeConfiguration{constructor(){var e;this.types=new Map([["off",ShadowTypeConfiguration._noShadow],["BasicShadowMap",ShadowTypeConfiguration._basicShadow],["PCFShadowMap",ShadowTypeConfiguration._pcfShadow],["PCFSoftShadowMap",ShadowTypeConfiguration._pcfSoftShadow],["VSMShadowMap",ShadowTypeConfiguration._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:ShadowTypeConfiguration._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:ShadowTypeConfiguration._defaultType,!0)}}ShadowTypeConfiguration._noShadow={castShadow:!1,type:PCFShadowMap,bias:0,normalBias:0,radius:0},ShadowTypeConfiguration._basicShadow={castShadow:!0,type:BasicShadowMap,bias:-5e-5,normalBias:.005,radius:0},ShadowTypeConfiguration._pcfShadow={castShadow:!0,type:PCFShadowMap,bias:-5e-5,normalBias:.01,radius:4},ShadowTypeConfiguration._pcfSoftShadow={castShadow:!0,type:PCFSoftShadowMap,bias:-5e-5,normalBias:.01,radius:1},ShadowTypeConfiguration._vcmShadow={castShadow:!0,type:VSMShadowMap,bias:1e-4,normalBias:0,radius:15},ShadowTypeConfiguration._defaultType=ShadowTypeConfiguration._pcfShadow;class BaseShadowLightSource{constructor(e,t){var n,a;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(a=null==t?void 0:t.blurSamples)&&void 0!==a?a:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new Vector2(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new Vector3(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof SpotLight){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),a=Math.max(.001,Math.min(-n.min.z,-n.max.z)),r=Math.max(-n.min.z,-n.max.z),i=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),s=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(s,i),a);t.aspect=1,t.near=a,t.far=r,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,a,r;if(this._shadowLightSource instanceof SpotLight){const n=t.clone().sub(e),a=n.length();n.normalize();const r=t.clone().sub(n.clone().multiplyScalar(4*a));this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(r),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(a=this._shadowLightSource.shadow)||void 0===a||a.camera.lookAt(t);null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class RectAreaShadowLightSource extends BaseShadowLightSource{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case"DirectionalLightShadow":n=new DirectionalLight(16777215,1);break;case"SpotLightShadow":n=new SpotLight(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new RectAreaLightHelper(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class EnvironmentShadowLightSource extends BaseShadowLightSource{constructor(e,t,n){const a=new DirectionalLight(16777215,t);a.position.copy(e),a.lookAt(0,0,0),a.updateMatrix(),a.castShadow=!0,super(a,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class GroundShadowLightSource extends BaseShadowLightSource{constructor(e,t){const n=new DirectionalLight(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}const CopyShader={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},FXAAShader={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new Vector2(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t\t//----------------------------------------------------------------------------------\n\t\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t\t// SDK Version: v3.00\n\t\t// Email: gameworks@nvidia.com\n\t\t// Site: http://developer.nvidia.com/\n\t\t//\n\t\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t\t//\n\t\t// Redistribution and use in source and binary forms, with or without\n\t\t// modification, are permitted provided that the following conditions\n\t\t// are met:\n\t\t// * Redistributions of source code must retain the above copyright\n\t\t// notice, this list of conditions and the following disclaimer.\n\t\t// * Redistributions in binary form must reproduce the above copyright\n\t\t// notice, this list of conditions and the following disclaimer in the\n\t\t// documentation and/or other materials provided with the distribution.\n\t\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t\t// contributors may be used to endorse or promote products derived\n\t\t// from this software without specific prior written permission.\n\t\t//\n\t\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t\t//\n\t\t//----------------------------------------------------------------------------------\n\n\t\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t\t/*--------------------------------------------------------------------------*/\n\n\t\t#define NUM_SAMPLES 5\n\n\t\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\t\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t\t}\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t// locate the edge\n\t\t\t\tvec2 dirToEdge;\n\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t// . 2 . . 1 .\n\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t// . 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 H\n\n\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t// V 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 .\n\n\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t// 1 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t// do a simple blur\n\t\t\t\t\treturn mix(\n\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t.4\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\titerationsUsed = i;\n\n\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\tif(!doneN) {\n\t\t\t\t\tnDist += increment;\n\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t}\n\n\t\t\t\tif(!doneP) {\n\t\t\t\t\tpDist += increment;\n\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t}\n\n\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\trgbaM,\n\t\t\t\trgbaN,\n\t\t\t\tdist * .5\n\t\t\t);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t\t}\n\t"};class OutlinePass extends RenderPass{constructor(e,t,n,a,r,i){var s;super(e),this.patternTexture=null,this.clearBackground=!1,this.renderScene=n,this.renderCamera=a,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new Color$1(1,1,1),this.hiddenEdgeColor=new Color$1(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==i?void 0:i.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==i?void 0:i.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==t?new Vector2(t.x,t.y):new Vector2(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),l=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new WebGLRenderTarget(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(s=this.gBufferTextures)||void 0===s?void 0:s.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=DoubleSide,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new ShaderMaterial(FXAAShader),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 WebGLRenderTarget(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new WebGLRenderTarget(o,l),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new WebGLRenderTarget(o,l),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new WebGLRenderTarget(Math.round(o/2),Math.round(l/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new WebGLRenderTarget(o,l),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new WebGLRenderTarget(Math.round(o/2),Math.round(l/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(o,l),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(o/2),Math.round(l/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const d=CopyShader;this.copyUniforms=UniformsUtils.clone(d.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ShaderMaterial({uniforms:this.copyUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:NoBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new Color$1,this.oldClearAlpha=1,this.fsQuad=new FullScreenQuad(void 0),this.tempPulseColor1=new Color$1,this.tempPulseColor2=new Color$1,this.textureMatrix=new Matrix4}dispose(){var e,t;super.dispose(),this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.prepareMaskMaterial.dispose(),null===(t=this.fxaaRenderMaterial)||void 0===t||t.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,a;this.renderTargetMaskBuffer.setSize(e,t);let r=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(r,i),this.renderTargetBlurBuffer1.setSize(r,i),this.renderTargetEdgeBuffer1.setSize(r,i),this.separableBlurMaterial1.uniforms.texSize.value.set(r,i),r=Math.round(r/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(r,i),this.renderTargetEdgeBuffer2.setSize(r,i),this.separableBlurMaterial2.uniforms.texSize.value.set(r,i),null===(n=this.fxaaRenderMaterial)||void 0===n||n.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(a=this.renderTargetFxaaBuffer)||void 0===a||a.setSize(e,t)}_canBeHighlighted(e){return e.isMesh||OutlinePass.highlightLines&&e.isLine}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;this.selectedObjects.forEach(n=>n.traverse(n=>{this._canBeHighlighted(n)&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];this.selectedObjects.forEach(e=>e.traverse(e=>{this._canBeHighlighted(e)&&n.push(e)})),this.renderScene.traverse(a=>{if(this._canBeHighlighted(a)||a.isSprite){if(!1===n.some(e=>e.id===a.id)){const n=a.visible;!1!==e&&!0!==t.get(a)||(a.visible=e),t.set(a,n)}}else a.isPoints&&(!0===e?a.visible=t.get(a):(t.set(a,a.visible),a.visible=e))})}_updateTextureMatrix(){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)}render(e,t,n,a,r){if(this.selectedObjects.length>0){e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;this.clearBackground&&(e.setClearColor(0,255),e.clear(!0,!1,!1)),e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const a=this.renderScene.background;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,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=a;let i=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),i=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=i.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}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,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=OutlinePass.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=OutlinePass.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=OutlinePass.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=OutlinePass.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=i.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,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}renderPass(e){this.render(e,null,null,0,!1)}_getPrepareMaskMaterial(e){return new ShaderMaterial({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new Vector2(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new ShaderMaterial({uniforms:{maskTexture:{value:null},texSize:{value:new Vector2(.5,.5)},visibleEdgeColor:{value:new Vector3(1,1,1)},hiddenEdgeColor:{value:new Vector3(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new ShaderMaterial({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new Vector2(.5,.5)},direction:{value:new Vector2(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new ShaderMaterial({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0})}}OutlinePass.BlurDirectionX=new Vector2(1,0),OutlinePass.BlurDirectionY=new Vector2(0,1),OutlinePass.highlightLines=!0;const BlendAoPassDepthShader_uniforms={tDiffuse:{value:null}};class BlendAoPassDepthMaterial extends ShaderMaterial{constructor(e){super({uniforms:UniformsUtils.clone(BlendAoPassDepthShader_uniforms),vertexShader:"\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",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 }",transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:DstColorFactor,blendDst:ZeroFactor,blendEquation:AddEquation,blendSrcAlpha:DstAlphaFactor,blendDstAlpha:ZeroFactor,blendEquationAlpha:AddEquation}),this._intensity=new Vector2(1,1),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=e.texture),void 0!==(null==e?void 0:e.blending)&&(this.blending=e.blending),this}}const sphereToEquirectangular=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new Vector2(t,n)};class TextureConverter{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new WebGLRenderTarget,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?FloatType:UnsignedByteType;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new WebGLRenderTarget(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new EnvironmentMapDecodeMaterial(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new EnvironmentMapDecodeMaterial(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new OrthographicCamera(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,a){var r;this.colorRenderTarget.setSize(n,a),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new Mesh(new PlaneGeometry(2,2),new MeshBasicMaterial({map:t}));const i=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(i);const s=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*a*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,a,o),{texture:s,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,a){var r;const i=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),s=this.environmentMapDecodeTarget(e);s.setSize(n,a),i.setSourceTexture(t),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new Mesh(new PlaneGeometry(2,2),i);const o=e.getRenderTarget();e.setRenderTarget(s),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=s.texture,d=s.texture.type===FloatType,c=d?new Float32Array(n*a*4):new Uint8Array(n*a*4);return e.readRenderTargetPixels(s,0,0,n,a,c),{texture:l,pixels:c,sRgbaPixels:d}}}const EnvironmentMapDecodeShader_uniforms={tDiffuse:{value:null}};class EnvironmentMapDecodeMaterial extends ShaderMaterial{constructor(e,t){super({uniforms:UniformsUtils.clone(EnvironmentMapDecodeShader_uniforms),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",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 }",defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}class LightSourceDetector{constructor(e){var t,n,a,r;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new Texture,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new Texture,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new LightGraph(0),this.lightSources=[],this._grayScale=new Vector3(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;n<e;n++){const a=n*Math.PI*(3-Math.sqrt(5)),r=1-n/(e-1)*2,i=Math.sqrt(1-r*r),s=Math.cos(a)*i,o=Math.sin(a)*i;t.push(new Vector3(s,o,r))}return t},this._numberOfSamples=null!==(t=null==e?void 0:e.numberOfSamples)&&void 0!==t?t:1e3,this._width=null!==(n=null==e?void 0:e.width)&&void 0!==n?n:1024,this._height=null!==(a=null==e?void 0:e.height)&&void 0!==a?a:512,this._sampleThreshold=null!==(r=null==e?void 0:e.sampleThreshold)&&void 0!==r?r:.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=>sphereToEquirectangular(e))}detectLightSources(e,t,n){var a;this.textureData=n,this._textureConverter=null!==(a=this._textureConverter)&&void 0!==a?a:new TextureConverter,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)}_redFromRgbaToNormalizedFloatArray(e,t,n){const a=new Float32Array(e.length/4);let r=1,i=0;for(let t=0;t<e.length/4;++t){const n=new Color$1(...e.slice(4*t,4*t+3));e instanceof Float32Array&&n.convertSRGBToLinear();const s=new Vector3(n.r,n.g,n.b).dot(this._grayScale);r=Math.min(r,s),i=Math.max(i,s),a[t]=s}if(n)for(let e=0;e<a.length;++e){const s=t?a[e]:(a[e]-r)/(i-r);a[e]=Math.pow(s,n)}else if(!t)for(let e=0;e<a.length;++e)a[e]=(a[e]-r)/(i-r);return a}_grayscaleTextureFromFloatArray(e,t,n){const a=t*n,r=new Uint8Array(4*a);for(let t=0;t<a;t++){const n=255*e[t];r[4*t+0]=n,r[4*t+1]=n,r[4*t+2]=n,r[4*t+3]=255}const i=new DataTexture(r,t,n);return i.needsUpdate=!0,i}_filterLightSamples(e){const t=[];for(let n=0;n<this.sampleUVs.length;n++){const a=this.sampleUVs[n];this._detectorTextureLuminanceValueFromUV(a)>e&&t.push(new LightSample(this.samplePoints[n],a))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let a=0;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){const n=t*this.textureData._width+e,r=(this.textureData.data[4*n]+this.textureData.data[4*n+1]+this.textureData.data[4*n+2])/3;a=Math.max(a,r)}return a}_findClusterSegments(e,t){const n=2*this.pixelDistance,a=1.5*this.pointDistance,r=new LightGraph(e.length);for(let i=0;i<e.length;i++)for(let s=i+1;s<e.length;s++)if(e[i].position.angleTo(e[s].position)<a){const a=e[s].position.clone().sub(e[i].position),o=Math.floor(a.length()/n);let l=!0,d=0;for(let n=1;n<o;n++){const r=a.clone().multiplyScalar(n/o),s=sphereToEquirectangular(e[i].position.clone().add(r).normalize());if(this._detectorTextureLuminanceValueFromUV(s)<t){if(d++,d>1){l=!1;break}}else d=0}l&&(r.adjacent[i].push(s),r.adjacent[s].push(i),r.edges.push([i,s]))}return r}createLightSourcesFromLightGraph(e,t){const n=t.components.filter(e=>e.length>1).map(t=>new LightSource(t.map(t=>e[t])));return n.forEach(e=>e.calculateLightSourceProperties(e=>this._originalLuminanceValueFromUV(e))),n}}class LightSample{constructor(e,t){this.position=e,this.uv=t}}class LightGraph{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;t<e;t++)this.adjacent.push([])}findConnectedComponents(){const e=new Array(this.noOfNodes).fill(!1);this.components=[];for(let t=0;t<this.noOfNodes;t++)if(!e[t]){const n=[];this._dfs(t,e,n),this.components.push(n)}this.components.sort((e,t)=>t.length-e.length)}_dfs(e,t,n){t[e]=!0,n.push(e);for(const a of this.adjacent[e])t[a]||this._dfs(a,t,n)}}class LightSource{constructor(e){this.position=new Vector3,this.uv=new Vector2,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new Vector3,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=sphereToEquirectangular(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class DebugPass extends RenderPass{constructor(e){super(e),this.debugOutput="",this._environmentMapDecodeMaterial=new EnvironmentMapDecodeMaterial(!0,!1),this._environmentMapDecodeMaterial.blending=NoBlending,this._environmentMapDecodeMaterial.depthTest=!1}dispose(){var e,t,n;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),null===(n=this._srgbToLinearCopyMaterial)||void 0===n||n.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new CopyTransformMaterial,this._copyMaterial.update(e)}getBlendAoAndShadowMaterial(e){var t;return this._blendAoAndShadowMaterial=null!==(t=this._blendAoAndShadowMaterial)&&void 0!==t?t:new BlendAoAndAShadowMaterial({blending:NoBlending}),this._blendAoAndShadowMaterial.update(e)}getBlendAoPassDepthMaterial(e){var t;return this._blendAoPassDepthMaterial=null!==(t=this._blendAoPassDepthMaterial)&&void 0!==t?t:new BlendAoPassDepthMaterial({blending:NoBlending}),this._blendAoPassDepthMaterial.update(e)}getSrgbToLinearCopyMaterial(e){var t;return this._srgbToLinearCopyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new CopyTransformMaterial({},"additive",!0,!0),this._srgbToLinearCopyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new LinearDepthRenderMaterial({depthTexture:this.gBufferTextures.textureWithDepthValue,depthFilter:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?new Vector4(0,0,0,1):new Vector4(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}renderPass(e){var t,n,a,r,i,s;switch(this.debugOutput){default:break;case"lineardepth":this.passRenderer.renderScreenSpace(e,this._getDepthRenderMaterial(this.camera),null);break;case"g-normal":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(t=this.gBufferTextures)||void 0===t?void 0:t.gBufferTexture,blending:NoBlending,colorTransform:(new Matrix4).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new Vector4(.5,.5,.5,1),multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(n=this.gBufferTextures)||void 0===n?void 0:n.gBufferTexture,blending:NoBlending,colorTransform:RGB_TRANSFORM,colorBase:ALPHA_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"g-depth":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(a=this.gBufferTextures)||void 0===a?void 0:a.gBufferTexture,blending:NoBlending,colorTransform:ALPHA_TRANSFORM,colorBase:ALPHA_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(r=this.gBufferTextures)||void 0===r?void 0:r.depthBufferTexture,blending:NoBlending,colorTransform:RED_TRANSFORM,colorBase:ALPHA_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"ssao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:NoBlending,colorTransform:GRAYSCALE_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"ssaodenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:NoBlending,colorTransform:GRAYSCALE_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"shadowmap":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.screenSpaceShadowMapPass.shadowTexture,blending:NoBlending,colorTransform:GRAYSCALE_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"shadowsoft":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:NoBlending,colorTransform:ShadowAndAoPass.shadowTransform,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"shadowdenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:NoBlending,colorTransform:ShadowAndAoPass.shadowTransform,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"shadowfadein":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.fadeRenderTarget.texture,blending:NoBlending,colorTransform:ShadowAndAoPass.shadowTransform,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"shadowandao":this.passRenderer.renderScreenSpace(e,this.getBlendAoAndShadowMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:NoBlending,aoIntensity:this.renderPassManager.shadowAndAoPass.parameters.aoIntensity,shadowIntensity:this.renderPassManager.shadowAndAoPass.parameters.shadowIntensity}),null);break;case"shadowandaodepth":this.passRenderer.renderScreenSpace(e,this.getBlendAoPassDepthMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:NoBlending}),null);break;case"materialao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.aoPassMapTexture,blending:NoBlending,colorTransform:DEFAULT_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"groundreflection":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.reflectionRenderTarget.texture,blending:NoBlending,colorTransform:DEFAULT_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:FLIP_Y_UV_TRANSFORM}),null);break;case"groundreflectionfinal":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.intensityRenderTarget.texture,blending:NoBlending,colorTransform:DEFAULT_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:FLIP_Y_UV_TRANSFORM}),null);break;case"bakedgroundshadow":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.bakedGroundContactShadowPass.renderTarget.texture,blending:NoBlending,colorTransform:DEFAULT_TRANSFORM,colorBase:ZERO_RGBA,multiplyChannels:0,uvTransform:DEFAULT_UV_TRANSFORM}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(this.scene.environment),this.passRenderer.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(i=this.scene.userData)||void 0===i?void 0:i.environmentDefinition){const t=this.renderPassManager.aspect,n=new OrthographicCamera(-1,1,1/t,-1/t,-1,1),a=null===(s=this.scene.userData)||void 0===s?void 0:s.environmentDefinition.createDebugScene(e,this.scene,this.renderPassManager.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources);a.background=new Color$1(16777215),e.render(a,n)}}}}class SceneRenderPass extends RenderPass{constructor(e){super(e),this.drawGround=!0,this.drawWithDebugMaterial=!1,this.grayDebugMaterial=new MeshStandardMaterial({color:12632256,side:DoubleSide,envMapIntensity:.4})}dispose(){super.dispose(),this.grayDebugMaterial.dispose()}renderPass(e){this.renderCacheManager.onBeforeRender("floorDepthWrite",this.scene),this.renderPassManager.setGroundVisibility(this.drawGround),this.drawWithDebugMaterial?this.renderCacheManager.render("debug",this.scene,()=>{this.passRenderer.renderWithOverrideMaterial(e,this.scene,this.camera,this.grayDebugMaterial,null,0,1)}):e.render(this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}}class PostProcessingMaterialPlugin{constructor(){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}set aoPassMap(e){this._aoPassMapUniform.value=e}set aoPassMapScale(e){this._aoPassMapScaleUniform.value=e}set aoPassMapIntensity(e){this._aoPassMapIntensityUniform.value=e}set shPassMapIntensity(e){this._shPassMapIntensityUniform.value=e}set reflectionPassMap(e){this._reflectionPassMapUniform.value=e}set reflectionPassMapScale(e){this._reflectionPassMapScaleUniform.value=e}set reflectionPassMapIntensity(e){this._reflectionPassMapIntensityUniform.value=e}static addPlugin(e){if(e instanceof MeshPhysicalMaterial&&e.transmission>0)return null;if(void 0!==e.userData.postProcessingMaterialPlugin)return e.userData.postProcessingMaterialPlugin instanceof PostProcessingMaterialPlugin?e.userData.postProcessingMaterialPlugin:null;const t=new PostProcessingMaterialPlugin;return e.userData.postProcessingMaterialPlugin=t,e.onBeforeCompile=(e,n)=>t._onBeforeCompile(e,n),e.customProgramCacheKey=()=>t._customProgramCacheKey(),t}_isEnabled(){return void 0!==this._aoPassMapUniform.value&&null!==this._aoPassMapUniform.value}_customProgramCacheKey(){let e="";return this._isEnabled()&&(e+="aoPassMap"+(this.applyAoAndShadowToAlpha?"Alpha":"")),this.applyReflectionPassMap&&(e+="reflectionPassMap"),e}_onBeforeCompile(e,t){if(this._isEnabled()||this.applyReflectionPassMap){let t=this.applyAoAndShadowToAlpha?"#define USE_APPLY_AO_AND_SHADOW_TO_ALPHA\n":"";t+=this.applyReflectionPassMap?"#define USE_REFLECTION_PASS_MAP\n":"",t+=aoMapParsFragmentReplacement,e.fragmentShader=e.fragmentShader.replace("#include <aomap_pars_fragment>",t),e.fragmentShader=e.fragmentShader.replace("#include <aomap_fragment>",aoMapFragmentReplacement),this._initUniforms(e)}}_initUniforms(e){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)}}const aoMapParsFragmentReplacement="\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n\n\tuniform 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",aoMapFragmentReplacement="\n#ifndef AOPASSMAP_SWIZZLE\n\t#define AOPASSMAP_SWIZZLE rg\n#endif\n\nfloat ambientOcclusion = 1.0;\nfloat shadowValue = 1.0;\n\t\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tambientOcclusion = 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\treflectedLight.indirectDiffuse *= ambientOcclusion * shadowValue;\n \n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n \n float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion * shadowValue, material.roughness );\n\t\treflectedLight.indirectSpecular *= specularOcclusion;\n\n #ifdef USE_REFLECTION_PASS_MAP\n reflectedLight.indirectSpecular += material.specularColor * reflectionPassMapColor.rgb * reflectionPassMapColor.a * reflectionPassMapIntensity * specularOcclusion;\n #endif \n \n\t#endif\n";class RenderPassManager{get passRenderer(){return this._passRenderer}get scene(){return this._scene}get camera(){return this._camera}get aspect(){return this._sceneRenderer.width/this._sceneRenderer.height}get cameraChanged(){return this._cameraChanged}get noOStaticFrames(){return this._noOStaticFrames}get renderCacheManager(){return this._sceneRenderer.renderCacheManager}get parameters(){return this._sceneRenderer.parameters}get sceneRenderPass(){return this._sceneRenderPass}get bakedGroundContactShadowPass(){return this._bakedGroundContactShadowPass}get gBufferRenderPass(){return this._gBufferRenderPass}get groundReflectionPass(){return this._groundReflectionPass}get screenSpaceShadowMapPass(){return this._screenSpaceShadowMapPass}get shadowAndAoPass(){return this._shadowAndAoPass}get outlinePass(){return this._outlinePass}get outlineRenderer(){return this._sceneRenderer.outlineRenderer}get debugPass(){var e;return null!==(e=this._debugPass)&&void 0!==e||(this._debugPass=new DebugPass(this)),this._debugPass}get debugOutput(){return this._sceneRenderer.debugOutput}constructor(e){this.materialsNeedUpdate=!0,this._passRenderer=new PassRenderer,this._outlinePass=null,this._debugPass=null,this._cameraUpdate=new CameraUpdate,this._cameraChanged=!0,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._maxSamples=1,this._passUpdateStates={updateGroundReflection:!1,updateGBuffer:!1,updateScreenSpaceShadow:!1,updateShadowAndAoPass:!1,updateOutlinePass:!1,updateDebugPass:!1},this.aoPassMapTexture=null,this._sceneRenderer=e,this._maxSamples=this._sceneRenderer.renderer.capabilities.maxSamples,this._sceneRenderPass=new SceneRenderPass(this),this._bakedGroundContactShadowPass=new BakedGroundContactShadowPass(this,this._sceneRenderer.renderer,this._sceneRenderer.groundGroup,{sharedShadowGroundPlane:this._sceneRenderer.shadowAndAoGroundPlane}),this._gBufferRenderPass=new GBufferRenderPass(this,{shared:!0,capabilities:this._sceneRenderer.renderer.capabilities,width:this._sceneRenderer.width,height:this._sceneRenderer.height,samples:0}),this._groundReflectionPass=new GroundReflectionPass(this,this._sceneRenderer.width,this._sceneRenderer.height,this._maxSamples,{}),this._screenSpaceShadowMapPass=new ScreenSpaceShadowMapPass(this,new Vector2(this._sceneRenderer.width,this._sceneRenderer.height),{samples:1,alwaysUpdate:!1}),this._shadowAndAoPass=new ShadowAndAoPass(this,this._sceneRenderer.width,this._sceneRenderer.height,0)}dispose(){var e;this._sceneRenderPass.dispose(),this._bakedGroundContactShadowPass.dispose(),this._gBufferRenderPass.dispose(),this._groundReflectionPass.dispose(),this._screenSpaceShadowMapPass.dispose(),this._shadowAndAoPass.dispose(),null===(e=this._outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._gBufferRenderPass.setSize(e,t),this._groundReflectionPass.setSize(e,t),this._screenSpaceShadowMapPass.setSize(e,t),this._shadowAndAoPass.setSize(e,t),null===(n=this._outlinePass)||void 0===n||n.setSize(e,t)}createOutlinePass(){return this._outlinePass||(this._outlinePass=new OutlinePass(this,new Vector2(this._sceneRenderer.width,this._sceneRenderer.height),this.scene,this.camera,[],{downSampleRatio:2,edgeDetectionFxaa:!0})),this._outlinePass}setGroundVisibility(e){this._sceneRenderer.shadowAndAoGroundPlane.setVisibility(e)}updatePasses(e,t,n){this._scene=t,this._camera=n,this._cameraChanged=this._cameraUpdate.changed(n);const a=this._evaluateIfShadowAndAoUpdateIsNeeded();this._updateSceneRenderPass(),this._updateBakedGroundContactShadowPass(),this._updateGBufferPass(a),this._updateGroundReflectionPass(a),this._updateScreenSpaceShadowPass(a),this._updateShadowAndAoPass(a),this._updateOutlinePass(),this._updateDebugPass()}_evaluateIfShadowAndAoUpdateIsNeeded(){const e=this._shadowAndAoPass.parameters.alwaysUpdate||this._screenSpaceShadowMapPass.needsUpdate||this._screenSpaceShadowMapPass.shadowTypeNeedsUpdate;let t=(this._shadowAndAoPass.parameters.enabled||this._groundReflectionPass.parameters.enabled)&&this._cameraChanged,n=1;return 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||1!==n||this._noOStaticFrames++,t=e||t,{needsUpdate:t,shadowOnCameraChange:!t||n<.99?this.parameters.shadowOnCameraChange:"off",intensityScale:n}}_dynamicChanges(e){return e.needsUpdate||"off"!==e.shadowOnCameraChange}_updateSceneRenderPass(){this._sceneRenderPass.drawWithDebugMaterial=!1}_updateBakedGroundContactShadowPass(){const e=this._bakedGroundContactShadowPass.limitPlaneSize;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}_updateGBufferPass(e){this._passUpdateStates.updateGBuffer=!1,this._gBufferRenderPass.needsUpdate=e.needsUpdate||"poisson"===e.shadowOnCameraChange,this.gBufferRenderPass.drawGround=this._sceneRenderer.boundingVolumeSet&&this._shadowAndAoPass.parameters.aoOnGround}_updateGroundReflectionPass(e){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)}_updateScreenSpaceShadowPass(e){this._dynamicChanges(e)?(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):this._passUpdateStates.updateScreenSpaceShadow=!1}_updateShadowAndAoPass(e){this._dynamicChanges(e)?(this._shadowAndAoPass.shadowAndAoPassSettings={shadowMapTexture:this._screenSpaceShadowMapPass.shadowTexture,shadowBlurType:e.needsUpdate?"full":e.shadowOnCameraChange,shadowFadeInBlurType:e.shadowOnCameraChange,shadowFadeInMix:1-e.intensityScale,noOStaticFrames:this.noOStaticFrames},this._passUpdateStates.updateShadowAndAoPass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateShadowAndAoPass=!1}_updateOutlinePass(){this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass?(this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.clearBackground=!1,this._passUpdateStates.updateOutlinePass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateOutlinePass=!1}_updateDebugPass(){if(this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput){if("outline"===this.debugOutput&&this.outlineRenderer.outlinePass)return this.outlineRenderer.outlinePass.clearBackground=!0,void(this._passUpdateStates.updateDebugPass=!1);if("color"===this.debugOutput||"grayscale"===this.debugOutput)return this._passUpdateStates.updateGroundReflection=!1,this._passUpdateStates.updateGBuffer=!1,this._passUpdateStates.updateScreenSpaceShadow=!1,this._passUpdateStates.updateShadowAndAoPass=!1,this._passUpdateStates.updateOutlinePass=!1,this._passUpdateStates.updateDebugPass=!1,void(this._sceneRenderPass.drawWithDebugMaterial="grayscale"===this.debugOutput);this.debugPass.debugOutput=this.debugOutput,this._passUpdateStates.updateDebugPass=!0}else this._passUpdateStates.updateDebugPass=!1}_updateMaterials(e,t){if(!this.materialsNeedUpdate||!this._shadowAndAoPass.parameters.applyToMaterial)return;this.aoPassMapTexture=this._shadowAndAoPass.denoiseRenderTargetTexture;const n=e.getPixelRatio();this.materialsNeedUpdate=!1,t.traverse(e=>{if(e.isMesh){const t=e.material;t instanceof MeshStandardMaterial&&this._updateMaterial(e,t,n)}})}_updateMaterial(e,t,n){const a=PostProcessingMaterialPlugin.addPlugin(t);a&&(this._updatePlugInAo(a,e,t,n),this._updatePlugInReflection(a,e),t.needsUpdate=!1)}_updatePlugInAo(e,t,n,a){const r=this._shadowAndAoPass.parameters.enabled&&this._shadowAndAoPass.parameters.applyToMaterial&&null!==this.aoPassMapTexture&&("ShadowGroundPlaneMaterial"===n.name||t.receiveShadow&&(!n.transparent||n.alphaTest>=.9)),i=r&&this._shadowAndAoPass.parameters.aoIntensity>.01,s=r&&this._screenSpaceShadowMapPass.enabled&&this._shadowAndAoPass.parameters.shadowIntensity>.01;e.applyAoAndShadowToAlpha="ShadowGroundPlaneMaterial"===n.name,e.aoPassMapIntensity=i?2*this._shadowAndAoPass.parameters.aoIntensity:-1,e.shPassMapIntensity=s?2*this._shadowAndAoPass.parameters.shadowIntensity:-1,e.aoPassMapScale=1/a,e.aoPassMap=this.aoPassMapTexture}_updatePlugInReflection(e,t){const n=this._groundReflectionPass.intensityRenderTarget.texture,a=t.userData.isPlanFloor&&this._groundReflectionPass.parameters.enabled&&(null!==n||void 0!==n),r=this._groundReflectionPass.parameters.intensity;e.applyReflectionPassMap=a,e.reflectionPassMapIntensity=a?Math.pow(r,.5):0,e.reflectionPassMapScale=1/(this._groundReflectionPass.parameters.renderTargetDownScale*devicePixelRatio),e.reflectionPassMap=a?n:null}renderPasses(e,t){var n,a;e.setRenderTarget(null),this._bakedGroundContactShadowPass.renderPass(e),this._passUpdateStates.updateGBuffer&&this._gBufferRenderPass.renderPass(e),this._passUpdateStates.updateScreenSpaceShadow&&this._screenSpaceShadowMapPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&this._shadowAndAoPass.renderPass(e),this._updateMaterials(e,t),this._sceneRenderPass.renderPass(e),this._passUpdateStates.updateGroundReflection&&this._groundReflectionPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&!this._shadowAndAoPass.parameters.applyToMaterial&&this._shadowAndAoPass.renderToTarget(e),this._passUpdateStates.updateOutlinePass&&(null===(n=this._outlinePass)||void 0===n||n.renderPass(e)),this._passUpdateStates.updateDebugPass&&(null===(a=this._debugPass)||void 0===a||a.renderPass(e))}}class SceneRenderer{get sceneRenderPass(){return this._renderPassManager.sceneRenderPass}get bakedGroundContactShadowPass(){return this._renderPassManager.bakedGroundContactShadowPass}get gBufferRenderPass(){return this._renderPassManager.gBufferRenderPass}get groundReflectionPass(){return this._renderPassManager.groundReflectionPass}get screenSpaceShadowMapPass(){return this._renderPassManager.screenSpaceShadowMapPass}get shadowAndAoPass(){return this._renderPassManager.shadowAndAoPass}get debugPass(){return this._renderPassManager.debugPass}get shadowAndAoGroundPlane(){return this._shadowAndAoGroundPlane}constructor(e,t,n){this.debugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.enableObjectSelection=!0,this.groundLevel=0,this.uiInteractionMode=!1,this.width=0,this.height=0,this.boundingVolume=new SceneVolume,this.boundingVolumeSet=!1,this.renderCacheManager=new RenderCacheManager,this.selectedObjects=[],this.groundGroup=new Group,this._shadingType="default",this._qualityLevel="highest",this._qualityMap=new Map,this._customShadingParameters=null,this.width=t,this.height=n,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new VisibilityRenderCache(e=>e===this.groundGroup)),this.renderCacheManager.registerCache("debug",new VisibilityRenderCache),this.renderCacheManager.registerCache("floorDepthWrite",new DepthWriteRenderCache(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor})),this._shadowAndAoGroundPlane=new ShadowGroundPlane(null),this.groundGroup.rotateX(-Math.PI/2),this._renderPassManager=new RenderPassManager(this),this.outlineRenderer=new OutlineRenderer(this._renderPassManager,null,{}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderPass.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadowPass.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadowMapPass.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:"off"},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",()=>{}),e.domElement.addEventListener("webglcontextrestored",()=>{this._forceEnvironmentMapUpdate(this.renderer)})}dispose(){var e;null===(e=this._copyMaterial)||void 0===e||e.dispose(),this._renderPassManager.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this._renderPassManager.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setShadingType(e){this._shadingType!==e&&(this._shadingType=e,this.applyCurrentParameters())}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}setCustomShadingParameters(e){this._customShadingParameters=e,this.applyCurrentParameters(),this.requestUpdateOfPasses()}setQualityMapAndShadingParameters(e,t){this._qualityMap=e,this._customShadingParameters=t,this.applyCurrentParameters(),this.requestUpdateOfPasses()}applyCurrentParameters(){const e=[];this._qualityMap.has(this._qualityLevel)&&e.push(this._qualityMap.get(this._qualityLevel));const t=(n=this._shadingType)&&"default"!==n&&"bright"===n?brightSceneShadingParameters:null;var n;t&&e.push(t);const a=this.uiInteractionMode?{groundReflectionParameters:{enabled:!1}}:null;if(a&&e.push(a),this._customShadingParameters&&e.push((e=>{const t={shAndAoPassParameters:{ao:{},shadow:{}},groundReflectionParameters:{},bakedGroundContactShadowParameters:{}};return((e,t)=>{void 0!==t.aoIntensity&&(e.shAndAoPassParameters.aoIntensity=_clamp(t.aoIntensity)),void 0!==t.aoExtent&&(e.shAndAoPassParameters.ao.radius=.3*_clamp(t.aoExtent),e.shAndAoPassParameters.ao.thickness=.1+.2*_clamp(t.aoExtent))})(t,e),((e,t)=>{t.shBakedOnGround?(e.bakedGroundContactShadowParameters.enabled=!0,e.shAndAoPassParameters.shadowIntensity=0,void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.opacity=_clamp(t.shadowIntensity)),void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.blurMax=.1*_clamp(t.shadowIntensity),e.bakedGroundContactShadowParameters.blurMin=.01*e.bakedGroundContactShadowParameters.blurMax)):(void 0!==t.shBakedOnGround&&(e.bakedGroundContactShadowParameters.enabled=!1),void 0!==t.shadowIntensity&&(e.shAndAoPassParameters.shadowIntensity=_clamp(t.shadowIntensity)),void 0!==t.shadowSoftening&&(e.shAndAoPassParameters.shadow.shadowRadius=.001+.2*_clamp(t.shadowSoftening)))})(t,e),((e,t)=>{void 0!==t.grReflectIntensity&&(e.groundReflectionParameters.enabled=t.grReflectIntensity>0,e.groundReflectionParameters.intensity=_clamp(t.grReflectIntensity)),void 0!==t.grReflectFadeOut&&(e.groundReflectionParameters.fadeOutDistance=4*(1-_clamp(t.grReflectFadeOut)))})(t,e),t})(this._customShadingParameters)),e.length>0){const t=((...e)=>{if(0===e.length)return null;if(1===e.length)return e[0];let t=e[0];for(let n=1;n<e.length;n++)t=deepMerge(t,e[n]);return t})(...e);this.updateParameters(t),this.bakedGroundContactShadowPass.applyParameters()}}requestUpdateOfPasses(){this.gBufferRenderPass.needsUpdate=!0,this.screenSpaceShadowMapPass.needsUpdate=!0,this.shadowAndAoPass.needsUpdate=!0,this.shadowAndAoPass.softShadowPass.needsUpdate=!0,this._renderPassManager.materialsNeedUpdate=!0}clearCache(){this.renderCacheManager.clearCache(),this._renderPassManager.materialsNeedUpdate=!0}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderPass.needsUpdate=!0,this.screenSpaceShadowMapPass.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadowPass.needsUpdate=!0)}updateParameters(e){e.shadowType&&this.screenSpaceShadowMapPass.switchType(e.shadowType),void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadowPass.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadowMapPass.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadowMapPass.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadowMapPass.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadowMapPass.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache();const n=e.clone();n.min.y>this.groundLevel&&(n.min.y=this.groundLevel),this.boundingVolumeSet=!0,this.gBufferRenderPass.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(n);const a=this.boundingVolume.size,r=(a.x+a.y+a.z)/3,i=Math.min(a.x,a.y,a.z),s=Math.max(a.x,a.y,a.z),o=i<.5?i/.5:a.z>5?a.z/5:1;this.bakedGroundContactShadowPass.setScale(t?r:o,r),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,s)),this.screenSpaceShadowMapPass.updateBounds(this.boundingVolume,r),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?r:Math.min(1,2*s))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,a;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const r=e.userData;if(r&&((null===(a=t.userData)||void 0===a?void 0:a.environmentDefinition.needsUpdate)||!r.environmentTexture||r.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(r.environmentDefinition=n,r.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==r?void 0:r.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){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)}}class SceneRendererGUI{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const a=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(a,t);const r=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(r,t);const i=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(i,t);const s=e.addFolder("Outline");this._addOutlineGUI(s,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",LinearSRGBColorSpace],["SRGBColorSpace",SRGBColorSpace]]),a=[];n.forEach((e,t)=>{a.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)}),e.add(this._sceneRenderer,"outputColorSpace",a).onChange(e=>{var a;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(a=n.get(e))&&void 0!==a?a:SRGBColorSpace,t())});const r=new Map([["NoToneMapping",NoToneMapping],["LinearToneMapping",LinearToneMapping],["ReinhardToneMapping",ReinhardToneMapping],["CineonToneMapping",CineonToneMapping],["ACESFilmicToneMapping",ACESFilmicToneMapping]]),i=[];r.forEach((e,t)=>{i.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)}),e.add(this._sceneRenderer,"toneMapping",i).onChange(e=>{var n;r.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=r.get(e))&&void 0!==n?n:NoToneMapping,t())})}_addDebugGUI(e,t){const n=new Map([["HIGHEST","highest"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"]]),a=[];n.forEach((e,t)=>a.push(t)),e.add(this,"_qualityLevel",a).onChange(e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:"highest")}),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow soft":"shadowsoft","shadow denoised":"shadowdenoise","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","shadow and AO depth":"shadowandaodepth","material AO pass":"materialao","ground reflection base":"groundreflection","ground reflection final":"groundreflectionfinal","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange(()=>t())}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadowMapPass.shadowConfiguration,a=[];n.types.forEach((e,t)=>{a.push(t)});const r=()=>{this._sceneRenderer.screenSpaceShadowMapPass.needsUpdate=!0,this._sceneRenderer.screenSpaceShadowMapPass.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",a).onChange(e=>{this._sceneRenderer.screenSpaceShadowMapPass.switchType(e)&&(i.object=n.currentConfiguration,s.object=n.currentConfiguration,o.object=n.currentConfiguration,i.updateDisplay(),s.updateDisplay(),o.updateDisplay(),r())});const i=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange(()=>r()),s=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange(()=>r()),o=e.add(n.currentConfiguration,"radius",0,100).onChange(()=>r())}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.requestUpdateOfPasses(),t()},a=this._sceneRenderer.shadowAndAoPass.parameters,r=a.shadow,i=this._sceneRenderer.screenSpaceShadowMapPass.parameters,s=a.ao,o=a.poissonDenoise;e.add(a,"enabled").onChange(()=>n()),e.add(a,"applyToMaterial").onChange(()=>{n(),this._sceneRenderer.clearCache()});const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),d=Array.from(l.keys());l.forEach((e,t)=>{e===s.algorithm&&(this._ambientOcclusionType=t)}),e.add(a,"aoIntensity",0,1).onChange(()=>{n()}),e.add(a,"aoOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(a,"shadowOnGround").onChange(()=>{n(),this._sceneRenderer.clearCache()}),e.add(a,"shadowIntensity",0,1).onChange(()=>n()),e.add(a,"alwaysUpdate").onChange(()=>n()),e.add(a,"progressiveDenoiseIterations",0,3,1).onChange(()=>n());const c=e.addFolder("Environment Shadow");c.add(i,"maximumNumberOfLightSources",-1,10,1).onChange(()=>n()),c.add(i,"enableGroundBoundary").onChange(()=>n()),c.add(i,"directionalDependency",0,1,.01).onChange(()=>n()),c.add(i,"directionalExponent",0,2,.01).onChange(()=>n()),c.add(i,"groundBoundary",0,1,.01).onChange(()=>n()),c.add(i,"fadeOutDistance",0,5,.01).onChange(()=>n()),c.add(i,"fadeOutBlur",0,20,1).onChange(()=>n()),c.add(r,"shadowRadius",.001,.5).onChange(()=>n());const h=e.addFolder("AO");h.add(this,"_ambientOcclusionType",d).onChange(e=>{if(l.has(e)){const t=l.get(e);s.algorithm=void 0!==t?t:0,n()}}),h.add(s,"samples",1,64,1).onChange(()=>n()),h.add(s,"radius",.01,2,.01).onChange(()=>n()),h.add(s,"distanceExponent",.1,4,.1).onChange(()=>n()),h.add(s,"thickness",.01,2,.01).onChange(()=>n()),h.add(s,"distanceFallOff",0,1).onChange(()=>n()),h.add(s,"scale",.01,2,.01).onChange(()=>n()),h.add(s,"bias",1e-4,.01,1e-4).onChange(()=>n()),h.add(s,"screenSpaceRadius").onChange(()=>n());const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange(()=>n()),u.add(o,"samples",0,32,1).onChange(()=>n()),u.add(o,"rings",0,16,.125).onChange(()=>n()),u.add(o,"radiusExponent",.1,4,.01).onChange(()=>n()),u.add(o,"radius",0,50,1).onChange(()=>n()),u.add(o,"depthPhi",0,20,.001).onChange(()=>n()),u.add(o,"normalPhi",0,20,.001).onChange(()=>n())}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange(()=>t()),e.add(n,"fadeOutDistance",0,4).onChange(()=>t()),e.add(n,"fadeOutExponent",.1,10).onChange(()=>t()),e.add(n,"brightness",0,2).onChange(()=>t()),e.add(n,"blurHorizontal",0,10).onChange(()=>t()),e.add(n,"blurVertical",0,10).onChange(()=>t())}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadowPass.applyParameters(),t()},a=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(a,"enabled").onChange(()=>n()),e.add(a,"cameraHelper").onChange(()=>n()),e.add(a,"alwaysUpdate"),e.add(a,"fadeIn"),e.add(a,"blurMin",0,.2,.001).onChange(()=>n()),e.add(a,"blurMax",0,.5,.01).onChange(()=>n()),e.add(a,"fadeoutFalloff",0,1,.01).onChange(()=>n()),e.add(a,"fadeoutBias",0,.5).onChange(()=>n()),e.add(a,"opacity",0,1,.01).onChange(()=>n()),e.add(a,"maximumPlaneSize",0,50,1).onChange(()=>n()),e.add(a,"cameraFar",.1,10,.1).onChange(()=>n())}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},a=this._sceneRenderer.outlineRenderer.parameters;e.add(a,"enabled"),e.add(a,"edgeStrength",.5,20).onChange(()=>n()),e.add(a,"edgeGlow",0,20).onChange(()=>n()),e.add(a,"edgeThickness",.5,20).onChange(()=>n()),e.add(a,"pulsePeriod",0,5).onChange(()=>n()),e.addColor(a,"visibleEdgeColor").onChange(()=>n()),e.addColor(a,"hiddenEdgeColor").onChange(()=>n())}}const noEffectsSuspension={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:"full"},partialEffectsSuspension={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:"poisson"},fullEffectsSuspension={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:"poisson"},configuratorAoSettings={algorithm:0,samples:32,radius:.15,distanceExponent:2,thickness:.25,distanceFallOff:1,bias:.01},configuratorDenoiseSettings={iterations:2,samples:16,rings:2.89,radius:4,radiusExponent:1.3,depthPhi:2.5,normalPhi:.5},standaloneConfiguratorQualityLevels=new Map([["highest",{...noEffectsSuspension,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:configuratorAoSettings,poissonDenoise:configuratorDenoiseSettings},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],["high",{...partialEffectsSuspension,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:configuratorAoSettings,poissonDenoise:configuratorDenoiseSettings},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}}],["medium",{...fullEffectsSuspension,shAndAoPassParameters:{enabled:!0,aoOnGround:!0,shadowOnGround:!0,ao:configuratorAoSettings,poissonDenoise:configuratorDenoiseSettings},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]]),screenSpaceShadowLayers=new Layers;screenSpaceShadowLayers.enable(3);const bakedGroundShadowHardLayers=new Layers;bakedGroundShadowHardLayers.disableAll(),bakedGroundShadowHardLayers.enable(9);const aoConfiguratorParameters={enabled:!0,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,ao:configuratorAoSettings,poissonDenoise:configuratorDenoiseSettings},aoPlan3dParameters={enabled:!0,aoIntensity:.5,shadowIntensity:0,aoOnGround:!0,shadowOnGround:!1,ao:{algorithm:2,samples:16,radius:.5,distanceExponent:2,thickness:.5,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,rings:2.89,radius:4,radiusExponent:1.3,lumaPhi:10,depthPhi:1,normalPhi:1}},aoPlan2dParameters=aoPlan3dParameters,bakedGroundContactConfiguratorParameters={enabled:!0,fadeoutFalloff:.9,blurMax:.1,opacity:.5,hardLayers:null,softLayers:null,polygonOffset:2},bakedGroundContactPlan3dParameters={enabled:!0,fadeoutFalloff:.8,blurMax:.15,opacity:.5,hardLayers:bakedGroundShadowHardLayers,softLayers:null,polygonOffset:-1},bakedGroundContactPlan2dParameters={enabled:!1},plannerConfiguratorQualityLevels=new Map([["highest",{...noEffectsSuspension,shAndAoPassParameters:aoConfiguratorParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:bakedGroundContactConfiguratorParameters}],["high",{...partialEffectsSuspension,shAndAoPassParameters:aoConfiguratorParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:bakedGroundContactConfiguratorParameters}],["medium",{...fullEffectsSuspension,shAndAoPassParameters:aoConfiguratorParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:bakedGroundContactConfiguratorParameters}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactConfiguratorParameters}]]),planner3dQualityLevels=new Map([["highest",{...noEffectsSuspension,shAndAoPassParameters:aoPlan3dParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:bakedGroundContactPlan3dParameters}],["high",{...partialEffectsSuspension,shAndAoPassParameters:aoPlan3dParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:bakedGroundContactPlan3dParameters}],["medium",{...fullEffectsSuspension,shAndAoPassParameters:aoPlan3dParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactPlan3dParameters}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactPlan3dParameters}]]),planner2dQualityLevels=new Map([["highest",{...noEffectsSuspension,shAndAoPassParameters:aoPlan2dParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactPlan2dParameters}],["high",{...partialEffectsSuspension,shAndAoPassParameters:aoPlan2dParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactPlan2dParameters}],["medium",{...fullEffectsSuspension,shAndAoPassParameters:aoPlan2dParameters,screenSpaceShadowMapParameters:{layers:screenSpaceShadowLayers},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactPlan2dParameters}],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:bakedGroundContactPlan2dParameters}]]);class FpsCounter{constructor(){this._index=0,this._prevTime=0,this._frames=0,this._fps=-1,this._fpsList=Array(2).fill(0),this._prevTime=(performance||Date).now(),this.reset()}update(){this._frames++;const e=(performance||Date).now();e>=this._prevTime+1e3&&(this._fpsList[this._index%2]=1e3*this._frames/(e-this._prevTime),this._index>=2&&(this._fps=this._fpsList.reduce((e,t)=>e+t)/this._fpsList.length),this._prevTime=e,this._frames=0,this._index++)}start(){this._prevTime=(performance||Date).now(),this._frames=0}reset(){this._fps=-1,this._fpsList=Array(2).fill(0),this._index=0}getFps(){return this._fps}}var RenderMode;!function(e){e[e.Mode3D=0]="Mode3D",e[e.Mode2D=1]="Mode2D"}(RenderMode||(RenderMode={}));class RoomleWebGLRenderer{get renderer(){return this._renderer}get sceneRenderer(){return this._sceneRenderer}get isConfiguring(){return this.configuratorMode}get screenSpaceShadowParameters(){return this.sceneRenderer.screenSpaceShadowMapPass.parameters}get shadowAndAoPassParameters(){return this._sceneRenderer.shadowAndAoPass.parameters}get bakedGroundContactShadowParameters(){return this.sceneRenderer.bakedGroundContactShadowPass.parameters}get groundReflectionParameters(){return this._sceneRenderer.groundReflectionPass.parameters}get outlineParameters(){return this._sceneRenderer.outlineRenderer.parameters}constructor(e,t,n){this.configuratorMode=!0,this.uiInteractionMode=!0,this._movingCamera=!1,this._boundingBox=new Box3,this._boundingBoxNeedsUpdate=!1,this._cacheNeedsUpdate=!1,this._shadowNeedsUpdate=!1,this._bakedGroundShadowNeedsUpdate=!1,this._customShadingParameters=null,this._customShadingParametersMoc=null,this._renderer=e,this._sceneRenderer=new SceneRenderer(this._renderer,t,n),this.outlineParameters.enabled=!0,this.outlineParameters.edgeStrength=2,this.outlineParameters.edgeGlow=1,this.outlineParameters.edgeThickness=2,this.outlineParameters.pulsePeriod=0,this.outlineParameters.usePatternTexture=!1,this.outlineParameters.visibleEdgeColor=16777215,this.outlineParameters.hiddenEdgeColor=16777215,RoomleWebGLRenderer.enableRectAreaLightShadow&&(DynamicLightSettingLoader.rectAreaLightReplacement=!1,DynamicLightSettingLoader.rectAreaLightLoadingListener=this.loadRectAreLight),this.sceneRenderer.setQualityLevel("highest"),this.SceneRendererGUI=new SceneRendererGUI(this.sceneRenderer)}dispose(){this._sceneRenderer.dispose()}setSize(e,t){this._sceneRenderer.setSize(e,t)}setCameraType(e){this._cameraType=e}setShadingType(e){this.sceneRenderer.setShadingType(e)}setAutoQuality(e){!this._fpsCounter&&e?this._fpsCounter=new FpsCounter:this._fpsCounter&&!e&&(this._fpsCounter=null)}setQualityLevel(e){this._sceneRenderer.setQualityLevel(e)}setQualityMap(e){this._sceneRenderer.setQualityMap(e)}setCustomShadingParameters(e,t){this._customShadingParameters=e,this._customShadingParametersMoc=t;const n=this.configuratorMode?this._customShadingParameters:this._customShadingParametersMoc;this._sceneRenderer.setCustomShadingParameters(n)}enableUiInteractionMode(){this._sceneRenderer.uiInteractionMode=!0,this._sceneRenderer.applyCurrentParameters()}disableUiInteractionMode(){this._sceneRenderer.uiInteractionMode=!1,this._sceneRenderer.applyCurrentParameters()}loadRectAreLight(e){RoomleWebGLRenderer.rectAreaLightsNeedsUpdate=!0}updateRectAreaLight(e){let t=[];e.traverse(e=>{e instanceof RectAreaLight&&t.push(e)}),this._sceneRenderer.updateRectAreaLights(t,e),RoomleWebGLRenderer.rectAreaLightsNeedsUpdate=!1}clearCache(){this._cacheNeedsUpdate=!0}forceShadowUpdates(e){this._shadowNeedsUpdate=!0,this._bakedGroundShadowNeedsUpdate=e}setGroundShadow(e){this.sceneRenderer.bakedGroundContactShadowPass.parameters.enabled=e,this._bakedGroundShadowNeedsUpdate=!0}switchToConfigurator(){this.configuratorMode=!0,this._sceneRenderer.setQualityMapAndShadingParameters(plannerConfiguratorQualityLevels,this._customShadingParameters)}switchToPlanner(e){RenderMode.Mode3D,this.configuratorMode=!1,e===RenderMode.Mode3D?this._sceneRenderer.setQualityMapAndShadingParameters(planner3dQualityLevels,this._customShadingParametersMoc):this._sceneRenderer.setQualityMapAndShadingParameters(planner2dQualityLevels,null)}updateBounds(e){e&&(this._boundingBox.copy(e),this._boundingBoxNeedsUpdate=!0)}movingCameraStarts(){var e;this._movingCamera=!0,null===(e=this._fpsCounter)||void 0===e||e.start()}movingCameraStops(){this._movingCamera=!1}highlightObjects(e){this._sceneRenderer.selectObjects(e)}render(e,t){var n;this._doUpdatesBeforeRender(e,t);const a=RoomleWebGLRenderer.updateNearAndFarPlaneOfPerspectiveCamera?this.createRenderCamera(t):t;if(this._sceneRenderer.render(e,a),this._movingCamera&&this._fpsCounter){null===(n=this._fpsCounter)||void 0===n||n.update();const e=this._sceneRenderer.getQualityLevel(),t=this._fpsCounter.getFps();t>0&&t<30&&"low"!==e&&("highest"===e?this.sceneRenderer.setQualityLevel("high"):"high"===e?this.sceneRenderer.setQualityLevel("medium"):"medium"===e&&this.sceneRenderer.setQualityLevel("low"),this._fpsCounter.reset())}}_doUpdatesBeforeRender(e,t){this._boundingBoxNeedsUpdate&&(this._sceneRenderer.updateBounds(this._boundingBox,!1),this._boundingBoxNeedsUpdate=!1),this._cacheNeedsUpdate&&(this._sceneRenderer.clearCache(),this._cacheNeedsUpdate=!1),this._shadowNeedsUpdate&&(this._sceneRenderer.forceShadowUpdates(this._bakedGroundShadowNeedsUpdate),this._shadowNeedsUpdate=!1,this._bakedGroundShadowNeedsUpdate=!1),RoomleWebGLRenderer.rectAreaLightsNeedsUpdate&&this.updateRectAreaLight(e),t.updateMatrixWorld(),(t instanceof PerspectiveCamera||t instanceof OrthographicCamera)&&t.updateProjectionMatrix(),this._sceneRenderer.enableObjectSelection=!this._movingCamera&&this._cameraType!==CAMERA_TYPE.CAMERA_FP}createRenderCamera(e){const t=e.clone();return this.configuratorMode&&t instanceof PerspectiveCamera&&(this._sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(t,120),t.updateProjectionMatrix()),t}showGUI(e){const t=getGUI();this.SceneRendererGUI.addGUI(t,e)}clear(){this.renderer.clear()}}RoomleWebGLRenderer.enableRectAreaLightShadow=!0,RoomleWebGLRenderer.rectAreaLightsNeedsUpdate=!1,RoomleWebGLRenderer.updateNearAndFarPlaneOfPerspectiveCamera=!1;class ImageRenderer{_getRenderer(){const e=this._globalInitData.e2e,t=this._globalInitData.e2eRoomleRendererForImages;if(!this._imageRenderer){const t=new WebGLRenderer({antialias:!e,alpha:!0});t.outputColorSpace=SRGBColorSpace,t.setSize(1024,1024),t.autoClear=!1,t.shadowMap.enabled=!0,t.shadowMap.type=PCFSoftShadowMap,this._imageRenderer=t}return e&&!t?this._imageRenderer:(this._roomleRenderer||(this._roomleRenderer=new RoomleWebGLRenderer(this._imageRenderer,1024,1024),this._roomleRenderer.setQualityMap(standaloneConfiguratorQualityLevels),this._roomleRenderer.setSize(1024,1024),this._roomleRenderer.outlineParameters.enabled=!1),this._roomleRenderer)}switchToPlannerSettings(){const e=this._getRenderer();e instanceof RoomleWebGLRenderer&&e.switchToPlanner(RenderMode.Mode3D)}switchToConfiguratorSettings(){const e=this._getRenderer();e instanceof RoomleWebGLRenderer&&e.switchToConfigurator()}updateBounds(e){const t=this._getRenderer();t instanceof RoomleWebGLRenderer&&t.updateBounds(e)}static getCameraTargetForBBox(e,t=0){if(!e){const e=new Vector3;return{center:e,bounds:e,diagonal:0}}const n=e.getSize(new Vector3);return n.addScalar(t),{center:e.getCenter(new Vector3),bounds:n,diagonal:Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2)+Math.pow(n.z,2))}}preparePerspectiveImage(e,t,n,a,r={},i=0,s){return new Promise(o=>{const{size:l=1024,showDimensions:d}=r,c=this._getRenderer();c.setSize(l,l);const h=e.fog?e.fog.clone():null,u=e.background?e.background.clone():null;e.background=null,e.fog=null,n.layers.disable(2),n.layers.disable(6),n.layers.disable(5),d?n.layers.enable(8):n.layers.disable(8);const p=-30+toDegrees(i);ImageRenderer.placeCameraForPerspectiveImage(n,a,-20,p),s&&(n.updateMatrixWorld(!0),s(n));const m=this._render(c,e,t,n);n.layers.enable(2),n.layers.enable(6),n.layers.enable(5),e.background=u,e.fog=h,o({image:m,width:l,height:l,blob:null})})}renderPerspectiveImage(e,t,n,a){return new Promise(r=>{a||(a=1024);const i=this._getRenderer();i.setSize(a,a);const s=e.fog?e.fog.clone():null,o=e.background?e.background.clone():null;e.background=null,e.fog=null,t.layers.disable(2),t.layers.disable(6),t.layers.disable(5),n?ImageRenderer.placeCameraForPerspectiveImage(t,n,-20,-30):(t.aspect=1,t.updateProjectionMatrix());const l=this._render(i,e,null,t);t.layers.enable(2),t.layers.enable(6),t.layers.enable(5),e.background=o,e.fog=s,r({image:l,width:a,height:a,blob:null})})}static placeCameraForPerspectiveImage(e,t,n,a){e.far=1e3,e.fov=15,e.aspect=1,e.position.copy(t.center),e.rotation.set(0,0,0),e.rotateY(toRadiant(a)),e.rotateX(toRadiant(n)),e.translateZ(3.8*t.diagonal),e.updateProjectionMatrix()}prepareTopImage(e,t,n,a={}){const{size:r=1024,showDimensions:i=!1}=a;return new Promise(a=>{const s=this._getRenderer();let o=new OrthographicCamera(-n.bounds.x/2,n.bounds.x/2,n.bounds.z/2,-n.bounds.z/2,.5);o.position.copy(n.center),o.rotateX(toRadiant(-90)),o.translateZ(n.bounds.y+1),o.far=o.position.y+.5,o.layers.mask=65535;let l=200*n.bounds.x,d=200*n.bounds.z;if(l>r||d>r){let e=0;l>r?e=l/r:d>r&&(e=d/r),l/=e,d/=e}s.setSize(l,d);let c=e.fog?e.fog.clone():null,h=e.background?e.background.clone():null;e.background=null,e.fog=null,o.layers.disable(2),o.layers.disable(6),o.layers.disable(5),i?o.layers.enable(8):o.layers.disable(8);const u=this._render(s,e,t,o);o.layers.enable(2),o.layers.enable(6),o.layers.enable(5),e.background=h,e.fog=c,a({image:u,width:l,height:d,blob:null})})}_render(e,t,n,a){const r=e instanceof WebGLRenderer?e:e.renderer;e instanceof WebGLRenderer||(e.forceShadowUpdates(!0),e.render(t,a)),e.render(t,a),n&&(r.autoClear=!1,r.clearDepth(),r.render(n,a),r.autoClear=!0);const i=r.domElement.toDataURL();return r.clear(),i}}__decorate([inject],ImageRenderer.prototype,"_globalInitData",void 0);const promisifyIdbRequest=e=>new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}),eachCursor=(e,t)=>(e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},promisifyIdbRequest(e.transaction));class IdbManager{constructor(e){this._creator_=e,this.configStore=this._createStore("rml-idb","rml-config-store")}get allStores(){return[this.configStore]}_getValue(e,t){return t("readonly",t=>promisifyIdbRequest(t.get(e)))}_setValue(e,t,n){return n("readwrite",n=>(n.put(t,e),promisifyIdbRequest(n.transaction)))}_getEntries(e){return e("readonly",async t=>{if(t.getAll&&t.getAllKeys){const[e,n]=await Promise.all([promisifyIdbRequest(t.getAllKeys()),promisifyIdbRequest(t.getAll())]);return e.map((e,t)=>[e,n[t]])}const n=[];return await e("readonly",async e=>{await eachCursor(e,e=>n.push([e.key,e.value]))}),n})}deleteValue(e,t){return t("readwrite",t=>(t.delete(e),promisifyIdbRequest(t.transaction)))}_createStore(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const a=promisifyIdbRequest(n);return async(e,n)=>n((await a).transaction(t,e).objectStore(t))}getKey(...e){return e.join("_")}async setValue(e,t,n){const a=getHostname(),r={id:e,data:t,lastModified:(new Date).toISOString(),referrer:a};await this._setValue(e,r,n),this._initData.debug}getValue(e,t){return this._getValue(e,t)}clearStore(e){return e("readwrite",e=>(e.clear(),promisifyIdbRequest(e.transaction)))}async pruneOldEntries(){for(const e of this.allStores){const t=await this._getEntries(e);for(const n of t){const t=n[1].lastModified,a=(new Date).toISOString(),r=new Date(a).getTime()-new Date(t).getTime();Math.floor(r/864e5)>30&&await this.deleteValue(n[0],e)}}}}__decorate([inject],IdbManager.prototype,"_initData",void 0);const INJECTABLES=[new DependencyInjectionAssignment("error-handler",class{constructor(){this._listeners={}}_subscribe(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}subscribe(e,t){this._subscribe(e,t)}dispatch(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let a=n.length;for(let e=0;e<a;e++){const a=n[e];a.apply(a,t)}}unsubscribe(e,t){if(!this._listeners[e])return;const n=this._listeners[e];let a=n.length;for(let e=0;e<a;e++)if(n[e]===t)return n.splice(e,1),a--,void e--}softReject(e,t,n){return this.dispatch(n,[t]),e()}}),new DependencyInjectionAssignment("form-data-util",FormDataUtil),new DependencyInjectionAssignment("hdr-environment-loader",class{constructor(e){this._creator_=e;const t=new Color$1("#DDDDDD");this._environmentMap=((e,t,n,a)=>{const r=new CubeTexture;r.format=RGBAFormat,r.generateMipmaps=!1;for(let a=0;a<6;++a){const i=createColorTexture(e,t,n,1);i.format=r.format,i.type=r.type,i.minFilter=r.minFilter,i.magFilter=r.magFilter,i.generateMipmaps=r.generateMipmaps,i.needsUpdate=!0,r.images[a]=i}return r.needsUpdate=!0,r})(t.r,t.g,t.b)}async loadUrl(e,t){const n=t.toLowerCase();this._environmentMap=n.endsWith(".exr")?await this._loadExr(t):await this._loadRgbe(t),this._environmentMap.mapping=EquirectangularReflectionMapping;const a={url:t,environmentMap:this._environmentMap};return this._envChangedCallback(a),a}_loadExr(e){var t;return this._exrLoader=null!==(t=this._exrLoader)&&void 0!==t?t:new EXRLoader,this._exrLoader.setPath(e.startsWith("http")?"":getAssetPath()),this._exrLoader.loadAsync(e)}_loadRgbe(e){var t;return this._rgbeLoader=null!==(t=this._rgbeLoader)&&void 0!==t?t:new RGBELoader,this._rgbeLoader.setPath(e.startsWith("http")?"":getAssetPath()),this._rgbeLoader.loadAsync(e)}registerEnvironmentChangedCallback(e){this._envChangedCallback=e}}),new DependencyInjectionAssignment("static-item-loader",class{constructor(e){this._gltfLoaderGuard=new AsyncGuard,this._creator_=e,this._initLoaders()}_initLoaders(){this._gltfLoader=new GLTFLoader;const e=new DRACOLoader,t=e._loadLibrary.bind(e._loadLibrary);e._loadLibrary=(e,n)=>{const a=DRACO_LIB_FILES[e];if(!a)throw new Error('Can not load draco dependency "'+e+'" did three.js update DracoLoader lib? Available files'+JSON.stringify(DRACO_LIB_FILES));return t(getAssetPath()+a,n)},e.setDecoderConfig({type:"wasm"}),this._gltfLoader.setDRACOLoader(e),this._gltfLoaderGuard.resolve(this._gltfLoader)}async loadGLB(e,t,n,a,r,i,s,o){return await this._gltfLoaderGuard.wait(),new Promise((l,d)=>{this._gltfLoader.load(e,e=>{l(this._handleGLTFScene("GLB",e,t,n,a,r,i,s))},e=>{o&&o(e.loaded/e.total)},e=>{d(e)})})}async loadGLTF(e,t,n,a,r,i,s,o){return await this._gltfLoaderGuard.wait(),new Promise((l,d)=>{this._gltfLoader.parse(e,null,e=>{l(this._handleGLTFScene("GLTF",e,t,n,a,r,i,s))},e=>{o&&o(e.loaded/e.total)},e=>{d(e)})})}_handleGLTFScene(e,t,n,a,r,i,s,o){if(!t||!t.scene||!t.scene.children||0===t.scene.children.length)return null;n&&t.scene.position.copy(n),a&&(t.scene.rotation.y=a);const l=new Box3;if(l.setFromObject(t.scene),r){const{x:e,y:n,z:a}=l.getSize(new Vector3);let i=new Vector3(r.x/e,r.y/n,r.z/a);t.scene.scale.copy(i)}return i&&t.scene.scale.multiply(i),t.scene.type=e,t.scene.traverse(e=>{if(e instanceof Mesh){if(e.layers.set(3),e.material instanceof MeshStandardMaterial){const t=e.material;if(o&&s&&s>0){let e=new Color$1(s);t.color=e.copySRGBToLinear(e),t.roughness=.5,t.metalness=.1}t.needsUpdate=!0}e.castShadow=!0,e.receiveShadow=!0}}),{boundingBox:l,scene:t.scene}}},0),new DependencyInjectionAssignment("form-data-util",FormDataUtil),new DependencyInjectionAssignment("single-promise-factory",class{constructor(e){this._promises=new Map,this._creator_=e}create(e,t,n){return new Promise((a,r)=>{let i=this._promises.get(e),s=!0;if(!i){const t=new Map;this._promises.set(e,t),i=this._promises.get(e),s=!1}i.get(t)||(i.set(t,[]),s=!1);const o=i.get(t);o.push({resolve:a,reject:r}),i.set(t,o);const l=()=>{i.delete(t),0===i.size&&this._promises.delete(e)};s||new Promise(n).then(e=>{i.get(t).forEach(({resolve:t})=>t(e)),l()},e=>{i.get(t).forEach(({reject:t})=>t(e)),l()})})}},1),new DependencyInjectionAssignment("dynamic-light-setting-loader",DynamicLightSettingLoader),new DependencyInjectionAssignment("network-layer",NetworkLayer),new DependencyInjectionAssignment("local-storage",class{constructor(e){this._context_=e}get _localStorage(){let e=null;try{e=window.localStorage}catch(e){console.error(e)}return e}getItem(e){if(!this._localStorage)return null;const t=this._localStorage.getItem(e);try{return JSON.parse(t)}catch(e){return t}}setItem(e,t){if(this._localStorage)try{const n=JSON.stringify(t);this._localStorage.setItem(e,n)}catch(e){console.error(e)}}}),new DependencyInjectionAssignment("network-layer",NetworkLayer),new DependencyInjectionAssignment("kernel-io",KernelIo,0),new DependencyInjectionAssignment("data-syncer",DataSyncer),new DependencyInjectionAssignment("memory-manager",class{constructor(){this._configurationStringSet=new Set,this._singleLoadCounter=0}loadingConfigurationString(){this._singleLoadCounter+=1}loadingConfiguration(e){this._configurationStringSet.add(e),this._singleLoadCounter+=1}shouldHardReset(){return this._configurationStringSet.size>=15||this._singleLoadCounter>=30}executedHardReset(){this._configurationStringSet.clear(),this._singleLoadCounter=0}}),new DependencyInjectionAssignment("life-cycle-manager",class{constructor(){this._listeners=[]}addEventListener(e){this._listeners.push(e)}removeEventListener(e){const t=this._listeners;let n=t.length;if(n)for(let a=0;a<n;a++)t[a]===e&&(t.splice(a,1),a--,n--)}pause(){this._listeners.forEach(e=>e.pause())}resume(){this._listeners.forEach(e=>e.resume())}destroy(){this._listeners.forEach(e=>e.destroy())}},1),new DependencyInjectionAssignment("local-storage-helper",LocalStorageHelper),new DependencyInjectionAssignment("cache-holder",class{constructor(){this._componentCache=new Map,this._geometryCache=new Map,this._materialCache=new Map}get componentCache(){return this._componentCache}get geometryCache(){return this._geometryCache}get materialCache(){return this._materialCache}clear(){for(const e of this._componentCache.values())disposeObject(e);for(const e of this._materialCache.values())disposeMaterial(e);for(const e of this._geometryCache.values())disposeGeometry(e);this._componentCache.clear(),this._geometryCache.clear(),this._materialCache.clear()}},0),new DependencyInjectionAssignment("kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new DependencyInjectionAssignment("configurator-kernel-access-callback",class{constructor(e){this._callbackListener=new Set,this._creator_=e}addListener(e){this._callbackListener.add(e)}removeListener(e){this._callbackListener.delete(e)}isReady(){this._callbackListener.forEach(e=>e.isReady())}updatePossibleChildren(e,t,n){this._callbackListener.forEach(a=>a.updatePossibleChildren(e,t,n))}updateParameters(e,t,n,a){this._callbackListener.forEach(r=>r.updateParameters(e,t,n,a))}loadError(e){this._callbackListener.forEach(t=>t.loadError(e))}},1),new DependencyInjectionAssignment("configurator-context",class{constructor(){this.planObjectId=0,this.planElementId=0,this.rootComponentId=0,this.dockingRootComponentId=0,this.baseContext=null,this.rootComponentParametersAsGlobal=!1,this.lastLoadedRapiId=null,this.lastLoadedPlanId=null,this.selectedRuntimeComponentIds=[],this.selectionMode="standard"}get selectedRuntimeComponentId(){return this.selectedRuntimeComponentIds.length>0?this.selectedRuntimeComponentIds[0]:null}},1),new DependencyInjectionAssignment("init-data",InitData,1),new DependencyInjectionAssignment("global-init-data",GlobalInitData,0),new DependencyInjectionAssignment("global-callback",GlobalCallback,0),new DependencyInjectionAssignment("dom-helper",DomHelper,1),new DependencyInjectionAssignment("unit-formatter",UnitFormatter,0),new DependencyInjectionAssignment("plugin-system",PluginSystem,1),new DependencyInjectionAssignment("configurator-mesh-generator",ConfiguratorMeshGenerator),new DependencyInjectionAssignment("configurator-input-manager",class extends InputManager{},1),new DependencyInjectionAssignment("selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedComponents=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedComponents.size&&this._selectedComponents.forEach((e,t)=>{e.deselect(),this._selectedComponents.delete(t),this.dispatchEvent(1,new SelectionHandlerEvent({component:e}))})}_checkStandard(e){this._selectedComponents.has(e.runtimeId)?this.dispatchEvent(0,new SelectionHandlerEvent({component:e,consecutive:!0})):(this._selectedComponents.size>0&&this._selectedComponents.forEach((e,t)=>{this._selectedComponents.delete(t),this.dispatchEvent(1,new SelectionHandlerEvent({component:e,resetCamera:!1}))}),this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new SelectionHandlerEvent({component:e,consecutive:!1})))}_checkMulti(e){if(this._selectedComponents.has(e.runtimeId))return this._selectedComponents.delete(e.runtimeId),void this.dispatchEvent(1,new SelectionHandlerEvent({component:e,resetCamera:0===this._selectedComponents.size}));this._selectedComponents.set(e.runtimeId,e),this.dispatchEvent(0,new SelectionHandlerEvent({component:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedComponents.size>0}getSelectedRuntimeComponentIds(){let e=[];return this._selectedComponents.forEach(t=>e.push(t.runtimeId)),e}isSelected(e){return this._selectedComponents.has(e.runtimeId)}},1),new DependencyInjectionAssignment("component-dimensioning-helper",ComponentDimensioningHelper,1),new DependencyInjectionAssignment("component-dimensioning-helper",ComponentDimensioningHelper,1),new DependencyInjectionAssignment("planner-kernel-access",PlannerKernelAccess),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator,1),new DependencyInjectionAssignment("unit-formatter",UnitFormatter),new DependencyInjectionAssignment("configurator-history",ConfiguratorHistory,1),new DependencyInjectionAssignment("roomle-planner-ui-callback",class extends UiCallback{constructor(e){super(e),this.onItemsLoaded=()=>{},this.onCameraChanged=e=>{},this.onCameraIdle=()=>{},this.onTotalFloorAreaChanged=e=>{},this.onPlanInteractionHandlerCreated=e=>{},this.onPlannerKernelIsReady=e=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onSelectionChange=(e,t,n,a,r)=>{},this.onSelectionCancel=e=>{},this.onPlanChanged=()=>{},this.onPlanElementChanged=(e,t)=>{},this.onCompletelyLoaded=()=>{},this.onRotationCancel=()=>{},this.onHistoryChange=(e,t)=>{},this.onUpdateWallDimensions=e=>{},this.onUpdateMeasurementLineDimensions=e=>{},this.onUpdateConstructionElementsMeasurements=e=>{},this.onUpdateObjectMeasurements=e=>{},this.disableWallDimensions=()=>{},this.onUpdatePlanObjectPositions=e=>{},this.onDrawCancel=()=>{},this.onDrawingStateChanged=e=>{},this.onHandlerSwitchedPlans=()=>{},this.onDragElementStart=e=>{},this.onDragElementEnd=()=>{},this.onClickElement=e=>{},this.onMultiSelectionChange=e=>{},this.onSelectionModeChange=e=>{},this.onMeasurementLineStateChange=e=>{},this.onFloorPlanAreasUpdated=e=>{},this.onComponentSelectionCancel=()=>{},this.onPlanSnapshotCreated=e=>{},this.onStartConfiguring=()=>{},this.onBackToPlanner=()=>{},this.onContextChanged=e=>{},this.onMergeExternalObjectGroup=(e,t)=>{},this.onSplitExternalObjectGroup=(e,t)=>{},this.onExternalObjectGroupArrangementChanged=e=>{},this.onDeleteExternalObjectGroup=e=>{},this.onDeleteExternalObjectRootModule=(e,t,n)=>{},this.onDeleteExternalObjectSubModule=(e,t)=>{this.onDeleteExternalObjectSubModule(e,t)},this.onDuplicateExternalObjectGroup=(e,t)=>{},this.onMovedExternalObjectGroup=e=>{},this.onExternalObjectEnvironmentChanged=e=>{},this.onExternalObjectGroupChanged=e=>{},this.onExternalObjectGroupLoaded=e=>{},this.onExternalObjectAttributeChanged=(e,t,n,a)=>{},this.onExternalObjectModuleSelected=(e,t,n)=>{},this.onExternalObjectSelectionCancel=e=>{}}}),new DependencyInjectionAssignment("configurator-ui-callbacks",class extends UiCallback{constructor(e){super(e),this.onKernelIsReady=null,this.onComponentPositionsUpdated=null,this.onUpdateParameters=e=>{},this.onUpdatePossibleChildren=(e,t)=>{},this.onUpdatePrice=(e,t)=>{},this.onSelectionChange=(e,t,n,a)=>{},this.onSelectionCancel=()=>{},this.onPartListUpdate=(e,t)=>{},this.onBoundsUpdate=e=>{},this.onLoadConfiguration=()=>{},this.onConfigurationReady=(e,t,n)=>{},this.onOpenTag=e=>{},this.onOpenAddOns=()=>{},this.onClickOutside=()=>{},this.onNoDockingsAvailable=()=>{},this.onUiIntersectionChange=e=>{},this.onZoomChange=(e,t)=>{},this.onZoomToComponent=()=>{},this.onDimensionsVisibilityChange=e=>{},this.onErrorDueToOffline=e=>{},this.onError=e=>{},this.onElementDocked=(e,t)=>{},this.onDockingsPreviewRemoved=()=>{},this.onConfigurationHasChildren=e=>{},this.onTrackTiming=(e,t,n,a)=>{},this.onUserInitiatedDockDone=(e,t,n,a,r)=>{},this.onAddonPlusHover=()=>{},this.onAddonPlusHoverOff=()=>{},this.onAddonPlusShown=()=>{},this.onAddonPlusHidden=()=>{},this.onContentProblem=e=>{},this.onSyncStarted=()=>{},this.onSyncDone=()=>{},this.onOpenFloorMaterials=()=>{},this.onOpenPartList=()=>{},this.onComponentLoadError=(e,t)=>{},this.onConfigurationLoadError=()=>{},this.onChangeTypeChangeTag=e=>{},this.onRemoveTypeChangeTag=e=>{},this.onConfigurationLabelChange=(e,t,n)=>{},this.onMemoryCorruption=()=>{},this.onConfiguratorKernelIsReady=(e,t)=>{},this.onConfigurationSaved=e=>{},this.onCameraPositionChanges=()=>{},this.onHistoryChange=(e,t)=>{},this.onClickComponent=e=>{},this.onRequestExternalMesh=(e,t)=>{},this.onGeometryReady=e=>{},this.onGeometryNotReady=e=>{},this.onValueMapChanged=e=>{}}},1),new DependencyInjectionAssignment("roomle-tools-core",RoomleToolsCore,0),new DependencyInjectionAssignment("image-renderer",ImageRenderer,0),new DependencyInjectionAssignment("idb-manager",IdbManager,0),new DependencyInjectionAssignment("camera-behaviour-state",class{constructor(e){this._lastPlanBounds=new Box3,this._creator_=e}isWithinPlanBounds(e,t){const n=this._lastPlanBounds.containsPoint(e);return t&&this._lastPlanBounds.copy(t),n}},1)];class RoomleDependencyInjection{static _ensureContainer(){window.__RML__DI__||(window.__RML__DI__=new Container,window.__RML__DI__.addDependencyInjectionAssignments(INJECTABLES))}static setup(e){RoomleDependencyInjection.addToContainer(e)}static lookup(e,t){return window.__RML__DI__?window.__RML__DI__.lookup(e,t):null}static getContext(e){return RoomleDependencyInjection._ensureContainer(),window.__RML__DI__.getContext(e)}static cleanUp(e){return window.__RML__DI__?window.__RML__DI__.cleanUp(e):null}static addToContainer(e){RoomleDependencyInjection._ensureContainer(),window.__RML__DI__.addDependencyInjectionAssignments(e)}}export{convertCObject as $,AppContext as A,Benchmark as B,ConfigurableConstructionPlanObjectViewModel as C,DependencyInjectionAssignment as D,EventDispatcher as E,FloorPlanElementViewModel as F,createEmptySceneFromCurrent as G,dispose as H,INJECTABLES as I,getYRotationOfObject as J,getIdealDistance as K,Logger as L,MeasurementLinePlanElementViewModel as M,NodePlanElementViewModel as N,getHostname as O,PlannerKernelAccess as P,toDegrees as Q,RapiAccess as R,StaticPlanObjectViewModel as S,DEFAULT_CONVERSATION_ID as T,getCatalogIdFromItemOrConfigurationId as U,isIdItemId as V,WallPlanElementViewModel as W,isRange as X,sortBySort as Y,isMaterial as Z,__decorate as _,DataSyncer as a,sortByString as a0,position3VectorsAreEqual as a1,position2VectorsAreEqual as a2,DOCK_PREVIEW_MATERIAL_OPACITY as a3,DOCK_PREVIEW_MATERIAL_ROUGHNESS as a4,DOCK_PREVIEW_MATERIAL_METALNESS as a5,DOCK_PREVIEW_MATERIAL_OPACITY_HOVERED as a6,MaterialCreator as a7,PREVIEW_MATERIAL_OPACITY as a8,PREVIEW_MATERIAL_COLOR as a9,hideWallsBasedOnCamera as aA,fadeIn as aB,isBox3InFrustum as aC,viewSpacePositionFromUV as aD,setWallTransparency as aE,toFloorAreaDataTransferable as aF,toMeasurementLineDimensionToTransferable as aG,objectToWallDimensionToTransferable as aH,toConstructionMeasurementTransferable as aI,wallDimensionToTransferable as aJ,convertToStandardArray as aK,isPlanSnapshotId as aL,InputManager as aM,PlannerMeshGenerator as aN,setMaterial as aO,getMaterialShading as aP,addExistingTexture as aQ,UiCallback as aR,ConfiguratorMeshGenerator as aS,GlobalCallback as aT,GlobalInitData as aU,InitData as aV,normalizeRotation as aW,AsyncDependencyLoader as aX,ScenePluginDefaultImplementation as aY,animateMeshMatrix as aa,setMeshMatrix as ab,convertToTHREE as ac,PREVIEW_LINE_MATERIAL_OPACITY as ad,createMaterial as ae,addTexture as af,getGUI as ag,rotationQuaternionsAreEqual as ah,getDelta as ai,MIN_MOVE_DISTANCE as aj,LightSourceDetector as ak,EnvironmentMapDecodeMaterial as al,RoomleWebGLRenderer as am,standaloneConfiguratorQualityLevels as an,ENV_HDR_256_FILE_NAME as ao,transitionTransparencyOfMaterial as ap,MEASUREMENTS_LINE_DRAGGABLE_POINTS_NAME as aq,isSafari as ar,CORE_CHILD_ENTITY_MODE as as,DRAW_PREVIEW_MODES as at,INPUT_DELAY_TYPE as au,threeVectorToTransferableXY as av,CONFIGURATION_TYPE as aw,getDrawingMinBounds as ax,RenderMode as ay,PLAN_ELEMENT_CHANGE_TYPES as az,RoomleDependencyInjection as b,convertToThreeMatrix as c,isUVIdentityMatrix as d,convertToThreeUVMatrix as e,AsyncHelper as f,convertToEuler as g,DOCKING_CONVERSATION_ID as h,inject as i,AsyncGuard as j,kernelBoxToThreeBox as k,ConfiguratorPlanObjectViewModel as l,mergeGeometries as m,ConstructionPlanObjectViewModel as n,CeilingPlanElementViewModel as o,compareBox3Size as p,disposeMesh as q,convertToKernel as r,getScreenXY as s,toRadiant as t,CANVAS_ID as u,vectorIsZero as v,Env as w,DynamicLightSettingLoader as x,PREDEFINED_LIGHTSETTING as y,ImageRenderer as z};
|
|
9
|
-
//# sourceMappingURL=roomle-dependency-injection-4e221caa.js.map
|