@realsee/five-webgpu 1.0.0-alpha.4 → 1.0.0-alpha.6
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/ai_guides/api.md +9 -8
- package/ai_guides/features/camera-animation.md +1 -1
- package/ai_guides/features/event.md +0 -1
- package/ai_guides/features/five.md +8 -8
- package/ai_guides/features/gesture.md +1 -1
- package/ai_guides/features/load-external-model.md +6 -6
- package/ai_guides/features/load-progress.md +2 -2
- package/ai_guides/features/mode.md +3 -23
- package/ai_guides/features/model.md +1 -1
- package/ai_guides/features/state.md +2 -2
- package/ai_guides/features/ultra-hdr.md +41 -32
- package/ai_guides/quick-start.md +2 -2
- package/ai_guides/release_notes/6.8.md +2 -2
- package/ai_guides/support.md +0 -4
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
- package/docs/classes/index.BoundingMesh.html +1 -1
- package/docs/classes/index.Camera.html +1 -1
- package/docs/classes/index.EffectComposer.html +1 -1
- package/docs/classes/index.EyeDomeLightingPass.html +1 -1
- package/docs/classes/index.Five.html +68 -67
- package/docs/classes/index.FivePass.html +1 -1
- package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
- package/docs/classes/index.FlowingLight2DPass.html +1 -1
- package/docs/classes/index.FlowingLight3DPass.html +1 -1
- package/docs/classes/index.GaussianBlurPass.html +1 -1
- package/docs/classes/index.InternalWebGPURenderer.html +14 -3
- package/docs/classes/index.Model.html +1 -1
- package/docs/classes/index.ModelScene.html +1 -1
- package/docs/classes/index.NetworkSubscribe.html +1 -1
- package/docs/classes/index.PBMCustomNode.html +57 -0
- package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +8 -6
- package/docs/classes/index.PBMGaussianSplattingObject.html +10 -4
- package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +26 -15
- package/docs/classes/index.PBMGroup.html +1 -1
- package/docs/classes/index.PBMMesh.html +1 -1
- package/docs/classes/index.PBMMeshBasicMaterial.html +16 -5
- package/docs/classes/index.PBMMeshBasicNodeMaterial.html +28 -7
- package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +16 -5
- package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +28 -7
- package/docs/classes/index.PBMMeshPhongMaterial.html +16 -5
- package/docs/classes/index.PBMMeshPhongNodeMaterial.html +28 -7
- package/docs/classes/index.PBMMeshPhysicalMaterial.html +16 -5
- package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +28 -7
- package/docs/classes/index.PBMPanoFilter.html +8 -8
- package/docs/classes/index.PBMPointCloud.html +1 -1
- package/docs/classes/index.PBMSkinnedMesh.html +1 -1
- package/docs/classes/index.PBMUpdateable.html +1 -1
- package/docs/classes/index.PanoCircleMesh.html +1 -1
- package/docs/classes/index.PanoCircleMeshCustom.html +5 -5
- package/docs/classes/index.PanoCircleMeshSolid.html +1 -1
- package/docs/classes/index.Parameter.html +57 -52
- package/docs/classes/index.Scene.html +1 -1
- package/docs/classes/index.Subscribe.html +1 -1
- package/docs/classes/index.TextureLoader.html +4 -1
- package/docs/classes/index.Tile3D.html +23 -21
- package/docs/classes/index.TileNode.html +1 -1
- package/docs/classes/index.Tileset.html +4 -4
- package/docs/classes/index.TrajectoryNode.html +3 -3
- package/docs/classes/index.Work.html +20 -18
- package/docs/classes/index.WorkResolvedObserver.html +22 -22
- package/docs/documents/api.html +11 -10
- package/docs/documents/features_camera-animation.html +1 -1
- package/docs/documents/features_event.html +0 -1
- package/docs/documents/features_five.html +7 -7
- package/docs/documents/features_gesture.html +1 -1
- package/docs/documents/features_load-external-model.html +6 -6
- package/docs/documents/features_load-progress.html +1 -1
- package/docs/documents/features_mode.html +5 -15
- package/docs/documents/features_model.html +1 -1
- package/docs/documents/features_state.html +1 -1
- package/docs/documents/features_ultra-hdr.html +50 -44
- package/docs/documents/quick-start.html +1 -1
- package/docs/documents/release_notes_6.8.html +2 -2
- package/docs/documents/support.html +1 -3
- package/docs/functions/index.customNodesCacheKey.html +3 -0
- package/docs/functions/index.parseWork.html +1 -1
- package/docs/functions/index.workToJson.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/index.AddableObject.html +1 -1
- package/docs/interfaces/index.AjaxOptions.html +1 -1
- package/docs/interfaces/index.BaseEvent.html +2 -2
- package/docs/interfaces/index.Clock.html +24 -0
- package/docs/interfaces/index.EventCallback.html +49 -47
- package/docs/interfaces/index.FiveInitArgs.html +49 -40
- package/docs/interfaces/index.GainmapCfgData.html +15 -0
- package/docs/interfaces/index.GestureEvent.html +2 -2
- package/docs/interfaces/index.IPBMMaterial.html +15 -4
- package/docs/interfaces/index.ImageOptions.html +1 -1
- package/docs/interfaces/index.IntersectEvent.html +2 -2
- package/docs/interfaces/index.IntersectMesh.html +1 -1
- package/docs/interfaces/index.IntersectMeshInterface.html +1 -1
- package/docs/interfaces/index.Intersection.html +1 -1
- package/docs/interfaces/index.LoosePanoWork.html +2 -2
- package/docs/interfaces/index.LooseWork.html +2 -2
- package/docs/interfaces/index.LooseWorkInitial.html +2 -2
- package/docs/interfaces/index.LooseWorkModel.html +2 -2
- package/docs/interfaces/index.LooseWorkObserver.html +2 -2
- package/docs/interfaces/index.LooseWorkPanorama.html +4 -3
- package/docs/interfaces/index.LooseWorkWithExtrinsics.html +15 -9
- package/docs/interfaces/index.ModeChangeEvent.html +2 -2
- package/docs/interfaces/index.ModelControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ModelEvent.html +2 -2
- package/docs/interfaces/index.ModelSceneEvent.html +2 -2
- package/docs/interfaces/index.ModelTileEvent.html +2 -2
- package/docs/interfaces/index.MovePanoOptions.html +1 -1
- package/docs/interfaces/index.NetworkAbortError.html +1 -1
- package/docs/interfaces/index.NetworkFirbiddenError.html +1 -1
- package/docs/interfaces/index.NetworkOptions.html +1 -1
- package/docs/interfaces/index.NetworkProxyError.html +1 -1
- package/docs/interfaces/index.NetworkResourceEvent.html +2 -2
- package/docs/interfaces/index.NetworkResponseError.html +1 -1
- package/docs/interfaces/index.NetworkTimeoutError.html +1 -1
- package/docs/interfaces/index.ObjectEvent.html +2 -2
- package/docs/interfaces/index.PBMClipperParameter.html +2 -2
- package/docs/interfaces/index.PBMCustomNodeContext.html +87 -0
- package/docs/interfaces/index.PBMCustomNodeOptions.html +10 -0
- package/docs/interfaces/index.PBMCustomNodePanoContext.html +20 -0
- package/docs/interfaces/index.PBMCustomNodeSlots.html +31 -0
- package/docs/interfaces/index.PBMPanoDepth.html +5 -5
- package/docs/interfaces/index.PBMPanoFilterValue.html +2 -2
- package/docs/interfaces/index.PBMPanoGainmap.html +6 -0
- package/docs/interfaces/index.PBMPanoPicture.html +9 -8
- package/docs/interfaces/index.PBMRefinedScreen.html +2 -2
- package/docs/interfaces/index.PanoCircleMeshCustomOptions.html +2 -2
- package/docs/interfaces/index.PanoCircleMeshInterface.html +1 -1
- package/docs/interfaces/index.PanoEvent.html +2 -2
- package/docs/interfaces/index.PanoTextureEvent.html +2 -2
- package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +9 -9
- package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ParameterMaterialValue.html +42 -37
- package/docs/interfaces/index.ParameterTilesetValue.html +15 -15
- package/docs/interfaces/index.ParameterValue.html +56 -51
- package/docs/interfaces/index.Pose.html +1 -1
- package/docs/interfaces/index.RenderEvent.html +2 -2
- package/docs/interfaces/index.ResolvedParameterValue.html +56 -51
- package/docs/interfaces/index.State.html +1 -1
- package/docs/interfaces/index.StateEvent.html +2 -2
- package/docs/interfaces/index.TextureOptions.html +1 -1
- package/docs/interfaces/index.TilesetOptions.html +7 -2
- package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +37 -0
- package/docs/interfaces/index.ViewLayer.html +23 -21
- package/docs/interfaces/index.WorkCubeHdrGainmapImage.html +10 -0
- package/docs/interfaces/index.WorkCubeImage.html +5 -9
- package/docs/interfaces/index.WorkImage.html +8 -12
- package/docs/interfaces/index.WorkInitial.html +8 -8
- package/docs/interfaces/index.WorkModel.html +8 -8
- package/docs/interfaces/index.WorkModelLayer.html +6 -6
- package/docs/interfaces/index.WorkObserver.html +23 -23
- package/docs/interfaces/index.WorkPanoramaJson.html +3 -2
- package/docs/interfaces/index.WorkTile.html +8 -12
- package/docs/interfaces/index.WorksEvent.html +2 -2
- package/docs/interfaces/index.XRControllerEvent.html +2 -2
- package/docs/interfaces/index.XRGestureEvent.html +2 -2
- package/docs/interfaces/index.XRSessionEvent.html +2 -2
- package/docs/modules/index.html +1 -1
- package/docs/types/index.ControllerCustomInitTypes.html +3 -2
- package/docs/types/index.ControllerEventTypes.html +25 -23
- package/docs/types/index.EventTypes.html +26 -26
- package/docs/types/index.Mode.html +2 -1
- package/docs/types/index.PBMCustomNodeTargetType.html +2 -0
- package/docs/types/index.ParseOptions.html +14 -8
- package/docs/variables/index.GSPLAT_PIPELINE_AUTO.html +2 -0
- package/docs/variables/index.GSPLAT_PIPELINE_RASTER_CPU_SORT.html +2 -0
- package/docs/variables/index.GSPLAT_PIPELINE_RASTER_GPU_SORT.html +2 -0
- package/docs/variables/index.PROXY_CONTROLLER_EVENT_NAMES.html +1 -1
- package/docs/variables/index.controllersDefaultInitArgs.html +1 -1
- package/five/application/controllers.d.ts +4 -0
- package/five/application/events.d.ts +1 -1
- package/five/application/five.d.ts +4 -1
- package/five/application/fiveInitArgs.d.ts +13 -0
- package/five/application/mode.d.ts +2 -0
- package/five/cardboard/helper.d.ts +2 -0
- package/five/cardboard/index.d.ts +13 -0
- package/five/cardboard/sensor.d.ts +158 -0
- package/five/controllers/base.d.ts +3 -0
- package/five/controllers/events.d.ts +5 -3
- package/five/controllers/panorama.d.ts +2 -2
- package/five/controllers/vrPanorama.d.ts +56 -0
- package/five/core/internalWebGPURenderer.d.ts +16 -0
- package/five/core/panoVideo.d.ts +4 -1
- package/five/core/tiling.d.ts +40 -9
- package/five/gaussian-splatting/gpu-sort/prefixSumKernel.d.ts +65 -0
- package/five/gaussian-splatting/gpu-sort/radixSortModule.d.ts +128 -0
- package/five/gaussian-splatting/gpu-sort/shaders/prefixSum.d.ts +2 -0
- package/five/gaussian-splatting/gpu-sort/shaders/radixHistogram.d.ts +2 -0
- package/five/gaussian-splatting/gpu-sort/shaders/radixReorder.d.ts +2 -0
- package/five/gaussian-splatting/gpu-sort/shaders/sortKeygen.d.ts +2 -0
- package/five/gaussian-splatting/gpu-sort/sortAdapter.d.ts +234 -0
- package/five/gaussian-splatting/pipelines/cpuSortPipeline.d.ts +159 -0
- package/five/gaussian-splatting/pipelines/gpuSortPipeline.d.ts +98 -0
- package/five/gaussian-splatting/pipelines/gsplatPipeline.d.ts +104 -0
- package/five/gaussian-splatting/pipelines/pipelineMode.d.ts +42 -0
- package/five/gaussian-splatting/pipelines/sortThrottle.d.ts +45 -0
- package/five/index.d.ts +4 -1
- package/five/index.js +272 -269
- package/five/index.mjs +7183 -4546
- package/five/meshes/panoCircleMeshCustom.d.ts +1 -0
- package/five/model/index.d.ts +1 -1
- package/five/model/materials/nodes/pbmMeshBasicNodeMaterial.d.ts +2 -0
- package/five/model/materials/nodes/pbmMeshPanoOnlyNodeMaterial.d.ts +2 -0
- package/five/model/materials/nodes/pbmMeshPhongNodeMaterial.d.ts +2 -0
- package/five/model/materials/nodes/pbmMeshPhysicalNodeMaterial.d.ts +2 -0
- package/five/model/materials/pbmGaussianSplattingNodeMaterial.d.ts +4 -0
- package/five/model/materials/pbmMaterial.d.ts +268 -5
- package/five/model/materials/tsl/defines.d.ts +8 -2
- package/five/model/materials/tsl/outputBuilder.d.ts +8 -15
- package/five/model/materials/tsl/panoColor.d.ts +8 -2
- package/five/model/materials/tsl/utils.d.ts +13 -0
- package/five/model/objects/pbmGaussianSplattingObject.d.ts +9 -0
- package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +67 -101
- package/five/model/parameter.d.ts +13 -1
- package/five/model/tile3d/index.d.ts +2 -0
- package/five/model/tile3d/tileset.d.ts +5 -0
- package/five/model/tile3d/trajectory-content.d.ts +53 -0
- package/five/texture/loader.d.ts +6 -0
- package/five/types/cube.d.ts +0 -1
- package/five/utils/detector.d.ts +11 -1
- package/five/utils/error.d.ts +1 -0
- package/five/utils/event.d.ts +17 -1
- package/five/utils/gainmap-data.d.ts +23 -0
- package/five/work/index.d.ts +1 -1
- package/five/work/looseWorkType.d.ts +2 -1
- package/five/work/work.d.ts +30 -7
- package/five/work/workJsonType.d.ts +2 -1
- package/gltf-loader/gltf-object.d.ts +17 -0
- package/gltf-loader/index.d.ts +45 -0
- package/gltf-loader/index.js +255 -0
- package/gltf-loader/index.mjs +302 -0
- package/package.json +6 -1
- package/plugins/BackgroundPlugin/Controller.d.ts +20 -0
- package/plugins/BackgroundPlugin/index.d.ts +5 -0
- package/plugins/BackgroundPlugin/typings.d.ts +44 -0
- package/plugins/CSS2DPlugin/Controller.d.ts +59 -0
- package/plugins/CSS2DPlugin/index.d.ts +5 -0
- package/plugins/CSS2DPlugin/typing.d.ts +31 -0
- package/plugins/CSS3DPlugin/Controller.d.ts +64 -0
- package/plugins/CSS3DPlugin/index.d.ts +5 -0
- package/plugins/CSS3DPlugin/typing.d.ts +33 -0
- package/plugins/FloorplanPlugin/Controller.d.ts +100 -0
- package/plugins/FloorplanPlugin/index.d.ts +5 -0
- package/plugins/FloorplanPlugin/render/assets.d.ts +9 -0
- package/plugins/FloorplanPlugin/render/index.d.ts +35 -0
- package/plugins/FloorplanPlugin/render/isPointInPolygon.d.ts +5 -0
- package/plugins/FloorplanPlugin/render/renderFloor.d.ts +22 -0
- package/plugins/FloorplanPlugin/render/roomLabelVisibility.d.ts +10 -0
- package/plugins/FloorplanPlugin/typing.d.ts +156 -0
- package/plugins/FloorplanPlugin/typings/floorplanData.d.ts +112 -0
- package/plugins/FloorplanPlugin/typings/floorplanServerData.d.ts +78 -0
- package/plugins/FloorplanPlugin/typings/index.d.ts +2 -0
- package/plugins/FloorplanPlugin/utils/changeMode.d.ts +5 -0
- package/plugins/FloorplanPlugin/utils/changeModelCanvasOpacity.d.ts +6 -0
- package/plugins/FloorplanPlugin/utils/correctFiveState.d.ts +11 -0
- package/plugins/FloorplanPlugin/utils/equal.d.ts +9 -0
- package/plugins/FloorplanPlugin/utils/filter.d.ts +8 -0
- package/plugins/FloorplanPlugin/utils/fiveModelLoad.d.ts +6 -0
- package/plugins/FloorplanPlugin/utils/formatData.d.ts +6 -0
- package/plugins/FloorplanPlugin/utils/formatPosition.d.ts +33 -0
- package/plugins/FloorplanPlugin/utils/getDistanceFromModel.d.ts +6 -0
- package/plugins/FloorplanPlugin/utils/getPxmm.d.ts +19 -0
- package/plugins/FloorplanPlugin/utils/isTruelyObject.d.ts +4 -0
- package/plugins/FloorplanPlugin/utils/nearlyEqual.d.ts +8 -0
- package/plugins/FloorplanPlugin/utils/to.d.ts +5 -0
- package/plugins/Object3DHelperPlugin/Controller.d.ts +99 -0
- package/plugins/Object3DHelperPlugin/Controllers/BaseController.d.ts +142 -0
- package/plugins/Object3DHelperPlugin/Controllers/BoundingBoxController.d.ts +16 -0
- package/plugins/Object3DHelperPlugin/Controllers/MoveController.d.ts +66 -0
- package/plugins/Object3DHelperPlugin/Controllers/RotateController.d.ts +61 -0
- package/plugins/Object3DHelperPlugin/FiveControllerWrapper.d.ts +17 -0
- package/plugins/Object3DHelperPlugin/Helper/BaseHelper.d.ts +97 -0
- package/plugins/Object3DHelperPlugin/Helper/BoundingBoxHelper.d.ts +16 -0
- package/plugins/Object3DHelperPlugin/Helper/MoveHelper.d.ts +37 -0
- package/plugins/Object3DHelperPlugin/Helper/RotateHelper.d.ts +93 -0
- package/plugins/Object3DHelperPlugin/constant.d.ts +27 -0
- package/plugins/Object3DHelperPlugin/index.d.ts +6 -0
- package/plugins/Object3DHelperPlugin/typing.d.ts +143 -0
- package/plugins/Object3DHelperPlugin/utils/ArrowGroup.d.ts +22 -0
- package/plugins/Object3DHelperPlugin/utils/CenterHandle.d.ts +23 -0
- package/plugins/Object3DHelperPlugin/utils/PlaneHandle.d.ts +19 -0
- package/plugins/Object3DHelperPlugin/utils/calculateScaleByCamera.d.ts +5 -0
- package/plugins/Object3DHelperPlugin/utils/cameraHooks.d.ts +3 -0
- package/plugins/Object3DHelperPlugin/utils/direction.d.ts +14 -0
- package/plugins/Object3DHelperPlugin/utils/getMouseRaycaster.d.ts +5 -0
- package/plugins/Object3DHelperPlugin/utils/getOrthographicCameraDirection.d.ts +8 -0
- package/plugins/Object3DHelperPlugin/utils/setObjectQuaternion.d.ts +8 -0
- package/plugins/Object3DHelperPlugin/utils/solidGuide.d.ts +27 -0
- package/plugins/Object3DHelperPlugin/utils/tipsDom.d.ts +8 -0
- package/plugins/PanoAnimePlugin/Controller.d.ts +49 -0
- package/plugins/PanoAnimePlugin/index.d.ts +5 -0
- package/plugins/PanoAnimePlugin/typing.d.ts +37 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +393 -3
- package/plugins/index.mjs +3421 -92
- package/plugins/thirdParty/CSS2DRenderer.d.ts +37 -0
- package/plugins/thirdParty/CSS3DRenderer.d.ts +45 -0
- package/plugins/thirdParty/OrbitControls.d.ts +78 -0
- package/plugins/thirdParty/domevents.d.ts +36 -0
- package/plugins/utils/clamp.d.ts +2 -0
- package/plugins/utils/uuid.d.ts +2 -0
- package/react/index.js +2 -2
- package/react/index.mjs +2 -2
- package/umd/five-gltf-loader.js +255 -0
- package/umd/five-plugins.js +461 -3
- package/umd/five-react.js +2 -2
- package/umd/five.js +350 -347
- package/docs/interfaces/index.PBMHDRConfig.html +0 -12
- package/five/gaussian-splatting/worker/dataWorker.d.ts +0 -1
- package/five/three-version-check.d.ts +0 -1
- package/five/utils/hdr-data.d.ts +0 -13
- package/five/utils/shaderContentFix.d.ts +0 -7
package/umd/five-plugins.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/9/24
|
|
5
|
+
* Version: 1.0.0-alpha.6
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -252,4 +252,462 @@
|
|
|
252
252
|
* No amendment to or modification of this Agreement will be binding unless in
|
|
253
253
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
254
254
|
* Agreement and all related documents shall be drafted in English.
|
|
255
|
-
*/(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@realsee/five-webgpu")):typeof define==`function`&&define.amd?define([`exports`,`@realsee/five-webgpu`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FiveSDK_Plugins={},e.FiveSDK))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function r(e){return/^https?:\/\/|^\/\//.test(e)||/^data:/.test(e)}function i(e,t){return r(t)?t:`${e}${t}`}var a;(function(e){class n{constructor(e,n){this.hooks=new t.Subscribe,this.staticPrefix=`//vr-image-4.realsee-cdn.cn`,this.five=e,n!=null&&n.staticPrefix&&(this.staticPrefix=n.staticPrefix)}getCurrentState(){return this.state}absoluteUrl(e){return i(this.staticPrefix,e)}}e.Controller=n})(a||(a={}));function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var f=1e3,p=1001,m=1002,h=1006,g=1008,_=1009,v=1023,y=2300,b=2301,x=2302,S=2303,C=2400,w=2401,T=2402,E=`srgb`,D=`srgb-linear`,O=`linear`,k=`srgb`,A=2e3;function ee(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function te(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}var ne={},j=null;function re(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function M(...e){e=re(e);let t=`THREE.`+e.shift();if(j)j(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function N(...e){e=re(e);let t=`THREE.`+e.shift();if(j)j(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function ie(...e){let t=e.join(` `);t in ne||(ne[t]=!0,M(...e))}var ae=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},P=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);Math.PI/180,180/Math.PI;function oe(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(P[e&255]+P[e>>8&255]+P[e>>16&255]+P[e>>24&255]+`-`+P[t&255]+P[t>>8&255]+`-`+P[t>>16&15|64]+P[t>>24&255]+`-`+P[n&63|128]+P[n>>8&255]+`-`+P[n>>16&255]+P[n>>24&255]+P[r&255]+P[r>>8&255]+P[r>>16&255]+P[r>>24&255]).toLowerCase()}function F(e,t,n){return Math.max(t,Math.min(n,e))}function se(e,t){return(e%t+t)%t}function ce(e,t,n){return(1-n)*e+n*t}var I=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=F(this.x,e.x,t.x),this.y=F(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=F(this.x,e,t),this.y=F(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(F(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(F(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},le=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:M(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(F(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},L=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(de.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(de.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=F(this.x,e.x,t.x),this.y=F(this.y,e.y,t.y),this.z=F(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=F(this.x,e,t),this.y=F(this.y,e,t),this.z=F(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(F(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ue.copy(this).projectOnVector(e),this.sub(ue)}reflect(e){return this.sub(ue.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(F(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ue=new L,de=new le,fe=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(pe.makeScale(e,t)),this}rotate(e){return this.premultiply(pe.makeRotation(-e)),this}translate(e,t){return this.premultiply(pe.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},pe=new fe,me=new fe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),he=new fe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ge(){let e={enabled:!0,workingColorSpace:D,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=z(e.r),e.g=z(e.g),e.b=z(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=_e(e.r),e.g=_e(e.g),e.b=_e(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?O:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return ie(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return ie(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[D]:{primaries:t,whitePoint:r,transfer:O,toXYZ:me,fromXYZ:he,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:E},outputColorSpaceConfig:{drawingBufferColorSpace:E}},[E]:{primaries:t,whitePoint:r,transfer:k,toXYZ:me,fromXYZ:he,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:E}}}),e}var R=ge();function z(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function _e(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}var ve,ye=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ve===void 0&&(ve=te(`canvas`)),ve.width=e.width,ve.height=e.height;let t=ve.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=ve}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=te(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=z(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(z(t[e]/255)*255):t[e]=z(t[e]);return{data:t,width:e.width,height:e.height}}else return M(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},be=0,xe=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:be++}),this.uuid=oe(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Se(r[t].image)):e.push(Se(r[t]))}else e=Se(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Se(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?ye.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(M(`Texture: Unable to serialize Texture.`),{})}var Ce=0,we=new L,Te=class e extends ae{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=p,i=p,a=h,o=g,s=v,c=_,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ce++}),this.uuid=oe(),this.name=``,this.source=new xe(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new I(0,0),this.repeat=new I(1,1),this.center=new I(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(we).x}get height(){return this.source.getSize(we).y}get depth(){return this.source.getSize(we).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){M(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){M(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case f:e.x-=Math.floor(e.x);break;case p:e.x=e.x<0?0:1;break;case m:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case f:e.y-=Math.floor(e.y);break;case p:e.y=e.y<0?0:1;break;case m:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Te.DEFAULT_IMAGE=null,Te.DEFAULT_MAPPING=300,Te.DEFAULT_ANISOTROPY=1;var Ee=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/De.setFromMatrixColumn(e,0).length(),i=1/De.setFromMatrixColumn(e,1).length(),a=1/De.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Oe,e,ke)}lookAt(e,t,n){let r=this.elements;return H.subVectors(e,t),H.lengthSq()===0&&(H.z=1),H.normalize(),V.crossVectors(n,H),V.lengthSq()===0&&(Math.abs(n.z)===1?H.x+=1e-4:H.z+=1e-4,H.normalize(),V.crossVectors(n,H)),V.normalize(),Ae.crossVectors(H,V),r[0]=V.x,r[4]=Ae.x,r[8]=H.x,r[1]=V.y,r[5]=Ae.y,r[9]=H.y,r[2]=V.z,r[6]=Ae.z,r[10]=H.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],ee=r[10],te=r[14],ne=r[3],j=r[7],re=r[11],M=r[15];return i[0]=a*x+o*T+s*k+c*ne,i[4]=a*S+o*E+s*A+c*j,i[8]=a*C+o*D+s*ee+c*re,i[12]=a*w+o*O+s*te+c*M,i[1]=l*x+u*T+d*k+f*ne,i[5]=l*S+u*E+d*A+f*j,i[9]=l*C+u*D+d*ee+f*re,i[13]=l*w+u*O+d*te+f*M,i[2]=p*x+m*T+h*k+g*ne,i[6]=p*S+m*E+h*A+g*j,i[10]=p*C+m*D+h*ee+g*re,i[14]=p*w+m*O+h*te+g*M,i[3]=_*x+v*T+y*k+b*ne,i[7]=_*S+v*E+y*A+b*j,i[11]=_*C+v*D+y*ee+b*re,i[15]=_*w+v*O+y*te+b*M,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=De.set(r[0],r[1],r[2]).length(),o=De.set(r[4],r[5],r[6]).length(),s=De.set(r[8],r[9],r[10]).length();i<0&&(a=-a),B.copy(this);let c=1/a,l=1/o,u=1/s;return B.elements[0]*=c,B.elements[1]*=c,B.elements[2]*=c,B.elements[4]*=l,B.elements[5]*=l,B.elements[6]*=l,B.elements[8]*=u,B.elements[9]*=u,B.elements[10]*=u,t.setFromRotationMatrix(B),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=A,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=A,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},De=new L,B=new Ee,Oe=new L(0,0,0),ke=new L(1,1,1),V=new L,Ae=new L,H=new L,je=new Ee,Me=new le,Ne=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(F(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-F(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(F(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-F(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(F(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-F(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:M(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return je.makeRotationFromQuaternion(e),this.setFromRotationMatrix(je,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Me.setFromEuler(this),this.setFromQuaternion(Me,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ne.DEFAULT_ORDER=`XYZ`;var Pe=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Fe=0,Ie=new L,Le=new le,U=new Ee,Re=new L,ze=new L,Be=new L,Ve=new le,He=new L(1,0,0),Ue=new L(0,1,0),We=new L(0,0,1),Ge={type:`added`},Ke={type:`removed`},qe={type:`childadded`,child:null},Je={type:`childremoved`,child:null},Ye=class e extends ae{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fe++}),this.uuid=oe(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new L,n=new Ne,r=new le,i=new L(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ee},normalMatrix:{value:new fe}}),this.matrix=new Ee,this.matrixWorld=new Ee,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Pe,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Le.setFromAxisAngle(e,t),this.quaternion.multiply(Le),this}rotateOnWorldAxis(e,t){return Le.setFromAxisAngle(e,t),this.quaternion.premultiply(Le),this}rotateX(e){return this.rotateOnAxis(He,e)}rotateY(e){return this.rotateOnAxis(Ue,e)}rotateZ(e){return this.rotateOnAxis(We,e)}translateOnAxis(e,t){return Ie.copy(e).applyQuaternion(this.quaternion),this.position.add(Ie.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(He,e)}translateY(e){return this.translateOnAxis(Ue,e)}translateZ(e){return this.translateOnAxis(We,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(U.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Re.copy(e):Re.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),ze.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?U.lookAt(ze,Re,this.up):U.lookAt(Re,ze,this.up),this.quaternion.setFromRotationMatrix(U),r&&(U.extractRotation(r.matrixWorld),Le.setFromRotationMatrix(U),this.quaternion.premultiply(Le.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(N(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ge),qe.child=e,this.dispatchEvent(qe),qe.child=null):N(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ke),Je.child=e,this.dispatchEvent(Je),Je.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),U.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),U.multiply(e.parent.matrixWorld)),e.applyMatrix4(U),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ge),qe.child=e,this.dispatchEvent(qe),qe.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ze,e,Be),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ze,Ve,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>d(d({},e),{},{boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>d({},e)),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Ye.DEFAULT_UP=new L(0,1,0),Ye.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ye.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Xe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},W={h:0,s:0,l:0},Ze={h:0,s:0,l:0};function Qe(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var $e=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=E){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,R.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=R.workingColorSpace){return this.r=e,this.g=t,this.b=n,R.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=R.workingColorSpace){if(e=se(e,1),t=F(t,0,1),n=F(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Qe(i,r,e+1/3),this.g=Qe(i,r,e),this.b=Qe(i,r,e-1/3)}return R.colorSpaceToWorking(this,r),this}setStyle(e,t=E){function n(t){t!==void 0&&parseFloat(t)<1&&M(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:M(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);M(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=E){let n=Xe[e.toLowerCase()];return n===void 0?M(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=z(e.r),this.g=z(e.g),this.b=z(e.b),this}copyLinearToSRGB(e){return this.r=_e(e.r),this.g=_e(e.g),this.b=_e(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=E){return R.workingToColorSpace(G.copy(this),e),Math.round(F(G.r*255,0,255))*65536+Math.round(F(G.g*255,0,255))*256+Math.round(F(G.b*255,0,255))}getHexString(e=E){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=R.workingColorSpace){R.workingToColorSpace(G.copy(this),t);let n=G.r,r=G.g,i=G.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=R.workingColorSpace){return R.workingToColorSpace(G.copy(this),t),e.r=G.r,e.g=G.g,e.b=G.b,e}getStyle(e=E){R.workingToColorSpace(G.copy(this),e);let t=G.r,n=G.g,r=G.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(W),this.setHSL(W.h+e,W.s+t,W.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(W),e.getHSL(Ze);let n=ce(W.h,Ze.h,t),r=ce(W.s,Ze.s,t),i=ce(W.l,Ze.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},G=new $e;$e.NAMES=Xe;var et=class{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(q.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(q.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=q.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,q):q.fromBufferAttribute(r,t),q.applyMatrix4(e.matrixWorld),this.expandByPoint(q);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),tt.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),tt.copy(e.boundingBox)),tt.applyMatrix4(e.matrixWorld),this.union(tt)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,q),q.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ot),st.subVectors(this.max,ot),nt.subVectors(e.a,ot),rt.subVectors(e.b,ot),it.subVectors(e.c,ot),J.subVectors(rt,nt),Y.subVectors(it,rt),at.subVectors(nt,it);let t=[0,-J.z,J.y,0,-Y.z,Y.y,0,-at.z,at.y,J.z,0,-J.x,Y.z,0,-Y.x,at.z,0,-at.x,-J.y,J.x,0,-Y.y,Y.x,0,-at.y,at.x,0];return!ut(t,nt,rt,it,st)||(t=[1,0,0,0,1,0,0,0,1],!ut(t,nt,rt,it,st))?!1:(ct.crossVectors(J,Y),t=[ct.x,ct.y,ct.z],ut(t,nt,rt,it,st))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,q).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(q).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(K[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),K[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),K[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),K[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),K[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),K[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),K[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),K[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(K),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},K=[new L,new L,new L,new L,new L,new L,new L,new L],q=new L,tt=new et,nt=new L,rt=new L,it=new L,J=new L,Y=new L,at=new L,ot=new L,st=new L,ct=new L,lt=new L;function ut(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){lt.fromArray(e,a);let o=i.x*Math.abs(lt.x)+i.y*Math.abs(lt.y)+i.z*Math.abs(lt.z),s=t.dot(lt),c=n.dot(lt),l=r.dot(lt);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var X=new L,dt=new L,ft=new L,Z=new L,pt=new L,mt=new L,ht=new L,gt=class{constructor(e=new L,t=new L(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,X)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=X.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(X.copy(this.origin).addScaledVector(this.direction,t),X.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){dt.copy(e).add(t).multiplyScalar(.5),ft.copy(t).sub(e).normalize(),Z.copy(this.origin).sub(dt);let i=e.distanceTo(t)*.5,a=-this.direction.dot(ft),o=Z.dot(this.direction),s=-Z.dot(ft),c=Z.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(dt).addScaledVector(ft,d),f}intersectSphere(e,t){X.subVectors(e.center,this.origin);let n=X.dot(this.direction),r=X.dot(X)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,X)!==null}intersectTriangle(e,t,n,r,i){pt.subVectors(t,e),mt.subVectors(n,e),ht.crossVectors(pt,mt);let a=this.direction.dot(ht),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Z.subVectors(this.origin,e);let s=o*this.direction.dot(mt.crossVectors(Z,mt));if(s<0)return null;let c=o*this.direction.dot(pt.cross(Z));if(c<0||s+c>a)return null;let l=-o*Z.dot(ht);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},_t=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){M(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new I:new L);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new L,r=[],i=[],a=[],o=new L,s=new Ee;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new L)}i[0]=new L,a[0]=new L;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>Number.EPSILON){o.normalize();let e=Math.acos(F(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(F(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}};function vt(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var yt=new L,bt=new vt,xt=new vt,St=new vt,Ct=class extends _t{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new L){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(yt.subVectors(r[0],r[1]).add(r[0]),c=yt);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(yt.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=yt),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=Math.pow(c.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),r=Math.pow(d.distanceToSquared(l),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),bt.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),xt.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),St.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(bt.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),xt.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),St.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(bt.calc(s),xt.calc(s),St.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new L().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function wt(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Tt=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},Et=class extends Tt{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:C,endingEnd:C}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case w:i=e,o=2*t-n;break;case T:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case w:a=e,s=2*n-t;break;case T:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},Dt=class extends Tt{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Ot=class extends Tt{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},kt=class extends Tt{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.settings||this.DefaultSettings_,u=l.inTangents,d=l.outTangents;if(!u||!d){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let f=o*2,p=e-1;for(let l=0;l!==o;++l){let o=a[c+l],m=a[s+l],h=p*f+l*2,g=d[h],_=d[h+1],v=e*f+l*2,y=u[v],b=u[v+1],x=(n-t)/(r-t),S,C,w,T,E;for(let e=0;e<8;e++){S=x*x,C=S*x,w=1-x,T=w*w,E=T*w;let e=E*t+3*T*x*g+3*w*S*y+C*r-n;if(Math.abs(e)<1e-10)break;let i=3*T*(g-t)+6*w*x*(y-g)+3*S*(r-y);if(Math.abs(i)<1e-10)break;x-=e/i,x=Math.max(0,Math.min(1,x))}i[l]=E*o+3*T*x*_+3*w*S*b+C*m}return i}},Q=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=wt(t,this.TimeBufferType),this.values=wt(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wt(e.times,Array),values:wt(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ot(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dt(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Et(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new kt(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case y:t=this.InterpolantFactoryMethodDiscrete;break;case b:t=this.InterpolantFactoryMethodLinear;break;case x:t=this.InterpolantFactoryMethodSmooth;break;case S:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return M(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return y;case this.InterpolantFactoryMethodLinear:return b;case this.InterpolantFactoryMethodSmooth:return x;case this.InterpolantFactoryMethodBezier:return S}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(N(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(N(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){N(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){N(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&ee(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){N(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===x,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Q.prototype.ValueTypeName=``,Q.prototype.TimeBufferType=Float32Array,Q.prototype.ValueBufferType=Float32Array,Q.prototype.DefaultInterpolation=b;var At=class extends Q{constructor(e,t,n){super(e,t,n)}};At.prototype.ValueTypeName=`bool`,At.prototype.ValueBufferType=Array,At.prototype.DefaultInterpolation=y,At.prototype.InterpolantFactoryMethodLinear=void 0,At.prototype.InterpolantFactoryMethodSmooth=void 0;var jt=class extends Q{constructor(e,t,n,r){super(e,t,n,r)}};jt.prototype.ValueTypeName=`color`;var Mt=class extends Q{constructor(e,t,n,r){super(e,t,n,r)}};Mt.prototype.ValueTypeName=`number`;var Nt=class extends Tt{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)le.slerpFlat(i,0,a,c-o,a,c,s);return i}},Pt=class extends Q{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Nt(this.times,this.values,this.getValueSize(),e)}};Pt.prototype.ValueTypeName=`quaternion`,Pt.prototype.InterpolantFactoryMethodSmooth=void 0;var Ft=class extends Q{constructor(e,t,n){super(e,t,n)}};Ft.prototype.ValueTypeName=`string`,Ft.prototype.ValueBufferType=Array,Ft.prototype.DefaultInterpolation=y,Ft.prototype.InterpolantFactoryMethodLinear=void 0,Ft.prototype.InterpolantFactoryMethodSmooth=void 0;var It=class extends Q{constructor(e,t,n,r){super(e,t,n,r)}};It.prototype.ValueTypeName=`vector`;var Lt=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Rt=class{constructor(e){this.manager=e===void 0?Lt:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};Rt.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var zt=`\\[\\]\\.:\\/`,Bt=RegExp(`[\\[\\]\\.:\\/]`,`g`),Vt=`[^\\[\\]\\.:\\/]`,Ht=`[^`+zt.replace(`\\.`,``)+`]`,Ut=`((?:WC+[\\/:])*)`.replace(`WC`,Vt),Wt=`(WCOD+)?`.replace(`WCOD`,Ht),Gt=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Vt),Kt=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Vt),qt=RegExp(`^`+Ut+Wt+Gt+Kt+`$`),Jt=[`material`,`materials`,`bones`,`map`],Yt=class{constructor(e,t,n){let r=n||$.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},$=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(Bt,``)}static parseTrackName(e){let t=qt.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);Jt.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){M(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){N(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){N(`PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){N(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){N(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){N(`PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){N(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){N(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;N(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){N(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){N(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};$.Composite=Yt,$.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},$.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},$.prototype.GetterByBindingType=[$.prototype._getValue_direct,$.prototype._getValue_array,$.prototype._getValue_arrayElement,$.prototype._getValue_toArray],$.prototype.SetterByBindingTypeAndVersioning=[[$.prototype._setValue_direct,$.prototype._setValue_direct_setNeedsUpdate,$.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[$.prototype._setValue_array,$.prototype._setValue_array_setNeedsUpdate,$.prototype._setValue_array_setMatrixWorldNeedsUpdate],[$.prototype._setValue_arrayElement,$.prototype._setValue_arrayElement_setNeedsUpdate,$.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[$.prototype._setValue_fromArray,$.prototype._setValue_fromArray_setNeedsUpdate,$.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]],typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`183`}})),typeof window<`u`&&(window.__THREE__?M(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`183`);var Xt=class{constructor(e,t,n,r,i){this.R=e,this.Q=t,this.A=n,this.B=r,this.C=i,this.cov=NaN,this.x=NaN}filter(e,t=0){if(isNaN(this.x))this.x=1/this.C*e,this.cov=1/this.C*this.Q*(1/this.C);else{let n=this.A*this.x+this.B*t,r=this.A*this.cov*this.A+this.R,i=r*this.C*(1/(this.C*r*this.C+this.Q));this.x=n+i*(e-this.C*n),this.cov=r-i*this.C*r}return this.x}},Zt=class extends a.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){var n,r,i;super(e),this.boundingAABB=null,this.cancelAnimation=null,this.boundsSet=!1,this.keyframes=[],this.five=e,this.state={enabled:!0,visible:!0},this.duration=(n=t==null?void 0:t.duration)==null?5e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?3e3:i}load(){return n(this,void 0,void 0,function*(){})}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!0},n)}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!1},n)}dispose(){this.disable(),this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null);try{let e=this.findRenderMesh();e&&(e.material.aggregationEnabled=!1,e.material.aggregationProgress=1)}catch(e){}}extractKeyframes(e){let t=[];if(!e.content.data)throw Error(`轨迹数据未加载`);let n=e.content.data.positionArray,r=n.length/3,i=.01,a=.1,o=new Xt(i,a,1,0,1),s=new Xt(i,a,1,0,1),c=new Xt(i,a,1,0,1),l=new Float32Array(r);for(let e=0;e<r;e++)if(e===0)l[e]=0;else{let t=new L(n[(e-1)*3],n[(e-1)*3+1],n[(e-1)*3+2]);l[e]=new L(n[e*3],n[e*3+1],n[e*3+2]).distanceTo(t)+l[e-1]}for(let i=0;i<r;i++){let a=new L(0,0,0),u=0;for(let e=i-5;e<i+6;e++)e>=0&&e<r&&(a.add(new L(n[e*3],n[e*3+1],n[e*3+2])),u++);a.divideScalar(u).applyMatrix4(e.transform);let d=o.filter(a.x),f=s.filter(a.y),p=c.filter(a.z);t.push({position:new L(d,f,p),location:l[i]})}return t}computeAABB2D(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)a.position.x<t&&(t=a.position.x),a.position.x>n&&(n=a.position.x),a.position.z<r&&(r=a.position.z),a.position.z>i&&(i=a.position.z);return{min:new I(t,r),max:new I(n,i)}}findClosestKeyframeToRay(e,t){let n=1/0,r=t[0].position.clone(),i=new L;for(let a of t){e.closestPointToPoint(a.position,i);let t=i.distanceTo(a.position);t<n&&(n=t,r=a.position.clone())}return r}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{if(e)return;let n=t,r=n.material;r&&r.isPBMGaussianSplattingMaterial&&(e=n)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}loadTrajectoryDataIfNeeded(e){return n(this,void 0,void 0,function*(){var n,r,i,a,o,s,c,l;if((n=e.content)!=null&&n.data)return;if(((r=e.content)==null?void 0:r.loadState)===`LOADING`){yield new Promise(n=>{let r=t.AnimationFrameLoop.shared.add(()=>{var t;let i=(t=e.content)==null?void 0:t.loadState;(i===`READY`||i===`FAILED`||i===`UNLOADED`)&&(r(),n())})});return}let u=(i=this.five.model.viewLayers)==null?void 0:i[0],d=u==null?void 0:u.fetcher,f=u==null?void 0:u.search,p=(a=e.content)==null?void 0:a.uri;if(!d||!p)return;let m=f?p.includes(`?`)?`${p}&${f.replace(/^\?/,``)}`:`${p}${f.startsWith(`?`)?f:`?${f}`}`:p;e.content.loadState=`LOADING`;try{let n=yield(0,t.loadPly)(m,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:d}),r=n.scene,i=r.getAttribute(`position`),a=r.getAttribute(`time`),u=(o=i==null?void 0:i.array)==null?new Float32Array:o,f=(s=a==null?void 0:a.array)==null?new Uint32Array:s;e.content.data={uri:m,byteLength:(c=n.byteLength)==null?0:c,memoryUsage:(l=n.memoryUsage)==null?0:l,positionArray:u,timeArray:f,object:null},e.content.loadState=`READY`}catch(t){console.warn(`[GaussianSplattingEntranceAnimationPlugin] trajectory ply 加载失败,将使用 3DGS AABB 回退`,t),e.content.data=void 0,e.content.loadState=`FAILED`}})}computeGSSceneBounds(){let e=new et,t=new et;return this.five.scene.traverse(n=>{let r=n;(r==null?void 0:r.boundingBox)instanceof et&&!r.boundingBox.isEmpty()&&(t.copy(r.boundingBox),r.matrixWorld&&t.applyMatrix4(r.matrixWorld),e.union(t))}),e.isEmpty()?null:e}getCameraCurve(){return n(this,void 0,void 0,function*(){var e,t,n,r,i,a,o,s,c,l;let u=(r=(n=(t=(e=this.five.model.viewLayers)==null?void 0:e[0])==null?void 0:t.trajectories)==null?void 0:n[0])==null?(s=(o=(a=(i=this.five.model.viewLayers)==null?void 0:i[0])==null?void 0:a.scene)==null?void 0:o.trajectories)==null?void 0:s[0]:r,d=null,f=null;if(u&&(yield this.loadTrajectoryDataIfNeeded(u),(c=u.content)!=null&&c.data&&((l=u.content.data.positionArray)==null?void 0:l.length)>=6&&(d=this.extractKeyframes(u),d.length>=2?f=this.computeAABB2D(d):d=null)),!d||!f){let e=this.computeGSSceneBounds();if(!e)throw Error(`未找到可用于计算入场曲线的 3DGS 边界或轨迹`);f={min:new I(e.min.x,e.min.z),max:new I(e.max.x,e.max.z)};let t=(f.min.x+f.max.x)/2,n=(f.min.y+f.max.y)/2,r=(e.min.y+e.max.y)/2,i=Math.max(f.max.x-f.min.x,f.max.y-f.min.y)*.5;d=[];let a=0,o=null;for(let e=0;e<16;e++){let s=e/16*Math.PI*2,c=new L(t+Math.cos(s)*i,r,n+Math.sin(s)*i);o&&(a+=c.distanceTo(o)),d.push({position:c,location:a}),o=c}}this.keyframes=d,this.boundingAABB=f;let p=this.curveHeight,m=new L((f.min.x+f.max.x)/2,p,(f.min.y+f.max.y)/2),h=(f.max.x-f.min.x)/2,g=(f.max.y-f.min.y)/2,_=Math.sqrt(h*h+g*g),v=e=>{let t=new L().subVectors(e,m);return t.length()<.001&&t.set(1,0,0),m.clone().add(t.normalize().multiplyScalar(_))},y=new L(d[0].position.x,p,d[0].position.z),b=v(y),x=new L().subVectors(m,y).normalize(),S=new gt(y,x),C=new gt(m,new L(-x.z,0,x.x).normalize()),w=this.findClosestKeyframeToRay(C,d),T=v(new L(w.x,p,w.z)),E=this.findClosestKeyframeToRay(S,d);return new Ct([b,T,v(new L(E.x,p,E.z))],!1,`centripetal`,.5)})}setBounding(e,t,n){let r=this.findRenderMesh();r.material.aggregationBoundsMin.copy(e),r.material.aggregationBoundsMax.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),n=new L(e.min.x,0,e.min.y),r=new L(e.max.x,3,e.max.y);t.material.aggregationBoundsMin.copy(n),t.material.aggregationBoundsMax.copy(r),this.boundsSet=!0}normalizedPointDuration(){let e=this.pointDuration;return e<=0?.01:Math.min(e<=1?e:e/this.duration,1)}resetToPointCloud(){return n(this,void 0,void 0,function*(){this.boundingAABB||(yield this.getCameraCurve()),this.setBounds();let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0})}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let n=performance.now(),r=this.duration;this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-n,i=Math.min(t/r,1);e.aggregationProgress=i*i*(3-2*i),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.aggregationEnabled=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return n(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),n=this.boundingAABB,r=new L((n.min.x+n.max.x)/2,this.curveHeight,(n.min.y+n.max.y)/2),i=e.getPointAt(0),a=new t.Camera(90).copy(this.five.camera);a.position.copy(i),a.lookAt(r),a.computePose(0),this.five.setState(Object.assign({},a.pose)),this.setBounds();let o=this.findRenderMesh().material;o.aggregationEnabled=!0,o.aggregationProgress=0,o.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let s=this.duration,c=performance.now();return new Promise(n=>{this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-c,i=Math.min(t/s,1),l=i*i*(3-2*i);o.aggregationProgress=l,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(l);a.position.copy(u),a.lookAt(r),a.computePose(0),this.five.setState(Object.assign({},a.pose)),this.five.needsRender=!0,i>=1&&(o.aggregationEnabled=!1,o.aggregationProgress=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),n())})})})}};Object.defineProperty(e,"BasePlugin",{enumerable:!0,get:function(){return a}}),e.GaussianSplattingEntranceAnimationPlugin=(e,t)=>new Zt(e,t)});
|
|
255
|
+
*/(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@realsee/five-webgpu")):typeof define==`function`&&define.amd?define([`exports`,`@realsee/five-webgpu`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FiveSDK_Plugins={},e.FiveSDK))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function r(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function i(e){return/^https?:\/\/|^\/\//.test(e)||/^data:/.test(e)}function a(e,t){return i(t)?t:`${e}${t}`}var o;(function(e){class n{constructor(e,n){this.hooks=new t.Subscribe,this.staticPrefix=`//vr-image-4.realsee-cdn.cn`,this.five=e,n!=null&&n.staticPrefix&&(this.staticPrefix=n.staticPrefix)}getCurrentState(){return this.state}absoluteUrl(e){return a(this.staticPrefix,e)}}e.Controller=n})(o||(o={}));var s=class extends o.Controller{constructor(e,t){super(e),this.data={},this.pluginName=`BackgroundPlugin`,this._onFiveCameraUpdate=e=>{let t=(Math.PI/2-Math.max(e.latitude,0))/(Math.PI/2),n=Math.max(.2-t,0)*10;this.gradientBg&&(this.gradientBg.style.transform=`translateY(-${(1-t)*50}%)`),this.groundBg&&(this.groundBg.style.backgroundImage=`radial-gradient(circle, #2E303350 ${n*100}%, transparent ${n*120}%)`)},this._addEventListener=()=>{this.five.on(`cameraUpdate`,this._onFiveCameraUpdate)},this._removeEventListener=()=>{this.five.off(`cameraUpdate`,this._onFiveCameraUpdate)},this.load=()=>r(this,void 0,void 0,function*(){}),this.setState=(e,t={})=>{},this.enable=()=>{var e;let t=(e=this.five.getElement())==null?void 0:e.parentNode;if(!t){this.five.ready().then(()=>this.enable());return}this.state.enabled||(this._onFiveCameraUpdate(this.five.getPose(),!1),this.gradientBg&&t.appendChild(this.gradientBg),this.groundBg&&t.appendChild(this.groundBg),this.style&&document.head.appendChild(this.style),this._addEventListener(),this.hooks.emit(`enable`,{userAction:!0}),this.state.enabled=!0)},this.disable=(e={})=>{var t,n,r,i;this.state.enabled&&((n=(t=this.gradientBg)==null?void 0:t.parentNode)==null||n.removeChild(this.gradientBg),(i=(r=this.groundBg)==null?void 0:r.parentNode)==null||i.removeChild(this.groundBg),this.style&&document.head.removeChild(this.style),this._removeEventListener(),this.hooks.emit(`disable`,{userAction:!0}),this.state.enabled=!1)},this.dispose=()=>{this._removeEventListener(),this.hooks.emit(`disable`,{userAction:!0}),this.state.enabled=!1},this.state={enabled:!1},!(typeof document>`u`)&&(this.gradientBg=document.createElement(`div`),this.groundBg=document.createElement(`div`),this.style=document.createElement(`style`),this.gradientBg.className=`BackgroundPluginBg`,this.groundBg.className=`BackgroundPluginGroundBg`,this.style.innerHTML=`
|
|
256
|
+
.BackgroundPluginBg {
|
|
257
|
+
position: absolute;
|
|
258
|
+
top: 0;
|
|
259
|
+
right: 0;
|
|
260
|
+
left: 0;
|
|
261
|
+
height: 200%;
|
|
262
|
+
background: linear-gradient(#0A0B0D, #2E3033);
|
|
263
|
+
z-index: -1;
|
|
264
|
+
pointerEvents: none;
|
|
265
|
+
}
|
|
266
|
+
.BackgroundPluginGroundBg {
|
|
267
|
+
position: absolute;
|
|
268
|
+
top: 0;
|
|
269
|
+
right: 0;
|
|
270
|
+
left: 0;
|
|
271
|
+
bottom: 0;
|
|
272
|
+
background-image: radial-gradient(circle, #2E303350 0, transparent 0);
|
|
273
|
+
z-index: -1;
|
|
274
|
+
pointerEvents: none;
|
|
275
|
+
}
|
|
276
|
+
`,this.enable())}},c=(e,t)=>new s(e,t);function l(e){"@babel/helpers - typeof";return l=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?p(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){h(a,r,i,o,s,`next`,e)}function s(e){h(a,r,i,o,s,`throw`,e)}o(void 0)})}}var _=1e3,v=1001,y=1002,b=1003,x=1006,S=1008,C=1008,ee=1009,te=1014,ne=1015,w=1016,re=1023,ie=1026,ae=1030,oe=2300,se=2301,ce=2302,le=2303,ue=2400,de=2401,fe=2402,pe=`srgb`,me=`srgb-linear`,he=`linear`,ge=`srgb`,_e=7680,ve=35044,ye=35048,be=2e3,xe=2001,Se={TEXTURE_COMPARE:`depthTextureCompare`};function Ce(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function we(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Te(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}var Ee={},De=null;function Oe(...e){let t=`THREE.`+e.shift();De?De(`log`,t,...e):console.log(t,...e)}function ke(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function T(...e){e=ke(e);let t=`THREE.`+e.shift();if(De)De(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function E(...e){e=ke(e);let t=`THREE.`+e.shift();if(De)De(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Ae(...e){let t=e.join(` `);t in Ee||(Ee[t]=!0,T(...e))}var je=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},Me=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),Ne=1234567,Pe=Math.PI/180,Fe=180/Math.PI;function Ie(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Me[e&255]+Me[e>>8&255]+Me[e>>16&255]+Me[e>>24&255]+`-`+Me[t&255]+Me[t>>8&255]+`-`+Me[t>>16&15|64]+Me[t>>24&255]+`-`+Me[n&63|128]+Me[n>>8&255]+`-`+Me[n>>16&255]+Me[n>>24&255]+Me[r&255]+Me[r>>8&255]+Me[r>>16&255]+Me[r>>24&255]).toLowerCase()}function D(e,t,n){return Math.max(t,Math.min(n,e))}function Le(e,t){return(e%t+t)%t}function Re(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function ze(e,t,n){return e===t?0:(n-e)/(t-e)}function Be(e,t,n){return(1-n)*e+n*t}function Ve(e,t,n,r){return Be(e,t,1-Math.exp(-n*r))}function He(e,t=1){return t-Math.abs(Le(e,t*2)-t)}function Ue(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function We(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Ge(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Ke(e,t){return e+Math.random()*(t-e)}function qe(e){return e*(.5-Math.random())}function Je(e){e!==void 0&&(Ne=e);let t=Ne+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ye(e){return e*Pe}function Xe(e){return e*Fe}function Ze(e){return(e&e-1)==0&&e!==0}function Qe(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function $e(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function et(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:T(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function tt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function nt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var rt={DEG2RAD:Pe,RAD2DEG:Fe,generateUUID:Ie,clamp:D,euclideanModulo:Le,mapLinear:Re,inverseLerp:ze,lerp:Be,damp:Ve,pingpong:He,smoothstep:Ue,smootherstep:We,randInt:Ge,randFloat:Ke,randFloatSpread:qe,seededRandom:Je,degToRad:Ye,radToDeg:Xe,isPowerOfTwo:Ze,ceilPowerOfTwo:Qe,floorPowerOfTwo:$e,setQuaternionFromProperEuler:et,normalize:nt,denormalize:tt},it=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=D(this.x,e.x,t.x),this.y=D(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=D(this.x,e,t),this.y=D(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(D(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(D(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},at=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:T(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(D(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},O=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(st.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(st.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=D(this.x,e.x,t.x),this.y=D(this.y,e.y,t.y),this.z=D(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=D(this.x,e,t),this.y=D(this.y,e,t),this.z=D(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(D(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ot.copy(this).projectOnVector(e),this.sub(ot)}reflect(e){return this.sub(ot.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(D(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ot=new O,st=new at,ct=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(lt.makeScale(e,t)),this}rotate(e){return this.premultiply(lt.makeRotation(-e)),this}translate(e,t){return this.premultiply(lt.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},lt=new ct,ut=new ct().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dt=new ct().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ft(){let e={enabled:!0,workingColorSpace:me,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=mt(e.r),e.g=mt(e.g),e.b=mt(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=ht(e.r),e.g=ht(e.g),e.b=ht(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?he:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Ae(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Ae(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[me]:{primaries:t,whitePoint:r,transfer:he,toXYZ:ut,fromXYZ:dt,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:pe},outputColorSpaceConfig:{drawingBufferColorSpace:pe}},[pe]:{primaries:t,whitePoint:r,transfer:ge,toXYZ:ut,fromXYZ:dt,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:pe}}}),e}var pt=ft();function mt(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function ht(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}var gt,_t=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gt===void 0&&(gt=Te(`canvas`)),gt.width=e.width,gt.height=e.height;let t=gt.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=gt}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Te(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=mt(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(mt(t[e]/255)*255):t[e]=mt(t[e]);return{data:t,width:e.width,height:e.height}}else return T(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},vt=0,yt=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:vt++}),this.uuid=Ie(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(bt(r[t].image)):e.push(bt(r[t]))}else e=bt(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function bt(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?_t.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(T(`Texture: Unable to serialize Texture.`),{})}var xt=0,St=new O,Ct=class e extends je{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=v,i=v,a=x,o=S,s=re,c=ee,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xt++}),this.uuid=Ie(),this.name=``,this.source=new yt(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new it(0,0),this.repeat=new it(1,1),this.center=new it(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(St).x}get height(){return this.source.getSize(St).y}get depth(){return this.source.getSize(St).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){T(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){T(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case _:e.x-=Math.floor(e.x);break;case v:e.x=e.x<0?0:1;break;case y:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case _:e.y-=Math.floor(e.y);break;case v:e.y=e.y<0?0:1;break;case y:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Ct.DEFAULT_IMAGE=null,Ct.DEFAULT_MAPPING=300,Ct.DEFAULT_ANISOTROPY=1;var wt=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=D(this.x,e.x,t.x),this.y=D(this.y,e.y,t.y),this.z=D(this.z,e.z,t.z),this.w=D(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=D(this.x,e,t),this.y=D(this.y,e,t),this.z=D(this.z,e,t),this.w=D(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(D(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Tt=class extends je{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:x,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];let r=new Ct({width:e,height:t,depth:n.depth}),i=n.count;for(let e=0;e<i;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:x,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new yt(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},Et=class extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=b,this.minFilter=b,this.wrapR=v,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},k=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/Dt.setFromMatrixColumn(e,0).length(),i=1/Dt.setFromMatrixColumn(e,1).length(),a=1/Dt.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kt,e,At)}lookAt(e,t,n){let r=this.elements;return Nt.subVectors(e,t),Nt.lengthSq()===0&&(Nt.z=1),Nt.normalize(),jt.crossVectors(n,Nt),jt.lengthSq()===0&&(Math.abs(n.z)===1?Nt.x+=1e-4:Nt.z+=1e-4,Nt.normalize(),jt.crossVectors(n,Nt)),jt.normalize(),Mt.crossVectors(Nt,jt),r[0]=jt.x,r[4]=Mt.x,r[8]=Nt.x,r[1]=jt.y,r[5]=Mt.y,r[9]=Nt.y,r[2]=jt.z,r[6]=Mt.z,r[10]=Nt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],ee=r[12],te=r[1],ne=r[5],w=r[9],re=r[13],ie=r[2],ae=r[6],oe=r[10],se=r[14],ce=r[3],le=r[7],ue=r[11],de=r[15];return i[0]=a*x+o*te+s*ie+c*ce,i[4]=a*S+o*ne+s*ae+c*le,i[8]=a*C+o*w+s*oe+c*ue,i[12]=a*ee+o*re+s*se+c*de,i[1]=l*x+u*te+d*ie+f*ce,i[5]=l*S+u*ne+d*ae+f*le,i[9]=l*C+u*w+d*oe+f*ue,i[13]=l*ee+u*re+d*se+f*de,i[2]=p*x+m*te+h*ie+g*ce,i[6]=p*S+m*ne+h*ae+g*le,i[10]=p*C+m*w+h*oe+g*ue,i[14]=p*ee+m*re+h*se+g*de,i[3]=_*x+v*te+y*ie+b*ce,i[7]=_*S+v*ne+y*ae+b*le,i[11]=_*C+v*w+y*oe+b*ue,i[15]=_*ee+v*re+y*se+b*de,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,ee=l*h-d*p,te=l*g-f*p,ne=u*h-d*m,w=u*g-f*m,re=d*g-f*h,ie=_*re-v*w+y*ne+b*te-x*ee+S*C;if(ie===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let ae=1/ie;return e[0]=(o*re-s*w+c*ne)*ae,e[1]=(r*w-n*re-i*ne)*ae,e[2]=(m*S-h*x+g*b)*ae,e[3]=(d*x-u*S-f*b)*ae,e[4]=(s*te-a*re-c*ee)*ae,e[5]=(t*re-r*te+i*ee)*ae,e[6]=(h*y-p*S-g*v)*ae,e[7]=(l*S-d*y+f*v)*ae,e[8]=(a*w-o*te+c*C)*ae,e[9]=(n*te-t*w-i*C)*ae,e[10]=(p*x-m*y+g*_)*ae,e[11]=(u*y-l*x-f*_)*ae,e[12]=(o*ee-a*ne-s*C)*ae,e[13]=(t*ne-n*ee+r*C)*ae,e[14]=(m*v-p*b-h*_)*ae,e[15]=(l*b-u*v+d*_)*ae,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinant();if(i===0)return n.set(1,1,1),t.identity(),this;let a=Dt.set(r[0],r[1],r[2]).length(),o=Dt.set(r[4],r[5],r[6]).length(),s=Dt.set(r[8],r[9],r[10]).length();i<0&&(a=-a),Ot.copy(this);let c=1/a,l=1/o,u=1/s;return Ot.elements[0]*=c,Ot.elements[1]*=c,Ot.elements[2]*=c,Ot.elements[4]*=l,Ot.elements[5]*=l,Ot.elements[6]*=l,Ot.elements[8]*=u,Ot.elements[9]*=u,Ot.elements[10]*=u,t.setFromRotationMatrix(Ot),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=be,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=be,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Dt=new O,Ot=new k,kt=new O(0,0,0),At=new O(1,1,1),jt=new O,Mt=new O,Nt=new O,Pt=new k,Ft=new at,It=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(D(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-D(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(D(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-D(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(D(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-D(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:T(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Pt.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Pt,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ft.setFromEuler(this),this.setFromQuaternion(Ft,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};It.DEFAULT_ORDER=`XYZ`;var Lt=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}},Rt=0,zt=new O,Bt=new at,Vt=new k,Ht=new O,Ut=new O,Wt=new O,Gt=new at,Kt=new O(1,0,0),qt=new O(0,1,0),Jt=new O(0,0,1),Yt={type:`added`},Xt={type:`removed`},Zt={type:`childadded`,child:null},Qt={type:`childremoved`,child:null},$t=class e extends je{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Rt++}),this.uuid=Ie(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new O,n=new It,r=new at,i=new O(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new k},normalMatrix:{value:new ct}}),this.matrix=new k,this.matrixWorld=new k,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Lt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Bt.setFromAxisAngle(e,t),this.quaternion.multiply(Bt),this}rotateOnWorldAxis(e,t){return Bt.setFromAxisAngle(e,t),this.quaternion.premultiply(Bt),this}rotateX(e){return this.rotateOnAxis(Kt,e)}rotateY(e){return this.rotateOnAxis(qt,e)}rotateZ(e){return this.rotateOnAxis(Jt,e)}translateOnAxis(e,t){return zt.copy(e).applyQuaternion(this.quaternion),this.position.add(zt.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Kt,e)}translateY(e){return this.translateOnAxis(qt,e)}translateZ(e){return this.translateOnAxis(Jt,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Vt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ht.copy(e):Ht.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Ut.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Vt.lookAt(Ut,Ht,this.up):Vt.lookAt(Ht,Ut,this.up),this.quaternion.setFromRotationMatrix(Vt),r&&(Vt.extractRotation(r.matrixWorld),Bt.setFromRotationMatrix(Vt),this.quaternion.premultiply(Bt.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(E(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Yt),Zt.child=e,this.dispatchEvent(Zt),Zt.child=null):E(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Xt),Qt.child=e,this.dispatchEvent(Qt),Qt.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Vt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Vt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Vt),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Yt),Zt.child=e,this.dispatchEvent(Zt),Zt.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ut,e,Wt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ut,Gt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>m(m({},e),{},{boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>m({},e)),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};$t.DEFAULT_UP=new O(0,1,0),$t.DEFAULT_MATRIX_AUTO_UPDATE=!0,$t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var en=class extends $t{constructor(){super(),this.isGroup=!0,this.type=`Group`}},tn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},nn={h:0,s:0,l:0},rn={h:0,s:0,l:0};function an(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var on=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pe){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=pt.workingColorSpace){return this.r=e,this.g=t,this.b=n,pt.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=pt.workingColorSpace){if(e=Le(e,1),t=D(t,0,1),n=D(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=an(i,r,e+1/3),this.g=an(i,r,e),this.b=an(i,r,e-1/3)}return pt.colorSpaceToWorking(this,r),this}setStyle(e,t=pe){function n(t){t!==void 0&&parseFloat(t)<1&&T(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:T(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);T(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pe){let n=tn[e.toLowerCase()];return n===void 0?T(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mt(e.r),this.g=mt(e.g),this.b=mt(e.b),this}copyLinearToSRGB(e){return this.r=ht(e.r),this.g=ht(e.g),this.b=ht(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pe){return pt.workingToColorSpace(sn.copy(this),e),Math.round(D(sn.r*255,0,255))*65536+Math.round(D(sn.g*255,0,255))*256+Math.round(D(sn.b*255,0,255))}getHexString(e=pe){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pt.workingColorSpace){pt.workingToColorSpace(sn.copy(this),t);let n=sn.r,r=sn.g,i=sn.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=pt.workingColorSpace){return pt.workingToColorSpace(sn.copy(this),t),e.r=sn.r,e.g=sn.g,e.b=sn.b,e}getStyle(e=pe){pt.workingToColorSpace(sn.copy(this),e);let t=sn.r,n=sn.g,r=sn.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(nn),this.setHSL(nn.h+e,nn.s+t,nn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nn),e.getHSL(rn);let n=Be(nn.h,rn.h,t),r=Be(nn.s,rn.s,t),i=Be(nn.l,rn.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},sn=new on;on.NAMES=tn;var cn=class extends $t{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new It,this.environmentIntensity=1,this.environmentRotation=new It,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},ln=new O,un=new O,dn=new O,fn=new O,pn=new O,mn=new O,hn=new O,gn=new O,_n=new O,vn=new O,yn=new wt,bn=new wt,xn=new wt,Sn=class e{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),ln.subVectors(e,t),r.cross(ln);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){ln.subVectors(r,t),un.subVectors(n,t),dn.subVectors(e,t);let a=ln.dot(ln),o=ln.dot(un),s=ln.dot(dn),c=un.dot(un),l=un.dot(dn),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,fn)===null?!1:fn.x>=0&&fn.y>=0&&fn.x+fn.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,fn)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,fn.x),s.addScaledVector(a,fn.y),s.addScaledVector(o,fn.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return yn.setScalar(0),bn.setScalar(0),xn.setScalar(0),yn.fromBufferAttribute(e,t),bn.fromBufferAttribute(e,n),xn.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(yn,i.x),a.addScaledVector(bn,i.y),a.addScaledVector(xn,i.z),a}static isFrontFacing(e,t,n,r){return ln.subVectors(n,t),un.subVectors(e,t),ln.cross(un).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ln.subVectors(this.c,this.b),un.subVectors(this.a,this.b),ln.cross(un).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;pn.subVectors(r,n),mn.subVectors(i,n),gn.subVectors(e,n);let s=pn.dot(gn),c=mn.dot(gn);if(s<=0&&c<=0)return t.copy(n);_n.subVectors(e,r);let l=pn.dot(_n),u=mn.dot(_n);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(pn,a);vn.subVectors(e,i);let f=pn.dot(vn),p=mn.dot(vn);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(mn,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return hn.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(hn,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(pn,a).addScaledVector(mn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Cn=class{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Tn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Tn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Tn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,Tn):Tn.fromBufferAttribute(r,t),Tn.applyMatrix4(e.matrixWorld),this.expandByPoint(Tn);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),En.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),En.copy(e.boundingBox)),En.applyMatrix4(e.matrixWorld),this.union(En)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Tn),Tn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Nn),Pn.subVectors(this.max,Nn),Dn.subVectors(e.a,Nn),On.subVectors(e.b,Nn),kn.subVectors(e.c,Nn),An.subVectors(On,Dn),jn.subVectors(kn,On),Mn.subVectors(Dn,kn);let t=[0,-An.z,An.y,0,-jn.z,jn.y,0,-Mn.z,Mn.y,An.z,0,-An.x,jn.z,0,-jn.x,Mn.z,0,-Mn.x,-An.y,An.x,0,-jn.y,jn.x,0,-Mn.y,Mn.x,0];return!Ln(t,Dn,On,kn,Pn)||(t=[1,0,0,0,1,0,0,0,1],!Ln(t,Dn,On,kn,Pn))?!1:(Fn.crossVectors(An,jn),t=[Fn.x,Fn.y,Fn.z],Ln(t,Dn,On,kn,Pn))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Tn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Tn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(wn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},wn=[new O,new O,new O,new O,new O,new O,new O,new O],Tn=new O,En=new Cn,Dn=new O,On=new O,kn=new O,An=new O,jn=new O,Mn=new O,Nn=new O,Pn=new O,Fn=new O,In=new O;function Ln(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){In.fromArray(e,a);let o=i.x*Math.abs(In.x)+i.y*Math.abs(In.y)+i.z*Math.abs(In.z),s=t.dot(In),c=n.dot(In),l=r.dot(In);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Rn=new O,zn=new it,Bn=0,Vn=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Bn++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=ve,this.updateRanges=[],this.gpuType=ne,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)zn.fromBufferAttribute(this,t),zn.applyMatrix3(e),this.setXY(t,zn.x,zn.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.applyMatrix3(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.applyMatrix4(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.applyNormalMatrix(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.transformDirection(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=tt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tt(t,this.array)),t}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tt(t,this.array)),t}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=tt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=tt(t,this.array)),t}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),r=nt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),r=nt(r,this.array),i=nt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==35044&&(e.usage=this.usage),e}},Hn=class extends Vn{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Un=class extends Vn{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Wn=class extends Vn{constructor(e,t,n){super(new Float32Array(e),t,n)}},Gn=new Cn,Kn=new O,qn=new O,Jn=class{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Gn.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Kn.subVectors(e,this.center);let t=Kn.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Kn,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(qn.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kn.copy(e.center).add(qn)),this.expandByPoint(Kn.copy(e.center).sub(qn))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Yn=0,Xn=new k,Zn=new $t,Qn=new O,$n=new Cn,er=new Cn,tr=new O,nr=class e extends je{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yn++}),this.uuid=Ie(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Ce(e)?Un:Hn)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new ct().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Xn.makeRotationFromQuaternion(e),this.applyMatrix4(Xn),this}rotateX(e){return Xn.makeRotationX(e),this.applyMatrix4(Xn),this}rotateY(e){return Xn.makeRotationY(e),this.applyMatrix4(Xn),this}rotateZ(e){return Xn.makeRotationZ(e),this.applyMatrix4(Xn),this}translate(e,t,n){return Xn.makeTranslation(e,t,n),this.applyMatrix4(Xn),this}scale(e,t,n){return Xn.makeScale(e,t,n),this.applyMatrix4(Xn),this}lookAt(e){return Zn.lookAt(e),Zn.updateMatrix(),this.applyMatrix4(Zn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qn).negate(),this.translate(Qn.x,Qn.y,Qn.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Wn(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&T(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Cn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){E(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];$n.setFromBufferAttribute(n),this.morphTargetsRelative?(tr.addVectors(this.boundingBox.min,$n.min),this.boundingBox.expandByPoint(tr),tr.addVectors(this.boundingBox.max,$n.max),this.boundingBox.expandByPoint(tr)):(this.boundingBox.expandByPoint($n.min),this.boundingBox.expandByPoint($n.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&E(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Jn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){E(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new O,1/0);return}if(e){let n=this.boundingSphere.center;if($n.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];er.setFromBufferAttribute(n),this.morphTargetsRelative?(tr.addVectors($n.min,er.min),$n.expandByPoint(tr),tr.addVectors($n.max,er.max),$n.expandByPoint(tr)):($n.expandByPoint(er.min),$n.expandByPoint(er.max))}$n.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)tr.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(tr));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)tr.fromBufferAttribute(a,t),o&&(Qn.fromBufferAttribute(e,t),tr.add(Qn)),r=Math.max(r,n.distanceToSquared(tr))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&E(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){E(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new Vn(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new O,s[e]=new O;let c=new O,l=new O,u=new O,d=new it,f=new it,p=new it,m=new O,h=new O;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new O,y=new O,b=new O,x=new O;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e])<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,n)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new Vn(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new O,i=new O,a=new O,o=new O,s=new O,c=new O,l=new O,u=new O;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)tr.fromBufferAttribute(e,t),tr.normalize(),e.setXYZ(t,tr.x,tr.y,tr.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Vn(a,r,i)}if(this.index===null)return T(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}},rr=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=ve,this.updateRanges=[],this.version=0,this.uuid=Ie()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ie()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ie()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},ir=new O,ar=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)ir.fromBufferAttribute(this,t),ir.applyMatrix4(e),this.setXYZ(t,ir.x,ir.y,ir.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ir.fromBufferAttribute(this,t),ir.applyNormalMatrix(e),this.setXYZ(t,ir.x,ir.y,ir.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ir.fromBufferAttribute(this,t),ir.transformDirection(e),this.setXYZ(t,ir.x,ir.y,ir.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=tt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=tt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tt(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),r=nt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),r=nt(r,this.array),i=nt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){Oe(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Vn(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Oe(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},or=0,sr=class extends je{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:or++}),this.uuid=Ie(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new on(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=_e,this.stencilZFail=_e,this.stencilZPass=_e,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){T(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){T(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},cr=new O,lr=new O,ur=new O,dr=new O,fr=new O,pr=new O,mr=new O,hr=class{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,cr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=cr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(cr.copy(this.origin).addScaledVector(this.direction,t),cr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){lr.copy(e).add(t).multiplyScalar(.5),ur.copy(t).sub(e).normalize(),dr.copy(this.origin).sub(lr);let i=e.distanceTo(t)*.5,a=-this.direction.dot(ur),o=dr.dot(this.direction),s=-dr.dot(ur),c=dr.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(lr).addScaledVector(ur,d),f}intersectSphere(e,t){cr.subVectors(e.center,this.origin);let n=cr.dot(this.direction),r=cr.dot(cr)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,cr)!==null}intersectTriangle(e,t,n,r,i){fr.subVectors(t,e),pr.subVectors(n,e),mr.crossVectors(fr,pr);let a=this.direction.dot(mr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;dr.subVectors(this.origin,e);let s=o*this.direction.dot(pr.crossVectors(dr,pr));if(s<0)return null;let c=o*this.direction.dot(fr.cross(dr));if(c<0||s+c>a)return null;let l=-o*dr.dot(mr);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},gr=class extends sr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new on(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new It,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},_r=new k,vr=new hr,yr=new Jn,br=new O,xr=new O,Sr=new O,Cr=new O,wr=new O,Tr=new O,Er=new O,Dr=new O,Or=class extends $t{constructor(e=new nr,t=new gr){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Tr.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(wr.fromBufferAttribute(s,e),a?Tr.addScaledVector(wr,r):Tr.addScaledVector(wr.sub(t),r))}t.add(Tr)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),yr.copy(n.boundingSphere),yr.applyMatrix4(i),vr.copy(e.ray).recast(e.near),!(yr.containsPoint(vr.origin)===!1&&(vr.intersectSphere(yr,br)===null||vr.origin.distanceToSquared(br)>Math.pow(e.far-e.near,2)))&&(_r.copy(i).invert(),vr.copy(e.ray).applyMatrix4(_r),!(n.boundingBox!==null&&vr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,vr)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ar(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ar(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ar(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ar(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function kr(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Dr.copy(s),Dr.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Dr);return l<n.near||l>n.far?null:{distance:l,point:Dr.clone(),object:e}}function Ar(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,xr),e.getVertexPosition(c,Sr),e.getVertexPosition(l,Cr);let u=kr(e,t,n,r,xr,Sr,Cr,Er);if(u){let e=new O;Sn.getBarycoord(Er,xr,Sr,Cr,e),i&&(u.uv=Sn.getInterpolatedAttribute(i,s,c,l,e,new it)),a&&(u.uv1=Sn.getInterpolatedAttribute(a,s,c,l,e,new it)),o&&(u.normal=Sn.getInterpolatedAttribute(o,s,c,l,e,new O),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new O,materialIndex:0};Sn.getNormal(xr,Sr,Cr,t.normal),u.face=t,u.barycoord=e}return u}var jr=class extends Ct{constructor(e=null,t=1,n=1,r,i,a,o,s,c=b,l=b,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Mr=class extends Vn{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Nr=new O,Pr=new O,Fr=new ct,Ir=class{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Nr.subVectors(n,t).cross(Pr.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(Nr),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Fr.getNormalMatrix(e),r=this.coplanarPoint(Nr).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Lr=class extends sr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new on(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Rr=new O,zr=new O,Br=new k,Vr=new hr,Hr=new Jn,Ur=new O,Wr=new O,Gr=class extends $t{constructor(e=new nr,t=new Lr){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)Rr.fromBufferAttribute(t,e-1),zr.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Rr.distanceTo(zr);e.setAttribute(`lineDistance`,new Wn(n,1))}else T(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Hr.copy(n.boundingSphere),Hr.applyMatrix4(r),Hr.radius+=i,e.ray.intersectsSphere(Hr)===!1)return;Br.copy(r).invert(),Vr.copy(e.ray).applyMatrix4(Br);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=Kr(this,e,Vr,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=Kr(this,e,Vr,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=Kr(this,e,Vr,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=Kr(this,e,Vr,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Kr(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(Rr.fromBufferAttribute(s,i),zr.fromBufferAttribute(s,a),n.distanceSqToSegment(Rr,zr,Ur,Wr)>r)return;Ur.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Ur);if(!(c<t.near||c>t.far))return{distance:c,point:Wr.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var qr=new O,Jr=new O,Yr=class extends Gr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)qr.fromBufferAttribute(t,e),Jr.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+qr.distanceTo(Jr);e.setAttribute(`lineDistance`,new Wn(n,1))}else T(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},Xr=class extends Ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=b,this.minFilter=b,this.generateMipmaps=!1,this.needsUpdate=!0}},Zr=class extends Ct{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Qr=class extends Ct{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},$r=class extends Ct{constructor(e,t,n=te,r,i,a,o=b,s=b,c,l=ie,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new yt(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ei=class extends $r{constructor(e,t=te,n=301,r,i,a=b,o=b,s,c=ie){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ti=class e extends nr{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Wn(c,3)),this.setAttribute(`normal`,new Wn(l,3)),this.setAttribute(`uv`,new Wn(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,ee=g+1,te=0,ne=0,w=new O;for(let a=0;a<ee;a++){let o=a*y-x;for(let s=0;s<C;s++)w[e]=(s*v-b)*r,w[t]=o*i,w[n]=S,c.push(w.x,w.y,w.z),w[e]=0,w[t]=0,w[n]=m>0?1:-1,l.push(w.x,w.y,w.z),u.push(s/h),u.push(1-a/g),te+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),ne+=6}o.addGroup(f,ne,_),f+=ne,d+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},ni=class e extends nr{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type=`CircleGeometry`,this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let i=[],a=[],o=[],s=[],c=new O,l=new it;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){let d=n+i/t*r;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute(`position`,new Wn(a,3)),this.setAttribute(`normal`,new Wn(o,3)),this.setAttribute(`uv`,new Wn(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.segments,t.thetaStart,t.thetaLength)}},ri=class e extends nr{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Wn(u,3)),this.setAttribute(`normal`,new Wn(d,3)),this.setAttribute(`uv`,new Wn(f,2));function _(){let a=new O,_=new O,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new it,m=new O,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ii=class e extends ri{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ai=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){T(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new it:new O);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new O,r=[],i=[],a=[],o=new O,s=new k;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new O)}i[0]=new O,a[0]=new O;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>Number.EPSILON){o.normalize();let e=Math.acos(D(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(D(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}};function oi(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var si=new O,ci=new oi,li=new oi,ui=new oi,di=class extends ai{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new O){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(si.subVectors(r[0],r[1]).add(r[0]),c=si);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(si.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=si),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=Math.pow(c.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),r=Math.pow(d.distanceToSquared(l),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),ci.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),li.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),ui.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(ci.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),li.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),ui.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(ci.calc(s),li.calc(s),ui.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new O().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},fi=class e extends nr{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new O,p=new it;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new Wn(s,3)),this.setAttribute(`normal`,new Wn(c,3)),this.setAttribute(`uv`,new Wn(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}};function pi(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var mi=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},hi=class extends mi{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ue,endingEnd:ue}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case de:i=e,o=2*t-n;break;case fe:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case de:a=e,s=2*n-t;break;case fe:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},gi=class extends mi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},_i=class extends mi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},vi=class extends mi{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this.settings||this.DefaultSettings_,u=l.inTangents,d=l.outTangents;if(!u||!d){let e=(n-t)/(r-t),l=1-e;for(let t=0;t!==o;++t)i[t]=a[c+t]*l+a[s+t]*e;return i}let f=o*2,p=e-1;for(let l=0;l!==o;++l){let o=a[c+l],m=a[s+l],h=p*f+l*2,g=d[h],_=d[h+1],v=e*f+l*2,y=u[v],b=u[v+1],x=(n-t)/(r-t),S,C,ee,te,ne;for(let e=0;e<8;e++){S=x*x,C=S*x,ee=1-x,te=ee*ee,ne=te*ee;let e=ne*t+3*te*x*g+3*ee*S*y+C*r-n;if(Math.abs(e)<1e-10)break;let i=3*te*(g-t)+6*ee*x*(y-g)+3*S*(r-y);if(Math.abs(i)<1e-10)break;x-=e/i,x=Math.max(0,Math.min(1,x))}i[l]=ne*o+3*te*x*_+3*ee*S*b+C*m}return i}},yi=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=pi(t,this.TimeBufferType),this.values=pi(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:pi(e.times,Array),values:pi(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new _i(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new gi(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new hi(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new vi(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case oe:t=this.InterpolantFactoryMethodDiscrete;break;case se:t=this.InterpolantFactoryMethodLinear;break;case ce:t=this.InterpolantFactoryMethodSmooth;break;case le:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return T(`KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return oe;case this.InterpolantFactoryMethodLinear:return se;case this.InterpolantFactoryMethodSmooth:return ce;case this.InterpolantFactoryMethodBezier:return le}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(E(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(E(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){E(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){E(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&we(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){E(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===ce,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o];if(s!==e[o+1]&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};yi.prototype.ValueTypeName=``,yi.prototype.TimeBufferType=Float32Array,yi.prototype.ValueBufferType=Float32Array,yi.prototype.DefaultInterpolation=se;var bi=class extends yi{constructor(e,t,n){super(e,t,n)}};bi.prototype.ValueTypeName=`bool`,bi.prototype.ValueBufferType=Array,bi.prototype.DefaultInterpolation=oe,bi.prototype.InterpolantFactoryMethodLinear=void 0,bi.prototype.InterpolantFactoryMethodSmooth=void 0;var xi=class extends yi{constructor(e,t,n,r){super(e,t,n,r)}};xi.prototype.ValueTypeName=`color`;var Si=class extends yi{constructor(e,t,n,r){super(e,t,n,r)}};Si.prototype.ValueTypeName=`number`;var Ci=class extends mi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)at.slerpFlat(i,0,a,c-o,a,c,s);return i}},wi=class extends yi{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Ci(this.times,this.values,this.getValueSize(),e)}};wi.prototype.ValueTypeName=`quaternion`,wi.prototype.InterpolantFactoryMethodSmooth=void 0;var Ti=class extends yi{constructor(e,t,n){super(e,t,n)}};Ti.prototype.ValueTypeName=`string`,Ti.prototype.ValueBufferType=Array,Ti.prototype.DefaultInterpolation=oe,Ti.prototype.InterpolantFactoryMethodLinear=void 0,Ti.prototype.InterpolantFactoryMethodSmooth=void 0;var Ei=class extends yi{constructor(e,t,n,r){super(e,t,n,r)}};Ei.prototype.ValueTypeName=`vector`;var Di=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Oi=class{constructor(e){this.manager=e===void 0?Di:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};Oi.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var ki=new O,Ai=new at,ji=new O,Mi=class extends $t{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new k,this.projectionMatrix=new k,this.projectionMatrixInverse=new k,this.coordinateSystem=be,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ki,Ai,ji),ji.x===1&&ji.y===1&&ji.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ki,Ai,ji.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(ki,Ai,ji),ji.x===1&&ji.y===1&&ji.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ki,Ai,ji.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Ni=new O,Pi=new it,Fi=new it,Ii=class extends Mi{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Fe*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Pe*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Fe*2*Math.atan(Math.tan(Pe*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ni.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ni.x,Ni.y).multiplyScalar(-e/Ni.z),Ni.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ni.x,Ni.y).multiplyScalar(-e/Ni.z)}getViewSize(e,t){return this.getViewBounds(e,Pi,Fi),t.subVectors(Fi,Pi)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Pe*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Li=class extends Mi{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Ri=`\\[\\]\\.:\\/`,zi=RegExp(`[\\[\\]\\.:\\/]`,`g`),Bi=`[^\\[\\]\\.:\\/]`,Vi=`[^`+Ri.replace(`\\.`,``)+`]`,Hi=`((?:WC+[\\/:])*)`.replace(`WC`,Bi),Ui=`(WCOD+)?`.replace(`WCOD`,Vi),Wi=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,Bi),Gi=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,Bi),Ki=RegExp(`^`+Hi+Ui+Wi+Gi+`$`),qi=[`material`,`materials`,`bones`,`map`],Ji=class{constructor(e,t,n){let r=n||Yi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Yi=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(zi,``)}static parseTrackName(e){let t=Ki.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);qi.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){T(`PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){E(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){E(`PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){E(`PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){E(`PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){E(`PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){E(`PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){E(`PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;E(`PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){E(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){E(`PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Yi.Composite=Ji,Yi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Yi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Yi.prototype.GetterByBindingType=[Yi.prototype._getValue_direct,Yi.prototype._getValue_array,Yi.prototype._getValue_arrayElement,Yi.prototype._getValue_toArray],Yi.prototype.SetterByBindingTypeAndVersioning=[[Yi.prototype._setValue_direct,Yi.prototype._setValue_direct_setNeedsUpdate,Yi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Yi.prototype._setValue_array,Yi.prototype._setValue_array_setNeedsUpdate,Yi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Yi.prototype._setValue_arrayElement,Yi.prototype._setValue_arrayElement_setNeedsUpdate,Yi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Yi.prototype._setValue_fromArray,Yi.prototype._setValue_fromArray_setNeedsUpdate,Yi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Xi=class extends rr{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Zi=new k,Qi=class{constructor(e,t,n=0,r=1/0){this.ray=new hr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Lt,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):E(`Raycaster: Unsupported camera type: `+t.type)}setFromXRController(e){return Zi.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Zi),this}intersectObject(e,t=!0,n=[]){return ea(e,this,n,t),n.sort($i),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)ea(e[r],this,n,t);return n.sort($i),n}};function $i(e,t){return e.distance-t.distance}function ea(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)ea(r[e],t,n,!0)}}var ta=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},na=new O,ra=new O,ia=new O,aa=new O,oa=new O,sa=new O,ca=new O,la=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){na.subVectors(e,this.start),ra.subVectors(this.end,this.start);let n=ra.dot(ra),r=ra.dot(na)/n;return t&&(r=D(r,0,1)),r}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=sa,n=ca){let r=1e-8*1e-8,i,a,o=this.start,s=e.start,c=this.end,l=e.end;ia.subVectors(c,o),aa.subVectors(l,s),oa.subVectors(o,s);let u=ia.dot(ia),d=aa.dot(aa),f=aa.dot(oa);if(u<=r&&d<=r)return t.copy(o),n.copy(s),t.sub(n),t.dot(t);if(u<=r)i=0,a=f/d,a=D(a,0,1);else{let e=ia.dot(oa);if(d<=r)a=0,i=D(-e/u,0,1);else{let t=ia.dot(aa),n=u*d-t*t;i=n===0?0:D((t*f-e*d)/n,0,1),a=(t*i+f)/d,a<0?(a=0,i=D(-e/u,0,1)):a>1&&(a=1,i=D((t-e)/u,0,1))}}return t.copy(o).addScaledVector(ia,i),n.copy(s).addScaledVector(aa,a),t.distanceToSquared(n)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:`183`}})),typeof window<`u`&&(window.__THREE__?T(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=`183`);var ua=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`),da=new WeakMap,fa=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=ua,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexId:n.index?n.index.id:null,indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={id:r.id,version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];r!=null&&(typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e,t){let{object:n,material:r,geometry:i}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(n.matrixWorld)!==!0)return a.worldMatrix.copy(n.matrixWorld),!1;let o=a.material;for(let e in o){let t=o[e],n=r[e];if(t.equals!==void 0){if(t.equals(n)===!1)return t.copy(n),!1}else if(n.isTexture===!0){if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,!1}else if(t!==n)return o[e]=n,!1}if(o.transmission>0){let{width:t,height:n}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==n)return a.bufferWidth=t,a.bufferHeight=n,!1}let s=a.geometry,c=i.attributes,l=s.attributes,u=Object.keys(l),d=Object.keys(c);if(s.id!==i.id)return s.id=i.id,!1;if(u.length!==d.length)return a.geometry.attributes=this.getAttributesData(c),!1;for(let e of u){let t=l[e],n=c[e];if(n===void 0)return delete l[e],!1;if(t.id!==n.id||t.version!==n.version)return t.id=n.id,t.version=n.version,!1}let f=i.index,p=s.indexId,m=s.indexVersion,h=f?f.id:null,g=f?f.version:null;if(p!==h||m!==g)return s.indexId=h,s.indexVersion=g,!1;if(s.drawRange.start!==i.drawRange.start||s.drawRange.count!==i.drawRange.count)return s.drawRange.start=i.drawRange.start,s.drawRange.count=i.drawRange.count,!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t<a.morphTargetInfluences.length;t++)a.morphTargetInfluences[t]!==n.morphTargetInfluences[t]&&(a.morphTargetInfluences[t]=n.morphTargetInfluences[t],e=!0);if(e)return!1}if(a.lights){for(let e=0;e<t.length;e++)if(a.lights[e].map!==t[e].map)return!1}return a.center&&a.center.equals(n.center)===!1?(a.center.copy(n.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){let t=[];for(let n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(da.has(e)){let n=da.get(e);if(n.renderId===t)return n.lightsData}let n=this.getLightsData(e.getLights());return da.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.getLights(e.lightsNode,n);return this.equals(e,a)!==!0}},pa=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function ma(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
277
|
+
`).map(e=>{let n=e.match(t);if(!n)return null;let r=n[1]||n[2]||``,i=n[3].split(`?`)[0],a=parseInt(n[4],10),o=parseInt(n[5],10);return{fn:r,file:i.split(`/`).pop(),line:a,column:o}}).filter(e=>e&&!pa.some(t=>t.test(e.file)))}var ha=class{constructor(e=null){this.isStackTrace=!0,this.stack=ma(e||Error().stack)}getLocation(){if(this.stack.length===0)return`[Unknown location]`;let e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:``}"${e.file}:${e.line}"`}getError(e){return this.stack.length===0?e:`${e}\n${this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join(`
|
|
278
|
+
`)}`}};function ga(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}var _a=e=>ga(e),va=e=>ga(e),ya=(...e)=>ga(e),ba=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),xa=new WeakMap;function Sa(e){return ba.get(e)}function Ca(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function wa(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;E(`TSL: Unsupported type: ${e}`,new ha)}function Ta(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;E(`TSL: Unsupported type: ${e}`,new ha)}function Ea(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e)||/mat4/.test(e))return 16;E(`TSL: Unsupported type: ${e}`,new ha)}function Da(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function Oa(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new on(...t):n===`vec2`?new it(...t):n===`vec3`?new O(...t):n===`vec4`?new wt(...t):n===`mat2`?new ta(...t):n===`mat3`?new ct(...t):n===`mat4`?new k(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?ja(t[0]):null}function ka(e){let t=xa.get(e);return t===void 0&&(t={},xa.set(e,t)),t}function Aa(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function ja(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Ma={VERTEX:`vertex`,FRAGMENT:`fragment`},A={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},Na={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},Pa={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},Fa=[`fragment`,`vertex`],Ia=[`setup`,`analyze`,`generate`],La=[...Fa,`compute`],Ra=[`x`,`y`,`z`,`w`],za={analyze:`setup`,generate:`analyze`},Ba=0,j=class e extends je{static get type(){return`Node`}constructor(t=null){super(),this.nodeType=t,this.updateType=A.NONE,this.updateBeforeType=A.NONE,this.updateAfterType=A.NONE,this.uuid=rt.generateUUID(),this.version=0,this.name=``,this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ba++}),this.stackTrace=null,e.captureStackTrace===!0&&(this.stackTrace=new ha)}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,A.FRAME)}onRenderUpdate(e){return this.onUpdate(e,A.RENDER)}onObjectUpdate(e){return this.onUpdate(e,A.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){let t=[];e.add(this);for(let n of Object.getOwnPropertyNames(this)){let r=this[n];if(!(n.startsWith(`_`)===!0||e.has(r))){if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let e in r){if(e.startsWith(`_`)===!0)continue;let i=r[e];i&&i.isNode===!0&&t.push({property:n,index:e,childNode:i})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);let n=[];for(let{property:r,childNode:i}of this._getChildren(t))n.push(_a(r.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=ya(va(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){T(`Abstract function.`)}updateAfter(){T(`Abstract function.`)}update(){T(`Abstract function.`)}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){let n=this._beforeNodes;this._beforeNodes=null;for(let r of n)r.build(e,t);this._beforeNodes=n}let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=za[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){e.addNode(this),this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}e.addSequentialNode(this)}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){if(this.generate.length<2){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(T(`Node: Recursion detected.`,this),a=`/* Recursion detected. */`):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``;a===``&&t!==null&&t!==`void`&&t!==`OutputType`&&(E(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n])r[i]=t[e.inputNodes[n][i]];this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}};j.captureStackTrace=!1;var Va=class extends j{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){let t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`)} ]`}},Ha=class extends j{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},Ua=class extends j{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},Wa=class extends Ua{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){E(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;if(s+c>r&&(E(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i),e.getComponentType(i)!==a){let t=e.getTypeFromLength(c,a);l=e.format(l,i,t)}o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},Ga=Ra.join(``),Ka=class extends j{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Ra.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=n.build(e,a);i=this.components.length===r&&this.components===Ga.slice(0,this.components.length)?e.format(o,a,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},qa=class extends Ua{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Ra[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Ja=class extends Ua{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Ra[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Ya=class extends j{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Da(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Da(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=Aa(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Oa(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){T(`Abstract function.`)}},Xa=/float|u?int/,Za=class extends Ya{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return Xa.test(n)&&Xa.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Qa=class extends j{static get type(){return`MemberNode`}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!==`void`}getNodeType(e){return this.hasMember(e)===!1?`float`:this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return`float`;let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){T(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+`.`+this.property}},$a=null,eo=new Map;function M(e,t){if(eo.has(e)){T(`TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);eo.set(e,t),e!==`assign`&&(j.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},j.prototype[e+`Assign`]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}var to=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),no=e=>to(e).split(``).sort().join(``);j.prototype.assign=function(...e){if(this.isStackNode!==!0)return $a===null?E(`TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().`,new ha):$a.assign(this,...e),this;{let t=eo.get(`assign`);return this.addToStack(t(...e))}},j.prototype.toVarIntent=function(){return this},j.prototype.get=function(e){return new Qa(this,e)};var ro={};function io(e,t,n){ro[e]=ro[t]=ro[n]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Ka(this,e),this._cache[e]=t),t},set(t){this[e].assign(N(t))}};let r=e.toUpperCase(),i=t.toUpperCase(),a=n.toUpperCase();j.prototype[`set`+r]=j.prototype[`set`+i]=j.prototype[`set`+a]=function(t){let n=no(e);return new qa(this,n,N(t))},j.prototype[`flip`+r]=j.prototype[`flip`+i]=j.prototype[`flip`+a]=function(){let t=no(e);return new Ja(this,t)}}var ao=[`x`,`y`,`z`,`w`],oo=[`r`,`g`,`b`,`a`],so=[`s`,`t`,`p`,`q`];for(let e=0;e<4;e++){let t=ao[e],n=oo[e],r=so[e];io(t,n,r);for(let i=0;i<4;i++){t=ao[e]+ao[i],n=oo[e]+oo[i],r=so[e]+so[i],io(t,n,r);for(let a=0;a<4;a++){t=ao[e]+ao[i]+ao[a],n=oo[e]+oo[i]+oo[a],r=so[e]+so[i]+so[a],io(t,n,r);for(let o=0;o<4;o++)t=ao[e]+ao[i]+ao[a]+ao[o],n=oo[e]+oo[i]+oo[a]+oo[o],r=so[e]+so[i]+so[a]+so[o],io(t,n,r)}}}for(let e=0;e<32;e++)ro[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return t===void 0&&(t=new Va(this,new Za(e,`uint`)),this._cache[e]=t),t},set(t){this[e].assign(N(t))}};Object.defineProperties(j.prototype,ro);var co=new WeakMap,lo=function(e,t=null){let n=Da(e);return n===`node`?e:t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`?N(ko(e,t)):n===`shader`?e.isFn?e:L(e):e},uo=function(e,t=null){for(let n in e)e[n]=N(e[n],t);return e},fo=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=N(e[r],t);return e},po=function(e,t=null,n=null,r=null){function i(e){return r===null?e=N(e):(e=N(Object.assign(e,r)),r.intent===!0&&(e=e.toVarIntent())),e}let a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(E(`TSL: "${n}" parameter length is less than minimum required.`,new ha),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(E(`TSL: "${n}" parameter length exceeds limit.`,new ha),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...Io(l(t)))):n===null?a=(...n)=>i(new e(t,...Io(l(n)))):(n=N(n),a=(...r)=>i(new e(t,...Io(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},mo=function(e,...t){return new e(...Io(t))},ho=class extends j{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||``,a=i||`default`;if(r[a])return r[a];let o=e.subBuildFn,s=e.fnCall;e.subBuildFn=i,e.fnCall=this;let c=null;if(t.layout){let r=co.get(e.constructor);r===void 0&&(r=new WeakMap,co.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=N(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i);let a=n?go(n):null;c=N(i.call(a))}else{let r=new Proxy(e,{get:(e,t,n)=>{let r;return r=Symbol.iterator===t?function*(){yield void 0}:Reflect.get(e,t,n),r}}),i=n?_o(n):null,a=Array.isArray(n)?n.length>0:n!==null,o=t.jsFunc;c=N(a||o.length>1?o(i,r):o(r))}return e.subBuildFn=o,e.fnCall=s,t.once&&(r[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),s=e.fnCall;if(e.fnCall=this,r===`setup`){let t=e.getSubBuildProperty(`initialized`,this);if(i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let n=e.getDataFromNode(t,`any`);n.subBuilds=n.subBuilds||new Set;for(let e of this.shaderNode.subBuilds)n.subBuilds.add(e)}n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return e.fnCall=s,n}};function go(e){let t;return Fo(e),t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0],t}function _o(e){let t=0;return Fo(e),new Proxy(e,{get:(n,r,i)=>{let a;if(r===`length`)return a=e.length,a;if(Symbol.iterator===r)a=function*(){for(let t of e)yield N(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){let n=e[0];a=n[r]===void 0?n[t++]:Reflect.get(n,r,i)}else e[0]instanceof j&&(a=e[r]===void 0?e[t++]:Reflect.get(e,r,i));else a=Reflect.get(n,r,i);a=N(a)}return a}})}var vo=class extends j{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new ho(this,e)}setup(){return this.call()}},yo=[!1,!0],bo=[0,1,2,3],xo=[-1,-2],So=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Co=new Map;for(let e of yo)Co.set(e,new Za(e));var wo=new Map;for(let e of bo)wo.set(e,new Za(e,`uint`));var To=new Map([...wo].map(e=>new Za(e.value,`int`)));for(let e of xo)To.set(e,new Za(e,`int`));var Eo=new Map([...To].map(e=>new Za(e.value)));for(let e of So)Eo.set(e,new Za(e));for(let e of So)Eo.set(-e,new Za(-e));var Do={bool:Co,uint:wo,ints:To,float:Eo},Oo=new Map([...Co,...Eo]),ko=(e,t)=>Oo.has(e)?Oo.get(e):e.isNode===!0?e:new Za(e,t),Ao=function(e,t=null){return(...n)=>{for(let t of n)if(t===void 0)return E(`TSL: Invalid parameter for the type "${e}".`,new ha),new Za(0,e);if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>{let t=typeof e;return t!==`object`&&t!==`function`}))&&(n=[Oa(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return Po(t.get(n[0]));if(n.length===1){let t=ko(n[0],e);return t.nodeType===e?Po(t):Po(new Ha(t,e))}return Po(new Wa(n.map(e=>ko(e)),e))}},jo=e=>typeof e==`object`&&e?e.value:e,Mo=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function No(e,t){return new vo(e,t)}var N=(e,t=null)=>lo(e,t),Po=(e,t=null)=>N(e,t).toVarIntent(),Fo=(e,t=null)=>new uo(e,t),Io=(e,t=null)=>new fo(e,t),P=(e,t=null,n=null,r=null)=>new po(e,t,n,r),F=(e,...t)=>new mo(e,...t),I=(e,t=null,n=null,r={})=>new po(e,t,n,m(m({},r),{},{intent:!0})),Lo=0,Ro=class extends j{constructor(e,t=null){super();let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:E(`TSL: Invalid layout type.`,new ha),t=null)),this.shaderNode=new No(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if(typeof e.inputs!=`object`){let n={name:`fn`+Lo++,type:t,inputs:[]};for(let t in e)t!==`return`&&n.inputs.push({name:t,type:e[t]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||`float`}call(...e){let t=this.shaderNode.call(e);return this.shaderNode.nodeType===`void`&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return E(`TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".`,this.stackTrace),e.generateConst(t)}};function L(e,t=null){let n=new Ro(e,t);return new Proxy(()=>{},{apply(e,t,r){return n.call(...r)},get(e,t,r){return Reflect.get(n,t,r)},set(e,t,r,i){return Reflect.set(n,t,r,i)}})}var zo=e=>{$a=e},Bo=()=>$a,R=(...e)=>$a.If(...e),Vo=(...e)=>$a.Switch(...e);function Ho(e){return $a&&$a.addToStack(e),e}M(`toStack`,Ho);var Uo=new Ao(`color`),z=new Ao(`float`,Do.float),B=new Ao(`int`,Do.ints),V=new Ao(`uint`,Do.uint),Wo=new Ao(`bool`,Do.bool),H=new Ao(`vec2`),Go=new Ao(`ivec2`),Ko=new Ao(`uvec2`),qo=new Ao(`bvec2`),U=new Ao(`vec3`),Jo=new Ao(`ivec3`),Yo=new Ao(`uvec3`),Xo=new Ao(`bvec3`),W=new Ao(`vec4`),Zo=new Ao(`ivec4`),Qo=new Ao(`uvec4`),$o=new Ao(`bvec4`),es=new Ao(`mat2`),ts=new Ao(`mat3`),ns=new Ao(`mat4`),rs=(e=``)=>new Za(e,`string`),is=e=>new Za(e,`ArrayBuffer`);M(`toColor`,Uo),M(`toFloat`,z),M(`toInt`,B),M(`toUint`,V),M(`toBool`,Wo),M(`toVec2`,H),M(`toIVec2`,Go),M(`toUVec2`,Ko),M(`toBVec2`,qo),M(`toVec3`,U),M(`toIVec3`,Jo),M(`toUVec3`,Yo),M(`toBVec3`,Xo),M(`toVec4`,W),M(`toIVec4`,Zo),M(`toUVec4`,Qo),M(`toBVec4`,$o),M(`toMat2`,es),M(`toMat3`,ts),M(`toMat4`,ns);var as=P(Va).setParameterLength(2),os=(e,t)=>new Ha(N(e),t),ss=(e,t)=>new Ka(N(e),t);M(`element`,as),M(`convert`,os);var cs=e=>(T(`TSL: append() has been renamed to Stack().`,new ha),Ho(e));M(`append`,e=>(T(`TSL: .append() has been renamed to .toStack().`,new ha),Ho(e)));var ls=class extends j{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return _a(this.type+`:`+(this.name||``)+`:`+(this.varying?`1`:`0`))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}},us=(e,t)=>new ls(e,t),ds=(e,t)=>new ls(e,t,!0),fs=F(ls,`vec4`,`DiffuseColor`),ps=F(ls,`vec3`,`DiffuseContribution`),ms=F(ls,`vec3`,`EmissiveColor`),hs=F(ls,`float`,`Roughness`),gs=F(ls,`float`,`Metalness`),_s=F(ls,`float`,`Clearcoat`),vs=F(ls,`float`,`ClearcoatRoughness`),ys=F(ls,`vec3`,`Sheen`),bs=F(ls,`float`,`SheenRoughness`),xs=F(ls,`float`,`Iridescence`),Ss=F(ls,`float`,`IridescenceIOR`),Cs=F(ls,`float`,`IridescenceThickness`),ws=F(ls,`float`,`AlphaT`),Ts=F(ls,`float`,`Anisotropy`),Es=F(ls,`vec3`,`AnisotropyT`),Ds=F(ls,`vec3`,`AnisotropyB`),Os=F(ls,`color`,`SpecularColor`),ks=F(ls,`color`,`SpecularColorBlended`),As=F(ls,`float`,`SpecularF90`),js=F(ls,`float`,`Shininess`),Ms=F(ls,`vec4`,`Output`),Ns=F(ls,`float`,`dashSize`),Ps=F(ls,`float`,`gapSize`),Fs=F(ls,`float`,`pointWidth`),Is=F(ls,`float`,`IOR`),Ls=F(ls,`float`,`Transmission`),Rs=F(ls,`float`,`Thickness`),zs=F(ls,`float`,`AttenuationDistance`),Bs=F(ls,`color`,`AttenuationColor`),Vs=F(ls,`float`,`Dispersion`),Hs=class extends j{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}},Us=e=>new Hs(e),Ws=(e,t=0)=>new Hs(e,!0,t),Gs=Ws(`frame`),G=Ws(`render`),Ks=Us(`object`),qs=class extends Ya{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=Ks}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new ha),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let n=e(t,this);n!==void 0&&(this.value=n)},t)}getInputType(e){let t=super.getInputType(e);return t===`bool`&&(t=`uint`),t}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.nodeName),s=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=s;if(n===`bool`){let t=e.getDataFromNode(this),r=t.propertyName;if(r===void 0){let i=e.getVarFromNode(this,null,`bool`);r=e.getPropertyName(i),t.propertyName=r,c=e.format(s,a,n),e.addLineFlowCode(`${r} = ${c}`,this)}c=r}return e.format(c,n,t)}},K=(e,t)=>{let n=Mo(t||e);if(n===e&&(e=Oa(n)),e&&e.isNode===!0){let t=e.value;e.traverse(e=>{e.isConstNode===!0&&(t=e.value)}),e=t}return new qs(e,n)},Js=class extends Ua{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}},Ys=(...e)=>{let t;if(e.length===1){let n=e[0];t=new Js(null,n.length,n)}else{let n=e[0],r=e[1];t=new Js(n,r)}return N(t)};M(`toArray`,(e,t)=>Ys(Array(t).fill(e)));var Xs=P(class extends Ua{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e));return Ra.join(``).slice(0,n)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=t.getScope(),i=e.getDataFromNode(r);i.assign=!0;let a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.build(e),o=n.getNodeType(e),s=r.build(e,o),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=a);else if(i){let r=e.getVarFromNode(this,null,o),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}).build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${l}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=a)}else u=`${a} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=a));return l.initialized=!0,e.format(u,o,t)}}).setParameterLength(2);M(`assign`,Xs);var Zs=class extends Ua{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)E(`TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(E(`TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(z(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(E(`TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(z(0),e))):t.push(a(n,e))}return`${n.build(e,`property`)}( ${t.join(`, `)} )`}},Qs=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Io(t):Fo(t[0]),new Zs(N(e),t));M(`call`,Qs);var $s={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`},ec=class e extends Ua{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod($s[this.op],t)}getNodeType(e,t=null){let n=this.op,r=this.aNode,i=this.bNode,a=r.getNodeType(e),o=i?i.getNodeType(e):null;if(a===`void`||o===`void`)return t||`void`;if(n===`%`)return a;if(n===`~`||n===`&`||n===`|`||n===`^`||n===`>>`||n===`<<`)return e.getIntegerType(a);if(n===`!`||n===`&&`||n===`||`||n===`^^`)return`bool`;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`){let t=Math.max(e.getTypeLength(a),e.getTypeLength(o));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(a)){if(o===`float`)return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a===`float`)return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e,t),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===be;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}},tc=I(ec,`+`).setParameterLength(2,1/0).setName(`add`),q=I(ec,`-`).setParameterLength(2,1/0).setName(`sub`),J=I(ec,`*`).setParameterLength(2,1/0).setName(`mul`),nc=I(ec,`/`).setParameterLength(2,1/0).setName(`div`),rc=I(ec,`%`).setParameterLength(2).setName(`mod`),ic=I(ec,`==`).setParameterLength(2).setName(`equal`),ac=I(ec,`!=`).setParameterLength(2).setName(`notEqual`),oc=I(ec,`<`).setParameterLength(2).setName(`lessThan`),sc=I(ec,`>`).setParameterLength(2).setName(`greaterThan`),cc=I(ec,`<=`).setParameterLength(2).setName(`lessThanEqual`),lc=I(ec,`>=`).setParameterLength(2).setName(`greaterThanEqual`),uc=I(ec,`&&`).setParameterLength(2,1/0).setName(`and`),dc=I(ec,`||`).setParameterLength(2,1/0).setName(`or`),fc=I(ec,`!`).setParameterLength(1).setName(`not`),pc=I(ec,`^^`).setParameterLength(2).setName(`xor`),mc=I(ec,`&`).setParameterLength(2).setName(`bitAnd`),hc=I(ec,`~`).setParameterLength(1).setName(`bitNot`),gc=I(ec,`|`).setParameterLength(2).setName(`bitOr`),_c=I(ec,`^`).setParameterLength(2).setName(`bitXor`),vc=I(ec,`<<`).setParameterLength(2).setName(`shiftLeft`),yc=I(ec,`>>`).setParameterLength(2).setName(`shiftRight`),bc=L(([e])=>(e.addAssign(1),e)),xc=L(([e])=>(e.subAssign(1),e)),Sc=L(([e])=>{let t=B(e).toConst();return e.addAssign(1),t}),Cc=L(([e])=>{let t=B(e).toConst();return e.subAssign(1),t});M(`add`,tc),M(`sub`,q),M(`mul`,J),M(`div`,nc),M(`mod`,rc),M(`equal`,ic),M(`notEqual`,ac),M(`lessThan`,oc),M(`greaterThan`,sc),M(`lessThanEqual`,cc),M(`greaterThanEqual`,lc),M(`and`,uc),M(`or`,dc),M(`not`,fc),M(`xor`,pc),M(`bitAnd`,mc),M(`bitNot`,hc),M(`bitOr`,gc),M(`bitXor`,_c),M(`shiftLeft`,vc),M(`shiftRight`,yc),M(`incrementBefore`,bc),M(`decrementBefore`,xc),M(`increment`,Sc),M(`decrement`,Cc);var wc=(e,t)=>(T(`TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`,new ha),rc(B(e),B(t)));M(`modInt`,wc);var Y=class e extends Ua{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=q(1,n);else if(i===e.RECIPROCAL)a=nc(1,n);else if(i===e.DIFFERENCE)a=Zc(q(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=W(U(i),0):e=W(U(e),0);let o=J(e,i).xyz;a=Uc(o)}return a===null?super.setup(t):a}generate(t,n){if(t.getNodeProperties(this).outputNode)return super.generate(t,n);let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=this.cNode,l=t.renderer.coordinateSystem;if(r===e.NEGATE)return t.format(`( - `+o.build(t,a)+` )`,i,n);{let u=[];return r===e.CROSS?u.push(o.build(t,i),s.build(t,i)):l===2e3&&r===e.STEP?u.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?`float`:a),s.build(t,a)):l===2e3&&(r===e.MIN||r===e.MAX)?u.push(o.build(t,a),s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:a)):r===e.REFRACT?u.push(o.build(t,a),s.build(t,a),c.build(t,`float`)):r===e.MIX?u.push(o.build(t,a),s.build(t,a),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:a)):(l===2001&&r===e.ATAN&&s!==null&&(r=`atan2`),t.shaderStage!==`fragment`&&(r===e.DFDX||r===e.DFDY)&&(T(`TSL: '${r}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),r=`/*`+r+`*/`),u.push(o.build(t,a)),s!==null&&u.push(s.build(t,a)),c!==null&&u.push(c.build(t,a))),t.format(`${t.getMethod(r,i)}( ${u.join(`, `)} )`,i,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Y.ALL=`all`,Y.ANY=`any`,Y.RADIANS=`radians`,Y.DEGREES=`degrees`,Y.EXP=`exp`,Y.EXP2=`exp2`,Y.LOG=`log`,Y.LOG2=`log2`,Y.SQRT=`sqrt`,Y.INVERSE_SQRT=`inversesqrt`,Y.FLOOR=`floor`,Y.CEIL=`ceil`,Y.NORMALIZE=`normalize`,Y.FRACT=`fract`,Y.SIN=`sin`,Y.COS=`cos`,Y.TAN=`tan`,Y.ASIN=`asin`,Y.ACOS=`acos`,Y.ATAN=`atan`,Y.ABS=`abs`,Y.SIGN=`sign`,Y.LENGTH=`length`,Y.NEGATE=`negate`,Y.ONE_MINUS=`oneMinus`,Y.DFDX=`dFdx`,Y.DFDY=`dFdy`,Y.ROUND=`round`,Y.RECIPROCAL=`reciprocal`,Y.TRUNC=`trunc`,Y.FWIDTH=`fwidth`,Y.TRANSPOSE=`transpose`,Y.DETERMINANT=`determinant`,Y.INVERSE=`inverse`,Y.EQUALS=`equals`,Y.MIN=`min`,Y.MAX=`max`,Y.STEP=`step`,Y.REFLECT=`reflect`,Y.DISTANCE=`distance`,Y.DIFFERENCE=`difference`,Y.DOT=`dot`,Y.CROSS=`cross`,Y.POW=`pow`,Y.TRANSFORM_DIRECTION=`transformDirection`,Y.MIX=`mix`,Y.CLAMP=`clamp`,Y.REFRACT=`refract`,Y.SMOOTHSTEP=`smoothstep`,Y.FACEFORWARD=`faceforward`;var Tc=z(1e-6),Ec=z(1e6),Dc=z(Math.PI),Oc=z(Math.PI*2),kc=z(Math.PI*2),Ac=z(Math.PI*.5),jc=I(Y,Y.ALL).setParameterLength(1),Mc=I(Y,Y.ANY).setParameterLength(1),Nc=I(Y,Y.RADIANS).setParameterLength(1),Pc=I(Y,Y.DEGREES).setParameterLength(1),Fc=I(Y,Y.EXP).setParameterLength(1),Ic=I(Y,Y.EXP2).setParameterLength(1),Lc=I(Y,Y.LOG).setParameterLength(1),Rc=I(Y,Y.LOG2).setParameterLength(1),zc=I(Y,Y.SQRT).setParameterLength(1),Bc=I(Y,Y.INVERSE_SQRT).setParameterLength(1),Vc=I(Y,Y.FLOOR).setParameterLength(1),Hc=I(Y,Y.CEIL).setParameterLength(1),Uc=I(Y,Y.NORMALIZE).setParameterLength(1),Wc=I(Y,Y.FRACT).setParameterLength(1),Gc=I(Y,Y.SIN).setParameterLength(1),Kc=I(Y,Y.COS).setParameterLength(1),qc=I(Y,Y.TAN).setParameterLength(1),Jc=I(Y,Y.ASIN).setParameterLength(1),Yc=I(Y,Y.ACOS).setParameterLength(1),Xc=I(Y,Y.ATAN).setParameterLength(1,2),Zc=I(Y,Y.ABS).setParameterLength(1),Qc=I(Y,Y.SIGN).setParameterLength(1),$c=I(Y,Y.LENGTH).setParameterLength(1),el=I(Y,Y.NEGATE).setParameterLength(1),tl=I(Y,Y.ONE_MINUS).setParameterLength(1),nl=I(Y,Y.DFDX).setParameterLength(1),rl=I(Y,Y.DFDY).setParameterLength(1),il=I(Y,Y.ROUND).setParameterLength(1),al=I(Y,Y.RECIPROCAL).setParameterLength(1),ol=I(Y,Y.TRUNC).setParameterLength(1),sl=I(Y,Y.FWIDTH).setParameterLength(1),cl=I(Y,Y.TRANSPOSE).setParameterLength(1),ll=I(Y,Y.DETERMINANT).setParameterLength(1),ul=I(Y,Y.INVERSE).setParameterLength(1),dl=I(Y,Y.MIN).setParameterLength(2,1/0),fl=I(Y,Y.MAX).setParameterLength(2,1/0),pl=I(Y,Y.STEP).setParameterLength(2),ml=I(Y,Y.REFLECT).setParameterLength(2),hl=I(Y,Y.DISTANCE).setParameterLength(2),gl=I(Y,Y.DIFFERENCE).setParameterLength(2),_l=I(Y,Y.DOT).setParameterLength(2),vl=I(Y,Y.CROSS).setParameterLength(2),yl=I(Y,Y.POW).setParameterLength(2),bl=e=>J(e,e),xl=e=>J(e,e,e),Sl=e=>J(e,e,e,e),Cl=I(Y,Y.TRANSFORM_DIRECTION).setParameterLength(2),wl=e=>J(Qc(e),yl(Zc(e),1/3)),Tl=e=>_l(e,e),El=I(Y,Y.MIX).setParameterLength(3),Dl=(e,t=0,n=1)=>new Y(Y.CLAMP,N(e),N(t),N(n)),Ol=e=>Dl(e),kl=I(Y,Y.REFRACT).setParameterLength(3),Al=I(Y,Y.SMOOTHSTEP).setParameterLength(3),jl=I(Y,Y.FACEFORWARD).setParameterLength(3),Ml=L(([e])=>Wc(Gc(rc(_l(e.xy,H(12.9898,78.233)),Dc)).mul(43758.5453))),Nl=(e,t,n)=>El(t,n,e),Pl=(e,t,n)=>Al(t,n,e),Fl=(e,t)=>pl(t,e),Il=jl,Ll=Bc;M(`all`,jc),M(`any`,Mc),M(`radians`,Nc),M(`degrees`,Pc),M(`exp`,Fc),M(`exp2`,Ic),M(`log`,Lc),M(`log2`,Rc),M(`sqrt`,zc),M(`inverseSqrt`,Bc),M(`floor`,Vc),M(`ceil`,Hc),M(`normalize`,Uc),M(`fract`,Wc),M(`sin`,Gc),M(`cos`,Kc),M(`tan`,qc),M(`asin`,Jc),M(`acos`,Yc),M(`atan`,Xc),M(`abs`,Zc),M(`sign`,Qc),M(`length`,$c),M(`lengthSq`,Tl),M(`negate`,el),M(`oneMinus`,tl),M(`dFdx`,nl),M(`dFdy`,rl),M(`round`,il),M(`reciprocal`,al),M(`trunc`,ol),M(`fwidth`,sl),M(`min`,dl),M(`max`,fl),M(`step`,Fl),M(`reflect`,ml),M(`distance`,hl),M(`dot`,_l),M(`cross`,vl),M(`pow`,yl),M(`pow2`,bl),M(`pow3`,xl),M(`pow4`,Sl),M(`transformDirection`,Cl),M(`mix`,Nl),M(`clamp`,Dl),M(`refract`,kl),M(`smoothstep`,Pl),M(`faceForward`,jl),M(`difference`,gl),M(`saturate`,Ol),M(`cbrt`,wl),M(`transpose`,cl),M(`determinant`,ll),M(`inverse`,ul),M(`rand`,Ml);var Rl=P(class extends j{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,`setup`),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?n:n.context({nodeBlock:n}),o.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?us(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);if(e.context.uniformFlow&&o!==null){let r=a.build(e,n),i=o.build(e,n),s=e.getTernary(u,r,i);return e.format(s,n,t)}e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(T(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
279
|
+
|
|
280
|
+
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
281
|
+
|
|
282
|
+
`).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(T(`TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`,this.stackTrace),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+`
|
|
283
|
+
|
|
284
|
+
`+e.tab+`}
|
|
285
|
+
|
|
286
|
+
`)}else e.addFlowCode(`
|
|
287
|
+
|
|
288
|
+
`);return e.format(l,n,t)}}).setParameterLength(2,3);M(`select`,Rl);var zl=class extends j{static get type(){return`ContextNode`}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}},Bl=(e=null,t={})=>{let n=e;return(n===null||n.isNode!==!0)&&(t=n||t,n=null),new zl(n,t)},Vl=e=>Bl(e,{uniformFlow:!0}),Hl=(e,t)=>Bl(e,{nodeName:t});function Ul(e,t,n=null){return Bl(n,{getShadow:({light:n,shadowColorNode:r})=>t===n?r.mul(e):r})}function Wl(e,t=null){return Bl(t,{getAO:(t,{material:n})=>n.transparent===!0?t:t===null?e:t.mul(e)})}function Gl(e,t){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`),Hl(e,t)}M(`context`,Bl),M(`label`,Gl),M(`uniformFlow`,Vl),M(`setName`,Hl),M(`builtinShadowContext`,(e,t,n)=>Ul(t,n,e)),M(`builtinAOContext`,(e,t)=>Wl(t,e));var Kl=P(class extends j{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0];if(this._hasStack(t)===!1&&t.buildStage===`setup`&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){let n=t.getDataFromNode(this);n.forceDeclaration=!0,e=!0}let n=t.getBaseStack();e?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=this.getNodeType(e);if(c==`void`)return this.isIntent(e)!==!0&&E(`TSL: ".toVar()" can not be used with void type.`,this.stackTrace),t.build(e);let l=e.getVectorType(c),u=t.build(e,l),d=e.getVarFromNode(this,n,l,void 0,s),f=e.getPropertyName(d),p=f;if(s)if(a)p=o?`const ${f}`:`let ${f}`;else{let n=t.getArrayCount(e);p=`const ${e.getVar(d.type,f,n)}`}return e.addLineFlowCode(`${p} = ${u}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}),ql=(e,t=null)=>Kl(e,t).toStack(),Jl=(e,t=null)=>Kl(e,t,!0).toStack(),Yl=e=>Kl(e).setIntent(!0).toStack();M(`toVar`,ql),M(`toConst`,Jl),M(`toVarIntent`,Yl);var Xl=class extends j{static get type(){return`SubBuild`}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let n=this.node.build(e,...t);return e.removeSubBuild(),n}},Zl=(e,t,n=null)=>new Xl(N(e),t,n),Ql=P(class extends j{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=Zl(e,`VERTEX`),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=Zl(this.node,`VERTEX`)}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage===`fragment`),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ma.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ma.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty(`property`,e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){let i=this.getNodeType(e),a=e.getPropertyName(r,Ma.VERTEX);e.flowNodeFromShaderStage(Ma.VERTEX,n.node,i,a),n[t]=a}return e.getPropertyName(r)}}).setParameterLength(1,2),$l=e=>Ql(e);M(`toVarying`,Ql),M(`toVertexStage`,$l);var eu=L(([e])=>El(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),tu=L(([e])=>El(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),nu=`WorkingColorSpace`,ru=`OutputColorSpace`,iu=class extends Ua{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===nu?pt.workingColorSpace:t===ru?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return pt.enabled===!1||n===r||!n||!r?i:(pt.getTransfer(n)===`srgb`&&(i=W(eu(i.rgb),i.a)),pt.getPrimaries(n)!==pt.getPrimaries(r)&&(i=W(ts(pt._getMatrix(new ct,n,r)).mul(i.rgb),i.a)),pt.getTransfer(r)===`srgb`&&(i=W(tu(i.rgb),i.a)),i)}},au=(e,t)=>new iu(N(e),nu,t),ou=(e,t)=>new iu(N(e),t,nu),su=(e,t,n)=>new iu(N(e),t,n);M(`workingToColorSpace`,au),M(`colorSpaceToWorking`,ou);var cu=class extends Va{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},lu=class extends j{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=A.OBJECT}setGroup(e){return this.group=e,this}element(e){return new cu(this,N(e))}setNodeType(e){let t=K(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},uu=class extends lu{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(G)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}},du=(e,t,n=null)=>new uu(e,t,n),fu=class extends Ua{static get type(){return`ToneMappingNode`}constructor(e,t=mu,n=null){super(`vec3`),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return ya(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){let t=this.colorNode||e.context.color,n=this._toneMapping;if(n===0)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(E(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=W(i(t.rgb,this.exposureNode),t.a),r}},pu=(e,t,n)=>new fu(e,N(t),N(n)),mu=du(`toneMappingExposure`,`float`);M(`toneMapping`,(e,t,n)=>pu(t,n,e));var hu=new WeakMap;function gu(e,t){let n=hu.get(e);return n===void 0&&(n=new rr(e,t),hu.set(e,n)),n}var _u=class extends Ya{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=ve,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,i=this.bufferStride||n,a=this.bufferOffset,o;o=r.isInterleavedBuffer===!0?r:r.isBufferAttribute===!0?gu(r.array,i):gu(r,i);let s=new ar(o,n,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;return e.shaderStage===`vertex`||e.shaderStage===`compute`?(this.name=r,i=r):i=Ql(this).build(e,t),i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};function vu(e,t=null,n=0,r=0,i=ve,a=!1){return t===`mat3`||t===null&&e.itemSize===9?ts(new _u(e,`vec3`,9,0).setUsage(i).setInstanced(a),new _u(e,`vec3`,9,3).setUsage(i).setInstanced(a),new _u(e,`vec3`,9,6).setUsage(i).setInstanced(a)):t===`mat4`||t===null&&e.itemSize===16?ns(new _u(e,`vec4`,16,0).setUsage(i).setInstanced(a),new _u(e,`vec4`,16,4).setUsage(i).setInstanced(a),new _u(e,`vec4`,16,8).setUsage(i).setInstanced(a),new _u(e,`vec4`,16,12).setUsage(i).setInstanced(a)):new _u(e,t,n,r).setUsage(i)}var yu=(e,t=null,n=0,r=0)=>vu(e,t,n,r),bu=(e,t=null,n=0,r=0)=>vu(e,t,n,r,ye),xu=(e,t=null,n=0,r=0)=>vu(e,t,n,r,ve,!0),Su=(e,t=null,n=0,r=0)=>vu(e,t,n,r,ye,!0);M(`toAttribute`,e=>yu(e.value));var Cu=class extends j{static get type(){return`ComputeNode`}constructor(e,t){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name=``,this.updateBeforeType=A.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:`dispose`})}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new ha),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}},wu=(e,t=[64])=>{(t.length===0||t.length>3)&&E(`TSL: compute() workgroupSize must have 1, 2, or 3 elements`,new ha);for(let e=0;e<t.length;e++){let n=t[e];(typeof n!=`number`||n<=0||!Number.isInteger(n))&&E(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new ha)}for(;t.length<3;)t.push(1);return new Cu(N(e),t)},Tu=(e,t,n)=>wu(e,n).setCount(t);M(`compute`,Tu),M(`computeKernel`,wu);var Eu=class extends j{static get type(){return`IsolateNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}},Du=e=>new Eu(N(e));function Ou(e,t=!0){return T(`TSL: "cache()" has been deprecated. Use "isolate()" instead.`),Du(e).setParent(t)}M(`cache`,Ou),M(`isolate`,Du);var ku=P(class extends j{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}).setParameterLength(2);M(`bypass`,ku);var Au=class extends j{static get type(){return`RemapNode`}constructor(e,t,n,r=z(0),i=z(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}},ju=P(Au,null,null,{doClamp:!1}).setParameterLength(3,5),Mu=P(Au).setParameterLength(3,5);M(`remap`,ju),M(`remapClamp`,Mu);var Nu=P(class extends j{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}}).setParameterLength(1,2),Pu=e=>(e?Rl(e,Nu(`discard`)):Nu(`discard`)).toStack(),Fu=()=>Nu(`return`).toStack();M(`discard`,Pu);var Iu=class extends Ua{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color,n=(this._toneMapping===null?e.toneMapping:this._toneMapping)||0,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||``;return n!==0&&(t=t.toneMapping(n)),r!==``&&r!==pt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}},Lu=(e,t=null,n=null)=>new Iu(N(e),t,n);M(`renderOutput`,Lu);var Ru=class extends Ua{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{let t=`--- TSL debug - `+e.shaderStage+` shader ---`,r=`-`.repeat(t.length),i=``;i+=`// #`+t+`#
|
|
289
|
+
`,i+=e.flow.code.replace(/^\t/gm,``)+`
|
|
290
|
+
`,i+=`/* ... */ `+n+` /* ... */
|
|
291
|
+
`,i+=`// #`+r+`#
|
|
292
|
+
`,Oe(i)}return n}},zu=(e,t=null)=>new Ru(N(e),t).toStack();M(`debug`,zu);var Bu=class{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}},Vu=class extends j{static get type(){return`InspectorNode`}constructor(e,t=``,n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=A.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==Bu&&Ae(`TSL: ".toInspector()" is only available with WebGPU.`),t}};function Hu(e,t=``,n=null){return e=N(e),e.before(new Vu(e,t,n))}M(`toInspector`,Hu);function Uu(e){T(`TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var Wu=class extends j{static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);return e.shaderStage===`vertex`?e.format(a.name,i,n):Ql(this).build(e,n)}else return T(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}},Gu=(e,t=null)=>new Wu(e,t),Ku=(e=0)=>Gu(`uv`+(e>0?e:``),`vec2`),qu=P(class extends j{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}}).setParameterLength(1,2),Ju=P(class extends qs{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=A.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}}).setParameterLength(1),Yu=class extends Error{constructor(e,t=null){super(e),this.name=`NodeError`,this.stackTrace=t}},Xu=new Ct,Zu=class extends qs{static get type(){return`TextureNode`}constructor(e=Xu,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=A.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===1014?`uvec4`:this.value.type===1013?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return Ku(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=K(this.value.matrix)),this._matrixUniform.mul(U(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=K(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(B(qu(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw new Yu("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let r=L(()=>{let t=this.uvNode;return(t===null||e.context.forceUVContext===!0)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),this.updateMatrix===!0&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?A.OBJECT:A.NONE,t})(),i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(Se.TEXTURE_COMPARE))a=this.compareNode;else{let e=n.compareFunction;e===null||e===513||e===515||e===516||e===518?o=this.compareNode:(a=this.compareNode,Ae(`TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.`))}t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateOffset(e,t){return t.build(e,`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value,u;return u=i?e.generateTextureBias(l,t,n,i,a,c):s?e.generateTextureGrad(l,t,n,s,a,c):o?e.generateTextureCompare(l,t,n,o,a,c):this.sampler===!1?e.generateTextureLoad(l,t,n,r,a,c):r?e.generateTextureLevel(l,t,n,r,a,c):e.generateTexture(l,t,n,a,c),u}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=this.getNodeType(e),s=a.propertyName;if(s===void 0){let{uvNode:t,levelNode:c,biasNode:l,compareNode:u,compareStepNode:d,depthNode:f,gradNode:p,offsetNode:m}=r,h=this.generateUV(e,t),g=c?c.build(e,`float`):null,_=l?l.build(e,`float`):null,v=f?f.build(e,`int`):null,y=u?u.build(e,`float`):null,b=d?d.build(e,`float`):null,x=p?[p[0].build(e,`vec2`),p[1].build(e,`vec2`)]:null,S=m?this.generateOffset(e,m):null,C=e.getVarFromNode(this);s=e.getPropertyName(C);let ee=this.generateSnippet(e,i,h,g,_,v,y,x,S);if(b!==null){let t=n.compareFunction;ee=t===516||t===518?pl(Nu(ee,o),Nu(b,`float`)).build(e,o):pl(Nu(b,`float`),Nu(ee,o)).build(e,o)}e.addLineFlowCode(`${s} = ${ee}`,this),a.snippet=ee,a.propertyName=s}let c=s;return e.needsToWorkingColorSpace(n)&&(c=ou(Nu(c,o),n.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=N(e),t.referenceNode=this.getBase(),N(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=N(e).mul(Ju(t)),t.referenceNode=this.getBase();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===1003||n.magFilter===1003)&&(T(`TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),N(t)}level(e){let t=this.clone();return t.levelNode=N(e),t.referenceNode=this.getBase(),N(t)}size(e){return qu(this,e)}bias(e){let t=this.clone();return t.biasNode=N(e),t.referenceNode=this.getBase(),N(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=N(e),t.referenceNode=this.getBase(),N(t)}grad(e,t){let n=this.clone();return n.gradNode=[N(e),N(t)],n.referenceNode=this.getBase(),N(n)}depth(e){let t=this.clone();return t.depthNode=N(e),t.referenceNode=this.getBase(),N(t)}offset(e){let t=this.clone();return t.offsetNode=N(e),t.referenceNode=this.getBase(),N(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();let n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},Qu=P(Zu).setParameterLength(1,4).setName(`texture`),$u=(e=Xu,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=N(e.clone()),i.referenceNode=e.getBase(),t!==null&&(i.uvNode=N(t)),n!==null&&(i.levelNode=N(n)),r!==null&&(i.biasNode=N(r))):i=Qu(e,t,n,r),i},ed=(e=Xu)=>$u(e),td=(...e)=>$u(...e).setSampler(!1),nd=(e,t,n)=>$u(e,t).level(n),rd=e=>(e.isNode===!0?e:$u(e)).convert(`sampler`),id=e=>(e.isNode===!0?e:$u(e)).convert(`samplerComparison`),ad=class extends qs{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}},od=(e,t,n)=>new ad(e,t,n),sd=class extends Va{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},cd=class extends ad{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Da(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=A.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,this.update(),super.setup(e)}element(e){return new sd(this,N(e))}},ld=(e,t)=>new cd(e,t),ud=P(class extends j{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),dd,fd,pd=class e extends j{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===e.DPR?`float`:this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=A.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT||this.scope===e.DPR)&&(t=A.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(fd),fd.multiplyScalar(t.getPixelRatio())):fd.copy(n.viewport):this.scope===e.DPR?this._output.value=t.getPixelRatio():n===null?t.getDrawingBufferSize(dd):(dd.width=n.width,dd.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?K(dd||(dd=new it)):t===e.VIEWPORT?K(fd||(fd=new wt)):t===e.DPR?K(1):H(_d.div(gd)),this._output=n,n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(gd).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};pd.COORDINATE=`coordinate`,pd.VIEWPORT=`viewport`,pd.SIZE=`size`,pd.UV=`uv`,pd.DPR=`dpr`;var md=F(pd,pd.DPR),hd=F(pd,pd.UV),gd=F(pd,pd.SIZE),_d=F(pd,pd.COORDINATE),vd=F(pd,pd.VIEWPORT),yd=vd.zw,bd=_d.sub(vd.xy),xd=bd.div(yd),Sd=L(()=>(T(`TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`,new ha),gd),`vec2`).once()(),Cd=null,wd=null,Td=null,Ed=null,Dd=null,Od=null,kd=null,Ad=null,jd=null,Md=null,Nd=null,Pd=null,Fd=null,Id=null,Ld=K(0,`uint`).setName(`u_cameraIndex`).setGroup(Ws(`cameraIndex`)).toVarying(`v_cameraIndex`),Rd=K(`float`).setName(`cameraNear`).setGroup(G).onRenderUpdate(({camera:e})=>e.near),zd=K(`float`).setName(`cameraFar`).setGroup(G).onRenderUpdate(({camera:e})=>e.far),Bd=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);wd===null?wd=ld(n).setGroup(G).setName(`cameraProjectionMatrices`):wd.array=n,t=wd.element(e.isMultiViewCamera?ud(`gl_ViewID_OVR`):Ld).toConst(`cameraProjectionMatrix`)}else Cd===null&&(Cd=K(e.projectionMatrix).setName(`cameraProjectionMatrix`).setGroup(G).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Cd;return t}).once()(),Vd=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);Ed===null?Ed=ld(n).setGroup(G).setName(`cameraProjectionMatricesInverse`):Ed.array=n,t=Ed.element(e.isMultiViewCamera?ud(`gl_ViewID_OVR`):Ld).toConst(`cameraProjectionMatrixInverse`)}else Td===null&&(Td=K(e.projectionMatrixInverse).setName(`cameraProjectionMatrixInverse`).setGroup(G).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=Td;return t}).once()(),Hd=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);Od===null?Od=ld(n).setGroup(G).setName(`cameraViewMatrices`):Od.array=n,t=Od.element(e.isMultiViewCamera?ud(`gl_ViewID_OVR`):Ld).toConst(`cameraViewMatrix`)}else Dd===null&&(Dd=K(e.matrixWorldInverse).setName(`cameraViewMatrix`).setGroup(G).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=Dd;return t}).once()(),Ud=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorld);Ad===null?Ad=ld(n).setGroup(G).setName(`cameraWorldMatrices`):Ad.array=n,t=Ad.element(e.isMultiViewCamera?ud(`gl_ViewID_OVR`):Ld).toConst(`cameraWorldMatrix`)}else kd===null&&(kd=K(e.matrixWorld).setName(`cameraWorldMatrix`).setGroup(G).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=kd;return t}).once()(),Wd=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.normalMatrix);Md===null?Md=ld(n).setGroup(G).setName(`cameraNormalMatrices`):Md.array=n,t=Md.element(e.isMultiViewCamera?ud(`gl_ViewID_OVR`):Ld).toConst(`cameraNormalMatrix`)}else jd===null&&(jd=K(e.normalMatrix).setName(`cameraNormalMatrix`).setGroup(G).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=jd;return t}).once()(),Gd=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t=0,r=e.cameras.length;t<r;t++)n.push(new O);Pd===null?Pd=ld(n).setGroup(G).setName(`cameraPositions`).onRenderUpdate(({camera:e},t)=>{let n=e.cameras,r=t.array;for(let e=0,t=n.length;e<t;e++)r[e].setFromMatrixPosition(n[e].matrixWorld)}):Pd.array=n,t=Pd.element(e.isMultiViewCamera?ud(`gl_ViewID_OVR`):Ld).toConst(`cameraPosition`)}else Nd===null&&(Nd=K(new O).setName(`cameraPosition`).setGroup(G).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=Nd;return t}).once()(),Kd=L(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.viewport);Id===null?Id=ld(n,`vec4`).setGroup(G).setName(`cameraViewports`):Id.array=n,t=Id.element(Ld).toConst(`cameraViewport`)}else Fd===null&&(Fd=W(0,0,gd.x,gd.y).toConst(`cameraViewport`)),t=Fd;return t}).once()(),qd=new Jn,Jd=class e extends j{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=A.OBJECT,this.uniformNode=new qs(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new O,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new O,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new O,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new O,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),qd.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=qd.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Jd.WORLD_MATRIX=`worldMatrix`,Jd.POSITION=`position`,Jd.SCALE=`scale`,Jd.VIEW_POSITION=`viewPosition`,Jd.DIRECTION=`direction`,Jd.RADIUS=`radius`;var Yd=P(Jd,Jd.DIRECTION).setParameterLength(1),Xd=P(Jd,Jd.WORLD_MATRIX).setParameterLength(1),Zd=P(Jd,Jd.POSITION).setParameterLength(1),Qd=P(Jd,Jd.SCALE).setParameterLength(1),$d=P(Jd,Jd.VIEW_POSITION).setParameterLength(1),ef=P(Jd,Jd.RADIUS).setParameterLength(1),tf=class extends Jd{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}},nf=F(tf,tf.DIRECTION),rf=F(tf,tf.WORLD_MATRIX),af=F(tf,tf.POSITION),of=F(tf,tf.SCALE),sf=F(tf,tf.VIEW_POSITION),cf=F(tf,tf.RADIUS),lf=K(new ct).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),uf=K(new k).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),df=L(e=>e.context.modelViewMatrix||ff).once()().toVar(`modelViewMatrix`),ff=Hd.mul(rf),pf=L(e=>(e.context.isHighPrecisionModelViewMatrix=!0,K(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),mf=L(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return K(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),hf=L(e=>e.shaderStage===`fragment`?e.context.clipSpace.toVarying(`v_clipSpace`):(Ae("TSL: `clipSpace` is only available in fragment stage."),W())).once()(),gf=Gu(`position`,`vec3`),_f=gf.toVarying(`positionLocal`),vf=gf.toVarying(`positionPrevious`),yf=L(e=>rf.mul(_f).xyz.toVarying(e.getSubBuildProperty(`v_positionWorld`)),`vec3`).once([`POSITION`])(),bf=L(()=>_f.transformDirection(rf).toVarying(`v_positionWorldDirection`).normalize().toVar(`positionWorldDirection`),`vec3`).once([`POSITION`])(),xf=L(e=>{if(e.shaderStage===`fragment`&&e.material.vertexNode){let e=Vd.mul(hf);return e.xyz.div(e.w).toVar(`positionView`)}return e.context.setupPositionView().toVarying(`v_positionView`)},`vec3`).once([`POSITION`,`VERTEX`])(),Sf=L(e=>{let t;return t=e.camera.isOrthographicCamera?U(0,0,1):xf.negate().toVarying(`v_positionViewDirection`).normalize(),t.toVar(`positionViewDirection`)},`vec3`).once([`POSITION`])(),Cf=F(class extends j{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!==`fragment`)return`true`;let{material:t}=e;return t.side===1?`false`:e.getFrontFacing()}}),wf=z(Cf).mul(2).sub(1),Tf=L(([e],{material:t})=>{let n=t.side;return n===1?e=e.mul(-1):n===2&&(e=e.mul(wf)),e}),Ef=Gu(`normal`,`vec3`),Df=L(e=>e.geometry.hasAttribute(`normal`)===!1?(T(`TSL: Vertex attribute "normal" not found on geometry.`),U(0,1,0)):Ef,`vec3`).once()().toVar(`normalLocal`),Of=xf.dFdx().cross(xf.dFdy()).normalize().toVar(`normalFlat`),kf=L(e=>{let t;return t=e.isFlatShading()?Of:Ff(Df).toVarying(`v_normalViewGeometry`).normalize(),t},`vec3`).once()().toVar(`normalViewGeometry`),Af=L(e=>{let t=kf.transformDirection(Hd);return e.isFlatShading()!==!0&&(t=t.toVarying(`v_normalWorldGeometry`)),t.normalize().toVar(`normalWorldGeometry`)},`vec3`).once()(),jf=L(e=>{let t;return e.subBuildFn===`NORMAL`||e.subBuildFn===`VERTEX`?(t=kf,e.isFlatShading()!==!0&&(t=Tf(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`normalView`),Mf=jf.transformDirection(Hd).toVar(`normalWorld`),Nf=L(({subBuildFn:e,context:t})=>{let n;return n=e===`NORMAL`||e===`VERTEX`?jf:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),n},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`clearcoatNormalView`),Pf=L(([e,t=rf])=>{let n=ts(t),r=e.div(U(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),Ff=L(([e],t)=>{let n=t.context.modelNormalViewMatrix;if(n)return n.transformDirection(e);let r=lf.mul(e);return Hd.transformDirection(r)}),If=L(()=>(T(`TSL: "transformedNormalView" is deprecated. Use "normalView" instead.`),jf)).once([`NORMAL`,`VERTEX`])(),Lf=L(()=>(T(`TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.`),Mf)).once([`NORMAL`,`VERTEX`])(),Rf=L(()=>(T(`TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.`),Nf)).once([`NORMAL`,`VERTEX`])(),zf=new It,Bf=new k,Vf=K(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Hf=K(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Uf=K(new k).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(zf.copy(n),Bf.makeRotationFromEuler(zf)):Bf.identity(),Bf}),Wf=Sf.negate().reflect(jf),Gf=Sf.negate().refract(jf,Vf),Kf=Wf.transformDirection(Hd).toVar(`reflectVector`),qf=Gf.transformDirection(Hd).toVar(`reflectVector`),Jf=new Zr,Yf=P(class extends Zu{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?`cubeDepthTexture`:`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===301?Kf:e.mapping===302?qf:(E(`CubeTextureNode: Mapping "%s" not supported.`,e.mapping),U(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===2001?U(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===2001||!n.isRenderTargetTexture)&&(t=U(t.x.negate(),t.yz)),Uf.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}}).setParameterLength(1,4).setName(`cubeTexture`),Xf=(e=Jf,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=N(e.clone()),i.referenceNode=e,t!==null&&(i.uvNode=N(t)),n!==null&&(i.levelNode=N(n)),r!==null&&(i.biasNode=N(r))):i=Yf(e,t,n,r),i},Zf=(e=Jf)=>Yf(e),Qf=class extends Va{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},$f=class extends j{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=A.OBJECT}element(e){return new Qf(this,N(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`),this.setName(e)}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?ld(null,e):e===`texture`?$u(null):e===`cubeTexture`?Xf(null):K(null,e):od(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},ep=(e,t,n)=>new $f(e,t,n),tp=(e,t,n,r)=>new $f(e,t,r,n),np=class extends $f{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}},rp=(e,t,n=null)=>new np(e,t,n),ip=Ku(),ap=xf.dFdx(),op=xf.dFdy(),sp=ip.dFdx(),cp=ip.dFdy(),lp=jf,up=op.cross(lp),dp=lp.cross(ap),fp=up.mul(sp.x).add(dp.mul(cp.x)),pp=up.mul(sp.y).add(dp.mul(cp.y)),mp=fp.dot(fp).max(pp.dot(pp)),hp=mp.equal(0).select(0,mp.inverseSqrt()),gp=fp.mul(hp).toVar(`tangentViewFrame`),_p=pp.mul(hp).toVar(`bitangentViewFrame`),vp=Gu(`tangent`,`vec4`),yp=vp.xyz.toVar(`tangentLocal`),bp=L(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?df.mul(W(yp,0)).xyz.toVarying(`v_tangentView`).normalize():gp,e.isFlatShading()!==!0&&(t=Tf(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`tangentView`),xp=bp.transformDirection(Hd).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),Sp=L(([e,t],n)=>{let r=e.mul(vp.w).xyz;return n.subBuildFn===`NORMAL`&&n.isFlatShading()!==!0&&(r=r.toVarying(t)),r}).once([`NORMAL`]),Cp=Sp(Ef.cross(vp),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),wp=Sp(Df.cross(yp),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),Tp=L(e=>{let t;return t=e.subBuildFn===`VERTEX`||e.geometry.hasAttribute(`tangent`)?Sp(jf.cross(bp),`v_bitangentView`).normalize():_p,e.isFlatShading()!==!0&&(t=Tf(t)),t},`vec3`).once([`NORMAL`,`VERTEX`])().toVar(`bitangentView`),Ep=Sp(Mf.cross(xp),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),Dp=ts(bp,Tp,jf).toVar(`TBNViewMatrix`),Op=Sf.mul(Dp),kp=(e,t)=>e.sub(Op.mul(t)),Ap=L(()=>{let e=Ds.cross(Sf);return e=e.cross(Ds).normalize(),e=El(e,jf,Ts.mul(hs.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),jp=e=>N(e).mul(.5).add(.5),Mp=e=>N(e).mul(2).sub(1),Np=e=>U(e,zc(Ol(z(1).sub(_l(e,e))))),Pp=P(class extends Ua{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=0,this.unpackNormalMode=``}setup(e){let{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this,i=this.node.mul(2).sub(1);if(t===0?r===`rg`?i=Np(i.xy):r===`ga`?i=Np(i.yw):r!==``&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==``&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let t=n;e.isFlatShading()===!0&&(t=Tf(t)),i=U(i.xy.mul(t),i.z)}let a=null;return t===1?a=Ff(i):t===0?a=Dp.mul(i).normalize():(E(`NodeMaterial: Unsupported normal map type: ${t}`),a=jf),a}}).setParameterLength(1,2),Fp=L(({textureNode:e,bumpScale:t})=>{let n=t=>e.isolate().context({getUV:e=>t(e.uvNode||Ku()),forceUVContext:!0}),r=z(n(e=>e));return H(z(n(e=>e.add(e.dFdx()))).sub(r),z(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),Ip=L(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(wf),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()}),Lp=P(class extends Ua{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode;return Ip({surf_pos:xf,surf_norm:jf,dHdxy:Fp({textureNode:this.textureNode,bumpScale:e})})}}).setParameterLength(1,2),Rp=new Map,X=class e extends j{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Rp.get(e);return n===void 0&&(n=rp(e,t),Rp.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?U():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:z(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=Pp(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType,(n.normalMap.format==1030||n.normalMap.format==36285||n.normalMap.format==37490)&&(i.unpackNormalMode=`rg`)):i=n.bumpMap?Lp(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):jf;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?Pp(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):jf;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(1e-4,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r);i=es(Sm.x,Sm.y,Sm.y.negate(),Sm.x).mul(e.rg.mul(2).sub(H(1)).normalize().mul(e.b))}else i=Sm;else if(r===e.IRIDESCENCE_THICKNESS){let e=ep(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=ep(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):z(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};X.ALPHA_TEST=`alphaTest`,X.COLOR=`color`,X.OPACITY=`opacity`,X.SHININESS=`shininess`,X.SPECULAR=`specular`,X.SPECULAR_STRENGTH=`specularStrength`,X.SPECULAR_INTENSITY=`specularIntensity`,X.SPECULAR_COLOR=`specularColor`,X.REFLECTIVITY=`reflectivity`,X.ROUGHNESS=`roughness`,X.METALNESS=`metalness`,X.NORMAL=`normal`,X.CLEARCOAT=`clearcoat`,X.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,X.CLEARCOAT_NORMAL=`clearcoatNormal`,X.EMISSIVE=`emissive`,X.ROTATION=`rotation`,X.SHEEN=`sheen`,X.SHEEN_ROUGHNESS=`sheenRoughness`,X.ANISOTROPY=`anisotropy`,X.IRIDESCENCE=`iridescence`,X.IRIDESCENCE_IOR=`iridescenceIOR`,X.IRIDESCENCE_THICKNESS=`iridescenceThickness`,X.IOR=`ior`,X.TRANSMISSION=`transmission`,X.THICKNESS=`thickness`,X.ATTENUATION_DISTANCE=`attenuationDistance`,X.ATTENUATION_COLOR=`attenuationColor`,X.LINE_SCALE=`scale`,X.LINE_DASH_SIZE=`dashSize`,X.LINE_GAP_SIZE=`gapSize`,X.LINE_WIDTH=`linewidth`,X.LINE_DASH_OFFSET=`dashOffset`,X.POINT_SIZE=`size`,X.DISPERSION=`dispersion`,X.LIGHT_MAP=`light`,X.AO=`ao`;var zp=F(X,X.ALPHA_TEST),Bp=F(X,X.COLOR),Vp=F(X,X.SHININESS),Hp=F(X,X.EMISSIVE),Up=F(X,X.OPACITY),Wp=F(X,X.SPECULAR),Gp=F(X,X.SPECULAR_INTENSITY),Kp=F(X,X.SPECULAR_COLOR),qp=F(X,X.SPECULAR_STRENGTH),Jp=F(X,X.REFLECTIVITY),Yp=F(X,X.ROUGHNESS),Xp=F(X,X.METALNESS),Zp=F(X,X.NORMAL),Qp=F(X,X.CLEARCOAT),$p=F(X,X.CLEARCOAT_ROUGHNESS),em=F(X,X.CLEARCOAT_NORMAL),tm=F(X,X.ROTATION),nm=F(X,X.SHEEN),rm=F(X,X.SHEEN_ROUGHNESS),im=F(X,X.ANISOTROPY),am=F(X,X.IRIDESCENCE),om=F(X,X.IRIDESCENCE_IOR),sm=F(X,X.IRIDESCENCE_THICKNESS),cm=F(X,X.TRANSMISSION),lm=F(X,X.THICKNESS),um=F(X,X.IOR),dm=F(X,X.ATTENUATION_DISTANCE),fm=F(X,X.ATTENUATION_COLOR),pm=F(X,X.LINE_SCALE),mm=F(X,X.LINE_DASH_SIZE),hm=F(X,X.LINE_GAP_SIZE),gm=F(X,X.LINE_WIDTH),_m=F(X,X.LINE_DASH_OFFSET),vm=F(X,X.POINT_SIZE),ym=F(X,X.DISPERSION),bm=F(X,X.LIGHT_MAP),xm=F(X,X.AO),Sm=K(new it).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Cm=L(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`),wm=P(class extends Va{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}}).setParameterLength(2),Tm=class extends ad{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=Sa(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Pa.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return wm(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Pa.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=yu(this.value),this._varying=Ql(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}},Em=(e,t=null,n=0)=>new Tm(e,t,n),Dm=class e extends j{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;return a=t.shaderStage===`vertex`||t.shaderStage===`compute`?i:Ql(this).build(t,n),a}};Dm.VERTEX=`vertex`,Dm.INSTANCE=`instance`,Dm.SUBGROUP=`subgroup`,Dm.INVOCATION_LOCAL=`invocationLocal`,Dm.INVOCATION_SUBGROUP=`invocationSubgroup`,Dm.DRAW=`draw`;var Om=F(Dm,Dm.VERTEX),km=F(Dm,Dm.INSTANCE),Am=F(Dm,Dm.SUBGROUP),jm=F(Dm,Dm.INVOCATION_SUBGROUP),Mm=F(Dm,Dm.INVOCATION_LOCAL),Nm=F(Dm,Dm.DRAW),Pm=class extends j{static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=A.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){let{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){let{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:n}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);let{instanceColor:r,isStorageColor:i}=this;if(r&&n===null){if(i)n=Em(r,`vec3`,Math.max(r.count,1)).element(km);else{let e=new Mr(r.array,3),t=r.usage===35048?Su:xu;this.bufferColor=e,n=U(t(e,`vec3`,3,0))}this.instanceColorNode=n}let a=t.mul(_f).xyz;if(_f.assign(a),e.needsPreviousData()&&vf.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute(`normal`)){let e=Pf(Df,t);Df.assign(e)}this.instanceColorNode!==null&&ds(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(e){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){let t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(vf).xyz}_createInstanceMatrixNode(e,t){let n,{instanceMatrix:r}=this,{count:i}=r;if(this.isStorageMatrix)n=Em(r,`mat4`,Math.max(i,1)).element(km);else if(i*16*4<=t.getUniformBufferLimit())n=od(r.array,`mat4`,Math.max(i,1)).element(km);else{let t=new Xi(r.array,16,1);e===!0&&(this.buffer=t);let i=r.usage===35048?Su:xu;n=ns(i(t,`vec4`,16,0),i(t,`vec4`,16,4),i(t,`vec4`,16,8),i(t,`vec4`,16,12))}return n}},Fm=P(Pm).setParameterLength(2,3),Im=P(class extends Pm{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}).setParameterLength(1),Lm=P(class extends j{static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=km:this.batchingIdNode=Nm);let t=L(([e])=>{let t=B(qu(td(this.batchMesh._indirectTexture),0).x).toConst(),n=B(e).mod(t).toConst(),r=B(e).div(t).toConst();return td(this.batchMesh._indirectTexture,Go(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]})(B(this.batchingIdNode)),n=this.batchMesh._matricesTexture,r=B(qu(td(n),0).x).toConst(),i=z(t).mul(4).toInt().toConst(),a=i.mod(r).toConst(),o=i.div(r).toConst(),s=ns(td(n,Go(a,o)),td(n,Go(a.add(1),o)),td(n,Go(a.add(2),o)),td(n,Go(a.add(3),o))),c=this.batchMesh._colorsTexture;if(c!==null){let e=L(([e])=>{let t=B(qu(td(c),0).x).toConst(),n=e;return td(c,Go(n.mod(t).toConst(),n.div(t).toConst())).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]})(t);ds(`vec3`,`vBatchColor`).assign(e)}let l=ts(s);_f.assign(s.mul(_f));let u=Df.div(U(l[0].dot(l[0]),l[1].dot(l[1]),l[2].dot(l[2]))),d=l.mul(u).xyz;Df.assign(d),e.hasGeometryAttribute(`tangent`)&&yp.mulAssign(l)}}).setParameterLength(1),Rm=new WeakMap,zm=class extends j{static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=A.OBJECT,this.skinIndexNode=Gu(`skinIndex`,`uvec4`),this.skinWeightNode=Gu(`skinWeight`,`vec4`),this.bindMatrixNode=ep(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=ep(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=tp(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=_f,this.toPositionNode=_f,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=tc(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Df,n=yp){let{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:a,bindMatrixInverseNode:o}=this,s=e.element(r.x),c=e.element(r.y),l=e.element(r.z),u=e.element(r.w),d=tc(i.x.mul(s),i.y.mul(c),i.z.mul(l),i.w.mul(u));return d=o.mul(d).mul(a),{skinNormal:d.transformDirection(t).xyz,skinTangent:d.transformDirection(n).xyz}}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=tp(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,vf)}setup(e){e.needsPreviousData()&&vf.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let{skinNormal:t,skinTangent:n}=this.getSkinnedNormalAndTangent();Df.assign(t),e.hasGeometryAttribute(`tangent`)&&yp.assign(n)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Rm.get(t)!==e.frameId&&(Rm.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}},Bm=e=>new zm(e),Vm=(e,t=null)=>{let n=new zm(e);return n.positionNode=Em(new Mr(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(km).toVar(),n.skinIndexNode=Em(new Mr(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(km).toVar(),n.skinWeightNode=Em(new Mr(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(km).toVar(),n.bindMatrixNode=K(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=K(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=od(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,N(n)},Hm=class extends j{static get type(){return`LoopNode`}constructor(e=[]){super(`void`),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e);n[r]=Nu(r,t.isNode!==!0&&t.type||`int`)}let r=e.addStack(),i=this.params[this.params.length-1](n);t.returnsNode=i.context({nodeLoop:i}),t.stackNode=r;let a=this.params[0];if(a.isNode!==!0&&typeof a.update==`function`){let e=L(this.params[0].update)(n);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){let t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:a=e.flowStagesNode(t.updateNode,`void`).code.replace(/\t|;/g,``);break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(E(`TSL: 'Loop( { update: ... } )' is not a function, string or number.`,this.stackTrace),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;f=`for ( ${e.getVar(l,c)+` = `+r}; ${c+` `+u+` `+i}; ${a} )`}e.addFlowCode((r===0?`
|
|
293
|
+
`:``)+e.tab+f+` {
|
|
294
|
+
|
|
295
|
+
`).addFlowTab()}let i=r.build(e,`void`);t.returnsNode.build(e,`void`),e.removeFlowTab().addFlowCode(`
|
|
296
|
+
`+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
|
|
297
|
+
|
|
298
|
+
`).removeFlowTab();e.addFlowTab()}},Um=(...e)=>new Hm(Io(e,`int`)).toStack(),Wm=()=>Nu(`continue`).toStack(),Gm=()=>Nu(`break`).toStack(),Km=new WeakMap,qm=new wt,Jm=L(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=B(Om).mul(n).add(a),s=o.div(r);return td(e,Go(o.sub(s.mul(r)),s)).depth(i).xyz.mul(t)});function Ym(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=Km.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],c=e.morphAttributes.normal||[],l=e.morphAttributes.color||[],u=0;t===!0&&(u=1),n===!0&&(u=2),r===!0&&(u=3);let d=e.attributes.position.count*u,f=1,p=4096;d>p&&(f=Math.ceil(d/p),d=p);let m=new Float32Array(d*f*4*a),h=new Et(m,d,f,a);h.type=ne,h.needsUpdate=!0;let g=u*4;for(let e=0;e<a;e++){let a=i[e],o=c[e],s=l[e],u=d*f*4*e;for(let e=0;e<a.count;e++){let i=e*g;t===!0&&(qm.fromBufferAttribute(a,e),m[u+i+0]=qm.x,m[u+i+1]=qm.y,m[u+i+2]=qm.z,m[u+i+3]=0),n===!0&&(qm.fromBufferAttribute(o,e),m[u+i+4]=qm.x,m[u+i+5]=qm.y,m[u+i+6]=qm.z,m[u+i+7]=0),r===!0&&(qm.fromBufferAttribute(s,e),m[u+i+8]=qm.x,m[u+i+9]=qm.y,m[u+i+10]=qm.z,m[u+i+11]=s.itemSize===4?qm.w:1)}}o={count:a,texture:h,stride:u,size:new it(d,f)},Km.set(e,o);function s(){h.dispose(),Km.delete(e),e.removeEventListener(`dispose`,s)}e.addEventListener(`dispose`,s)}return o}var Xm=P(class extends j{static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=K(1),this.updateType=A.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=Ym(t);n===!0&&_f.mulAssign(this.morphBaseInfluence),r===!0&&Df.mulAssign(this.morphBaseInfluence);let l=B(c.width);Um(a,({i:e})=>{let t=z(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(td(this.mesh.morphTexture,Go(B(e).add(1),B(km))).r):t.assign(ep(`morphTargetInfluences`,`float`).element(e).toVar()),R(t.notEqual(0),()=>{n===!0&&_f.addAssign(Jm({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:B(0)})),r===!0&&Df.addAssign(Jm({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:B(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}).setParameterLength(1),Zm=class extends j{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},Qm=class extends Zm{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},$m=P(class extends zl{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n={directDiffuse:U().toVar(`directDiffuse`),directSpecular:U().toVar(`directSpecular`),indirectDiffuse:U().toVar(`indirectDiffuse`),indirectSpecular:U().toVar(`indirectSpecular`)};return{radiance:U().toVar(`radiance`),irradiance:U().toVar(`irradiance`),iblIrradiance:U().toVar(`iblIrradiance`),ambientOcclusion:z(1).toVar(`ambientOcclusion`),reflectedLight:n,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}),eh=class extends Zm{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}},th=new it,nh=class extends Zu{static get type(){return`ViewportTextureNode`}constructor(e=hd,t=null,n=null){let r=null;n===null?(r=new Xr,r.minFilter=S,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=A.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){let r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){let t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){let t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(th):th.set(n.width,n.height);let r=this.getTextureForReference(n);(r.image.width!==th.width||r.image.height!==th.height)&&(r.image.width=th.width,r.image.height=th.height,r.needsUpdate=!0);let i=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=i}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}},rh=P(nh).setParameterLength(0,3),ih=P(nh,null,null,{generateMipmaps:!0}).setParameterLength(0,3),ah=ih(),oh=(e=hd,t=null)=>ah.sample(e,t),sh=null,ch=P(class extends nh{static get type(){return`ViewportDepthTextureNode`}constructor(e=hd,t=null){sh===null&&(sh=new $r),super(e,t,sh)}getTextureForReference(){return sh}}).setParameterLength(0,2),lh=class e extends j{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;return n===e.DEPTH_BASE?r!==null&&(i=vh().assign(r)):n===e.DEPTH?i=t.isPerspectiveCamera?ph(xf.z,Rd,zd):uh(xf.z,Rd,zd):n===e.LINEAR_DEPTH&&(i=r===null?uh(xf.z,Rd,zd):t.isPerspectiveCamera?uh(hh(r,Rd,zd),Rd,zd):r),i}};lh.DEPTH_BASE=`depthBase`,lh.DEPTH=`depth`,lh.LINEAR_DEPTH=`linearDepth`;var uh=(e,t,n)=>e.add(t).div(t.sub(n)),dh=(e,t,n)=>e.add(n).div(n.sub(t)),fh=L(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?n.sub(t).mul(e).sub(n):t.sub(n).mul(e).sub(t)),ph=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),mh=(e,t,n)=>t.mul(e.add(n)).div(e.mul(t.sub(n))),hh=L(([e,t,n],r)=>r.renderer.reversedDepthBuffer===!0?t.mul(n).div(t.sub(n).mul(e).sub(t)):t.mul(n).div(n.sub(t).mul(e).sub(n))),gh=(e,t,n)=>{t=t.max(1e-6).toVar();let r=Rc(e.negate().div(t)),i=Rc(n.div(t));return r.div(i)},_h=(e,t,n)=>{let r=e.mul(Lc(n.div(t)));return z(Math.E).pow(r).mul(t).negate()},vh=P(lh,lh.DEPTH_BASE),yh=F(lh,lh.DEPTH),bh=P(lh,lh.LINEAR_DEPTH).setParameterLength(0,1),xh=bh(ch());yh.assign=e=>vh(e);var Sh=class e extends j{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let{intersectionPlanes:n,unionPlanes:r}=t.clippingContext;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===e.HARDWARE?this.setupHardwareClipping(r,t):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return L(()=>{let n=z().toVar(`distanceToPlane`),r=z().toVar(`distanceToGradient`),i=z(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=ld(t).setGroup(G);Um(a,({i:t})=>{let a=e.element(t);n.assign(xf.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(Al(r.negate(),r,n))})}let o=e.length;if(o>0){let t=ld(e).setGroup(G),a=z(1).toVar(`intersectionClipOpacity`);Um(o,({i:e})=>{let i=t.element(e);n.assign(xf.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(Al(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}fs.a.mulAssign(i),fs.a.equal(0).discard()})()}setupDefault(e,t){return L(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=ld(t).setGroup(G);Um(n,({i:t})=>{let n=e.element(t);xf.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=ld(e).setGroup(G),n=Wo(!0).toVar(`clipped`);Um(r,({i:e})=>{let r=t.element(e);n.assign(xf.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),L(()=>{let r=ld(e).setGroup(G),i=ud(t.getClipDistance());Um(n,({i:e})=>{let t=r.element(e),n=xf.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};Sh.ALPHA_TO_COVERAGE=`alphaToCoverage`,Sh.DEFAULT=`default`,Sh.HARDWARE=`hardware`;var Ch=()=>new Sh,wh=()=>new Sh(Sh.ALPHA_TO_COVERAGE),Th=()=>new Sh(Sh.HARDWARE),Eh=.05,Dh=L(([e])=>Wc(J(1e4,Gc(J(17,e.x).add(J(.1,e.y)))).mul(tc(.1,Zc(Gc(J(13,e.y).add(e.x))))))),Oh=L(([e])=>Dh(H(Dh(e.xy),e.z))),kh=L(([e])=>{let t=fl($c(nl(e.xyz)),$c(rl(e.xyz))),n=z(1).div(z(Eh).mul(t)).toVar(`pixScale`),r=H(Ic(Vc(Rc(n))),Ic(Hc(Rc(n)))),i=H(Oh(Vc(r.x.mul(e.xyz))),Oh(Vc(r.y.mul(e.xyz)))),a=Wc(Rc(n)),o=tc(J(a.oneMinus(),i.x),J(a,i.y)),s=dl(a,a.oneMinus()),c=U(o.mul(o).div(J(2,s).mul(q(1,s))),o.sub(J(.5,s)).div(q(1,s)),q(1,q(1,o).mul(q(1,o)).div(J(2,s).mul(q(1,s)))));return Dl(o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z),1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]}),Ah=class extends Wu{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new wt(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}},jh=(e=0)=>new Ah(e),Mh=L(([e,t])=>dl(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Nh=L(([e,t])=>dl(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Ph=L(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Fh=L(([e,t])=>El(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),pl(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Ih=L(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return W(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),Lh=L(([e])=>W(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),Rh=L(([e])=>(R(e.a.equal(0),()=>W(0)),W(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),zh=class extends sr{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(t.startsWith(`_`)===!0)continue;let n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:n}of this._getNodeChildren())e.push(_a(t.slice(0,-4)),n.getCacheKey());return this.type+va(e)}build(e){this.setup(e)}setupObserver(e){return new fa(e)}setup(e){e.context.setupNormal=()=>Zl(this.setupNormal(e),`NORMAL`,`vec3`),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context=m(m({},e.context),t.contextNode.getFlowContextData()):E('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context=m(m({},e.context),this.contextNode.getFlowContextData()):E('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();let r=this.setupVertex(e),i=Zl(this.vertexNode||r,`VERTEX`);e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.addToStack(o);let i=W(r,fs.a).max(0);a=this.setupOutput(e,i),Ms.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&Ms.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=W(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?r=wh():e.stack.addToStack(Ch())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.addToStack(Th()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?gh(xf.z,Rd,zd):uh(xf.z,Rd,zd))}r!==null&&yh.assign(r).toStack()}setupPositionView(){return df.mul(_f).xyz}setupModelViewProjection(){return Bd.mul(xf)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Cm}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&Xm(t).toStack(),t.isSkinnedMesh===!0&&Bm(t).toStack(),this.displacementMap){let e=rp(`displacementMap`,`texture`),t=rp(`displacementScale`,`float`),n=rp(`displacementBias`,`float`);_f.addAssign(Df.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&Lm(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&Im(t).toStack(),this.positionNode!==null&&_f.assign(Zl(this.positionNode,`POSITION`,`vec3`)),_f}setupDiffuseColor(e){let{object:t,geometry:n}=e;this.maskNode!==null&&Wo(this.maskNode).not().discard();let r=this.colorNode?W(this.colorNode):Bp;this.vertexColors===!0&&n.hasAttribute(`color`)&&(r=r.mul(jh())),t.instanceColor&&(r=ds(`vec3`,`vInstanceColor`).mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=ds(`vec3`,`vBatchColor`).mul(r)),fs.assign(r);let i=this.opacityNode?z(this.opacityNode):Up;fs.a.assign(fs.a.mul(i));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode===null?zp:z(this.alphaTestNode),this.alphaToCoverage===!0?(fs.a=Al(a,a.add(sl(fs.a)),fs.a),fs.a.lessThanEqual(0).discard()):fs.a.lessThanEqual(a).discard()),this.alphaHash===!0&&fs.a.lessThan(kh(_f)).discard(),e.isOpaque()&&fs.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?U(0):fs.rgb}setupNormal(){return this.normalNode?U(this.normalNode):Zp}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?rp(`envMap`,`cubeTexture`):rp(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new eh(bm)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let i=this.aoNode;i===null&&e.material.aoMap&&(i=xm),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new Qm(i));let a=this.lightsNode||e.lightsNode;return t.length>0&&(a=e.renderer.lighting.createNode([...a.getLights(),...t])),a}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null,o=this.setupOutgoingLight(e);return a&&a.getScope().hasLights?o=$m(a,this.setupLightingModel(e)||null,n,r):n!==null&&(o=U(r===null?n:El(o,n,r))),(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(ms.assign(U(i||Hp)),o=o.add(ms)),o}setupFog(e,t){let n=e.fogNode;return n&&(Ms.assign(t),t=W(n.toVar())),t}setupPremultipliedAlpha(e,t){return Lh(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=sr.prototype.toJSON.call(this,e);n.inputNodes={};for(let{property:t,childNode:r}of this._getNodeChildren())n.inputNodes[t]=r.toJSON(e).uuid;function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images),a=r(e.nodes);t.length>0&&(n.textures=t),i.length>0&&(n.images=i),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}},Bh=L(([e=bf])=>H(e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),Vh=L(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Hh=L(e=>e.diffuseColor.mul(1/Math.PI)),Uh=L(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return z(0);let t=kf.dFdx().abs().max(kf.dFdy().abs());return t.x.max(t.y).max(t.z)}),Wh=L(e=>{let{roughness:t}=e,n=Uh(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),Gh=L(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return nc(.5,i.add(a).max(Tc))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),Kh=L(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(U(e.mul(n),t.mul(r),o).length()),l=o.mul(U(e.mul(i),t.mul(a),s).length());return nc(.5,c.add(l))}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),qh=L(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Jh=z(1/Math.PI),Yh=L(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=U(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Jh.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),Xh=L(({lightDirection:e,f0:t,f90:n,roughness:r,f:i,normalView:a=jf,USE_IRIDESCENCE:o,USE_ANISOTROPY:s})=>{let c=r.pow2(),l=e.add(Sf).normalize(),u=a.dot(e).clamp(),d=a.dot(Sf).clamp(),f=a.dot(l).clamp(),p=Vh({f0:t,f90:n,dotVH:Sf.dot(l).clamp()}),m,h;if(jo(o)&&(p=xs.mix(p,i)),jo(s)){let t=Es.dot(e),n=Es.dot(Sf),r=Es.dot(l),i=Ds.dot(e),a=Ds.dot(Sf),o=Ds.dot(l);m=Kh({alphaT:ws,alphaB:c,dotTV:n,dotBV:a,dotTL:t,dotBL:i,dotNV:d,dotNL:u}),h=Yh({alphaT:ws,alphaB:c,dotNH:f,dotTH:r,dotBH:o})}else m=Gh({alpha:c,dotNL:u,dotNV:d}),h=qh({alpha:c,dotNH:f});return p.mul(m).mul(h)}),Zh=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Qh=null,$h=L(({roughness:e,dotNV:t})=>{Qh===null&&(Qh=new jr(Zh,16,16,ae,w),Qh.name=`DFG_LUT`,Qh.minFilter=x,Qh.magFilter=x,Qh.wrapS=v,Qh.wrapT=v,Qh.generateMipmaps=!1,Qh.needsUpdate=!0);let n=H(e,t);return $u(Qh,n).rg}),eg=L(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(U(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),tg=1/6,ng=e=>J(tg,J(e,J(e,e.negate().add(3)).sub(3)).add(1)),rg=e=>J(tg,J(e,J(e,J(3,e).sub(6))).add(4)),ig=e=>J(tg,J(e,J(e,J(-3,e).add(3)).add(3)).add(1)),ag=e=>J(tg,yl(e,3)),og=e=>ng(e).add(rg(e)),sg=e=>ig(e).add(ag(e)),cg=e=>tc(-1,rg(e).div(ng(e).add(rg(e)))),lg=e=>tc(1,ag(e).div(ig(e).add(ag(e)))),ug=(e,t,n)=>{let r=e.uvNode,i=J(r,t.zw).add(.5),a=Vc(i),o=Wc(i),s=og(o.x),c=sg(o.x),l=cg(o.x),u=lg(o.x),d=cg(o.y),f=lg(o.y),p=H(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=H(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=H(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=H(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=og(o.y).mul(tc(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=sg(o.y).mul(tc(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},dg=L(([e,t])=>{let n=H(e.size(B(t))),r=H(e.size(B(t.add(1)))),i=nc(1,n),a=nc(1,r),o=ug(e,W(i,n),Vc(t)),s=ug(e,W(a,r),Hc(t));return Wc(t).mix(o,s)}),fg=L(([e,t])=>dg(e,t.mul(Ju(e))));U(.04),z(1);var pg=z(1),mg=z(-2),hg=z(.8),gg=z(-1),_g=z(.4),vg=z(2),yg=z(.305),bg=z(3),xg=z(.21),Sg=z(4),Cg=z(4),wg=z(16),Tg=L(([e])=>{let t=U(Zc(e)).toVar(),n=z(-1).toVar();return R(t.x.greaterThan(t.z),()=>{R(t.x.greaterThan(t.y),()=>{n.assign(Rl(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(Rl(e.y.greaterThan(0),1,4))})}).Else(()=>{R(t.z.greaterThan(t.y),()=>{n.assign(Rl(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(Rl(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),Eg=L(([e,t])=>{let n=H().toVar();return R(t.equal(0),()=>{n.assign(H(e.z,e.y).div(Zc(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(H(e.x.negate(),e.z.negate()).div(Zc(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(H(e.x.negate(),e.y).div(Zc(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(H(e.z.negate(),e.y).div(Zc(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(H(e.x.negate(),e.z).div(Zc(e.y)))}).Else(()=>{n.assign(H(e.x,e.y).div(Zc(e.z)))}),J(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),Dg=L(([e])=>{let t=z(0).toVar();return R(e.greaterThanEqual(hg),()=>{t.assign(pg.sub(e).mul(gg.sub(mg)).div(pg.sub(hg)).add(mg))}).ElseIf(e.greaterThanEqual(_g),()=>{t.assign(hg.sub(e).mul(vg.sub(gg)).div(hg.sub(_g)).add(gg))}).ElseIf(e.greaterThanEqual(yg),()=>{t.assign(_g.sub(e).mul(bg.sub(vg)).div(_g.sub(yg)).add(vg))}).ElseIf(e.greaterThanEqual(xg),()=>{t.assign(yg.sub(e).mul(Sg.sub(bg)).div(yg.sub(xg)).add(bg))}).Else(()=>{t.assign(z(-2).mul(Rc(J(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),Og=L(([e,t])=>{let n=e.toVar();n.assign(J(2,n).sub(1));let r=U(n,1).toVar();return R(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),kg=L(([e,t,n,r,i,a])=>{let o=z(n),s=U(t),c=Dl(Dg(o),mg,a),l=Wc(c),u=Vc(c),d=U(Ag(e,s,u,r,i,a)).toVar();return R(l.notEqual(0),()=>{let t=U(Ag(e,s,u.add(1),r,i,a)).toVar();d.assign(El(d,t,l))}),d}),Ag=L(([e,t,n,r,i,a])=>{let o=z(n).toVar(),s=U(t),c=z(Tg(s)).toVar(),l=z(fl(Cg.sub(o),0)).toVar();o.assign(fl(o,Cg));let u=z(Ic(o)).toVar(),d=H(Eg(s,c).mul(u.sub(2)).add(1)).toVar();return R(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(J(3,wg))),d.y.addAssign(J(4,Ic(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(H(),H())}),jg=L(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=Kc(r);return Ag(e,n.mul(c).add(i.cross(n).mul(Gc(r))).add(i.mul(i.dot(n).mul(c.oneMinus()))),t,a,o,s)}),Mg=L(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=U(Rl(t,n,vl(n,r))).toVar();R(f.equal(U(0)),()=>{f.assign(U(r.z,0,r.x.negate()))}),f.assign(Uc(f));let p=U().toVar();return p.addAssign(i.element(0).mul(jg({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),Um({start:B(1),end:e},({i:e})=>{R(e.greaterThanEqual(a),()=>{Gm()});let t=z(o.mul(z(e))).toVar();p.addAssign(i.element(e).mul(jg({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(jg({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),W(p,1)}),Ng=L(([e])=>{let t=V(e).toVar();return t.assign(t.shiftLeft(V(16)).bitOr(t.shiftRight(V(16)))),t.assign(t.bitAnd(V(1431655765)).shiftLeft(V(1)).bitOr(t.bitAnd(V(2863311530)).shiftRight(V(1)))),t.assign(t.bitAnd(V(858993459)).shiftLeft(V(2)).bitOr(t.bitAnd(V(3435973836)).shiftRight(V(2)))),t.assign(t.bitAnd(V(252645135)).shiftLeft(V(4)).bitOr(t.bitAnd(V(4042322160)).shiftRight(V(4)))),t.assign(t.bitAnd(V(16711935)).shiftLeft(V(8)).bitOr(t.bitAnd(V(4278255360)).shiftRight(V(8)))),z(t).mul(23283064365386963e-26)}),Pg=L(([e,t])=>H(z(e).div(z(t)),Ng(e))),Fg=L(([e,t,n])=>{let r=n.mul(n).toConst(),i=U(1,0,0).toConst(),a=vl(t,i).toConst(),o=zc(e.x).toConst(),s=J(2,3.14159265359).mul(e.y).toConst(),c=o.mul(Kc(s)).toConst(),l=o.mul(Gc(s)).toVar(),u=J(.5,t.z.add(1)).toConst();l.assign(u.oneMinus().mul(zc(c.mul(c).oneMinus())).add(u.mul(l)));let d=i.mul(c).add(a.mul(l)).add(t.mul(zc(fl(0,c.mul(c).add(l.mul(l)).oneMinus()))));return Uc(U(r.mul(d.x),r.mul(d.y),fl(0,d.z)))}),Ig=L(({roughness:e,mipInt:t,envMap:n,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=U(r).toVar(),l=U(0).toVar(),u=z(0).toVar();return R(e.lessThan(.001),()=>{l.assign(Ag(n,c,t,a,o,s))}).Else(()=>{let r=Uc(vl(Rl(Zc(c.z).lessThan(.999),U(0,0,1),U(1,0,0)),c)).toVar(),d=vl(c,r).toVar();Um({start:V(0),end:i},({i:f})=>{let p=Fg(Pg(f,i),U(0,0,1),e),m=Uc(r.mul(p.x).add(d.mul(p.y)).add(c.mul(p.z))),h=Uc(m.mul(_l(c,m).mul(2)).sub(c)),g=fl(_l(c,h),0);R(g.greaterThan(0),()=>{let e=Ag(n,h,t,a,o,s);l.addAssign(e.mul(g)),u.addAssign(g)})}),R(u.greaterThan(0),()=>{l.assign(l.div(u))})}),W(l,1)}),Lg=4,Rg=[.125,.215,.35,.446,.526,.582],zg=20,Bg=512,Vg=new Li(-1,1,1,-1,0,1),Hg=new Ii(90,1),Ug=new on,Wg=null,Gg=0,Kg=0,qg=new O,Jg=new WeakMap,Yg=[3,1,5,0,4,2],Xg=Og(Ku(),Gu(`faceIndex`)).normalize(),Zg=U(Xg.x,Xg.y,Xg.z),Qg=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=qg,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){T(`PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}Wg=this._renderer.getRenderTarget(),Gg=this._renderer.getActiveCubeFace(),Kg=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromSceneAsync(e){var t=this;return g(function*(e,n=0,r=.1,i=100,a={}){return Ae(`PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.`),yield t._renderer.init(),t.fromScene(e,n,r,i,a)}).apply(this,arguments)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){T(`PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}fromEquirectangularAsync(e,t=null){var n=this;return g(function*(){return Ae(`PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.`),yield n._renderer.init(),n._fromTexture(e,t)})()}fromCubemap(e,t=null){if(this._hasInitialized===!1){T(`PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}fromCubemapAsync(e,t=null){var n=this;return g(function*(){return Ae(`PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.`),yield n._renderer.init(),n._fromTexture(e,t)})()}compileCubemapShader(){var e=this;return g(function*(){e._cubemapMaterial===null&&(e._cubemapMaterial=a_(),yield e._compileMaterial(e._cubemapMaterial))})()}compileEquirectangularShader(){var e=this;return g(function*(){e._equirectMaterial===null&&(e._equirectMaterial=o_(),yield e._compileMaterial(e._equirectMaterial))})()}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===301||e.mapping===302?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Wg,Gg,Kg),e.scissorTest=!1,t_(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Wg=this._renderer.getRenderTarget(),Gg=this._renderer.getActiveCubeFace(),Kg=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){return e_(3*Math.max(this._cubeSize,112),4*this._cubeSize)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=e_(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=$g(t)),this._blurMaterial=r_(t,e.width,e.height),this._ggxMaterial=i_(t,e.width,e.height)}}_compileMaterial(e){var t=this;return g(function*(){let n=new Or(new nr,e);yield t._renderer.compile(n,Vg)})()}_sceneToCubeUV(e,t,n,r,i){let a=Hg;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(Ug),c.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new Or(new ti,new gr({name:`PMREM.Background`,side:1,depthWrite:!1,depthTest:!1})));let u=this._backgroundBox,d=u.material,f=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,f=!0):(d.color.copy(Ug),f=!0),c.setRenderTarget(r),c.clear(),f&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;t_(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?this._cubemapMaterial===null&&(this._cubemapMaterial=a_(e)):this._equirectMaterial===null&&(this._equirectMaterial=o_(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;t_(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Vg)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;t<r;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let s=Jg.get(a),c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l)*(0+c*1.25),{_lodMax:d}=this,f=this._sizeLods[n],p=3*f*(n>d-Lg?n-d+Lg:0),m=4*(this._cubeSize-f);e.texture.frame=(e.texture.frame||0)+1,s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,t_(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Vg),i.texture.frame=(i.texture.frame||0)+1,s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,t_(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Vg)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&E(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=Jg.get(c),d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*zg-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):zg;m>zg&&T(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${zg}`);let h=[],g=0;for(let e=0;e<zg;++e){let t=e/p,n=Math.exp(-t*t/2);h.push(n),e===0?g+=n:e<m&&(g+=2*n)}for(let e=0;e<h.length;e++)h[e]=h[e]/g;e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.samples.value=m,u.weights.array=h,u.latitudinal.value=+(a===`latitudinal`),o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=f,u.mipInt.value=_-n;let v=this._sizeLods[r];t_(t,3*v*(r>_-Lg?r-_+Lg:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Vg)}};function $g(e){let t=[],n=[],r=[],i=e,a=e-Lg+1+Rg.length;for(let o=0;o<a;o++){let a=Math.pow(2,i);t.push(a);let s=1/a;o>e-Lg?s=Rg[o-e+Lg-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=Yg[e];f.set(r,18*i),p.set(d,12*i);let a=[i,i,i,i,i,i];m.set(a,6*i)}let h=new nr;h.setAttribute(`position`,new Vn(f,3)),h.setAttribute(`uv`,new Vn(p,2)),h.setAttribute(`faceIndex`,new Vn(m,1)),r.push(new Or(h,null)),i>Lg&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function e_(e,t){let n=new Tt(e,t,{magFilter:x,minFilter:x,generateMipmaps:!1,type:w,format:re,colorSpace:me});return n.texture.mapping=306,n.texture.name=`PMREM.cubeUv`,n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function t_(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function n_(e){let t=new zh;return t.depthTest=!1,t.depthWrite=!1,t.blending=0,t.name=`PMREM_${e}`,t}function r_(e,t,n){let r=ld(Array(zg).fill(0)),i=K(new O(0,1,0)),a=K(0),o=z(zg),s=K(0),c={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:Zg,dTheta:a,samples:K(1),envMap:$u(),mipInt:K(0),CUBEUV_TEXEL_WIDTH:z(1/t),CUBEUV_TEXEL_HEIGHT:z(1/n),CUBEUV_MAX_MIP:z(e)},l=n_(`blur`);return l.fragmentNode=Mg(m(m({},c),{},{latitudinal:s.equal(1)})),Jg.set(l,c),l}function i_(e,t,n){let r={envMap:$u(),roughness:K(0),mipInt:K(0),CUBEUV_TEXEL_WIDTH:z(1/t),CUBEUV_TEXEL_HEIGHT:z(1/n),CUBEUV_MAX_MIP:z(e)},i=n_(`ggx`);return i.fragmentNode=Ig(m(m({},r),{},{N_immutable:Zg,GGX_SAMPLES:V(Bg)})),Jg.set(i,r),i}function a_(e){let t=n_(`cubemap`);return t.fragmentNode=Xf(e,Zg),t}function o_(e){let t=n_(`equirect`);return t.fragmentNode=$u(e,Bh(Zg),0),t}var s_=new WeakMap;function c_(e){let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function l_(e,t,n){let r=u_(t),i=r.get(e);if((i===void 0?-1:i.pmremVersion)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(f_(t))i=n.fromCubemap(e,i);else return null;else if(p_(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function u_(e){let t=s_.get(e);return t===void 0&&(t=new WeakMap,s_.set(e,t)),t}var d_=class extends Ua{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new Ct;r.isRenderTargetTexture=!0,this._texture=$u(r),this._width=K(0),this._height=K(0),this._maxMip=K(0),this.updateBeforeType=A.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=c_(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:l_(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new Qg(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=Uf.mul(U(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),kg(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function f_(e){if(e==null)return!1;let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function p_(e){return e==null?!1:e.height>0}var m_=P(d_).setParameterLength(1,3),h_=L(()=>{let e=U(Sf.z,0,Sf.x.negate()).normalize(),t=Sf.cross(e);return H(e.dot(jf),t.dot(jf)).mul(.495).add(.5)}).once([`NORMAL`,`VERTEX`])().toVar(`matcapUV`),g_=P(class extends Ua{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)===`vec2`){let e=t.cos(),r=t.sin();return es(e,r,r.negate(),e).mul(n)}else{let e=t,r=ns(W(1,0,0,0),W(0,Kc(e.x),Gc(e.x).negate(),0),W(0,Gc(e.x),Kc(e.x),0),W(0,0,0,1)),i=ns(W(Kc(e.y),0,Gc(e.y),0),W(0,1,0,0),W(Gc(e.y).negate(),0,Kc(e.y),0),W(0,0,0,1)),a=ns(W(Kc(e.z),Gc(e.z).negate(),0,0),W(Gc(e.z),Kc(e.z),0,0),W(0,0,1,0),W(0,0,0,1));return r.mul(i).mul(a).mul(W(n,1)).xyz}}}).setParameterLength(2);us(`vec3`),us(`vec3`),us(`vec3`);var __=class{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},v_=class extends ls{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let n=this.getNodeType(e),r=e.getStructTypeNode(n),i;return r===null?(E(`TSL: Member "${t}" not found in struct "${n}".`,new ha),i=`float`):i=r.getMemberType(e,t),i}getHash(){return this.uuid}generate(){return this.name}},y_=(e,t)=>new v_(e,t),b_=P(class extends j{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this.isStackNode=!0}getElementType(e){return this.hasOutput(e)?this.outputNode.getElementType(e):`void`}getNodeType(e){return this.hasOutput(e)?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.hasOutput(e)?this.outputNode.getMemberType(e,t):`void`}addToStack(e,t=this.nodes.length){return e.isNode===!0?(this.nodes.splice(t,0,e),this):(E(`TSL: Invalid node added to stack.`,new ha),this)}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let n=new No(t);return this._currentCond=Rl(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){let n=Rl(e,new No(t));return this._currentCond.elseNode=n,this._currentCond=n,this}Else(e){return this._currentCond.elseNode=new No(e),this}Switch(e){return this._expressionNode=N(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(N(e[n])));else E(`TSL: Invalid parameter length. Case() requires at least two parameters.`,new ha);let n=e[e.length-1],r=new No(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=Rl(i,r);return this._currentCond===null?(this._currentCond=a,this.addToStack(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),n=0;for(let r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t[`node`+n++]=r);return t.outputNode||null}hasOutput(e){return this.outputNode&&this.outputNode.isNode&&this.outputNode.getNodeType(e)!==`void`}build(e,...t){let n=Bo(),r=e.buildStage;zo(this),e.setActiveStack(this);let i=t=>{if(this._currentNode=t,!(t.isVarNode&&t.isIntent(e)&&t.isAssign(e)!==!0)){if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)return;t.build(e,`void`)}}},a=[...this.nodes];for(let e of a)i(e);this._currentNode=null;let o=this.nodes.filter(e=>a.indexOf(e)===-1);for(let e of o)i(e);let s;return s=this.hasOutput(e)?this.outputNode.build(e,...t):super.build(e,...t),zo(n),e.removeActiveStack(this),s}}).setParameterLength(0,1);function x_(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var S_=class extends j{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=x_(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=Float32Array.BYTES_PER_ELEMENT,t=1,n=0;for(let r of this.membersLayout){let i=r.type,a=Ta(i),o=Ea(i)/e;t=Math.max(t,o);let s=n%t%o;s!==0&&(n+=o-s),n+=a}return Math.ceil(n/t)*t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}},C_=class extends j{static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}},w_=(e,t=null)=>{let n=new S_(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return new C_(n,r)};return r.layout=n,r.isStruct=!0,r},T_=class extends j{static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(){return`OutputType`}generate(e){let t=e.getDataFromNode(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}let n=e.getOutputStructName(),r=this.members,i=n===``?``:n+`.`;for(let t=0;t<r.length;t++){let n=r[t].build(e);e.addLineFlowCode(`${i}m${t} = ${n}`,this)}return n}},E_=P(T_),D_=class{constructor(e=1){this.blending=e,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}},O_=new D_(0),k_=new D_(6);function A_(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var j_=P(class extends T_{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.blendModes={output:k_},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||O_}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t=m(m({},this.outputNodes),e.outputNodes),n=m(m({},this.blendModes),e.blendModes),r=j_(t);return r.blendings=n,r}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=A_(i,e);r[n]=W(t[e])}return this.members=r,super.setup(e)}}),M_=class extends Ua{static get type(){return`BitcastNode`}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){let t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),n=``;if(this.inputType!==null){let t=this.valueNode.getNodeType(e);n=e.getTypeLength(t)===1?this.inputType:e.changeComponentType(t,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}},N_=I(M_).setParameterLength(2),P_=e=>new M_(e,`int`,`float`),F_=e=>new M_(e,`uint`,`float`),I_=e=>new M_(e,`float`,`int`),L_=e=>new M_(e,`float`,`uint`),R_={},z_=class e extends Y{static get type(){return`BitcountNode`}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n===`int`?t.assign(N_(e,`uint`)):t.assign(e)}_returnDataNode(e){switch(e){case`uint`:return V;case`int`:return B;case`uvec2`:return Ko;case`uvec3`:return Yo;case`uvec4`:return Qo;case`ivec2`:return Go;case`ivec3`:return Jo;case`ivec4`:return Zo}}_createTrailingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return L(([e])=>{let r=V(0);return this._resolveElementType(e,r,t),n(F_(z(r.bitAnd(el(r)))).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createLeadingZerosBaseLayout(e,t){let n=this._returnDataNode(t);return L(([e])=>{R(e.equal(V(0)),()=>V(32));let r=V(0),i=V(0);return this._resolveElementType(e,r,t),R(r.shiftRight(16).equal(0),()=>{i.addAssign(16),r.shiftLeftAssign(16)}),R(r.shiftRight(24).equal(0),()=>{i.addAssign(8),r.shiftLeftAssign(8)}),R(r.shiftRight(28).equal(0),()=>{i.addAssign(4),r.shiftLeftAssign(4)}),R(r.shiftRight(30).equal(0),()=>{i.addAssign(2),r.shiftLeftAssign(2)}),R(r.shiftRight(31).equal(0),()=>{i.addAssign(1)}),n(i)}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createOneBitsBaseLayout(e,t){let n=this._returnDataNode(t);return L(([e])=>{let r=V(0);return this._resolveElementType(e,r,t),r.assign(r.sub(r.shiftRight(V(1)).bitAnd(V(1431655765)))),r.assign(r.bitAnd(V(858993459)).add(r.shiftRight(V(2)).bitAnd(V(858993459)))),n(r.add(r.shiftRight(V(4))).bitAnd(V(252645135)).mul(V(16843009)).shiftRight(V(24)))}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}_createMainLayout(e,t,n,r){let i=this._returnDataNode(t);return L(([e])=>{if(n===1)return i(r(e));{let t=i(0),a=[`x`,`y`,`z`,`w`];for(let i=0;i<n;i++){let n=a[i];t[n].assign(r(e[n]))}return t}}).setLayout({name:e,type:t,inputs:[{name:`value`,type:t}]})}setup(t){let{method:n,aNode:r}=this,{renderer:i}=t;if(i.backend.isWebGPUBackend)return super.setup(t);let a=this.getInputType(t),o=t.getElementType(a),s=t.getTypeLength(a),c=`${n}_base_${o}`,l=`${n}_${a}`,u=R_[c];if(u===void 0){switch(n){case e.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(c,o);break;case e.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(c,o);break;case e.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(c,o);break}R_[c]=u}let d=R_[l];return d===void 0&&(d=this._createMainLayout(l,a,s,u),R_[l]=d),L(()=>d(r))()}};z_.COUNT_TRAILING_ZEROS=`countTrailingZeros`,z_.COUNT_LEADING_ZEROS=`countLeadingZeros`,z_.COUNT_ONE_BITS=`countOneBits`;var B_=I(z_,z_.COUNT_TRAILING_ZEROS).setParameterLength(1),V_=I(z_,z_.COUNT_LEADING_ZEROS).setParameterLength(1),H_=I(z_,z_.COUNT_ONE_BITS).setParameterLength(1),U_=L(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return n.shiftRight(22).bitXor(n).toFloat().mul(1/Math.pow(2,32))}),W_=(e,t)=>yl(J(4,e.mul(q(1,e))),t),G_=(e,t)=>e.lessThan(.5)?W_(e.mul(2),t).div(2):q(1,W_(J(q(1,e),2),t).div(2)),K_=(e,t,n)=>yl(nc(yl(e,t),tc(yl(e,t),yl(q(1,e),n))),1/t),q_=(e,t)=>Gc(Dc.mul(t.mul(e).sub(1))).div(Dc.mul(t.mul(e).sub(1))),J_=class extends Ua{static get type(){return`PackFloatNode`}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}getNodeType(){return`uint`}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}},Y_=I(J_,`snorm`).setParameterLength(1),X_=I(J_,`unorm`).setParameterLength(1),Z_=I(J_,`float16`).setParameterLength(1),Q_=class extends Ua{static get type(){return`UnpackFloatNode`}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}getNodeType(){return`vec2`}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}},$_=I(Q_,`snorm`).setParameterLength(1),ev=I(Q_,`unorm`).setParameterLength(1),tv=I(Q_,`float16`).setParameterLength(1),nv=L(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),rv=L(([e])=>U(nv(e.z.add(nv(e.y.mul(1)))),nv(e.z.add(nv(e.x.mul(1)))),nv(e.y.add(nv(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),iv=L(([e,t,n])=>{let r=U(e).toVar(),i=z(1.4).toVar(),a=z(0).toVar(),o=U(r).toVar();return Um({start:z(0),end:z(3),type:`float`,condition:`<=`},()=>{let e=U(rv(o.mul(2))).toVar();r.addAssign(e.add(n.mul(z(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=z(nv(r.z.add(nv(r.x.add(nv(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]}),av=P(class extends j{static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}getNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,n=this._candidateFn;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode.layout;if(a===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let o=a.inputs;if(t.length===o.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=o[n];r.getNodeType(e)===i.type&&a++}a>i&&(r=n,i=a)}}this._candidateFn=n=r}return n}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}),ov=e=>(...t)=>av(e,...t),sv=K(0).setGroup(G).onRenderUpdate(e=>e.time),cv=K(0).setGroup(G).onRenderUpdate(e=>e.deltaTime),lv=K(0,`uint`).setGroup(G).onRenderUpdate(e=>e.frameId),uv=(e=sv)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),dv=(e=sv)=>e.fract().round(),fv=(e=sv)=>e.add(.5).fract().mul(2).sub(1).abs(),pv=(e=sv)=>e.fract();function mv(e,t=null){return Bl(t,{getUV:typeof e==`function`?e:()=>e})}var hv=L(([e,t,n=H(.5)])=>g_(e.sub(n),t).add(n)),gv=L(([e,t,n=H(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i).mul(t);return e.add(r.mul(a))}),_v=L(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=rf:(r=rf.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Hd.mul(r);return jo(t)&&(i[0][0]=rf[0].length(),i[0][1]=0,i[0][2]=0),jo(n)&&(i[1][0]=0,i[1][1]=rf[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Bd.mul(i).mul(_f)}),vv=L(([e=null])=>{let t=bh();return bh(ch(e)).sub(t).lessThan(0).select(hd,e)}),yv=L(([e,t=Ku(),n=z(0)])=>{let r=e.x,i=e.y,a=n.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=e.reciprocal(),l=H(o,s);return t.add(l).mul(c)}),bv=L(([e,t=null,n=null,r=z(1),i=_f,a=Df])=>{let o=a.abs().normalize();o=o.div(o.dot(U(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value;return tc($u(u,s).mul(o.x),$u(d,c).mul(o.y),$u(f,l).mul(o.z))}),xv=(...e)=>bv(...e),Sv=new Ir,Cv=new O,wv=new O,Tv=new O,Ev=new k,Dv=new O(0,0,-1),Ov=new wt,kv=new O,Av=new O,jv=new wt,Mv=new it,Nv=new Tt,Pv=hd.flipX();Nv.depthTexture=new $r(1,1);var Fv=!1,Iv=class e extends Zu{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||Nv.texture,Pv),this._reflectorBaseNode=e.reflector||new Lv(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=new e({defaultTexture:Nv.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},Lv=class extends j{static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new $t,resolutionScale:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1,samples:s=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=r,t.resolution!==void 0&&(Ae(`ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".`),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=a,this.depth=o,this.samples=s,this.updateBeforeType=a?A.RENDER:A.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolutionScale;t.getDrawingBufferSize(Mv),e.setSize(Math.round(Mv.width*n),Math.round(Mv.height*n))}setup(e){return this._updateResolution(Nv,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Tt(0,0,{type:w,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=C,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new $r),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Fv)return!1;Fv=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(Mv),this._updateResolution(s,r),wv.setFromMatrixPosition(a.matrixWorld),Tv.setFromMatrixPosition(n.matrixWorld),Ev.extractRotation(a.matrixWorld),Cv.set(0,0,1),Cv.applyMatrix4(Ev),kv.subVectors(wv,Tv);let c=kv.dot(Cv)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Fv=!1;return}l=!0}kv.reflect(Cv).negate(),kv.add(wv),Ev.extractRotation(n.matrixWorld),Dv.set(0,0,-1),Dv.applyMatrix4(Ev),Dv.add(Tv),Av.subVectors(wv,Dv),Av.reflect(Cv).negate(),Av.add(wv),o.coordinateSystem=n.coordinateSystem,o.position.copy(kv),o.up.set(0,1,0),o.up.applyMatrix4(Ev),o.up.reflect(Cv),o.lookAt(Av),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),Sv.setFromNormalAndCoplanarPoint(Cv,wv),Sv.applyMatrix4(o.matrixWorldInverse),Ov.set(Sv.normal.x,Sv.normal.y,Sv.normal.z,Sv.constant);let u=o.projectionMatrix;jv.x=(Math.sign(Ov.x)+u.elements[8])/u.elements[0],jv.y=(Math.sign(Ov.y)+u.elements[9])/u.elements[5],jv.z=-1,jv.w=(1+u.elements[10])/u.elements[14],Ov.multiplyScalar(1/Ov.dot(jv)),u.elements[2]=Ov.x,u.elements[6]=Ov.y,u.elements[10]=r.coordinateSystem===2001?Ov.z-0:Ov.z+1-0,u.elements[14]=Ov.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let d=r.getRenderTarget(),f=r.getMRT(),p=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0;let m=t.name;t.name=(t.name||`Scene`)+` [ Reflector ]`,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),t.name=m,r.setMRT(f),r.setRenderTarget(d),r.autoClear=p,i.visible=!0,Fv=!1,this.forceUpdate=!1}get resolution(){return Ae(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale}set resolution(e){Ae(`ReflectorNode: The "resolution" property has been renamed to "resolutionScale".`),this.resolutionScale=e}},Rv=e=>new Iv(e),zv=new Li(-1,1,1,-1,0,1),Bv=new class extends nr{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new Wn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new Wn(t,2))}},Vv=class extends Or{constructor(e=null){super(Bv,e),this.camera=zv,this.isQuadMesh=!0}renderAsync(e){var t=this;return g(function*(){Ae(`QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.`),yield e.init(),e.render(t,zv)})()}render(e){e.render(this,zv)}},Hv=new it,Uv=class extends Zu{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:w}){let i=new Tt(t,n,r);super(i.texture,Ku()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new Vv(new zh),this.updateBeforeType=A.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){let t=e.getPixelRatio(),n=e.getSize(Hv),r=Math.floor(n.width*t),i=Math.floor(n.height*t);(r!==this.renderTarget.width||i!==this.renderTarget.height)&&(this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0)}let t=`RTT`;this.node.name&&(t=this.node.name+` [ `+t+` ]`),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=t;let n=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(n)}clone(){let e=new Zu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}},Wv=(e,...t)=>new Uv(N(e),...t),Gv=(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():Wv(e,...t),Kv=L(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===2001?(e=H(e.x,e.y.oneMinus()).mul(2).sub(1),i=W(U(e,t),1)):i=W(U(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=W(n.mul(i));return a.xyz.div(a.w)}),qv=L(([e,t])=>{let n=t.mul(W(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return H(r.x,r.y.oneMinus())}),Jv=L(([e,t,n])=>{let r=qu(td(t)),i=Go(e.mul(r)).toVar(),a=td(t,i).toVar(),o=td(t,i.sub(Go(2,0))).toVar(),s=td(t,i.sub(Go(1,0))).toVar(),c=td(t,i.add(Go(1,0))).toVar(),l=td(t,i.add(Go(2,0))).toVar(),u=td(t,i.add(Go(0,2))).toVar(),d=td(t,i.add(Go(0,1))).toVar(),f=td(t,i.sub(Go(0,1))).toVar(),p=td(t,i.sub(Go(0,2))).toVar(),m=Zc(q(z(2).mul(s).sub(o),a)).toVar(),h=Zc(q(z(2).mul(c).sub(l),a)).toVar(),g=Zc(q(z(2).mul(d).sub(u),a)).toVar(),_=Zc(q(z(2).mul(f).sub(p),a)).toVar(),v=Kv(e,a,n).toVar();return Uc(vl(m.lessThan(h).select(v.sub(Kv(e.sub(H(z(1).div(r.x),0)),s,n)),v.negate().add(Kv(e.add(H(z(1).div(r.x),0)),c,n))),g.lessThan(_).select(v.sub(Kv(e.add(H(0,z(1).div(r.y))),d,n)),v.negate().add(Kv(e.sub(H(0,z(1).div(r.y))),f,n)))))}),Yv=L(([e])=>Wc(z(52.9829189).mul(Wc(_l(e,H(.06711056,.00583715)))))).setLayout({name:`interleavedGradientNoise`,type:`float`,inputs:[{name:`position`,type:`vec2`}]}),Xv=L(([e,t,n])=>{let r=z(2.399963229728653),i=zc(z(e).add(.5).div(z(t))),a=z(e).mul(r).add(n);return H(Kc(a),Gc(a)).mul(i)}).setLayout({name:`vogelDiskSample`,type:`vec2`,inputs:[{name:`sampleIndex`,type:`int`},{name:`samplesCount`,type:`int`},{name:`phi`,type:`float`}]}),Zv=class extends j{static get type(){return`SampleNode`}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Ku())}sample(e){return this.callback(e)}},Qv=(e,t=null)=>new Zv(e,N(t)),$v=class e extends j{static get type(){return`EventNode`}constructor(t,n){super(`void`),this.eventType=t,this.callback=n,t===e.OBJECT?this.updateType=A.OBJECT:t===e.MATERIAL?this.updateType=A.RENDER:t===e.BEFORE_OBJECT?this.updateBeforeType=A.OBJECT:t===e.BEFORE_MATERIAL&&(this.updateBeforeType=A.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}};$v.OBJECT=`object`,$v.MATERIAL=`material`,$v.BEFORE_OBJECT=`beforeObject`,$v.BEFORE_MATERIAL=`beforeMaterial`;var ey=(e,t)=>new $v(e,t).toStack(),ty=e=>ey($v.OBJECT,e),ny=e=>ey($v.MATERIAL,e),ry=e=>ey($v.BEFORE_OBJECT,e),iy=e=>ey($v.BEFORE_MATERIAL,e),ay=class extends Mr{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},oy=class extends Vn{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}},sy=(e,t=`float`)=>{let n,r;return t.isStruct===!0?(n=t.layout.getLength(),r=Ca(`float`)):(n=wa(t),r=Ca(t)),Em(new oy(e,n,r),t,e)},cy=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=Ca(`float`)):(n=wa(t),r=Ca(t));let i=new ay(e,n,r);return Em(i,t,i.count)},ly=F(class extends j{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}}),uy=new It,dy=new k,fy=K(0).setGroup(G).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),py=K(1).setGroup(G).onRenderUpdate(({scene:e})=>e.backgroundIntensity),my=K(new k).setGroup(G).onRenderUpdate(({scene:e})=>{let t=e.background;return t!==null&&t.isTexture&&t.mapping!==300?(uy.copy(e.backgroundRotation),uy.x*=-1,uy.y*=-1,uy.z*=-1,dy.makeRotationFromEuler(uy)):dy.identity(),dy}),hy=P(class extends Zu{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=Pa.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}generateSnippet(e,t,n,r,i,a,o,s,c){let l=this.value;return e.generateStorageTextureLoad(l,t,n,r,a,c)}toReadWrite(){return this.setAccess(Pa.READ_WRITE)}toReadOnly(){return this.setAccess(Pa.READ_ONLY)}toWriteOnly(){return this.setAccess(Pa.WRITE_ONLY)}generateStore(e){let{uvNode:t,storeNode:n,depthNode:r}=e.getNodeProperties(this),i=super.generate(e,`property`),a=t.build(e,this.value.is3DTexture===!0?`uvec3`:`uvec2`),o=n.build(e,`vec4`),s=r?r.build(e,`int`):null,c=e.generateTextureStore(e,i,a,s,o);e.addLineFlowCode(c,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}).setParameterLength(1,3),gy=(e,t,n)=>{let r;return e.isStorageTextureNode===!0?(r=e.clone(),r.uvNode=t,r.storeNode=n):r=hy(e,t,n),n!==null&&r.toStack(),r},_y=L(({texture:e,uv:t})=>{let n=1e-4,r=U().toVar();return R(t.x.lessThan(n),()=>{r.assign(U(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(U(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(U(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(U(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(U(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(U(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(U(-.01,0,0))).r.sub(e.sample(t.add(U(n,0,0))).r),a=e.sample(t.add(U(0,-.01,0))).r.sub(e.sample(t.add(U(0,n,0))).r),o=e.sample(t.add(U(0,0,-.01))).r.sub(e.sample(t.add(U(0,0,n))).r);r.assign(U(i,a,o))}),r.normalize()}),vy=P(class extends Zu{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return U(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?`vec3`:`ivec3`)}generateOffset(e,t){return t.build(e,`ivec3`)}normal(e){return _y({texture:this,uv:e})}}).setParameterLength(1,3),yy=(...e)=>vy(...e).setSampler(!1),by=(e,t,n)=>vy(e,t).level(n),xy=class extends $f{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}},Sy=(e,t,n)=>new xy(e,t,n),Cy=new WeakMap,wy=class extends Ua{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=A.OBJECT,this.updateAfterType=A.OBJECT,this.previousModelWorldMatrix=K(new k),this.previousProjectionMatrix=K(new k).setGroup(G),this.previousCameraViewMatrix=K(new k)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=Ey(n);this.previousModelWorldMatrix.value.copy(r);let i=Ty(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new k,i.previousCameraViewMatrix=new k,i.currentProjectionMatrix=new k,i.currentCameraViewMatrix=new k,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Ey(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?Bd:K(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(df).mul(_f),r=this.previousProjectionMatrix.mul(t).mul(vf);return q(n.xy.div(n.w),r.xy.div(r.w))}};function Ty(e){let t=Cy.get(e);return t===void 0&&(t={},Cy.set(e,t)),t}function Ey(e,t=0){let n=Ty(e),r=n[t];return r===void 0&&(n[t]=r=new k,n[t].copy(e.matrixWorld)),r}var Dy=F(wy),Oy=L(([e])=>My(e.rgb)),ky=L(([e,t=z(1)])=>t.mix(My(e.rgb),e.rgb)),Ay=L(([e,t=z(1)])=>{let n=tc(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return El(e.rgb,r,i)}),jy=L(([e,t=z(1)])=>{let n=U(.57735,.57735,.57735),r=t.cos();return U(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(_l(n,e.rgb).mul(r.oneMinus())))))}),My=(e,t=U(pt.getLuminanceCoefficients(new O)))=>_l(e,t),Ny=L(([e,t=U(1),n=U(0),r=U(1),i=z(1),a=U(pt.getLuminanceCoefficients(new O,me))])=>{let o=e.rgb.dot(U(a)),s=fl(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return R(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),R(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),R(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),W(s.rgb,e.a)}),Py=L(([e,t])=>e.mul(t).floor().div(t)),Fy=null,Iy=P(class extends nh{static get type(){return`ViewportSharedTextureNode`}constructor(e=hd,t=null){Fy===null&&(Fy=new Xr),super(e,t,Fy)}getTextureForReference(){return Fy}updateReference(){return this}}).setParameterLength(0,2),Ly=new it,Ry=class extends Zu{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){let t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},zy=class extends Ry{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}},By=class e extends Ua{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new $r;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new Tt(this._width*this._pixelRatio,this._height*this._pixelRatio,m({type:w},r));a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=K(0),this._cameraFar=K(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=A.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return T(`PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead.`),this.setResolutionScale(e)}getResolution(){return T(`PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead.`),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=new zy(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new zy(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=hh(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=uh(i,n,r)}return t}compileAsync(e){var t=this;return g(function*(){let n=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(t.renderTarget),e.setMRT(t._mrt),yield e.compileAsync(t.scene,t.camera),e.setRenderTarget(n),e.setMRT(r)})()}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,this.renderTarget.texture.type=t.getOutputBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),Ly.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(Ly)),this._pixelRatio=i,this.setSize(Ly.width,Ly.height);let o=t.getRenderTarget(),s=t.getMRT(),c=t.autoClear,l=t.transparent,u=t.opaque,d=r.layers.mask,f=t.contextNode,p=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(let e in this._previousTextures)this.toggleTexture(e);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Bl(m(m({},t.contextNode.getFlowContextData()),this.contextNode.getFlowContextData()))}),t.contextNode=this._contextNodeCache.context);let h=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=h,n.overrideMaterial=p,t.setRenderTarget(o),t.setMRT(s),t.autoClear=c,t.transparent=l,t.opaque=u,t.contextNode=f,r.layers.mask=d}setSize(e,t){this._width=e,this._height=t;let n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new wt),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new wt),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};By.COLOR=`color`,By.DEPTH=`depth`;var Vy=(e,t,n)=>new By(By.COLOR,e,t,n),Hy=(e,t)=>new Ry(e,t),Uy=(e,t,n)=>new By(By.DEPTH,e,t,n),Wy=class extends By{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(By.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap,this.name=`Outline Pass`}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new zh;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=1;let t=Df.negate(),n=Bd.mul(df),r=z(1),i=n.mul(W(_f,1)),a=n.mul(W(_f.add(t),1)),o=Uc(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=W(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}},Gy=(e,t,n=new on(0,0,0),r=.003,i=1)=>new Wy(e,t,N(n),N(r),N(i)),Ky=L(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),qy=L(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Jy=L(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Yy=L(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),Xy=L(([e,t])=>{let n=ts(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=ts(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Yy(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Zy=ts(U(1.6605,-.1246,-.0182),U(-.5876,1.1329,-.1006),U(-.0728,-.0083,1.1187)),Qy=ts(U(.6274,.0691,.0164),U(.3293,.9195,.088),U(.0433,.0113,.8956)),$y=L(([e])=>{let t=U(e).toVar(),n=U(t.mul(t)).toVar(),r=U(n.mul(n)).toVar();return z(15.5).mul(r.mul(n)).sub(J(40.14,r.mul(t))).add(J(31.96,r).sub(J(6.868,n.mul(t))).add(J(.4298,n).add(J(.1191,t).sub(.00232))))}),eb=L(([e,t])=>{let n=U(e).toVar(),r=ts(U(.856627153315983,.137318972929847,.11189821299995),U(.0951212405381588,.761241990602591,.0767994186031903),U(.0482516061458583,.101439036467562,.811302368396859)),i=ts(U(1.1271005818144368,-.1413297634984383,-.14132976349843826),U(-.11060664309660323,1.157823702216272,-.11060664309660294),U(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=z(-12.47393),o=z(4.026069);return n.mulAssign(t),n.assign(Qy.mul(n)),n.assign(r.mul(n)),n.assign(fl(n,1e-10)),n.assign(Rc(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(Dl(n,0,1)),n.assign($y(n)),n.assign(i.mul(n)),n.assign(yl(fl(U(0),n),U(2.2))),n.assign(Zy.mul(n)),n.assign(Dl(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),tb=L(([e,t])=>{let n=z(.76),r=z(.15);e=e.mul(t);let i=dl(e.r,dl(e.g,e.b)),a=Rl(i.lessThan(.08),i.sub(J(6.25,i.mul(i))),.04);e.subAssign(a);let o=fl(e.r,fl(e.g,e.b));R(o.lessThan(n),()=>e);let s=q(1,n),c=q(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=q(1,nc(1,r.mul(o.sub(c)).add(1)));return El(e,U(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),nb=class extends j{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}},rb=P(nb).setParameterLength(1,3),ib=(e,t)=>rb(e,t,`js`),ab=(e,t)=>rb(e,t,`wgsl`),ob=(e,t)=>rb(e,t,`glsl`),sb=class extends nb{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a);return a.code=this.getNodeFunction(e).getCode(o)+`
|
|
299
|
+
`,t===`property`?o:e.format(`${o}()`,i,t)}},cb=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=new sb(e,t,n),i=(...e)=>r.call(...e);return i.functionNode=r,i},lb=(e,t)=>cb(e,t,`glsl`),ub=(e,t)=>cb(e,t,`wgsl`);function db(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||xf.z).negate()}var fb=L(([e,t],n)=>Al(e,t,db(n))),pb=L(([e],t)=>{let n=db(t);return e.mul(e,n,n).negate().exp().oneMinus()}),mb=L(([e,t],n)=>{let r=db(n),i=t.sub(yf.y).max(0).toConst().mul(r).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),hb=L(([e,t])=>W(t.toFloat().mix(Ms.rgb,e.toVec3()),Ms.a)),gb=null,_b=null,vb=P(class extends j{static get type(){return`RangeNode`}constructor(e=z(),t=z()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),r=e.getTypeLength(Da(t.value)),i=e.getTypeLength(Da(n.value));return r>i?r:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}getConstNode(e){let t=null;if(e.traverse(e=>{e.isConstNode===!0&&(t=e)}),t===null)throw new Yu(`THREE.TSL: No "ConstNode" found in node graph.`,this.stackTrace);return t}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.getConstNode(this.minNode),i=this.getConstNode(this.maxNode),a=r.value,o=i.value,s=e.getTypeLength(Da(a)),c=e.getTypeLength(Da(o));gb=gb||new wt,_b=_b||new wt,gb.setScalar(0),_b.setScalar(0),s===1?gb.setScalar(a):a.isColor?gb.set(a.r,a.g,a.b,1):gb.set(a.x,a.y,a.z||0,a.w||0),c===1?_b.setScalar(o):o.isColor?_b.set(o.r,o.g,o.b,1):_b.set(o.x,o.y,o.z||0,o.w||0);let l=4*t.count,u=new Float32Array(l);for(let e=0;e<l;e++){let t=e%4,n=gb.getComponent(t),r=_b.getComponent(t);u[e]=rt.lerp(n,r,Math.random())}let d=this.getNodeType(e);if(t.count*4*4<=e.getUniformBufferLimit())n=od(u,`vec4`,t.count).element(km).convert(d);else{let t=new Mr(u,4);e.geometry.setAttribute(`__range`+this.id,t),n=xu(t).convert(d)}}else n=z(0);return n}}).setParameterLength(2),yb=class extends j{static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(T(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}},bb=(e,t)=>new yb(e,t),xb=bb(`numWorkgroups`,`uvec3`),Sb=bb(`workgroupId`,`uvec3`),Cb=bb(`globalId`,`uvec3`),wb=bb(`localId`,`uvec3`),Tb=bb(`subgroupSize`,`uint`),Eb=P(class extends j{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}),Db=()=>Eb(`workgroup`).toStack(),Ob=()=>Eb(`storage`).toStack(),kb=()=>Eb(`texture`).toStack(),Ab=class extends Va{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},jb=class extends j{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=``}setName(e){return this.name=e,this}label(e){return T(`TSL: "label()" has been deprecated. Use "setName()" instead.`,new ha),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new Ab(this,e)}generate(e){let t=this.name===``?`${this.scope}Array_${this.id}`:this.name;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}},Mb=(e,t)=>new jb(`Workgroup`,e,t),Nb=class extends j{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`;if(n&&n.length===1&&n[0].isStackNode===!0)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=Nu(l,i).toConst()),t.constNode.build(e)}};Nb.ATOMIC_LOAD=`atomicLoad`,Nb.ATOMIC_STORE=`atomicStore`,Nb.ATOMIC_ADD=`atomicAdd`,Nb.ATOMIC_SUB=`atomicSub`,Nb.ATOMIC_MAX=`atomicMax`,Nb.ATOMIC_MIN=`atomicMin`,Nb.ATOMIC_AND=`atomicAnd`,Nb.ATOMIC_OR=`atomicOr`,Nb.ATOMIC_XOR=`atomicXor`;var Pb=P(Nb),Fb=(e,t,n)=>Pb(e,t,n).toStack(),Ib=e=>Fb(Nb.ATOMIC_LOAD,e,null),Lb=(e,t)=>Fb(Nb.ATOMIC_STORE,e,t),Rb=(e,t)=>Fb(Nb.ATOMIC_ADD,e,t),zb=(e,t)=>Fb(Nb.ATOMIC_SUB,e,t),Bb=(e,t)=>Fb(Nb.ATOMIC_MAX,e,t),Vb=(e,t)=>Fb(Nb.ATOMIC_MIN,e,t),Hb=(e,t)=>Fb(Nb.ATOMIC_AND,e,t),Ub=(e,t)=>Fb(Nb.ATOMIC_OR,e,t),Wb=(e,t)=>Fb(Nb.ATOMIC_XOR,e,t),Z=class e extends Ua{static get type(){return`SubgroupFunctionNode`}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(n)?0:e.getTypeLength(n))?t:n}getNodeType(t){let n=this.method;return n===e.SUBGROUP_ELECT?`bool`:n===e.SUBGROUP_BALLOT?`uvec4`:this.getInputType(t)}generate(t,n){let r=this.method,i=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,s=this.bNode,c=[];if(r===e.SUBGROUP_BROADCAST||r===e.SUBGROUP_SHUFFLE||r===e.QUAD_BROADCAST){let e=s.getNodeType(t);c.push(o.build(t,i),s.build(t,e===`float`?`int`:i))}else r===e.SUBGROUP_SHUFFLE_XOR||r===e.SUBGROUP_SHUFFLE_DOWN||r===e.SUBGROUP_SHUFFLE_UP?c.push(o.build(t,i),s.build(t,`uint`)):(o!==null&&c.push(o.build(t,a)),s!==null&&c.push(s.build(t,a)));let l=c.length===0?`()`:`( ${c.join(`, `)} )`;return t.format(`${t.getMethod(r,i)}${l}`,i,n)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Z.SUBGROUP_ELECT=`subgroupElect`,Z.SUBGROUP_BALLOT=`subgroupBallot`,Z.SUBGROUP_ADD=`subgroupAdd`,Z.SUBGROUP_INCLUSIVE_ADD=`subgroupInclusiveAdd`,Z.SUBGROUP_EXCLUSIVE_AND=`subgroupExclusiveAdd`,Z.SUBGROUP_MUL=`subgroupMul`,Z.SUBGROUP_INCLUSIVE_MUL=`subgroupInclusiveMul`,Z.SUBGROUP_EXCLUSIVE_MUL=`subgroupExclusiveMul`,Z.SUBGROUP_AND=`subgroupAnd`,Z.SUBGROUP_OR=`subgroupOr`,Z.SUBGROUP_XOR=`subgroupXor`,Z.SUBGROUP_MIN=`subgroupMin`,Z.SUBGROUP_MAX=`subgroupMax`,Z.SUBGROUP_ALL=`subgroupAll`,Z.SUBGROUP_ANY=`subgroupAny`,Z.SUBGROUP_BROADCAST_FIRST=`subgroupBroadcastFirst`,Z.QUAD_SWAP_X=`quadSwapX`,Z.QUAD_SWAP_Y=`quadSwapY`,Z.QUAD_SWAP_DIAGONAL=`quadSwapDiagonal`,Z.SUBGROUP_BROADCAST=`subgroupBroadcast`,Z.SUBGROUP_SHUFFLE=`subgroupShuffle`,Z.SUBGROUP_SHUFFLE_XOR=`subgroupShuffleXor`,Z.SUBGROUP_SHUFFLE_UP=`subgroupShuffleUp`,Z.SUBGROUP_SHUFFLE_DOWN=`subgroupShuffleDown`,Z.QUAD_BROADCAST=`quadBroadcast`;var Gb=I(Z,Z.SUBGROUP_ELECT).setParameterLength(0),Kb=I(Z,Z.SUBGROUP_BALLOT).setParameterLength(1),qb=I(Z,Z.SUBGROUP_ADD).setParameterLength(1),Jb=I(Z,Z.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),Yb=I(Z,Z.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),Xb=I(Z,Z.SUBGROUP_MUL).setParameterLength(1),Zb=I(Z,Z.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),Qb=I(Z,Z.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),$b=I(Z,Z.SUBGROUP_AND).setParameterLength(1),ex=I(Z,Z.SUBGROUP_OR).setParameterLength(1),tx=I(Z,Z.SUBGROUP_XOR).setParameterLength(1),nx=I(Z,Z.SUBGROUP_MIN).setParameterLength(1),rx=I(Z,Z.SUBGROUP_MAX).setParameterLength(1),ix=I(Z,Z.SUBGROUP_ALL).setParameterLength(0),ax=I(Z,Z.SUBGROUP_ANY).setParameterLength(0),ox=I(Z,Z.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),sx=I(Z,Z.QUAD_SWAP_X).setParameterLength(1),cx=I(Z,Z.QUAD_SWAP_Y).setParameterLength(1),lx=I(Z,Z.QUAD_SWAP_DIAGONAL).setParameterLength(1),ux=I(Z,Z.SUBGROUP_BROADCAST).setParameterLength(2),dx=I(Z,Z.SUBGROUP_SHUFFLE).setParameterLength(2),fx=I(Z,Z.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),px=I(Z,Z.SUBGROUP_SHUFFLE_UP).setParameterLength(2),mx=I(Z,Z.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),hx=I(Z,Z.QUAD_BROADCAST).setParameterLength(1),gx;function _x(e){gx=gx||new WeakMap;let t=gx.get(e);return t===void 0&&gx.set(e,t={}),t}function vx(e){let t=_x(e);return t.shadowMatrix||(t.shadowMatrix=K(`mat4`).setGroup(G).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function yx(e,t=yf){let n=vx(e).mul(t);return n.xyz.div(n.w)}function bx(e){let t=_x(e);return t.position||(t.position=K(new O).setGroup(G).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld)))}function xx(e){let t=_x(e);return t.targetPosition||(t.targetPosition=K(new O).setGroup(G).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld)))}function Sx(e){let t=_x(e);return t.viewPosition||(t.viewPosition=K(new O).setGroup(G).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new O,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}var Cx=e=>Hd.transformDirection(bx(e).sub(xx(e))),wx=e=>e.sort((e,t)=>e.id-t.id),Tx=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},Ex=new WeakMap,Dx=[],Ox=class extends j{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=us(`vec3`,`totalDiffuse`),this.totalSpecularNode=us(`vec3`,`totalSpecular`),this.outgoingLightNode=us(`vec3`,`outgoingLight`),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(Dx.push(n.id),Dx.push(+!!n.castShadow),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;Dx.push(e,t)}}let t=va(Dx);return Dx.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=wx(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(N(e));else{let r=null;if(n!==null&&(r=Tx(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){T(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;Ex.has(e)?r=Ex.get(e):(r=new n(e),Ex.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct(m(m({},n),{},{lightNode:t,reflectedLight:i}),e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea(m(m({},n),{},{lightNode:t,reflectedLight:i}),e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n,a.nodes=e.addStack().nodes,i.start(e);let{backdrop:s,backdropAlpha:c}=r,{directDiffuse:l,directSpecular:u,indirectDiffuse:d,indirectSpecular:f}=r.reflectedLight,p=l.add(d);s!==null&&(p=U(c===null?s:c.mix(p,s))),t.assign(p),o.assign(u.add(f)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}},kx=(e=[])=>new Ox().setLights(e),Ax=class extends j{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=A.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){jx.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||yf)}},jx=us(`vec3`,`shadowPositionWorld`);function Mx(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new on),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function Nx(e,t){return t=Mx(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Px(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function Fx(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function Ix(e,t){return t=Fx(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Lx(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Rx(e,t,n){return n=Nx(e,n),n=Ix(t,n),n}function zx(e,t,n){Px(e,n),Lx(t,n)}var Bx=new WeakMap,Vx=L(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=$u(e,t.xy).setName(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),Hx=L(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=$u(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=ep(`mapSize`,`vec2`,n).setGroup(G),o=ep(`radius`,`float`,n).setGroup(G),s=H(1).div(a),c=o.mul(s.x),l=Yv(_d.xy).mul(6.28318530718);return tc(i(t.xy.add(Xv(0,5,l).mul(c)),t.z),i(t.xy.add(Xv(1,5,l).mul(c)),t.z),i(t.xy.add(Xv(2,5,l).mul(c)),t.z),i(t.xy.add(Xv(3,5,l).mul(c)),t.z),i(t.xy.add(Xv(4,5,l).mul(c)),t.z)).mul(1/5)}),Ux=L(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=$u(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=ep(`mapSize`,`vec2`,n).setGroup(G),o=H(1).div(a),s=o.x,c=o.y,l=t.xy,u=Wc(l.mul(a).add(.5));return l.subAssign(u.mul(o)),tc(i(l,t.z),i(l.add(H(s,0)),t.z),i(l.add(H(0,c)),t.z),i(l.add(o),t.z),El(i(l.add(H(s.negate(),0)),t.z),i(l.add(H(s.mul(2),0)),t.z),u.x),El(i(l.add(H(s.negate(),c)),t.z),i(l.add(H(s.mul(2),c)),t.z),u.x),El(i(l.add(H(0,c.negate())),t.z),i(l.add(H(0,c.mul(2))),t.z),u.y),El(i(l.add(H(s,c.negate())),t.z),i(l.add(H(s,c.mul(2))),t.z),u.y),El(El(i(l.add(H(s.negate(),c.negate())),t.z),i(l.add(H(s.mul(2),c.negate())),t.z),u.x),El(i(l.add(H(s.negate(),c.mul(2))),t.z),i(l.add(H(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),Wx=L(({depthTexture:e,shadowCoord:t,depthLayer:n},r)=>{let i=$u(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=i.x,o=fl(1e-7,i.y.mul(i.y)),s=r.renderer.reversedDepthBuffer?pl(a,t.z):pl(t.z,a),c=z(1).toVar();return R(s.notEqual(1),()=>{let e=t.z.sub(a),n=o.div(o.add(e.mul(e)));n=Dl(q(n,.3).div(.65)),c.assign(fl(s,n))}),c}),Gx=e=>{let t=Bx.get(e);return t===void 0&&(t=new zh,t.colorNode=W(0,0,0,1),t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.blending=0,t.fog=!1,Bx.set(e,t)),t},Kx=e=>{let t=Bx.get(e);t!==void 0&&(t.dispose(),Bx.delete(e))},qx=new __,Jx=[],Yx=(e,t,n,r)=>{Jx[0]=e,Jx[1]=t;let i=qx.get(Jx);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===3)&&(r&&(ka(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,qx.set(Jx,i)),Jx[0]=null,Jx[1]=null,i},Xx=L(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=z(0).toVar(`meanVertical`),o=z(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(z(1)).select(z(0),z(2).div(e.sub(1))),c=e.lessThanEqual(z(1)).select(z(0),z(-1));return Um({start:B(0),end:B(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(z(e).mul(s)),u=r.sample(tc(_d.xy,H(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e),H(a,zc(o.sub(a.mul(a)).max(0)))}),Zx=L(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=z(0).toVar(`meanHorizontal`),o=z(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(z(1)).select(z(0),z(2).div(e.sub(1))),c=e.lessThanEqual(z(1)).select(z(0),z(-1));return Um({start:B(0),end:B(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(z(e).mul(s)),u=r.sample(tc(_d.xy,H(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(tc(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e),H(a,zc(o.sub(a.mul(a)).max(0)))}),Qx=[Vx,Hx,Ux,Wx],$x,eS=new Vv,tS=class extends Ax{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,z(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=n.biasNode||ep(`bias`,`float`,n).setGroup(G),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{let e=a.w;a=a.xy.div(e);let t=ep(`near`,`float`,n.camera).setGroup(G),r=ep(`far`,`float`,n.camera).setGroup(G);o=gh(e.negate(),t,r)}return a=U(a.x,a.y.oneMinus(),r.reversedDepthBuffer?o.sub(i):o.add(i)),a}getShadowFilterFn(e){return Qx[e]}setupRenderTarget(e,t){let n=new $r(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t,camera:n}=e,{light:r,shadow:i}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,e),s=t.shadowMap.type,c=t.hasCompatibility(Se.TEXTURE_COMPARE);if((s===1||s===2)&&c?(a.minFilter=x,a.magFilter=x):(a.minFilter=b,a.magFilter=b),i.camera.coordinateSystem=n.coordinateSystem,i.camera.updateProjectionMatrix(),s===3&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ae,type:w,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ae,type:w,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ae,type:w,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:ae,type:w,depthBuffer:!1}));let t=$u(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=$u(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let r=ep(`blurSamples`,`float`,i).setGroup(G),s=ep(`radius`,`float`,i).setGroup(G),c=ep(`mapSize`,`vec2`,i).setGroup(G),l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new zh);l.fragmentNode=Xx({samples:r,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new zh),l.fragmentNode=Zx({samples:r,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let l=ep(`intensity`,`float`,i).setGroup(G),u=ep(`normalBias`,`float`,i).setGroup(G),d=vx(r).mul(jx.add(Mf.mul(u))),f=this.setupShadowCoord(e,d),p=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(p===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let m=s===3&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,h=this.setupShadowFilter(e,{filterFn:p,shadowTexture:o.texture,depthTexture:m,shadowCoord:f,shadow:i,depthLayer:this.depthLayer}),g;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?g=Xf(o.texture,f.xyz):(g=$u(o.texture,f),a.isArrayTexture&&(g=g.depth(this.depthLayer))));let _;_=g?El(1,h.rgb.mix(g,1),l.mul(g.a)).toVar():El(1,h,l).toVar(),this.shadowMap=o,this.shadow.map=o;let v=`${this.light.type} Shadow [ ${this.light.name||`ID: `+this.light.id} ]`;return g&&_.toInspector(`${v} / Color`,()=>this.shadowMap.texture.isCubeTexture?Xf(this.shadowMap.texture):$u(this.shadowMap.texture)),_.toInspector(`${v} / Depth`,()=>this.shadowMap.texture.isCubeTexture?Xf(this.shadowMap.texture).r.oneMinus():td(this.shadowMap.depthTexture,Ku().mul(qu($u(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return L(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);let o=a.name;a.name=`Shadow Map [ ${r.name||`ID: `+r.id} ]`,i.render(a,t.camera),a.name=o}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;$x=Rx(i,a,$x),a.overrideMaterial=Gx(n),i.setRenderObjectFunction(Yx(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===3&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,zx(i,a,$x)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),eS.material=this.vsmMaterialVertical,eS.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),eS.material=this.vsmMaterialHorizontal,eS.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,Kx(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}},nS=(e,t)=>new tS(e,t),rS=new on,iS=new k,aS=new O,oS=new O,sS=[new O(1,0,0),new O(-1,0,0),new O(0,-1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)],cS=[new O(0,-1,0),new O(0,-1,0),new O(0,0,-1),new O(0,0,1),new O(0,-1,0),new O(0,-1,0)],lS=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],uS=[new O(0,-1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1),new O(0,-1,0),new O(0,-1,0)],dS=L(({depthTexture:e,bd3D:t,dp:n})=>Xf(e,t).compare(n)),fS=L(({depthTexture:e,bd3D:t,dp:n,shadow:r})=>{let i=ep(`radius`,`float`,r).setGroup(G),a=ep(`mapSize`,`vec2`,r).setGroup(G),o=i.div(a.x),s=Zc(t),c=Uc(vl(t,s.x.greaterThan(s.z).select(U(0,1,0),U(1,0,0)))),l=vl(t,c),u=Yv(_d.xy).mul(6.28318530718),d=Xv(0,5,u),f=Xv(1,5,u),p=Xv(2,5,u),m=Xv(3,5,u),h=Xv(4,5,u);return Xf(e,t.add(c.mul(d.x).add(l.mul(d.y)).mul(o))).compare(n).add(Xf(e,t.add(c.mul(f.x).add(l.mul(f.y)).mul(o))).compare(n)).add(Xf(e,t.add(c.mul(p.x).add(l.mul(p.y)).mul(o))).compare(n)).add(Xf(e,t.add(c.mul(m.x).add(l.mul(m.y)).mul(o))).compare(n)).add(Xf(e,t.add(c.mul(h.x).add(l.mul(h.y)).mul(o))).compare(n)).mul(1/5)}),pS=L(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r},i)=>{let a=n.xyz.toConst(),o=a.abs().toConst(),s=o.x.max(o.y).max(o.z),c=K(`float`).setGroup(G).onRenderUpdate(()=>r.camera.near),l=K(`float`).setGroup(G).onRenderUpdate(()=>r.camera.far),u=ep(`bias`,`float`,r).setGroup(G),d=z(1).toVar();return R(s.sub(l).lessThanEqual(0).and(s.sub(c).greaterThanEqual(0)),()=>{let n;i.renderer.reversedDepthBuffer?(n=mh(s.negate(),c,l),n.subAssign(u)):(n=ph(s.negate(),c,l),n.addAssign(u));let o=a.normalize();d.assign(e({depthTexture:t,bd3D:o,dp:n,shadow:r}))}),d}),mS=class extends tS{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===0?dS:fS}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i}){return pS({filterFn:t,depthTexture:n,shadowCoord:r,shadow:i})}setupRenderTarget(e,t){let n=new ei(e.mapSize.width);n.name=`PointShadowDepthTexture`,n.compareFunction=t.renderer.reversedDepthBuffer?518:515;let r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name=`PointShadowMap`,r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.camera,s=t.matrix,c=i.coordinateSystem===xe,l=c?sS:lS,u=c?cS:uS;n.setSize(t.mapSize.width,t.mapSize.width);let d=i.autoClear,f=i.getClearColor(rS),p=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(n,e),i.clear();let c=r.distance||o.far;c!==o.far&&(o.far=c,o.updateProjectionMatrix()),aS.setFromMatrixPosition(r.matrixWorld),o.position.copy(aS),oS.copy(o.position),oS.add(l[e]),o.up.copy(u[e]),o.lookAt(oS),o.updateMatrixWorld(),s.makeTranslation(-aS.x,-aS.y,-aS.z),iS.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(iS,o.coordinateSystem,o.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${r.name||`ID: `+r.id} ] - Face ${e+1}`,i.render(a,o),a.name=d}i.autoClear=d,i.setClearColor(f,p)}},hS=(e,t)=>new mS(e,t),gS=L(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),_S=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=gS({lightDistance:t.length(),cutoffDistance:n,decayExponent:r});return{lightDirection:i,lightColor:e.mul(a)}},vS=L(([e=Ku()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor();return n.add(r).mod(2).sign()}),yS=L(([e=Ku()],{renderer:t,material:n})=>{let r=Tl(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.currentSamples>0){let e=z(r.fwidth()).toVar();i=Al(e.oneMinus(),e.add(1),r).oneMinus()}else i=Rl(r.greaterThan(1),0,1);return i}),bS=L(([e,t,n])=>{let r=z(n).toVar(),i=z(t).toVar();return Rl(Wo(e).toVar(),i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),xS=L(([e,t])=>{let n=Wo(t).toVar(),r=z(e).toVar();return Rl(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),SS=L(([e])=>B(Vc(z(e).toVar()))).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),CS=L(([e,t])=>{let n=z(e).toVar();return t.assign(SS(n)),n.sub(z(t))}),wS=ov([L(([e,t,n,r,i,a])=>{let o=z(a).toVar(),s=z(i).toVar(),c=z(r).toVar(),l=z(n).toVar(),u=z(t).toVar(),d=z(e).toVar(),f=z(q(1,s)).toVar();return q(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),L(([e,t,n,r,i,a])=>{let o=z(a).toVar(),s=z(i).toVar(),c=U(r).toVar(),l=U(n).toVar(),u=U(t).toVar(),d=U(e).toVar(),f=z(q(1,s)).toVar();return q(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]})]),TS=ov([L(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=z(u).toVar(),f=z(l).toVar(),p=z(c).toVar(),m=z(s).toVar(),h=z(o).toVar(),g=z(a).toVar(),_=z(i).toVar(),v=z(r).toVar(),y=z(n).toVar(),b=z(t).toVar(),x=z(e).toVar(),S=z(q(1,p)).toVar(),C=z(q(1,f)).toVar();return z(q(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),L(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=z(u).toVar(),f=z(l).toVar(),p=z(c).toVar(),m=U(s).toVar(),h=U(o).toVar(),g=U(a).toVar(),_=U(i).toVar(),v=U(r).toVar(),y=U(n).toVar(),b=U(t).toVar(),x=U(e).toVar(),S=z(q(1,p)).toVar(),C=z(q(1,f)).toVar();return z(q(1,d)).toVar().mul(C.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(C.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]})]),ES=ov([L(([e,t,n])=>{let r=z(n).toVar(),i=z(t).toVar(),a=V(V(e).toVar().bitAnd(V(7))).toVar(),o=z(bS(a.lessThan(V(4)),i,r)).toVar(),s=z(J(2,bS(a.lessThan(V(4)),r,i))).toVar();return xS(o,Wo(a.bitAnd(V(1)))).add(xS(s,Wo(a.bitAnd(V(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),L(([e,t,n,r])=>{let i=z(r).toVar(),a=z(n).toVar(),o=z(t).toVar(),s=V(V(e).toVar().bitAnd(V(15))).toVar(),c=z(bS(s.lessThan(V(8)),o,a)).toVar(),l=z(bS(s.lessThan(V(4)),a,bS(s.equal(V(12)).or(s.equal(V(14))),o,i))).toVar();return xS(c,Wo(s.bitAnd(V(1)))).add(xS(l,Wo(s.bitAnd(V(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),DS=ov([L(([e,t,n])=>{let r=z(n).toVar(),i=z(t).toVar(),a=Yo(e).toVar();return U(ES(a.x,i,r),ES(a.y,i,r),ES(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),L(([e,t,n,r])=>{let i=z(r).toVar(),a=z(n).toVar(),o=z(t).toVar(),s=Yo(e).toVar();return U(ES(s.x,o,a,i),ES(s.y,o,a,i),ES(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]})]),OS=L(([e])=>J(.6616,z(e).toVar())).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),kS=L(([e])=>J(.982,z(e).toVar())).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),AS=ov([OS,L(([e])=>J(.6616,U(e).toVar())).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),jS=ov([kS,L(([e])=>J(.982,U(e).toVar())).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]})]),MS=L(([e,t])=>{let n=B(t).toVar(),r=V(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(B(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),NS=L(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(MS(n,B(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(MS(e,B(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(MS(t,B(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(MS(n,B(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(MS(e,B(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(MS(t,B(4))),t.addAssign(e)}),PS=L(([e,t,n])=>{let r=V(n).toVar(),i=V(t).toVar(),a=V(e).toVar();return r.bitXorAssign(i),r.subAssign(MS(i,B(14))),a.bitXorAssign(r),a.subAssign(MS(r,B(11))),i.bitXorAssign(a),i.subAssign(MS(a,B(25))),r.bitXorAssign(i),r.subAssign(MS(i,B(16))),a.bitXorAssign(r),a.subAssign(MS(r,B(4))),i.bitXorAssign(a),i.subAssign(MS(a,B(14))),r.bitXorAssign(i),r.subAssign(MS(i,B(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),FS=L(([e])=>z(V(e).toVar()).div(z(V(B(4294967295))))).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),IS=L(([e])=>{let t=z(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),LS=ov([L(([e])=>{let t=B(e).toVar(),n=V(V(1)).toVar(),r=V(V(B(3735928559)).add(n.shiftLeft(V(2))).add(V(13))).toVar();return PS(r.add(V(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),L(([e,t])=>{let n=B(t).toVar(),r=B(e).toVar(),i=V(V(2)).toVar(),a=V().toVar(),o=V().toVar(),s=V().toVar();return a.assign(o.assign(s.assign(V(B(3735928559)).add(i.shiftLeft(V(2))).add(V(13))))),a.addAssign(V(r)),o.addAssign(V(n)),PS(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),L(([e,t,n])=>{let r=B(n).toVar(),i=B(t).toVar(),a=B(e).toVar(),o=V(V(3)).toVar(),s=V().toVar(),c=V().toVar(),l=V().toVar();return s.assign(c.assign(l.assign(V(B(3735928559)).add(o.shiftLeft(V(2))).add(V(13))))),s.addAssign(V(a)),c.addAssign(V(i)),l.addAssign(V(r)),PS(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),L(([e,t,n,r])=>{let i=B(r).toVar(),a=B(n).toVar(),o=B(t).toVar(),s=B(e).toVar(),c=V(V(4)).toVar(),l=V().toVar(),u=V().toVar(),d=V().toVar();return l.assign(u.assign(d.assign(V(B(3735928559)).add(c.shiftLeft(V(2))).add(V(13))))),l.addAssign(V(s)),u.addAssign(V(o)),d.addAssign(V(a)),NS(l,u,d),l.addAssign(V(i)),PS(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),L(([e,t,n,r,i])=>{let a=B(i).toVar(),o=B(r).toVar(),s=B(n).toVar(),c=B(t).toVar(),l=B(e).toVar(),u=V(V(5)).toVar(),d=V().toVar(),f=V().toVar(),p=V().toVar();return d.assign(f.assign(p.assign(V(B(3735928559)).add(u.shiftLeft(V(2))).add(V(13))))),d.addAssign(V(l)),f.addAssign(V(c)),p.addAssign(V(s)),NS(d,f,p),d.addAssign(V(o)),f.addAssign(V(a)),PS(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]})]),RS=ov([L(([e,t])=>{let n=B(t).toVar(),r=V(LS(B(e).toVar(),n)).toVar(),i=Yo().toVar();return i.x.assign(r.bitAnd(B(255))),i.y.assign(r.shiftRight(B(8)).bitAnd(B(255))),i.z.assign(r.shiftRight(B(16)).bitAnd(B(255))),i}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),L(([e,t,n])=>{let r=B(n).toVar(),i=B(t).toVar(),a=V(LS(B(e).toVar(),i,r)).toVar(),o=Yo().toVar();return o.x.assign(a.bitAnd(B(255))),o.y.assign(a.shiftRight(B(8)).bitAnd(B(255))),o.z.assign(a.shiftRight(B(16)).bitAnd(B(255))),o}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]})]),zS=ov([L(([e])=>{let t=H(e).toVar(),n=B().toVar(),r=B().toVar(),i=z(CS(t.x,n)).toVar(),a=z(CS(t.y,r)).toVar(),o=z(IS(i)).toVar(),s=z(IS(a)).toVar();return AS(z(wS(ES(LS(n,r),i,a),ES(LS(n.add(B(1)),r),i.sub(1),a),ES(LS(n,r.add(B(1))),i,a.sub(1)),ES(LS(n.add(B(1)),r.add(B(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),L(([e])=>{let t=U(e).toVar(),n=B().toVar(),r=B().toVar(),i=B().toVar(),a=z(CS(t.x,n)).toVar(),o=z(CS(t.y,r)).toVar(),s=z(CS(t.z,i)).toVar(),c=z(IS(a)).toVar(),l=z(IS(o)).toVar(),u=z(IS(s)).toVar();return jS(z(TS(ES(LS(n,r,i),a,o,s),ES(LS(n.add(B(1)),r,i),a.sub(1),o,s),ES(LS(n,r.add(B(1)),i),a,o.sub(1),s),ES(LS(n.add(B(1)),r.add(B(1)),i),a.sub(1),o.sub(1),s),ES(LS(n,r,i.add(B(1))),a,o,s.sub(1)),ES(LS(n.add(B(1)),r,i.add(B(1))),a.sub(1),o,s.sub(1)),ES(LS(n,r.add(B(1)),i.add(B(1))),a,o.sub(1),s.sub(1)),ES(LS(n.add(B(1)),r.add(B(1)),i.add(B(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]})]),BS=ov([L(([e])=>{let t=H(e).toVar(),n=B().toVar(),r=B().toVar(),i=z(CS(t.x,n)).toVar(),a=z(CS(t.y,r)).toVar(),o=z(IS(i)).toVar(),s=z(IS(a)).toVar();return AS(U(wS(DS(RS(n,r),i,a),DS(RS(n.add(B(1)),r),i.sub(1),a),DS(RS(n,r.add(B(1))),i,a.sub(1)),DS(RS(n.add(B(1)),r.add(B(1))),i.sub(1),a.sub(1)),o,s)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),L(([e])=>{let t=U(e).toVar(),n=B().toVar(),r=B().toVar(),i=B().toVar(),a=z(CS(t.x,n)).toVar(),o=z(CS(t.y,r)).toVar(),s=z(CS(t.z,i)).toVar(),c=z(IS(a)).toVar(),l=z(IS(o)).toVar(),u=z(IS(s)).toVar();return jS(U(TS(DS(RS(n,r,i),a,o,s),DS(RS(n.add(B(1)),r,i),a.sub(1),o,s),DS(RS(n,r.add(B(1)),i),a,o.sub(1),s),DS(RS(n.add(B(1)),r.add(B(1)),i),a.sub(1),o.sub(1),s),DS(RS(n,r,i.add(B(1))),a,o,s.sub(1)),DS(RS(n.add(B(1)),r,i.add(B(1))),a.sub(1),o,s.sub(1)),DS(RS(n,r.add(B(1)),i.add(B(1))),a,o.sub(1),s.sub(1)),DS(RS(n.add(B(1)),r.add(B(1)),i.add(B(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar())}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]})]),VS=ov([L(([e])=>FS(LS(B(SS(z(e).toVar())).toVar()))).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),L(([e])=>{let t=H(e).toVar();return FS(LS(B(SS(t.x)).toVar(),B(SS(t.y)).toVar()))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),L(([e])=>{let t=U(e).toVar();return FS(LS(B(SS(t.x)).toVar(),B(SS(t.y)).toVar(),B(SS(t.z)).toVar()))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),L(([e])=>{let t=W(e).toVar();return FS(LS(B(SS(t.x)).toVar(),B(SS(t.y)).toVar(),B(SS(t.z)).toVar(),B(SS(t.w)).toVar()))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]})]),HS=ov([L(([e])=>{let t=B(SS(z(e).toVar())).toVar();return U(FS(LS(t,B(0))),FS(LS(t,B(1))),FS(LS(t,B(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),L(([e])=>{let t=H(e).toVar(),n=B(SS(t.x)).toVar(),r=B(SS(t.y)).toVar();return U(FS(LS(n,r,B(0))),FS(LS(n,r,B(1))),FS(LS(n,r,B(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),L(([e])=>{let t=U(e).toVar(),n=B(SS(t.x)).toVar(),r=B(SS(t.y)).toVar(),i=B(SS(t.z)).toVar();return U(FS(LS(n,r,i,B(0))),FS(LS(n,r,i,B(1))),FS(LS(n,r,i,B(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),L(([e])=>{let t=W(e).toVar(),n=B(SS(t.x)).toVar(),r=B(SS(t.y)).toVar(),i=B(SS(t.z)).toVar(),a=B(SS(t.w)).toVar();return U(FS(LS(n,r,i,a,B(0))),FS(LS(n,r,i,a,B(1))),FS(LS(n,r,i,a,B(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]})]),US=L(([e,t,n,r])=>{let i=z(r).toVar(),a=z(n).toVar(),o=B(t).toVar(),s=U(e).toVar(),c=z(0).toVar(),l=z(1).toVar();return Um(o,()=>{c.addAssign(l.mul(zS(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),WS=L(([e,t,n,r])=>{let i=z(r).toVar(),a=z(n).toVar(),o=B(t).toVar(),s=U(e).toVar(),c=U(0).toVar(),l=z(1).toVar();return Um(o,()=>{c.addAssign(l.mul(BS(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),GS=L(([e,t,n,r])=>{let i=z(r).toVar(),a=z(n).toVar(),o=B(t).toVar(),s=U(e).toVar();return H(US(s,o,a,i),US(s.add(U(B(19),B(193),B(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),KS=L(([e,t,n,r])=>{let i=z(r).toVar(),a=z(n).toVar(),o=B(t).toVar(),s=U(e).toVar();return W(U(WS(s,o,a,i)).toVar(),z(US(s.add(U(B(19),B(193),B(17))),o,a,i)).toVar())}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),qS=ov([L(([e,t,n,r,i,a,o])=>{let s=B(o).toVar(),c=z(a).toVar(),l=B(i).toVar(),u=B(r).toVar(),d=B(n).toVar(),f=B(t).toVar(),p=H(e).toVar(),m=U(HS(H(f.add(u),d.add(l)))).toVar(),h=H(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=H(H(H(z(f),z(d)).add(h)).toVar().sub(p)).toVar();return R(s.equal(B(2)),()=>Zc(g.x).add(Zc(g.y))),R(s.equal(B(3)),()=>fl(Zc(g.x),Zc(g.y))),_l(g,g)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),L(([e,t,n,r,i,a,o,s,c])=>{let l=B(c).toVar(),u=z(s).toVar(),d=B(o).toVar(),f=B(a).toVar(),p=B(i).toVar(),m=B(r).toVar(),h=B(n).toVar(),g=B(t).toVar(),_=U(e).toVar(),v=U(HS(U(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=U(U(U(z(g),z(h),z(m)).add(v)).toVar().sub(_)).toVar();return R(l.equal(B(2)),()=>Zc(y.x).add(Zc(y.y)).add(Zc(y.z))),R(l.equal(B(3)),()=>fl(Zc(y.x),Zc(y.y),Zc(y.z))),_l(y,y)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),JS=L(([e,t,n])=>{let r=B(n).toVar(),i=z(t).toVar(),a=H(e).toVar(),o=B().toVar(),s=B().toVar(),c=H(CS(a.x,o),CS(a.y,s)).toVar(),l=z(1e6).toVar();return Um({start:-1,end:B(1),name:`x`,condition:`<=`},({x:e})=>{Um({start:-1,end:B(1),name:`y`,condition:`<=`},({y:t})=>{let n=z(qS(c,e,t,o,s,i,r)).toVar();l.assign(dl(l,n))})}),R(r.equal(B(0)),()=>{l.assign(zc(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),YS=L(([e,t,n])=>{let r=B(n).toVar(),i=z(t).toVar(),a=H(e).toVar(),o=B().toVar(),s=B().toVar(),c=H(CS(a.x,o),CS(a.y,s)).toVar(),l=H(1e6,1e6).toVar();return Um({start:-1,end:B(1),name:`x`,condition:`<=`},({x:e})=>{Um({start:-1,end:B(1),name:`y`,condition:`<=`},({y:t})=>{let n=z(qS(c,e,t,o,s,i,r)).toVar();R(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),R(r.equal(B(0)),()=>{l.assign(zc(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),XS=L(([e,t,n])=>{let r=B(n).toVar(),i=z(t).toVar(),a=H(e).toVar(),o=B().toVar(),s=B().toVar(),c=H(CS(a.x,o),CS(a.y,s)).toVar(),l=U(1e6,1e6,1e6).toVar();return Um({start:-1,end:B(1),name:`x`,condition:`<=`},({x:e})=>{Um({start:-1,end:B(1),name:`y`,condition:`<=`},({y:t})=>{let n=z(qS(c,e,t,o,s,i,r)).toVar();R(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),R(r.equal(B(0)),()=>{l.assign(zc(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),ZS=ov([JS,L(([e,t,n])=>{let r=B(n).toVar(),i=z(t).toVar(),a=U(e).toVar(),o=B().toVar(),s=B().toVar(),c=B().toVar(),l=U(CS(a.x,o),CS(a.y,s),CS(a.z,c)).toVar(),u=z(1e6).toVar();return Um({start:-1,end:B(1),name:`x`,condition:`<=`},({x:e})=>{Um({start:-1,end:B(1),name:`y`,condition:`<=`},({y:t})=>{Um({start:-1,end:B(1),name:`z`,condition:`<=`},({z:n})=>{let a=z(qS(l,e,t,n,o,s,c,i,r)).toVar();u.assign(dl(u,a))})})}),R(r.equal(B(0)),()=>{u.assign(zc(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),QS=ov([YS,L(([e,t,n])=>{let r=B(n).toVar(),i=z(t).toVar(),a=U(e).toVar(),o=B().toVar(),s=B().toVar(),c=B().toVar(),l=U(CS(a.x,o),CS(a.y,s),CS(a.z,c)).toVar(),u=H(1e6,1e6).toVar();return Um({start:-1,end:B(1),name:`x`,condition:`<=`},({x:e})=>{Um({start:-1,end:B(1),name:`y`,condition:`<=`},({y:t})=>{Um({start:-1,end:B(1),name:`z`,condition:`<=`},({z:n})=>{let a=z(qS(l,e,t,n,o,s,c,i,r)).toVar();R(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),R(r.equal(B(0)),()=>{u.assign(zc(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),$S=ov([XS,L(([e,t,n])=>{let r=B(n).toVar(),i=z(t).toVar(),a=U(e).toVar(),o=B().toVar(),s=B().toVar(),c=B().toVar(),l=U(CS(a.x,o),CS(a.y,s),CS(a.z,c)).toVar(),u=U(1e6,1e6,1e6).toVar();return Um({start:-1,end:B(1),name:`x`,condition:`<=`},({x:e})=>{Um({start:-1,end:B(1),name:`y`,condition:`<=`},({y:t})=>{Um({start:-1,end:B(1),name:`z`,condition:`<=`},({z:n})=>{let a=z(qS(l,e,t,n,o,s,c,i,r)).toVar();R(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),R(r.equal(B(0)),()=>{u.assign(zc(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]})]),eC=L(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=B(e).toVar(),f=H(t).toVar(),p=H(n).toVar(),m=H(r).toVar(),h=z(i).toVar(),g=z(a).toVar(),_=z(o).toVar(),v=Wo(s).toVar(),y=B(c).toVar(),b=z(l).toVar(),x=z(u).toVar(),S=f.mul(p).add(m),C=z(0).toVar();return R(d.equal(B(0)),()=>{C.assign(BS(S))}),R(d.equal(B(1)),()=>{C.assign(HS(S))}),R(d.equal(B(2)),()=>{C.assign($S(S,h,B(0)))}),R(d.equal(B(3)),()=>{C.assign(WS(U(S,0),y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),R(v,()=>{C.assign(Dl(C,g,_))}),C}).setLayout({name:`mx_unifiednoise2d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`texcoord`,type:`vec2`},{name:`freq`,type:`vec2`},{name:`offset`,type:`vec2`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),tC=L(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=B(e).toVar(),f=U(t).toVar(),p=U(n).toVar(),m=U(r).toVar(),h=z(i).toVar(),g=z(a).toVar(),_=z(o).toVar(),v=Wo(s).toVar(),y=B(c).toVar(),b=z(l).toVar(),x=z(u).toVar(),S=f.mul(p).add(m),C=z(0).toVar();return R(d.equal(B(0)),()=>{C.assign(BS(S))}),R(d.equal(B(1)),()=>{C.assign(HS(S))}),R(d.equal(B(2)),()=>{C.assign($S(S,h,B(0)))}),R(d.equal(B(3)),()=>{C.assign(WS(S,y,b,x))}),C.assign(C.mul(_.sub(g)).add(g)),R(v,()=>{C.assign(Dl(C,g,_))}),C}).setLayout({name:`mx_unifiednoise3d`,type:`float`,inputs:[{name:`noiseType`,type:`int`},{name:`position`,type:`vec3`},{name:`freq`,type:`vec3`},{name:`offset`,type:`vec3`},{name:`jitter`,type:`float`},{name:`outmin`,type:`float`},{name:`outmax`,type:`float`},{name:`clampoutput`,type:`bool`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),nC=L(([e])=>{let t=e.y,n=e.z,r=U().toVar();return R(t.lessThan(1e-4),()=>{r.assign(U(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(Vc(i)).mul(6).toVar();let a=B(ol(i)),o=i.sub(z(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());R(a.equal(B(0)),()=>{r.assign(U(n,l,s))}).ElseIf(a.equal(B(1)),()=>{r.assign(U(c,n,s))}).ElseIf(a.equal(B(2)),()=>{r.assign(U(s,n,l))}).ElseIf(a.equal(B(3)),()=>{r.assign(U(s,c,n))}).ElseIf(a.equal(B(4)),()=>{r.assign(U(l,s,n))}).Else(()=>{r.assign(U(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),rC=L(([e])=>{let t=U(e).toVar(),n=z(t.x).toVar(),r=z(t.y).toVar(),i=z(t.z).toVar(),a=z(dl(n,dl(r,i))).toVar(),o=z(fl(n,fl(r,i))).toVar(),s=z(o.sub(a)).toVar(),c=z().toVar(),l=z().toVar(),u=z().toVar();return u.assign(o),R(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),R(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{R(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(tc(2,i.sub(n).div(s)))}).Else(()=>{c.assign(tc(4,n.sub(r).div(s)))}),c.mulAssign(1/6),R(c.lessThan(0),()=>{c.addAssign(1)})}),U(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),iC=L(([e])=>{let t=U(e).toVar(),n=Xo(sc(t,U(.04045))).toVar();return El(U(t.div(12.92)).toVar(),U(yl(fl(t.add(U(.055)),U(0)).div(1.055),U(2.4))).toVar(),n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),aC=(e,t)=>{e=z(e),t=z(t);let n=H(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Al(e.sub(n),e.add(n),t)},oC=(e,t,n,r)=>El(e,t,n[r].clamp()),sC=(e,t,n=Ku())=>oC(e,t,n,`x`),cC=(e,t,n=Ku())=>oC(e,t,n,`y`),lC=(e,t,n,r,i=Ku())=>{let a=i.x.clamp(),o=i.y.clamp();return El(El(e,t,a),El(n,r,a),o)},uC=(e,t,n,r,i)=>El(e,t,aC(n,r[i])),Q=Object.freeze({__proto__:null,BRDF_GGX:Xh,BRDF_Lambert:Hh,BasicPointShadowFilter:dS,BasicShadowFilter:Vx,Break:Gm,Const:Jl,Continue:Wm,DFGLUT:$h,D_GGX:qh,Discard:Pu,EPSILON:Tc,F_Schlick:Vh,Fn:L,HALF_PI:Ac,INFINITY:Ec,If:R,Loop:Um,NodeAccess:Pa,NodeShaderStage:Ma,NodeType:Na,NodeUpdateType:A,OnBeforeMaterialUpdate:iy,OnBeforeObjectUpdate:ry,OnMaterialUpdate:ny,OnObjectUpdate:ty,PCFShadowFilter:Hx,PCFSoftShadowFilter:Ux,PI:Dc,PI2:Oc,PointShadowFilter:fS,Return:Fu,Schlick_to_F0:eg,ShaderNode:No,Stack:Ho,Switch:Vo,TBNViewMatrix:Dp,TWO_PI:kc,VSMShadowFilter:Wx,V_GGX_SmithCorrelated:Gh,Var:ql,VarIntent:Yl,abs:Zc,acesFilmicToneMapping:Xy,acos:Yc,add:tc,addMethodChaining:M,addNodeElement:Uu,agxToneMapping:eb,all:jc,alphaT:ws,and:uc,anisotropy:Ts,anisotropyB:Ds,anisotropyT:Es,any:Mc,append:cs,array:Ys,arrayBuffer:is,asin:Jc,assign:Xs,atan:Xc,atomicAdd:Rb,atomicAnd:Hb,atomicFunc:Fb,atomicLoad:Ib,atomicMax:Bb,atomicMin:Vb,atomicOr:Ub,atomicStore:Lb,atomicSub:zb,atomicXor:Wb,attenuationColor:Bs,attenuationDistance:zs,attribute:Gu,attributeArray:sy,backgroundBlurriness:fy,backgroundIntensity:py,backgroundRotation:my,batch:Lm,bentNormalView:Ap,billboarding:_v,bitAnd:mc,bitNot:hc,bitOr:gc,bitXor:_c,bitangentGeometry:Cp,bitangentLocal:wp,bitangentView:Tp,bitangentWorld:Ep,bitcast:N_,blendBurn:Mh,blendColor:Ih,blendDodge:Nh,blendOverlay:Fh,blendScreen:Ph,blur:Mg,bool:Wo,buffer:od,bufferAttribute:yu,builtin:ud,builtinAOContext:Wl,builtinShadowContext:Ul,bumpMap:Lp,bvec2:qo,bvec3:Xo,bvec4:$o,bypass:ku,cache:Ou,call:Qs,cameraFar:zd,cameraIndex:Ld,cameraNear:Rd,cameraNormalMatrix:Wd,cameraPosition:Gd,cameraProjectionMatrix:Bd,cameraProjectionMatrixInverse:Vd,cameraViewMatrix:Hd,cameraViewport:Kd,cameraWorldMatrix:Ud,cbrt:wl,cdl:Ny,ceil:Hc,checker:vS,cineonToneMapping:Jy,clamp:Dl,clearcoat:_s,clearcoatNormalView:Nf,clearcoatRoughness:vs,clipSpace:hf,code:rb,color:Uo,colorSpaceToWorking:ou,colorToDirection:Mp,compute:Tu,computeKernel:wu,computeSkinning:Vm,context:Bl,convert:os,convertColorSpace:su,convertToTexture:Gv,cos:Kc,countLeadingZeros:V_,countOneBits:H_,countTrailingZeros:B_,cross:vl,cubeTexture:Xf,cubeTextureBase:Yf,dFdx:nl,dFdy:rl,dashSize:Ns,debug:zu,decrement:Cc,decrementBefore:xc,defaultBuildStages:Ia,defaultShaderStages:Fa,defined:jo,degrees:Pc,deltaTime:cv,densityFogFactor:pb,depth:yh,depthPass:Uy,determinant:ll,difference:gl,diffuseColor:fs,diffuseContribution:ps,directPointLight:_S,directionToColor:jp,directionToFaceDirection:Tf,dispersion:Vs,disposeShadowMaterial:Kx,distance:hl,div:nc,dot:_l,drawIndex:Nm,dynamicBufferAttribute:bu,element:as,emissive:ms,equal:ic,equirectUV:Bh,exp:Fc,exp2:Ic,exponentialHeightFogFactor:mb,expression:Nu,faceDirection:wf,faceForward:jl,faceforward:Il,float:z,floatBitsToInt:P_,floatBitsToUint:F_,floor:Vc,fog:hb,fract:Wc,frameGroup:Gs,frameId:lv,frontFacing:Cf,fwidth:sl,gain:G_,gapSize:Ps,getConstNodeType:Mo,getCurrentStack:Bo,getDirection:Og,getDistanceAttenuation:gS,getGeometryRoughness:Uh,getNormalFromDepth:Jv,getParallaxCorrectNormal:L(([e,t,n])=>{let r=Uc(e).toVar(),i=q(z(.5).mul(t.sub(n)),yf).div(r).toVar(),a=q(z(-.5).mul(t.sub(n)),yf).div(r).toVar(),o=U().toVar();o.x=r.x.greaterThan(z(0)).select(i.x,a.x),o.y=r.y.greaterThan(z(0)).select(i.y,a.y),o.z=r.z.greaterThan(z(0)).select(i.z,a.z);let s=dl(o.x,o.y,o.z).toVar();return yf.add(r.mul(s)).toVar().sub(n)}),getRoughness:Wh,getScreenPosition:qv,getShIrradianceAt:L(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(J(n,n).sub(J(r,r)))),a}),getShadowMaterial:Gx,getShadowRenderObjectFunction:Yx,getTextureIndex:A_,getViewPosition:Kv,ggxConvolution:Ig,globalId:Cb,glsl:ob,glslFn:lb,grayscale:Oy,greaterThan:sc,greaterThanEqual:lc,hash:U_,highpModelNormalViewMatrix:mf,highpModelViewMatrix:pf,hue:jy,increment:Sc,incrementBefore:bc,inspector:Hu,instance:Fm,instanceIndex:km,instancedArray:cy,instancedBufferAttribute:xu,instancedDynamicBufferAttribute:Su,instancedMesh:Im,int:B,intBitsToFloat:I_,interleavedGradientNoise:Yv,inverse:ul,inverseSqrt:Bc,inversesqrt:Ll,invocationLocalIndex:Mm,invocationSubgroupIndex:jm,ior:Is,iridescence:xs,iridescenceIOR:Ss,iridescenceThickness:Cs,isolate:Du,ivec2:Go,ivec3:Jo,ivec4:Zo,js:ib,label:Gl,length:$c,lengthSq:Tl,lessThan:oc,lessThanEqual:cc,lightPosition:bx,lightProjectionUV:yx,lightShadowMatrix:vx,lightTargetDirection:Cx,lightTargetPosition:xx,lightViewPosition:Sx,lightingContext:$m,lights:kx,linearDepth:bh,linearToneMapping:Ky,localId:wb,log:Lc,log2:Rc,logarithmicDepthToViewZ:_h,luminance:My,mat2:es,mat3:ts,mat4:ns,matcapUV:h_,materialAO:xm,materialAlphaTest:zp,materialAnisotropy:im,materialAnisotropyVector:Sm,materialAttenuationColor:fm,materialAttenuationDistance:dm,materialClearcoat:Qp,materialClearcoatNormal:em,materialClearcoatRoughness:$p,materialColor:Bp,materialDispersion:ym,materialEmissive:Hp,materialEnvIntensity:Hf,materialEnvRotation:Uf,materialIOR:um,materialIridescence:am,materialIridescenceIOR:om,materialIridescenceThickness:sm,materialLightMap:bm,materialLineDashOffset:_m,materialLineDashSize:mm,materialLineGapSize:hm,materialLineScale:pm,materialLineWidth:gm,materialMetalness:Xp,materialNormal:Zp,materialOpacity:Up,materialPointSize:vm,materialReference:rp,materialReflectivity:Jp,materialRefractionRatio:Vf,materialRotation:tm,materialRoughness:Yp,materialSheen:nm,materialSheenRoughness:rm,materialShininess:Vp,materialSpecular:Wp,materialSpecularColor:Kp,materialSpecularIntensity:Gp,materialSpecularStrength:qp,materialThickness:lm,materialTransmission:cm,max:fl,maxMipLevel:Ju,mediumpModelViewMatrix:ff,metalness:gs,min:dl,mix:El,mixElement:Nl,mod:rc,modInt:wc,modelDirection:nf,modelNormalMatrix:lf,modelPosition:af,modelRadius:cf,modelScale:of,modelViewMatrix:df,modelViewPosition:sf,modelViewProjection:Cm,modelWorldMatrix:rf,modelWorldMatrixInverse:uf,morphReference:Xm,mrt:j_,mul:J,mx_aastep:aC,mx_add:(e,t=z(0))=>tc(e,t),mx_atan2:(e=z(0),t=z(1))=>Xc(e,t),mx_cell_noise_float:(e=Ku())=>VS(e.convert(`vec2|vec3`)),mx_contrast:(e,t=1,n=.5)=>z(e).sub(n).mul(t).add(n),mx_divide:(e,t=z(1))=>nc(e,t),mx_fractal_noise_float:(e=Ku(),t=3,n=2,r=.5,i=1)=>US(e,B(t),n,r).mul(i),mx_fractal_noise_vec2:(e=Ku(),t=3,n=2,r=.5,i=1)=>GS(e,B(t),n,r).mul(i),mx_fractal_noise_vec3:(e=Ku(),t=3,n=2,r=.5,i=1)=>WS(e,B(t),n,r).mul(i),mx_fractal_noise_vec4:(e=Ku(),t=3,n=2,r=.5,i=1)=>KS(e,B(t),n,r).mul(i),mx_frame:()=>lv,mx_heighttonormal:(e,t)=>(e=U(e),t=z(t),Lp(e,t)),mx_hsvtorgb:nC,mx_ifequal:(e,t,n,r)=>e.equal(t).mix(n,r),mx_ifgreater:(e,t,n,r)=>e.greaterThan(t).mix(n,r),mx_ifgreatereq:(e,t,n,r)=>e.greaterThanEqual(t).mix(n,r),mx_invert:(e,t=z(1))=>q(t,e),mx_modulo:(e,t=z(1))=>rc(e,t),mx_multiply:(e,t=z(1))=>J(e,t),mx_noise_float:(e=Ku(),t=1,n=0)=>zS(e.convert(`vec2|vec3`)).mul(t).add(n),mx_noise_vec3:(e=Ku(),t=1,n=0)=>BS(e.convert(`vec2|vec3`)).mul(t).add(n),mx_noise_vec4:(e=Ku(),t=1,n=0)=>(e=e.convert(`vec2|vec3`),W(BS(e),zS(e.add(H(19,73)))).mul(t).add(n)),mx_place2d:(e,t=H(.5,.5),n=H(1,1),r=z(0),i=H(0,0))=>{let a=e;if(t&&(a=a.sub(t)),n&&(a=a.mul(n)),r){let e=r.mul(Math.PI/180),t=e.cos(),n=e.sin();a=H(a.x.mul(t).sub(a.y.mul(n)),a.x.mul(n).add(a.y.mul(t)))}return t&&(a=a.add(t)),i&&(a=a.add(i)),a},mx_power:(e,t=z(1))=>yl(e,t),mx_ramp4:lC,mx_ramplr:sC,mx_ramptb:cC,mx_rgbtohsv:rC,mx_rotate2d:(e,t)=>{e=H(e),t=z(t);let n=t.mul(Math.PI/180);return g_(e,n)},mx_rotate3d:(e,t,n)=>{e=U(e),t=z(t),n=U(n);let r=t.mul(Math.PI/180),i=n.normalize(),a=r.cos(),o=r.sin(),s=z(1).sub(a);return e.mul(a).add(i.cross(e).mul(o)).add(i.mul(i.dot(e)).mul(s))},mx_safepower:(e,t=1)=>(e=z(e),e.abs().pow(t).mul(e.sign())),mx_separate:(e,t=null)=>{if(typeof t==`string`){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=t.replace(/^out/,``).toLowerCase();if(n[r]!==void 0)return e.element(n[r])}if(typeof t==`number`)return e.element(t);if(typeof t==`string`&&t.length===1){let n={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(n[t]!==void 0)return e.element(n[t])}return e},mx_splitlr:(e,t,n,r=Ku())=>uC(e,t,n,r,`x`),mx_splittb:(e,t,n,r=Ku())=>uC(e,t,n,r,`y`),mx_srgb_texture_to_lin_rec709:iC,mx_subtract:(e,t=z(0))=>q(e,t),mx_timer:()=>sv,mx_transform_uv:(e=1,t=0,n=Ku())=>n.mul(e).add(t),mx_unifiednoise2d:(e,t=Ku(),n=H(1,1),r=H(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>eC(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),mx_unifiednoise3d:(e,t=Ku(),n=H(1,1),r=H(0,0),i=1,a=0,o=1,s=!1,c=1,l=2,u=.5)=>tC(e,t.convert(`vec2|vec3`),n,r,i,a,o,s,c,l,u),mx_worley_noise_float:(e=Ku(),t=1)=>ZS(e.convert(`vec2|vec3`),t,B(1)),mx_worley_noise_vec2:(e=Ku(),t=1)=>QS(e.convert(`vec2|vec3`),t,B(1)),mx_worley_noise_vec3:(e=Ku(),t=1)=>$S(e.convert(`vec2|vec3`),t,B(1)),negate:el,neutralToneMapping:tb,nodeArray:Io,nodeImmutable:F,nodeObject:N,nodeObjectIntent:Po,nodeObjects:Fo,nodeProxy:P,nodeProxyIntent:I,normalFlat:Of,normalGeometry:Ef,normalLocal:Df,normalMap:Pp,normalView:jf,normalViewGeometry:kf,normalWorld:Mf,normalWorldGeometry:Af,normalize:Uc,not:fc,notEqual:ac,numWorkgroups:xb,objectDirection:Yd,objectGroup:Ks,objectPosition:Zd,objectRadius:ef,objectScale:Qd,objectViewPosition:$d,objectWorldMatrix:Xd,oneMinus:tl,or:dc,orthographicDepthToViewZ:fh,oscSawtooth:pv,oscSine:uv,oscSquare:dv,oscTriangle:fv,output:Ms,outputStruct:E_,overloadingFn:ov,packHalf2x16:Z_,packSnorm2x16:Y_,packUnorm2x16:X_,parabola:W_,parallaxDirection:Op,parallaxUV:kp,parameter:y_,pass:Vy,passTexture:Hy,pcurve:K_,perspectiveDepthToViewZ:hh,pmremTexture:m_,pointShadow:hS,pointUV:ly,pointWidth:Fs,positionGeometry:gf,positionLocal:_f,positionPrevious:vf,positionView:xf,positionViewDirection:Sf,positionWorld:yf,positionWorldDirection:bf,posterize:Py,pow:yl,pow2:bl,pow3:xl,pow4:Sl,premultiplyAlpha:Lh,property:us,quadBroadcast:hx,quadSwapDiagonal:lx,quadSwapX:sx,quadSwapY:cx,radians:Nc,rand:Ml,range:vb,rangeFogFactor:fb,reciprocal:al,reference:ep,referenceBuffer:tp,reflect:ml,reflectVector:Kf,reflectView:Wf,reflector:Rv,refract:kl,refractVector:qf,refractView:Gf,reinhardToneMapping:qy,remap:ju,remapClamp:Mu,renderGroup:G,renderOutput:Lu,rendererReference:du,replaceDefaultUV:mv,rotate:g_,rotateUV:hv,roughness:hs,round:il,rtt:Wv,sRGBTransferEOTF:eu,sRGBTransferOETF:tu,sample:Qv,sampler:rd,samplerComparison:id,saturate:Ol,saturation:ky,screenCoordinate:_d,screenDPR:md,screenSize:gd,screenUV:hd,select:Rl,setCurrentStack:zo,setName:Hl,shaderStages:La,shadow:nS,shadowPositionWorld:jx,shapeCircle:yS,sharedUniformGroup:Ws,sheen:ys,sheenRoughness:bs,shiftLeft:vc,shiftRight:yc,shininess:js,sign:Qc,sin:Gc,sinc:q_,skinning:Bm,smoothstep:Al,smoothstepElement:Pl,specularColor:Os,specularColorBlended:ks,specularF90:As,spherizeUV:gv,split:ss,spritesheetUV:yv,sqrt:zc,stack:b_,step:pl,stepElement:Fl,storage:Em,storageBarrier:Ob,storageTexture:hy,string:rs,struct:w_,sub:q,subBuild:Zl,subgroupAdd:qb,subgroupAll:ix,subgroupAnd:$b,subgroupAny:ax,subgroupBallot:Kb,subgroupBroadcast:ux,subgroupBroadcastFirst:ox,subgroupElect:Gb,subgroupExclusiveAdd:Yb,subgroupExclusiveMul:Qb,subgroupInclusiveAdd:Jb,subgroupInclusiveMul:Zb,subgroupIndex:Am,subgroupMax:rx,subgroupMin:nx,subgroupMul:Xb,subgroupOr:ex,subgroupShuffle:dx,subgroupShuffleDown:mx,subgroupShuffleUp:px,subgroupShuffleXor:fx,subgroupSize:Tb,subgroupXor:tx,tan:qc,tangentGeometry:vp,tangentLocal:yp,tangentView:bp,tangentWorld:xp,texture:$u,texture3D:vy,texture3DLevel:by,texture3DLoad:yy,textureBarrier:kb,textureBicubic:fg,textureBicubicLevel:dg,textureCubeUV:kg,textureLevel:nd,textureLoad:td,textureSize:qu,textureStore:gy,thickness:Rs,time:sv,toneMapping:pu,toneMappingExposure:mu,toonOutlinePass:Gy,transformDirection:Cl,transformNormal:Pf,transformNormalToView:Ff,transformedClearcoatNormalView:Rf,transformedNormalView:If,transformedNormalWorld:Lf,transmission:Ls,transpose:cl,triNoise3D:iv,triplanarTexture:xv,triplanarTextures:bv,trunc:ol,uint:V,uintBitsToFloat:L_,uniform:K,uniformArray:ld,uniformCubeTexture:Zf,uniformFlow:Vl,uniformGroup:Us,uniformTexture:ed,unpackHalf2x16:tv,unpackNormal:Np,unpackSnorm2x16:$_,unpackUnorm2x16:ev,unpremultiplyAlpha:Rh,userData:Sy,uv:Ku,uvec2:Ko,uvec3:Yo,uvec4:Qo,varying:Ql,varyingProperty:ds,vec2:H,vec3:U,vec4:W,vectorComponents:Ra,velocity:Dy,vertexColor:jh,vertexIndex:Om,vertexStage:$l,vibrance:Ay,viewZToLogarithmicDepth:gh,viewZToOrthographicDepth:uh,viewZToPerspectiveDepth:ph,viewZToReversedOrthographicDepth:dh,viewZToReversedPerspectiveDepth:mh,viewport:vd,viewportCoordinate:bd,viewportDepthTexture:ch,viewportLinearDepth:xh,viewportMipTexture:ih,viewportOpaqueMipTexture:oh,viewportResolution:Sd,viewportSafeUV:vv,viewportSharedTexture:Iy,viewportSize:yd,viewportTexture:rh,viewportUV:xd,vogelDiskSample:Xv,wgsl:ab,wgslFn:ub,workgroupArray:Mb,workgroupBarrier:Db,workgroupId:Sb,workingToColorSpace:au,xor:pc}),dC=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};dC.isNodeFunctionInput=!0;var fC=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){T(`Abstract function.`)}};fC.isNodeFunction=!0,new nb(`uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }`),new nb(`uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }`);var pC=typeof self<`u`&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4};Pa.READ_ONLY,Pa.WRITE_ONLY,Pa.READ_WRITE,pC.VERTEX,pC.FRAGMENT,pC.COMPUTE,new nb(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),new nb(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),new nb(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),new nb(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),new nb(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),new nb(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),new nb(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),new nb(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),new nb(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),new nb(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),new nb(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),new nb(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),new nb(`
|
|
300
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
301
|
+
|
|
302
|
+
let res = vec2f( iRes );
|
|
303
|
+
|
|
304
|
+
let uvScaled = coord * res;
|
|
305
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
306
|
+
|
|
307
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
308
|
+
|
|
309
|
+
let uv = uvWrapping - 0.5;
|
|
310
|
+
let iuv = floor( uv );
|
|
311
|
+
let f = fract( uv );
|
|
312
|
+
|
|
313
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
314
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
315
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
316
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
317
|
+
|
|
318
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
`),new nb(`
|
|
322
|
+
fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
|
|
323
|
+
|
|
324
|
+
let res = vec2f( iRes );
|
|
325
|
+
|
|
326
|
+
let uvScaled = coord * res;
|
|
327
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
328
|
+
|
|
329
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
330
|
+
|
|
331
|
+
let uv = uvWrapping - 0.5;
|
|
332
|
+
let iuv = floor( uv );
|
|
333
|
+
let f = fract( uv );
|
|
334
|
+
|
|
335
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
|
|
336
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
|
|
337
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
|
|
338
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );
|
|
339
|
+
|
|
340
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
341
|
+
|
|
342
|
+
}
|
|
343
|
+
`);var mC=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(mC+=`diagnostic( off, derivative_uniformity );
|
|
344
|
+
`);var hC=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]);typeof Float16Array<`u`&&hC.set(Float16Array,[`float16`]);function gC(e,t,n){if(n){let r=new O().subVectors(e.position,n).applyQuaternion(e.quaternion.clone().invert()).applyQuaternion(t).add(n);e.position.copy(r)}e.quaternion.copy(t)}function _C(e){return e==null}var vC=class extends $t{removeChildren(){for(;this.children.length>0;)this.remove(this.children[0]);return this}add(...e){let t=e.filter(Boolean);return t.length===0?this:super.add(...t)}addIfNotExists(...e){return e.forEach(e=>{this.children.includes(e)||this.add(e)}),this}remove(...e){if(e.length===0)return this;let t=e.filter(Boolean);return super.remove(...t)}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}get helperObject(){return this}constructor(e,t){var n,r;super(),this.originObject3D=e,this.onRender=(n=t==null?void 0:t.onRender)==null?(()=>{}):n,this.positionFrom=(r=t==null?void 0:t.positionFrom)==null?`objectPosition`:r}render(){this.onRender()}enable(){this.parent&&(this.parent.children.includes(this)||this.parent.add(this))}disable(){this.removeFromParent()}show(){this.visible=!0,this.render()}hide(){this.visible=!1,this.render()}raycasterIntersectObject(e,t=[]){return e.intersectObject(this,!0,t)}initialPosition(e){this.positionFrom===`objectPosition`?this.position.copy(this.originObject3D.position):this.positionFrom===`boundingBox`||this.positionFrom===`boundingSphere`?this.position.copy(new Cn().expandByObject(this.originObject3D).getCenter(new O)):this.positionFrom instanceof O?this.position.copy(this.positionFrom):this.positionFrom instanceof Function&&this.position.copy(this.positionFrom(this.originObject3D)),e&&this.position.add(e)}setScaleByCamera(e){}initQuaternion(e){if(this.quaternion.set(0,0,0,1),e&&(e.xAxis||e.yAxis||e.zAxis)){let t=e.xAxis instanceof Function?e.xAxis():e.xAxis,n=e.yAxis instanceof Function?e.yAxis():e.yAxis,r=e.zAxis instanceof Function?e.zAxis():e.zAxis,i=t==null?void 0:t.clone(),a=n==null?void 0:n.clone(),o=r==null?void 0:r.clone();if(i&&!a&&!a){let e=new at().setFromUnitVectors(new O(1,0,0),i.normalize());this.applyQuaternion(e)}if(a&&!i&&!o){let e=new at().setFromUnitVectors(new O(0,1,0),a.normalize());this.applyQuaternion(e)}if(o&&!i&&!a){let e=new at().setFromUnitVectors(new O(0,0,1),o.normalize());this.applyQuaternion(e)}if([i,a,o].filter(e=>!_C(e)).length>=2){i||(i=new O().crossVectors(a,o).normalize()),a||(a=new O().crossVectors(i,o).normalize()),o||(o=new O().crossVectors(i,a).normalize()),i.applyQuaternion(this.quaternion),a.applyQuaternion(this.quaternion),o.applyQuaternion(this.quaternion);let e=new k().makeBasis(i,a,o),t=new at().setFromRotationMatrix(e);this.quaternion.copy(t)}}}applyHelperScaleMatrix4(e,t){this.scale.applyMatrix4(e)}setHelperQuaternion(e,t){this.initQuaternion(),t?gC(this,this.quaternion.clone().premultiply(e),t):this.quaternion.premultiply(e)}applyHelperQuaternion(e,t){if(t){let n=new O().subVectors(this.position,t).applyQuaternion(e).add(t);this.position.copy(n)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}},yC=class extends vC{},bC=class extends vC{},xC=class extends vC{},SC=class extends en{constructor(e){super(),this.direction=e||`x`}},CC=class extends Or{constructor(e,t,n){super(e,t),this.direction=n||`x`}},wC={X:16730698,Y:54927,Z:3368703},TC=class{static get X(){return new on(wC.X).convertSRGBToLinear().clone()}static get Y(){return new on(wC.Y).convertSRGBToLinear().clone()}static get Z(){return new on(wC.Z).convertSRGBToLinear().clone()}},EC={ROTATE_HELPER:9992,MOVE_HELPER:9993,SCALE_HELPER_LINE:9994,SCALE_HELPER_SPHERE:9995,MOVE_HELPER_ARROW:10001,MOVE_HELPER_CENTER:10002,DRAG_GUIDE_LINE:10003,DRAG_FACE_PATCH:10004},DC=class extends SC{constructor(e){var t;super(e.direction),this.lineHeight=.5,this.arrowHeight=.1,this.name=`ArrowGroup`;let n=new on((t=e.color)==null?16214315:t),r=()=>new gr({color:n,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),i=new ii(.04,this.arrowHeight,32);this.arrow=new CC(i,r(),e.direction),this.arrow.name=`arrow-${e.direction}`,this.arrow.renderOrder=EC.MOVE_HELPER_ARROW;let a=new ii(.04,this.arrowHeight,32);this.arrowNeg=new CC(a,r(),e.direction),this.arrowNeg.name=`arrow-neg-${e.direction}`,this.arrowNeg.renderOrder=EC.MOVE_HELPER_ARROW;let o=.004,s=new ri(o,o,this.lineHeight,32);this.line=new CC(s,r(),e.direction),this.line.name=`line-${e.direction}`,this.line.renderOrder=EC.MOVE_HELPER_ARROW,this.formatGeometries(),this.add(this.arrow,this.arrowNeg,this.line)}formatGeometries(){let e=this.lineHeight,t=this.arrowHeight;this.arrow.geometry.translate(0,e+t/2,0),this.arrowNeg.geometry.rotateZ(Math.PI),this.arrowNeg.geometry.translate(0,-(e+t/2),0),this.line.geometry.translate(0,e/2,0),this.direction===`x`?(this.arrow.geometry.rotateX(Math.PI/2),this.arrow.geometry.rotateY(Math.PI/2),this.arrowNeg.geometry.rotateX(Math.PI/2),this.arrowNeg.geometry.rotateY(Math.PI/2),this.line.geometry.rotateX(Math.PI/2),this.line.geometry.rotateY(Math.PI/2)):this.direction===`z`&&(this.arrow.geometry.rotateX(Math.PI/2),this.arrowNeg.geometry.rotateX(Math.PI/2),this.line.geometry.rotateX(Math.PI/2))}},OC=class extends SC{constructor(e){var t,n;super(`plane`),this.name=`CenterHandle`,this.faceNormals=[new O(1,0,0),new O(-1,0,0),new O(0,1,0),new O(0,-1,0),new O(0,0,1),new O(0,0,-1)],this.baseColor=new on((t=e==null?void 0:e.color)==null?16419862:t);let r=(n=e==null?void 0:e.size)==null?.05:n,i=new on(16755008).convertSRGBToLinear();this.faceMaterials=Array.from({length:6},()=>new gr({color:i,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,side:0}));let a=new Or(new ti(r,r,r),this.faceMaterials);a.direction=`plane`,a.renderOrder=EC.MOVE_HELPER_CENTER,a.name=`center-plane-handle`,this.cube=a,this.add(this.cube)}update(e){let t=new O().subVectors(e.position,this.cube.getWorldPosition(new O)).normalize(),n=this.cube.getWorldQuaternion(new at),r=this.faceNormals.map((e,r)=>{let i=e.clone().applyQuaternion(n).dot(t);return{index:r,angle:Math.acos(Math.abs(i))}});r.sort((e,t)=>e.angle-t.angle);let i=[new on(16755008).convertSRGBToLinear(),new on(16419862).convertSRGBToLinear(),new on(13921032).convertSRGBToLinear()];r.forEach((e,t)=>{let n=Math.floor(t/2);this.faceMaterials[e.index].color.copy(i[n])})}},kC=class extends SC{constructor(e){var t,n,r;super(e.direction),this.name=`PlaneHandle`;let i=(t=e.size)==null?.12:t,a=(n=e.offset)==null?.12:n,o=new on((r=e.color)==null?16776960:r),s=new ti(i,i,.005),c=new gr({color:o,transparent:!0,opacity:.4,depthTest:!1,depthWrite:!1,side:2});switch(this.handle=new Or(s,c),this.handle.direction=e.direction,this.handle.renderOrder=EC.MOVE_HELPER_ARROW,this.handle.name=`plane-handle-${e.direction}`,e.direction){case`xy`:this.handle.position.set(a,a,0);break;case`xz`:this.handle.position.set(a,0,a),this.handle.rotation.x=-Math.PI/2;break;case`yz`:this.handle.position.set(0,a,a),this.handle.rotation.y=Math.PI/2;break}this.add(this.handle)}};function AC(e,t,n){let r=e.position.distanceTo(t),i=e.fov,a=e.distance||3,o=r/3,s=i/90,c=a/3,l=o*s*c,u=(n==null?void 0:n.min)||.6,d=n==null?void 0:n.max;return u&&l<u?u:d&&l>d?d:l}function jC(e){let{latitude:t,longitude:n}=e,r=new O;return MC-t<.03?r.set(0,1,0):NC(0,n)?r.set(0,0,1):NC(Math.PI,n)?r.set(0,0,-1):NC(MC,n)?r.set(1,0,0):r.set(-1,0,0),r}var MC=Number((Math.PI/2).toFixed(5));function NC(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function PC(e,t){return FC(document.createElement(t==null?`div`:t),e)}function FC(e,t){if(!t)return e;for(let n in t)n&&t[n]&&(e.style[n]=t[n]);return e}function IC(e){let t=PC(Object.assign({position:`absolute`,display:`block`,borderRadius:`4px`,paddingTop:`1px`,paddingBottom:`1px`,paddingLeft:`4px`,paddingRight:`4px`,pointerEvents:`none`,userSelect:`none`,zIndex:`99999`,backgroundColor:`rgba(0,0,0,0.7)`,fontSize:`12px`,color:`#fff`,letterSpacing:`0`,lineHeight:`18px`},e)),n=()=>{t.style.display!==`block`&&t.style.top&&t.style.left&&(t.style.display=`block`)};return{element:t,show:n,hide:()=>{t.style.display=`none`,t.style.top=``,t.style.left=``},setLeftTop:(e,r)=>{t.style.left=e,t.style.top=r,n()}}}var LC=class extends yC{constructor(e,t){super(e,t),this.name=`MoveHelper`,(t==null?void 0:t.xArrowEnable)!==!1&&(this.xArrow=new DC({direction:`x`,color:TC.X})),(t==null?void 0:t.yArrowEnable)!==!1&&(this.yArrow=new DC({direction:`y`,color:TC.Y})),(t==null?void 0:t.zArrowEnable)!==!1&&(this.zArrow=new DC({direction:`z`,color:TC.Z})),(t==null?void 0:t.centerHandleEnable)!==!1&&(this.centerHandle=new OC),(t==null?void 0:t.xyPlaneEnable)!==!1&&(this.xyPlane=new kC({direction:`xy`,color:TC.Z})),(t==null?void 0:t.xzPlaneEnable)!==!1&&(this.xzPlane=new kC({direction:`xz`,color:TC.Y})),(t==null?void 0:t.yzPlaneEnable)!==!1&&(this.yzPlane=new kC({direction:`yz`,color:TC.X})),t!=null&&t.container&&(t==null?void 0:t.moveTipsEnable)!==!1&&(this.container=t.container,this.moveTips=IC({display:`none`}),this.container.appendChild(this.moveTips.element)),this.add(...[this.xArrow,this.yArrow,this.zArrow,this.centerHandle,this.xyPlane,this.xzPlane,this.yzPlane].filter(Boolean))}update(e){if(this.xArrow&&(this.xArrow.visible=!0),this.yArrow&&(this.yArrow.visible=!0),this.zArrow&&(this.zArrow.visible=!0),this.centerHandle&&this.centerHandle.update(e),e.type===`OrthographicCamera`){let t=new O(1,0,0).applyQuaternion(this.quaternion),n=new O(0,1,0).applyQuaternion(this.quaternion),r=new O(0,0,1).applyQuaternion(this.quaternion),i=e.pose,a=jC(i),o=.0872665;Math.abs(t.angleTo(a)-0)<o||Math.abs(t.angleTo(a)-Math.PI)<o?this.xArrow&&(this.xArrow.visible=!1):Math.abs(n.angleTo(a)-0)<o||Math.abs(n.angleTo(a)-Math.PI)<o?this.yArrow&&(this.yArrow.visible=!1):(Math.abs(r.angleTo(a)-0)<o||Math.abs(r.angleTo(a)-Math.PI)<o)&&this.zArrow&&(this.zArrow.visible=!1)}}show(){var e;super.show(),this.xArrow&&this.add(this.xArrow),this.yArrow&&this.add(this.yArrow),this.zArrow&&this.add(this.zArrow),this.centerHandle&&this.add(this.centerHandle),this.xyPlane&&this.add(this.xyPlane),this.xzPlane&&this.add(this.xzPlane),this.yzPlane&&this.add(this.yzPlane),(e=this.moveTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(AC(e,this.position))}showDraggingHelper(e){this.xArrow&&(e.includes(`x`)?this.add(this.xArrow):this.remove(this.xArrow)),this.yArrow&&(e.includes(`y`)?this.add(this.yArrow):this.remove(this.yArrow)),this.zArrow&&(e.includes(`z`)?this.add(this.zArrow):this.remove(this.zArrow)),this.centerHandle&&(e.includes(`plane`)?this.add(this.centerHandle):this.remove(this.centerHandle)),this.xyPlane&&(e.includes(`xy`)?this.add(this.xyPlane):this.remove(this.xyPlane)),this.xzPlane&&(e.includes(`xz`)?this.add(this.xzPlane):this.remove(this.xzPlane)),this.yzPlane&&(e.includes(`yz`)?this.add(this.yzPlane):this.remove(this.yzPlane))}dispose(){var e,t;this.remove(...[this.xArrow,this.yArrow,this.zArrow,this.centerHandle,this.xyPlane,this.xzPlane,this.yzPlane].filter(Boolean)),(t=(e=this.moveTips)==null?void 0:e.element)==null||t.remove(),super.dispose()}},RC=class extends xC{constructor(e,t){super(e,t),this.name=`RotateHelper`,this.children=[],(t==null?void 0:t.yzCircleEnable)!==!1&&(this.xCircle=new zC({direction:`x`,color:TC.X})),(t==null?void 0:t.xzCircleEnable)!==!1&&(this.yCircle=new zC({direction:`y`,color:TC.Y})),(t==null?void 0:t.xyCircleEnable)!==!1&&(this.zCircle=new zC({direction:`z`,color:TC.Z})),t!=null&&t.container&&(t==null?void 0:t.angleTipsEnable)!==!1&&(this.container=t==null?void 0:t.container,this.angleTips=IC({display:`none`}),this.container.appendChild(this.angleTips.element)),this.add(...[this.xCircle,this.yCircle,this.zCircle].filter(Boolean)),this.show()}hide(){this.children.forEach(e=>e.hide())}show(){var e;this.children.forEach(e=>e.showCircle()),(e=this.angleTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(AC(e,this.position))}update(e){if(e.type===`OrthographicCamera`)return;let t=this.helperObject.position.clone().sub(e.position).normalize(),n=new O(1,0,0).applyQuaternion(this.quaternion),r=new O(0,1,0).applyQuaternion(this.quaternion),i=new O(0,0,1).applyQuaternion(this.quaternion),a=t.angleTo(n),o=t.angleTo(r),s=t.angleTo(i),c=Math.PI/2,l=o>=c,u=s>=c,d=a>=c;if(this.xCircle){let e=this.xCircle.circle.gapAngle;l&&u?this.xCircle.circle.geometry=new fi(.3,.35,20,8,e,Math.PI/2-e*2):l&&!u?this.xCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!l&&u?this.xCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!l&&!u&&(this.xCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.xCircle.angleSector&&(this.xCircle.angleSector.offsetAngle=e=>e,l&&u||l&&!u?this.xCircle.angleSector.baseAxes=new O(0,0,1):!l&&u?(this.xCircle.angleSector.baseAxes=new O(0,-1,0),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!l&&!u&&(this.xCircle.angleSector.baseAxes=new O(0,0,-1),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI))}if(this.yCircle){this.yCircle.angleSector.offsetAngle=e=>e;let e=this.yCircle.circle.gapAngle;d&&u?this.yCircle.circle.geometry=new fi(.3,.35,20,8,e,Math.PI/2-e*2):d&&!u?this.yCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!d&&u?this.yCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!d&&!u&&(this.yCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),d&&u?this.yCircle.angleSector.baseAxes=new O(1,0,0):d&&!u?(this.yCircle.angleSector.baseAxes=new O(0,0,-1),this.yCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!d&&u?(this.yCircle.angleSector.baseAxes=new O(0,0,1),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!d&&!u&&(this.yCircle.angleSector.baseAxes=new O(-1,0,0),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI)}if(this.zCircle){this.zCircle.angleSector.offsetAngle=e=>e;let e=this.zCircle.circle.gapAngle;d&&l?this.zCircle.circle.geometry=new fi(.3,.35,20,8,e,Math.PI/2-e*2):d&&!l?this.zCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!d&&l?this.zCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!d&&!l&&(this.zCircle.circle.geometry=new fi(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.zCircle.angleSector&&(d&&l?this.zCircle.angleSector.baseAxes=new O(1,0,0):d&&!l?(this.zCircle.angleSector.baseAxes=new O(0,-1,0),this.zCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!d&&l?(this.zCircle.angleSector.baseAxes=new O(0,1,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!d&&!l&&(this.zCircle.angleSector.baseAxes=new O(-1,0,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI))}}showDraggingHelper(e){var t;this.hide(),this.children.filter(t=>e.includes(t.direction)).forEach(e=>e.showRing()),(t=this.angleTips)==null||t.show()}dispose(){var e,t;this.removeFromParent(),(t=(e=this.angleTips)==null?void 0:e.element)==null||t.remove()}},zC=class extends en{constructor(e){super(),this.direction=e.direction,this.circle=new BC(e),this.ring=new VC(e),this.angleSector=new HC(e),this.add(this.circle,this.ring,this.angleSector),this.direction===`y`?this.rotation.x=Math.PI/2:this.direction===`x`&&(this.rotation.y=-Math.PI/2)}showCircle(){this.add(this.circle),this.remove(this.ring,this.angleSector)}showRing(){this.add(this.ring,this.angleSector),this.remove(this.circle)}hide(){this.remove(this.ring,this.angleSector,this.circle)}},BC=class extends Or{constructor(e){var t;super(),this.gapAngle=.02,this.geometry=new fi(.3,.35,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2),this.material=new gr({opacity:.6,transparent:!0,color:(t=e.color)==null?16777215:t,side:2,depthTest:!1}),this.direction=e.direction,this.renderOrder=EC.ROTATE_HELPER,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}},VC=class extends en{constructor(e){super(),this.direction=e.direction;let t=.015,n=Array(8).fill(null).map((e,n)=>{let r=new Or(new fi(.3,.35,20,8,Math.PI/4*n+t,Math.PI/4-t*2),new gr({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:2}));return r.name=`AxesDashedRing-${this.direction}-${n}`,r});this.add(...n)}},HC=class extends Or{constructor(e){var t;switch(super(),this.offsetAngle=e=>e,e.direction){case`x`:this.baseAxes=new O(0,0,1);break;case`y`:this.baseAxes=new O(1,0,0);break;case`z`:this.baseAxes=new O(1,0,0);break}this.geometry=new ni(.3505,48,0,1e-4),this.material=new gr({opacity:.4,color:(t=e.color)==null?16777215:t,depthTest:!1,depthWrite:!1,transparent:!0,side:2}),this.direction=e.direction,this.angleDirection=1}setClockwiseDirection(){this.angleDirection=-1}setCounterClockwiseDirection(){this.angleDirection=1}toggleDirection(){this.angleDirection=this.angleDirection===1?-1:1}setBaseAxes(e){this.baseAxes=e.clone().normalize()}getDirection(){return this.angleDirection===-1?`clockwise`:`counterclockwise`}},UC=class extends bC{constructor(e){super(e),this.name=`BoundingBoxHelper`,this.positionAttribute=new Vn(new Float32Array(24),3),this.box=this.createBox(),this.outline=this.createOutline(),this.add(this.box,this.outline),this.update()}initQuaternion(){this.quaternion.copy(this.originObject3D.quaternion),this.scale.copy(this.originObject3D.scale)}setHelperQuaternion(e,t){gC(this,e,t)}raycasterIntersectObject(e,t){return e.intersectObject(this,!1,t)}raycast(e,t){this.box.raycast(e,t)}update(){let e=new Cn,t=new k().copy(this.originObject3D.matrixWorld).invert(),n=new O;if(this.originObject3D.updateMatrixWorld(!0),this.originObject3D.traverse(r=>{let i=r.geometry;if(!i)return;r.updateMatrixWorld(!0);let a=new k().multiplyMatrices(t,r.matrixWorld);if(i.isBufferGeometry){let t=i,r=t.attributes.position;if(r)for(let t=0,i=r.count;t<i;t++)n.fromBufferAttribute(r,t).applyMatrix4(a),e.expandByPoint(n);let o=t.attributes.instanceStart,s=t.attributes.instanceEnd;if(o)for(let t=0,r=o.count;t<r;t++)n.fromBufferAttribute(o,t).applyMatrix4(a),e.expandByPoint(n);if(s)for(let t=0,r=s.count;t<r;t++)n.fromBufferAttribute(s,t).applyMatrix4(a),e.expandByPoint(n)}else if(i.vertices){let t=i.vertices;for(let r of t)n.copy(r).applyMatrix4(a),e.expandByPoint(n)}}),e.isEmpty())return;let{min:r,max:i}=e;this.positionAttribute.setXYZ(0,i.x,i.y,i.z),this.positionAttribute.setXYZ(1,r.x,i.y,i.z),this.positionAttribute.setXYZ(2,r.x,r.y,i.z),this.positionAttribute.setXYZ(3,i.x,r.y,i.z),this.positionAttribute.setXYZ(4,i.x,i.y,r.z),this.positionAttribute.setXYZ(5,r.x,i.y,r.z),this.positionAttribute.setXYZ(6,r.x,r.y,r.z),this.positionAttribute.setXYZ(7,i.x,r.y,r.z),this.positionAttribute.needsUpdate=!0}createOutline(){let e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),t=new nr;t.setIndex(new Vn(e,1)),t.setAttribute(`position`,this.positionAttribute);let n=new Yr(t,new Lr({color:64767,linewidth:1,opacity:1,toneMapped:!1}));return n.matrixAutoUpdate=!1,n}createBox(){let e=new Uint16Array([0,1,2,0,2,3,0,3,7,0,7,4,0,4,5,0,5,1,6,1,5,6,2,1,6,5,4,6,4,7,6,3,2,6,7,3]),t=new nr;return t.setIndex(new Vn(e,1)),t.setAttribute(`position`,this.positionAttribute),new Or(t,new gr({color:64767,opacity:.1,depthTest:!1,transparent:!0}))}},WC=new Map;function GC(e){if(WC.has(e))return WC.get(e).hooks;let n=new t.Subscribe,r=null,i,a=()=>{r=requestAnimationFrame(a);let t=e.projectionMatrix.toArray().join(`,`)+e.matrixWorld.toArray().join(`,`);t!==i&&(i=t,n.emit(`cameraUpdate`))};return a(),WC.set(e,{hooks:n,dispose:()=>{WC.delete(e),cancelAnimationFrame(r)}}),n}function KC(e){return arguments.length===0?[]:Array.isArray(e)?e:[e]}var qC=class{updateOtherControllers(e){this.otherControllers=e}getIsDragging(){return this.isDragging}constructor(e,n){var r,i,a;this.preventTapDefaultEvent=!1,this.disposers=[],this.isDragging=!1,this.enabled=!1,this.name=`BaseController`,this.onWantsTapGesture=e=>{if(this.getIntersectObject(e))return!1},this.updateHelperScale=()=>{`update`in this.helperObject3D&&typeof this.helperObject3D.update==`function`&&this.helperObject3D.update(this.camera),this.helperObject3D.setScaleByCamera(this.camera)},this.getBox=()=>(this.boundingBox||(this.boundingBox=new Cn().expandByObject(this.originObject3D)),this.boundingBox),this.hooks=(r=e.sharedHooks)==null?new t.Subscribe:r,this.internalHooks=(i=e.sharedInternalHooks)==null?new t.Subscribe:i,this.camera=e.camera,this.model=e.model,this.originObject3D=e.originObject3D,this.helperObject3D=e.helperObject3D,this.container=e.container,this.scene=e.scene,this.domEvents=e.domEvents,this.onRender=(a=e.onRender)==null?(()=>{}):a,this.config=n==null?{}:n,this.otherControllers=e.otherControllers,this.initialHelperPosition(),this.initialHelperQuaternion(),this.updateHelperScale(),this.cameraHooks=GC(this.camera),this.enable();let o=this.onSetOriginObjectScale.bind(this),s=this.onSetOriginObjectRotate.bind(this),c=this.onSetOriginObjectPosition.bind(this),l=this.onApplyOriginObjectScale.bind(this),u=this.onApplyOriginObjectRotate.bind(this),d=this.onApplyOriginObjectPosition.bind(this),f=this.initialHelperPosition.bind(this);this.cameraHooks.on(`cameraUpdate`,this.updateHelperScale),this.internalHooks.on(`initialHelperPosition`,f),this.internalHooks.on(`setObjectScale`,o),this.internalHooks.on(`setObjectRotate`,s),this.internalHooks.on(`setObjectPosition`,c),this.internalHooks.on(`applyObjectPosition`,d),this.internalHooks.on(`applyObjectRotate`,u),this.internalHooks.on(`applyObjectScale`,l),this.hooks.on(`moveEnd`,this.updateHelperScale),this.internalHooks.on(`setObjectPosition`,this.updateHelperScale),this.internalHooks.on(`initialHelperPosition`,this.updateHelperScale),this.disposers.push(()=>{this.cameraHooks.off(`cameraUpdate`,this.updateHelperScale),this.internalHooks.off(`initialHelperPosition`,f),this.internalHooks.off(`setObjectScale`,o),this.internalHooks.off(`setObjectRotate`,s),this.internalHooks.off(`setObjectPosition`,c),this.internalHooks.off(`applyObjectPosition`,d),this.internalHooks.off(`applyObjectRotate`,u),this.internalHooks.off(`applyObjectScale`,l),this.hooks.off(`moveEnd`,this.updateHelperScale),this.internalHooks.off(`setObjectPosition`,this.updateHelperScale),this.internalHooks.off(`initialHelperPosition`,this.updateHelperScale)})}initialHelperPosition(){this.helperObject3D.initialPosition(this.calculateOffset(this.config.offset))}initialHelperQuaternion(){this.helperObject3D.initQuaternion(this.config)}enable(){this.enabled||(this.enabled=!0,this.scene.add(this.helperObject3D),this.helperObject3D.enable(),this.render())}disable(){this.enabled&&(this.enabled=!1,this.helperObject3D.disable(),this.render())}show(){this.helperObject3D.show(),this.render()}hide(){this.helperObject3D.hide(),this.render()}dispose(){var e;(e=this.disposers)==null||e.forEach(e=>e==null?void 0:e()),this.helperObject3D.dispose(),this.render()}applyHelperMatrix4(e){this.helperObject3D.applyMatrix4(e)}applyHelperQuaternion(e,t){this.helperObject3D.applyHelperQuaternion(e,t)}applyHelperScaleMatrix4(e,t){this.helperObject3D.applyHelperScaleMatrix4(e,t)}onWantsGesture(e,t,n){if(this.isDragging)return!1}onIntersectionOnModelUpdate(e){}onApplyOriginObjectScale(e){this.applyHelperScaleMatrix4(e.matrix,e.origin)}onApplyOriginObjectRotate(e){let t=e.origin;if(t){let n=new O().subVectors(this.helperObject3D.position,t).applyQuaternion(e.quaternion).add(t);this.helperObject3D.position.copy(n)}}onApplyOriginObjectPosition(e){this.applyHelperMatrix4(e.matrix)}onSetOriginObjectScale(e){this.helperObject3D.scale.copy(e),this.updateOffsetByScale(e)}onSetOriginObjectRotate(e,t){}onSetOriginObjectPosition(e){this.helperObject3D.position.copy(e.clone().add(this.calculateOffset(this.config.offset)))}render(){this.onRender()}updateOffsetByScale(e){if(this.boundingBox&&this.config.offset){let t=this.originObject3D.position,n=new O().subVectors(this.boundingBox.max,t).multiply(e).add(t),r=new O().subVectors(this.boundingBox.min,t).multiply(e).add(t),i=this.calculateOffset(this.config.offset,{min:r,max:n});this.helperObject3D.initialPosition(i)}}hoverListener(e,t=16777215,n=1){let r=KC(e).filter(e=>!_C(e)),i=[];for(let e of r)if(e.material||e instanceof en){let r=e instanceof en?e.children.filter(e=>e instanceof Or):[e];r.forEach(e=>{var t,n,r,i;let a=e.material;Array.isArray(a)?(e.__originalColor__=(t=e.__originalColor__)==null?a.map(e=>e.color.clone()):t,e.__originalOpacity__=(n=e.__originalOpacity__)==null?a.map(e=>e.opacity):n):(e.__originalColor__=(r=e.__originalColor__)==null?a.color.clone():r,e.__originalOpacity__=(i=e.__originalOpacity__)==null?a.opacity:i)});let a=()=>{r.forEach(e=>{if(e.name===`ScaleHelperTransparentGroup`){if(e.children[0]){let r=e.children[0].material;r.color.set(t),r.opacity=n}}else{let r=e.material;Array.isArray(r)?r.forEach(e=>{e.color.set(t),e.opacity=n}):(r.color.set(t),r.opacity=n)}}),this.render()},o=()=>{r.forEach(e=>{if(e.name===`ScaleHelperTransparentGroup`){if(e.children[0]){let t=e.children[0].material;t.color.set(16776960),t.opacity=1}}else{let t=e.material;if(Array.isArray(t)){let n=e.__originalColor__,r=e.__originalOpacity__;t.forEach((e,t)=>{n&&n[t]&&e.color.copy(n[t]),r&&r[t]!==void 0&&(e.opacity=r[t])})}else t.color.copy(e.__originalColor__),t.opacity=e.__originalOpacity__}}),this.render()},s=e=>{this.isDragging||a()},c=e=>{this.isDragging||o()};for(let e of r)this.domEvents.addEventListener(e,`mouseover`,s),this.domEvents.addEventListener(e,`mouseout`,c),this.hooks.on(`moveStart`,a),this.hooks.on(`moveEnd`,o),this.hooks.on(`rotateEnd`,o),this.hooks.on(`scaleEnd`,o),i.push(()=>{this.domEvents.removeEventListener(e,`mouseover`,s),this.domEvents.removeEventListener(e,`mouseout`,c),this.hooks.off(`moveStart`,a),this.hooks.off(`moveEnd`,o),this.hooks.off(`rotateEnd`,o),this.hooks.off(`scaleEnd`,o)})}return()=>i.forEach(e=>e==null?void 0:e())}getIntersectObject(e){let t=this.camera.position,n=this.helperObject3D;if(!n)return;let r=this.helperObject3D.raycasterIntersectObject(e)[0];if(!r)return;let i=r;if(i.object=n,this.model.intersectRaycaster){let n=this.model.intersectRaycaster(e)[0];if(n&&n.point.distanceTo(t)<i.point.distanceTo(t))return}return i.object}calculateOffset(e,t){let n=new O(0,0,0);if(!e)return n;let r=()=>t||this.getBox();if(typeof e.x==`number`)n.setX(e.x);else if(typeof e.x==`object`){let t=r();n.setX((t.max.x-t.min.x)*e.x.percents)}if(typeof e.y==`number`)n.setY(e.y);else if(typeof e.y==`object`){let t=r();n.setY((t.max.y-t.min.y)*e.y.percents)}if(typeof e.z==`number`)n.setZ(e.z);else if(typeof e.z==`object`){let t=r();n.setZ((t.max.z-t.min.z)*e.z.percents)}return n}};function JC(e,t){let n=10,r=10,i=e.isPerspectiveCamera,a=e.isOrthographicCamera;if(i){let i=e,a=i.position.distanceTo(t),o=i.fov*Math.PI/180;r=2*Math.tan(o/2)*a,n=r*i.aspect}else if(a){let t=e;n=Math.abs(t.right-t.left),r=Math.abs(t.top-t.bottom)}let o=Math.sqrt(n*n+r*r),s=o*.8,c=Math.min(n,r)*.25,l=o*1.2;return Math.max(c,Math.min(s,l))}var YC=class{constructor(e,t,n){this.camera=e,this.container=t,this.defaults=Object.assign({},n||{})}createSolidLine(e,t,n){let r=Object.assign(Object.assign({color:16777215,renderOrder:EC.DRAG_GUIDE_LINE},this.defaults),n||{}),i=t.clone().normalize(),a=this.computeInfiniteLineLength(e),o=e.clone().add(i.clone().multiplyScalar(-a)),s=e.clone().add(i.clone().multiplyScalar(a)),c=new Float32Array([o.x,o.y,o.z,s.x,s.y,s.z]),l=new nr;l.setAttribute(`position`,new Vn(c,3));let u=new Gr(l,new Lr({color:r.color,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.65}));return u.renderOrder=r.renderOrder,u}updateSolidLine(e,t,n,r){let i=n.clone().normalize(),a=this.computeInfiniteLineLength(t),o=t.clone().add(i.clone().multiplyScalar(-a)),s=t.clone().add(i.clone().multiplyScalar(a)),c=new Float32Array([o.x,o.y,o.z,s.x,s.y,s.z]),l=e.geometry,u=l.getAttribute(`position`);u&&u.itemSize===3&&u.array.length===c.length?(u.array.set(c),u.needsUpdate=!0):l.setAttribute(`position`,new Vn(c,3)),(r==null?void 0:r.color)!==void 0&&e.material.color.setHex(r.color)}computeInfiniteLineLength(e){return JC(this.camera,e)*10}dispose(e){if(!e)return;e.geometry.dispose();let t=e.material;Array.isArray(t)?t.forEach(e=>e.dispose()):t.dispose()}updateDefaults(e){this.defaults=Object.assign(Object.assign({},this.defaults),e)}};function XC(e,t,n){let{top:r,left:i,width:a,height:o}=t.getBoundingClientRect();return n&&(i+=a*n.left,r+=o*(1-n.bottom-n.height),a*=n.width,o*=n.height),new it((e.x-i)/a*2-1,-(e.y-r)/o*2+1)}function ZC(e,t,n){if(!t||!n||!e)return;let r=XC(t,n);if(Math.abs(r.x)===1||Math.abs(r.y)===1)return;let i=new Qi;return i.setFromCamera(r,e),i.params.Points&&(i.params.Points.threshold=.1),i}function QC(e){let{raycaster:t,line:n,clampToLine:r=!0}=e,i=new Ir().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),new O),a=i.projectPoint(n.start,new O),o=i.projectPoint(n.end,new O),s=new la(a,o),c=s.closestPointToPoint(t.ray.origin,r,new O),l=c.distanceTo(o),u=c.distanceTo(a),d=s.distance();if(l>u&&l>d){let e=-c.distanceTo(a)/d,t=n.start.clone().sub(n.end).normalize();return n.start.clone().sub(t.clone().multiplyScalar(e*n.distance()))}else{let e=c.distanceTo(a)/d;return new O().lerpVectors(n.start,n.end,e)}}var $C=class extends qC{get moveByMouseEnable(){return this._moveByMouse.enabled}constructor(...e){var t,n,r,i,a;super(...e),this.name=`MoveController`,this.solidGuide=new YC(this.camera,this.container,(n=(t=this.config)==null?void 0:t.solidGuide)==null?{}:n),this._moveByMouse={enabled:!1},this.dragStart=e=>{if(this.moveByMouseEnable||this.isDragging)return;let t=e==null?void 0:e.intersect;if(!t)return this.dragEnd();let n=(t==null?void 0:t.object).direction;if(!n)return this.dragEnd();let r=new O(1,0,0),i=new O(0,1,0),a=new O(0,0,1),o=(()=>{switch(n){case`x`:return r;case`y`:return i;case`z`:return a;case`xy`:case`xz`:case`yz`:case`plane`:return}})(),s=t.point.clone();if(n===`xy`||n===`xz`||n===`yz`){let e=(()=>{switch(n){case`xy`:return a;case`xz`:return i;case`yz`:return r}})(),t=new Ir().setFromNormalAndCoplanarPoint(e,s),o=s.clone();this.startInfo={draggingDirection:n,startVectorProject:o,line:new la(o.clone(),o.clone()),plane:t}}else if(n===`plane`){let e=this.camera.position.clone(),t=s.clone(),r=t.clone().sub(e).normalize(),i=new Ir().setFromNormalAndCoplanarPoint(r,t),a=t.clone();this.startInfo={draggingDirection:n,startVectorProject:a,line:new la(a.clone(),a.clone()),plane:i}}else{if(!o)return this.dragEnd();let e=new la(s.clone().sub(o.normalize()),s.clone().add(o.normalize()));this.startInfo={draggingDirection:n,startVectorProject:s,line:e};try{let e=o.clone().normalize(),t=this.helperObject3D.getWorldPosition(new O),n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:EC.DRAG_GUIDE_LINE});this.scene.add(n),this.dragGuideLine=n}catch(e){}}let c=(()=>{switch(n){case`plane`:return[];case`xy`:return[`x`,`y`,`xy`];case`xz`:return[`x`,`z`,`xz`];case`yz`:return[`y`,`z`,`yz`];default:return[n]}})();this.helperObject3D.showDraggingHelper(c),this.hooks.emit(`moveStart`,n),this.isDragging=!0,this.setTipsText(this.originObject3D.position),this.setTipsPosition(s)},this.dragging=e=>{if(!this.isDragging||!this.startInfo)return;let t=`touches`in e?e.touches[0].clientX:e.x,n=`touches`in e?e.touches[0].clientY:e.y,r=ZC(this.camera,{x:t,y:n},this.container);return r?(this.move(r),!1):this.dragEnd()},this.dragEnd=()=>{if(this.isDragging){if(this.startInfo=void 0,this.isDragging=!1,this.dragGuideLine){this.scene.remove(this.dragGuideLine),this.dragGuideLine.geometry.dispose();let e=this.dragGuideLine.material;Array.isArray(e)?e.forEach(e=>e.dispose()):e.dispose(),this.dragGuideLine=void 0}this.helperObject3D.show(),this.hooks.emit(`moveEnd`)}};let o=this.helperObject3D;if(this.hoverListener([o.xArrow,o.yArrow,o.zArrow,(r=o.xyPlane)==null?void 0:r.handle,(i=o.xzPlane)==null?void 0:i.handle,(a=o.yzPlane)==null?void 0:a.handle]),o.centerHandle&&o.centerHandle instanceof OC){let e=o.centerHandle,t=e.cube;this.domEvents.addEventListener(t,`mouseover`,()=>{this.isDragging||(Array.isArray(t.material)&&t.material.forEach(e=>{e.color.set(16777215)}),this.render())}),this.domEvents.addEventListener(t,`mouseout`,()=>{this.isDragging||(e.update(this.camera),this.render())})}let s=this.show.bind(this),c=this.hide.bind(this),l=()=>{this.helperObject3D.update(this.camera),this.isDragging&&this.updateDragGuideLineScale(),this.render()};l(),this.domEvents.addEventListener(this.helperObject3D,`mousedown`,this.dragStart),document.addEventListener(`mousemove`,this.dragging),document.addEventListener(`mouseup`,this.dragEnd),this.domEvents.addEventListener(this.helperObject3D,`touchstart`,this.dragStart),document.addEventListener(`touchmove`,this.dragging),document.addEventListener(`touchend`,this.dragEnd),this.hooks.on(`rotateStart`,c),this.hooks.on(`rotateEnd`,s),this.hooks.on(`scaleStart`,c),this.hooks.on(`scaleEnd`,s),this.hooks.on(`moveByMouseEnable`,c),this.hooks.on(`moveByMouseDisable`,s),this.hooks.on(`updateOtherHelpers`,e=>{this.helperObject3D.update(e.camera),this.render()}),this.cameraHooks.on(`cameraUpdate`,l),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,`mousedown`,this.dragStart),document.removeEventListener(`mousemove`,this.dragging),document.removeEventListener(`mouseup`,this.dragEnd),this.domEvents.removeEventListener(this.helperObject3D,`touchstart`,this.dragStart),document.removeEventListener(`touchmove`,this.dragging),document.removeEventListener(`touchend`,this.dragEnd),this.hooks.off(`rotateStart`,c),this.hooks.off(`rotateEnd`,s),this.hooks.off(`scaleStart`,c),this.hooks.off(`scaleEnd`,s),this.hooks.off(`moveByMouseEnable`,c),this.hooks.off(`moveByMouseDisable`,s),this.hooks.off(`updateOtherHelpers`),this.cameraHooks.off(`cameraUpdate`,l)}),this.moveByMouseEnable&&this.moveByMouse()}dispose(){var e;super.dispose(),(e=this.disposers)==null||e.forEach(e=>e==null?void 0:e())}moveByMouse(e){this._moveByMouse={enabled:!0,useFaceNormal:e==null?void 0:e.useFaceNormal},this.preventTapDefaultEvent=!0;let t=this.handleMouseDown.bind(this),n=this.handleMouseUp.bind(this);this.hooks.emit(`moveByMouseEnable`),setTimeout(()=>{this.container.addEventListener(`mousedown`,t),this.container.addEventListener(`mouseup`,n)}),this.mousedownEventListenerDisposer=()=>{this.container.removeEventListener(`mousedown`,t),this.container.removeEventListener(`mouseup`,n)}}disableMoveByMouse(){var e;this._moveByMouse={enabled:!1},this.preventTapDefaultEvent=!1,this.hooks.emit(`moveByMouseDisable`),(e=this.mousedownEventListenerDisposer)==null||e.call(this)}onIntersectionOnModelUpdate(e){var t,n,r;if(!this.moveByMouseEnable)return;let{point:i,face:a}=e;if(!this.hooks.emit(`wantToMove`,i)){if(this.originObject3D.position.copy(i),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.enable!==!1)&&a!=null&&a.normal){let e=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0},i=new O((t=e.x)==null?0:t,(n=e.y)==null?0:n,(r=e.z)==null?0:r),o=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(a.normal):a.normal;this.originObject3D.quaternion.setFromUnitVectors(i,o),this.internalHooks.emit(`setObjectRotate`,this.originObject3D.quaternion.clone(),new O)}this.internalHooks.emit(`setObjectPosition`,i),this.hooks.emit(`move`,i)}}handleMouseDown(e){let{x:t,y:n}=e;this.mouseInfo={x:t,y:n,mouseDownTimestamp:Date.now()}}handleMouseUp(e){if(!this.mouseInfo)return;let{x:t,y:n}=e;this.mouseInfo.x===t&&this.mouseInfo.y===n&&Date.now()-this.mouseInfo.mouseDownTimestamp<500&&(this.disableMoveByMouse(),this.mouseInfo=void 0)}updateDragGuideLineScale(){if(!this.dragGuideLine||!this.startInfo)return;let{line:e}=this.startInfo,t=e.end.clone().sub(e.start).normalize();if(t.lengthSq()<1e-6)return;let n=this.helperObject3D.getWorldPosition(new O);this.solidGuide.updateSolidLine(this.dragGuideLine,n,t)}move(e){if(!this.startInfo)return this.dragEnd();let{line:t,startVectorProject:n}=this.startInfo,r=this.originObject3D,i=this.startInfo.draggingDirection===`plane`||this.startInfo.draggingDirection===`xy`||this.startInfo.draggingDirection===`xz`||this.startInfo.draggingDirection===`yz`,a;if(i){let t=this.startInfo.plane;if(!t)return;let n=new O,r=t.normal.dot(e.ray.direction);if(Math.abs(r)<1e-6)return;let i=-(t.normal.dot(e.ray.origin)+t.constant)/r;if(i<0)return;n.copy(e.ray.origin.clone().add(e.ray.direction.clone().multiplyScalar(i))),a=n}else a=QC({raycaster:e,line:t,clampToLine:!1});let o=r.position.clone(),s=a.clone().sub(n),c=new k;c.setPosition(s);let l=r.position.clone().applyMatrix4(c);if(this.hooks.emit(`wantToMove`,l))return;let u=l.clone();this.hooks.emit(`moveBefore`,u);let d=new k;d.setPosition(u.clone().sub(o)),r.position.copy(u),this.setTipsText(u),this.setTipsPosition(u),n.copy(a),this.internalHooks.emit(`applyObjectPosition`,{matrix:d}),this.hooks.emit(`move`,u)}setTipsText(e){var t;let n=(t=this.helperObject3D.moveTips)==null?void 0:t.element;if(!n||!this.startInfo)return;let r=this.startInfo.draggingDirection,i=e=>e.toFixed(3);switch(r){case`x`:n.innerText=`x: ${i(e.x)}`;break;case`y`:n.innerText=`y: ${i(e.y)}`;break;case`z`:n.innerText=`z: ${i(e.z)}`;break;case`xy`:n.innerText=`x: ${i(e.x)} y: ${i(e.y)}`;break;case`xz`:n.innerText=`x: ${i(e.x)} z: ${i(e.z)}`;break;case`yz`:n.innerText=`y: ${i(e.y)} z: ${i(e.z)}`;break;case`plane`:n.innerText=`x: ${i(e.x)} y: ${i(e.y)} z: ${i(e.z)}`;break}}setTipsPosition(e){let t=this.helperObject3D.moveTips;if(!t)return;let{x:n,y:r,z:i}=this.helperObject3D.getWorldPosition(new O).clone().project(this.camera);if(i>1){t.hide();return}let a=this.container.getBoundingClientRect(),o=(n+1)/2*a.width,s=(-r+1)/2*a.height;t.setLeftTop(o+`px`,s+`px`)}},ew=class{constructor(e,t,n,r,i,a,o,s,c){this.onFiveWantsTapGesture=e=>{if(!this.helperController)return;if(this.helperController.preventTapDefaultEvent)return!1;let t=this.helperController.onWantsTapGesture(e);return this.five.needsRender=!0,t},this.onFiveWantsGesture=(...e)=>{if(!this.helperController)return;let t=this.helperController.onWantsGesture(...e);return this.five.needsRender=!0,t},this.onFiveIntersectionOnModelUpdate=(...e)=>{this.helperController&&this.helperController.onIntersectionOnModelUpdate(...e)};let{camera:l,model:u,scene:d}=e,f=e.getElement();if(this.five=e,!l||!u||!f||!d)return;let p=c==null?d:c,m=()=>{e.needsRender=!0};this.helperController=new n({camera:l,model:u,domEvents:t,originObject3D:r,helperObject3D:i,container:f,scene:p,onRender:m,sharedHooks:o,sharedInternalHooks:s},a),e.on(`wantsTapGesture`,this.onFiveWantsTapGesture),e.on(`wantsGesture`,this.onFiveWantsGesture),e.on(`intersectionOnModelUpdate`,this.onFiveIntersectionOnModelUpdate)}dispose(){var e;this.five.off(`wantsTapGesture`,this.onFiveWantsTapGesture),this.five.off(`wantsGesture`,this.onFiveWantsGesture),this.five.off(`intersectionOnModelUpdate`,this.onFiveIntersectionOnModelUpdate),(e=this.helperController)==null||e.dispose()}},tw=new at,nw=class extends qC{get rotateCenter(){return this.helperObject3D.position.clone()}constructor(...e){var t,n,r;super(...e),this.name=`RotateController`,this.solidGuide=new YC(this.camera,this.container),this.snapGuideLines=[];let i=this.helperObject3D;this.hoverListener([(t=i.xCircle)==null?void 0:t.circle,(n=i.yCircle)==null?void 0:n.circle,(r=i.zCircle)==null?void 0:r.circle].filter(Boolean));let a=this.dragStart.bind(this),o=this.dragging.bind(this),s=this.dragEnd.bind(this),c=this.show.bind(this),l=this.hide.bind(this),u=()=>{this.helperObject3D.update(this.camera),this.render()};u(),this.domEvents.addEventListener(this.helperObject3D,`mousedown`,a),document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s),this.domEvents.addEventListener(this.helperObject3D,`touchstart`,a),document.addEventListener(`touchmove`,o),document.addEventListener(`touchend`,s),this.hooks.on(`moveStart`,l),this.hooks.on(`moveEnd`,c),this.hooks.on(`scaleStart`,l),this.hooks.on(`scaleEnd`,c),this.hooks.on(`moveByMouseEnable`,l),this.hooks.on(`moveByMouseDisable`,c),this.hooks.on(`updateOtherHelpers`,e=>{this.helperObject3D.update(e.camera),this.render()}),this.cameraHooks.on(`cameraUpdate`,u),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,`mousedown`,a),document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s),this.domEvents.removeEventListener(this.helperObject3D,`touchstart`,a),document.removeEventListener(`touchmove`,o),document.removeEventListener(`touchend`,s),this.hooks.off(`moveStart`,l),this.hooks.off(`moveEnd`,c),this.hooks.off(`scaleStart`,l),this.hooks.off(`scaleEnd`,c),this.hooks.off(`moveByMouseEnable`,l),this.hooks.off(`moveByMouseDisable`,c),this.hooks.off(`updateOtherHelpers`),this.cameraHooks.off(`cameraUpdate`,u)})}setRotateAngle(e){let{x:t=0,y:n=0,z:r=0}=e,i=new It(rt.degToRad(t),rt.degToRad(n),rt.degToRad(r)),a=new at().setFromEuler(i);if(this.hooks.emit(`wantToRotate`,a))return;let{originObject3D:o,rotateCenter:s}=this;gC(o,a,s),this.internalHooks.emit(`setObjectRotate`,a,s),this.hooks.emit(`rotate`,a),this.render()}getEulerAngle(e,t){let{originObject3D:n}=this,r=new It().setFromQuaternion(n.quaternion),i={x:rt.radToDeg(r.x),y:rt.radToDeg(r.y),z:rt.radToDeg(r.z)},a={x:e===`x`?t:i.x,y:e===`y`?t:i.y,z:e===`z`?t:i.z},o=new It(rt.degToRad(a.x),rt.degToRad(a.y),rt.degToRad(a.z));return new at().setFromEuler(o)}onApplyOriginObjectRotate(e){this.isDragging||super.onApplyOriginObjectRotate(e)}onApplyOriginObjectScale(e){}dragStart(e){if(this.isDragging)return;this.helperObject3D.update(this.camera);let t=e==null?void 0:e.intersect;if(!t)return this.dragEnd();let n=(t==null?void 0:t.object).direction;if(!n)return this.dragEnd();let r=t.point;this.setTipsAngle(0);let i=r.clone();i.y+=.2,this.setTipsPosition(i);let a=new at,o=n===`x`?new O(1,0,0):n===`y`?new O(0,1,0):n===`z`?new O(0,0,1):new O(0,1,0),s=new Ir().setFromNormalAndCoplanarPoint(o,r),c=s.projectPoint(r.clone(),new O).clone().sub(this.rotateCenter),l=this.getAngleHelper(n);if(!l)return this.dragEnd();let u=c.angleTo(l.baseAxes.clone().applyQuaternion(a)),d=l.offsetAngle(u);this.setAngleHelperStart(n,d),this.setAngleHelperLength(n,0),this.startInfo={direction:n,startVector:c,directionVector:o,plane:s,angleHelper:l,angle:0,helperQuaternion:a.clone(),startQuaternion:this.originObject3D.quaternion.clone()},tw=new at,this.helperObject3D.showDraggingHelper([n]),this.hooks.emit(`rotateStart`,n),this.isDragging=!0}getMatrix(){var e,t;return(t=(e=this.originObject3D)==null?void 0:e.ext)==null?void 0:t.matrix}getMatrixAngle(e,t){let n;if(e&&e.isMatrix4){n=new at,e.decompose(new O,n,new O);let r=new It().setFromQuaternion(n);if(t===`x`)return Math.round(rt.radToDeg(r.z));if(t===`y`)return Math.round(rt.radToDeg(r.y));if(t===`z`)return Math.round(rt.radToDeg(r.x))}}parseAngleByDirection(e){var t,n;let r=(n=(t=this.originObject3D)==null?void 0:t.ext)==null?void 0:n.matrix,i;if(r&&r.isMatrix4){i=new at,r.decompose(new O,i,new O);let t=new It().setFromQuaternion(i);if(e===`x`)return Math.round(rt.radToDeg(t.z));if(e===`y`)return Math.round(rt.radToDeg(t.y));if(e===`z`)return Math.round(rt.radToDeg(t.x))}}dragging(e){if(!this.isDragging)return;let t=`touches`in e?e.touches[0].clientX:e.x,n=`touches`in e?e.touches[0].clientY:e.y,r=ZC(this.camera,{x:t,y:n},this.container);return r?(this.rotate(r),!1):this.dragEnd()}rotate(e){if(!this.startInfo)return this.dragEnd();let{startVector:t,plane:n,angleHelper:r,direction:i,helperQuaternion:a}=this.startInfo,{originObject3D:o}=this,s=e.ray.intersectPlane(n,new O);if(!s)return;let c=this.rotateCenter.clone(),l=n.projectPoint(s.clone(),new O).clone().sub(c),u=this.startInfo.directionVector.clone().normalize();l=l.clone().projectOnPlane(u).normalize().multiplyScalar(l.length());let d=new at().setFromUnitVectors(t.clone().normalize(),l.clone().normalize()),f=o.quaternion.clone().premultiply(d);if(t.angleTo(l)===0||this.hooks.emit(`wantToRotate`,f))return;let p=new It().setFromQuaternion(new at().setFromUnitVectors(t.clone().normalize().applyQuaternion(a.clone().invert()),l.clone().normalize().applyQuaternion(a.clone().invert())),`${i.toUpperCase()}${`XZY`.replace(i.toUpperCase(),``)}`)[i]*r.angleDirection,m=this.startInfo.angle,h=m+p,g=Math.PI/2,_=rt.degToRad(5),v=rt.degToRad(10),y=new at().setFromAxisAngle(u,h),b=this.startInfo.startQuaternion.clone().premultiply(y),x=this.extractAxisAngle(b,u),S=Math.round(x/g)*g,C=Math.abs(x-S);if(Math.abs(h)>v&&C<_){let e=S-x;h+=e}let ee=h-m;this.startInfo.angle=h;let te=Math.abs(ee)<1e-6&&Math.abs(p)>1e-6,ne=this.snapGuideLines.length>0;te&&!ne?this.showSnapGuideLines(i,c):!te&&ne&&this.removeSnapGuideLines(),this.setAngleHelperLength(i,this.startInfo.angle),this.setTipsAngle(rt.radToDeg(this.startInfo.angle));let w=new at().setFromAxisAngle(u,ee);if(c){let e=new O().subVectors(o.position,c).applyQuaternion(w).add(c);o.position.copy(e)}o.applyQuaternion(w),tw.premultiply(w),this.internalHooks.emit(`applyObjectRotate`,{quaternion:w,origin:c}),this.hooks.emit(`rotate`,o.quaternion),te||(this.startInfo.startVector=l)}dragEnd(){var e;this.isDragging&&(this.removeSnapGuideLines(),(e=this.startInfo)!=null&&e.lineMeshes&&this.startInfo.lineMeshes.forEach(e=>{this.scene.remove(e),e.geometry.dispose(),e.material instanceof sr&&e.material.dispose()}),this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.updateOtherHelpers(),this.hooks.emit(`rotateEnd`))}updateOtherHelpers(){this.hooks.emit(`updateOtherHelpers`,{camera:this.camera})}getAngleHelper(e){var t,n,r;switch(e){case`x`:return(t=this.helperObject3D.xCircle)==null?void 0:t.angleSector;case`y`:return(n=this.helperObject3D.yCircle)==null?void 0:n.angleSector;case`z`:return(r=this.helperObject3D.zCircle)==null?void 0:r.angleSector}}setAngleHelperStart(e,t){let n=this.getAngleHelper(e);if(!n){console.warn(`angleHelper is undefined`);return}if(n instanceof Or&&n.geometry instanceof ni){let{radius:e,segments:r,thetaLength:i}=n.geometry.parameters;n.geometry=new ni(e,r,t,i)}else console.warn(`only support THREE.CircleGeometry`)}setAngleHelperLength(e,t){let n=e===`x`||e===`y`?-t:t,r=n>=0?Math.max(n,.001):Math.min(n,-.001),i=this.getAngleHelper(e);if(i instanceof Or&&i.geometry instanceof ni){let{radius:e,thetaStart:t}=i.geometry.parameters;i.geometry=new ni(e,Math.ceil(Math.abs(r)*(40/(2*Math.PI))),t,r)}else console.warn(`only support THREE.CircleGeometry`)}setTipsAngle(e){var t;let n=(t=this.helperObject3D.angleTips)==null?void 0:t.element;n&&(n.innerText=`${e.toFixed(0)}°`)}setTipsPosition(e){let t=this.helperObject3D.angleTips;if(!t)return;let{x:n,y:r,z:i}=this.helperObject3D.getWorldPosition(new O).clone().project(this.camera);if(i>1){t.hide();return}let a=this.container.getBoundingClientRect(),o=(n+1)/2*a.width,s=(-r+1)/2*a.height;t.setLeftTop(o+`px`,s+`px`)}extractAxisAngle(e,t){let n=t.clone().normalize(),r=e.x*n.x+e.y*n.y+e.z*n.z,i=e.w,a=2*Math.atan2(r,i);return Math.atan2(Math.sin(a),Math.cos(a))}showSnapGuideLines(e,t){this.removeSnapGuideLines();let n=(()=>{switch(e){case`x`:return[new O(0,1,0),new O(0,0,1)];case`y`:return[new O(1,0,0),new O(0,0,1)];case`z`:return[new O(1,0,0),new O(0,1,0)];default:return[]}})();for(let e of n){let n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:EC.DRAG_GUIDE_LINE});this.scene.add(n),this.snapGuideLines.push(n)}this.render()}removeSnapGuideLines(){for(let e of this.snapGuideLines)this.scene.remove(e),this.solidGuide.dispose(e);this.snapGuideLines=[]}},rw=class extends qC{constructor(...e){super(...e),this.name=`BoundingBoxController`;let t=()=>{this.syncWithObject(),this.render()};this.hooks.on(`moveEnd`,t),this.hooks.on(`rotateEnd`,t),this.hooks.on(`scaleEnd`,t),this.disposers.push(()=>{this.hooks.off(`moveEnd`,t),this.hooks.off(`rotateEnd`,t),this.hooks.off(`scaleEnd`,t)})}onApplyOriginObjectRotate(e){this.helperObject3D.applyHelperQuaternion(e.quaternion,e.origin)}onSetOriginObjectRotate(e,t){this.helperObject3D.setHelperQuaternion(e,t)}syncWithObject(){this.helperObject3D.position.copy(this.originObject3D.position),this.helperObject3D.quaternion.copy(this.originObject3D.quaternion),this.helperObject3D.scale.copy(this.originObject3D.scale);let e=this.helperObject3D;e.update&&e.update()}};function $(e,t){this._camera=e||null,this._domElement=t||document,this._raycaster=new Qi,this._selected=null,this._boundObjs={};var n=this;this._$onClick=function(){n._onClick.apply(n,arguments)},this._$onDblClick=function(){n._onDblClick.apply(n,arguments)},this._$onMouseMove=function(){n._onMouseMove.apply(n,arguments)},this._$onMouseDown=function(){n._onMouseDown.apply(n,arguments)},this._$onMouseUp=function(){n._onMouseUp.apply(n,arguments)},this._$onTouchMove=function(){n._onTouchMove.apply(n,arguments)},this._$onTouchStart=function(){n._onTouchStart.apply(n,arguments)},this._$onTouchEnd=function(){n._onTouchEnd.apply(n,arguments)},this._$onContextmenu=function(){n._onContextmenu.apply(n,arguments)},this._domElement.addEventListener(`click`,this._$onClick,!1),this._domElement.addEventListener(`dblclick`,this._$onDblClick,!1),this._domElement.addEventListener(`mousemove`,this._$onMouseMove,!1),this._domElement.addEventListener(`mousedown`,this._$onMouseDown,!1),this._domElement.addEventListener(`mouseup`,this._$onMouseUp,!1),this._domElement.addEventListener(`touchmove`,this._$onTouchMove,!1),this._domElement.addEventListener(`touchstart`,this._$onTouchStart,!1),this._domElement.addEventListener(`touchend`,this._$onTouchEnd,!1),this._domElement.addEventListener(`contextmenu`,this._$onContextmenu,!1)}$.prototype.destroy=function(){this._domElement.removeEventListener(`click`,this._$onClick,!1),this._domElement.removeEventListener(`dblclick`,this._$onDblClick,!1),this._domElement.removeEventListener(`mousemove`,this._$onMouseMove,!1),this._domElement.removeEventListener(`mousedown`,this._$onMouseDown,!1),this._domElement.removeEventListener(`mouseup`,this._$onMouseUp,!1),this._domElement.removeEventListener(`touchmove`,this._$onTouchMove,!1),this._domElement.removeEventListener(`touchstart`,this._$onTouchStart,!1),this._domElement.removeEventListener(`touchend`,this._$onTouchEnd,!1),this._domElement.removeEventListener(`contextmenu`,this._$onContextmenu,!1)},$.eventNames=[`click`,`dblclick`,`mouseover`,`mouseout`,`mousemove`,`mousedown`,`mouseup`,`contextmenu`,`touchstart`,`touchend`],$.prototype._getRelativeMouseXY=function(e){var t=e.target||e.srcElement;t.nodeType===3&&(t=t.parentNode);var n={x:0,y:0},r=t,i=getComputedStyle(r,null);n.y+=parseInt(i.getPropertyValue(`padding-top`),10),n.x+=parseInt(i.getPropertyValue(`padding-left`),10);do n.x+=r.offsetLeft,n.y+=r.offsetTop,i=getComputedStyle(r,null),n.x+=parseInt(i.getPropertyValue(`border-left-width`),10),n.y+=parseInt(i.getPropertyValue(`border-top-width`),10);while(r=r.offsetParent);var a={width:t===window?window.innerWidth:t.offsetWidth,height:t===window?window.innerHeight:t.offsetHeight};return{x:Number((e.pageX-n.x)/a.width)*2-1,y:-((e.pageY-n.y)/a.height)*2+1}},$.prototype._objectCtxInit=function(e){e._3xDomEvent={}},$.prototype._objectCtxDeinit=function(e){delete e._3xDomEvent},$.prototype._objectCtxIsInit=function(e){return!!e._3xDomEvent},$.prototype._objectCtxGet=function(e){return e._3xDomEvent},$.prototype.camera=function(e){return e&&(this._camera=e),this._camera},$.prototype.bind=function(e,t,n,r){console.assert($.eventNames.indexOf(t)!==-1,`not available events:`+t),this._objectCtxIsInit(e)||this._objectCtxInit(e);var i=this._objectCtxGet(e);i[t+`Handlers`]||(i[t+`Handlers`]=[]),i[t+`Handlers`].push({callback:n,useCapture:r}),this._boundObjs[t]===void 0&&(this._boundObjs[t]=[]),this._boundObjs[t].push(e)},$.prototype.addEventListener=$.prototype.bind,$.prototype.unbind=function(e,t,n,r){console.assert($.eventNames.indexOf(t)!==-1,`not available events:`+t),this._objectCtxIsInit(e)||this._objectCtxInit(e);var i=this._objectCtxGet(e);i[t+`Handlers`]||(i[t+`Handlers`]=[]);for(var a=i[t+`Handlers`],o=0;o<a.length;o++){var s=a[o];if(n==s.callback&&r==s.useCapture){a.splice(o,1);break}}var c=this._boundObjs[t].indexOf(e);this._boundObjs[t].splice(c,1)},$.prototype.removeEventListener=$.prototype.unbind,$.prototype._bound=function(e,t){var n=this._objectCtxGet(t);return n?!!n[e+`Handlers`]:!1},$.prototype._isObjectVisible=function(e){for(var t=e;t;){if(t.visible===!1)return!1;t=t.parent}return!0},$.prototype._filterVisibleObjects=function(e){var t=this;return e.filter(function(e){return t._isObjectVisible(e)})},$.prototype._onMove=function(e,t,n,r){var i=this._boundObjs[e];if(!(i===void 0||i.length===0)){var a=this._filterVisibleObjects(i);if(a.length!==0){var o=new it;o.set(t,n),this._raycaster.setFromCamera(o,this._camera);var s=this._raycaster.intersectObjects(a),c=this;s=s.filter(function(e){return c._isObjectVisible(e.object)}),s.sort(function(e,t){var n=e.object.renderOrder||0,r=t.object.renderOrder||0;return n===r?e.distance-t.distance:r-n});var l=this._selected;if(s.length>0){var u,d,f,p=s[0],m=p.object;this._selected=m,f=this._bound(`mousemove`,m),l!=m&&(u=this._bound(`mouseover`,m),d=l&&this._bound(`mouseout`,l))}else d=l&&this._bound(`mouseout`,l),this._selected=null;f&&this._notify(`mousemove`,m,r,p),u&&this._notify(`mouseover`,m,r,p),d&&this._notify(`mouseout`,l,r,p)}}},$.prototype._onEvent=function(e,t,n,r){var i=this._boundObjs[e];if(!(i===void 0||i.length===0)){var a=this._filterVisibleObjects(i);if(a.length!==0){var o=new it;o.set(t,n),this._raycaster.setFromCamera(o,this._camera);var s=this._raycaster.intersectObjects(a,!0),c=this;if(s=s.filter(function(e){return c._isObjectVisible(e.object)}),s.sort(function(e,t){var n=e.object.renderOrder||0,r=t.object.renderOrder||0;return n===r?e.distance-t.distance:r-n}),s.length!==0){for(var l=s[0],u=l.object,d=this._objectCtxGet(u),f=u.parent;d===void 0&&f;)d=this._objectCtxGet(f),f=f.parent;d&&this._notify(e,u,r,l)}}}},$.prototype._notify=function(e,t,n,r){var i=this._objectCtxGet(t),a=i?i[e+`Handlers`]:null;if(!i||!a||a.length===0){t.parent&&this._notify(e,t.parent,n,r);return}for(var a=i[e+`Handlers`],o=0;o<a.length;o++){var s=a[o],c=!0;s.callback({type:e,target:t,origDomEvent:n,intersect:r,stopPropagation:function(){c=!1}}),c&&s.useCapture===!1&&t.parent&&this._notify(e,t.parent,n,r)}},$.prototype._onMouseDown=function(e){return this._onMouseEvent(`mousedown`,e)},$.prototype._onMouseUp=function(e){return this._onMouseEvent(`mouseup`,e)},$.prototype._onMouseEvent=function(e,t){var n=this._getRelativeMouseXY(t);this._onEvent(e,n.x,n.y,t)},$.prototype._onMouseMove=function(e){var t=this._getRelativeMouseXY(e);this._onMove(`mousemove`,t.x,t.y,e),this._onMove(`mouseover`,t.x,t.y,e),this._onMove(`mouseout`,t.x,t.y,e)},$.prototype._onClick=function(e){this._onMouseEvent(`click`,e)},$.prototype._onDblClick=function(e){this._onMouseEvent(`dblclick`,e)},$.prototype._onContextmenu=function(e){this._onMouseEvent(`contextmenu`,e)},$.prototype._onTouchStart=function(e){return this._onTouchEvent(`touchstart`,e)},$.prototype._onTouchEnd=function(e){return this._onTouchEvent(`touchend`,e)},$.prototype._onTouchMove=function(e){if(e.touches.length==1){var t=Number(e.touches[0].pageX/window.innerWidth)*2-1,n=-(e.touches[0].pageY/window.innerHeight)*2+1;this._onMove(`mousemove`,t,n,e),this._onMove(`mouseover`,t,n,e),this._onMove(`mouseout`,t,n,e)}},$.prototype._onTouchEvent=function(e,t){var n=t.touches;if(n.length==0&&(n=t.changedTouches),n.length==1){var r=Number(n[0].pageX/window.innerWidth)*2-1,i=-(n[0].pageY/window.innerHeight)*2+1;this._onEvent(e,r,i,t)}};var iw=`Object3DHelperPlugin`,aw=iw,ow=()=>{console.error(`${aw} is disposed`)},sw=()=>{console.warn(`${aw} is disabled`)},cw=()=>{console.error(`${aw} is disabled`)},lw=class{constructor(e){this.controllers={},this.state={visible:!0,enabled:!0,disposed:!1},this.hooks=new t.Subscribe,e&&this.addControllers(e),this.setState(this.state)}show(e){this.setState({visible:!0},e)}hide(e){this.setState({visible:!1},e)}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}setState(e,t){if(this.state.disposed||!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return;let n=Object.assign({},this.state);this.state=Object.assign(Object.assign({},this.state),e),e.disposed!==void 0&&e.disposed!==n.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&this.handleVisible(e.visible),e.enabled!==void 0&&this.handleEnable(e.enabled),this.hooks.emit(`stateChange`,{state:this.state,prevState:n})}addControllers(e){this.controllers=Object.assign(Object.assign({},this.controllers),e),this.setState(this.state)}initialHelperMatrix(){this.everyControllerDo(e=>{e.initialHelperPosition(),e.initialHelperQuaternion()})}handleEnable(e,t=!0){e?(this.everyControllerDo(e=>e.enable()),this.hooks.emit(`enable`,{userAction:t})):(this.everyControllerDo(e=>e.disable()),this.hooks.emit(`disable`,{userAction:t}))}handleVisible(e,t=!0){e?(this.everyControllerDo(e=>e.show()),this.state.enabled&&this.hooks.emit(`show`,{userAction:t})):(this.everyControllerDo(e=>e.hide()),this.state.enabled&&this.hooks.emit(`hide`,{userAction:t}))}handleDispose(){Object.values(this.controllers).forEach(e=>{e==null||e.dispose()})}everyControllerDo(e){Object.values(this.controllers).forEach(t=>{t&&e(t)})}},uw=class extends o.Controller{constructor(e){super(e),this.name=iw,this.state={visible:!0,enabled:!0,disposed:!1},this.objectHelperMap=new Map,this.five=e}show(e){return r(this,void 0,void 0,function*(){this.setState({visible:!0},e)})}hide(e){return r(this,void 0,void 0,function*(){this.setState({visible:!1},e)})}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}load(e){return r(this,void 0,void 0,function*(){})}setState(e,t){var n;if(this.state.disposed)return ow();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return cw();let r=Object.assign({},this.state);this.state=Object.assign(Object.assign({},this.state),e),e.disposed!==void 0&&e.disposed!==r.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&e.visible!==r.visible&&this.handleVisible(e.visible),e.enabled!==void 0&&e.enabled!==r.enabled&&this.handleEnable(e.enabled),this.hooks.emit(`stateChange`,{state:this.state,prevState:r,userAction:(n=t==null?void 0:t.userAction)==null?!0:n})}getObject3DHelper(e){return this.objectHelperMap.get(e)}addObject3DHelper(e,n={}){var r,i;if(!e){console.error(`Object3D is undefined`);return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} already has helper`);return}let a=new lw,o=[],s=(r=this.five.getElement())==null?void 0:r.parentElement;this.five.camera;let c=Object.assign(Object.assign({},{moveHelper:!0,rotateHelper:!0,boundingBoxHelper:!1,moveHelperTips:!1,positionFrom:`objectPosition`}),n),{moveHelper:l,rotateHelper:u,boundingBoxHelper:d}=c,f=new en;c.helperOffset&&f.position.copy(c.helperOffset),this.five.scene.add(f);let p=a.hooks,m=new t.Subscribe,h=new $(this.five.camera,this.five.getElement()),g=e=>{if(e)return typeof e==`boolean`?e:e.enable},_={};if(g(l)){let t=Object.assign(Object.assign({},this.getConfig(c.moveHelper)),c),n=new LC(e,Object.assign({container:s==null?void 0:s,moveTipsEnable:(i=c.moveHelperTips)==null?!1:i},t)),r=new ew(this.five,h,$C,e,n,t,p,m,f);_.moveController=r.helperController,o.push(()=>r.dispose())}if(g(u)){let t=Object.assign(Object.assign({},this.getConfig(c.rotateHelper)),c),n=new RC(e,Object.assign({container:s==null?void 0:s},t)),r=new ew(this.five,h,nw,e,n,t,p,m,f);_.rotateController=r.helperController,o.push(()=>r.dispose())}if(g(d)){let t=new UC(e),n=new ew(this.five,h,rw,e,t,void 0,p,m,f);_.boundingBoxController=n.helperController,o.push(()=>n.dispose())}return Object.values(_).forEach(e=>{e&&typeof e.updateOtherControllers==`function`&&e.updateOtherControllers(_)}),a.addControllers(_),this.objectHelperMap.set(e,{helper:a,disposers:o,helperGroup:f}),a.controllers}removeObject3DHelper(e){if(!this.objectHelperMap.has(e))return;let{helper:t,disposers:n,helperGroup:r}=this.objectHelperMap.get(e);this.objectHelperMap.delete(e),t.dispose(),n==null||n.forEach(e=>e==null?void 0:e()),r.parent&&r.parent.remove(r)}handleEnable(e,t=!0){e?(this.everyHelperDo(e=>e.enable()),this.hooks.emit(`enable`,{userAction:t})):(this.everyHelperDo(e=>e.disable()),this.hooks.emit(`disable`,{userAction:t})),this.state.enabled=e}handleVisible(e,t=!0){e?(this.everyHelperDo(e=>e.show()),this.actionIfStateIsEnabled(()=>this.hooks.emit(`show`,{userAction:t}))):(this.everyHelperDo(e=>e.hide()),this.actionIfStateIsEnabled(()=>this.hooks.emit(`hide`,{userAction:t}))),this.state.visible=e}handleDispose(){this.objectHelperMap.forEach(({helper:e,disposers:t,helperGroup:n})=>{e.dispose(),t==null||t.forEach(e=>e==null?void 0:e()),n.parent&&n.parent.remove(n)}),this.objectHelperMap.clear()}everyHelperDo(e){this.objectHelperMap.forEach(({helper:t,disposers:n})=>{t&&e(t,n)})}actionIfStateIsEnabled(e,t){if(this.state.enabled)return e();t!=null&&t.warnLog&&sw()}getConfig(e){if(e&&typeof e!=`boolean`&&e.enable)return e}},dw=e=>new uw(e);Q.BRDF_GGX,Q.BRDF_Lambert,Q.BasicPointShadowFilter,Q.BasicShadowFilter,Q.Break,Q.Const,Q.Continue,Q.DFGLUT,Q.D_GGX;var fw=Q.Discard;Q.EPSILON,Q.F_Schlick;var pw=Q.Fn;Q.INFINITY,Q.If,Q.Loop,Q.NodeAccess,Q.NodeShaderStage,Q.NodeType,Q.NodeUpdateType,Q.PCFShadowFilter,Q.PCFSoftShadowFilter,Q.PI,Q.PI2,Q.TWO_PI,Q.HALF_PI,Q.PointShadowFilter,Q.Return,Q.Schlick_to_F0,Q.ShaderNode,Q.Stack,Q.Switch,Q.TBNViewMatrix,Q.VSMShadowFilter,Q.V_GGX_SmithCorrelated,Q.Var,Q.VarIntent,Q.abs,Q.acesFilmicToneMapping,Q.acos,Q.add,Q.addMethodChaining,Q.addNodeElement,Q.agxToneMapping,Q.all,Q.alphaT,Q.and,Q.anisotropy,Q.anisotropyB,Q.anisotropyT,Q.any,Q.append,Q.array,Q.arrayBuffer,Q.asin,Q.assign,Q.atan,Q.atomicAdd,Q.atomicAnd,Q.atomicFunc,Q.atomicLoad,Q.atomicMax,Q.atomicMin,Q.atomicOr,Q.atomicStore,Q.atomicSub,Q.atomicXor,Q.attenuationColor,Q.attenuationDistance,Q.attribute,Q.attributeArray,Q.backgroundBlurriness,Q.backgroundIntensity,Q.backgroundRotation,Q.batch,Q.bentNormalView,Q.billboarding,Q.bitAnd,Q.bitNot,Q.bitOr,Q.bitXor,Q.bitangentGeometry,Q.bitangentLocal,Q.bitangentView,Q.bitangentWorld,Q.bitcast,Q.blendBurn,Q.blendColor,Q.blendDodge,Q.blendOverlay,Q.blendScreen,Q.blur,Q.bool,Q.buffer,Q.bufferAttribute,Q.bumpMap,Q.builtin,Q.builtinAOContext,Q.builtinShadowContext,Q.bvec2,Q.bvec3,Q.bvec4,Q.bypass,Q.cache,Q.call,Q.cameraFar,Q.cameraIndex,Q.cameraNear,Q.cameraNormalMatrix,Q.cameraPosition,Q.cameraProjectionMatrix,Q.cameraProjectionMatrixInverse,Q.cameraViewMatrix,Q.cameraViewport,Q.cameraWorldMatrix,Q.cbrt,Q.cdl,Q.ceil,Q.checker,Q.cineonToneMapping,Q.clamp,Q.clearcoat,Q.clearcoatNormalView,Q.clearcoatRoughness,Q.clipSpace,Q.code,Q.color,Q.colorSpaceToWorking,Q.colorToDirection,Q.compute,Q.computeKernel,Q.computeSkinning,Q.context,Q.convert,Q.convertColorSpace,Q.convertToTexture,Q.countLeadingZeros,Q.countOneBits,Q.countTrailingZeros,Q.cos,Q.cross,Q.cubeTexture,Q.cubeTextureBase,Q.dFdx,Q.dFdy,Q.dashSize,Q.debug,Q.decrement,Q.decrementBefore,Q.defaultBuildStages,Q.defaultShaderStages,Q.defined,Q.degrees,Q.deltaTime,Q.densityFog,Q.densityFogFactor,Q.depth,Q.depthPass,Q.determinant,Q.difference,Q.diffuseColor,Q.directPointLight,Q.directionToColor,Q.directionToFaceDirection,Q.dispersion,Q.distance,Q.div,Q.dot,Q.drawIndex,Q.dynamicBufferAttribute,Q.element,Q.emissive,Q.equal,Q.equirectUV,Q.exp,Q.exp2,Q.exponentialHeightFogFactor,Q.expression,Q.faceDirection,Q.faceForward,Q.faceforward,Q.float,Q.floatBitsToInt,Q.floatBitsToUint,Q.floor,Q.fog,Q.fract,Q.frameGroup,Q.frameId,Q.frontFacing,Q.fwidth,Q.gain,Q.gapSize,Q.getConstNodeType,Q.getCurrentStack,Q.getDirection,Q.getDistanceAttenuation,Q.getGeometryRoughness,Q.getNormalFromDepth,Q.interleavedGradientNoise,Q.vogelDiskSample,Q.getParallaxCorrectNormal,Q.getRoughness,Q.getScreenPosition,Q.getShIrradianceAt,Q.getShadowMaterial,Q.getShadowRenderObjectFunction,Q.getTextureIndex,Q.getViewPosition,Q.globalId,Q.glsl,Q.glslFn,Q.grayscale,Q.greaterThan,Q.greaterThanEqual,Q.hash,Q.highpModelNormalViewMatrix,Q.highpModelViewMatrix,Q.hue,Q.increment,Q.incrementBefore,Q.instance,Q.instanceIndex,Q.instancedArray,Q.instancedBufferAttribute,Q.instancedDynamicBufferAttribute,Q.instancedMesh,Q.int,Q.intBitsToFloat,Q.inverse,Q.inverseSqrt,Q.inversesqrt,Q.invocationLocalIndex,Q.invocationSubgroupIndex,Q.ior,Q.iridescence,Q.iridescenceIOR,Q.iridescenceThickness,Q.ivec2,Q.ivec3,Q.ivec4,Q.js,Q.label,Q.length,Q.lengthSq,Q.lessThan,Q.lessThanEqual,Q.lightPosition,Q.lightProjectionUV,Q.lightShadowMatrix,Q.lightTargetDirection,Q.lightTargetPosition,Q.lightViewPosition,Q.lightingContext,Q.lights,Q.linearDepth,Q.linearToneMapping,Q.localId,Q.log,Q.log2,Q.logarithmicDepthToViewZ,Q.luminance,Q.mat2,Q.mat3,Q.mat4,Q.matcapUV,Q.materialAO,Q.materialAlphaTest,Q.materialAnisotropy,Q.materialAnisotropyVector,Q.materialAttenuationColor,Q.materialAttenuationDistance,Q.materialClearcoat,Q.materialClearcoatNormal,Q.materialClearcoatRoughness,Q.materialColor,Q.materialDispersion,Q.materialEmissive,Q.materialEnvIntensity,Q.materialEnvRotation,Q.materialIOR,Q.materialIridescence,Q.materialIridescenceIOR,Q.materialIridescenceThickness,Q.materialLightMap,Q.materialLineDashOffset,Q.materialLineDashSize,Q.materialLineGapSize,Q.materialLineScale,Q.materialLineWidth,Q.materialMetalness,Q.materialNormal,Q.materialOpacity,Q.materialPointSize,Q.materialReference,Q.materialReflectivity,Q.materialRefractionRatio,Q.materialRotation,Q.materialRoughness,Q.materialSheen,Q.materialSheenRoughness,Q.materialShininess,Q.materialSpecular,Q.materialSpecularColor,Q.materialSpecularIntensity,Q.materialSpecularStrength,Q.materialThickness,Q.materialTransmission,Q.max,Q.maxMipLevel,Q.mediumpModelViewMatrix,Q.metalness,Q.min,Q.mix,Q.mixElement,Q.mod,Q.modInt,Q.modelDirection,Q.modelNormalMatrix,Q.modelPosition,Q.modelRadius,Q.modelScale,Q.modelViewMatrix,Q.modelViewPosition,Q.modelViewProjection,Q.modelWorldMatrix,Q.modelWorldMatrixInverse,Q.morphReference,Q.mrt,Q.mul,Q.mx_aastep,Q.mx_add,Q.mx_atan2,Q.mx_cell_noise_float,Q.mx_contrast,Q.mx_divide,Q.mx_fractal_noise_float,Q.mx_fractal_noise_vec2,Q.mx_fractal_noise_vec3,Q.mx_fractal_noise_vec4,Q.mx_frame,Q.mx_heighttonormal,Q.mx_hsvtorgb,Q.mx_ifequal,Q.mx_ifgreater,Q.mx_ifgreatereq,Q.mx_invert,Q.mx_modulo,Q.mx_multiply,Q.mx_noise_float,Q.mx_noise_vec3,Q.mx_noise_vec4,Q.mx_place2d,Q.mx_power,Q.mx_ramp4,Q.mx_ramplr,Q.mx_ramptb,Q.mx_rgbtohsv,Q.mx_rotate2d,Q.mx_rotate3d,Q.mx_safepower,Q.mx_separate,Q.mx_splitlr,Q.mx_splittb,Q.mx_srgb_texture_to_lin_rec709,Q.mx_subtract,Q.mx_timer,Q.mx_transform_uv,Q.mx_unifiednoise2d,Q.mx_unifiednoise3d,Q.mx_worley_noise_float,Q.mx_worley_noise_vec2,Q.mx_worley_noise_vec3,Q.negate,Q.neutralToneMapping,Q.nodeArray,Q.nodeImmutable,Q.nodeObject,Q.nodeObjectIntent,Q.nodeObjects,Q.nodeProxy,Q.nodeProxyIntent,Q.normalFlat,Q.normalGeometry,Q.normalLocal,Q.normalMap,Q.normalView,Q.normalViewGeometry,Q.normalWorld,Q.normalWorldGeometry,Q.normalize,Q.not,Q.notEqual,Q.numWorkgroups,Q.objectDirection,Q.objectGroup,Q.objectPosition,Q.objectRadius,Q.objectScale,Q.objectViewPosition,Q.objectWorldMatrix,Q.OnBeforeObjectUpdate,Q.OnBeforeMaterialUpdate,Q.OnObjectUpdate,Q.OnMaterialUpdate,Q.oneMinus,Q.or,Q.orthographicDepthToViewZ,Q.oscSawtooth,Q.oscSine,Q.oscSquare,Q.oscTriangle,Q.output,Q.outputStruct,Q.overloadingFn,Q.packHalf2x16,Q.packSnorm2x16,Q.packUnorm2x16,Q.parabola,Q.parallaxDirection,Q.parallaxUV,Q.parameter,Q.pass,Q.passTexture,Q.pcurve,Q.perspectiveDepthToViewZ,Q.pmremTexture,Q.pointShadow,Q.pointUV,Q.pointWidth;var mw=Q.positionGeometry;Q.positionLocal,Q.positionPrevious,Q.positionView,Q.positionViewDirection,Q.positionWorld,Q.positionWorldDirection,Q.posterize,Q.pow,Q.pow2,Q.pow3,Q.pow4,Q.premultiplyAlpha,Q.property,Q.radians,Q.rand,Q.range,Q.rangeFog,Q.rangeFogFactor,Q.reciprocal,Q.reference,Q.referenceBuffer,Q.reflect,Q.reflectVector,Q.reflectView,Q.reflector,Q.refract,Q.refractVector,Q.refractView,Q.reinhardToneMapping,Q.remap,Q.remapClamp,Q.renderGroup,Q.renderOutput,Q.rendererReference,Q.replaceDefaultUV,Q.rotate,Q.rotateUV,Q.roughness,Q.round,Q.rtt,Q.sRGBTransferEOTF,Q.sRGBTransferOETF,Q.sample,Q.sampler,Q.samplerComparison,Q.saturate,Q.saturation,Q.screen,Q.screenCoordinate,Q.screenDPR,Q.screenSize,Q.screenUV;var hw=Q.select;Q.setCurrentStack,Q.setName,Q.shaderStages,Q.shadow,Q.shadowPositionWorld,Q.shapeCircle,Q.sharedUniformGroup,Q.sheen,Q.sheenRoughness,Q.shiftLeft,Q.shiftRight,Q.shininess,Q.sign,Q.sin,Q.sinc,Q.skinning,Q.smoothstep,Q.smoothstepElement,Q.specularColor,Q.specularF90,Q.spherizeUV,Q.split,Q.spritesheetUV,Q.sqrt,Q.stack,Q.step,Q.stepElement,Q.storage,Q.storageBarrier,Q.storageTexture,Q.string,Q.struct,Q.sub,Q.subgroupAdd,Q.subgroupAll,Q.subgroupAnd,Q.subgroupAny,Q.subgroupBallot,Q.subgroupBroadcast,Q.subgroupBroadcastFirst,Q.subBuild,Q.subgroupElect,Q.subgroupExclusiveAdd,Q.subgroupExclusiveMul,Q.subgroupInclusiveAdd,Q.subgroupInclusiveMul,Q.subgroupIndex,Q.subgroupMax,Q.subgroupMin,Q.subgroupMul,Q.subgroupOr,Q.subgroupShuffle,Q.subgroupShuffleDown,Q.subgroupShuffleUp,Q.subgroupShuffleXor,Q.subgroupSize,Q.subgroupXor,Q.tan,Q.tangentGeometry,Q.tangentLocal,Q.tangentView,Q.tangentWorld;var gw=Q.texture;Q.texture3D,Q.textureBarrier,Q.textureBicubic,Q.textureBicubicLevel,Q.textureCubeUV,Q.textureLoad,Q.textureSize,Q.textureLevel,Q.textureStore,Q.thickness,Q.time,Q.toneMapping,Q.toneMappingExposure,Q.toonOutlinePass,Q.transformDirection,Q.transformNormal,Q.transformNormalToView,Q.transformedClearcoatNormalView,Q.transformedNormalView,Q.transformedNormalWorld,Q.transmission,Q.transpose,Q.triNoise3D,Q.triplanarTexture,Q.triplanarTextures,Q.trunc,Q.uint,Q.uintBitsToFloat;var _w=Q.uniform;Q.uniformArray,Q.uniformCubeTexture,Q.uniformGroup,Q.uniformFlow,Q.uniformTexture,Q.unpackHalf2x16,Q.unpackSnorm2x16,Q.unpackUnorm2x16,Q.unpremultiplyAlpha,Q.userData;var vw=Q.uv;Q.uvec2,Q.uvec3,Q.uvec4;var yw=Q.varying;Q.varyingProperty,Q.vec2;var bw=Q.vec3,xw=Q.vec4;Q.vectorComponents,Q.velocity,Q.vertexColor,Q.vertexIndex,Q.vertexStage,Q.vibrance,Q.viewZToLogarithmicDepth,Q.viewZToOrthographicDepth,Q.viewZToPerspectiveDepth,Q.viewZToReversedOrthographicDepth,Q.viewZToReversedPerspectiveDepth,Q.viewport,Q.viewportCoordinate,Q.viewportDepthTexture,Q.viewportLinearDepth,Q.viewportMipTexture,Q.viewportOpaqueMipTexture,Q.viewportResolution,Q.viewportSafeUV,Q.viewportSharedTexture,Q.viewportSize,Q.viewportTexture,Q.viewportUV,Q.wgsl,Q.wgslFn,Q.workgroupArray,Q.workgroupBarrier,Q.workgroupId,Q.workingToColorSpace,Q.xor;function Sw(e,t,n){return e<t?t:e>n?n:e}function Cw(){let e={map:gw(new Ct),progress:_w(0),opacity:_w(0)},t=pw(()=>{let t=vw(),n=yw(mw);fw(t.y.greaterThan(e.progress));let r=e.map.sample(t),i=xw(bw(1,1,1),e.progress.sub(n.y).mul(.7)),a=i.add(xw(r.rgb,r.a.mul(n.y.oneMinus()))),o=hw(e.progress.equal(1),a,i);return xw(o.rgb,o.a.mul(e.opacity))}),n=new zh;return n.fragmentNode=t(),n.transparent=!0,n.depthTest=!1,{material:n,u:e}}var ww=[1,5,2,6,3,7,4,8,9,13,10,14,11,15,12,16],Tw=512,Ew=512,Dw=128,Ow=class extends o.Controller{get config(){return Object.assign({},this._config)}updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}updateConfig(e,t={}){var n;let r=this.config,i=Object.assign(Object.assign({},r),e);this._config=i,this.hooks.emit(`configChange`,{prevConfig:r,config:i,userAction:(n=t.userAction)==null?!0:n})}constructor(e,n){super(e),this.group=new en,this.materialUniforms=Cw(),this.mesh=(()=>{let e=new ri(.12,.12,1,32,1,!0);return e.translate(0,.5,0),new Or(e,this.materialUniforms.material)})(),this.panoMesh=new t.PanoCircleMesh({scale:1.5}),this.stop=()=>{},this.drawLine=(e,t)=>{if(!this.ctx)return;let n=(()=>{var t;return 32*((t=ww[e])==null?0:t)})(),r=(1-(t+e*150)%1200/1200)*640,i=this.ctx.createLinearGradient(0,r-Dw,0,r);i.addColorStop(0,`rgba(255,255,255,0)`),i.addColorStop(.5,`rgba(255,255,255,1)`),i.addColorStop(1,`rgba(255,255,255,0)`),this.ctx.fillStyle=i,this.ctx.fillRect(n,r-Dw,3,Dw)},this.anime=e=>{if(!this.ctx||!this.startTime)return;this.ctx.clearRect(0,0,Tw,Ew);for(let t=0;t<16;t++)this.drawLine(t,e-this.startTime);let t=Sw((e-this.startTime)/1e3,0,1),n=Sw((e-this.startTime)/300,0,this.config.maxOpacity);this.panoMesh.setOpacity(n),this.materialUniforms.u.progress.value=t,this.materialUniforms.u.opacity.value=n,this.canvasTexture&&(this.canvasTexture.needsUpdate=!0),this.five.needsRender=!0},this.dispose=()=>{this.disable()},this.five=e;let r={enabled:!1,visible:!0};this.state=Object.assign(r,n==null?void 0:n.initialState);let i=Object.assign(Object.assign({},n==null?void 0:n.config),{maxOpacity:1});this._config=i,!(typeof document>`u`)&&(this.canvas=document.createElement(`canvas`),this.ctx=this.canvas.getContext(`2d`),this.canvas.width=Tw,this.canvas.height=Ew,this.ctx.shadowColor=`rgba(255,255,255,0.5)`,this.ctx.shadowBlur=6,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.canvasTexture=new Qr(this.canvas),this.materialUniforms.u.map.value=this.canvasTexture,this.group.add(this.mesh),this.panoMesh.setProgress(1),this.panoMesh.setOpacity(0),this.group.add(this.panoMesh),this.state.enabled&&this._enable({userAction:!1}))}load(e){return r(this,void 0,void 0,function*(){})}_enable(e){this.mesh.position.copy(this.five.observers[this.five.state.panoIndex].standingPosition),this.panoMesh.position.copy(this.five.observers[this.five.state.panoIndex].standingPosition),this.five.ready().then(()=>{this.five.scene.add(this.group),this.stop=t.AnimationFrameLoop.shared.add((e,t)=>{this.startTime||(this.startTime=e),this.panoMesh.updateTime(e,t),this.anime(e)})})}_disable(e){this.five.scene.remove(this.group),this.panoMesh.setOpacity(0),this.startTime=void 0,this.stop(),this.five.needsRender=!0}enable(e){var t;if(!this.ctx||this.state.enabled||!this.five.observers[this.five.state.panoIndex])return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!0},n),this._enable({userAction:n})}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!1},n),this._disable({userAction:n})}setState(e,t={}){let n=this.state,r=t.userAction===void 0?!0:t.userAction;if(this.updateState(e,r),e.enabled!==void 0&&n.enabled!==e.enabled){let t={userAction:r};e.enabled?this._enable(t):this._disable(t)}}},kw=(e,t)=>new Ow(e,t),Aw=class extends $t{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new it(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center.clone(),this}},jw=new O,Mw=new k,Nw=new k,Pw=new O,Fw=new O,Iw=class{constructor(e={}){let t=this,n,r,i,a,o={objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s,this.sortObjects=!0,this.getSize=function(){return{width:n,height:r}},this.render=function(e,n){e.updateMatrixWorld(),n.parent===null&&n.updateMatrixWorld(),Mw.copy(n.matrixWorldInverse),Nw.multiplyMatrices(n.projectionMatrix,Mw),l(e,e,n),t.sortObjects&&f(e)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`};function c(e){e.isCSS2DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)c(e.children[t])}function l(e,n,r){if(e.visible===!1){c(e);return}if(e.isCSS2DObject){jw.setFromMatrixPosition(e.matrixWorld),jw.applyMatrix4(Nw);let c=jw.z>=-1&&jw.z<=1&&e.layers.test(r.layers)===!0,l=e.element;l.style.display=c===!0?``:`none`,c===!0&&(e.onBeforeRender(t,n,r),l.style.transform=`translate(`+-100*e.center.x+`%,`+-100*e.center.y+`%)translate(`+(jw.x*i+i)+`px,`+(-jw.y*a+a)+`px)`,l.parentNode!==s&&s.appendChild(l),e.onAfterRender(t,n,r));let d={distanceToCameraSquared:u(r,e)};o.objects.set(e,d)}for(let t=0,i=e.children.length;t<i;t++)l(e.children[t],n,r)}function u(e,t){return Pw.setFromMatrixPosition(e.matrixWorld),Fw.setFromMatrixPosition(t.matrixWorld),Pw.distanceToSquared(Fw)}function d(e){let t=[];return e.traverseVisible(function(e){e.isCSS2DObject&&t.push(e)}),t}function f(e){let t=d(e).sort(function(e,t){return e.renderOrder===t.renderOrder?o.objects.get(e).distanceToCameraSquared-o.objects.get(t).distanceToCameraSquared:t.renderOrder-e.renderOrder}),n=t.length;for(let e=0,r=t.length;e<r;e++)t[e].element.style.zIndex=n-e}}},Lw=`#five-CSS2DPlugin {
|
|
345
|
+
position: absolute;
|
|
346
|
+
pointer-events: none;
|
|
347
|
+
user-select: none;
|
|
348
|
+
top: 0;
|
|
349
|
+
left: 0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.five-CSS2DPlugin-X {
|
|
353
|
+
--timeout: 300ms;
|
|
354
|
+
transition: opacity ease-in-out var(--timeout);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.five-CSS2DPlugin-hidden {
|
|
358
|
+
opacity: 0;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
#five-CSS2DPlugin .five-CSS2DPlugin-hidden * {
|
|
362
|
+
pointer-events: none;
|
|
363
|
+
}
|
|
364
|
+
`;function Rw(){return((1+Math.random())*parseInt(`10000`,36)|0).toString(36).substring(1)}function zw(){let e=Rw()+Rw().substr(0,2)+Date.now().toString(36),t=e.length,n=``,r=Math.floor(Math.random()*Math.pow(2,t));for(let i=0;i<t;i++){let t=e[i];t>=`a`&&t<=`z`&&r>>i&1&&(t=t.toUpperCase()),n+=t}return`u-`+n}var Bw=class extends o.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){super(e),this.scene=new cn,this.styleSheet=new CSSStyleSheet,this.camera=new Ii,this.createCSS2DObject=({id:e=zw(),name:t,innerHTML:n,center:r,position:i,visible:a=!0,timeout:o})=>{let s=document.createElement(`div`);s.className=`five-CSS2DPlugin-X`,a||s.classList.add(`five-CSS2DPlugin-hidden`),o&&s.style.setProperty(`--timeout`,o+`ms`),s.innerHTML=n;let c=new Aw(s);return c.userData={id:e,_visible:a,_timeout:o,get visible(){return this._visible},set visible(e){e?s.classList.remove(`five-CSS2DPlugin-hidden`):s.classList.add(`five-CSS2DPlugin-hidden`),this._visible=e},get timeout(){return this._timeout},set timeout(e){s.style.setProperty(`--timeout`,e+`ms`),this._timeout=e}},r&&c.center.copy(r),i&&c.position.copy(i),t&&(c.name=t),c},this.render=()=>{this.camera.fov=this.five.camera.fov,this.camera.aspect=this.five.camera.aspect,this.camera.position.copy(this.five.camera.position),this.camera.rotation.copy(this.five.camera.rotation),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)},this._addEventListener=()=>{this.five.on(`render.prepare`,this.render),this.appendToFiveContainer()},this._removeEventListener=()=>{var e;this.five.off(`render.prepare`,this.render),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0},this.dispose=()=>{this.removeAll(),this._disable({userAction:!1})},this.five=e,this.renderer=new Iw,this.renderer.domElement.id=`five-CSS2DPlugin`,this.styleSheet.replaceSync(Lw),document&&document.adoptedStyleSheets.push(this.styleSheet);let n={enabled:!0,visible:!0};this.state=Object.assign(n,t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return r(this,void 0,void 0,function*(){})}appendToFiveContainer(){var e;if(!this.five.renderer)return;let t=this.five.getElement();if(!(t!=null&&t.parentElement))return;let{x:n,y:r}=this.five.renderer.getSize(new it);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(n,r),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=new ResizeObserver(()=>{var e;if(!this.five.renderer)return;let t=(e=this.five.getElement())==null?void 0:e.getBoundingClientRect();if(!t)return;let{x:n,y:r,width:i,height:a}=t;this.renderer.setSize(i,a),this.renderer.domElement.style.left=n+`px`,this.renderer.domElement.style.top=r+`px`,this.render()}),this.resizeObserver.observe(t)}add(...e){this.scene.add(...e),this.render()}remove(e){this.scene.remove(e),e.traverse(e=>{e instanceof Aw&&e.element.remove()}),this.render()}removeAll(){this.scene.remove(...this.scene.children),this.render()}fadeInObjects(...e){for(let t of e)t.userData.visible=!0;this.render()}fadeOutObjects(...e){for(let t of e)t.userData.visible=!1;this.render()}_enable(e){this.styleSheet.disabled=!1,this.updateState({enabled:!0},e.userAction),this._addEventListener(),this.render()}_disable(e){this.styleSheet.disabled=!0,this.updateState({enabled:!1},e.userAction),this._removeEventListener()}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._enable({userAction:n})}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._disable({userAction:n})}show(e){this.renderer.domElement.style.display=`block`,this.updateState({visible:!0},!0),this.render()}hide(e){this.renderer.domElement.style.display=`none`,this.updateState({visible:!1},!0)}},Vw=(e,t)=>new Bw(e,t),Hw=new O,Uw=new at,Ww=new O,Gw=class extends $t{constructor(e=document.createElement(`div`)){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}},Kw=class extends Gw{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}},qw=new k,Jw=new k,Yw=class{constructor(e={}){let t=this,n,r,i,a,o={camera:{style:``},objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s;let c=document.createElement(`div`);c.style.transformOrigin=`0 0`,c.style.pointerEvents=`none`,s.appendChild(c);let l=document.createElement(`div`);l.style.transformStyle=`preserve-3d`,c.appendChild(l),this.getSize=function(){return{width:n,height:r}};let u=!0,d=new Set;this.markDirty=function(){u=!0},this.updateSpriteSet=function(e){d.clear(),e.traverse(function(e){e.isCSS3DSprite&&d.add(e)})};function f(e,n,r){if(e.visible===!1)return;let i=e.layers.test(r.layers)===!0,a=e.element;if(a.style.display=i===!0?``:`none`,i===!0){e.onBeforeRender(t,n,r),qw.copy(r.matrixWorldInverse),qw.transpose(),e.rotation2D!==0&&qw.multiply(Jw.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(Hw,Uw,Ww),qw.setPosition(Hw),qw.scale(Ww),qw.elements[3]=0,qw.elements[7]=0,qw.elements[11]=0,qw.elements[15]=1;let i=h(qw),s=o.objects.get(e);(s===void 0||s.style!==i)&&(a.style.transform=i,o.objects.set(e,{style:i})),a.parentNode!==l&&l.appendChild(a),e.onAfterRender(t,n,r)}}this.render=function(e,t){let n=t.projectionMatrix.elements[5]*a;e.updateMatrixWorld(),t.parent===null&&t.updateMatrixWorld();let r,s;t.isOrthographicCamera&&(r=-(t.right+t.left)/2,s=(t.top+t.bottom)/2);let c=t.isOrthographicCamera?`scale(`+n+`)translate(`+p(r)+`px,`+p(s)+`px)`+m(t.matrixWorldInverse):`translateZ(`+n+`px)`+m(t.matrixWorldInverse),h=(t.isPerspectiveCamera?`perspective(`+n+`px) `:``)+c+` translate(`+i+`px,`+a+`px)`;if(o.camera.style!==h&&(l.style.transform=h,o.camera.style=h),u)_(e,e,t,c),u=!1;else if(d.size>0)for(let n of d)f(n,e,t)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`,c.style.width=e+`px`,c.style.height=t+`px`,l.style.width=e+`px`,l.style.height=t+`px`};function p(e){return Math.abs(e)<1e-10?0:e}function m(e){let t=e.elements;return`matrix3d(`+p(t[0])+`,`+p(-t[1])+`,`+p(t[2])+`,`+p(t[3])+`,`+p(t[4])+`,`+p(-t[5])+`,`+p(t[6])+`,`+p(t[7])+`,`+p(t[8])+`,`+p(-t[9])+`,`+p(t[10])+`,`+p(t[11])+`,`+p(t[12])+`,`+p(-t[13])+`,`+p(t[14])+`,`+p(t[15])+`)`}function h(e){let t=e.elements;return`translate(-50%,-50%) matrix3d(${[t[0],t[1],t[2],t[3],-t[4],-t[5],-t[6],-t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]].map(e=>Math.abs(e)<1e-10?0:e).join(`,`)})`}function g(e){e.isCSS3DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)g(e.children[t])}function _(e,n,r,i){if(e.visible===!1){g(e);return}if(e.isCSS3DObject){let i=e.layers.test(r.layers)===!0,a=e.element;if(a.style.display=i===!0?``:`none`,i===!0){e.onBeforeRender(t,n,r);let i;e.isCSS3DSprite?(qw.copy(r.matrixWorldInverse),qw.transpose(),e.rotation2D!==0&&qw.multiply(Jw.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(Hw,Uw,Ww),qw.setPosition(Hw),qw.scale(Ww),qw.elements[3]=0,qw.elements[7]=0,qw.elements[11]=0,qw.elements[15]=1,i=h(qw)):i=h(e.matrixWorld);let s=o.objects.get(e);if(s===void 0||s.style!==i){a.style.transform=i;let t={style:i};o.objects.set(e,t)}a.parentNode!==l&&l.appendChild(a),e.onAfterRender(t,n,r)}}for(let t=0,a=e.children.length;t<a;t++)_(e.children[t],n,r,i)}}},Xw=`#five-CSS3DPlugin {
|
|
365
|
+
position: absolute;
|
|
366
|
+
pointer-events: none;
|
|
367
|
+
user-select: none;
|
|
368
|
+
transform-origin: left top;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.five-CSS3DPlugin-X {
|
|
372
|
+
--timeout: 300ms;
|
|
373
|
+
transition: opacity ease-in-out var(--timeout);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.five-CSS3DPlugin-hidden {
|
|
377
|
+
opacity: 0;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
#five-CSS3DPlugin .five-CSS3DPlugin-hidden * {
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
}
|
|
383
|
+
`,Zw=class extends o.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){super(e),this.scene=new cn,this.styleSheet=new CSSStyleSheet,this.camera=new Ii,this.cacheMap=new WeakMap,this.createCSS3DObject=({id:e=zw(),name:t,innerHTML:n,sprite:r,normal:i,position:a,scalar:o=.00216,visible:s=!0,timeout:c})=>{let l=document.createElement(`div`);l.className=`five-CSS3DPlugin-X`,s||l.classList.add(`five-CSS3DPlugin-hidden`),c&&l.style.setProperty(`--timeout`,c+`ms`),l.innerHTML=n;let u=r?new Kw(l):new Gw(l);if(u.userData={id:e,_visible:s,_timeout:c,get visible(){return this._visible},set visible(e){e?l.classList.remove(`five-CSS3DPlugin-hidden`):l.classList.add(`five-CSS3DPlugin-hidden`),this._visible=e},get timeout(){return this._timeout},set timeout(e){l.style.setProperty(`--timeout`,e+`ms`),this._timeout=e}},i){let e=new O(0,0,1),t=new at().setFromUnitVectors(e,i.clone().normalize());u.quaternion.copy(t)}return a&&u.position.copy(a),o&&u.scale.setScalar(o),t&&(u.name=t),u},this.render=()=>{this.camera.fov=this.five.camera.fov,this.camera.aspect=this.five.camera.aspect,this.camera.position.copy(this.five.camera.position),this.camera.rotation.copy(this.five.camera.rotation),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)},this.forceRender=()=>{this.renderer.markDirty(),this.render()},this._addEventListener=()=>{this.five.on(`render.prepare`,this.render),this.appendToFiveContainer()},this._removeEventListener=()=>{var e;this.five.off(`render.prepare`,this.render),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0},this.dispose=()=>{this.removeAll(),this._disable({userAction:!1})},this.five=e,this.renderer=new Yw,this.renderer.domElement.id=`five-CSS3DPlugin`,this.styleSheet.replaceSync(Xw),/Chrome/.test(navigator.userAgent)&&!/Edge|Edg|OPR/.test(navigator.userAgent)&&this.styleSheet.insertRule(`#five-CSS3DPlugin * { transform-style: preserve-3d; }`),document&&document.adoptedStyleSheets.push(this.styleSheet);let n={enabled:!0,visible:!0};this.state=Object.assign(n,t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return r(this,void 0,void 0,function*(){})}appendToFiveContainer(){var e;if(!this.five.renderer)return;let t=this.five.getElement();if(!(t!=null&&t.parentElement))return;let{x:n,y:r}=this.five.renderer.getSize(new it);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(n*2,r*2),this.renderer.domElement.style.width=n*2+`px`,this.renderer.domElement.style.height=r*2+`px`,this.renderer.domElement.style.transform=`scale(0.5)`,(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=new ResizeObserver(()=>{var e;if(!this.five.renderer)return;let t=(e=this.five.getElement())==null?void 0:e.getBoundingClientRect();if(!t)return;let{x:n,y:r,width:i,height:a}=t;this.renderer.setSize(i*2,a*2),this.renderer.domElement.style.left=n+`px`,this.renderer.domElement.style.top=r+`px`,this.renderer.domElement.style.width=i*2+`px`,this.renderer.domElement.style.height=a*2+`px`,this.render()}),this.resizeObserver.observe(t)}add(...e){this.scene.add(...e),this.renderer.updateSpriteSet(this.scene),this.forceRender()}remove(e){this.scene.remove(e),e.traverse(e=>{e instanceof Gw&&e.element.remove()}),this.renderer.updateSpriteSet(this.scene),this.forceRender()}removeAll(){this.scene.remove(...this.scene.children),this.renderer.updateSpriteSet(this.scene),this.forceRender()}fadeInObjects(...e){for(let t of e)t.userData.visible=!0;this.render()}fadeOutObjects(...e){for(let t of e)t.userData.visible=!1;this.render()}_enable(e){this.styleSheet.disabled=!1,this.updateState({enabled:!0},e.userAction),this._addEventListener(),this.render()}_disable(e){this.styleSheet.disabled=!0,this.updateState({enabled:!1},e.userAction),this._removeEventListener()}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._enable({userAction:n})}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._disable({userAction:n})}show(e){this.renderer.domElement.style.display=`block`,this.updateState({visible:!0},!0),this.forceRender()}hide(e){this.renderer.domElement.style.display=`none`,this.updateState({visible:!1},!0)}},Qw=(e,t)=>new Zw(e,t);function $w(e){return r(this,void 0,void 0,function*(){return Promise.all(e.map(e=>r(this,void 0,void 0,function*(){if(!e.svg_url)return{url:e.url,index:e.index};let t=yield fetch(e.svg_url).then(e=>e.text()).catch(()=>void 0);return{url:e.url,index:e.index,svgUrl:e.svg_url,svgContent:t}})))})}function eT(e){let{room_type:t,floor_type:r,room_label:i,observer_indexs:a,customized_name:o,dimension:s}=e,c=n(e,[`room_type`,`floor_type`,`room_label`,`observer_indexs`,`customized_name`,`dimension`]);return Object.assign(Object.assign({},c),{roomType:t,floorType:r,roomLabel:{position:i.position,positionInImage:i.position_in_image},observerIndexs:a,customizedName:o,dimension:s?{width:s.width,height:s.height,vertical:s.vertical,horizontal:s.horizontal}:void 0})}function tT(e){let{floor_name:t,floor_index:r,rooms:i}=e,a=n(e,[`floor_name`,`floor_index`,`rooms`]);return Object.assign(Object.assign({},a),{floorName:t,floorIndex:r,rooms:i.map(eT)})}function nT(e){return{floorIndex:e.floor_index,positionInImage:e.position_in_image}}function rT(e){return{positionInImage:e.position_in_image,northRad:e.north_rad,roomId:e.room_id,floorIndex:e.floor_index}}function iT(e){return r(this,void 0,void 0,function*(){var t,n;let{computed_data:r}=e;return{outlines:yield $w((t=e.outlines)==null?[]:t),bounding:r.bounding,floorDatas:r.floor_datas.map(tT),entrance:r.entrance?rT(r.entrance):null,observers:((n=r.observers)==null?[]:n).map(nT)}})}function aT(e,t,n=2){return Number(e.toFixed(n))===Number(t.toFixed(n))}function oT(e,t,n=2){let r=Math.PI*2,i=e=>(e%r+r)%r,a=i(e),o=i(t),s=Math.min(Math.abs(a-o),r-Math.abs(a-o));return Number(s.toFixed(n))===0}function sT(e){return r(this,void 0,void 0,function*(){try{return[null,yield e]}catch(e){return e instanceof Error?[e,null]:[Error(String(e)),null]}})}function cT(e){return Object.prototype.toString.call(e)===`[object Object]`&&!!e.isVector3}function lT(e,t){return Object.keys(e).every(n=>{let r=t[n],i=e[n];return r===void 0||i===void 0?!0:n===`longitude`||n===`latitude`?oT(r,i,2):typeof r==`number`&&typeof i==`number`?aT(r,i,2):cT(i)&&cT(r)?i.distanceTo(r)<.01:r===i})}function uT(e,t){return r(this,void 0,void 0,function*(){let[n]=yield sT(e.changeMode(...t));if(n)throw Error(`change mode canceled`);yield new Promise(t=>{e.once(`initAnimationWillStart`,()=>{e.once(`initAnimationEnded`,()=>t())})});let r=t[1];if(r&&!lT(r,e.getCurrentState()))throw Error(`pose 与预期不符`)})}function dT(e,t,n){let r=e.modelScene.boundingBox,i=r.isEmpty()?10:Math.pow(Math.pow(r.max.x-r.min.x+1,2)+Math.pow(r.max.y-r.min.y+1,2)+Math.pow(r.max.z-r.min.z+1,2),1/2),a=i/2/Math.tan(Math.PI*t/360);return n<1&&(a/=n),Number.isNaN(a)?i:a}function fT(e,t){let n=Object.assign({},e);for(let e of t)delete n[e];return n}function pT(e,t){if(e.currentMode!==t.mode)return!1;let n=e.getCurrentState(),r=e.camera.fov;return!(!aT(n.latitude,t.latitude,2)||!aT(n.longitude,t.longitude,2)||t.fov!==void 0&&!aT(r,t.fov,2)||t.offset&&n.offset.distanceTo(t.offset)>.01)}function mT(e,t){return r(this,arguments,void 0,function*(e,t,n=!0){var r;if(pT(e,t))return;let i=e.getCurrentState();if(e.currentMode!==t.mode){let r=e.models.find(t=>t.name===e.state.workCode),i=typeof t.fov==`number`?t.fov:80;r&&(t.distance=dT(e,i,e.camera.aspect));let[a]=yield sT(uT(e,[t.mode,t,void 0,n]));if(a)throw a;return}let{latitude:a,longitude:o,fov:s}=i,c=(r=t.fov)==null?s:r,l=Math.min(1e3,Math.max(200,Math.abs(a-Math.PI/2)*1e3,(o>Math.PI?Math.PI*2-o:o)*500,Number.isFinite(c)?Math.abs(s-c)*10:1/0)),[u]=yield sT(e.updateCamera(fT(t,[`mode`]),l,n));if(u)throw Error(`UpdateCameraError`)})}function hT(e,t,n=300){let r=e.getElement();if(!r)return;r.style.opacity=t+``;let i=r.parentElement;if(i)for(let e=0;e<i.children.length;e++){let n=i.children[e];n instanceof HTMLElement&&n.dataset.infive===`1`&&(n.style.opacity=t+``)}r.style.transition=n===0?`none`:`opacity ${n}ms linear`,n!==0&&Promise.race([new Promise(e=>r.addEventListener(`transitionend`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,n))]).then(()=>{r.style.transition=`none`})}function gT(e,t){var n,r;let i=(r=(n=e.work)==null?void 0:n.observers)==null?[]:r;if(t>(i.length?Math.max(...i.map(e=>e.floorIndex)):0))return e.modelScene.boundingBox.max.y;let a=i.filter(e=>e.floorIndex===t).map(e=>e.standingPosition.y);return a.length?Math.max(...a):e.modelScene.boundingBox.min.y}function _T(e,t,n=3){let r=e.modelScene.boundingBox;return n===3?(r.max.y+r.min.y)/2:n===2?gT(e,t+1):gT(e,t)}function vT(e,t,n,r){let i=_T(e,n,r==null?void 0:r.attachedTo),a=new O(0,i,0),o=new O(1,i,0),s=a.clone().project(e.camera),c=o.clone().project(e.camera);return Math.abs((c.x-s.x)/1e3)*(t.getBoundingClientRect().width/2)}function yT(e){var t;return((t=e.models)==null?void 0:t.filter(t=>t.name===e.state.workCode)[0])||e.model}function bT(e){var t;return!!((t=yT(e))!=null&&t.loaded)}function xT(e){return r(this,void 0,void 0,function*(){return new Promise(t=>{if(bT(e)){t();return}let n=r=>{r===yT(e)&&(e.off(`modelLoaded`,n),t())};e.on(`modelLoaded`,n)})})}function ST(e){return Object.prototype.toString.call(e)===`[object Object]`}function CT(e,t){return!!(e===t||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t))}function wT(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>CT(e[n],t[n])):!1}function TT(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>kT(e[n],t[n])):!1}function ET(e,t){return e.length===t.length?e.every((e,n)=>CT(e,t[n])):!1}function DT(e,t){return e.length===t.length?e.every((e,n)=>kT(e,t[n])):!1}function OT(e,t){return CT(e,t)?!0:ST(e)&&ST(t)?wT(e,t):Array.isArray(e)&&Array.isArray(t)?ET(e,t):!1}function kT(e,t){return CT(e,t)?!0:ST(e)&&ST(t)?TT(e,t):Array.isArray(e)&&Array.isArray(t)?DT(e,t):!1}function AT(e,t,n={deep:!1}){return n.deep?kT(e,t):OT(e,t)}function jT(e,t={}){let n=``,{needZ:r,format:i}=t;return(r?e.slice().concat(e[0]):e.slice()).forEach((e,t)=>{let{x:r,y:a}=i?i(e):e,o=`${r},${a}`;n+=(t===0?`M`:`L`)+o}),n+(r?`Z`:``)}function MT({x:e,y:t},n){let{max:r,min:i}=n;return{x:e-i.x,y:r.y-t}}function NT(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}function PT(e,t,n){if(t.width===0||t.height===0)return!1;let r=e.path.map(({x:e,y:t})=>[e,t]),{x:i,y:a}=e.roomLabel.position,o=t.width/2,s=t.height/2,c=i*n,l=a*n,u=r.map(([e,t])=>[e*n,t*n]);return[[c+o,l-s],[c-o,l-s],[c-o,l+s],[c+o,l+s]].every(e=>NT(e,u))}var FT=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArUAAAB7CAMAAABdA4ieAAAC91BMVEUAAACOpP/H0P+yxP/a4/+asv/W3/+/z/+cs//S3f+mu//Q2//5+v/H1P/d5f/l6//y9f++zf/i6f+ww/+ovP/7/P/u8v/N2f+Mp//q7/+4yf+uwf+Wr/+7y/+1xv+Ho//x9P+9zP+2x/+swP+gt/+Oqf/Y4v/r8P/l7P/b4//F0/+juf+Zsv+XsP+Trf/p7v97mv9wj/+kuv+ftf/x9P92lf/3+f/I1f+5yv+Eof98m//8/f/4+f90lf+9zf/j6f/T3f/L1/+Bnv/6+/+SrP/m7P/f5v/O2v/L2P/E0v/Az//+///s8P/e5v+rv/+pvv+Anv+qvv+Pqv+Kpv+CoP93l/9xlP/z9v/p7v90lf9uj//P2//v8//o7f/k6v/K1v+6yv9rjv98nv/E0v/9/v/09//h6P/X4f9pjP/9/f/N2f/K1v/C0f+Ho/99nP/1+P9sj//6+//u8/+iuP/u8//g6P/U3v+3x/+0xv+etf+Vrv9pjf/B0P9ukf+ht/+Vr/94mP/G0/+8zP+2x//+/v/09v/W4f9ojv/c5P+xxP/d5v+xw/+vwv+Jo//g6P+nvP+SrP/R3P/1+f/W3//U3//C0P+Jp/9nh/+Kpv+Fov/Y4f/J1/+Pqf+rv/+Oqv+Oqv+muv+twP/f5//t8P97mf/h5/+twP+kuf/L2P+juP+Ipf+huP+Pqf/d5v+zxf+cs/+Zsf+wwv/V3v+8zP+Go/+zxP+GpP/T3f/r8P/u8v/o7f/d5P/m7P/H1P/w9P/D0f+uwf/Z4v/F0v/09//D0v/v8//s8v/d5P/Y4f/s8P+etv/X4f+gt/+ovf+bsv+xw/+Vr//j6v+1x//J1v+4yf/r8P+yxf/T3f/B0f+Fo//09//W4P/h6P/L1v/i6f/x9f/t8v/G0/+uwf/z9f/7/P/n7f/z9v/T3f+4yf/J1v/z9f/w8//q7v/O2v/8/f/5+v/y9f/w8//g6P/z9v+/zv+5yf+9zf/5+v/Q3P/B0P/u8f/R2//////LSJnaAAAA/HRSTlMAAwGMx2jAn2u7ebn0q8zX7J3TiHz45bRS35SFYZmPSembkYNwVMXh2cmodWVjXN43DHZu6gfyrJZGOvrzLAbVvbBB91raz7aypqH+4s6Bfj9/Vk9EMint3C8gt+fc1q+XGAml/O/SxBz7s66kSz3wI/bjc+fQvpOObV8VoyZyXjSpmgv97sMPyorNiYZN0XpYuvHCv6JNEhEWw61YgCUdGBIP5CIgHypaUEU6NS9JQy8lGlY6NCuMfVtPSzspJoRxcExBNTMUyn9zaWRfVkk9Oad9emtkY0RBMLGsnJaQj4ZmXVHhsaKbeW9owb466dnVy7mYj45wyaGV3bdGzuNnAAASkklEQVR42uyaS0iUURiGTUQZ1MaMURSEbOFt4ybGQClFHO9rBS8F3nAURHG0hZvyQrgQRsfNuKmRCTcGGaEzThNqMyouwswKNTVMLe/a/bLo+845/5z/dzIiumj971I3gz6+Puc9x0POT6bRaXfYrJa18YHFhYXXKzMz6+/fb2+/ePFia8uvWlXelFkcr6pO2NqCr2xv77xfn5lZWXm9sDgwvmZZGnHYzaZjHnLk/PaYzL0jS9Pji6+XN3Z3gvJPnTkTEJCT01xSUtWuVick+PlVJ6tUqvj44uLipkxIU3F5fLxKlZxc7efnl6BWt1eVlDTn5AQEnDl16lR+be2n3fWZlYWBNcugze485yFHzq/Kub7eEcv44tzyekpsbEhIZGRWVk1NUFBtPqU2gFGbANRWVycnI7XlCO0XQm25mFp1VRWjFrDNz68NCqqpyYqMDAmJjc3NzQ3cmJwfmLba7CZPDzlyfg5Wh3V6YG559HyhUhkVlZJSUJDLqK3pDkJqoS8ZtVWEWiCTUltejl37BaCVdG2Cul1MLUIb1M2pLShIiYpSKpWF58+37U3Oj1ue2E0ecuT8EK1mm3VoYG4vW6MrLQ0MDDwvUIvQ8q6tBWqZIeRQQ+DU8q51NwQxtbVAbRajNrZARG1gaWBpm0anyY6enB+bGOyV6ZVzIK6bPUPzs17Rx48fb80GaHVtpQRaF7XYtZFIbTcRBAFb7rWc2uJM1rVoCCqgFquWdy0TBDCEbqSWlm2KQC38rZSW6nS67OxW+CxXr0Z7ec/J8MqRxtQ7ONQ/2xIREeHlFR191UVtqRu1wBep2hpqCNxrpYYg6dp4Ude2Y9cG8K5FQ8hyNwSglnZtNoE22svLKyKirKxFsTo28cQsH9v+81Bevb29O1qMZQAtUhs9SqnVsK5199osRi3fENwNgXitcBqrrmZly7r2DKUWq7Zb8FrBEAoptW1tGg3rWk5tC3xSQ53ig8zuf5pzd4df9c8qFIrEOgOhtgyphdCubaVdC9iyrkVo+Wnsm12bID6NZYqWLxX32qpm0fKVD9ii10bSrkVDiJJ2bWuriFqjsaUDPmpdXWIifG7f1bGezT55bfhfYrrfM7Wamufrq9cjtIkGA+1aZgiArdRrlUBtirRr2YbAvBZGBLV71/INAcuWbwjcEERey7tWKe7abGnXdiC1DFq9r29eampF/3O5dv/1ODd7pj5og4ODU13UQtdyQ+Beq9FovnMaE20IAdwQJHut2BCE05jaffkSDAGwxbJl1CK27DQ2iqcxCFKLXWsgXatX+BJqg4O1aWlJz14N35XR/RfTeP/2VOeFpKS0tDQCLVDrq9AjtXVIrdFYVsaoHWWGQKgN3EdtCNVa91sGtdQQmvhpjFUtX74QWjoioNdm0a5lGwL3Wp1GI/HaCCP1WkMddi1Cm5cH1BJsky5UxGHrysLw7wQd9pl/XFfFBaRWq9UCtalIrZ56rcG7A7u2jHktMQQN91qllFq2fImoba468G5M6rVq4rV8Q0CvZdTGgtcitrxrNUgtli1QCyFe6+0yBL3eF6Cl1CYBtYBtnL9/0b2ezWseco56QGLvpV++7O8fF1dRAdhC16Ih0K4lhpBoQBaMLS6vZacxTdu+DSFXsiHkU689YENgd2MSQ0iQ7rXiG90Qvnxh2eJhTOfqWihb7rXUEIBalyFotaRru+IQ28uXY9LBF27JD3OObPqePn9TlJ4eExNDqO0CapOQWsCWdq2CUmtgGwKnli9f6LWFrg0hhFEr7doS1rXSu7HM8nK3DaHd7W6shnutyxACqdficYxSyzYEgVqEVsENQYtdi9j6U2rTi4oqfaZu32n0kHO04nlr+N3HjIaGoqIipNafUNsF1KIicK9VUK8FQ8Cu5YbAqQVslfv2Wuq1+TU7uxszK/DycG1t2mJZWrKOjIzYHA673Wx2Ok3nPImbNJqcfWa7vdfhsMG3rUtLFss0PG3Eh43ruzvC8sW7lhkCgxYMQXzLYCReyzYESGoePY0JXesPiYlBbCsbOjMyMu713L/uIedo5NiNm+8++vhkALSVlaRrqSEAtNKu1VNqWddKN4Rs3f6uLdxYnsTXsdNLg7Ze8y95WOhp6rM7RqyW6fGB+bnJ5Q0lNQRyo+u+fOGGIMFWOI2Rqq2ghgDUYtcSbH18fE4AuXLnHvr0PX30JvzEiRM+gG0nYFsE2IIgQARD0LINIY9vCNLla1R8ozu6PLc4brE6zH/iEcAxp90GD83mJ/dAqjU64TTGvNYodC0uX2SvJV1LNwSkFg3B1bWEWvhBhIdfeSjbwiHO9QeP34aFXQkPp9AitWgIgtfGYdcecBrrMJYJy1c0gLIHb62GrE96+/7aCmoyOwYnhvrnJo3otXz5Yl6roNCmptLTGHYtei1imy50rQ+lFrANC7v48ra86B6+HLs1/PDs2YsA7RWAlmLb0MkNgXStdENwv2WIUKzi2yrnoZo98ekkPpYQ7saQWtq1dPlCr+WGIO1axJZSe/Hs2bePHsiae4jSeOfxpdBQhJZULe/aSmIISG0cNwTetQoIMQTDbP9Qj818mP+Pejp7ByfGVmeF5WufIVw4wGuxahm1oaGh9S9vyqPYYYgnnL1O19cDtEAt7VrqtXCIdnWtsCEkYdfyWwaF4jMp174j9JtsvGvrGer/oMcNQXzL0CVZvhoaMii1iG2YQG19/enTp08+li33K/tm7JNGGIbxqiEht5m7iasMcBuwwOJk0tEFcn9BG7s1bizQGBycCCbXpUkTo9VFJVpRSeNkuBqnq6BRoiwOMtldm3Tr+37fJ9+dtFEUbNX3+RPIj+d+93zf/ctgyZb1YDAUAmx510J410JY1wqvbTeEma3vJ9uP9571yObu8rfTd6xrhSEIahFb2bXCayW1wWAwM2CvLf5XFvSMMr9fzw9kMhnEFqmVXSsMYQI3hFFJLUD7GixwZuvHU/kuoG+zsXx0CtS+Yl4runZ0fHzcvSEAtUPcEEKCWshhdYlezx44I0vV80J+AILQQgIuagdby9e1vXbm9Ogp3kmd2j45q7z1Ll/tXRuAoCEAtQzbQkE93qdLCw+Wsa9NXVXVfB6xdXftsOxauSHwszHgtfG0L6IufNkBdhm0vGul10Kk14quzQO1qqqDK7yg9Dwj682wrk+raqEgoGXUtrp2yGUI3Gt/we3T5/L+0Q+6W/mIXTvR7rWArTSEfJ5Rq+the40at5dBMTDDCC2jVhoCYjscAGo5tBC+fA0elXefhsF2dqTdOKtMyLlWvo2F3NQCtNPTiG04aZcI3B6lb6mqJZPhK2rVFrVBFATRtXKvrZw1Fh/RotXdoOzu/LwYhLj3Wo8hCGrDQG1y1jTIcbufvo2ilTJnZxFbnRsC81qxIYQ8XntRpy9SWOZ3y+dv2pevjPRaQa1pplIph87OuoxsXEulTJND6zWEjPRagDZwXqbredd94bgiqfUYgsq6Ngldi9hqmna8Qj9etw6/bMvSNIYt/MAtQ8i7DQG79rLeoPH8b75QPg8wbINyQ+CGILtW0yxLUZoE7v2RrRmKolgaUouGwL1W93gtdu1lnY57bj5IPBRei+GGAHF3rYKJ7608l82lF5lacSLxOFLLutaUXeuhNlOnOyEdkMu9VnYtJGnysrUshDYej6SLG9QBd5TZdASgjSsQhNZFrS69FoilF6+OsgDkIrauDWEWu1ZjhoDYRiKRdNohU+g4CyUnl2tRa1nSEKTXFmwi9s7kNg89G4IwBNG1SG0uZ9BVhQ4PEwzDyKWBWoEtUis2BNG19toSydc9bx81D91dC9hKaiNIrWE4dPxwy8yXnEQCoL3WtSnetQhtsklXRLv1YajNli8BraYgtozaXBqgTSQS2cl1+q1vytj6pD+bBWpF10qvFV2btIukBV2WhVRrQxDQCkNAbLNZv1N7zoeMt/jr13x+P1LLyhawlYLAX8fobl33g0ZWtE2+11oearFr/RDf3gEV7p/z6WDS5/MJaF1eqwhslSo9q3qW/vn9Y63Na7Fqs0gtpDZHhXs9/Z9r0ShC6+5aQS1C65ToEKHXmVqvRtoNwQ9BbKPR96vUGt5H1IcYg9YjCDkxIcSrNB32ONLRSg7H1msIEMA2GqNJoZWp1ckYQCuoRWwZtUYaFSFdpNHwYbOwsodde7UhtLAFaGOxl7U5eub9Ztfscd0Eoihsu8oSKJBoQpUYyYULmhSIBVjACuip0tFQpEaaagTSyLiI9GSMZArEKp4it95N7oXBk6dUr7Ln59sB4uNw7p0BTlfb3s7Wcm0fvfbbV7MveAYo7k9eEB5h+x0Aa22b9OlKb9bHP7kNgLZC2slawKTs80Bx/2sIW8DO7dy7VSt9SfuoyHMurei1k7bnt/3K8ExQXLT2Y0MA8qLwro2mRaG6hV5RTNpuuba81345v+n+E3oR6su7aAjc2hyt9cL4qN+fcNNcw9DzPJG1i7VG2dfidHlHaYW1qK0H2oauZvvz/ZEyhtLyrBUN4WzuxLweIO6HrOXWhiQa6pUupHeLkRCYrbWB2dqzZh+vPGxOl1xoW3iztYyxqNWj4KadG0URm7z9tyHoPZi+PnBJRExjk7WEEHiTrtMof9T7q7NctJYwcBaYGgJwVf/R5Sft3bkh8KydrXVV93aHzs7WklBMY2b+kob65uE0NhcEQhhaa1mWo+7VmqqzgElaRlDbKWtD0wykAg6GikJkretO2saKelt1cRyjtQAD5qw1zUBCdr2L1jIWAdzaWEVvq44+pI0AErLQs/rdyiAjm9ONiF5rATGlpaPWwUM1ZHSxFokIY9FNn12fivw4toQwkbWobemPynhbD1lW0hKtfYTtVa3PUk+q3pp7LYDW0jLL2lGJ+yP14DhZltFFW5DW6swApgbrpn1kbVmCtJnj+KP0GyFwFsCspZRLq1j70Z2qsxC0loK0qK0vd95Wne/7IC1Q8qgd9DgB1Il0dKx4CVsH8P1E3n3C7t76AM/aErKW3s1FAxVZNweUllvrIwc5V5r7MUiSWVoMW5C2NdVAXao7DmNL1vpJkgy1dH/V9W9wNmmTxdqy7OR7CMMnV2EiaxMgkGzoXjdDEKC2S0HwR3OeoD6beuBZ26K0QXC4y/Pa/7Jrx7gJw1AYx2su0iuYgYFI7sAJstiS2ZKpk8UeWfKWKyQLLJ5Qxyp34TZ9D15YOkBpm9ji/U/A8CP+HFj0styMapHtZ54bh/t5y2E9LoQNVppMXoN1uixLQns8rl9PeZ0T3O96O5T4rL2wBQkuZnCbWQ7OXdUe1zwNni8YCsh2VOuK1I/a2jtHapHtZp/J+cD9bf0HoiW1rpAp38TfYlEUgJaetWUOZwP3P3UnetYCW1ChU52JogoS1UKIlq9gT95yILSugKRKciq2VhLaEpIVm3366j2pxaSMyf07YRUlND5qTynvGG6aaDOSWgnptFiIKoQLWmQ7pLphuOkTB0lqoZDSTGiVBrXE1iT0wbgEEn0gtSEEncoNfRV1uKKN/KqL+/4C1xYSA7XapjATRGU1hGxT3NtcGnUK0UJgZf7TuDWEls1yt9wiWsja7awzYRWttYgWYrPcLbejWqua2WaCqBSixQLvWe5mi06RWqv8TDOhNUrZC9sdm+Xuu5cpUqvU+wwzYbVVkIXYLHd/olekVpmpZ8KiMYbU7ma/EXJZBW5JrZl2V9bRnNWyWe4xt8TWTPd3FdEYSEFslnsoURlAi01FqN56f2br2xeOe9ytgbyf4nErGg/hl6RN4Jc5Lt++2rVjHMdCIIqiqtoRQW2mMogIyZFjlsB2B9wjjaY1PXa3wcbSPaEDR1fP9fVt8aPai2+f2+TlWu2l0yweZHlEO5S9cyu1lDKj5T/fWCH4jLaUnXMbvFyrzby8xRrayqUM2+ZWqvuM1nmpgHWkl8F9z9yG7LNa5yEMa0n8yHb93Er1oXjnoMVyFn3KQVcP7VRpFn+sDiznaiuHNufsHnkIwy7aPA/r5jbFGW3m7S12ku55WPN7Li1PPIRhN6sjtBjTmm+KmYcwPEOKs9tHF1JDHCoHLZ5DQ8yPBic9DoHjAKvsb85qjbFxHOCprMZaf5qdhlorxwGeTsPIttvPlno0y3GAZfbHp6n3ynGAV0m99u/2J6H3znGAvW4n+J25tdY7xwFey1pvQe6/DlrjOMDLqfXW7N5pbs0YWhxgtpj0rl1uiaHFISzccSWohUCzOIemm0VKChwHOMutKCVwHOA4av/JVi0xtDiRpCRfRcvQ4lBfxSnG0OJc/+xTjKHFyVRMP38iDC0O92lZVRhanO+vcVWGFu9BRWkW7+Z3rapEizdy7ZVm8V5Gtr8AtSnix59eOmYAAAAASUVORK5CYII=`,IT=e=>e*180/Math.PI;function LT(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function RT(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);if(t)for(let e in t)n.setAttribute(e,t[e]);return n}function zT(e){let t=LT(`div`,`floorplan-plugin__missing-floor`),{imageURL:n,imageWidth:r=200,imageHeight:i=120,text:a,textFontSize:o=14}=e.missingFloorConfig;if(n){let e=LT(`img`);e.src=n,e.alt=`缺省楼层展位图`,e.style.width=r+`px`,e.style.height=i+`px`,e.style.maxWidth=`none`,t.appendChild(e)}if(a){let e=LT(`span`,`floorplan-plugin__missing-floor-text`);e.style.fontSize=o+`px`,e.textContent=a,t.appendChild(e)}return t}var BT=0;function VT(e,t){e.appendChild(RT(`path`,{d:t,fill:`#2F313A`}))}function HT(e,t){let n=`fpm-room-pattern-tile-${BT++}`,r=RT(`defs`),i=RT(`pattern`,{id:n,x:`0`,y:`0`,width:`12`,height:`12`,patternUnits:`userSpaceOnUse`,patternTransform:`scale(50 50)`});i.appendChild(RT(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`#323747`})),i.appendChild(RT(`path`,{d:`M0 6 h 12 M6 0 v 12`,stroke:`#ffffff`,"stroke-opacity":`0.06`,"stroke-width":`0.5`,fill:`none`})),r.appendChild(i),e.appendChild(r),e.appendChild(RT(`path`,{d:t,fill:`url(#${n})`}))}function UT(e,t){let n=`fpm-room-pattern-wood-1-${BT++}`,r=`fpm-room-pattern-wood-2-${BT++}`,i=RT(`defs`),a=RT(`pattern`,{id:n,x:`0`,y:`0`,width:`12`,height:`50`,patternUnits:`userSpaceOnUse`,patternTransform:`scale(50 50)`});a.appendChild(RT(`rect`,{x:`0`,y:`0`,width:`6`,height:`50`,fill:`none`,stroke:`#4B4B57`,"stroke-width":`0.5`}));let o=RT(`pattern`,{id:r,x:`6`,y:`25`,width:`12`,height:`50`,patternUnits:`userSpaceOnUse`,patternTransform:`scale(50 50)`});o.appendChild(RT(`rect`,{x:`0`,y:`0`,width:`6`,height:`50`,fill:`none`,stroke:`#4B4B57`,"stroke-width":`0.5`})),i.appendChild(a),i.appendChild(o),e.appendChild(i),e.appendChild(RT(`path`,{d:t,fill:`#43434D`})),e.appendChild(RT(`path`,{d:t,fill:`url(#${n})`})),e.appendChild(RT(`path`,{d:t,fill:`url(#${r})`}))}function WT(e){let{vertical:t,horizontal:n}=e;if(!(!t||t.length<2||!n||n.length<2))return`${jT([{x:t[1].x,y:t[1].y+53},{x:t[1].x-60,y:t[1].y+124},{x:t[1].x+60,y:t[1].y+124}],{needZ:!0})} ${jT([{x:t[0].x,y:t[0].y-53},{x:t[0].x-60,y:t[0].y-124},{x:t[0].x+60,y:t[0].y-124}],{needZ:!0})} ${jT([{x:n[0].x+53,y:n[0].y},{x:n[0].x+124,y:n[0].y+60},{x:n[0].x+124,y:n[0].y-60}],{needZ:!0})} ${jT([{x:n[1].x-53,y:n[1].y},{x:n[1].x-124,y:n[1].y+60},{x:n[1].x-124,y:n[1].y-60}],{needZ:!0})}`}function GT(e,t,n){let r=LT(`div`,`floorplan-plugin__room-material`),{bounding:i}=t,a=i.max.x-i.min.x,o=i.max.y-i.min.y,s=n.roomLabelsEnable&&n.roomDimensionEnable;for(let t of e.rooms){let e=jT(t.path.map(e=>MT(e,i)),{needZ:!0}),n=RT(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 ${a} ${o}`});if(t.floorType===1?VT(n,e):t.floorType===0?UT(n,e):HT(n,e),r.appendChild(n),s&&t.dimension){let e=WT(t.dimension);if(e){let t=RT(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 ${a} ${o}`});t.appendChild(RT(`path`,{d:e,fill:`#969696`,stroke:`#969696`,"stroke-width":`1`,"fill-rule":`evenodd`})),r.appendChild(t)}}}return r}function KT(e,t,n){let r=LT(`div`,`floorplan-plugin__room-highlight`),{bounding:i}=t,a=RT(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 ${i.max.x-i.min.x} ${i.max.y-i.min.y}`});for(let t of e.rooms){let e=RT(`path`,{d:jT(t.path,{needZ:!0,format:e=>MT(e,i)}),id:`${n.floorIndex}_${t.id}`}),r=n.highlightData[`${n.floorIndex}_${t.id}`];r&&(r.fill&&(e.style.fill=r.fill),r.opacity!==void 0&&e.style.setProperty(`--opacity`,String(r.opacity)),e.style.pointerEvents=r.disabled?`none`:`auto`),e.addEventListener(`mouseenter`,()=>n.onRoomHover(t)),e.addEventListener(`mouseleave`,()=>n.onRoomHover(null)),a.appendChild(e)}return r.appendChild(a),r}function qT(e,t){let n=LT(`div`,`floorplan-plugin__base-image`),r=e.outlines[t];if(r!=null&&r.svgContent)n.innerHTML=r.svgContent;else if(r!=null&&r.url){let e=LT(`img`);e.src=r.url,e.alt=`floorplan image`,n.appendChild(e)}return n}function JT(e){var t;let n=LT(`div`,`floorplan-plugin__items`);for(let r of(t=e.items)==null?[]:t){let e=LT(`div`,`floorplan-plugin__item`);e.style.left=r.positionInImage.x*100+`%`,e.style.top=r.positionInImage.y*100+`%`,e.style.width=r.width*100+`%`,e.style.height=r.height*100+`%`;let t=LT(`img`,`floorplan-plugin__item-img`);if(t.src=r.src,t.alt=``,t.style.transform=`rotate(${r.rotateZ}deg) scaleX(${r.rotateX?-1:1}) scaleY(${r.rotateY?-1:1})`,e.appendChild(t),r.notes){let t=LT(`span`,`floorplan-plugin__item-notes`);t.textContent=r.notes,e.appendChild(t)}n.appendChild(e)}return n}function YT(e,t,n,r){var i,a;let o=LT(`div`,`floorplan-plugin__room-label-item`);o.style.left=e.roomLabel.positionInImage.x*100+`%`,o.style.top=e.roomLabel.positionInImage.y*100+`%`;let s=r===e.id,{bounding:c}=t,l=c.max.x-c.min.x;o.dataset.roomId=e.id,o.dataset.roomLabelX=String(e.roomLabel.position.x),o.dataset.roomLabelY=String(e.roomLabel.position.y),o.dataset.boundingWidth=String(l);let u=(i=n.getLabelElement)==null?void 0:i.call(n,e);if(u)return o.appendChild(u),o;let d=LT(`div`,`floorplan-plugin__room-part1`);if(n.roomNameEnable){let t=LT(`span`,`floorplan-plugin__room-name`);t.textContent=n.roomNameOtherTypeEnable?e.name:e.roomType===`100900000012`?(a=e.customizedName)==null?e.name:a:e.name,d.appendChild(t)}if(n.roomAreaEnable&&e.size){let t=LT(`span`,`floorplan-plugin__room-area`);t.textContent=n.getRoomAreaText(e.size),d.appendChild(t)}if(o.appendChild(d),n.roomDimensionEnable&&e.dimension){let t=LT(`span`,`floorplan-plugin__room-size`);t.textContent=n.getRoomDimensionText(e.dimension.width,e.dimension.height),o.appendChild(t)}return s&&(o.style.opacity=`1`,d.style.opacity=`1`),o}function XT(e,t,n,r){let i=LT(`div`,`floorplan-plugin__room-labels`);for(let a of e.rooms)i.appendChild(YT(a,t,n,r));return i}function ZT(e,t,n,r){let i=e.observers[t];if(!i)return;let a=LT(`div`,`floorplan-plugin__camera-position`);a.style.left=i.positionInImage.x*100+`%`,a.style.top=i.positionInImage.y*100+`%`;let o=LT(`div`,`floorplan-plugin__camera-rotate`),s=document.body.clientWidth,c=document.body.clientHeight,l=`${(s<500||c<500?17:37)/16}rem`;return o.style.width=l,o.style.height=l,o.style.left=`-`+l,o.style.top=`-`+l,o.style.transform=`rotate(${-IT(n)+45}deg)`,o.style.transformOrigin=`${l} ${l}`,o.style.backgroundImage=`url(${r||`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAMAAAANf8AYAAAC2VBMVEUAAACCnP+Dn/+Enf+HqP+Gp/+Fof+Gpf+IrP+Lsf+Dof+Cmv+Lsv+Mtf+Eo/+Bmf+JrP+Hqf+Env+Krv+Fo/+Pu/+Ms/+Qvv+Hqf+RwP+KsP+Fpf+Mtv+Gov+Bnf+Qv/+Nt/+Krv+Ho/+Rwf+Ouv+Emv+Amv+SxP+Sw/+NuP+Mtf/G0f6huP+Ot/+JrP+Jqv+Dnv+crf6Uqv////+QvP+PvP+Ms//J0/3p9/+Ux/+Ouf+Krf+Iqf+Fpv+/zf6WsP+MpP+RqP+Uyf+Jy//V3P6Yuf+Qqf+Rqv/5/f+Sxf+Jy/////+Lx/+Ouf+Nw/+Owv+PwP+Jr/+Jq/+VvP+Vuv/c4v+Fnf+btP+InP+Blf/3+P6Txf+Jzf+Jyf+NxP+Qwf/t8/6Svv+Tvf/O1f7Czv3T2f6cu/+qvP7a4fvo7v77/v/o9//p9//0+v////+Vy//w9//k8/+B1f/v9/+D0/+UyP/u9v+D0v/i8f+F0v/g7/+G0P+KzP+Hz/////+Lx//s8/+Puf/h7P+Mxv/w9f7q8v/q8f2RwP/r8f6JrP/t8v6RvP/l6f7////j6P6VvP/f5/7q8P7a4P/U2f6au/+ZuP+ewf+auP+iu//n6f2Fn//j6P/h4fn9/v/4/P/3/P/o9v/l9P+F1P+B1f/i8v+UyP+J0f+E0f/h7//r8v6Izf/g7v/q8v6Pv//f7P7f7f/g7f+Lxf+MyP+Mw//k7v6Ow/+Ov//v8/2Pu//t8f+Tvv/p8P6Uu//q7v/i6P2Xvf+WuP/L1vypu//Azv7K0/zy8v/l8v/A4P/o9f/x+f+I0f/j8v+J0P/s9v/h8P+I0P/t9v/r9P6Lyv+Lyf/s9P/g7P+Myv/s8/7j7v+Jrv/q8P2Uwf+Epf+TuP/a3vzh5f3w8P/a4P20v//Nzfzx8f/Pz/Cg0P/f7//u9f/q8v7o8v7s8/7s8v3w9f+Sv/+TuP+Gp//s8fr///8/HFXHAAAA8nRSTlMANUQ/Z2JJXXaKTjCPmVMre3E6gFiylLxsxoVYnk5JwaOFU8utOjrV0KieQS2icWwzMC4Dt7aTQvjfrHprXD0zMyvpvUxGNjH+2sK9raeYkoiAcF5TUi0rKCYY2cy3pIJ/eGpEQDcxLx0S/Pv19PPu7Ovr5+Tk4eDe3NXU09DIsq2opKCViYN9e3V1cmZlXllVTk1GQDs2NTMwJw0K/vn28u/u5+Pj3tjNycjGw8DAua2pqJ6SjYyMf3BvaWNgWk5NSTc3MxT79PHw6efl2trY19PHurWysqWZe2xkXVlUPjo6OSskCO7Qzs6+vKCedmhdN1av0hoAAAV1SURBVEjHjZT3P9RxHMe1nCjcObo4cjpX5w53l7pUbnBGkr2TPZJKmiqVEQlJhGjvvfcm2nvvvXf5C3q/P98bkuR1D7+9n16v1/vzvtPrnAade/ty6anHJfFHOjkfXbe07PGxkuL4oqIjCzoDjHtxurzsRHmFStokjBDG/59JrwurOF2hkkUoIyKEQmFqatG3/xDnXlSGPZcKI5VKiVgsli+vrakpfNAx8UoVlpRWH6mUeMsVcm8vhah6WfXB3A6IlSlVKoE4KjxcgtNGRl1Ayzw9H+Z20DypMVkZZWKiUIi6oHj2PAbPs6Eh/+6/kBUpVUliIEQKGGcwGPbdiBpCQ/O//AMZJ218XW9igoHsGTwY7kopdMmSvTvbz/VGmiyhCARwWJ/Ss5CQ9pl3zVJZJCEwEszb6BtaGxrCn3XIyZP3trW3rybBWTCB1jy0sNGHeWM7+BgzrX4kJu752E57mWA5mIjsMRVxgGkrJpPpRvtJSywt3X2rPUSMuUgqIIzx37vRaLQeqNKEhN03/womg/bYhDJBBzdqvjsqYeHCHdfa1k9BF0QoEyuwoOadWc4sFutoXNzWGW2W3Axd8E3AxAZ6WNGeEoDl7EwPho/T0cDAtswb2Bi6kFx2VkwaDYgRI5zo9EUGRIGHD82e+ufrJ8uo+l31oQogYMJiOdFh2BQ03NTscEDAn8wKgQCeUsRTI8QEMhkYDDc1NTMLMuNwLAP8/a9Pbl0mJQlXhvVtrO2YNLce3Uew6IvAAsYtLS17gvwLCrKR0d3la0DsgdG3NiZVMBZacMh8L9CB2NjsS61eRiCtB4YH/Q21CMQKAgLnh1hYWAyJ3b9/40Qd09woppJhFytAnIPpBmBCCBjvjdrn59eKSU+SRWkZphu40IMBgRpAAMBmO7DZbL/786+s0TIpKqXOhgqGCKcnhOrd28HBlmj+2LFZWia9KjkqnHoa3BmsjG7wKIgDuSzQw9F29Gh+3jDunTseWas1zKtKYbiIsrEjZdAF2iPiYOvIz+Nyuebm5h6+HuvGa2xU0qhwBbkzayzjDO8y3IwgbAdHPp87zNx8sIvLYN/tvhc1TF1lWqSEwaMWgG3ABpIB4sC2HY2Ei0sf0O2YmLWr1CdQGRYp8SK3ic/ZnRWMLqQ+2xGRwUD069dvV8zcuRom+rlA6Y2MbgGmhAGEz4VYSPQF5cyZM6GFYl6eTlN6ixi6aE6PqDLQZRi4EKI/KOfGFjUzqCKsXu6l2RpuAKJxiI1tHhcQJAYOHDhgwOZZs4ZSTHR5lQQYPDW1DS4aELQxdyEIAANGjtk8c6aaqTslk8gVwIAN0w3rAEL2bMtHm12AIOHqenXaNDWztEwo9hKJGHjR6OO0yDSI1IGdoQ0iY0a6Tt+06fKUDRQzqKw8Qlxr1AXrwNqwDvGBA+BrGUDc3d3Xr5+SQZj0E2ERqXIjPAJYNUbD18FoWEeDbHLPzLyQ4ePjQ5i3x1RCubfmpqkjMMNo6KOJ5uqe+f58C9GoaD29XyVSYS1h4DftKeWDDN4AbACZMZAsExEKghWUNKXWhlPfA2P1qjmUT556a9jmQotWi/VOFael1lR7ep4JfRZy8nhpwtG4wMMB/gdi9/nNH+vhezsmJ+fG5quX12fomHl6J+KFy88uA2RJyJPE4wkL4wIPBfgXxO5HxGN7zNw5W2bNnLZhio+OmaR3LD6tplrLfKeYAwX7/O6Dje/2dpniwuKiwoMHH+bn7723Z8/uHTu2fpg9+3p29sYrWVnr1l1cO2HCUFCGT+tshUcWLPj6IDf37ued27Z9unXz2owZU6dOnnxp4sQ1q1ePH79KN6vbQWc1SrfrTit6lO5NO6/F8yZNmofBfgNTwRQLsPLsHQAAAABJRU5ErkJggg==`})`,a.appendChild(o),a}var QT=1e3,$T=180;function eE(e,t,n,r){let i=e===`top`||e===`bottom`,a=n.max.x-n.min.x-(QT-$T)*2,o=n.max.y-n.min.y-(QT-$T)*2,s=t.map(([e,t])=>i?[e.x,t.x]:[e.y,t.y]).flat().sort((e,t)=>e-t).filter((e,t,n)=>t===0||e!==n[t-1]),c=s.map(e=>({left:i?(e-n.min.x-QT+$T)/a:0,bottom:i?0:(e-n.min.y-QT+$T)/o}));c.unshift({left:0,bottom:0}),c.push(i?{left:1,bottom:0}:{left:0,bottom:1});let l=s.length?s[s.length-1]-s[0]:0,u=s.map((e,t,r)=>{let s=t===0?0:e-r[t-1],c=t===0?0:(e+r[t-1])/2;return{left:i?(c-n.min.x-QT+$T)/a:0,bottom:i?0:(c-n.min.y-QT+$T)/o,distance:s}}).filter(({distance:e})=>l?e/l>.1:!1),d=LT(`div`,`floorplan-plugin__rule-labels floorplan-plugin__rule-labels--${e}${i?` is-row`:``}`);d.style.width=i?`100%`:`0.0625rem`,d.style.height=i?`0.0625rem`:`100%`,d.appendChild(LT(`div`,`floorplan-plugin__rule-line`));let f=LT(`div`,`floorplan-plugin__rule-scale-wrapper${i?` is-row`:``}`);for(let{left:e,bottom:t}of c){let n=LT(`div`,`floorplan-plugin__rule-scale`);n.style.left=e*100+`%`,n.style.bottom=t*100+`%`,f.appendChild(n)}d.appendChild(f);let p=LT(`div`,`floorplan-plugin__rule-text-wrapper`);for(let{left:e,bottom:t,distance:n}of u){let a=LT(`div`,`floorplan-plugin__rule-text-item`);a.style.left=e*100+`%`,a.style.bottom=t*100+`%`;let o=LT(`div`,`floorplan-plugin__rule-text${i?` is-row`:``}`);o.textContent=r(n),a.appendChild(o),p.appendChild(a)}return d.appendChild(p),d}function tE(e,t,n){let r=t.bounding,i=r.max.x-r.min.x,a=r.max.y-r.min.y,o=i-(QT-$T)*2,s=a-(QT-$T)*2,c=LT(`div`,`floorplan-plugin__rule-labels-wrapper`);c.style.width=o/i*100+`%`,c.style.height=s/a*100+`%`;let l=e.rules;for(let e of[`top`,`right`,`bottom`,`left`]){let t=l[e];!t||t.length===0||c.appendChild(eE(e,t,r,n.getRuleDistanceText))}return c}function nE(e,t){var n;let r=(n=e.entrance)==null?void 0:n.northRad;if(typeof r!=`number`)return;let i=LT(`div`,`floorplan-plugin__compass`),a=IT(r);i.style.transform=`translateX(-50%) translateZ(10px) rotate(${-a+90}deg)`;let o=LT(`div`,`floorplan-plugin__compass-image`);o.style.backgroundImage=`url(${FT})`,i.appendChild(o);let s=LT(`span`,`floorplan-plugin__compass-text`);return s.textContent=t,i.appendChild(s),i}function rE(e){var t,n;let{floorplanData:r,floorIndex:i,config:a}=e,o=r.floorDatas[i],s=LT(`div`,`floorplan-plugin__floor`);if(!(o.rooms.length>0||o.is_has_wall))return s.appendChild(zT(a)),s;if(s.appendChild(GT(o,r,a)),(a.highlightEnable||a.hoverEnable)&&s.appendChild(KT(o,r,e)),s.appendChild(qT(r,i)),s.appendChild(JT(o)),a.roomLabelsEnable&&s.appendChild(XT(o,r,a,(n=(t=e.store.roomOnMouse)==null?void 0:t.id)==null?null:n)),a.ruleLabelsEnable&&s.appendChild(tE(o,r,a)),a.cameraEnable){let t=ZT(r,e.panoIndex,e.lastPanoramaLongitude,a.cameraImageUrl);t&&s.appendChild(t)}if(a.compassEnable){let e=nE(r,a.northDesc);e&&s.appendChild(e)}return s}function iE(e,t,n,r){let i=e.querySelector(`.floorplan-plugin__room-labels`);if(!i)return;let a=i.clientWidth;if(!a)return;let o=t.floorDatas[n],s=new Map(o.rooms.map(e=>[e.id,e])),{max:c,min:l}=t.bounding,u=a/(c.x-l.x);i.querySelectorAll(`.floorplan-plugin__room-label-item`).forEach(e=>{if(!r){e.style.opacity=`1`;return}let t=e.dataset.roomId,n=t?s.get(t):void 0;if(!n)return;let i=e.querySelector(`.floorplan-plugin__room-part1`),a=e.querySelector(`.floorplan-plugin__room-size`),o=PT(n,{width:e.clientWidth,height:e.clientHeight},u),c=i?PT(n,{width:i.clientWidth,height:i.clientHeight},u):o;e.style.opacity=o||c?`1`:`0`,i&&(i.style.opacity=c?`1`:`0`),a&&(a.style.opacity=o?`0.6`:`0`)})}var aE=class{constructor(){this.floorElements=new Map,this.currentFloorIndex=-1,this.isVisible=!1,this.rootElement=document.createElement(`div`),this.rootElement.className=`floorplan-plugin__main`}render(e){let{floorplanData:t,config:n}=e;this.rootElement.style.transitionDuration=e.duration+`ms`,e.visible!==this.isVisible&&(this.isVisible=e.visible,e.visible?(this.rootElement.classList.remove(`floorplan-plugin__main--visible`),requestAnimationFrame(()=>{this.rootElement.classList.add(`floorplan-plugin__main--visible`)})):this.rootElement.classList.remove(`floorplan-plugin__main--visible`));let r=new Set(t.floorDatas.map(e=>e.floorIndex));for(let[e,t]of this.floorElements)r.has(e)||(t.remove(),this.floorElements.delete(e));for(let r of t.floorDatas){let i=rE({floorplanData:t,floorIndex:r.floorIndex,panoIndex:e.panoIndex,lastPanoramaLongitude:e.lastPanoramaLongitude,config:n,highlightData:e.highlightData,store:e.store,onRoomHover:e.onRoomHover}),a=this.floorElements.get(r.floorIndex);a?this.rootElement.replaceChild(i,a):this.rootElement.appendChild(i),this.floorElements.set(r.floorIndex,i)}this.currentFloorIndex!==e.floorIndex&&(this.currentFloorIndex=e.floorIndex);for(let[t,n]of this.floorElements)n.classList.toggle(`floorplan-plugin__floor--is-current`,t===e.floorIndex);let i=this.floorElements.get(e.floorIndex);i&&requestAnimationFrame(()=>{iE(i,t,e.floorIndex,n.adaptiveRoomLabelVisibleEnable)})}updateLabelsVisibility(e,t,n){let r=this.floorElements.get(t);r&&iE(r,e,t,n)}dispose(){this.rootElement.remove(),this.floorElements.clear()}},oE=`.floorplan-plugin__main {
|
|
384
|
+
position: absolute;
|
|
385
|
+
pointer-events: none;
|
|
386
|
+
opacity: 0;
|
|
387
|
+
transition-property: opacity;
|
|
388
|
+
transition-timing-function: linear;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.floorplan-plugin__main--visible {
|
|
392
|
+
opacity: 1;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.floorplan-plugin__floor {
|
|
396
|
+
position: absolute;
|
|
397
|
+
left: 0;
|
|
398
|
+
top: 0;
|
|
399
|
+
width: 100%;
|
|
400
|
+
height: 100%;
|
|
401
|
+
opacity: 0;
|
|
402
|
+
pointer-events: none;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.floorplan-plugin__floor--is-current {
|
|
406
|
+
opacity: 1;
|
|
407
|
+
pointer-events: auto;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/* ============ missing floor ============ */
|
|
411
|
+
.floorplan-plugin__missing-floor {
|
|
412
|
+
position: absolute;
|
|
413
|
+
left: 50%;
|
|
414
|
+
top: 50%;
|
|
415
|
+
transform: translate(-50%, -50%);
|
|
416
|
+
display: flex;
|
|
417
|
+
flex-direction: column;
|
|
418
|
+
align-items: center;
|
|
419
|
+
}
|
|
420
|
+
.floorplan-plugin__missing-floor-text {
|
|
421
|
+
margin-top: 12px;
|
|
422
|
+
color: #fff;
|
|
423
|
+
opacity: 0.3;
|
|
424
|
+
white-space: nowrap;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/* ============ room material ============ */
|
|
428
|
+
.floorplan-plugin__room-material {
|
|
429
|
+
position: absolute;
|
|
430
|
+
left: 0;
|
|
431
|
+
top: 0;
|
|
432
|
+
width: 100%;
|
|
433
|
+
height: 100%;
|
|
434
|
+
}
|
|
435
|
+
.floorplan-plugin__room-material svg {
|
|
436
|
+
position: absolute;
|
|
437
|
+
left: 0;
|
|
438
|
+
top: 0;
|
|
439
|
+
width: 100%;
|
|
440
|
+
height: 100%;
|
|
441
|
+
overflow: visible;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/* ============ room highlight ============ */
|
|
445
|
+
.floorplan-plugin__room-highlight {
|
|
446
|
+
position: absolute;
|
|
447
|
+
width: 100%;
|
|
448
|
+
height: 100%;
|
|
449
|
+
}
|
|
450
|
+
.floorplan-plugin__room-highlight svg {
|
|
451
|
+
width: 100%;
|
|
452
|
+
height: 100%;
|
|
453
|
+
overflow: visible;
|
|
454
|
+
}
|
|
455
|
+
.floorplan-plugin__room-highlight path {
|
|
456
|
+
--opacity: 0;
|
|
457
|
+
opacity: var(--opacity);
|
|
458
|
+
fill: #fff;
|
|
459
|
+
pointer-events: auto;
|
|
460
|
+
}
|
|
461
|
+
.floorplan-plugin__room-highlight path:hover {
|
|
462
|
+
opacity: calc(var(--opacity) + 0.1);
|
|
463
|
+
}
|
|
464
|
+
/* main 未展示时,子元素显式设置的 pointer-events:auto 会覆盖父级 none,这里强制统一关闭交互 */
|
|
465
|
+
.floorplan-plugin__main:not(.floorplan-plugin__main--visible) * {
|
|
466
|
+
pointer-events: none !important;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/* ============ base image ============ */
|
|
470
|
+
.floorplan-plugin__base-image {
|
|
471
|
+
position: absolute;
|
|
472
|
+
z-index: 10;
|
|
473
|
+
width: 100%;
|
|
474
|
+
height: 100%;
|
|
475
|
+
pointer-events: none;
|
|
476
|
+
}
|
|
477
|
+
.floorplan-plugin__base-image img {
|
|
478
|
+
width: 100%;
|
|
479
|
+
height: 100%;
|
|
480
|
+
}
|
|
481
|
+
.floorplan-plugin__base-image svg [type='lineGroup'] path {
|
|
482
|
+
fill: #ffffff;
|
|
483
|
+
stroke: #ffffff;
|
|
484
|
+
}
|
|
485
|
+
.floorplan-plugin__base-image svg [type='lineItemGroup'] g g g g {
|
|
486
|
+
stroke: #ffffff;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/* ============ items ============ */
|
|
490
|
+
.floorplan-plugin__items {
|
|
491
|
+
width: 100%;
|
|
492
|
+
height: 100%;
|
|
493
|
+
position: absolute;
|
|
494
|
+
left: 0;
|
|
495
|
+
top: 0;
|
|
496
|
+
z-index: 20;
|
|
497
|
+
pointer-events: none;
|
|
498
|
+
}
|
|
499
|
+
.floorplan-plugin__item {
|
|
500
|
+
position: absolute;
|
|
501
|
+
display: flex;
|
|
502
|
+
flex-flow: column;
|
|
503
|
+
align-items: center;
|
|
504
|
+
line-height: 1;
|
|
505
|
+
color: #fff;
|
|
506
|
+
transform: translate(-50%, -50%);
|
|
507
|
+
white-space: nowrap;
|
|
508
|
+
transition: opacity 300ms;
|
|
509
|
+
}
|
|
510
|
+
.floorplan-plugin__item-img {
|
|
511
|
+
width: 100%;
|
|
512
|
+
height: 100%;
|
|
513
|
+
}
|
|
514
|
+
.floorplan-plugin__item-notes {
|
|
515
|
+
position: absolute;
|
|
516
|
+
top: 50%;
|
|
517
|
+
left: 50%;
|
|
518
|
+
transform: translate(-50%, -50%);
|
|
519
|
+
padding: 4px;
|
|
520
|
+
line-height: 1;
|
|
521
|
+
border-radius: 4px;
|
|
522
|
+
color: #fff;
|
|
523
|
+
background: rgba(0, 0, 0, 0.6);
|
|
524
|
+
font-size: 12px;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* ============ room labels ============ */
|
|
528
|
+
.floorplan-plugin__room-labels {
|
|
529
|
+
width: 100%;
|
|
530
|
+
height: 100%;
|
|
531
|
+
position: absolute;
|
|
532
|
+
left: 0;
|
|
533
|
+
top: 0;
|
|
534
|
+
z-index: 20;
|
|
535
|
+
pointer-events: none;
|
|
536
|
+
}
|
|
537
|
+
.floorplan-plugin__room-label-item {
|
|
538
|
+
position: absolute;
|
|
539
|
+
display: flex;
|
|
540
|
+
flex-flow: column;
|
|
541
|
+
align-items: center;
|
|
542
|
+
line-height: 1;
|
|
543
|
+
color: #fff;
|
|
544
|
+
transform: translate(-50%, -50%);
|
|
545
|
+
white-space: nowrap;
|
|
546
|
+
transition: opacity 300ms;
|
|
547
|
+
font-size: 12px;
|
|
548
|
+
}
|
|
549
|
+
.floorplan-plugin__room-part1 {
|
|
550
|
+
display: flex;
|
|
551
|
+
flex-flow: column;
|
|
552
|
+
align-items: center;
|
|
553
|
+
color: #fff;
|
|
554
|
+
white-space: nowrap;
|
|
555
|
+
transition: opacity 300ms;
|
|
556
|
+
}
|
|
557
|
+
.floorplan-plugin__room-name {
|
|
558
|
+
font-size: 12px;
|
|
559
|
+
}
|
|
560
|
+
.floorplan-plugin__room-area {
|
|
561
|
+
opacity: 0.6;
|
|
562
|
+
line-height: 1.25;
|
|
563
|
+
margin-top: 2px;
|
|
564
|
+
font-size: 10px;
|
|
565
|
+
}
|
|
566
|
+
.floorplan-plugin__room-size {
|
|
567
|
+
font-size: 10px;
|
|
568
|
+
transition: opacity 300ms;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/* ============ camera ============ */
|
|
572
|
+
.floorplan-plugin__camera-position {
|
|
573
|
+
pointer-events: none;
|
|
574
|
+
position: absolute;
|
|
575
|
+
width: 0;
|
|
576
|
+
height: 0;
|
|
577
|
+
}
|
|
578
|
+
.floorplan-plugin__camera-rotate {
|
|
579
|
+
position: absolute;
|
|
580
|
+
background-repeat: no-repeat;
|
|
581
|
+
background-size: 100%;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/* ============ rule labels ============ */
|
|
585
|
+
.floorplan-plugin__rule-labels-wrapper {
|
|
586
|
+
position: absolute;
|
|
587
|
+
top: 50%;
|
|
588
|
+
left: 50%;
|
|
589
|
+
transform: translate(-50%, -50%);
|
|
590
|
+
pointer-events: none;
|
|
591
|
+
}
|
|
592
|
+
.floorplan-plugin__rule-labels {
|
|
593
|
+
position: absolute;
|
|
594
|
+
display: flex;
|
|
595
|
+
}
|
|
596
|
+
.floorplan-plugin__rule-labels--top {
|
|
597
|
+
left: 0;
|
|
598
|
+
top: -1.25rem;
|
|
599
|
+
}
|
|
600
|
+
.floorplan-plugin__rule-labels--bottom {
|
|
601
|
+
left: 0;
|
|
602
|
+
bottom: -1.25rem;
|
|
603
|
+
}
|
|
604
|
+
.floorplan-plugin__rule-labels--left {
|
|
605
|
+
top: 0;
|
|
606
|
+
left: -1.25rem;
|
|
607
|
+
}
|
|
608
|
+
.floorplan-plugin__rule-labels--right {
|
|
609
|
+
top: 0;
|
|
610
|
+
right: -1.25rem;
|
|
611
|
+
}
|
|
612
|
+
.floorplan-plugin__rule-line {
|
|
613
|
+
background: #fff;
|
|
614
|
+
opacity: 0.2;
|
|
615
|
+
width: 100%;
|
|
616
|
+
height: 100%;
|
|
617
|
+
}
|
|
618
|
+
.floorplan-plugin__rule-scale-wrapper {
|
|
619
|
+
position: absolute;
|
|
620
|
+
width: 0.3125rem;
|
|
621
|
+
height: 100%;
|
|
622
|
+
left: 50%;
|
|
623
|
+
top: 0;
|
|
624
|
+
transform: translateX(-50%);
|
|
625
|
+
}
|
|
626
|
+
.floorplan-plugin__rule-labels.is-row .floorplan-plugin__rule-scale-wrapper {
|
|
627
|
+
width: 100%;
|
|
628
|
+
height: 0.3125rem;
|
|
629
|
+
top: 50%;
|
|
630
|
+
left: 0;
|
|
631
|
+
transform: translateY(-50%);
|
|
632
|
+
}
|
|
633
|
+
.floorplan-plugin__rule-scale {
|
|
634
|
+
position: absolute;
|
|
635
|
+
background: #fff;
|
|
636
|
+
opacity: 0.2;
|
|
637
|
+
width: 100%;
|
|
638
|
+
height: 0.0625rem;
|
|
639
|
+
}
|
|
640
|
+
.floorplan-plugin__rule-labels.is-row .floorplan-plugin__rule-scale {
|
|
641
|
+
width: 0.0625rem;
|
|
642
|
+
height: 100%;
|
|
643
|
+
}
|
|
644
|
+
.floorplan-plugin__rule-text-wrapper {
|
|
645
|
+
position: absolute;
|
|
646
|
+
}
|
|
647
|
+
.floorplan-plugin__rule-labels--top .floorplan-plugin__rule-text-wrapper {
|
|
648
|
+
width: 100%;
|
|
649
|
+
height: 0;
|
|
650
|
+
top: 0.625rem;
|
|
651
|
+
}
|
|
652
|
+
.floorplan-plugin__rule-labels--bottom .floorplan-plugin__rule-text-wrapper {
|
|
653
|
+
width: 100%;
|
|
654
|
+
height: 0;
|
|
655
|
+
bottom: 0.625rem;
|
|
656
|
+
}
|
|
657
|
+
.floorplan-plugin__rule-labels--left .floorplan-plugin__rule-text-wrapper {
|
|
658
|
+
width: 0;
|
|
659
|
+
height: 100%;
|
|
660
|
+
left: 0.625rem;
|
|
661
|
+
}
|
|
662
|
+
.floorplan-plugin__rule-labels--right .floorplan-plugin__rule-text-wrapper {
|
|
663
|
+
width: 0;
|
|
664
|
+
height: 100%;
|
|
665
|
+
right: 0.625rem;
|
|
666
|
+
}
|
|
667
|
+
.floorplan-plugin__rule-text-item {
|
|
668
|
+
width: 0;
|
|
669
|
+
height: 0;
|
|
670
|
+
position: absolute;
|
|
671
|
+
transform: rotate(90deg);
|
|
672
|
+
}
|
|
673
|
+
.floorplan-plugin__rule-labels.is-row .floorplan-plugin__rule-text-item {
|
|
674
|
+
transform: rotate(0);
|
|
675
|
+
}
|
|
676
|
+
.floorplan-plugin__rule-text {
|
|
677
|
+
width: max-content;
|
|
678
|
+
transform: translate(-50%, -50%);
|
|
679
|
+
font-size: 0.625rem;
|
|
680
|
+
color: #fff;
|
|
681
|
+
opacity: 0.35;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/* ============ compass ============ */
|
|
685
|
+
.floorplan-plugin__compass {
|
|
686
|
+
position: absolute;
|
|
687
|
+
left: 50%;
|
|
688
|
+
top: -46px;
|
|
689
|
+
width: 231px;
|
|
690
|
+
height: 41px;
|
|
691
|
+
transform-origin: center 184px;
|
|
692
|
+
}
|
|
693
|
+
.floorplan-plugin__compass-image {
|
|
694
|
+
width: 100%;
|
|
695
|
+
height: 100%;
|
|
696
|
+
position: absolute;
|
|
697
|
+
left: 0;
|
|
698
|
+
top: 0;
|
|
699
|
+
opacity: 0.1;
|
|
700
|
+
background-repeat: no-repeat;
|
|
701
|
+
background-size: 100% 100%;
|
|
702
|
+
}
|
|
703
|
+
.floorplan-plugin__compass-text {
|
|
704
|
+
position: absolute;
|
|
705
|
+
left: 50%;
|
|
706
|
+
top: 15px;
|
|
707
|
+
transform: translateX(-50%);
|
|
708
|
+
opacity: 0.2;
|
|
709
|
+
font-weight: bold;
|
|
710
|
+
font-size: 10px;
|
|
711
|
+
color: #fff;
|
|
712
|
+
}
|
|
713
|
+
`,sE=500,cE=.01;function lE(e){let{latitude:t,longitude:n}=e,r=Math.abs(t-Math.PI/2)>5*Math.PI/180,i=n>Math.PI/180*5&&n<Math.PI/180*355;return r||i}function uE(e){let{latitude:t,longitude:n}=e,r=Math.abs(t-Math.PI/2)<10*Math.PI/180,i=n<Math.PI/180*30||n>Math.PI/180*330;return r&&i}var dE=class extends o.Controller{constructor(e,t){var n,i,a;super(e),this.name=`FloorplanPlugin`,this.renderer=new aE,this.styleSheet=new CSSStyleSheet,this.panoIndex=0,this.floorIndex=0,this.lastPanoramaLongitude=0,this.size={width:0,height:0},this.hasAddedEventListener=!1,this.isHiddenByHideFunc=!1,this.highlightData={},this.store={roomOnMouse:null},this.dispose=()=>{var e,t;this.removeEventListener(),(e=this.resizeObserver)==null||e.disconnect(),(t=this.removeExtraElement)==null||t.call(this),this.removeExtraElement=void 0,this.pendingCameraUpdateFrame!==void 0&&cancelAnimationFrame(this.pendingCameraUpdateFrame),this.pendingResizeFrame!==void 0&&cancelAnimationFrame(this.pendingResizeFrame),this.renderer.dispose(),this.wrapper=void 0,this.data=void 0,this.hooks.emit(`dispose`)},this.show=(...e)=>r(this,[...e],void 0,function*(e={}){var t;if(!this.state.enabled||!this.showPromise&&this.state.visible)return;let n=(t=e.userAction)==null?!0:t;return this.updateState({visible:!0},n),this._show(e)}),this.hide=(...e)=>r(this,[...e],void 0,function*(e={}){var t;this.state.enabled&&(this.isHiddenByHideFunc=!0,this.state.visible!==!1&&(this.updateState({visible:!1},(t=e.userAction)==null?!0:t),this._hide(e)))}),this.highlight=e=>{this.state.config.highlightEnable&&(this.highlightData=e,this.renderCurrent())},this.unhighlight=()=>{this.highlightData={},this.renderCurrent()},this.updateShowState=e=>{this.showState=Object.assign(Object.assign({},this.showState),e)},this.onRoomHover=e=>{this.store.roomOnMouse=e},this.handleClick=()=>{if(this.state.visible&&this.hooks.emit(`click`,this.store.roomOnMouse))return!1},this.onFiveModelLoaded=()=>{var e,t,n;this.state.enabled!==!1&&(this.floorIndex=(n=(t=(e=this.five.work)==null?void 0:e.observers[this.panoIndex])==null?void 0:t.floorIndex)==null?0:n,this.renderCurrent())},this.onFiveModeChange=e=>{e!==this.showState.mode&&(this.updateState({visible:!1},!1),this._hide({userAction:!1}))},this.onFiveInertiaPan=(e,t)=>{t&&(this.state.visible||this.state.config.autoShowEnable!==!1&&(this.isHiddenByHideFunc||this.five.currentMode===this.showState.mode&&uE(this.getRelativePose(this.five.getCurrentState()))&&(this.updateState({visible:!0},!0),this._show({isAutoShow:!0}))))},this.onFivePanoArrived=e=>{var t,n;this.five.work&&(this.panoIndex=e,this.floorIndex=(n=(t=this.five.work.observers[e])==null?void 0:t.floorIndex)==null?this.floorIndex:n)},this.onFiveCameraUpdate=(e,t)=>{this.state.visible&&(this.showPromise||(this.scheduleCameraUpdate(),lE(this.getRelativePose(this.five.getCurrentState()))&&(this.updateState({visible:!1},t),this._hide({userAction:t}))))},this.onFiveWantsPanGesture=(e,t)=>{if(this.five.currentMode===this.showState.mode&&this.state.config.autoShowEnable!==!1&&t&&this.state.visible)return this.five.updateCamera(fT(this.showState,[`mode`,`offset`]),0),!1},this.onFiveWantsTapGesture=()=>this.handleClick(),this.onFiveWantsChangeMode=(e,t)=>{t===`Panorama`&&e===this.showState.mode&&(this.lastPanoramaLongitude=this.five.getCurrentState().longitude)},this.onModelShownFloorChange=e=>{var t,n,r;if(this.floorIndex!==e){if(e===null){this.floorIndex=(r=(n=(t=this.five.work)==null?void 0:t.observers[this.panoIndex])==null?void 0:n.floorIndex)==null?this.floorIndex:r;return}this.floorIndex=e,this.updateSize(),this.renderCurrent()}},this._show=e=>r(this,void 0,void 0,function*(){var t;if(!this.state.enabled)return;if(!((t=this.five.model)!=null&&t.loaded))throw Error(`ModelNotLoaded`);if(!this.data)throw Error(`DataNotLoaded`);if(this.showPromise)return this.showPromise;let n=Object.assign({floorIndex:this.floorIndex,modelOpacity:this.state.config.modelOpacity,immediately:!1,isAutoShow:!1,userAction:!0},e),i=()=>r(this,void 0,void 0,function*(){var e;this.hooks.emit(`show`,{userAction:n.userAction,auto:n.isAutoShow});let t=!1,r;this.showRejection=e=>{t=!0,r=e};let[i]=yield sT(mT(this.five,this.showState,n.userAction));if(i)throw i;if(t)throw Error(r||`UnknownError`);if(!this.updateSize())throw Error(`UpdateSizeError`);this.updatePosition(),this.floorIndex=n.floorIndex,(e=this.five.model)==null||e.show(this.floorIndex)});return this.isHiddenByHideFunc=!1,this.showPromise=i().then(()=>{this.showPromise=void 0,this.showRejection=void 0;let e=n.immediately?0:sE;hT(this.five,n.modelOpacity,e),this.renderWithDuration(e),this.hooks.emit(`showAnimationEnded`,{auto:n.isAutoShow,userAction:n.userAction})}).catch(e=>{if(this.showPromise=void 0,this.showRejection=void 0,this.updateState({visible:!1},n.userAction),!n.isAutoShow)throw e}),this.showPromise}),this._hide=e=>{var t;(t=this.showRejection)==null||t.call(this,`BreakOffByHide`),this.showPromise=void 0;let n=Object.assign({userAction:!0,isAutoHide:!1},e);hT(this.five,1,0),this.hooks.emit(`hide`,{auto:n.isAutoHide,userAction:n.userAction}),this.renderCurrent()},this.five=e,this.styleSheet.replaceSync(oE),typeof document<`u`&&document.adoptedStyleSheets.push(this.styleSheet),this.showState=Object.assign({mode:`Mapview`,longitude:0,latitude:Math.PI/2,fov:80},t==null?void 0:t.showState);let o={northDesc:`北`,modelOpacity:cE,cameraEnable:!0,highlightEnable:!1,hoverEnable:!0,compassEnable:!0,autoShowEnable:!0,ruleLabelsEnable:!0,roomLabelsEnable:!0,roomAreaEnable:!0,roomNameEnable:!0,roomNameOtherTypeEnable:!0,roomDimensionEnable:!0,cameraImageUrl:void 0,attachedTo:3,getLabelElement:void 0,adaptiveRoomLabelVisibleEnable:!0,missingFloorConfig:{imageWidth:200,imageHeight:120,text:`暂无平面图`,textFontSize:14},i18n:e=>e,getRoomAreaText:e=>(e/1e6).toFixed(1)+`㎡`,getRoomDimensionText:(e,t)=>(e/1e3).toFixed(1)+`m × `+(t/1e3).toFixed(1)+`m`,getRuleDistanceText:e=>e.toString()},s=Object.assign(Object.assign(Object.assign({},o),t==null?void 0:t.config),{missingFloorConfig:Object.assign(Object.assign({},o.missingFloorConfig),(n=t==null?void 0:t.config)==null?void 0:n.missingFloorConfig)});this.state={enabled:!0,visible:!1,config:s},Object.assign(this.state,fT((i=t==null?void 0:t.initialState)==null?{}:i,[`config`])),this.panoIndex=(a=e.state.panoIndex)==null?0:a,this.initContainer(),xT(e).then(this.onFiveModelLoaded),e.once(`dispose`,this.dispose),this.state.enabled?this.addEventListener():this.styleSheet.disabled=!0}load(e,t){return r(this,arguments,void 0,function*(e,t,n=!0){let r=`data`in e?e.data:e,i=this.data;this.data=yield iT(r),this.hooks.emit(`dataLoaded`,this.data),this.hooks.emit(`dataChange`,this.data,i),t&&this.updateState(t,n),this.updateSize(),this.updatePosition(),this.renderCurrent()})}loadItems(e){this.data&&(this.data.floorDatas.forEach((t,n)=>{t.items=e[n]}),this.renderCurrent())}appendTo(e){this.wrapper=e,this.state.enabled&&(e.appendChild(this.renderer.rootElement),this.observeResize(e),this.registerExtraElement(),this.updateSize(),this.updatePosition(),this.renderCurrent())}enable(e={}){var t;if(this.state.enabled)return;let n=(t=e.userAction)==null?!0:t;this.updateState({enabled:!0},n),this._enable({userAction:n})}disable(e={}){var t;if(!this.state.enabled)return;let n=(t=e.userAction)==null?!0:t;this.updateState({enabled:!1},n),this._disable({userAction:n})}setState(e,t={}){var n;let r=this.state,i=(n=t.userAction)==null?!0:n;this.updateState(e,i),e.enabled!==void 0&&r.enabled!==e.enabled&&(e.enabled?this._enable({userAction:i}):this._disable({userAction:i})),e.visible!==void 0&&r.visible!==e.visible&&(e.visible?this._show({userAction:i}):this._hide({userAction:i}))}changeConfigs(e,t=!0){this.updateState({config:Object.assign(Object.assign({},this.state.config),e)},t),this.renderCurrent()}updateSize(){if(!this.data||!this.wrapper)return!1;let{min:e,max:t}=this.data.bounding,n=t.x-e.x,r=t.y-e.y,i=this.getPxmmWithRotation(),a=Math.ceil(n*i),o=Math.ceil(r*i);return this.size.width===a&&this.size.height===o?!0:(this.renderer.rootElement.style.width=a+`px`,this.renderer.rootElement.style.height=o+`px`,this.size={width:a,height:o},!0)}updatePosition(){if(!this.wrapper)return;let e=_T(this.five,this.floorIndex,this.state.config.attachedTo),t=this.five.modelScene.boundingBox.getCenter(new O);t.y=e;let n=t.clone().project(this.five.camera),r=(n.x+1)/2,i=-(n.y-1)/2;this.renderer.rootElement.style.position=`absolute`,this.renderer.rootElement.style.left=r*100+`%`,this.renderer.rootElement.style.top=i*100+`%`,this.renderer.rootElement.style.transform=`translate(-50%, -50%)`}getPxmmWithRotation(){if(!this.wrapper)return 0;let e={attachedTo:this.state.config.attachedTo};return vT(this.five,this.wrapper,this.floorIndex,e)}updateState(e,t){let n=this.state,r=e.config?Object.assign(Object.assign({},n.config),e.config):n.config;this.state=Object.assign(Object.assign(Object.assign({},this.state),e),{config:r}),!AT(this.state,n,{deep:!0})&&this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}initContainer(){this.renderer.rootElement.classList.add(`floorplan-plugin`)}registerExtraElement(){var e;(e=this.removeExtraElement)==null||e.call(this),this.removeExtraElement=this.five.addExtraElement(this.renderer.rootElement)}observeResize(e){var t;(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=new ResizeObserver(()=>{this.scheduleResizeUpdate()}),this.resizeObserver.observe(e)}scheduleResizeUpdate(){this.pendingResizeFrame===void 0&&(this.pendingResizeFrame=requestAnimationFrame(()=>{this.pendingResizeFrame=void 0,this.updateSize(),this.updatePosition(),this.data&&this.renderer.updateLabelsVisibility(this.data,this.floorIndex,this.state.config.adaptiveRoomLabelVisibleEnable)}))}renderCurrent(){this.data&&this.renderer.render({visible:this.state.visible,duration:0,panoIndex:this.panoIndex,floorIndex:this.floorIndex,floorplanData:this.data,lastPanoramaLongitude:this.lastPanoramaLongitude,config:this.state.config,highlightData:this.highlightData,store:this.store,onRoomHover:this.onRoomHover})}addEventListener(){if(!this.state.enabled||this.hasAddedEventListener)return;this.hasAddedEventListener=!0;let e=this.five;e.on(`modeChange`,this.onFiveModeChange),e.on(`interiaPan`,this.onFiveInertiaPan),e.on(`panoArrived`,this.onFivePanoArrived),e.on(`cameraUpdate`,this.onFiveCameraUpdate),e.on(`wantsPanGesture`,this.onFiveWantsPanGesture),e.on(`wantsTapGesture`,this.onFiveWantsTapGesture),e.on(`wantsChangeMode`,this.onFiveWantsChangeMode),e.on(`modelShownFloorChange`,this.onModelShownFloorChange)}removeEventListener(){this.hasAddedEventListener=!1;let e=this.five;e.off(`modeChange`,this.onFiveModeChange),e.off(`interiaPan`,this.onFiveInertiaPan),e.off(`panoArrived`,this.onFivePanoArrived),e.off(`cameraUpdate`,this.onFiveCameraUpdate),e.off(`wantsPanGesture`,this.onFiveWantsPanGesture),e.off(`wantsTapGesture`,this.onFiveWantsTapGesture),e.off(`wantsChangeMode`,this.onFiveWantsChangeMode),e.off(`modelShownFloorChange`,this.onModelShownFloorChange)}scheduleCameraUpdate(){this.pendingCameraUpdateFrame===void 0&&(this.pendingCameraUpdateFrame=requestAnimationFrame(()=>{this.pendingCameraUpdateFrame=void 0,this.updatePosition(),this.updateSize()}))}getRelativePose(e){let t=this.showState.longitude||0,n=((e.longitude-t)%(2*Math.PI)+2*Math.PI)%(2*Math.PI);return{latitude:e.latitude,longitude:n}}_enable(e){this.styleSheet.disabled=!1,this.addEventListener(),this.wrapper&&(this.wrapper.appendChild(this.renderer.rootElement),this.registerExtraElement()),this.hooks.emit(`enable`,{userAction:e.userAction}),this.state.visible&&this._show({userAction:e.userAction})}_disable(e){var t,n;this.styleSheet.disabled=!0,(t=this.showRejection)==null||t.call(this,`BreakOffByDisable`),this.showPromise=void 0,this.renderer.rootElement.remove(),(n=this.removeExtraElement)==null||n.call(this),this.removeExtraElement=void 0,this.removeEventListener(),this.hooks.emit(`disable`,{userAction:e.userAction})}renderWithDuration(e){this.data&&this.renderer.render({visible:this.state.visible,duration:e,panoIndex:this.panoIndex,floorIndex:this.floorIndex,floorplanData:this.data,lastPanoramaLongitude:this.lastPanoramaLongitude,config:this.state.config,highlightData:this.highlightData,store:this.store,onRoomHover:this.onRoomHover})}},fE=(e,t)=>new dE(e,t),pE=class{constructor(e,t,n,r,i){this.R=e,this.Q=t,this.A=n,this.B=r,this.C=i,this.cov=NaN,this.x=NaN}filter(e,t=0){if(isNaN(this.x))this.x=1/this.C*e,this.cov=1/this.C*this.Q*(1/this.C);else{let n=this.A*this.x+this.B*t,r=this.A*this.cov*this.A+this.R,i=r*this.C*(1/(this.C*r*this.C+this.Q));this.x=n+i*(e-this.C*n),this.cov=r-i*this.C*r}return this.x}},mE=class extends o.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){var n,r,i;super(e),this.boundingAABB=null,this.cancelAnimation=null,this.boundsSet=!1,this.keyframes=[],this.five=e,this.state={enabled:!0,visible:!0},this.duration=(n=t==null?void 0:t.duration)==null?5e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?3e3:i}load(){return r(this,void 0,void 0,function*(){})}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!0},n)}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!1},n)}dispose(){this.disable(),this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null);try{let e=this.findRenderMesh();e&&(e.material.aggregationEnabled=!1,e.material.aggregationProgress=1)}catch(e){}}extractKeyframes(e){let t=[];if(!e.content.data)throw Error(`轨迹数据未加载`);let n=e.content.data.positionArray,r=n.length/3,i=.01,a=.1,o=new pE(i,a,1,0,1),s=new pE(i,a,1,0,1),c=new pE(i,a,1,0,1),l=new Float32Array(r);for(let e=0;e<r;e++)if(e===0)l[e]=0;else{let t=new O(n[(e-1)*3],n[(e-1)*3+1],n[(e-1)*3+2]);l[e]=new O(n[e*3],n[e*3+1],n[e*3+2]).distanceTo(t)+l[e-1]}for(let i=0;i<r;i++){let a=new O(0,0,0),u=0;for(let e=i-5;e<i+6;e++)e>=0&&e<r&&(a.add(new O(n[e*3],n[e*3+1],n[e*3+2])),u++);a.divideScalar(u).applyMatrix4(e.transform);let d=o.filter(a.x),f=s.filter(a.y),p=c.filter(a.z);t.push({position:new O(d,f,p),location:l[i]})}return t}computeAABB2D(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)a.position.x<t&&(t=a.position.x),a.position.x>n&&(n=a.position.x),a.position.z<r&&(r=a.position.z),a.position.z>i&&(i=a.position.z);return{min:new it(t,r),max:new it(n,i)}}findClosestKeyframeToRay(e,t){let n=1/0,r=t[0].position.clone(),i=new O;for(let a of t){e.closestPointToPoint(a.position,i);let t=i.distanceTo(a.position);t<n&&(n=t,r=a.position.clone())}return r}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{if(e)return;let n=t,r=n.material;r&&r.isPBMGaussianSplattingMaterial&&(e=n)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}loadTrajectoryDataIfNeeded(e){return r(this,void 0,void 0,function*(){var n,r,i,a,o,s,c,l;if((n=e.content)!=null&&n.data)return;if(((r=e.content)==null?void 0:r.loadState)===`LOADING`){yield new Promise(n=>{let r=t.AnimationFrameLoop.shared.add(()=>{var t;let i=(t=e.content)==null?void 0:t.loadState;(i===`READY`||i===`FAILED`||i===`UNLOADED`)&&(r(),n())})});return}let u=(i=this.five.model.viewLayers)==null?void 0:i[0],d=u==null?void 0:u.fetcher,f=u==null?void 0:u.search,p=(a=e.content)==null?void 0:a.uri;if(!d||!p)return;let m=f?p.includes(`?`)?`${p}&${f.replace(/^\?/,``)}`:`${p}${f.startsWith(`?`)?f:`?${f}`}`:p;e.content.loadState=`LOADING`;try{let n=yield(0,t.loadPly)(m,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:d}),r=n.scene,i=r.getAttribute(`position`),a=r.getAttribute(`time`),u=(o=i==null?void 0:i.array)==null?new Float32Array:o,f=(s=a==null?void 0:a.array)==null?new Uint32Array:s;e.content.data={uri:m,byteLength:(c=n.byteLength)==null?0:c,memoryUsage:(l=n.memoryUsage)==null?0:l,positionArray:u,timeArray:f,object:null},e.content.loadState=`READY`}catch(t){console.warn(`[GaussianSplattingEntranceAnimationPlugin] trajectory ply 加载失败,将使用 3DGS AABB 回退`,t),e.content.data=void 0,e.content.loadState=`FAILED`}})}computeGSSceneBounds(){let e=new Cn,t=new Cn;return this.five.scene.traverse(n=>{let r=n;(r==null?void 0:r.boundingBox)instanceof Cn&&!r.boundingBox.isEmpty()&&(t.copy(r.boundingBox),r.matrixWorld&&t.applyMatrix4(r.matrixWorld),e.union(t))}),e.isEmpty()?null:e}getCameraCurve(){return r(this,void 0,void 0,function*(){var e,t,n,r,i,a,o,s,c,l;let u=(r=(n=(t=(e=this.five.model.viewLayers)==null?void 0:e[0])==null?void 0:t.trajectories)==null?void 0:n[0])==null?(s=(o=(a=(i=this.five.model.viewLayers)==null?void 0:i[0])==null?void 0:a.scene)==null?void 0:o.trajectories)==null?void 0:s[0]:r,d=null,f=null;if(u&&(yield this.loadTrajectoryDataIfNeeded(u),(c=u.content)!=null&&c.data&&((l=u.content.data.positionArray)==null?void 0:l.length)>=6&&(d=this.extractKeyframes(u),d.length>=2?f=this.computeAABB2D(d):d=null)),!d||!f){let e=this.computeGSSceneBounds();if(!e)throw Error(`未找到可用于计算入场曲线的 3DGS 边界或轨迹`);f={min:new it(e.min.x,e.min.z),max:new it(e.max.x,e.max.z)};let t=(f.min.x+f.max.x)/2,n=(f.min.y+f.max.y)/2,r=(e.min.y+e.max.y)/2,i=Math.max(f.max.x-f.min.x,f.max.y-f.min.y)*.5;d=[];let a=0,o=null;for(let e=0;e<16;e++){let s=e/16*Math.PI*2,c=new O(t+Math.cos(s)*i,r,n+Math.sin(s)*i);o&&(a+=c.distanceTo(o)),d.push({position:c,location:a}),o=c}}this.keyframes=d,this.boundingAABB=f;let p=this.curveHeight,m=new O((f.min.x+f.max.x)/2,p,(f.min.y+f.max.y)/2),h=(f.max.x-f.min.x)/2,g=(f.max.y-f.min.y)/2,_=Math.sqrt(h*h+g*g),v=e=>{let t=new O().subVectors(e,m);return t.length()<.001&&t.set(1,0,0),m.clone().add(t.normalize().multiplyScalar(_))},y=new O(d[0].position.x,p,d[0].position.z),b=v(y),x=new O().subVectors(m,y).normalize(),S=new hr(y,x),C=new hr(m,new O(-x.z,0,x.x).normalize()),ee=this.findClosestKeyframeToRay(C,d),te=v(new O(ee.x,p,ee.z)),ne=this.findClosestKeyframeToRay(S,d);return new di([b,te,v(new O(ne.x,p,ne.z))],!1,`centripetal`,.5)})}setBounding(e,t,n){let r=this.findRenderMesh();r.material.aggregationBoundsMin.copy(e),r.material.aggregationBoundsMax.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),n=new O(e.min.x,0,e.min.y),r=new O(e.max.x,3,e.max.y);t.material.aggregationBoundsMin.copy(n),t.material.aggregationBoundsMax.copy(r),this.boundsSet=!0}normalizedPointDuration(){let e=this.pointDuration;return e<=0?.01:Math.min(e<=1?e:e/this.duration,1)}resetToPointCloud(){return r(this,void 0,void 0,function*(){this.boundingAABB||(yield this.getCameraCurve()),this.setBounds();let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0})}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let n=performance.now(),r=this.duration;this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-n,i=Math.min(t/r,1);e.aggregationProgress=i*i*(3-2*i),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.aggregationEnabled=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return r(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),n=this.boundingAABB,r=new O((n.min.x+n.max.x)/2,this.curveHeight,(n.min.y+n.max.y)/2),i=e.getPointAt(0),a=new t.Camera(90).copy(this.five.camera);a.position.copy(i),a.lookAt(r),a.computePose(0),this.five.setState(Object.assign({},a.pose)),this.setBounds();let o=this.findRenderMesh().material;o.aggregationEnabled=!0,o.aggregationProgress=0,o.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let s=this.duration,c=performance.now();return new Promise(n=>{this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-c,i=Math.min(t/s,1),l=i*i*(3-2*i);o.aggregationProgress=l,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(l);a.position.copy(u),a.lookAt(r),a.computePose(0),this.five.setState(Object.assign({},a.pose)),this.five.needsRender=!0,i>=1&&(o.aggregationEnabled=!1,o.aggregationProgress=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),n())})})})}};e.BackgroundPlugin=c,Object.defineProperty(e,"BasePlugin",{enumerable:!0,get:function(){return o}}),e.CSS2DPlugin=Vw,e.CSS3DPlugin=Qw,e.FloorplanPlugin=fE,e.GaussianSplattingEntranceAnimationPlugin=(e,t)=>new mE(e,t),e.Object3DHelperController=uw,e.Object3DHelperPlugin=dw,e.PanoAnimePlugin=kw});
|