@realsee/five 6.8.0-alpha.9 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS_READ_ME.md +6 -1
- package/AI_CONTEXT.md +6 -1
- package/README.md +10 -3
- package/ai_guides/README.md +29 -0
- package/ai_guides/api.md +92 -21
- package/ai_guides/features/3dtile.md +1 -1
- package/ai_guides/features/camera-animation.md +18 -1
- package/ai_guides/features/clipper.md +2 -2
- package/ai_guides/features/coordinate-system.md +20 -2
- package/ai_guides/features/event.md +106 -10
- package/ai_guides/features/five.md +17 -17
- package/ai_guides/features/flowing-light-2d-pass.md +11 -7
- package/ai_guides/features/flowing-light-3d-pass.md +12 -7
- package/ai_guides/features/gaussian-blur-pass.md +1 -1
- package/ai_guides/features/gesture.md +2 -1
- package/ai_guides/features/get-screen-pixels.md +2 -2
- package/ai_guides/features/image-options.md +2 -2
- package/ai_guides/features/load-external-model.md +6 -2
- package/ai_guides/features/load-progress.md +1 -1
- package/ai_guides/features/material.md +20 -12
- package/ai_guides/features/mode.md +1 -1
- package/ai_guides/features/model.md +1 -1
- package/ai_guides/features/move-pano-effect.md +1 -1
- package/ai_guides/features/multi-work.md +1 -1
- package/ai_guides/features/pano-filter.md +149 -0
- package/ai_guides/features/pano-tile.md +1 -1
- package/ai_guides/features/pano-uv.md +1 -1
- package/ai_guides/features/parameter.md +26 -2
- package/ai_guides/features/plugin.md +1 -1
- package/ai_guides/features/postprocessing.md +1 -1
- package/ai_guides/features/raycast.md +5 -2
- package/ai_guides/features/request-proxy.md +1 -1
- package/ai_guides/features/screen-project.md +2 -1
- package/ai_guides/features/state.md +23 -3
- package/ai_guides/features/view-layer.md +1 -1
- package/ai_guides/features/work.md +1 -1
- package/ai_guides/glossary.md +4 -4
- package/ai_guides/release_notes/6.8.md +190 -58
- package/ai_guides/template.md +11 -0
- package/docs/00_FOR_AI_AGENTS.md +3 -2
- package/docs/README.md +3 -2
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/main.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/five.AdaptiveLuminancePass.html +7 -6
- package/docs/classes/five.AnimationFrameLoop.html +1 -1
- package/docs/classes/five.BoundingMesh.html +2 -2
- package/docs/classes/five.Camera.html +3 -3
- package/docs/classes/five.EyeDomeLightingPass.html +1 -1
- package/docs/classes/five.Five.html +77 -76
- package/docs/classes/five.FivePass.html +1 -1
- package/docs/classes/five.Histogram.html +19 -0
- package/docs/classes/five.InternalWebGLRenderer.html +1 -1
- package/docs/classes/five.Model.html +8 -8
- package/docs/classes/five.ModelScene.html +1 -1
- package/docs/classes/five.NetworkSubscribe.html +5 -5
- package/docs/classes/five.PBMContainer.html +1 -1
- package/docs/classes/five.PBMCustomShader.html +42 -3
- package/docs/classes/five.PBMGSObject.html +5 -3
- package/docs/classes/five.PBMGroup.html +1 -1
- package/docs/classes/five.PBMMesh.html +1 -1
- package/docs/classes/five.PBMMeshMaterial.html +7 -7
- package/docs/classes/five.PBMPanoFilter.html +61 -0
- package/docs/classes/five.PBMPointCloud.html +1 -1
- package/docs/classes/five.PBMPointCloudMaterial.html +5 -6
- package/docs/classes/five.PBMSkinnedMesh.html +1 -1
- package/docs/classes/five.PBMUpdateable.html +41 -0
- package/docs/classes/five.PanoCircleMesh.html +1 -1
- package/docs/classes/five.PanoCircleMeshCustom.html +1 -1
- package/docs/classes/five.PanoCircleMeshSolid.html +1 -1
- package/docs/classes/five.Parameter.html +57 -55
- package/docs/classes/five.Scene.html +1 -1
- package/docs/classes/five.Subscribe.html +5 -5
- package/docs/classes/five.Tile.html +1 -1
- package/docs/classes/five.Tile3D.html +24 -24
- package/docs/classes/five.TileNode.html +1 -1
- package/docs/classes/five.Tileset.html +3 -2
- package/docs/classes/five.TrajectoryNode.html +1 -1
- package/docs/classes/five.Work.html +16 -16
- package/docs/classes/five.WorkResolvedObserver.html +22 -22
- package/docs/classes/gltf-loader.DDSLoader.html +1 -1
- package/docs/classes/gltf-loader.DRACOLoader.html +1 -1
- package/docs/classes/gltf-loader.GLTFLoader.html +2 -2
- package/docs/classes/gltf-loader.GLTFObject.html +1 -1
- package/docs/classes/gltf-loader.GLTFParser.html +1 -1
- package/docs/classes/gltf-loader.THREEGLTFLoader.html +2 -2
- package/docs/classes/line.Line.html +1 -1
- package/docs/classes/line.LineGeometry.html +1 -1
- package/docs/classes/line.LineMaterial.html +1 -1
- package/docs/classes/line.LineSegmentsGeometry.html +1 -1
- package/docs/classes/line.THREE_Line2.html +1 -1
- package/docs/classes/line.THREE_LineSegments2.html +1 -1
- package/docs/classes/plugins.BasePlugin.Controller.html +1 -1
- package/docs/classes/plugins.CSS3DObject.html +9 -0
- package/docs/classes/plugins.CSS3DRenderer.html +4 -2
- package/docs/classes/plugins.CSS3DSprite.html +11 -0
- package/docs/classes/plugins.Object3DHelperController.html +43 -0
- package/docs/classes/plugins.RoundedBoxGeometry.html +1 -1
- package/docs/classes/sticker.Sticker.html +1 -1
- package/docs/classes/vfx.Airflow.html +1 -1
- package/docs/classes/vfx.Flame.html +1 -1
- package/docs/classes/vfx.Particle.html +6 -6
- package/docs/classes/vfx.ParticleGPU.html +3 -3
- package/docs/classes/vfx.SpotLight.html +1 -1
- package/docs/documents/README.html +122 -1
- package/docs/documents/api.html +163 -35
- package/docs/documents/features_3dtile.html +1 -1
- package/docs/documents/features_camera-animation.html +18 -2
- package/docs/documents/features_clipper.html +2 -2
- package/docs/documents/features_coordinate-system.html +52 -3
- package/docs/documents/features_event.html +44 -8
- package/docs/documents/features_five.html +17 -17
- package/docs/documents/features_flowing-light-2d-pass.html +19 -116
- package/docs/documents/features_flowing-light-3d-pass.html +22 -124
- package/docs/documents/features_gaussian-blur-pass.html +6 -6
- package/docs/documents/features_gesture.html +2 -1
- package/docs/documents/features_get-screen-pixels.html +2 -2
- package/docs/documents/features_image-options.html +2 -2
- package/docs/documents/features_load-external-model.html +6 -2
- package/docs/documents/features_load-progress.html +1 -1
- package/docs/documents/features_material.html +11 -4
- package/docs/documents/features_mode.html +1 -1
- package/docs/documents/features_model.html +1 -1
- package/docs/documents/features_move-pano-effect.html +1 -1
- package/docs/documents/features_multi-work.html +1 -1
- package/docs/documents/features_pano-filter.html +123 -0
- package/docs/documents/features_pano-tile.html +1 -1
- package/docs/documents/features_pano-uv.html +1 -1
- package/docs/documents/features_parameter.html +11 -3
- package/docs/documents/features_plugin.html +1 -1
- package/docs/documents/features_postprocessing.html +1 -1
- package/docs/documents/features_raycast.html +5 -2
- package/docs/documents/features_request-proxy.html +1 -1
- package/docs/documents/features_screen-project.html +2 -1
- package/docs/documents/features_state.html +9 -2
- package/docs/documents/features_view-layer.html +1 -1
- package/docs/documents/features_work.html +1 -1
- package/docs/documents/glossary.html +5 -5
- package/docs/documents/release_notes_6.8.html +164 -64
- package/docs/documents/template.html +9 -0
- package/docs/functions/five.createDebugBoundingMesh.html +1 -1
- package/docs/functions/five.parseWork.html +1 -1
- package/docs/functions/plugins.CSS3DPlugin.html +1 -0
- package/docs/functions/plugins.GaussianSplattingEntranceAnimationPlugin.html +1 -0
- package/docs/functions/plugins.Object3DHelperPlugin.html +1 -0
- package/docs/functions/react.useFiveCurrentObserver.html +2 -2
- package/docs/functions/react.useFiveFloor.html +2 -2
- package/docs/functions/react.useFiveProject2d.html +2 -2
- package/docs/functions/vue.useFiveCurrentObserver.html +2 -2
- package/docs/functions/vue.useFiveFloor.html +2 -2
- package/docs/functions/vue.useFiveWorks.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +122 -1
- package/docs/interfaces/five.AddableObject.html +1 -1
- package/docs/interfaces/five.AjaxOptions.html +1 -1
- package/docs/interfaces/five.BaseEvent.html +7 -2
- package/docs/interfaces/five.BaseExtendableEvent.html +11 -0
- package/docs/interfaces/five.EventCallback.html +58 -54
- package/docs/interfaces/five.FiveInitArgs.html +2 -2
- package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +9 -9
- package/docs/interfaces/five.GestureEvent.html +21 -2
- package/docs/interfaces/five.GesturePointer.html +20 -0
- package/docs/interfaces/five.ImageOptions.html +1 -1
- package/docs/interfaces/five.IntersectEvent.html +10 -2
- package/docs/interfaces/five.IntersectMesh.html +1 -1
- package/docs/interfaces/five.IntersectMeshInterface.html +1 -1
- package/docs/interfaces/five.Intersection.html +1 -1
- package/docs/interfaces/five.LooseWorkObserver.html +2 -2
- package/docs/interfaces/five.LooseWorkPanorama.html +2 -2
- package/docs/interfaces/five.LooseWorkWithExtrinsics.html +6 -6
- package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +10 -10
- package/docs/interfaces/five.ModeChangeEvent.html +9 -2
- package/docs/interfaces/five.ModelControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ModelEvent.html +7 -2
- package/docs/interfaces/five.ModelSceneEvent.html +7 -2
- package/docs/interfaces/five.ModelTileEvent.html +7 -2
- package/docs/interfaces/five.MovePanoOptions.html +8 -8
- package/docs/interfaces/five.NetworkAbortError.html +1 -1
- package/docs/interfaces/five.NetworkFirbiddenError.html +1 -1
- package/docs/interfaces/five.NetworkOptions.html +1 -1
- package/docs/interfaces/five.NetworkProxyError.html +1 -1
- package/docs/interfaces/five.NetworkResourceEvent.html +7 -2
- package/docs/interfaces/five.NetworkResponseError.html +1 -1
- package/docs/interfaces/five.NetworkTimeoutError.html +1 -1
- package/docs/interfaces/five.ObjectEvent.html +7 -2
- package/docs/interfaces/five.PBMClipperParameter.html +2 -2
- package/docs/interfaces/five.PBMCustomShaderInitArgs.html +2 -2
- package/docs/interfaces/five.PBMCustomShaderSlots.html +2 -2
- package/docs/interfaces/five.PBMMaterial.html +1 -1
- package/docs/interfaces/five.PBMMeshMaterialParameters.html +5 -3
- package/docs/interfaces/five.PBMPanoDepth.html +5 -5
- package/docs/interfaces/five.PBMPanoFilterValue.html +6 -0
- package/docs/interfaces/five.PBMPanoPicture.html +8 -6
- package/docs/interfaces/five.PBMPointCloudMaterialParameters.html +2 -3
- package/docs/interfaces/five.PBMRefinedScreen.html +2 -2
- package/docs/interfaces/five.PanoCircleMeshInterface.html +2 -2
- package/docs/interfaces/five.PanoEvent.html +15 -2
- package/docs/interfaces/five.PanoPrepareEvent.html +15 -0
- package/docs/interfaces/five.PanoTextureEvent.html +11 -2
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ParameterMaterialValue.html +40 -38
- package/docs/interfaces/five.ParameterTilesetValue.html +15 -15
- package/docs/interfaces/five.ParameterValue.html +54 -52
- package/docs/interfaces/five.Pose.html +1 -1
- package/docs/interfaces/five.RenderEvent.html +7 -2
- package/docs/interfaces/five.ResolvedParameterValue.html +55 -54
- package/docs/interfaces/five.RgbaData.html +7 -0
- package/docs/interfaces/five.SplatData.html +2 -2
- package/docs/interfaces/five.State.html +1 -1
- package/docs/interfaces/five.StateEvent.html +9 -2
- package/docs/interfaces/five.TextureOptions.html +1 -1
- package/docs/interfaces/five.Tile3DOptions.html +2 -2
- package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +7 -7
- package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ViewLayer.html +24 -24
- package/docs/interfaces/five.WorkCubeImage.html +3 -2
- package/docs/interfaces/five.WorkImage.html +6 -5
- package/docs/interfaces/five.WorkInitial.html +8 -8
- package/docs/interfaces/five.WorkModel.html +8 -8
- package/docs/interfaces/five.WorkModelLayer.html +6 -6
- package/docs/interfaces/five.WorkObserver.html +29 -29
- package/docs/interfaces/five.WorkObserverJson.html +2 -2
- package/docs/interfaces/five.WorkObserverProto.html +26 -0
- package/docs/interfaces/five.WorkPanoramaJson.html +2 -2
- package/docs/interfaces/five.WorkTile.html +6 -5
- package/docs/interfaces/five.WorkVideo.html +4 -4
- package/docs/interfaces/five.WorksEvent.html +7 -2
- package/docs/interfaces/five.XRControllerEvent.html +10 -2
- package/docs/interfaces/five.XRControllerState.html +8 -0
- package/docs/interfaces/five.XRGestureEvent.html +13 -2
- package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.XRSessionEvent.html +9 -2
- package/docs/interfaces/plugins.BackgroundPluginController.html +1 -1
- package/docs/interfaces/plugins.BackgroundPluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.BasePlugin.State.html +1 -1
- package/docs/interfaces/plugins.CSS3DPluginController.html +52 -0
- package/docs/interfaces/plugins.CSS3DPluginType.Config.html +2 -0
- package/docs/interfaces/plugins.CSS3DPluginType.CreateCSS3DObjectType.html +10 -0
- package/docs/interfaces/plugins.CSS3DPluginType.EventMap.html +10 -0
- package/docs/interfaces/plugins.CSS3DPluginType.Params.html +4 -0
- package/docs/interfaces/plugins.CSS3DPluginType.State.html +8 -0
- package/docs/interfaces/plugins.CSS3DRendererParameters.html +2 -0
- package/docs/interfaces/plugins.DynamicPathLinePluginController.html +3 -3
- package/docs/interfaces/plugins.DynamicPathLinePluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.DynamicPathLinePluginType.State.html +1 -1
- package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationController.html +44 -0
- package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.BoundingAABB2D.html +3 -0
- package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.Config.html +8 -0
- package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.EventMap.html +10 -0
- package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.Keyframe.html +3 -0
- package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.State.html +8 -0
- package/docs/interfaces/plugins.ItemMaskController.html +1 -1
- package/docs/interfaces/plugins.ItemMaskPluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.ItemMaskPluginType.State.html +2 -2
- package/docs/interfaces/plugins.Object3DHelperPluginType.BaseController.html +30 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.BaseHelper.html +22 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.BoundingBoxController.html +30 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.HelperOffset.html +4 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.MoveController.html +36 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.MoveHelperAbstract.html +32 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.Object3DHelper.html +12 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.Object3DHelperPluginState.html +4 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.Object3DHelperState.html +4 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.ObjectHelperControllers.html +4 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.RotateController.html +36 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.RotateHelperAbstract.html +28 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.Scissor.html +5 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.Vector2Position.html +3 -0
- package/docs/interfaces/plugins.Object3DHelperPluginType.Vector3Position.html +4 -0
- package/docs/interfaces/plugins.OrientationPluginController.html +6 -6
- package/docs/interfaces/plugins.OrientationPluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.OrientationPluginType.State.html +1 -1
- package/docs/interfaces/plugins.PanoAnimeController.html +1 -1
- package/docs/interfaces/plugins.PanoAnimePluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.PanoAnimePluginType.State.html +1 -1
- package/docs/interfaces/plugins.PlayingState.html +2 -2
- package/docs/interfaces/plugins.PluginTemplateType.EventMap.html +1 -1
- package/docs/interfaces/plugins.PluginTemplateType.State.html +1 -1
- package/docs/interfaces/plugins.TrajectoryController.html +8 -8
- package/docs/interfaces/react.FiveInjectionTypes.html +21 -21
- package/docs/interfaces/sticker.IntersectionLike.html +2 -2
- package/docs/interfaces/vfx.ParticleArgs.html +4 -4
- package/docs/interfaces/vue.FiveActionVueCallbacks.html +3 -3
- package/docs/modules/five.html +1 -1
- package/docs/modules/plugins.CSS3DPluginType.html +1 -0
- package/docs/modules/plugins.GaussianSplattingEntranceAnimationPluginType.html +1 -0
- package/docs/modules/plugins.Object3DHelperPluginType.html +1 -0
- package/docs/modules/plugins.html +1 -1
- package/docs/modules.html +1 -1
- package/docs/types/five.ControllerEventTypes.html +30 -26
- package/docs/types/five.EasingFunction.html +1 -0
- package/docs/types/five.EventTypes.html +26 -26
- package/docs/types/five.LegacyEventType.html +7 -7
- package/docs/types/five.PBMAlphaMode.html +1 -1
- package/docs/types/five.PBMColorStyle.html +1 -1
- package/docs/types/five.PBMFloorStyle.html +1 -1
- package/docs/types/five.PBMMeshShaderType.html +1 -1
- package/docs/types/five.PBMPointBack.html +1 -1
- package/docs/types/five.PBMPointCloudShaderType.html +1 -1
- package/docs/types/five.PBMPointShape.html +1 -1
- package/docs/types/five.PBMPointSize.html +1 -1
- package/docs/types/five.PBMTransition.html +1 -1
- package/docs/types/five.ParseOptions.html +6 -6
- package/docs/types/five.Works.html +1 -1
- package/docs/types/plugins.BasePlugin.EventMap.html +1 -1
- package/docs/types/plugins.CSS3DPluginType.PluginData.html +1 -0
- package/docs/types/plugins.CSS3DPluginType.ServerData.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.AddObject3DHelperConfig.html +13 -0
- package/docs/types/plugins.Object3DHelperPluginType.Circle.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.Color.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.Direction.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.Direction4.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.HelperConfig.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.HelperEventMap.html +17 -0
- package/docs/types/plugins.Object3DHelperPluginType.InternalHelperEventMap.html +8 -0
- package/docs/types/plugins.Object3DHelperPluginType.Object3DHelperEventMap.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.Object3DHelperPluginEventMap.html +7 -0
- package/docs/types/plugins.Object3DHelperPluginType.PositionFrom.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.ScaleCallback.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.ScalePosition.html +4 -0
- package/docs/types/plugins.Object3DHelperPluginType.UseFaceNormalInterface.html +4 -0
- package/docs/types/plugins.Object3DHelperPluginType.Vector2WithArray.html +1 -0
- package/docs/types/plugins.Object3DHelperPluginType.Vector3WithArray.html +1 -0
- package/docs/variables/five.PROXY_CONTROLLER_EVENT_NAMES.html +1 -1
- package/five/application/events.d.ts +1 -1
- package/five/application/five.d.ts +6 -5
- package/five/bvh/bvhObject.d.ts +2 -2
- package/five/controllers/base.d.ts +1 -0
- package/five/controllers/events.d.ts +5 -1
- package/five/controllers/mapview.d.ts +1 -0
- package/five/controllers/model.d.ts +2 -2
- package/five/controllers/panorama.d.ts +3 -2
- package/five/controllers/xrPanorama.d.ts +1 -1
- package/five/core/camera.d.ts +1 -1
- package/five/gaussian-splatting/util/renderData.d.ts +66 -0
- package/five/index.d.ts +4 -1
- package/five/index.js +272 -782
- package/five/index.mjs +26894 -32056
- package/five/meshes/boundingMesh.d.ts +1 -0
- package/five/model/index.d.ts +2 -2
- package/five/model/loaders/glTF-helpers/extensions/KHR_binary_glTF.d.ts +1 -1
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting.d.ts +26 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz.d.ts +7 -5
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz_2.d.ts +13 -0
- package/five/model/loaders/glTF-helpers/extensions/base.d.ts +2 -1
- package/five/model/loaders/glTF-helpers/index.d.ts +4 -0
- package/five/model/loaders/glTF-helpers/parser.d.ts +2 -1
- package/five/model/loaders/spz.d.ts +2 -2
- package/five/model/materials/pbmMaterial.d.ts +54 -4
- package/five/model/materials/pbmMeshMaterial.d.ts +5 -3
- package/five/model/materials/pbmPointCloudMaterial.d.ts +0 -2
- package/five/model/objects/{pbmGSObject.d.ts → pbmGaussianSplattingObject.d.ts} +4 -1
- package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +59 -0
- package/five/model/objects/pbmGaussianSplattingTestMesh.d.ts +7 -0
- package/five/model/parameter.d.ts +11 -6
- package/five/model/tile3d/index.d.ts +5 -3
- package/five/model/tile3d/tile-node.d.ts +2 -2
- package/five/model/tile3d/tileset.d.ts +1 -0
- package/five/renderer/postprocessing/passes/adaptive-luminance-pass.d.ts +9 -7
- package/five/renderer/tools/render-cube-to-equirectangular.d.ts +7 -0
- package/five/renderer/tools/render-full-screen.d.ts +1 -1
- package/five/texture/histogram.d.ts +54 -0
- package/five/texture/loader.d.ts +1 -1
- package/five/texture/textureData.d.ts +11 -0
- package/five/thirdparty/hammer.d.ts +371 -255
- package/five/thirdparty/jsrsasign.d.ts +5 -20
- package/five/types/movePanoOptions.d.ts +4 -3
- package/five/utils/error.d.ts +1 -0
- package/five/utils/event.d.ts +98 -37
- package/five/utils/imageURL.d.ts +1 -1
- package/five/utils/memoryUsage.d.ts +2 -2
- package/five/utils/subscribe.d.ts +2 -2
- package/five/webxr/motionHelper.d.ts +1 -1
- package/five/work/index.d.ts +1 -0
- package/five/work/looseWorkType.d.ts +2 -2
- package/five/work/work.d.ts +5 -35
- package/five/work/workJsonType.d.ts +2 -2
- package/five/work/workObserverProto.d.ts +39 -0
- package/gltf-loader/index.js +9 -9
- package/gltf-loader/index.mjs +1351 -1451
- package/line/index.js +4 -4
- package/line/index.mjs +334 -513
- package/llms.txt +37 -1
- package/package.json +4 -4
- package/plugins/CSS3DPlugin/Controller.d.ts +64 -0
- package/plugins/CSS3DPlugin/index.d.ts +5 -0
- package/plugins/CSS3DPlugin/typing.d.ts +32 -0
- package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.d.ts +30 -0
- package/plugins/GaussianSplattingEntranceAnimationPlugin/index.d.ts +5 -0
- package/plugins/GaussianSplattingEntranceAnimationPlugin/typing.d.ts +28 -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 +2 -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/TrajectoryPlugin/Controller.d.ts +1 -1
- package/plugins/index.d.ts +4 -1
- package/plugins/index.js +35 -21
- package/plugins/index.mjs +5418 -4238
- package/plugins/thirdParty/CSS3DRenderer.d.ts +16 -3
- package/plugins/thirdParty/domevents.d.ts +36 -0
- package/plugins/utils/uuid.d.ts +1 -4
- package/react/context.d.ts +3 -2
- package/react/createProvider.d.ts +4 -4
- package/react/createStore.d.ts +3 -3
- package/react/hooks/useFiveProject2d.d.ts +1 -1
- package/react/index.js +3 -3
- package/react/index.mjs +572 -783
- package/react/rendererPool.d.ts +2 -2
- package/shader-lib/index.js +13 -14
- package/shader-lib/index.mjs +424 -824
- package/sticker/index.js +3 -3
- package/sticker/index.mjs +102 -142
- package/umd/five-gltf-loader.js +9 -9
- package/umd/five-line.js +4 -4
- package/umd/five-plugins.js +35 -21
- package/umd/five-react.js +3 -3
- package/umd/five-shader-lib.js +13 -14
- package/umd/five-sticker.js +3 -3
- package/umd/five-vfx.js +21 -21
- package/umd/five-vue.js +3 -3
- package/umd/five.js +267 -777
- package/vfx/index.js +21 -21
- package/vfx/index.mjs +454 -910
- package/vue/index.js +3 -3
- package/vue/index.mjs +309 -301
- package/vue/rendererPool.d.ts +5 -5
- package/work-downloader/index.js +3 -3
- package/work-downloader/index.mjs +339 -556
- package/five/gs/util/renderData.d.ts +0 -32
- package/five/model/objects/pbmGSRenderMesh.d.ts +0 -29
- package/five/work/workObserverUtils.d.ts +0 -36
- /package/five/assets/{realsee-pmg-data-url.d.ts → realsee-png-data-url.d.ts} +0 -0
- /package/five/{gs → gaussian-splatting}/wasm/data.d.ts +0 -0
- /package/five/{gs → gaussian-splatting}/wasm/sort.d.ts +0 -0
- /package/five/{gs → gaussian-splatting}/worker/dataWorker.d.ts +0 -0
- /package/five/{gs → gaussian-splatting}/worker/sortWorker.d.ts +0 -0
package/plugins/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.8.0
|
|
4
|
+
* Generated: 4/17/2026
|
|
5
|
+
* Version: 6.8.0
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -252,13 +252,13 @@
|
|
|
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
|
-
*/
|
|
255
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@realsee/five`),l=require(`three`);l=s(l);let u=require(`@realsee/five/plugins`);function d(e){return/^https?:\/\/|^\/\//.test(e)||/^data:/.test(e)}function f(e,t){return d(t)?t:`${e}${t}`}var p;(function(e){class t{constructor(e,t){this.hooks=new c.Subscribe,this.staticPrefix=`//vr-image-4.realsee-cdn.cn`,this.five=e,t!=null&&t.staticPrefix&&(this.staticPrefix=t.staticPrefix)}getCurrentState(){return this.state}absoluteUrl(e){return f(this.staticPrefix,e)}}e.Controller=t})(p||(p={}));function m(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 h(e){return new Promise((t,n)=>{let r=new Image;r.onload=function(){r.onload=r.onerror=function(){},t(r)},r.onerror=function(e){r.onload=r.onerror=function(){},n(e)},r.crossOrigin=``,r.src=e})}var g=typeof performance<`u`&&performance.timing!==void 0?performance.timing.navigationStart:Date.now(),_=typeof performance<`u`?(()=>g+performance.now()):(()=>Date.now());function v(e,t,n){return e+(t-e)*n}function y(e,t,n,r){let i=(t*n+2*e)/Math.pow(n,3),a=-(2*t*n+3*e)/Math.pow(n,2),o=t,s=e;return i*Math.pow(r,3)+a*Math.pow(r,2)+o*r+s}function b(e,t,n,r){let i=(t*n+2*e)/Math.pow(n,3),a=-(2*t*n+3*e)/Math.pow(n,2),o=t;return 3*i*Math.pow(r,2)+2*a*r+o}function x(e,t,n,r){let i=r[1]-r[0];return e=S(e,r),t=S(t,r),t-e>i/2?v(e+i,t,n):e-t>i/2?v(e-i,t,n):v(e,t,n)}function S(e,t){let n=t[1]-t[0];return e<t[0]?S(e+n,t):e>=t[1]?S(e-n,t):e}function C(e,t,n,r){return r?x(e,t,n,r):v(e,t,n)}var w=class{constructor(e){this.config={},this.progress=1,this.ended=!0,this.value={},this.startTime=_(),this.startVelocity=0,this.duration=0,this.keyframes=[];for(let t in e){let n=e[t];typeof n==`number`?(this.value[t]=n,this.config[t]={circle:!1}):(this.value[t]=n.value,this.config[t]={circle:n.circle})}this.keyframes=[{progress:0,value:Object.assign({},this.value)},{progress:1,value:Object.assign({},this.value)}]}getProgress(e){let t=e-this.startTime;return t<0?0:t>=this.duration?1:1-y(1,this.startVelocity,this.duration,t)}getValue(e){for(let t=1;t<this.keyframes.length;t++)if(this.keyframes[t].progress>e){let n=this.keyframes[t-1],r=this.keyframes[t],i={};for(let t in this.config){let a=(e-n.progress)/(r.progress-n.progress);i[t]=C(n.value[t],r.value[t],a,this.config[t].circle)}return i}return Object.assign({},this.keyframes[this.keyframes.length-1].value)}getProgressVelocity(e){let t=e-this.startTime;return t>=this.duration?0:b(1,this.startVelocity,this.duration,t)}update(e){return this.ended?!0:(this.progress=Math.min(1,Math.max(0,this.progress,this.getProgress(e))),this.value=this.getValue(this.progress),this.ended=this.progress>=1,this.ended&&this.callbacks&&(this.callbacks[0](),this.callbacks=void 0),this.ended)}getKeyFrameSegment(e){let t=this.getProgress(e);for(let e=1;e<this.keyframes.length;e++)if(this.keyframes[e].progress>t)return[this.keyframes[e-1],this.keyframes[e]];return[this.keyframes[this.keyframes.length-2],this.keyframes[this.keyframes.length-1]]}getTargetKeyframe(){return this.keyframes[this.keyframes.length-1]}set(e,t,n=0,r){var i;isNaN(t)&&(t=0),isNaN(n)&&(n=0),r=r==null?_():r;let a=this.getProgress(r),o=this.getValue(a),s={};for(let t in this.config)s[t]=(i=e[t])==null?o[t]:i;let c=[{progress:0,value:o},{progress:1,value:s}];return this.setKeyframes(c,t,n,r)}setKeyframes(e,t,n=0,r){if(e.length<2)throw Error(`keyframes invalid.`);return isNaN(t)&&(t=0),isNaN(n)&&(n=0),this.callbacks&&(this.callbacks[1](Error(`motion aborted.`)),this.callbacks=void 0),new Promise((i,a)=>{r=r==null?_():r,this.progress=0,this.ended=!1,this.startTime=r,this.startVelocity=n,this.keyframes=e,this.duration=t,t===0?(this.progress=1,this.value=Object.assign({},e[e.length-1].value)):this.value=Object.assign({},e[0].value),this.callbacks=[i,a]})}dispose(){this.callbacks&&(this.callbacks[1](Error(`motion dispose.`)),this.callbacks=void 0)}},T=[{progress:0,value:{scale:0,opacity:0,shadow:2}},{progress:.2,value:{scale:.5,opacity:1,shadow:1}},{progress:.8,value:{scale:2,opacity:0,shadow:.5}},{progress:1,value:{scale:2,opacity:0,shadow:.5}}],E=[{progress:0,value:{scale:0,opacity:0,shadow:2}},{progress:.2,value:{scale:.4,opacity:1,shadow:2}},{progress:.8,value:{scale:1.6,opacity:.4,shadow:.5}},{progress:1,value:{scale:2,opacity:0,shadow:.5}}],D=`
|
|
256
256
|
varying vec2 vUv;
|
|
257
257
|
void main() {
|
|
258
258
|
vUv = uv;
|
|
259
259
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
260
260
|
}
|
|
261
|
-
`,
|
|
261
|
+
`,O=`
|
|
262
262
|
varying vec2 vUv;
|
|
263
263
|
uniform sampler2D map;
|
|
264
264
|
uniform vec4 color;
|
|
@@ -304,7 +304,7 @@ void main() {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
`,
|
|
307
|
+
`,k=class extends p.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})}constructor(e,t){super(e),this.canvas=document.createElement(`canvas`),this.group=new l.Group,this.wrapper=document.createElement(`div`),this.style=document.createElement(`style`),this.itemMaskMesh=(()=>{let e=new l.Mesh(new l.SphereBufferGeometry(1,60,40),new l.ShaderMaterial({vertexShader:D,fragmentShader:O,uniforms:{map:{value:new l.Texture},color:{value:new l.Vector4}},depthWrite:!1,depthTest:!1,transparent:!0}));return e.renderOrder=-3,e.geometry.rotateY(-Math.PI/2),e.geometry.scale(-1,1,1),e})(),this.onFivePanoArrived=e=>{this.state.mode===`mask`&&this.loadPanoMask(e)},this.onFiveWantsMoveToPano=e=>{this.state.mode===`box`&&this.select()},this.loadPanoMask=e=>m(this,void 0,void 0,function*(){var t;let{five:n,canvas:r,itemMaskMesh:i,data:a}=this,o=r.getContext(`2d`),s=n.observers[e],c=(t=a==null?void 0:a.object_mask_list.find(e=>e.derived_id===String(s.derivedId)))==null?void 0:t.object_mask_url;if(!c)return;let u=yield h(c);r.width=u.width,r.height=u.height,o==null||o.drawImage(u,0,0,u.width,u.height),i.material.uniforms.map.value.image=u,i.material.uniforms.map.value.minFilter=l.LinearFilter,i.material.uniforms.map.value.needsUpdate=!0,i.position.copy(s.position),i.quaternion.copy(s.quaternion),n.scene.add(i),n.needsRender=!0}),this.onFiveMouseMove=e=>{var t;if(this.state.mode!==`mask`||this.five.state.mode!==`Panorama`)return;let{five:n,itemMaskMesh:r}=this,i=n.observers[n.state.panoIndex],a=(t=e.pointers[0])==null?void 0:t.raycaster;if(a){let[e]=a.intersectObjects(this.group.children.filter(e=>e.userData.visible_viewpoint.includes(String(i.derivedId))),!0);e?r.material.uniforms.color.value=e.object.userData.color:r.material.uniforms.color.value=new l.Vector4(0,0,0,1)}},this.onFiveTapGesture=e=>{let{five:t}=this,n=t.observers[t.state.panoIndex];if(e){let[r]=e.intersectObjects(this.group.children.filter(e=>e.userData.visible_viewpoint.includes(String(n.derivedId))),!0);if(r){this.select(r.object.name),this.stopAnimation&&this.stopAnimation(),this.tapPosition=r.point,this.changeTapScreenPosition();let e=new w({opacity:0,scale:0,shadow:2}),n=new w({opacity:0,scale:0,shadow:2});return e.setKeyframes(T,1e3),n.setKeyframes(E,1e3),this.stopAnimation=c.AnimationFrameLoop.shared.add((r,i,...a)=>{var o;let s=e.update(r),c=n.update(r);this.wrapper.firstChild.style.opacity=`${e.value.opacity}`,this.wrapper.firstChild.style.transform=`scale(${e.value.scale})`,this.wrapper.firstChild.style.boxShadow=`0 0 0 ${e.value.shadow}px #fff`,this.wrapper.lastChild.style.opacity=`${n.value.opacity}`,this.wrapper.lastChild.style.transform=`scale(${n.value.scale})`,this.wrapper.lastChild.style.boxShadow=`0 0 0 ${n.value.shadow}px #fff`,s&&c&&((o=this.stopAnimation)==null||o.call(this),this.stopAnimation=void 0,t.getElement().parentElement.removeChild(this.wrapper))},!1,0,10),t.getElement().parentElement.appendChild(this.wrapper),!1}}},this.changeTapScreenPosition=()=>{if(!this.tapPosition)return;let e=this.tapPosition.clone().project(this.five.camera),t=(e.x+1)/2,n=-(e.y-1)/2;this.wrapper.style.opacity=e.z>0&&e.z<1?`1`:`0`,this.wrapper.style.transform=`translate(${t*100}%, ${n*100}%)`},this.onFiveCameraUpdate=e=>{this.changeTapScreenPosition()},this.dispose=()=>{this.disable()},this.five=e,this.state=Object.assign({enabled:!0,visible:!0,mode:`box`,selectedId:null,selectAll:!1},t==null?void 0:t.initialState),this._config=Object.assign({},t==null?void 0:t.config),this.group.rotateX(Math.PI),this.wrapper.className=`ItemMaskPlugin`,this.wrapper.innerHTML=`<span class="ItemMaskPluginCircle"></span><span class="ItemMaskPluginCircle"></span>`,this.style.innerHTML=`
|
|
308
308
|
.ItemMaskPlugin {
|
|
309
309
|
position: absolute;
|
|
310
310
|
top: 0;
|
|
@@ -322,7 +322,7 @@ void main() {
|
|
|
322
322
|
border-radius: 50%;
|
|
323
323
|
box-shadow: 0px 0px 0px 2px #fff;
|
|
324
324
|
}
|
|
325
|
-
`,
|
|
325
|
+
`,this.state.enabled&&this._enable({userAction:!1})}load(e){return m(this,void 0,void 0,function*(){this.data=e;let t=e.data_list.map(e=>{let t=e.position.end.map(e=>Number(e)),n=e.position.start.map(e=>Number(e)),r=Math.abs(t[0]-n[0]),i=Math.abs(t[1]-n[1]),a=Math.abs(t[2]-n[2]),o=t[0]/2+n[0]/2,s=t[1]/2+n[1]/2,c=t[2]/2+n[2]/2,u=new l.Vector3(o,s,c),d=new l.BoxBufferGeometry(r,i,a),f=new l.ShaderMaterial({vertexShader:`
|
|
326
326
|
varying vec2 vUv;
|
|
327
327
|
void main() {
|
|
328
328
|
vUv = uv;
|
|
@@ -347,13 +347,9 @@ void main() {
|
|
|
347
347
|
gl_FragColor = vec4(1.0, 1.0, 1.0, alpha / 4.0 * opacity);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
`,side:
|
|
351
|
-
|
|
352
|
-
*
|
|
353
|
-
* Copyright (c) 2016 Jorik Tangelder;
|
|
354
|
-
* Licensed under the MIT license */var yt=(function(v,s,e,n){var t=["","webkit","Moz","MS","ms","o"],r=s.createElement?s.createElement("div"):n,l="function",i=Math.round,h=Math.abs,c=Date.now;function d(a,o,u){return setTimeout(b(a,u),o)}function y(a,o,u){return Array.isArray(a)?(M(a,u[o],u),!0):!1}function M(a,o,u){var g;if(a)if(a.forEach)a.forEach(o,u);else if(a.length!==n)for(g=0;g<a.length;)o.call(u,a[g],g,a),g++;else for(g in a)a.hasOwnProperty(g)&&o.call(u,a[g],g,a)}function w(a,o,u){var g="DEPRECATED METHOD: "+o+`
|
|
355
|
-
`+u+` AT
|
|
356
|
-
`;return function(){var A=new Error("get-stack-trace"),_=A&&A.stack?A.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",V=v.console&&(v.console.warn||v.console.log);return V&&V.call(v.console,g,_),a.apply(this,arguments)}}var P;typeof Object.assign!="function"?P=function(o){if(o===n||o===null)throw new TypeError("Cannot convert undefined or null to object");for(var u=Object(o),g=1;g<arguments.length;g++){var A=arguments[g];if(A!==n&&A!==null)for(var _ in A)A.hasOwnProperty(_)&&(u[_]=A[_])}return u}:P=Object.assign;var S=w(function(o,u,g){for(var A=Object.keys(u),_=0;_<A.length;)(!g||g&&o[A[_]]===n)&&(o[A[_]]=u[A[_]]),_++;return o},"extend","Use `assign`."),O=w(function(o,u){return S(o,u,!0)},"merge","Use `assign`.");function E(a,o,u){var g=o.prototype,A;A=a.prototype=Object.create(g),A.constructor=a,A._super=g,u&&P(A,u)}function b(a,o){return function(){return a.apply(o,arguments)}}function T(a,o){return typeof a==l?a.apply(o&&o[0]||n,o):a}function f(a,o){return a===n?o:a}function C(a,o,u){M(Y(o),function(g){a.addEventListener(g,u,!1)})}function x(a,o,u){M(Y(o),function(g){a.removeEventListener(g,u,!1)})}function F(a,o){for(;a;){if(a==o)return!0;a=a.parentNode}return!1}function j(a,o){return a.indexOf(o)>-1}function Y(a){return a.trim().split(/\s+/g)}function H(a,o,u){if(a.indexOf&&!u)return a.indexOf(o);for(var g=0;g<a.length;){if(u&&a[g][u]==o||!u&&a[g]===o)return g;g++}return-1}function Z(a){return Array.prototype.slice.call(a,0)}function J(a,o,u){for(var g=[],A=[],_=0;_<a.length;){var V=a[_][o];H(A,V)<0&&g.push(a[_]),A[_]=V,_++}return g=g.sort(function(fe,ae){return fe[o]>ae[o]}),g}function R(a,o){for(var u,g,A=o[0].toUpperCase()+o.slice(1),_=0;_<t.length;){if(u=t[_],g=u?u+A:o,g in a)return g;_++}return n}var K=1;function L(){return K++}function k(a){var o=a.ownerDocument||a;return o.defaultView||o.parentWindow||v}var I=/mobile|tablet|ip(ad|hone|od)|android/i,N="ontouchstart"in v,W=R(v,"PointerEvent")!==n,ee=N&&I.test(navigator.userAgent),Q="touch",U="pen",re="mouse",q="kinect",X=25,z=1,le=2,$=4,te=8,xe=1,Pe=2,Ce=4,Oe=8,Me=16,ce=Pe|Ce,de=Oe|Me,Be=ce|de,Ue=["x","y"],_e=["clientX","clientY"];function ue(a,o){var u=this;this.manager=a,this.callback=o,this.element=a.element,this.target=a.options.inputTarget,this.domHandler=function(g){T(a.options.enable,[a])&&u.handler(g)},this.init()}ue.prototype={handler:function(){},init:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(k(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(k(this.element),this.evWin,this.domHandler)}};function We(a){var o,u=a.options.inputClass;return u?o=u:W?o=lt:ee?o=Ze:N?o=ut:o=qe,new o(a,Ke)}function Ke(a,o,u){var g=u.pointers.length,A=u.changedPointers.length,_=o&z&&g-A===0,V=o&($|te)&&g-A===0;u.isFirst=!!_,u.isFinal=!!V,_&&(a.session={}),u.eventType=o,m(a,u),a.emit("hammer.input",u),a.recognize(u),a.session.prevInput=u}function m(a,o){var u=a.session,g=o.pointers,A=g.length;u.firstInput||(u.firstInput=ie(o)),A>1&&!u.firstMultiple?u.firstMultiple=ie(o):A===1&&(u.firstMultiple=!1);var _=u.firstInput,V=u.firstMultiple,oe=V?V.center:_.center,fe=o.center=me(g);o.timeStamp=c(),o.deltaTime=o.timeStamp-_.timeStamp,o.angle=st(oe,fe),o.distance=Xe(oe,fe),G(u,o),o.offsetDirection=we(o.deltaX,o.deltaY);var ae=Ve(o.deltaTime,o.deltaX,o.deltaY);o.overallVelocityX=ae.x,o.overallVelocityY=ae.y,o.overallVelocity=h(ae.x)>h(ae.y)?ae.x:ae.y,o.scale=V?Jt(V.pointers,g):1,o.rotation=V?Qt(V.pointers,g):0,o.maxPointers=u.prevInput?o.pointers.length>u.prevInput.maxPointers?o.pointers.length:u.prevInput.maxPointers:o.pointers.length,ne(u,o);var ye=a.element;F(o.srcEvent.target,ye)&&(ye=o.srcEvent.target),o.target=ye}function G(a,o){var u=o.center,g=a.offsetDelta||{},A=a.prevDelta||{},_=a.prevInput||{};(o.eventType===z||_.eventType===$)&&(A=a.prevDelta={x:_.deltaX||0,y:_.deltaY||0},g=a.offsetDelta={x:u.x,y:u.y}),o.deltaX=A.x+(u.x-g.x),o.deltaY=A.y+(u.y-g.y)}function ne(a,o){var u=a.lastInterval||o,g=o.timeStamp-u.timeStamp,A,_,V,oe;if(o.eventType!=te&&(g>X||u.velocity===n)){var fe=o.deltaX-u.deltaX,ae=o.deltaY-u.deltaY,ye=Ve(g,fe,ae);_=ye.x,V=ye.y,A=h(ye.x)>h(ye.y)?ye.x:ye.y,oe=we(fe,ae),a.lastInterval=o}else A=u.velocity,_=u.velocityX,V=u.velocityY,oe=u.direction;o.velocity=A,o.velocityX=_,o.velocityY=V,o.direction=oe}function ie(a){for(var o=[],u=0;u<a.pointers.length;)o[u]={clientX:i(a.pointers[u].clientX),clientY:i(a.pointers[u].clientY)},u++;return{timeStamp:c(),pointers:o,center:me(o),deltaX:a.deltaX,deltaY:a.deltaY}}function me(a){var o=a.length;if(o===1)return{x:i(a[0].clientX),y:i(a[0].clientY)};for(var u=0,g=0,A=0;A<o;)u+=a[A].clientX,g+=a[A].clientY,A++;return{x:i(u/o),y:i(g/o)}}function Ve(a,o,u){return{x:o/a||0,y:u/a||0}}function we(a,o){return a===o?xe:h(a)>=h(o)?a<0?Pe:Ce:o<0?Oe:Me}function Xe(a,o,u){u||(u=Ue);var g=o[u[0]]-a[u[0]],A=o[u[1]]-a[u[1]];return Math.sqrt(g*g+A*A)}function st(a,o,u){u||(u=Ue);var g=o[u[0]]-a[u[0]],A=o[u[1]]-a[u[1]];return Math.atan2(A,g)*180/Math.PI}function Qt(a,o){return st(o[1],o[0],_e)+st(a[1],a[0],_e)}function Jt(a,o){return Xe(o[0],o[1],_e)/Xe(a[0],a[1],_e)}var $t={mousedown:z,mousemove:le,mouseup:$},en="mousedown",tn="mousemove mouseup";function qe(){this.evEl=en,this.evWin=tn,this.pressed=!1,ue.apply(this,arguments)}E(qe,ue,{handler:function(o){var u=$t[o.type];u&z&&(o.button===0||o.button===2)&&(this.pressed=!0),u&le&&o.which!==1&&(u=$),this.pressed&&(u&$&&(this.pressed=!1),this.callback(this.manager,u,{pointers:[o],changedPointers:[o],pointerType:re,srcEvent:o}))}});var Ct={pointerdown:z,pointermove:le,pointerup:$,pointercancel:te,pointerout:te},nn={2:Q,3:U,4:re,5:q},Ot="pointerdown",_t="pointermove pointerup pointercancel";v.MSPointerEvent&&!v.PointerEvent&&(Ot="MSPointerDown",_t="MSPointerMove MSPointerUp MSPointerCancel");function lt(){this.evEl=Ot,this.evWin=_t,ue.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}E(lt,ue,{handler:function(o){var u=this.store,g=!1,A=!1,_=o.type.toLowerCase().replace("ms",""),V=Ct[_],oe=nn[o.pointerType]||o.pointerType,fe=oe==Q,ae=H(u,o.pointerId,"pointerId");V&z&&(o.button===0||o.button===2||fe)?ae<0&&(u.push(o),ae=u.length-1):V&($|te)?g=!0:!fe&&o.buttons===0&&(g=!0,A=!0,V=Ct.pointerup),!(ae<0)&&(A||(u[ae]=o),this.callback(this.manager,V,{pointers:u,changedPointers:[o],pointerType:oe,srcEvent:u[ae]}),g&&u.splice(ae,1))}});var rn={touchstart:z,touchmove:le,touchend:$,touchcancel:te},an="touchstart",on="touchstart touchmove touchend touchcancel";function kt(){this.evTarget=an,this.evWin=on,this.started=!1,ue.apply(this,arguments)}E(kt,ue,{handler:function(o){var u=rn[o.type];if(u===z&&(this.started=!0),!!this.started){var g=sn.call(this,o,u);u&($|te)&&g[0].length-g[1].length===0&&(this.started=!1),this.callback(this.manager,u,{pointers:g[0],changedPointers:g[1],pointerType:Q,srcEvent:o})}}});function sn(a,o){var u=Z(a.touches),g=Z(a.changedTouches);return o&($|te)&&(u=J(u.concat(g),"identifier")),[u,g]}var ln={touchstart:z,touchmove:le,touchend:$,touchcancel:te},un="touchstart touchmove touchend touchcancel";function Ze(){this.evTarget=un,this.targetIds={},ue.apply(this,arguments)}E(Ze,ue,{handler:function(o){var u=ln[o.type],g=cn.call(this,o,u);g&&this.callback(this.manager,u,{pointers:g[0],changedPointers:g[1],pointerType:Q,srcEvent:o})}});function cn(a,o){var u=Z(a.touches),g=this.targetIds;if(o&(z|le)&&u.length===1)return g[u[0].identifier]=!0,[u,u];var A,_,V=Z(a.changedTouches),oe=[],fe=this.target;if(_=u.filter(function(ae){return F(ae.target,fe)}),o===z)for(A=0;A<_.length;)g[_[A].identifier]=!0,A++;for(A=0;A<V.length;)g[V[A].identifier]&&oe.push(V[A]),o&($|te)&&delete g[V[A].identifier],A++;if(oe.length)return[J(_.concat(oe),"identifier"),oe]}var fn=2500,Ft=25;function ut(){ue.apply(this,arguments);var a=b(this.handler,this);this.touch=new Ze(this.manager,a),this.mouse=new qe(this.manager,a),this.primaryTouch=null,this.lastTouches=[]}E(ut,ue,{handler:function(o,u,g){var A=g.pointerType==Q,_=g.pointerType==re;if(!(_&&g.sourceCapabilities&&g.sourceCapabilities.firesTouchEvents)){if(A)hn.call(this,u,g);else if(_&&vn.call(this,g))return;this.callback(o,u,g)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function hn(a,o){a&z?(this.primaryTouch=o.changedPointers[0].identifier,Lt.call(this,o)):a&($|te)&&Lt.call(this,o)}function Lt(a){var o=a.changedPointers[0];if(o.identifier===this.primaryTouch){var u={x:o.clientX,y:o.clientY};this.lastTouches.push(u);var g=this.lastTouches,A=function(){var _=g.indexOf(u);_>-1&&g.splice(_,1)};setTimeout(A,fn)}}function vn(a){for(var o=a.srcEvent.clientX,u=a.srcEvent.clientY,g=0;g<this.lastTouches.length;g++){var A=this.lastTouches[g],_=Math.abs(o-A.x),V=Math.abs(u-A.y);if(_<=Ft&&V<=Ft)return!0}return!1}var It=r?R(r.style,"touchAction"):n,Dt=It!==n,Nt="compute",Bt="auto",ct="manipulation",ke="none",Re="pan-x",ze="pan-y",Qe=pn();function ft(a,o){this.manager=a,this.set(o)}ft.prototype={set:function(a){a==Nt&&(a=this.compute()),Dt&&this.manager.element.style&&Qe[a]&&(this.manager.element.style[It]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return M(this.manager.recognizers,function(o){T(o.options.enable,[o])&&(a=a.concat(o.getTouchAction()))}),dn(a.join(" "))},preventDefaults:function(a){var o=a.srcEvent,u=a.offsetDirection;if(this.manager.session.prevented){o.preventDefault();return}var g=this.actions,A=j(g,ke)&&!Qe[ke],_=j(g,ze)&&!Qe[ze],V=j(g,Re)&&!Qe[Re];if(A){var oe=a.pointers.length===1,fe=a.distance<2,ae=a.deltaTime<250;if(oe&&fe&&ae)return}if(!(V&&_)&&(A||_&&u&ce||V&&u&de))return this.preventSrc(o)},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};function dn(a){if(j(a,ke))return ke;var o=j(a,Re),u=j(a,ze);return o&&u?ke:o||u?o?Re:ze:j(a,ct)?ct:Bt}function pn(){if(!Dt)return!1;var a={},o=v.CSS&&v.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(u){a[u]=o?v.CSS.supports("touch-action",u):!0}),a}var Je=1,he=2,Ie=4,Se=8,Ee=Se,je=16,ge=32;function Te(a){this.options=P({},this.defaults,a||{}),this.id=L(),this.manager=null,this.options.enable=f(this.options.enable,!0),this.state=Je,this.simultaneous={},this.requireFail=[]}Te.prototype={defaults:{},set:function(a){return P(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(y(a,"recognizeWith",this))return this;var o=this.simultaneous;return a=$e(a,this),o[a.id]||(o[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return y(a,"dropRecognizeWith",this)?this:(a=$e(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(y(a,"requireFailure",this))return this;var o=this.requireFail;return a=$e(a,this),H(o,a)===-1&&(o.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(y(a,"dropRequireFailure",this))return this;a=$e(a,this);var o=H(this.requireFail,a);return o>-1&&this.requireFail.splice(o,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){var o=this,u=this.state;function g(A){o.manager.emit(A,a)}u<Se&&g(o.options.event+Ut(u)),g(o.options.event),a.additionalEvent&&g(a.additionalEvent),u>=Se&&g(o.options.event+Ut(u))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=ge},canEmit:function(){for(var a=0;a<this.requireFail.length;){if(!(this.requireFail[a].state&(ge|Je)))return!1;a++}return!0},recognize:function(a){var o=P({},a);if(!T(this.options.enable,[this,o])){this.reset(),this.state=ge;return}this.state&(Ee|je|ge)&&(this.state=Je),this.state=this.process(o),this.state&(he|Ie|Se|je)&&this.tryEmit(o)},process:function(a){},getTouchAction:function(){},reset:function(){}};function Ut(a){return a&je?"cancel":a&Se?"end":a&Ie?"move":a&he?"start":""}function Vt(a){return a==Me?"down":a==Oe?"up":a==Pe?"left":a==Ce?"right":""}function $e(a,o){var u=o.manager;return u?u.get(a):a}function pe(){Te.apply(this,arguments)}E(pe,Te,{defaults:{pointers:1},attrTest:function(a){var o=this.options.pointers;return o===0||a.pointers.length===o},process:function(a){var o=this.state,u=a.eventType,g=o&(he|Ie),A=this.attrTest(a);return g&&(u&te||!A)?o|je:g||A?u&$?o|Se:o&he?o|Ie:he:ge}});function et(){pe.apply(this,arguments),this.pX=null,this.pY=null}E(et,pe,{defaults:{event:"pan",threshold:10,pointers:1,direction:Be},getTouchAction:function(){var a=this.options.direction,o=[];return a&ce&&o.push(ze),a&de&&o.push(Re),o},directionTest:function(a){var o=this.options,u=!0,g=a.distance,A=a.direction,_=a.deltaX,V=a.deltaY;return A&o.direction||(o.direction&ce?(A=_===0?xe:_<0?Pe:Ce,u=_!=this.pX,g=Math.abs(a.deltaX)):(A=V===0?xe:V<0?Oe:Me,u=V!=this.pY,g=Math.abs(a.deltaY))),a.direction=A,u&&g>o.threshold&&A&o.direction},attrTest:function(a){return pe.prototype.attrTest.call(this,a)&&(this.state&he||!(this.state&he)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var o=Vt(a.direction);o&&(a.additionalEvent=this.options.event+o),this._super.emit.call(this,a)}});function ht(){pe.apply(this,arguments)}E(ht,pe,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[ke]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&he)},emit:function(a){if(a.scale!==1){var o=a.scale<1?"in":"out";a.additionalEvent=this.options.event+o}this._super.emit.call(this,a)}});function vt(){Te.apply(this,arguments),this._timer=null,this._input=null}E(vt,Te,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Bt]},process:function(a){var o=this.options,u=a.pointers.length===o.pointers,g=a.distance<o.threshold,A=a.deltaTime>o.time;if(this._input=a,!g||!u||a.eventType&($|te)&&!A)this.reset();else if(a.eventType&z)this.reset(),this._timer=d(function(){this.state=Ee,this.tryEmit()},o.time,this);else if(a.eventType&$)return Ee;return ge},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===Ee&&(a&&a.eventType&$?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=c(),this.manager.emit(this.options.event,this._input)))}});function dt(){pe.apply(this,arguments)}E(dt,pe,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[ke]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&he)}});function pt(){pe.apply(this,arguments)}E(pt,pe,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:ce|de,pointers:1},getTouchAction:function(){return et.prototype.getTouchAction.call(this)},attrTest:function(a){var o=this.options.direction,u;return o&(ce|de)?u=a.overallVelocity:o&ce?u=a.overallVelocityX:o&de&&(u=a.overallVelocityY),this._super.attrTest.call(this,a)&&o&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&h(u)>this.options.velocity&&a.eventType&$},emit:function(a){var o=Vt(a.offsetDirection);o&&this.manager.emit(this.options.event+o,a),this.manager.emit(this.options.event,a)}});function tt(){Te.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}E(tt,Te,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[ct]},process:function(a){var o=this.options,u=a.pointers.length===o.pointers,g=a.distance<o.threshold,A=a.deltaTime<o.time;if(this.reset(),a.eventType&z&&this.count===0)return this.failTimeout();if(g&&A&&u){if(a.eventType!=$)return this.failTimeout();var _=this.pTime?a.timeStamp-this.pTime<o.interval:!0,V=!this.pCenter||Xe(this.pCenter,a.center)<o.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,!V||!_?this.count=1:this.count+=1,this._input=a;var oe=this.count%o.taps;if(oe===0)return this.hasRequireFailures()?(this._timer=d(function(){this.state=Ee,this.tryEmit()},o.interval,this),he):Ee}return ge},failTimeout:function(){return this._timer=d(function(){this.state=ge},this.options.interval,this),ge},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Ee&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function De(a,o){return o=o||{},o.recognizers=f(o.recognizers,De.defaults.preset),new mt(a,o)}De.VERSION="2.0.7",De.defaults={domEvents:!1,touchAction:Nt,enable:!0,inputTarget:null,inputClass:null,preset:[[dt,{enable:!1}],[ht,{enable:!1},["rotate"]],[pt,{direction:ce}],[et,{direction:ce},["swipe"]],[tt],[tt,{event:"doubletap",taps:2},["tap"]],[vt]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var mn=1,Rt=2;function mt(a,o){this.options=P({},De.defaults,o||{}),this.options.inputTarget=this.options.inputTarget||a,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=a,this.input=We(this),this.touchAction=new ft(this,this.options.touchAction),zt(this,!0),M(this.options.recognizers,function(u){var g=this.add(new u[0](u[1]));u[2]&&g.recognizeWith(u[2]),u[3]&&g.requireFailure(u[3])},this)}mt.prototype={set:function(a){return P(this.options,a),a.touchAction&&this.touchAction.update(),a.inputTarget&&(this.input.destroy(),this.input.target=a.inputTarget,this.input.init()),this},stop:function(a){this.session.stopped=a?Rt:mn},recognize:function(a){var o=this.session;if(!o.stopped){this.touchAction.preventDefaults(a);var u,g=this.recognizers,A=o.curRecognizer;(!A||A&&A.state&Ee)&&(A=o.curRecognizer=null);for(var _=0;_<g.length;)u=g[_],o.stopped!==Rt&&(!A||u==A||u.canRecognizeWith(A))?u.recognize(a):u.reset(),!A&&u.state&(he|Ie|Se)&&(A=o.curRecognizer=u),_++}},get:function(a){if(a instanceof Te)return a;for(var o=this.recognizers,u=0;u<o.length;u++)if(o[u].options.event==a)return o[u];return null},add:function(a){if(y(a,"add",this))return this;var o=this.get(a.options.event);return o&&this.remove(o),this.recognizers.push(a),a.manager=this,this.touchAction.update(),a},remove:function(a){if(y(a,"remove",this))return this;if(a=this.get(a),a){var o=this.recognizers,u=H(o,a);u!==-1&&(o.splice(u,1),this.touchAction.update())}return this},on:function(a,o){if(a!==n&&o!==n){var u=this.handlers;return M(Y(a),function(g){u[g]=u[g]||[],u[g].push(o)}),this}},off:function(a,o){if(a!==n){var u=this.handlers;return M(Y(a),function(g){o?u[g]&&u[g].splice(H(u[g],o),1):delete u[g]}),this}},emit:function(a,o){this.options.domEvents&&gn(a,o);var u=this.handlers[a]&&this.handlers[a].slice();if(!(!u||!u.length)){o.type=a,o.preventDefault=function(){o.srcEvent.preventDefault()};for(var g=0;g<u.length;)u[g](o),g++}},destroy:function(){this.element&&zt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function zt(a,o){var u=a.element;if(u.style){var g;M(a.options.cssProps,function(A,_){g=R(u.style,_),o?(a.oldCssProps[g]=u.style[g],u.style[g]=A):u.style[g]=a.oldCssProps[g]||""}),o||(a.oldCssProps={})}}function gn(a,o){var u=s.createEvent("Event");u.initEvent(a,!0,!0),u.gesture=o,o.target.dispatchEvent(u)}return P(De,{INPUT_START:z,INPUT_MOVE:le,INPUT_END:$,INPUT_CANCEL:te,STATE_POSSIBLE:Je,STATE_BEGAN:he,STATE_CHANGED:Ie,STATE_ENDED:Se,STATE_RECOGNIZED:Ee,STATE_CANCELLED:je,STATE_FAILED:ge,DIRECTION_NONE:xe,DIRECTION_LEFT:Pe,DIRECTION_RIGHT:Ce,DIRECTION_UP:Oe,DIRECTION_DOWN:Me,DIRECTION_HORIZONTAL:ce,DIRECTION_VERTICAL:de,DIRECTION_ALL:Be,Manager:mt,Input:ue,TouchAction:ft,TouchInput:Ze,MouseInput:qe,PointerEventInput:lt,TouchMouseInput:ut,SingleTouchInput:kt,Recognizer:Te,AttrRecognizer:pe,Tap:tt,Pan:et,Swipe:pt,Pinch:ht,Rotate:dt,Press:vt,on:C,off:x,each:M,merge:O,extend:S,assign:P,inherit:E,bindFn:b,prefixed:R}),De})(typeof window!="undefined"?window:{},typeof document!="undefined"?document:{}),Ne=function(v,s){s===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),s===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=v,this.domElement=s,this.enabled=!0,this.target=new D.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:D.MOUSE.ROTATE,MIDDLE:D.MOUSE.DOLLY,RIGHT:D.MOUSE.PAN},this.touches={ONE:D.TOUCH.ROTATE,TWO:D.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return c.phi},this.getAzimuthalAngle=function(){return c.theta},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(n),e.update(),i=l.NONE},this.update=(function(){var m=new D.Vector3,G=new D.Quaternion().setFromUnitVectors(v.up,new D.Vector3(0,1,0)),ne=G.clone().inverse(),ie=new D.Vector3,me=new D.Quaternion;return function(){var we=e.object.position;return m.copy(we).sub(e.target),m.applyQuaternion(G),c.setFromVector3(m),e.autoRotate&&i===l.NONE&&Y(F()),e.enableDamping?(c.theta+=d.theta*e.dampingFactor,c.phi+=d.phi*e.dampingFactor):(c.theta+=d.theta,c.phi+=d.phi),c.theta=Math.max(e.minAzimuthAngle,Math.min(e.maxAzimuthAngle,c.theta)),c.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,c.phi)),c.makeSafe(),c.radius*=y,c.radius=Math.max(e.minDistance,Math.min(e.maxDistance,c.radius)),e.enableDamping===!0?e.target.addScaledVector(M,e.dampingFactor):e.target.add(M),m.setFromSpherical(c),m.applyQuaternion(ne),we.copy(e.target).add(m),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,M.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),M.set(0,0,0)),y=1,w||ie.distanceToSquared(e.object.position)>h||8*(1-me.dot(e.object.quaternion))>h?(e.dispatchEvent(n),ie.copy(e.object.position),me.copy(e.object.quaternion),w=!1,!0):!1}})(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ke,!1),e.domElement.removeEventListener("mousedown",Me,!1),e.domElement.removeEventListener("wheel",Be,!1),e.domElement.removeEventListener("touchstart",_e,!1),e.domElement.removeEventListener("touchend",We,!1),e.domElement.removeEventListener("touchmove",ue,!1),document.removeEventListener("mousemove",ce,!1),document.removeEventListener("mouseup",de,!1),e.domElement.removeEventListener("keydown",Ue,!1)};var e=this,n={type:"change"},t={type:"start"},r={type:"end"},l={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},i=l.NONE,h=1e-6,c=new D.Spherical,d=new D.Spherical,y=1,M=new D.Vector3,w=!1,P=new D.Vector2,S=new D.Vector2,O=new D.Vector2,E=new D.Vector2,b=new D.Vector2,T=new D.Vector2,f=new D.Vector2,C=new D.Vector2,x=new D.Vector2;function F(){return 2*Math.PI/60/60*e.autoRotateSpeed}function j(){return Math.pow(.95,e.zoomSpeed)}function Y(m){d.theta-=m}function H(m){d.phi-=m}var Z=(function(){var m=new D.Vector3;return function(ne,ie){m.setFromMatrixColumn(ie,0),m.multiplyScalar(-ne),M.add(m)}})(),J=(function(){var m=new D.Vector3;return function(ne,ie){e.screenSpacePanning===!0?m.setFromMatrixColumn(ie,1):(m.setFromMatrixColumn(ie,0),m.crossVectors(e.object.up,m)),m.multiplyScalar(ne),M.add(m)}})(),R=(function(){var m=new D.Vector3;return function(ne,ie){var me=e.domElement;if(e.object.isPerspectiveCamera){var Ve=e.object.position;m.copy(Ve).sub(e.target);var we=m.length();we*=Math.tan(e.object.fov/2*Math.PI/180),Z(2*ne*we/me.clientHeight,e.object.matrix),J(2*ie*we/me.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(Z(ne*(e.object.right-e.object.left)/e.object.zoom/me.clientWidth,e.object.matrix),J(ie*(e.object.top-e.object.bottom)/e.object.zoom/me.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}})();function K(m){e.object.isPerspectiveCamera?y/=m:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*m)),e.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function L(m){e.object.isPerspectiveCamera?y*=m:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function k(m){P.set(m.clientX,m.clientY)}function I(m){f.set(m.clientX,m.clientY)}function N(m){E.set(m.clientX,m.clientY)}function W(m){S.set(m.clientX,m.clientY),O.subVectors(S,P).multiplyScalar(e.rotateSpeed);var G=e.domElement;Y(2*Math.PI*O.x/G.clientHeight),H(2*Math.PI*O.y/G.clientHeight),P.copy(S),e.update()}function ee(m){C.set(m.clientX,m.clientY),x.subVectors(C,f),x.y>0?K(j()):x.y<0&&L(j()),f.copy(C),e.update()}function Q(m){b.set(m.clientX,m.clientY),T.subVectors(b,E).multiplyScalar(e.panSpeed),R(T.x,T.y),E.copy(b),e.update()}function U(m){m.deltaY<0?L(j()):m.deltaY>0&&K(j()),e.update()}function re(m){var G=!1;switch(m.keyCode){case e.keys.UP:R(0,e.keyPanSpeed),G=!0;break;case e.keys.BOTTOM:R(0,-e.keyPanSpeed),G=!0;break;case e.keys.LEFT:R(e.keyPanSpeed,0),G=!0;break;case e.keys.RIGHT:R(-e.keyPanSpeed,0),G=!0;break}G&&(m.preventDefault(),e.update())}function q(m){if(m.touches.length==1)P.set(m.touches[0].pageX,m.touches[0].pageY);else{var G=.5*(m.touches[0].pageX+m.touches[1].pageX),ne=.5*(m.touches[0].pageY+m.touches[1].pageY);P.set(G,ne)}}function X(m){if(m.touches.length==1)E.set(m.touches[0].pageX,m.touches[0].pageY);else{var G=.5*(m.touches[0].pageX+m.touches[1].pageX),ne=.5*(m.touches[0].pageY+m.touches[1].pageY);E.set(G,ne)}}function z(m){var G=m.touches[0].pageX-m.touches[1].pageX,ne=m.touches[0].pageY-m.touches[1].pageY,ie=Math.sqrt(G*G+ne*ne);f.set(0,ie)}function le(m){e.enableZoom&&z(m),e.enablePan&&X(m)}function $(m){e.enableZoom&&z(m),e.enableRotate&&q(m)}function te(m){if(m.touches.length==1)S.set(m.touches[0].pageX,m.touches[0].pageY);else{var G=.5*(m.touches[0].pageX+m.touches[1].pageX),ne=.5*(m.touches[0].pageY+m.touches[1].pageY);S.set(G,ne)}O.subVectors(S,P).multiplyScalar(e.rotateSpeed);var ie=e.domElement;Y(2*Math.PI*O.x/ie.clientHeight),H(2*Math.PI*O.y/ie.clientHeight),P.copy(S)}function xe(m){if(m.touches.length==1)b.set(m.touches[0].pageX,m.touches[0].pageY);else{var G=.5*(m.touches[0].pageX+m.touches[1].pageX),ne=.5*(m.touches[0].pageY+m.touches[1].pageY);b.set(G,ne)}T.subVectors(b,E).multiplyScalar(e.panSpeed),R(T.x,T.y),E.copy(b)}function Pe(m){var G=m.touches[0].pageX-m.touches[1].pageX,ne=m.touches[0].pageY-m.touches[1].pageY,ie=Math.sqrt(G*G+ne*ne);C.set(0,ie),x.set(0,Math.pow(C.y/f.y,e.zoomSpeed)),K(x.y),f.copy(C)}function Ce(m){e.enableZoom&&Pe(m),e.enablePan&&xe(m)}function Oe(m){e.enableZoom&&Pe(m),e.enableRotate&&te(m)}function Me(m){if(e.enabled!==!1){m.preventDefault(),e.domElement.focus?e.domElement.focus():window.focus();var G;switch(m.button){case 0:G=e.mouseButtons.LEFT;break;case 1:G=e.mouseButtons.MIDDLE;break;case 2:G=e.mouseButtons.RIGHT;break;default:G=-1}switch(G){case D.MOUSE.DOLLY:if(e.enableZoom===!1)return;I(m),i=l.DOLLY;break;case D.MOUSE.ROTATE:if(m.ctrlKey||m.metaKey||m.shiftKey){if(e.enablePan===!1)return;N(m),i=l.PAN}else{if(e.enableRotate===!1)return;k(m),i=l.ROTATE}break;case D.MOUSE.PAN:if(m.ctrlKey||m.metaKey||m.shiftKey){if(e.enableRotate===!1)return;k(m),i=l.ROTATE}else{if(e.enablePan===!1)return;N(m),i=l.PAN}break;default:i=l.NONE}i!==l.NONE&&(document.addEventListener("mousemove",ce,!1),document.addEventListener("mouseup",de,!1),e.dispatchEvent(t))}}function ce(m){if(e.enabled!==!1)switch(m.preventDefault(),i){case l.ROTATE:if(e.enableRotate===!1)return;W(m);break;case l.DOLLY:if(e.enableZoom===!1)return;ee(m);break;case l.PAN:if(e.enablePan===!1)return;Q(m);break}}function de(m){e.enabled!==!1&&(document.removeEventListener("mousemove",ce,!1),document.removeEventListener("mouseup",de,!1),e.dispatchEvent(r),i=l.NONE)}function Be(m){e.enabled===!1||e.enableZoom===!1||i!==l.NONE&&i!==l.ROTATE||(m.preventDefault(),m.stopPropagation(),e.dispatchEvent(t),U(m),e.dispatchEvent(r))}function Ue(m){e.enabled===!1||e.enableKeys===!1||e.enablePan===!1||re(m)}function _e(m){if(e.enabled!==!1){switch(m.preventDefault(),m.touches.length){case 1:switch(e.touches.ONE){case D.TOUCH.ROTATE:if(e.enableRotate===!1)return;q(m),i=l.TOUCH_ROTATE;break;case D.TOUCH.PAN:if(e.enablePan===!1)return;X(m),i=l.TOUCH_PAN;break;default:i=l.NONE}break;case 2:switch(e.touches.TWO){case D.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;le(m),i=l.TOUCH_DOLLY_PAN;break;case D.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;$(m),i=l.TOUCH_DOLLY_ROTATE;break;default:i=l.NONE}break;default:i=l.NONE}i!==l.NONE&&e.dispatchEvent(t)}}function ue(m){if(e.enabled!==!1)switch(m.preventDefault(),m.stopPropagation(),i){case l.TOUCH_ROTATE:if(e.enableRotate===!1)return;te(m),e.update();break;case l.TOUCH_PAN:if(e.enablePan===!1)return;xe(m),e.update();break;case l.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ce(m),e.update();break;case l.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Oe(m),e.update();break;default:i=l.NONE}}function We(m){e.enabled!==!1&&(e.dispatchEvent(r),i=l.NONE)}function Ke(m){e.enabled!==!1&&m.preventDefault()}e.domElement.addEventListener("contextmenu",Ke,!1),e.domElement.addEventListener("mousedown",Me,!1),e.domElement.addEventListener("wheel",Be,!1),e.domElement.addEventListener("touchstart",_e,!1),e.domElement.addEventListener("touchend",We,!1),e.domElement.addEventListener("touchmove",ue,!1),e.domElement.addEventListener("keydown",Ue,!1),e.domElement.tabIndex===-1&&(e.domElement.tabIndex=0),this.update()};Ne.prototype=Object.create(D.EventDispatcher.prototype);Ne.prototype.constructor=Ne;var Pt=function(v,s){Ne.call(this,v,s),this.mouseButtons.LEFT=D.MOUSE.PAN,this.mouseButtons.RIGHT=D.MOUSE.ROTATE,this.touches.ONE=D.TOUCH.PAN,this.touches.TWO=D.TOUCH.DOLLY_ROTATE};Pt.prototype=Object.create(D.EventDispatcher.prototype);Pt.prototype.constructor=Pt;var Ae=function(v){D.Object3D.call(this),this.element=v,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.addEventListener("removed",function(){this.traverse(function(s){s.element instanceof Element&&s.element.parentNode!==null&&s.element.parentNode.removeChild(s.element)})})};Ae.prototype=Object.create(D.Object3D.prototype);Ae.prototype.constructor=Ae;var ot=function(v){Ae.call(this,v)};ot.prototype=Object.create(Ae.prototype);ot.prototype.constructor=ot;var Wt=function(){var v=this,s,e,n,t,r=new D.Matrix4,l={camera:{fov:0,style:""},objects:new WeakMap},i=document.createElement("div");i.style.overflow="hidden",this.domElement=i;var h=document.createElement("div");h.style.WebkitTransformStyle="preserve-3d",h.style.transformStyle="preserve-3d",h.style.pointerEvents="none",i.appendChild(h);var c=/Trident/i.test(navigator.userAgent);this.getSize=function(){return{width:s,height:e}},this.setSize=function(E,b){s=E,e=b,n=s/2,t=e/2,i.style.width=E+"px",i.style.height=b+"px",h.style.width=E+"px",h.style.height=b+"px"};function d(E){return Math.abs(E)<1e-10?0:E}function y(E){var b=E.elements;return"matrix3d("+d(b[0])+","+d(-b[1])+","+d(b[2])+","+d(b[3])+","+d(b[4])+","+d(-b[5])+","+d(b[6])+","+d(b[7])+","+d(b[8])+","+d(-b[9])+","+d(b[10])+","+d(b[11])+","+d(b[12])+","+d(-b[13])+","+d(b[14])+","+d(b[15])+")"}function M(E,b){var T=E.elements,f="matrix3d("+d(T[0])+","+d(T[1])+","+d(T[2])+","+d(T[3])+","+d(-T[4])+","+d(-T[5])+","+d(-T[6])+","+d(-T[7])+","+d(T[8])+","+d(T[9])+","+d(T[10])+","+d(T[11])+","+d(T[12])+","+d(T[13])+","+d(T[14])+","+d(T[15])+")";return c?"translate(-50%,-50%)translate("+n+"px,"+t+"px)"+b+f:"translate(-50%,-50%)"+f}function w(E,b,T,f){if(E instanceof Ae){E.onBeforeRender(v,b,T);var C;E instanceof ot?(r.copy(T.matrixWorldInverse),r.transpose(),r.copyPosition(E.matrixWorld),r.scale(E.scale),r.elements[3]=0,r.elements[7]=0,r.elements[11]=0,r.elements[15]=1,C=M(r,f)):C=M(E.matrixWorld,f);var x=E.element,F=l.objects.get(E);if(F===void 0||F.style!==C){x.style.WebkitTransform=C,x.style.transform=C;var j={style:C};c&&(j.distanceToCameraSquared=P(T,E)),l.objects.set(E,j)}x.style.display=E.visible?"":"none",x.parentNode!==h&&h.appendChild(x),E.onAfterRender(v,b,T)}for(var Y=0,H=E.children.length;Y<H;Y++)w(E.children[Y],b,T,f)}var P=(function(){var E=new D.Vector3,b=new D.Vector3;return function(T,f){return E.setFromMatrixPosition(T.matrixWorld),b.setFromMatrixPosition(f.matrixWorld),E.distanceToSquared(b)}})();function S(E){var b=[];return E.traverse(function(T){T instanceof Ae&&b.push(T)}),b}function O(E){for(var b=S(E).sort(function(x,F){var j=l.objects.get(x).distanceToCameraSquared,Y=l.objects.get(F).distanceToCameraSquared;return j-Y}),T=b.length,f=0,C=b.length;f<C;f++)b[f].element.style.zIndex=T-f}this.render=function(E,b){var T=b.projectionMatrix.elements[5]*t;if(l.camera.fov!==T&&(b.isPerspectiveCamera?(i.style.WebkitPerspective=T+"px",i.style.perspective=T+"px"):(i.style.WebkitPerspective="",i.style.perspective=""),l.camera.fov=T),E.autoUpdate===!0&&E.updateMatrixWorld(),b.parent===null&&b.updateMatrixWorld(),b.isOrthographicCamera)var f=-(b.right+b.left)/2,C=(b.top+b.bottom)/2;var x=b.isOrthographicCamera?"scale("+T+")translate("+d(f)+"px,"+d(C)+"px)"+y(b.matrixWorldInverse):"translateZ("+T+"px)"+y(b.matrixWorldInverse),F=x+"translate("+n+"px,"+t+"px)";l.camera.style!==F&&!c&&(h.style.WebkitTransform=F,h.style.transform=F,l.camera.style=F),w(E,E,b,x),c&&O(E)}};function Ht(v,s,e){var n=s.getBoundingClientRect(),t=n.top,r=n.left,l=n.width,i=n.height;return new p.Vector2((v.x-r)/l*2-1,-(v.y-t)/i*2+1)}var Kt=(function(v){ve(s,v);function s(e,n,t,r,l){var i=v.call(this)||this;i.type="RoundedBoxGeometry",l=isNaN(l)?1:Math.max(1,Math.floor(l)),e=isNaN(e)?1:e,n=isNaN(n)?1:n,t=isNaN(t)?1:t,r=isNaN(r)?.15:r,r=Math.min(r,Math.min(e,Math.min(n,Math.min(t)))/2);var h=e/2-r,c=n/2-r,d=t/2-r;i.parameters={width:e,height:n,depth:t,radius:r,radiusSegments:l};var y=l+1,M=y*l+1<<3,w=new p.BufferAttribute(new Float32Array(M*3),3),P=new p.BufferAttribute(new Float32Array(M*3),3),S=[],O=[];new p.Vector3;var E=new p.Vector3,b=[],T=[],f=[],C=y*l,x=y*l+1;F(),Y(),j(),H(),J(),Z();function F(){for(var L=[new p.Vector3(1,1,1),new p.Vector3(1,1,-1),new p.Vector3(-1,1,-1),new p.Vector3(-1,1,1),new p.Vector3(1,-1,1),new p.Vector3(1,-1,-1),new p.Vector3(-1,-1,-1),new p.Vector3(-1,-1,1)],k=0;k<8;k++)S.push([]),O.push([]);for(var I=Math.PI/2,N=new p.Vector3(h,c,d),W=0;W<=l;W++){var ee=W/l,Q=ee*I,U=Math.cos(Q),re=Math.sin(Q);if(W==l){E.set(0,1,0);var q=E.clone().multiplyScalar(r).add(N);S[0].push(q),b.push(q);var X=E.clone();O[0].push(X),T.push(X);continue}for(var z=0;z<=l;z++){var le=z/l,$=le*I;E.x=U*Math.cos($),E.y=re,E.z=U*Math.sin($);var q=E.clone().multiplyScalar(r).add(N);S[0].push(q),b.push(q);var X=E.clone().normalize();O[0].push(X),T.push(X)}}for(var te=1;te<8;te++)for(var k=0;k<S[0].length;k++){var q=S[0][k].clone().multiply(L[te]);S[te].push(q),b.push(q);var X=O[0][k].clone().multiply(L[te]);O[te].push(X),T.push(X)}}function j(){for(var L=[!0,!1,!0,!1,!1,!0,!1,!0],k=y*(l-1),I=0;I<8;I++){for(var N=x*I,W=0;W<l-1;W++)for(var ee=W*y,Q=(W+1)*y,U=0;U<l;U++){var re=U+1,q=N+ee+U,X=N+ee+re,z=N+Q+U,le=N+Q+re;L[I]?(f.push(q),f.push(z),f.push(X),f.push(X),f.push(z),f.push(le)):(f.push(q),f.push(X),f.push(z),f.push(X),f.push(le),f.push(z))}for(var U=0;U<l;U++){var q=N+k+U,X=N+k+U+1,z=N+C;L[I]?(f.push(q),f.push(z),f.push(X)):(f.push(q),f.push(X),f.push(z))}}}function Y(){var L=C,k=C+x,I=C+x*2,N=C+x*3;f.push(L),f.push(k),f.push(I),f.push(L),f.push(I),f.push(N),L=C+x*4,k=C+x*5,I=C+x*6,N=C+x*7,f.push(L),f.push(I),f.push(k),f.push(L),f.push(N),f.push(I),L=0,k=x,I=x*4,N=x*5,f.push(L),f.push(I),f.push(k),f.push(k),f.push(I),f.push(N),L=x*2,k=x*3,I=x*6,N=x*7,f.push(L),f.push(I),f.push(k),f.push(k),f.push(I),f.push(N),L=l,k=l+x*3,I=l+x*4,N=l+x*7,f.push(L),f.push(k),f.push(I),f.push(k),f.push(N),f.push(I),L=l+x,k=l+x*2,I=l+x*5,N=l+x*6,f.push(L),f.push(I),f.push(k),f.push(k),f.push(I),f.push(N)}function H(){for(var L=0;L<4;L++)for(var k=L*x,I=4*x+k,N=(L&1)===1,W=0;W<l;W++){var ee=W+1,Q=k+W,U=k+ee,re=I+W,q=I+ee;N?(f.push(Q),f.push(re),f.push(U),f.push(U),f.push(re),f.push(q)):(f.push(Q),f.push(U),f.push(re),f.push(U),f.push(q),f.push(re))}}function Z(){for(var L=[0,2,4,6],k=[1,3,5,7],I=0;I<4;I++)for(var N=x*L[I],W=x*k[I],ee=1>=I,Q=0;Q<l;Q++){var U=Q*y,re=(Q+1)*y,q=N+U,X=N+re,z=W+U,le=W+re;ee?(f.push(q),f.push(z),f.push(X),f.push(X),f.push(z),f.push(le)):(f.push(q),f.push(X),f.push(z),f.push(X),f.push(le),f.push(z))}}function J(){for(var L=l-1,k=[0,1,4,5],I=[3,2,7,6],N=[0,1,1,0],W=0;W<4;W++)for(var ee=k[W]*x,Q=I[W]*x,U=0;U<=L;U++){var re=ee+l+U*y,q=ee+(U!=L?l+(U+1)*y:x-1),X=Q+l+U*y,z=Q+(U!=L?l+(U+1)*y:x-1);N[W]?(f.push(re),f.push(X),f.push(q),f.push(q),f.push(X),f.push(z)):(f.push(re),f.push(q),f.push(X),f.push(q),f.push(z),f.push(X))}}for(var R=0,K=0;K<b.length;K++)w.setXYZ(R,b[K].x,b[K].y,b[K].z),P.setXYZ(R,T[K].x,T[K].y,T[K].z),R++;return i.setIndex(new p.BufferAttribute(new Uint16Array(f),1)),i.setAttribute("position",w),i.setAttribute("normal",P),i}return s})(p.BufferGeometry);function Ge(v,s){return typeof v!="number"||typeof s!="number"?!1:Math.abs(v-s)<.001}function He(v,s,e,n){n===void 0&&(n=function(r){return r});var t=n(e);return v*(1-t)+s*t}var se=Number((Math.PI/2).toFixed(5));function Ln(v,s,e){var n=new p.Shape;return n.moveTo(e,0),n.lineTo(v-e,0),n.absarc(v-e,e,e,-se,0,!1),n.lineTo(v,s-e),n.absarc(v-e,s-e,e,0,se,!1),n.lineTo(e,s),n.absarc(e,s-e,e,se,Math.PI,!1),n.lineTo(0,e),n.absarc(e,e,e,Math.PI,Math.PI*1.5,!1),n}var Ye=function(v){var s=document.createElement("div");s.innerText=v;var e=new Ae(s);return e.name=v,e.scale.set(.3,.3,.3),s.style.pointerEvents="none",s.style.backfaceVisibility="hidden",e},nt=function(v){var s=new p.PlaneGeometry(5,5),e=new p.MeshBasicMaterial({transparent:!0,opacity:0}),n=new p.Mesh(s,e),t=document.createElement("div");t.innerText=v;var r=new Ae(t);return r.name=v,r.scale.set(.3,.3,.3),t.style.color="#ffffff",t.style.opacity="0.5",t.style.pointerEvents="none",t.style.backfaceVisibility="hidden",n.rotateX(-se),n.add(r),n},In=(function(v){ve(s,v);function s(e,n){var t=v.call(this,e)||this;t.camera=new be.Camera(90),t.scene=new p.Scene,t.renderer=new p.WebGLRenderer({antialias:!0,alpha:!0}),t.css3drenderer=new Wt,t.ambientLight=new p.AmbientLight(16777215,.7),t.wrapper=document.createElement("div"),t.arrows=document.createElement("div"),t.arrowLeft=document.createElement("div"),t.arrowRight=document.createElement("div"),t.arrowFront=document.createElement("div"),t.arrowBack=document.createElement("div"),t.arrowTop=document.createElement("div"),t.arrowBottom=document.createElement("div"),t.spherical=null,t.dragging=!1,t.style=document.createElement("style"),t.directionalLight=new p.DirectionalLight(16777215,.2),t.box=new p.Mesh(new Kt(8,8,8,.5,20),new p.MeshPhongMaterial({color:16777215})),t.faces=new p.Group,t.orient=function(i){var h=i.longitude,c=i.latitude;t.dragging=!1,t.spherical=null,t.controls.enableDamping=!1,t.five.setState(Object.assign({latitude:c},h!==void 0?{longitude:h+t.config.fixedLongitude}:{})),t.five.ready().then(function(){t.controls.enableDamping=!0,t.setState({arrowsVisible:!0})})},t.onRenderFrame=function(){var i,h,c,d,y;if(t.renderer.render(t.scene,t.camera),t.css3drenderer.render(t.scene,t.camera),t.directionalLight.position.copy(t.camera.position),(i=t.controls)===null||i===void 0||i.update(),t.dragging){t.camera.computePose(),t.updateByCamera();var M=t.camera.pose,w=M.longitude,P=M.latitude;t.five.setState({longitude:w,latitude:P},!0),t.updateArrows({longitude:w,latitude:P})}else if(t.spherical&&(!Ge(t.spherical.pi,(h=t.controls)===null||h===void 0?void 0:h.getPolarAngle())||!Ge(t.spherical.theta,(c=t.controls)===null||c===void 0?void 0:c.getAzimuthalAngle()))){t.spherical={pi:(d=t.controls)===null||d===void 0?void 0:d.getPolarAngle(),theta:(y=t.controls)===null||y===void 0?void 0:y.getAzimuthalAngle()},t.camera.computePose(),t.updateByCamera();var S=t.camera.pose,w=S.longitude,P=S.latitude;t.five.setState({longitude:w,latitude:P},!0),t.updateArrows({longitude:w,latitude:P})}else t.spherical=null},t.onTapGesture=function(i){var h=i.pointers[0].clientX,c=i.pointers[0].clientY,d=Ht({x:h,y:c},t.wrapper),y=new p.Raycaster;y.setFromCamera(d,t.camera);var M=y.intersectObjects(t.faces.children,!1)[0];if(M){var w=M.object.userData,P=w.longitude,S=w.latitude;t.orient({longitude:P,latitude:S})}},t.onFiveWantsGesture=function(){if(t.spherical)return!1},t.onFiveModeChange=function(i){t.controls&&(t.controls.maxPolarAngle=i==="Topview"?0:se)},t.onCameraUpdate=function(i){var h=i.state;if(!t.dragging&&!t.spherical){var c=h.longitude,d=h.latitude;t.camera.pose.longitude===c&&t.camera.pose.latitude===d||(t.camera.setFromPose({longitude:c,latitude:d,distance:20,offset:new p.Vector3(0,0,0)}),t.updateByCamera(),t.updateArrows({longitude:c,latitude:d}))}},t.onPanStart=function(i){t.dragging=!0,t.spherical={}},t.onMouseMove=function(i){if(!t.dragging){var h=Ht({x:i.clientX,y:i.clientY},t.wrapper),c=new p.Raycaster;c.setFromCamera(h,t.camera);var d=c.intersectObjects(t.faces.children,!1)[0];t.faces.children.forEach(function(y){y.material.opacity=0,y.children[0].element.style.color=""}),d&&(d.object.material.opacity=.3,d.object.children[0].element.style.color="#336dff")}},t.onPanEnd=function(i){t.dragging=!1,t.spherical={pi:t.controls.getPolarAngle(),theta:t.controls.getAzimuthalAngle()}},t.dispose=function(){t.disable()},t.five=e;var r={enabled:!1,visible:!0,arrowsVisible:!1};t.state=Object.assign(r,n==null?void 0:n.initialState);var l=B({fixedLongitude:0,orthoView:!0},n==null?void 0:n.config);return t._config=l,t.state.enabled&&t._enable({userAction:!1}),t.mc=new yt.Manager(t.wrapper),t.mc.add(new yt.Tap({interval:410})),t.mc.add(new yt.Pan({threshold:10,pointers:0})),t.camera.setFromPose({distance:20,offset:new p.Vector3(0,0,0),longitude:e.camera.pose.latitude,latitude:e.camera.pose.latitude}),t.cylinder=new p.Mesh(new p.CylinderGeometry(13.2,14,.01,50,1,!0),new p.ShaderMaterial({uniforms:{radiusTop:{value:13.2},radiusBottom:{value:14},opacity:{value:1}},vertexShader:`
|
|
350
|
+
`,side:l.DoubleSide,visible:this.state.selectedId===`${e.category_name}${e.index}`,uniforms:{opacity:{value:this.state.mode===`box`?1:0}},depthWrite:!1,depthTest:!1,transparent:!0}),p=new l.Mesh(d,f);return p.position.copy(u),p.name=`${e.category_name}${e.index}`,p.userData.color=new l.Vector4(...e.mask_color.map(e=>e/255).reverse(),1),p.userData.visible_viewpoint=Object.keys(e.visible_viewpoint),p});this.group.add(...t)})}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)}}setMode(e){this.updateState({mode:e},!1),e===`mask`?(this.group.children.forEach(e=>{e.material.uniforms.opacity.value=0}),this.loadPanoMask(this.five.state.panoIndex)):e===`box`&&(this.itemMaskMesh.material.uniforms.color.value=new l.Vector4(0,0,0,1),this.group.children.forEach(e=>{e.material.uniforms.opacity.value=1}),this.five.needsRender=!0)}select(e,t){var n;this.updateState({selectedId:e==null?null:e},(n=t==null?void 0:t.userAction)==null?!1:n),this.group.children.forEach(t=>{t.material.visible=this.state.selectAll||t.name===e}),this.five.needsRender=!0}selectAll(e=!0){this.updateState({selectAll:!!e},!1),this.select()}_enable(e){this.five.on(`panoArrived`,this.onFivePanoArrived),this.five.on(`wantsMoveToPano`,this.onFiveWantsMoveToPano),this.five.on(`gesture.mousemove`,this.onFiveMouseMove),this.five.on(`wantsTapGesture`,this.onFiveTapGesture),this.five.on(`cameraUpdate`,this.onFiveCameraUpdate),this.five.scene.add(this.group),document.head.appendChild(this.style)}_disable(e){this.five.off(`panoArrived`,this.onFivePanoArrived),this.five.off(`wantsMoveToPano`,this.onFiveWantsMoveToPano),this.five.off(`gesture.mousemove`,this.onFiveMouseMove),this.five.off(`wantsTapGesture`,this.onFiveTapGesture),this.five.off(`cameraUpdate`,this.onFiveCameraUpdate),this.five.scene.remove(this.group),document.head.removeChild(this.style)}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),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})}},A=(e,t)=>new k(e,t),ee=(function(e,t,n,r){"use strict";var i=[``,`webkit`,`Moz`,`MS`,`ms`,`o`],a=t.createElement?t.createElement(`div`):r,o=`function`,s=Math.round,c=Math.abs,l=Date.now;function u(e,t,n){return setTimeout(v(e,n),t)}function d(e,t,n){return Array.isArray(e)?(f(e,n[t],n),!0):!1}function f(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==r)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function p(t,n,r){var i=`DEPRECATED METHOD: `+n+`
|
|
351
|
+
`+r+` AT
|
|
352
|
+
`;return function(){var n=Error(`get-stack-trace`),r=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,``).replace(/^\s+at\s+/gm,``).replace(/^Object.<anonymous>\s*\(/gm,`{anonymous}()@`):`Unknown Stack Trace`,a=e.console&&(e.console.warn||e.console.log);return a&&a.call(e.console,i,r),t.apply(this,arguments)}}var m=typeof Object.assign==`function`?Object.assign:function(e){if(e===r||e===null)throw TypeError(`Cannot convert undefined or null to object`);for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==r&&i!==null)for(var a in i)i.hasOwnProperty(a)&&(t[a]=i[a])}return t},h=p(function(e,t,n){for(var i=Object.keys(t),a=0;a<i.length;)(!n||n&&e[i[a]]===r)&&(e[i[a]]=t[i[a]]),a++;return e},`extend`,"Use `assign`."),g=p(function(e,t){return h(e,t,!0)},`merge`,"Use `assign`.");function _(e,t,n){var r=t.prototype,i=e.prototype=Object.create(r);i.constructor=e,i._super=r,n&&m(i,n)}function v(e,t){return function(){return e.apply(t,arguments)}}function y(e,t){return typeof e==o?e.apply(t&&t[0]||r,t):e}function b(e,t){return e===r?t:e}function x(e,t,n){f(T(t),function(t){e.addEventListener(t,n,!1)})}function S(e,t,n){f(T(t),function(t){e.removeEventListener(t,n,!1)})}function C(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function w(e,t){return e.indexOf(t)>-1}function T(e){return e.trim().split(/\s+/g)}function E(e,t,n){if(e.indexOf&&!n)return e.indexOf(t);for(var r=0;r<e.length;){if(n&&e[r][n]==t||!n&&e[r]===t)return r;r++}return-1}function D(e){return Array.prototype.slice.call(e,0)}function O(e,t,n){for(var r=[],i=[],a=0;a<e.length;){var o=t?e[a][t]:e[a];E(i,o)<0&&r.push(e[a]),i[a]=o,a++}return n&&(r=t?r.sort(function(e,n){return e[t]>n[t]}):r.sort()),r}function k(e,t){for(var n,a,o=t[0].toUpperCase()+t.slice(1),s=0;s<i.length;){if(n=i[s],a=n?n+o:t,a in e)return a;s++}return r}var A=1;function ee(){return A++}function j(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var te=/mobile|tablet|ip(ad|hone|od)|android/i,ne=`ontouchstart`in e,re=k(e,`PointerEvent`)!==r,ie=ne&&te.test(navigator.userAgent),M=`touch`,ae=`pen`,N=`mouse`,oe=`kinect`,se=25,P=1,F=2,I=4,L=8,R=1,ce=2,z=4,B=8,le=16,V=ce|z,H=B|le,ue=V|H,de=[`x`,`y`],fe=[`clientX`,`clientY`];function U(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){y(e.options.enable,[e])&&n.handler(t)},this.init()}U.prototype={handler:function(){},init:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(j(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&S(this.element,this.evEl,this.domHandler),this.evTarget&&S(this.target,this.evTarget,this.domHandler),this.evWin&&S(j(this.element),this.evWin,this.domHandler)}};function pe(e){var t;return t=e.options.inputClass||(re?Pe:ie?He:ne?We:ke),new t(e,me)}function me(e,t,n){var r=n.pointers.length,i=n.changedPointers.length,a=t&P&&r-i===0,o=t&(I|L)&&r-i===0;n.isFirst=!!a,n.isFinal=!!o,a&&(e.session={}),n.eventType=t,he(e,n),e.emit(`hammer.input`,n),e.recognize(n),e.session.prevInput=n}function he(e,t){var n=e.session,r=t.pointers,i=r.length;n.firstInput||(n.firstInput=ve(t)),i>1&&!n.firstMultiple?n.firstMultiple=ve(t):i===1&&(n.firstMultiple=!1);var a=n.firstInput,o=n.firstMultiple,s=o?o.center:a.center,u=t.center=ye(r);t.timeStamp=l(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=Ce(s,u),t.distance=Se(s,u),ge(n,t),t.offsetDirection=xe(t.deltaX,t.deltaY);var d=be(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,t.scale=o?Te(o.pointers,r):1,t.rotation=o?we(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length,_e(n,t);var f=e.element;C(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f}function ge(e,t){var n=t.center,r=e.offsetDelta||{},i=e.prevDelta||{},a=e.prevInput||{};(t.eventType===P||a.eventType===I)&&(i=e.prevDelta={x:a.deltaX||0,y:a.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),t.deltaX=i.x+(n.x-r.x),t.deltaY=i.y+(n.y-r.y)}function _e(e,t){var n=e.lastInterval||t,i=t.timeStamp-n.timeStamp,a,o,s,l;if(t.eventType!=L&&(i>se||n.velocity===r)){var u=t.deltaX-n.deltaX,d=t.deltaY-n.deltaY,f=be(i,u,d);o=f.x,s=f.y,a=c(f.x)>c(f.y)?f.x:f.y,l=xe(u,d),e.lastInterval=t}else a=n.velocity,o=n.velocityX,s=n.velocityY,l=n.direction;t.velocity=a,t.velocityX=o,t.velocityY=s,t.direction=l}function ve(e){for(var t=[],n=0;n<e.pointers.length;)t[n]={clientX:s(e.pointers[n].clientX),clientY:s(e.pointers[n].clientY)},n++;return{timeStamp:l(),pointers:t,center:ye(t),deltaX:e.deltaX,deltaY:e.deltaY}}function ye(e){var t=e.length;if(t===1)return{x:s(e[0].clientX),y:s(e[0].clientY)};for(var n=0,r=0,i=0;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:s(n/t),y:s(r/t)}}function be(e,t,n){return{x:t/e||0,y:n/e||0}}function xe(e,t){return e===t?R:c(e)>=c(t)?e<0?ce:z:t<0?B:le}function Se(e,t,n){n||(n=de);var r=t[n[0]]-e[n[0]],i=t[n[1]]-e[n[1]];return Math.sqrt(r*r+i*i)}function Ce(e,t,n){n||(n=de);var r=t[n[0]]-e[n[0]],i=t[n[1]]-e[n[1]];return Math.atan2(i,r)*180/Math.PI}function we(e,t){return Ce(t[1],t[0],fe)+Ce(e[1],e[0],fe)}function Te(e,t){return Se(t[0],t[1],fe)/Se(e[0],e[1],fe)}var Ee={mousedown:P,mousemove:F,mouseup:I},De=`mousedown`,Oe=`mousemove mouseup`;function ke(){this.evEl=De,this.evWin=Oe,this.pressed=!1,U.apply(this,arguments)}_(ke,U,{handler:function(e){var t=Ee[e.type];t&P&&(e.button===0||e.button===2)&&(this.pressed=!0),t&F&&e.which!==1&&(t=I),this.pressed&&(t&I&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:N,srcEvent:e}))}});var Ae={pointerdown:P,pointermove:F,pointerup:I,pointercancel:L,pointerout:L},je={2:M,3:ae,4:N,5:oe},Me=`pointerdown`,Ne=`pointermove pointerup pointercancel`;e.MSPointerEvent&&!e.PointerEvent&&(Me=`MSPointerDown`,Ne=`MSPointerMove MSPointerUp MSPointerCancel`);function Pe(){this.evEl=Me,this.evWin=Ne,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}_(Pe,U,{handler:function(e){var t=this.store,n=!1,r=!1,i=Ae[e.type.toLowerCase().replace(`ms`,``)],a=je[e.pointerType]||e.pointerType,o=a==M,s=E(t,e.pointerId,`pointerId`);i&P&&(e.button===0||e.button===2||o)?s<0&&(t.push(e),s=t.length-1):i&(I|L)?n=!0:!o&&e.buttons===0&&(n=!0,r=!0,i=Ae.pointerup),!(s<0)&&(r||(t[s]=e),this.callback(this.manager,i,{pointers:t,changedPointers:[e],pointerType:a,srcEvent:t[s]}),n&&t.splice(s,1))}});var Fe={touchstart:P,touchmove:F,touchend:I,touchcancel:L},Ie=`touchstart`,Le=`touchstart touchmove touchend touchcancel`;function Re(){this.evTarget=Ie,this.evWin=Le,this.started=!1,U.apply(this,arguments)}_(Re,U,{handler:function(e){var t=Fe[e.type];if(t===P&&(this.started=!0),this.started){var n=ze.call(this,e,t);t&(I|L)&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:e})}}});function ze(e,t){var n=D(e.touches),r=D(e.changedTouches);return t&(I|L)&&(n=O(n.concat(r),`identifier`,!0)),[n,r]}var Be={touchstart:P,touchmove:F,touchend:I,touchcancel:L},Ve=`touchstart touchmove touchend touchcancel`;function He(){this.evTarget=Ve,this.targetIds={},U.apply(this,arguments)}_(He,U,{handler:function(e){var t=Be[e.type],n=Ue.call(this,e,t);n&&this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:e})}});function Ue(e,t){var n=D(e.touches),r=this.targetIds;if(t&(P|F)&&n.length===1)return r[n[0].identifier]=!0,[n,n];var i,a,o=D(e.changedTouches),s=[],c=this.target;if(a=n.filter(function(e){return C(e.target,c)}),t===P)for(i=0;i<a.length;)r[a[i].identifier]=!0,i++;for(i=0;i<o.length;)r[o[i].identifier]&&s.push(o[i]),t&(I|L)&&delete r[o[i].identifier],i++;if(s.length)return[O(a.concat(s),`identifier`,!0),s]}var W=2500,G=25;function We(){U.apply(this,arguments);var e=v(this.handler,this);this.touch=new He(this.manager,e),this.mouse=new ke(this.manager,e),this.primaryTouch=null,this.lastTouches=[]}_(We,U,{handler:function(e,t,n){var r=n.pointerType==M,i=n.pointerType==N;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(r)Ge.call(this,t,n);else if(i&&qe.call(this,n))return;this.callback(e,t,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function Ge(e,t){e&P?(this.primaryTouch=t.changedPointers[0].identifier,Ke.call(this,t)):e&(I|L)&&Ke.call(this,t)}function Ke(e){var t=e.changedPointers[0];if(t.identifier===this.primaryTouch){var n={x:t.clientX,y:t.clientY};this.lastTouches.push(n);var r=this.lastTouches;setTimeout(function(){var e=r.indexOf(n);e>-1&&r.splice(e,1)},W)}}function qe(e){for(var t=e.srcEvent.clientX,n=e.srcEvent.clientY,r=0;r<this.lastTouches.length;r++){var i=this.lastTouches[r],a=Math.abs(t-i.x),o=Math.abs(n-i.y);if(a<=G&&o<=G)return!0}return!1}var Je=a?k(a.style,`touchAction`):r,Ye=Je!==r,Xe=`compute`,Ze=`auto`,Qe=`manipulation`,K=`none`,$e=`pan-x`,et=`pan-y`,tt=it();function nt(e,t){this.manager=e,this.set(t)}nt.prototype={set:function(e){e==Xe&&(e=this.compute()),Ye&&this.manager.element.style&&tt[e]&&(this.manager.element.style[Je]=e),this.actions=e.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var e=[];return f(this.manager.recognizers,function(t){y(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),rt(e.join(` `))},preventDefaults:function(e){var t=e.srcEvent,n=e.offsetDirection;if(this.manager.session.prevented){t.preventDefault();return}var r=this.actions,i=w(r,K)&&!tt[K],a=w(r,et)&&!tt[et],o=w(r,$e)&&!tt[$e];if(i){var s=e.pointers.length===1,c=e.distance<2,l=e.deltaTime<250;if(s&&c&&l)return}if(!(o&&a)&&(i||a&&n&V||o&&n&H))return this.preventSrc(t)},preventSrc:function(e){this.manager.session.prevented=!0,e.preventDefault()}};function rt(e){if(w(e,K))return K;var t=w(e,$e),n=w(e,et);return t&&n?K:t||n?t?$e:et:w(e,Qe)?Qe:Ze}function it(){if(!Ye)return!1;var t={},n=e.CSS&&e.CSS.supports;return[`auto`,`manipulation`,`pan-y`,`pan-x`,`pan-x pan-y`,`none`].forEach(function(r){t[r]=n?e.CSS.supports(`touch-action`,r):!0}),t}var at=1,q=2,ot=4,J=8,Y=J,st=16,X=32;function Z(e){this.options=m({},this.defaults,e||{}),this.id=ee(),this.manager=null,this.options.enable=b(this.options.enable,!0),this.state=at,this.simultaneous={},this.requireFail=[]}Z.prototype={defaults:{},set:function(e){return m(this.options,e),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(e){if(d(e,`recognizeWith`,this))return this;var t=this.simultaneous;return e=ut(e,this),t[e.id]||(t[e.id]=e,e.recognizeWith(this)),this},dropRecognizeWith:function(e){return d(e,`dropRecognizeWith`,this)?this:(e=ut(e,this),delete this.simultaneous[e.id],this)},requireFailure:function(e){if(d(e,`requireFailure`,this))return this;var t=this.requireFail;return e=ut(e,this),E(t,e)===-1&&(t.push(e),e.requireFailure(this)),this},dropRequireFailure:function(e){if(d(e,`dropRequireFailure`,this))return this;e=ut(e,this);var t=E(this.requireFail,e);return t>-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,n=this.state;function r(n){t.manager.emit(n,e)}n<J&&r(t.options.event+ct(n)),r(t.options.event),e.additionalEvent&&r(e.additionalEvent),n>=J&&r(t.options.event+ct(n))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=X},canEmit:function(){for(var e=0;e<this.requireFail.length;){if(!(this.requireFail[e].state&(X|at)))return!1;e++}return!0},recognize:function(e){var t=m({},e);if(!y(this.options.enable,[this,t])){this.reset(),this.state=X;return}this.state&(Y|st|X)&&(this.state=at),this.state=this.process(t),this.state&(q|ot|J|st)&&this.tryEmit(t)},process:function(e){},getTouchAction:function(){},reset:function(){}};function ct(e){return e&st?`cancel`:e&J?`end`:e&ot?`move`:e&q?`start`:``}function lt(e){return e==le?`down`:e==B?`up`:e==ce?`left`:e==z?`right`:``}function ut(e,t){var n=t.manager;return n?n.get(e):e}function Q(){Z.apply(this,arguments)}_(Q,Z,{defaults:{pointers:1},attrTest:function(e){var t=this.options.pointers;return t===0||e.pointers.length===t},process:function(e){var t=this.state,n=e.eventType,r=t&(q|ot),i=this.attrTest(e);return r&&(n&L||!i)?t|st:r||i?n&I?t|J:t&q?t|ot:q:X}});function dt(){Q.apply(this,arguments),this.pX=null,this.pY=null}_(dt,Q,{defaults:{event:`pan`,threshold:10,pointers:1,direction:ue},getTouchAction:function(){var e=this.options.direction,t=[];return e&V&&t.push(et),e&H&&t.push($e),t},directionTest:function(e){var t=this.options,n=!0,r=e.distance,i=e.direction,a=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&V?(i=a===0?R:a<0?ce:z,n=a!=this.pX,r=Math.abs(e.deltaX)):(i=o===0?R:o<0?B:le,n=o!=this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&i&t.direction},attrTest:function(e){return Q.prototype.attrTest.call(this,e)&&(this.state&q||!(this.state&q)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=lt(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}});function ft(){Q.apply(this,arguments)}_(ft,Q,{defaults:{event:`pinch`,threshold:0,pointers:2},getTouchAction:function(){return[K]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||this.state&q)},emit:function(e){if(e.scale!==1){var t=e.scale<1?`in`:`out`;e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}});function $(){Z.apply(this,arguments),this._timer=null,this._input=null}_($,Z,{defaults:{event:`press`,pointers:1,time:251,threshold:9},getTouchAction:function(){return[Ze]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime>t.time;if(this._input=e,!r||!n||e.eventType&(I|L)&&!i)this.reset();else if(e.eventType&P)this.reset(),this._timer=u(function(){this.state=Y,this.tryEmit()},t.time,this);else if(e.eventType&I)return Y;return X},reset:function(){clearTimeout(this._timer)},emit:function(e){this.state===Y&&(e&&e.eventType&I?this.manager.emit(this.options.event+`up`,e):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function pt(){Q.apply(this,arguments)}_(pt,Q,{defaults:{event:`rotate`,threshold:0,pointers:2},getTouchAction:function(){return[K]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||this.state&q)}});function mt(){Q.apply(this,arguments)}_(mt,Q,{defaults:{event:`swipe`,threshold:10,velocity:.3,direction:V|H,pointers:1},getTouchAction:function(){return dt.prototype.getTouchAction.call(this)},attrTest:function(e){var t=this.options.direction,n;return t&(V|H)?n=e.overallVelocity:t&V?n=e.overallVelocityX:t&H&&(n=e.overallVelocityY),this._super.attrTest.call(this,e)&&t&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&c(n)>this.options.velocity&&e.eventType&I},emit:function(e){var t=lt(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}});function ht(){Z.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}_(ht,Z,{defaults:{event:`tap`,pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Qe]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&P&&this.count===0)return this.failTimeout();if(r&&i&&n){if(e.eventType!=I)return this.failTimeout();var a=this.pTime?e.timeStamp-this.pTime<t.interval:!0,o=!this.pCenter||Se(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!o||!a?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=u(function(){this.state=Y,this.tryEmit()},t.interval,this),q):Y}return X},failTimeout:function(){return this._timer=u(function(){this.state=X},this.options.interval,this),X},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Y&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function gt(e,t){return t=t||{},t.recognizers=b(t.recognizers,gt.defaults.preset),new yt(e,t)}gt.VERSION=`2.0.7`,gt.defaults={domEvents:!1,touchAction:Xe,enable:!0,inputTarget:null,inputClass:null,preset:[[pt,{enable:!1}],[ft,{enable:!1},[`rotate`]],[mt,{direction:V}],[dt,{direction:V},[`swipe`]],[ht],[ht,{event:`doubletap`,taps:2},[`tap`]],[$]],cssProps:{userSelect:`none`,touchSelect:`none`,touchCallout:`none`,contentZooming:`none`,userDrag:`none`,tapHighlightColor:`rgba(0,0,0,0)`}};var _t=1,vt=2;function yt(e,t){this.options=m({},gt.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=pe(this),this.touchAction=new nt(this,this.options.touchAction),bt(this,!0),f(this.options.recognizers,function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])},this)}yt.prototype={set:function(e){return m(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?vt:_t},recognize:function(e){var t=this.session;if(!t.stopped){this.touchAction.preventDefaults(e);var n,r=this.recognizers,i=t.curRecognizer;(!i||i&&i.state&Y)&&(i=t.curRecognizer=null);for(var a=0;a<r.length;)n=r[a],t.stopped!==vt&&(!i||n==i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&(q|ot|J)&&(i=t.curRecognizer=n),a++}},get:function(e){if(e instanceof Z)return e;for(var t=this.recognizers,n=0;n<t.length;n++)if(t[n].options.event==e)return t[n];return null},add:function(e){if(d(e,`add`,this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e},remove:function(e){if(d(e,`remove`,this))return this;if(e=this.get(e),e){var t=this.recognizers,n=E(t,e);n!==-1&&(t.splice(n,1),this.touchAction.update())}return this},on:function(e,t){if(e!==r&&t!==r){var n=this.handlers;return f(T(e),function(e){n[e]=n[e]||[],n[e].push(t)}),this}},off:function(e,t){if(e!==r){var n=this.handlers;return f(T(e),function(e){t?n[e]&&n[e].splice(E(n[e],t),1):delete n[e]}),this}},emit:function(e,t){this.options.domEvents&&xt(e,t);var n=this.handlers[e]&&this.handlers[e].slice();if(!(!n||!n.length)){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var r=0;r<n.length;)n[r](t),r++}},destroy:function(){this.element&&bt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function bt(e,t){var n=e.element;if(n.style){var r;f(e.options.cssProps,function(i,a){r=k(n.style,a),t?(e.oldCssProps[r]=n.style[r],n.style[r]=i):n.style[r]=e.oldCssProps[r]||``}),t||(e.oldCssProps={})}}function xt(e,n){var r=t.createEvent(`Event`);r.initEvent(e,!0,!0),r.gesture=n,n.target.dispatchEvent(r)}return m(gt,{INPUT_START:P,INPUT_MOVE:F,INPUT_END:I,INPUT_CANCEL:L,STATE_POSSIBLE:at,STATE_BEGAN:q,STATE_CHANGED:ot,STATE_ENDED:J,STATE_RECOGNIZED:Y,STATE_CANCELLED:st,STATE_FAILED:X,DIRECTION_NONE:R,DIRECTION_LEFT:ce,DIRECTION_RIGHT:z,DIRECTION_UP:B,DIRECTION_DOWN:le,DIRECTION_HORIZONTAL:V,DIRECTION_VERTICAL:H,DIRECTION_ALL:ue,Manager:yt,Input:U,TouchAction:nt,TouchInput:He,MouseInput:ke,PointerEventInput:Pe,TouchMouseInput:We,SingleTouchInput:Re,Recognizer:Z,AttrRecognizer:Q,Tap:ht,Pan:dt,Swipe:mt,Pinch:ft,Rotate:pt,Press:$,on:x,off:S,each:f,merge:g,extend:h,assign:m,inherit:_,bindFn:v,prefixed:k}),gt})(typeof window<`u`?window:{},typeof document<`u`?document:{},`Hammer`),j=function(e,t){t===void 0&&console.warn(`THREE.OrbitControls: The second parameter "domElement" is now mandatory.`),t===document&&console.error(`THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.`),this.object=e,this.domElement=t,this.enabled=!0,this.target=new l.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN},this.touches={ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return u.phi},this.getAzimuthalAngle=function(){return u.theta},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),s=o.NONE},this.update=function(){var t=new l.Vector3,i=new l.Quaternion().setFromUnitVectors(e.up,new l.Vector3(0,1,0)),a=i.clone().inverse(),h=new l.Vector3,g=new l.Quaternion;return function(){var e=n.object.position;return t.copy(e).sub(n.target),t.applyQuaternion(i),u.setFromVector3(t),n.autoRotate&&s===o.NONE&&E(w()),n.enableDamping?(u.theta+=d.theta*n.dampingFactor,u.phi+=d.phi*n.dampingFactor):(u.theta+=d.theta,u.phi+=d.phi),u.theta=Math.max(n.minAzimuthAngle,Math.min(n.maxAzimuthAngle,u.theta)),u.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,u.phi)),u.makeSafe(),u.radius*=f,u.radius=Math.max(n.minDistance,Math.min(n.maxDistance,u.radius)),n.enableDamping===!0?n.target.addScaledVector(p,n.dampingFactor):n.target.add(p),t.setFromSpherical(u),t.applyQuaternion(a),e.copy(n.target).add(t),n.object.lookAt(n.target),n.enableDamping===!0?(d.theta*=1-n.dampingFactor,d.phi*=1-n.dampingFactor,p.multiplyScalar(1-n.dampingFactor)):(d.set(0,0,0),p.set(0,0,0)),f=1,m||h.distanceToSquared(n.object.position)>c||8*(1-g.dot(n.object.quaternion))>c?(n.dispatchEvent(r),h.copy(n.object.position),g.copy(n.object.quaternion),m=!1,!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener(`contextmenu`,he,!1),n.domElement.removeEventListener(`mousedown`,V,!1),n.domElement.removeEventListener(`wheel`,de,!1),n.domElement.removeEventListener(`touchstart`,U,!1),n.domElement.removeEventListener(`touchend`,me,!1),n.domElement.removeEventListener(`touchmove`,pe,!1),document.removeEventListener(`mousemove`,H,!1),document.removeEventListener(`mouseup`,ue,!1),n.domElement.removeEventListener(`keydown`,fe,!1)};var n=this,r={type:`change`},i={type:`start`},a={type:`end`},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},s=o.NONE,c=1e-6,u=new l.Spherical,d=new l.Spherical,f=1,p=new l.Vector3,m=!1,h=new l.Vector2,g=new l.Vector2,_=new l.Vector2,v=new l.Vector2,y=new l.Vector2,b=new l.Vector2,x=new l.Vector2,S=new l.Vector2,C=new l.Vector2;function w(){return 2*Math.PI/60/60*n.autoRotateSpeed}function T(){return Math.pow(.95,n.zoomSpeed)}function E(e){d.theta-=e}function D(e){d.phi-=e}var O=function(){var e=new l.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),p.add(e)}}(),k=function(){var e=new l.Vector3;return function(t,r){n.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),p.add(e)}}(),A=function(){var e=new l.Vector3;return function(t,r){var i=n.domElement;if(n.object.isPerspectiveCamera){var a=n.object.position;e.copy(a).sub(n.target);var o=e.length();o*=Math.tan(n.object.fov/2*Math.PI/180),O(2*t*o/i.clientHeight,n.object.matrix),k(2*r*o/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(O(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),k(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),n.enablePan=!1)}}();function ee(e){n.object.isPerspectiveCamera?f/=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),m=!0):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function j(e){n.object.isPerspectiveCamera?f*=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),m=!0):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function te(e){h.set(e.clientX,e.clientY)}function ne(e){x.set(e.clientX,e.clientY)}function re(e){v.set(e.clientX,e.clientY)}function ie(e){g.set(e.clientX,e.clientY),_.subVectors(g,h).multiplyScalar(n.rotateSpeed);var t=n.domElement;E(2*Math.PI*_.x/t.clientHeight),D(2*Math.PI*_.y/t.clientHeight),h.copy(g),n.update()}function M(e){S.set(e.clientX,e.clientY),C.subVectors(S,x),C.y>0?ee(T()):C.y<0&&j(T()),x.copy(S),n.update()}function ae(e){y.set(e.clientX,e.clientY),b.subVectors(y,v).multiplyScalar(n.panSpeed),A(b.x,b.y),v.copy(y),n.update()}function N(e){e.deltaY<0?j(T()):e.deltaY>0&&ee(T()),n.update()}function oe(e){var t=!1;switch(e.keyCode){case n.keys.UP:A(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:A(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:A(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:A(-n.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),n.update())}function se(e){if(e.touches.length==1)h.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);h.set(t,n)}}function P(e){if(e.touches.length==1)v.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);v.set(t,n)}}function F(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+n*n);x.set(0,r)}function I(e){n.enableZoom&&F(e),n.enablePan&&P(e)}function L(e){n.enableZoom&&F(e),n.enableRotate&&se(e)}function R(e){if(e.touches.length==1)g.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),r=.5*(e.touches[0].pageY+e.touches[1].pageY);g.set(t,r)}_.subVectors(g,h).multiplyScalar(n.rotateSpeed);var i=n.domElement;E(2*Math.PI*_.x/i.clientHeight),D(2*Math.PI*_.y/i.clientHeight),h.copy(g)}function ce(e){if(e.touches.length==1)y.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),r=.5*(e.touches[0].pageY+e.touches[1].pageY);y.set(t,r)}b.subVectors(y,v).multiplyScalar(n.panSpeed),A(b.x,b.y),v.copy(y)}function z(e){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);S.set(0,i),C.set(0,Math.pow(S.y/x.y,n.zoomSpeed)),ee(C.y),x.copy(S)}function B(e){n.enableZoom&&z(e),n.enablePan&&ce(e)}function le(e){n.enableZoom&&z(e),n.enableRotate&&R(e)}function V(e){if(n.enabled!==!1){e.preventDefault(),n.domElement.focus?n.domElement.focus():window.focus();var t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;ne(e),s=o.DOLLY;break;case l.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enablePan===!1)return;re(e),s=o.PAN}else{if(n.enableRotate===!1)return;te(e),s=o.ROTATE}break;case l.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enableRotate===!1)return;te(e),s=o.ROTATE}else{if(n.enablePan===!1)return;re(e),s=o.PAN}break;default:s=o.NONE}s!==o.NONE&&(document.addEventListener(`mousemove`,H,!1),document.addEventListener(`mouseup`,ue,!1),n.dispatchEvent(i))}}function H(e){if(n.enabled!==!1)switch(e.preventDefault(),s){case o.ROTATE:if(n.enableRotate===!1)return;ie(e);break;case o.DOLLY:if(n.enableZoom===!1)return;M(e);break;case o.PAN:if(n.enablePan===!1)return;ae(e);break}}function ue(e){n.enabled!==!1&&(document.removeEventListener(`mousemove`,H,!1),document.removeEventListener(`mouseup`,ue,!1),n.dispatchEvent(a),s=o.NONE)}function de(e){n.enabled===!1||n.enableZoom===!1||s!==o.NONE&&s!==o.ROTATE||(e.preventDefault(),e.stopPropagation(),n.dispatchEvent(i),N(e),n.dispatchEvent(a))}function fe(e){n.enabled===!1||n.enableKeys===!1||n.enablePan===!1||oe(e)}function U(e){if(n.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;se(e),s=o.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;P(e),s=o.TOUCH_PAN;break;default:s=o.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;I(e),s=o.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;L(e),s=o.TOUCH_DOLLY_ROTATE;break;default:s=o.NONE}break;default:s=o.NONE}s!==o.NONE&&n.dispatchEvent(i)}}function pe(e){if(n.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),s){case o.TOUCH_ROTATE:if(n.enableRotate===!1)return;R(e),n.update();break;case o.TOUCH_PAN:if(n.enablePan===!1)return;ce(e),n.update();break;case o.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;B(e),n.update();break;case o.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;le(e),n.update();break;default:s=o.NONE}}function me(e){n.enabled!==!1&&(n.dispatchEvent(a),s=o.NONE)}function he(e){n.enabled!==!1&&e.preventDefault()}n.domElement.addEventListener(`contextmenu`,he,!1),n.domElement.addEventListener(`mousedown`,V,!1),n.domElement.addEventListener(`wheel`,de,!1),n.domElement.addEventListener(`touchstart`,U,!1),n.domElement.addEventListener(`touchend`,me,!1),n.domElement.addEventListener(`touchmove`,pe,!1),n.domElement.addEventListener(`keydown`,fe,!1),n.domElement.tabIndex===-1&&(n.domElement.tabIndex=0),this.update()};j.prototype=Object.create(l.EventDispatcher.prototype),j.prototype.constructor=j;var te=function(e,t){j.call(this,e,t),this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE};te.prototype=Object.create(l.EventDispatcher.prototype),te.prototype.constructor=te;var ne=new l.Vector3,re=new l.Quaternion,ie=new l.Vector3,M=class extends l.Object3D{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}},ae=class extends M{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}},N=new l.Matrix4,oe=new l.Matrix4,se=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),N.copy(r.matrixWorldInverse),N.transpose(),e.rotation2D!==0&&N.multiply(oe.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(ne,re,ie),N.setPosition(ne),N.scale(ie),N.elements[3]=0,N.elements[7]=0,N.elements[11]=0,N.elements[15]=1;let i=h(N),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.autoUpdate===!0&&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?(N.copy(r.matrixWorldInverse),N.transpose(),e.rotation2D!==0&&N.multiply(oe.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(ne,re,ie),N.setPosition(ne),N.scale(ie),N.elements[3]=0,N.elements[7]=0,N.elements[11]=0,N.elements[15]=1,i=h(N)):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)}}};function P(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 l.Vector2((e.x-i)/a*2-1,-(e.y-r)/o*2+1)}var F=class extends l.BufferGeometry{constructor(e,t,n,r,i){super(),this.type=`RoundedBoxGeometry`,i=isNaN(i)?1:Math.max(1,Math.floor(i)),e=isNaN(e)?1:e,t=isNaN(t)?1:t,n=isNaN(n)?1:n,r=isNaN(r)?.15:r,r=Math.min(r,Math.min(e,Math.min(t,Math.min(n)))/2);let a=e/2-r,o=t/2-r,s=n/2-r;this.parameters={width:e,height:t,depth:n,radius:r,radiusSegments:i};let c=i+1,u=c*i+1<<3,d=new l.BufferAttribute(new Float32Array(u*3),3),f=new l.BufferAttribute(new Float32Array(u*3),3),p=[],m=[];new l.Vector3;let h=new l.Vector3,g=[],_=[],v=[],y=c*i,b=c*i+1;x(),C(),S(),w(),E(),T();function x(){let e=[new l.Vector3(1,1,1),new l.Vector3(1,1,-1),new l.Vector3(-1,1,-1),new l.Vector3(-1,1,1),new l.Vector3(1,-1,1),new l.Vector3(1,-1,-1),new l.Vector3(-1,-1,-1),new l.Vector3(-1,-1,1)];for(let e=0;e<8;e++)p.push([]),m.push([]);let t=Math.PI/2,n=new l.Vector3(a,o,s);for(let e=0;e<=i;e++){let a=e/i*t,o=Math.cos(a),s=Math.sin(a);if(e==i){h.set(0,1,0);let e=h.clone().multiplyScalar(r).add(n);p[0].push(e),g.push(e);let t=h.clone();m[0].push(t),_.push(t);continue}for(let e=0;e<=i;e++){let a=e/i*t;h.x=o*Math.cos(a),h.y=s,h.z=o*Math.sin(a);let c=h.clone().multiplyScalar(r).add(n);p[0].push(c),g.push(c);let l=h.clone().normalize();m[0].push(l),_.push(l)}}for(let t=1;t<8;t++)for(let n=0;n<p[0].length;n++){let r=p[0][n].clone().multiply(e[t]);p[t].push(r),g.push(r);let i=m[0][n].clone().multiply(e[t]);m[t].push(i),_.push(i)}}function S(){let e=[!0,!1,!0,!1,!1,!0,!1,!0],t=c*(i-1);for(let n=0;n<8;n++){let r=b*n;for(let t=0;t<i-1;t++){let a=t*c,o=(t+1)*c;for(let t=0;t<i;t++){let i=t+1,s=r+a+t,c=r+a+i,l=r+o+t,u=r+o+i;e[n]?(v.push(s),v.push(l),v.push(c),v.push(c),v.push(l),v.push(u)):(v.push(s),v.push(c),v.push(l),v.push(c),v.push(u),v.push(l))}}for(let a=0;a<i;a++){let i=r+t+a,o=r+t+a+1,s=r+y;e[n]?(v.push(i),v.push(s),v.push(o)):(v.push(i),v.push(o),v.push(s))}}}function C(){let e=y,t=y+b,n=y+b*2,r=y+b*3;v.push(e),v.push(t),v.push(n),v.push(e),v.push(n),v.push(r),e=y+b*4,t=y+b*5,n=y+b*6,r=y+b*7,v.push(e),v.push(n),v.push(t),v.push(e),v.push(r),v.push(n),e=0,t=b,n=b*4,r=b*5,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r),e=b*2,t=b*3,n=b*6,r=b*7,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r),e=i,t=i+b*3,n=i+b*4,r=i+b*7,v.push(e),v.push(t),v.push(n),v.push(t),v.push(r),v.push(n),e=i+b,t=i+b*2,n=i+b*5,r=i+b*6,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r)}function w(){for(let e=0;e<4;e++){let t=e*b,n=4*b+t,r=(e&1)==1;for(let e=0;e<i;e++){let i=e+1,a=t+e,o=t+i,s=n+e,c=n+i;r?(v.push(a),v.push(s),v.push(o),v.push(o),v.push(s),v.push(c)):(v.push(a),v.push(o),v.push(s),v.push(o),v.push(c),v.push(s))}}}function T(){let e=[0,2,4,6],t=[1,3,5,7];for(let n=0;n<4;n++){let r=b*e[n],a=b*t[n],o=1>=n;for(let e=0;e<i;e++){let t=e*c,n=(e+1)*c,i=r+t,s=r+n,l=a+t,u=a+n;o?(v.push(i),v.push(l),v.push(s),v.push(s),v.push(l),v.push(u)):(v.push(i),v.push(s),v.push(l),v.push(s),v.push(u),v.push(l))}}}function E(){let e=i-1,t=[0,1,4,5],n=[3,2,7,6],r=[0,1,1,0];for(let a=0;a<4;a++){let o=t[a]*b,s=n[a]*b;for(let t=0;t<=e;t++){let n=o+i+t*c,l=o+(t==e?b-1:i+(t+1)*c),u=s+i+t*c,d=s+(t==e?b-1:i+(t+1)*c);r[a]?(v.push(n),v.push(u),v.push(l),v.push(l),v.push(u),v.push(d)):(v.push(n),v.push(l),v.push(u),v.push(l),v.push(d),v.push(u))}}}let D=0;for(let e=0;e<g.length;e++)d.setXYZ(D,g[e].x,g[e].y,g[e].z),f.setXYZ(D,_[e].x,_[e].y,_[e].z),D++;this.setIndex(new l.BufferAttribute(new Uint16Array(v),1)),this.setAttribute(`position`,d),this.setAttribute(`normal`,f)}};function I(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function L(e,t,n,r=e=>e){let i=r(n);return e*(1-i)+t*i}var R=Number((Math.PI/2).toFixed(5));function ce(e,t,n){let r=new l.Shape;return r.moveTo(n,0),r.lineTo(e-n,0),r.absarc(e-n,n,n,-R,0,!1),r.lineTo(e,t-n),r.absarc(e-n,t-n,n,0,R,!1),r.lineTo(n,t),r.absarc(n,t-n,n,R,Math.PI,!1),r.lineTo(0,n),r.absarc(n,n,n,Math.PI,Math.PI*1.5,!1),r}var z=e=>{let t=document.createElement(`div`);t.innerText=e;let n=new M(t);return n.name=e,n.scale.set(.3,.3,.3),t.style.pointerEvents=`none`,t.style.backfaceVisibility=`hidden`,n},B=e=>{let t=new l.PlaneGeometry(5,5),n=new l.MeshBasicMaterial({transparent:!0,opacity:0}),r=new l.Mesh(t,n),i=document.createElement(`div`);i.innerText=e;let a=new M(i);return a.name=e,a.scale.set(.3,.3,.3),i.style.color=`#ffffff`,i.style.opacity=`0.5`,i.style.pointerEvents=`none`,i.style.backfaceVisibility=`hidden`,r.rotateX(-R),r.add(a),r},le=class extends p.Controller{get config(){return Object.assign({},this._config)}updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),typeof e.arrowsVisible==`boolean`&&this.handleArrowsVisible(e.arrowsVisible),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){super(e),this.camera=new c.Camera(90),this.scene=new l.Scene,this.renderer=new l.WebGLRenderer({antialias:!0,alpha:!0}),this.css3drenderer=new se,this.ambientLight=new l.AmbientLight(16777215,.7),this.wrapper=document.createElement(`div`),this.arrows=document.createElement(`div`),this.arrowLeft=document.createElement(`div`),this.arrowRight=document.createElement(`div`),this.arrowFront=document.createElement(`div`),this.arrowBack=document.createElement(`div`),this.arrowTop=document.createElement(`div`),this.arrowBottom=document.createElement(`div`),this.spherical=null,this.dragging=!1,this.style=document.createElement(`style`),this.directionalLight=new l.DirectionalLight(16777215,.2),this.box=new l.Mesh(new F(8,8,8,.5,20),new l.MeshPhongMaterial({color:16777215})),this.faces=new l.Group,this.orient=({longitude:e,latitude:t})=>{this.dragging=!1,this.spherical=null,this.controls.enableDamping=!1,this.five.setState(Object.assign({latitude:t},e===void 0?{}:{longitude:e+this.config.fixedLongitude})),this.five.ready().then(()=>{this.controls.enableDamping=!0,this.setState({arrowsVisible:!0})})},this.onRenderFrame=()=>{var e,t,n,r,i;if(this.renderer.render(this.scene,this.camera),this.css3drenderer.render(this.scene,this.camera),this.directionalLight.position.copy(this.camera.position),(e=this.controls)==null||e.update(),this.dragging){this.camera.computePose(),this.updateByCamera();let{longitude:e,latitude:t}=this.camera.pose;this.five.setState({longitude:e,latitude:t},!0),this.updateArrows({longitude:e,latitude:t})}else if(this.spherical&&(!I(this.spherical.pi,(t=this.controls)==null?void 0:t.getPolarAngle())||!I(this.spherical.theta,(n=this.controls)==null?void 0:n.getAzimuthalAngle()))){this.spherical={pi:(r=this.controls)==null?void 0:r.getPolarAngle(),theta:(i=this.controls)==null?void 0:i.getAzimuthalAngle()},this.camera.computePose(),this.updateByCamera();let{longitude:e,latitude:t}=this.camera.pose;this.five.setState({longitude:e,latitude:t},!0),this.updateArrows({longitude:e,latitude:t})}else this.spherical=null},this.onTapGesture=e=>{let t=e.pointers[0].clientX,n=e.pointers[0].clientY,r=P({x:t,y:n},this.wrapper),i=new l.Raycaster;i.setFromCamera(r,this.camera);let[a]=i.intersectObjects(this.faces.children,!1);if(a){let{longitude:e,latitude:t}=a.object.userData;this.orient({longitude:e,latitude:t})}},this.onFiveWantsGesture=()=>{if(this.spherical)return!1},this.onFiveModeChange=e=>{this.controls&&(this.controls.maxPolarAngle=e===`Topview`?0:R)},this.onCameraUpdate=({state:e})=>{if(this.dragging||this.spherical)return;let{longitude:t,latitude:n}=e;this.camera.pose.longitude===t&&this.camera.pose.latitude===n||(this.camera.setFromPose({longitude:t,latitude:n,distance:20,offset:new l.Vector3(0,0,0)}),this.updateByCamera(),this.updateArrows({longitude:t,latitude:n}))},this.onPanStart=e=>{this.dragging=!0,this.spherical={}},this.onMouseMove=e=>{if(this.dragging)return;let t=P({x:e.clientX,y:e.clientY},this.wrapper),n=new l.Raycaster;n.setFromCamera(t,this.camera);let[r]=n.intersectObjects(this.faces.children,!1);this.faces.children.forEach(e=>{e.material.opacity=0,e.children[0].element.style.color=``}),r&&(r.object.material.opacity=.3,r.object.children[0].element.style.color=`#336dff`)},this.onPanEnd=e=>{this.dragging=!1,this.spherical={pi:this.controls.getPolarAngle(),theta:this.controls.getAzimuthalAngle()}},this.dispose=()=>{this.disable()},this.five=e,this.state=Object.assign({enabled:!1,visible:!0,arrowsVisible:!1},t==null?void 0:t.initialState),this._config=Object.assign({fixedLongitude:0,orthoView:!0},t==null?void 0:t.config),this.state.enabled&&this._enable({userAction:!1}),this.mc=new ee.Manager(this.wrapper),this.mc.add(new ee.Tap({interval:410})),this.mc.add(new ee.Pan({threshold:10,pointers:0})),this.camera.setFromPose({distance:20,offset:new l.Vector3(0,0,0),longitude:e.camera.pose.latitude,latitude:e.camera.pose.latitude}),this.cylinder=new l.Mesh(new l.CylinderGeometry(13.2,14,.01,50,1,!0),new l.ShaderMaterial({uniforms:{radiusTop:{value:13.2},radiusBottom:{value:14},opacity:{value:1}},vertexShader:`
|
|
357
353
|
varying vec3 pos;
|
|
358
354
|
varying mat4 vViewMatrix;
|
|
359
355
|
void main() {
|
|
@@ -383,7 +379,7 @@ void main() {
|
|
|
383
379
|
vec4 color = mix(color1, color2, z);
|
|
384
380
|
gl_FragColor = color;
|
|
385
381
|
}
|
|
386
|
-
`,transparent:!0})),
|
|
382
|
+
`,transparent:!0})),this.init()}appendTo(e){if(!e)return;e.appendChild(this.wrapper);let{width:t,height:n}=this.wrapper.getBoundingClientRect();this.renderer.setSize(t,n),this.css3drenderer.setSize(t,n)}init(){this.renderer.setClearAlpha(0),this.renderer.domElement.style.outline=`none`,this.initDom(),this.initFaces(),this.initControls(),this.initLights();let e=this.cylinder;e.position.y=-3;let t=B(`西`);t.position.set(-19,0,0),e.add(t);let n=B(`东`);n.position.set(19,0,0),e.add(n);let r=B(`北`);r.position.set(0,0,-19),e.add(r);let i=B(`南`);i.position.set(0,0,19),e.add(i),this.updateByCamera(),this.scene.add(e,this.box,this.faces),this.scene.rotation.y=this.config.fixedLongitude}initDom(){this.style.innerHTML=`
|
|
387
383
|
.OrientationPlugin .OrientationArrows {
|
|
388
384
|
position: absolute;
|
|
389
385
|
top: 0;
|
|
@@ -483,7 +479,7 @@ void main() {
|
|
|
483
479
|
border-color: transparent transparent var(--color) transparent;
|
|
484
480
|
transform: translate(0, -15px);
|
|
485
481
|
}
|
|
486
|
-
`,this.wrapper.className
|
|
482
|
+
`,this.wrapper.className=`OrientationPlugin`,this.arrows.className=`OrientationArrows`,this.wrapper.style.cssText=`position: relative; width: 100%; height: 100%`,this.wrapper.appendChild(this.arrows),this.arrowLeft.className=this.arrowRight.className=this.arrowTop.className=this.arrowBack.className=this.arrowFront.className=`OrientationArrow`,this.arrowBottom.className=`OrientationArrow disabled`,this.arrowBack.innerText=`后`,this.arrowFront.innerText=`前`,this.arrowLeft.innerText=`左`,this.arrowRight.innerText=`右`,this.arrowTop.innerText=`上`,this.arrowBottom.innerText=`下`,this.css3drenderer.domElement.style.cssText=`position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; color: #00000090;`}bindEvents(){this.five.on(`renderFrame`,this.onRenderFrame),this.five.on(`camera.update`,this.onCameraUpdate),this.five.on(`wantsGesture`,this.onFiveWantsGesture),this.five.on(`modeChange`,this.onFiveModeChange),this.mc.on(`tap`,this.onTapGesture),this.mc.on(`panstart`,this.onPanStart),this.mc.on(`panend`,this.onPanEnd),this.wrapper.addEventListener(`mousemove`,this.onMouseMove),this.arrowTop.onclick=()=>this.orient({longitude:0,latitude:R}),this.arrowLeft.onclick=()=>this.orient({longitude:-R,latitude:0}),this.arrowRight.onclick=()=>this.orient({longitude:R,latitude:0}),this.arrowFront.onclick=()=>this.orient({longitude:0,latitude:0}),this.arrowBack.onclick=()=>this.orient({longitude:Math.PI,latitude:0})}unbindEvents(){this.five.off(`renderFrame`,this.onRenderFrame),this.five.off(`camera.update`,this.onCameraUpdate),this.five.off(`wantsGesture`,this.onFiveWantsGesture),this.five.off(`modeChange`,this.onFiveModeChange),this.mc.off(`tap`,this.onTapGesture),this.mc.off(`panstart`,this.onPanStart),this.mc.off(`panend`,this.onPanEnd),this.wrapper.removeEventListener(`mousemove`,this.onMouseMove),this.arrowTop.onclick=null,this.arrowLeft.onclick=null,this.arrowRight.onclick=null,this.arrowFront.onclick=null,this.arrowBack.onclick=null}updateByCamera(){let e=L(.2,1,this.camera.pose.latitude/Math.PI*2,e=>e*e),t=L(11,13,this.camera.pose.latitude/Math.PI*2,e=>e*e),n=L(12,15,this.camera.pose.latitude/Math.PI*2,e=>e*e),r=L(13,19,this.camera.pose.latitude/Math.PI*2,e=>e*e),i=L(-.2,.5,this.camera.pose.latitude/Math.PI*2,e=>e*e);this.cylinder.geometry=new l.CylinderGeometry(t,n,.01,50,1,!0),this.cylinder.material.uniforms.radiusTop.value=t,this.cylinder.material.uniforms.radiusBottom.value=n,this.cylinder.material.needsUpdate=!0,this.cylinder.children.forEach(t=>{t.position.normalize().multiplyScalar(r),t.scale.set(e,e,e);let n=t.children[0];n&&(n.element.style.opacity=i.toString())}),this.css3drenderer.markDirty()}updateArrows({longitude:e,latitude:t}){let n=R-t<.02;this.setState({arrowsVisible:n})}handleArrowsVisible(e){if(this.state.enabled)if(this.cylinder.material.uniforms.opacity.value=e?.4:1,this.cylinder.material.needsUpdate=!0,e){let{longitude:e,latitude:t}=this.five.getCurrentState();if(R-t<.03)this.five.state.mode===`Topview`||this.five.state.mode===`Mapview`?(this.faces.getObjectByName(`上`).element.className=`active`,this.arrows.innerHTML=``,this.arrows.appendChild(this.arrowBack),this.arrows.appendChild(this.arrowLeft),this.arrows.appendChild(this.arrowRight),this.arrows.appendChild(this.arrowFront),this.arrows.style.transform=`rotate(${(e-this.config.fixedLongitude)/Math.PI*180}deg)`):(this.arrows.innerHTML=``,this.faces.getObjectByName(`上`).element.className=``);else{switch(this.arrows.innerHTML=``,this.arrows.appendChild(this.arrowTop),this.config.orthoView&&this.five.ready().then(()=>{this.five.controller.cameraType=`orthographic`,this.five.ready().then(()=>this.five.controller.cameraMotion.ended=!1)}),!0){case I(0,e-this.config.fixedLongitude):this.arrows.appendChild(this.arrowLeft),this.arrows.appendChild(this.arrowRight),this.arrows.appendChild(this.arrowBottom),this.faces.getObjectByName(`前`).element.className=`active`;break;case I(R,e-this.config.fixedLongitude):this.arrows.appendChild(this.arrowFront),this.arrows.appendChild(this.arrowBack),this.arrows.appendChild(this.arrowBottom),this.faces.getObjectByName(`右`).element.className=`active`;break;case I(Math.PI,e-this.config.fixedLongitude):this.arrows.appendChild(this.arrowRight),this.arrows.appendChild(this.arrowLeft),this.arrows.appendChild(this.arrowBottom),this.faces.getObjectByName(`后`).element.className=`active`;break;default:this.arrows.appendChild(this.arrowBack),this.arrows.appendChild(this.arrowFront),this.arrows.appendChild(this.arrowBottom),this.faces.getObjectByName(`左`).element.className=`active`;break}this.arrows.style.transform=``}this.arrows.style.display=`block`}else this.config.orthoView&&(this.five.controller.cameraType=`auto`,this.five.ready().then(()=>this.five.controller.cameraMotion.ended=!1)),this.arrows.style.display=`none`,this.faces.children.forEach(e=>{e.children[0].element.className=``})}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)}}initLights(){this.directionalLight.target=this.box,this.scene.add(this.ambientLight,this.directionalLight)}initFaces(){let e=ce(7,7,.5),t=new l.ShapeGeometry(e);t.translate(-3.5,-3.5,0);let n=new l.Mesh(t,new l.MeshBasicMaterial({transparent:!0,color:3370495,opacity:0}));n.userData={longitude:0,latitude:0},n.position.z=4.1,n.add(z(`前`));let r=new l.Mesh(t,new l.MeshBasicMaterial({transparent:!0,color:3370495,opacity:0}));r.rotateY(Math.PI),r.position.z=-4.1,r.add(z(`后`)),r.userData={longitude:Math.PI,latitude:0};let i=new l.Mesh(t,new l.MeshBasicMaterial({transparent:!0,color:3370495,opacity:0}));i.rotateY(R),i.position.x=4.1,i.add(z(`右`)),i.userData={longitude:R,latitude:0};let a=new l.Mesh(t,new l.MeshBasicMaterial({transparent:!0,color:3370495,opacity:0}));a.rotateY(-R),a.position.x=-4.1,a.add(z(`左`)),a.userData={longitude:-R,latitude:0};let o=new l.Mesh(t,new l.MeshBasicMaterial({transparent:!0,color:3370495,opacity:0}));o.rotateX(-R),o.position.y=4.1,o.add(z(`上`)),o.userData={longitude:0,latitude:R},this.faces.add(n,r,a,i,o)}initControls(){let e=this.controls=new j(this.camera,this.renderer.domElement);e.enableZoom=!1,e.enableDamping=!0,e.enablePan=!1,e.maxPolarAngle=R,e.dampingFactor=.15,e.rotateSpeed=.25}load(e){return m(this,void 0,void 0,function*(){})}_enable(e){let{longitude:t,latitude:n}=this.five.getCurrentState();this.camera.setFromPose({longitude:t,latitude:n,distance:20,offset:new l.Vector3(0,0,0)}),this.updateByCamera(),this.wrapper.appendChild(this.renderer.domElement),this.wrapper.appendChild(this.css3drenderer.domElement),this.bindEvents()}_disable(e){this.wrapper.removeChild(this.renderer.domElement),this.wrapper.removeChild(this.css3drenderer.domElement),this.unbindEvents()}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),this._enable({userAction:n}),document.head.appendChild(this.style)}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}),document.head.removeChild(this.style)}},V=(e,t)=>new le(e,t),H=class extends u.BasePlugin.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=()=>m(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=`
|
|
487
483
|
.BackgroundPluginBg {
|
|
488
484
|
position: absolute;
|
|
489
485
|
top: 0;
|
|
@@ -504,7 +500,7 @@ void main() {
|
|
|
504
500
|
z-index: -1;
|
|
505
501
|
pointerEvents: none;
|
|
506
502
|
}
|
|
507
|
-
`,t.enable()),t}return s})(Mt.BasePlugin.Controller),Bn=function(v,s){return new Nn(v,s)};new p.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]);var bt=(function(){function v(s,e,n,t,r){this.R=s,this.Q=e,this.A=n,this.B=t,this.C=r,this.cov=NaN,this.x=NaN}return v.prototype.filter=function(s,e){if(e===void 0&&(e=0),isNaN(this.x))this.x=1/this.C*s,this.cov=1/this.C*this.Q*(1/this.C);else{var n=this.A*this.x+this.B*e,t=this.A*this.cov*this.A+this.R,r=t*this.C*(1/(this.C*t*this.C+this.Q));this.x=n+r*(s-this.C*n),this.cov=t-r*this.C*t}return this.x},v})(),Un=(function(v){ve(s,v);function s(e,n){var t=v.call(this,e)||this;t.dispose=function(){t.disable()},t.five=e;var r={enabled:!0,visible:!0};t.state=Object.assign(r,n==null?void 0:n.initialState);var l=B({},n==null?void 0:n.config);return t._config=l,t.state.enabled&&t._enable({userAction:!1}),t.cancelAnimation=null,t.skipStart=0,t.skipEnd=0,t.location=0,t.totalDistance=0,t.trajectory=null,t.currentKeyFrame=null,t.nextKeyframe=null,t.nextButOneKeyframe=null,t.keyframes=[],t.rate=t.config.rate||1,t.virualCamera=t.five.camera.clone(),t.playingState={keyframeIndex:null,progress:null},t.timeArray=null,t.startTimestamp=null,t.playbackStartTime=null,t.playbackEndTime=null,Object.defineProperties(t,{currentDistance:{get:function(){return this._currentDistance},set:function(i){this._currentDistance=i}}}),t}return Object.defineProperty(s.prototype,"config",{get:function(){return B({},this._config)},enumerable:!1,configurable:!0}),s.prototype.updateState=function(e,n){var t=this.state;this.state=B(B({},this.state),e),this.hooks.emit("stateChange",{state:this.state,prevState:t,userAction:n})},s.prototype.load=function(e){return Fe(this,void 0,void 0,function(){return Le(this,function(n){return[2]})})},s.prototype.loadTrajectory=function(e){this.trajectory=e,this.cancelAnimation&&this.cancelAnimation(),this.playingState.keyframeIndex=null,this.playingState.progress=null;var n=.01,t=.1,r=1,l=0,i=1,h=new bt(n,t,r,l,i),c=new bt(n,t,r,l,i),d=new bt(n,t,r,l,i);if(this.trajectory&&this.trajectory.content.loadState==="READY"){var y=this.trajectory.content.data.positionArray;this.timeArray=this.trajectory.content.data.timeArray;for(var M=new Float32Array(y.length/3),w=0;w<M.length;w++)if(w===0)M[w]=0;else{var P=new p.Vector3(y[w-3],y[w-2],y[w-1]),S=new p.Vector3(y[w],y[w+1],y[w+2]);M[w]=S.distanceTo(P)+M[w-1]}this.totalDistance=M[M.length-1];for(var w=0;w<M.length;w++){for(var O=new p.Vector3(0,0,0),E=0,b=w-5;b<w+6;b++)b>=0&&b<M.length&&(O.add(new p.Vector3(y[b*3],y[b*3+1],y[b*3+2])),E++);O.divideScalar(E).applyMatrix4(e.transform);var T=h.filter(O.x),f=c.filter(O.y),C=d.filter(O.z),x={position:new p.Vector3(T,f,C),location:M[w]};this.keyframes.push(x)}}else throw new Error("trajectory content is not ready")},s.prototype.setPlayingState=function(e){(e.keyframeIndex!==null||e.progress!==null)&&(this.cancelAnimation&&this.cancelAnimation(),this.playingState.keyframeIndex=e.keyframeIndex?e.keyframeIndex:this.playingState.keyframeIndex,this.playingState.progress=e.progress?e.progress:this.playingState.progress,this.play())},s.prototype._enable=function(e){},s.prototype.play=function(){var e=this,n=this.keyframes.length;if(n<2)throw new Error("keyframes length must be greater than 2");var t={keyframeIndex:null,progress:null};this.playingState.keyframeIndex!==null&&this.playingState.progress!==null?(t.keyframeIndex=this.playingState.keyframeIndex,t.progress=this.playingState.progress):this.playingState.keyframeIndex===null&&this.playingState.progress===null&&(this.playingState.keyframeIndex=this.skipStart,this.playingState.progress=0,this.virualCamera.position.copy(this.keyframes[this.playingState.keyframeIndex].position.clone()),this.virualCamera.lookAt(this.keyframes[1].position.clone()),this.virualCamera.computePose(),this.five.setState(B({},this.virualCamera.pose)));var r=this.playingState.keyframeIndex,l=0;this.cancelAnimation=be.AnimationFrameLoop.shared.add(function(i,h){if(r===n-1-e.skipEnd&&e.cancelAnimation){e.cancelAnimation();return}e.currentKeyFrame=e.keyframes[r],e.nextKeyframe=e.keyframes[r+1],r+2<=n-1?e.nextButOneKeyframe=e.keyframes[r+2]:e.nextButOneKeyframe=null;var c=e.currentKeyFrame.position.clone(),d=e.nextKeyframe.position.clone(),y=e.nextKeyframe.position.clone().sub(e.currentKeyFrame.position.clone()).normalize(),M=c.clone().add(y.clone().multiplyScalar(.01)),w=new p.Vector3;e.nextButOneKeyframe!==null?w=e.nextButOneKeyframe.position.clone().sub(e.nextKeyframe.position.clone()).normalize():w.copy(y);var P=d.clone().add(w.clone().multiplyScalar(.01));l+=h/1e3*e.rate;var S=l/c.distanceTo(d);S=S>=1?1:S,t.keyframeIndex!==null&&t.progress!==null&&(S=t.progress,t.keyframeIndex=null,t.progress=null);var O=c.clone().lerp(d,S),E=M.clone().lerp(P,S);e.virualCamera.position.copy(O),e.virualCamera.lookAt(E),e.virualCamera.updateMatrixWorld(),e.virualCamera.updateMatrix(),e.virualCamera.computePose(),e.five.setState(B({},e.virualCamera.pose)),e.location=e.keyframes[r].location+c.clone().distanceTo(O),S===1?(l=0,r++,e.playingState.keyframeIndex=r,e.playingState.progress=0):(e.playingState.keyframeIndex=r,e.playingState.progress=S)})},s.prototype.pause=function(){var e;if(this.cancelAnimation){if(this.playingState.keyframeIndex!==null&&this.playingState.keyframeIndex>=0&&this.playingState.keyframeIndex<this.keyframes.length){var n=this.playingState.keyframeIndex,t=(e=this.playingState.progress)!==null&&e!==void 0?e:0,r=this.keyframes[n],l=n+1<this.keyframes.length?this.keyframes[n+1]:r,i=r.position.clone(),h=l.position.clone(),c=i.clone().lerp(h,t),d=h.clone().sub(i).normalize(),y=c.clone().add(d.multiplyScalar(.01));this.virualCamera.position.copy(c),this.virualCamera.lookAt(y),this.virualCamera.updateMatrixWorld(),this.virualCamera.updateMatrix(),this.virualCamera.computePose(),this.five.setState(B({},this.virualCamera.pose))}else if(this.currentKeyFrame&&this.nextKeyframe){var i=this.currentKeyFrame.position.clone(),h=this.nextKeyframe.position.clone(),c=i.clone(),d=h.clone().sub(i).normalize(),y=c.clone().add(d.multiplyScalar(.01));this.virualCamera.position.copy(c),this.virualCamera.lookAt(y),this.virualCamera.updateMatrixWorld(),this.virualCamera.updateMatrix(),this.virualCamera.computePose(),this.five.setState(B({},this.virualCamera.pose))}this.cancelAnimation()}this.startTimestamp=null},s.prototype.playByTimestamp=function(){var e=this,n;if(!this.trajectory||!this.timeArray||this.timeArray.length===0)throw new Error("Trajectory or timeArray is not available");var t=this.keyframes.length;if(t<2)throw new Error("keyframes length must be greater than 2");this.cancelAnimation&&this.cancelAnimation();var r=this.skipStart,l=this.timeArray.length-1-this.skipEnd;if(r>=l||r<0||l>=this.timeArray.length)throw new Error("Invalid skipStart or skipEnd values");this.playbackStartTime=this.timeArray[r],this.playbackEndTime=this.timeArray[l],this.playbackEndTime-this.playbackStartTime;var i,h=0,c=null;if(this.playingState.keyframeIndex!==null&&this.playingState.keyframeIndex>=r&&this.playingState.keyframeIndex<t-this.skipEnd){i=this.playingState.keyframeIndex,h=(n=this.playingState.progress)!==null&&n!==void 0?n:0;var d=this.timeArray[i],y=i+1<this.timeArray.length?this.timeArray[i+1]:d,M=y-d;c=d+M*h}else i=this.skipStart,i>=t-1-this.skipEnd&&(i=t-1-this.skipEnd-1),i<0&&(i=0),c=null;var w=this.playbackStartTime;if(c!==null){var P=c-w;this.startTimestamp=Date.now()-P/this.rate}else this.startTimestamp=Date.now();if(h>0&&i+1<t){var S=this.keyframes[i].position.clone(),O=this.keyframes[i+1].position.clone(),E=S.clone().lerp(O,h),b=O.clone().sub(S).normalize(),T=E.clone().add(b.multiplyScalar(.01));this.virualCamera.position.copy(E),this.virualCamera.lookAt(T)}else this.virualCamera.position.copy(this.keyframes[i].position.clone()),i+1<t&&this.virualCamera.lookAt(this.keyframes[i+1].position.clone());this.virualCamera.computePose(),this.five.setState(B({},this.virualCamera.pose)),this.cancelAnimation=be.AnimationFrameLoop.shared.add(function(f,C){if(e.startTimestamp){var x=Date.now()-e.startTimestamp,F=w+x*e.rate;if(e.playbackEndTime&&F>=e.playbackEndTime){var j=t-1-e.skipEnd;if(j>0&&j<t){if(e.currentKeyFrame=e.keyframes[j-1],e.nextKeyframe=e.keyframes[j],e.virualCamera.position.copy(e.nextKeyframe.position.clone()),j+1<t)e.virualCamera.lookAt(e.keyframes[j+1].position.clone());else{var Y=e.nextKeyframe.position.clone().sub(e.currentKeyFrame.position.clone()).normalize();e.virualCamera.lookAt(e.nextKeyframe.position.clone().add(Y.multiplyScalar(.01)))}e.virualCamera.computePose(),e.five.setState(B({},e.virualCamera.pose))}e.cancelAnimation&&(e.cancelAnimation(),e.startTimestamp=null);return}var H=e.findKeyFrameByTimestamp(F);if(!(H===void 0||H>=t-1-e.skipEnd)&&(H!==i&&(i=H),!(i>=t-1-e.skipEnd)&&(e.currentKeyFrame=e.keyframes[i],e.nextKeyframe=e.keyframes[i+1],i+2<=t-1?e.nextButOneKeyframe=e.keyframes[i+2]:e.nextButOneKeyframe=null,!!e.timeArray))){var Z=e.timeArray[i],J=e.timeArray[i+1],R=J-Z,K=R>0?(F-Z)/R:0,L=Math.max(0,Math.min(1,K)),k=e.currentKeyFrame.position.clone(),I=e.nextKeyframe.position.clone(),N=e.nextKeyframe.position.clone().sub(e.currentKeyFrame.position.clone()).normalize(),W=k.clone().add(N.clone().multiplyScalar(.01)),ee=new p.Vector3;e.nextButOneKeyframe!==null?ee=e.nextButOneKeyframe.position.clone().sub(e.nextKeyframe.position.clone()).normalize():ee.copy(N);var Q=I.clone().add(ee.clone().multiplyScalar(.01)),U=k.clone().lerp(I,L),re=W.clone().lerp(Q,L);e.virualCamera.position.copy(U),e.virualCamera.lookAt(re),e.virualCamera.updateMatrixWorld(),e.virualCamera.updateMatrix(),e.virualCamera.computePose(),e.five.setState(B({},e.virualCamera.pose)),e.playingState.keyframeIndex=i,e.playingState.progress=L,e.location=e.keyframes[i].location+k.clone().distanceTo(U),e.playingState.keyframeIndex=i,e.playingState.progress=L}}})},s.prototype.findKeyFrameByLocation=function(e){if(this.keyframes.length!==0){for(var n=0,t=this.keyframes.length-1;n<=t;){var r=Math.floor((n+t)/2);if(this.keyframes[r].location===e)return r;this.keyframes[r].location<e?n=r+1:t=r-1}return{keyframeIndex:n-1,progress:0}}},s.prototype.findKeyFrameByTimestamp=function(e){if(!(!this.timeArray||this.timeArray.length===0||this.keyframes.length===0)){for(var n=0,t=this.timeArray.length-1,r=0,l=Math.abs(this.timeArray[0]-e);n<=t;){var i=Math.floor((n+t)/2),h=this.timeArray[i],c=Math.abs(h-e);if(c<l&&(l=c,r=i),h===e)return i;h<e?n=i+1:t=i-1}if(r>0){var d=Math.abs(this.timeArray[r-1]-e);d<l&&(r=r-1)}if(r<this.timeArray.length-1){var y=Math.abs(this.timeArray[r+1]-e);y<l&&(r=r+1)}return r}},s.prototype.resetPlayingState=function(){this.playingState.keyframeIndex=null,this.playingState.progress=null},s.prototype.getTotalTime=function(){if(!this.timeArray||this.timeArray.length===0)return null;var e=this.skipStart,n=this.timeArray.length-1-this.skipEnd;if(e>=n||e<0||n>=this.timeArray.length)return null;var t=this.timeArray[e],r=this.timeArray[n];return r-t},s.prototype.setPlayingStateByTimestamp=function(e){var n=this;if(!this.trajectory||!this.timeArray||this.timeArray.length===0)throw new Error("Trajectory or timeArray is not available");var t=this.keyframes.length;if(e<0||e>=t)throw new Error("Invalid keyframeIndex");this.cancelAnimation&&this.cancelAnimation();var r=this.skipStart,l=this.timeArray.length-1-this.skipEnd;if(r>=l||r<0||l>=this.timeArray.length)throw new Error("Invalid skipStart or skipEnd values");this.playbackStartTime=this.timeArray[r],this.playbackEndTime=this.timeArray[l];var i=this.timeArray[e],h=i-this.playbackStartTime;if(this.startTimestamp=Date.now()-h/this.rate,this.playingState.keyframeIndex=e,this.playingState.progress=0,this.virualCamera.position.copy(this.keyframes[e].position.clone()),e+1<t)this.virualCamera.lookAt(this.keyframes[e+1].position.clone());else if(e>0){var c=this.keyframes[e].position.clone().sub(this.keyframes[e-1].position.clone()).normalize();this.virualCamera.lookAt(this.keyframes[e].position.clone().add(c.multiplyScalar(.01)))}this.virualCamera.computePose(),this.five.setState(B({},this.virualCamera.pose));var d=this.playbackStartTime,y=e;this.cancelAnimation=be.AnimationFrameLoop.shared.add(function(M,w){if(!(n.timeArray===null||n.timeArray.length===0)&&n.startTimestamp){var P=Date.now()-n.startTimestamp,S=d+P*n.rate;if(n.playbackEndTime&&S>=n.playbackEndTime){var O=t-1-n.skipEnd;if(O>0&&O<t){if(n.currentKeyFrame=n.keyframes[O-1],n.nextKeyframe=n.keyframes[O],n.virualCamera.position.copy(n.nextKeyframe.position.clone()),O+1<t)n.virualCamera.lookAt(n.keyframes[O+1].position.clone());else{var E=n.nextKeyframe.position.clone().sub(n.currentKeyFrame.position.clone()).normalize();n.virualCamera.lookAt(n.nextKeyframe.position.clone().add(E.multiplyScalar(.01)))}n.virualCamera.computePose(),n.five.setState(B({},n.virualCamera.pose))}n.cancelAnimation&&(n.cancelAnimation(),n.startTimestamp=null);return}var b=n.findKeyFrameByTimestamp(S);if(!(b===void 0||b>=t-1-n.skipEnd)&&(b!==y&&(y=b),!(y>=t-1-n.skipEnd))){n.currentKeyFrame=n.keyframes[y],n.nextKeyframe=n.keyframes[y+1],y+2<=t-1?n.nextButOneKeyframe=n.keyframes[y+2]:n.nextButOneKeyframe=null;var T=n.currentKeyFrame.position.clone(),f=n.nextKeyframe.position.clone(),C=n.nextKeyframe.position.clone().sub(n.currentKeyFrame.position.clone()).normalize(),x=T.clone().add(C.clone().multiplyScalar(.01)),F=new p.Vector3;n.nextButOneKeyframe!==null?F=n.nextButOneKeyframe.position.clone().sub(n.nextKeyframe.position.clone()).normalize():F.copy(C);var j=f.clone().add(F.clone().multiplyScalar(.01)),Y=n.timeArray[y],H=n.timeArray[y+1],Z=H-Y,J=0;if(Z>0){var R=S-Y;J=Math.max(0,Math.min(1,R/Z))}var K=J*J*(3-2*J),L=T.clone().lerp(f,K),k=x.clone().lerp(j,K);n.virualCamera.position.copy(L),n.virualCamera.lookAt(k),n.virualCamera.computePose(),n.five.setState(B({},n.virualCamera.pose))}}})},s.prototype._disable=function(e){},s.prototype.enable=function(e){var n;if(!this.state.enabled){var t=(n=e==null?void 0:e.userAction)!==null&&n!==void 0?n:!0;this.updateState({enabled:!0},t),this._enable({userAction:t})}},s.prototype.disable=function(e){var n;if(this.state.enabled!==!1){var t=(n=e==null?void 0:e.userAction)!==null&&n!==void 0?n:!0;this.updateState({enabled:!1},t),this._disable({userAction:t})}},s})(exports.BasePlugin.Controller),Vn=function(v,s){return new Un(v,s)};function Yt(v,s,e){return v<s?s:v>e?e:v}var Rn=`
|
|
503
|
+
`,this.enable())}},ue=(e,t)=>new H(e,t);new l.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]);var de=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}},fe=class extends p.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})}constructor(e,t){super(e),this.dispose=()=>{this.disable()},this.five=e,this.state=Object.assign({enabled:!0,visible:!0},t==null?void 0:t.initialState),this._config=Object.assign({},t==null?void 0:t.config),this.state.enabled&&this._enable({userAction:!1}),this.cancelAnimation=null,this.skipStart=0,this.skipEnd=0,this.location=0,this.totalDistance=0,this.trajectory=null,this.currentKeyFrame=null,this.nextKeyframe=null,this.nextButOneKeyframe=null,this.keyframes=[],this.rate=this.config.rate||1,this.virualCamera=this.five.camera.clone(),this.playingState={keyframeIndex:null,progress:null},this.timeArray=null,this.startTimestamp=null,this.playbackStartTime=null,this.playbackEndTime=null,Object.defineProperties(this,{currentDistance:{get(){return this._currentDistance},set(e){this._currentDistance=e}}})}load(e){return m(this,void 0,void 0,function*(){})}loadTrajectory(e){this.trajectory=e,this.cancelAnimation&&this.cancelAnimation(),this.playingState.keyframeIndex=null,this.playingState.progress=null;let t=.01,n=.1,r=new de(t,n,1,0,1),i=new de(t,n,1,0,1),a=new de(t,n,1,0,1);if(this.trajectory&&this.trajectory.content.loadState===`READY`){let t=this.trajectory.content.data.positionArray;this.timeArray=this.trajectory.content.data.timeArray;let n=new Float32Array(t.length/3);for(let e=0;e<n.length;e++)if(e===0)n[e]=0;else{let r=new l.Vector3(t[e-3],t[e-2],t[e-1]);n[e]=new l.Vector3(t[e],t[e+1],t[e+2]).distanceTo(r)+n[e-1]}this.totalDistance=n[n.length-1];for(let o=0;o<n.length;o++){let s=new l.Vector3(0,0,0),c=0;for(let e=o-5;e<o+6;e++)e>=0&&e<n.length&&(s.add(new l.Vector3(t[e*3],t[e*3+1],t[e*3+2])),c++);s.divideScalar(c).applyMatrix4(e.transform);let u=r.filter(s.x),d=i.filter(s.y),f=a.filter(s.z),p={position:new l.Vector3(u,d,f),location:n[o]};this.keyframes.push(p)}}else throw Error(`trajectory content is not ready`)}setPlayingState(e){(e.keyframeIndex!==null||e.progress!==null)&&(this.cancelAnimation&&this.cancelAnimation(),this.playingState.keyframeIndex=e.keyframeIndex?e.keyframeIndex:this.playingState.keyframeIndex,this.playingState.progress=e.progress?e.progress:this.playingState.progress,this.play())}_enable(e){}play(){let e=this.keyframes.length;if(e<2)throw Error(`keyframes length must be greater than 2`);let t={keyframeIndex:null,progress:null};this.playingState.keyframeIndex!==null&&this.playingState.progress!==null?(t.keyframeIndex=this.playingState.keyframeIndex,t.progress=this.playingState.progress):this.playingState.keyframeIndex===null&&this.playingState.progress===null&&(this.playingState.keyframeIndex=this.skipStart,this.playingState.progress=0,this.virualCamera.position.copy(this.keyframes[this.playingState.keyframeIndex].position.clone()),this.virualCamera.lookAt(this.keyframes[1].position.clone()),this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose)));let n=this.playingState.keyframeIndex,r=0;this.cancelAnimation=c.AnimationFrameLoop.shared.add((i,a)=>{if(n===e-1-this.skipEnd&&this.cancelAnimation){this.cancelAnimation();return}this.currentKeyFrame=this.keyframes[n],this.nextKeyframe=this.keyframes[n+1],n+2<=e-1?this.nextButOneKeyframe=this.keyframes[n+2]:this.nextButOneKeyframe=null;let o=this.currentKeyFrame.position.clone(),s=this.nextKeyframe.position.clone(),c=this.nextKeyframe.position.clone().sub(this.currentKeyFrame.position.clone()).normalize(),u=o.clone().add(c.clone().multiplyScalar(.01)),d=new l.Vector3;this.nextButOneKeyframe===null?d.copy(c):d=this.nextButOneKeyframe.position.clone().sub(this.nextKeyframe.position.clone()).normalize();let f=s.clone().add(d.clone().multiplyScalar(.01));r+=a/1e3*this.rate;let p=r/o.distanceTo(s);p=p>=1?1:p,t.keyframeIndex!==null&&t.progress!==null&&(p=t.progress,t.keyframeIndex=null,t.progress=null);let m=o.clone().lerp(s,p),h=u.clone().lerp(f,p);this.virualCamera.position.copy(m),this.virualCamera.lookAt(h),this.virualCamera.updateMatrixWorld(),this.virualCamera.updateMatrix(),this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose)),this.location=this.keyframes[n].location+o.clone().distanceTo(m),p===1?(r=0,n++,this.playingState.keyframeIndex=n,this.playingState.progress=0):(this.playingState.keyframeIndex=n,this.playingState.progress=p)})}pause(){var e;if(this.cancelAnimation){if(this.playingState.keyframeIndex!==null&&this.playingState.keyframeIndex>=0&&this.playingState.keyframeIndex<this.keyframes.length){let t=this.playingState.keyframeIndex,n=(e=this.playingState.progress)==null?0:e,r=this.keyframes[t],i=t+1<this.keyframes.length?this.keyframes[t+1]:r,a=r.position.clone(),o=i.position.clone(),s=a.clone().lerp(o,n),c=o.clone().sub(a).normalize(),l=s.clone().add(c.multiplyScalar(.01));this.virualCamera.position.copy(s),this.virualCamera.lookAt(l),this.virualCamera.updateMatrixWorld(),this.virualCamera.updateMatrix(),this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose))}else if(this.currentKeyFrame&&this.nextKeyframe){let e=this.currentKeyFrame.position.clone(),t=this.nextKeyframe.position.clone(),n=e.clone(),r=t.clone().sub(e).normalize(),i=n.clone().add(r.multiplyScalar(.01));this.virualCamera.position.copy(n),this.virualCamera.lookAt(i),this.virualCamera.updateMatrixWorld(),this.virualCamera.updateMatrix(),this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose))}this.cancelAnimation()}this.startTimestamp=null}playByTimestamp(){var e;if(!this.trajectory||!this.timeArray||this.timeArray.length===0)throw Error(`Trajectory or timeArray is not available`);let t=this.keyframes.length;if(t<2)throw Error(`keyframes length must be greater than 2`);this.cancelAnimation&&this.cancelAnimation();let n=this.skipStart,r=this.timeArray.length-1-this.skipEnd;if(n>=r||n<0||r>=this.timeArray.length)throw Error(`Invalid skipStart or skipEnd values`);this.playbackStartTime=this.timeArray[n],this.playbackEndTime=this.timeArray[r],this.playbackEndTime-this.playbackStartTime;let i,a=0,o=null;if(this.playingState.keyframeIndex!==null&&this.playingState.keyframeIndex>=n&&this.playingState.keyframeIndex<t-this.skipEnd){i=this.playingState.keyframeIndex,a=(e=this.playingState.progress)==null?0:e;let t=this.timeArray[i];o=t+((i+1<this.timeArray.length?this.timeArray[i+1]:t)-t)*a}else i=this.skipStart,i>=t-1-this.skipEnd&&(i=t-1-this.skipEnd-1),i<0&&(i=0),o=null;let s=this.playbackStartTime;if(o!==null){let e=o-s;this.startTimestamp=Date.now()-e/this.rate}else this.startTimestamp=Date.now();if(a>0&&i+1<t){let e=this.keyframes[i].position.clone(),t=this.keyframes[i+1].position.clone(),n=e.clone().lerp(t,a),r=t.clone().sub(e).normalize(),o=n.clone().add(r.multiplyScalar(.01));this.virualCamera.position.copy(n),this.virualCamera.lookAt(o)}else this.virualCamera.position.copy(this.keyframes[i].position.clone()),i+1<t&&this.virualCamera.lookAt(this.keyframes[i+1].position.clone());this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose)),this.cancelAnimation=c.AnimationFrameLoop.shared.add((e,n)=>{if(!this.startTimestamp)return;let r=s+(Date.now()-this.startTimestamp)*this.rate;if(this.playbackEndTime&&r>=this.playbackEndTime){let e=t-1-this.skipEnd;if(e>0&&e<t){if(this.currentKeyFrame=this.keyframes[e-1],this.nextKeyframe=this.keyframes[e],this.virualCamera.position.copy(this.nextKeyframe.position.clone()),e+1<t)this.virualCamera.lookAt(this.keyframes[e+1].position.clone());else{let e=this.nextKeyframe.position.clone().sub(this.currentKeyFrame.position.clone()).normalize();this.virualCamera.lookAt(this.nextKeyframe.position.clone().add(e.multiplyScalar(.01)))}this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose))}this.cancelAnimation&&(this.cancelAnimation(),this.startTimestamp=null);return}let a=this.findKeyFrameByTimestamp(r);if(a===void 0||a>=t-1-this.skipEnd||(a!==i&&(i=a),i>=t-1-this.skipEnd)||(this.currentKeyFrame=this.keyframes[i],this.nextKeyframe=this.keyframes[i+1],i+2<=t-1?this.nextButOneKeyframe=this.keyframes[i+2]:this.nextButOneKeyframe=null,!this.timeArray))return;let o=this.timeArray[i],c=this.timeArray[i+1]-o,u=c>0?(r-o)/c:0,d=Math.max(0,Math.min(1,u)),f=this.currentKeyFrame.position.clone(),p=this.nextKeyframe.position.clone(),m=this.nextKeyframe.position.clone().sub(this.currentKeyFrame.position.clone()).normalize(),h=f.clone().add(m.clone().multiplyScalar(.01)),g=new l.Vector3;this.nextButOneKeyframe===null?g.copy(m):g=this.nextButOneKeyframe.position.clone().sub(this.nextKeyframe.position.clone()).normalize();let _=p.clone().add(g.clone().multiplyScalar(.01)),v=f.clone().lerp(p,d),y=h.clone().lerp(_,d);this.virualCamera.position.copy(v),this.virualCamera.lookAt(y),this.virualCamera.updateMatrixWorld(),this.virualCamera.updateMatrix(),this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose)),this.playingState.keyframeIndex=i,this.playingState.progress=d,this.location=this.keyframes[i].location+f.clone().distanceTo(v),this.playingState.keyframeIndex=i,this.playingState.progress=d})}findKeyFrameByLocation(e){if(this.keyframes.length===0)return;let t=0,n=this.keyframes.length-1;for(;t<=n;){let r=Math.floor((t+n)/2);if(this.keyframes[r].location===e)return r;this.keyframes[r].location<e?t=r+1:n=r-1}return{keyframeIndex:t-1,progress:0}}findKeyFrameByTimestamp(e){if(!this.timeArray||this.timeArray.length===0||this.keyframes.length===0)return;let t=0,n=this.timeArray.length-1,r=0,i=Math.abs(this.timeArray[0]-e);for(;t<=n;){let a=Math.floor((t+n)/2),o=this.timeArray[a],s=Math.abs(o-e);if(s<i&&(i=s,r=a),o===e)return a;o<e?t=a+1:n=a-1}return r>0&&Math.abs(this.timeArray[r-1]-e)<i&&--r,r<this.timeArray.length-1&&Math.abs(this.timeArray[r+1]-e)<i&&(r+=1),r}resetPlayingState(){this.playingState.keyframeIndex=null,this.playingState.progress=null}getTotalTime(){if(!this.timeArray||this.timeArray.length===0)return null;let e=this.skipStart,t=this.timeArray.length-1-this.skipEnd;if(e>=t||e<0||t>=this.timeArray.length)return null;let n=this.timeArray[e];return this.timeArray[t]-n}setPlayingStateByTimestamp(e){if(!this.trajectory||!this.timeArray||this.timeArray.length===0)throw Error(`Trajectory or timeArray is not available`);let t=this.keyframes.length;if(e<0||e>=t)throw Error(`Invalid keyframeIndex`);this.cancelAnimation&&this.cancelAnimation();let n=this.skipStart,r=this.timeArray.length-1-this.skipEnd;if(n>=r||n<0||r>=this.timeArray.length)throw Error(`Invalid skipStart or skipEnd values`);this.playbackStartTime=this.timeArray[n],this.playbackEndTime=this.timeArray[r];let i=this.timeArray[e]-this.playbackStartTime;if(this.startTimestamp=Date.now()-i/this.rate,this.playingState.keyframeIndex=e,this.playingState.progress=0,this.virualCamera.position.copy(this.keyframes[e].position.clone()),e+1<t)this.virualCamera.lookAt(this.keyframes[e+1].position.clone());else if(e>0){let t=this.keyframes[e].position.clone().sub(this.keyframes[e-1].position.clone()).normalize();this.virualCamera.lookAt(this.keyframes[e].position.clone().add(t.multiplyScalar(.01)))}this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose));let a=this.playbackStartTime,o=e;this.cancelAnimation=c.AnimationFrameLoop.shared.add((e,n)=>{if(this.timeArray===null||this.timeArray.length===0||!this.startTimestamp)return;let r=a+(Date.now()-this.startTimestamp)*this.rate;if(this.playbackEndTime&&r>=this.playbackEndTime){let e=t-1-this.skipEnd;if(e>0&&e<t){if(this.currentKeyFrame=this.keyframes[e-1],this.nextKeyframe=this.keyframes[e],this.virualCamera.position.copy(this.nextKeyframe.position.clone()),e+1<t)this.virualCamera.lookAt(this.keyframes[e+1].position.clone());else{let e=this.nextKeyframe.position.clone().sub(this.currentKeyFrame.position.clone()).normalize();this.virualCamera.lookAt(this.nextKeyframe.position.clone().add(e.multiplyScalar(.01)))}this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose))}this.cancelAnimation&&(this.cancelAnimation(),this.startTimestamp=null);return}let i=this.findKeyFrameByTimestamp(r);if(i===void 0||i>=t-1-this.skipEnd||(i!==o&&(o=i),o>=t-1-this.skipEnd))return;this.currentKeyFrame=this.keyframes[o],this.nextKeyframe=this.keyframes[o+1],o+2<=t-1?this.nextButOneKeyframe=this.keyframes[o+2]:this.nextButOneKeyframe=null;let s=this.currentKeyFrame.position.clone(),c=this.nextKeyframe.position.clone(),u=this.nextKeyframe.position.clone().sub(this.currentKeyFrame.position.clone()).normalize(),d=s.clone().add(u.clone().multiplyScalar(.01)),f=new l.Vector3;this.nextButOneKeyframe===null?f.copy(u):f=this.nextButOneKeyframe.position.clone().sub(this.nextKeyframe.position.clone()).normalize();let p=c.clone().add(f.clone().multiplyScalar(.01)),m=this.timeArray[o],h=this.timeArray[o+1]-m,g=0;if(h>0){let e=r-m;g=Math.max(0,Math.min(1,e/h))}let _=g*g*(3-2*g),v=s.clone().lerp(c,_),y=d.clone().lerp(p,_);this.virualCamera.position.copy(v),this.virualCamera.lookAt(y),this.virualCamera.computePose(),this.five.setState(Object.assign({},this.virualCamera.pose))})}_disable(e){}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),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})}},U=(e,t)=>new fe(e,t);function pe(e,t,n){return e<t?t:e>n?n:e}var me=`
|
|
508
504
|
varying vec2 vUv;
|
|
509
505
|
varying vec3 vPosition;
|
|
510
506
|
void main() {
|
|
@@ -512,7 +508,7 @@ void main() {
|
|
|
512
508
|
vPosition = position;
|
|
513
509
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
514
510
|
}
|
|
515
|
-
`,
|
|
511
|
+
`,he=`
|
|
516
512
|
varying vec2 vUv;
|
|
517
513
|
uniform sampler2D map;
|
|
518
514
|
uniform float progress;
|
|
@@ -531,7 +527,7 @@ void main() {
|
|
|
531
527
|
}
|
|
532
528
|
gl_FragColor.a = gl_FragColor.a * opacity;
|
|
533
529
|
}
|
|
534
|
-
`,
|
|
530
|
+
`,ge=[1,5,2,6,3,7,4,8,9,13,10,14,11,15,12,16],_e=512,ve=512,ye=128,be=class extends u.BasePlugin.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,t){super(e),this.group=new l.Group,this.mesh=(()=>{let e=new l.CylinderGeometry(.12,.12,1,32,1,!0);e.translate(0,.5,0);let t=new l.ShaderMaterial({vertexShader:me,fragmentShader:he,uniforms:{map:{value:new l.Texture},progress:{value:0},opacity:{value:0}},transparent:!0,depthTest:!1});return new l.Mesh(e,t)})(),this.panoMesh=new c.PanoCircleMesh({scale:1.5}),this.stop=()=>{},this.drawLine=(e,t)=>{if(!this.ctx)return;let n=(()=>{var t;return(_e/16|0)*((t=ge[e])==null?0:t)})(),r=(1-(t+e*150)%1200/1200)*(ve+ye),i=this.ctx.createLinearGradient(0,r-ye,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-ye,3,ye)},this.anime=e=>{if(!this.ctx||!this.startTime)return;this.ctx.clearRect(0,0,_e,ve);for(let t=0;t<16;t++)this.drawLine(t,e-this.startTime);let t=pe((e-this.startTime)/1e3,0,1),n=pe((e-this.startTime)/300,0,this.config.maxOpacity);this.panoMesh.setOpacity(n),this.mesh.material.uniforms.progress.value=t,this.mesh.material.uniforms.opacity.value=n,this.mesh.material.uniforms.map.value.needsUpdate=!0,this.five.needsRender=!0},this.dispose=()=>{this.disable()},this.five=e,this.state=Object.assign({enabled:!1,visible:!0},t==null?void 0:t.initialState),this._config=Object.assign(Object.assign({},t==null?void 0:t.config),{maxOpacity:1}),!(typeof document>`u`)&&(this.canvas=document.createElement(`canvas`),this.ctx=this.canvas.getContext(`2d`),this.canvas.width=_e,this.canvas.height=ve,this.ctx.shadowColor=`rgba(255,255,255,0.5)`,this.ctx.shadowBlur=6,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.mesh.material.uniforms.map.value=new l.CanvasTexture(this.canvas),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 m(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=c.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)}}},xe=(e,t)=>new be(e,t),Se=class extends l.InstancedBufferGeometry{constructor(){super(),this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new l.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new l.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;t=e instanceof Float32Array?e:Array.isArray(e)?new Float32Array(e):new Float32Array;let n=new l.InstancedInterleavedBuffer(t,6,1);return this.setAttribute(`instanceStart`,new l.InterleavedBufferAttribute(n,3,0)),this.setAttribute(`instanceEnd`,new l.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;t=e instanceof Float32Array?e:Array.isArray(e)?new Float32Array(e):new Float32Array;let n=new l.InstancedInterleavedBuffer(t,6,1);return this.setAttribute(`instanceColorStart`,new l.InterleavedBufferAttribute(n,3,0)),this.setAttribute(`instanceColorEnd`,new l.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new l.WireframeGeometry(e.geometry)),this}fromLineSegments(e){var t=e.geometry;if(t instanceof l.Geometry){let e=new l.BufferGeometry().fromGeometry(t);this.setPositions(e.attributes.position.array)}else t instanceof l.BufferGeometry&&this.setPositions(t.attributes.position.array);return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new l.Box3);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=new l.Box3;this.boundingBox.setFromBufferAttribute(e),n.setFromBufferAttribute(t),this.boundingBox.union(n)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new l.Sphere),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0,i=new l.Vector3;for(let a=0,o=e.count;a<o;a++)i.fromBufferAttribute(e,a),r=Math.max(r,n.distanceToSquared(i)),i.fromBufferAttribute(t,a),r=Math.max(r,n.distanceToSquared(i));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};Object.assign(Se.prototype,{isLineSegmentsGeometry:!0});var Ce={uniforms:l.UniformsUtils.merge([l.UniformsLib.common,l.UniformsLib.fog,{linewidth:{value:1},resolution:{value:new l.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},opacity:{value:1},totalLength:{value:1},animationProgress:{value:0},time:{value:0},waveAmp:{value:.15},waveFreq:{value:5},waveDir:{value:2},startOffset:{value:0},endOffset:{value:0},range:{value:.3}}]),vertexShader:`
|
|
535
531
|
#include <common>
|
|
536
532
|
#include <color_pars_vertex>
|
|
537
533
|
#include <fog_pars_vertex>
|
|
@@ -728,7 +724,7 @@ void main() {
|
|
|
728
724
|
#include <fog_fragment>
|
|
729
725
|
#include <premultiplied_alpha_fragment>
|
|
730
726
|
}
|
|
731
|
-
`},xt=(function(v){ve(s,v);function s(e){var n=v.call(this,{uniforms:p.UniformsUtils.clone(Tt.uniforms),vertexShader:Tt.vertexShader,fragmentShader:Tt.fragmentShader,clipping:!0})||this;return n.type="LineMaterial",n.dashed=!1,Object.defineProperties(n,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},waveAmp:{enumerable:!0,get:function(){return this.uniforms.waveAmp.value},set:function(t){this.uniforms.waveAmp.value=t}},waveFreq:{enumerable:!0,get:function(){return this.uniforms.waveFreq.value},set:function(t){this.uniforms.waveFreq.value=t}},waveDir:{enumerable:!0,get:function(){return this.uniforms.waveDir.value},set:function(t){this.uniforms.waveDir.value=t}},startOffset:{enumerable:!0,get:function(){return this.uniforms.startOffset.value},set:function(t){this.uniforms.startOffset.value=t}},endOffset:{enumerable:!0,get:function(){return this.uniforms.endOffset.value},set:function(t){this.uniforms.endOffset.value=t}},range:{enumerable:!0,get:function(){return this.uniforms.range.value},set:function(t){this.uniforms.range.value=t}},animationProgress:{enumerable:!0,get:function(){return this.uniforms.animationProgress.value},set:function(t){this.uniforms.animationProgress.value=t}}}),n.setValues(e),n}return s})(p.ShaderMaterial);Object.assign(xt.prototype,{isLineMaterial:!0});var Xt=(function(v){ve(s,v);function s(e,n){var t=v.call(this)||this;return t.type="LineSegments2",t.geometry=e!==void 0?e:new St,t.material=n!==void 0?n:new xt({color:Math.random()*16777215}),t}return s.prototype.computeLineDistances=function(){for(var e=this.geometry,n=e.attributes.instanceStart,t=e.attributes.instanceEnd,r=new Float32Array(2*n.count),l=new p.Vector3,i=new p.Vector3,h=0,c=0,d=n.count;c<d;c++)l.fromBufferAttribute(n,c),i.fromBufferAttribute(t,c),h+=l.distanceTo(i);this.material.uniforms.totalLength.value=h;for(var c=0,y=0,d=n.count;c<d;c++,y+=2){l.fromBufferAttribute(n,c),i.fromBufferAttribute(t,c);var M=l.distanceTo(i);r[y]=y===0?0:r[y-1],r[y+1]=r[y]+M}var w=new p.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new p.InterleavedBufferAttribute(w,1,0)),e.setAttribute("instanceDistanceEnd",new p.InterleavedBufferAttribute(w,1,1)),this},s.prototype.raycast=function(e,n){e.camera===null&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');var t=e.ray,r=e.camera,l=r.projectionMatrix,i=this.geometry,h=this.material,c=h.resolution,d=h.linewidth,y=i.attributes.instanceStart,M=i.attributes.instanceEnd,w=new p.Vector4,P=new p.Vector4,S=new p.Vector4,O=new p.Vector3,E=new p.Matrix4,b=new p.Line3,T=new p.Vector3;t.at(1,S),S.w=1,S.applyMatrix4(r.matrixWorldInverse),S.applyMatrix4(l),S.multiplyScalar(1/S.w),S.x*=c.x/2,S.y*=c.y/2,S.z=0,O.copy(S);var f=this.matrixWorld;E.multiplyMatrices(r.matrixWorldInverse,f);for(var C=0,x=y.count;C<x;C++){w.fromBufferAttribute(y,C),P.fromBufferAttribute(M,C),w.w=1,P.w=1,w.applyMatrix4(E),P.applyMatrix4(E),w.applyMatrix4(l),P.applyMatrix4(l),w.multiplyScalar(1/w.w),P.multiplyScalar(1/P.w);var F=w.z<-1&&P.z<-1,j=w.z>1&&P.z>1;if(!(F||j)){w.x*=c.x/2,w.y*=c.y/2,P.x*=c.x/2,P.y*=c.y/2,b.start.copy(w),b.start.z=0,b.end.copy(P),b.end.z=0;var Y=b.closestPointToPointParameter(O,!0);b.at(Y,T);var H=p.MathUtils.lerp(w.z,P.z,Y),Z=H>=-1&&H<=1,J=O.distanceTo(T)<d*.5;if(Z&&J){b.start.fromBufferAttribute(y,C),b.end.fromBufferAttribute(M,C),b.start.applyMatrix4(f),b.end.applyMatrix4(f);var R=new p.Vector3,K=new p.Vector3;t.distanceSqToSegment(b.start,b.end,K,R),n.push({point:K,pointOnLine:R,distance:t.origin.distanceTo(K),object:this,faceIndex:C})}}}},s})(p.Mesh);Object.assign(Xt.prototype,{isLineSegments2:!0});var qt=(function(v){ve(s,v);function s(e,n){var t=v.call(this,e,n)||this;return t.type="Line2",t}return s})(Xt);Object.assign(qt.prototype,{isLine2:!0});var Zt=(function(v){ve(s,v);function s(){var e=v.call(this)||this;return e.type="LineGeometry",e}return s.prototype.setPositions=function(e){for(var n=e.length-3,t=new Float32Array(2*n),r=0;r<n;r+=3)t[2*r]=e[r],t[2*r+1]=e[r+1],t[2*r+2]=e[r+2],t[2*r+3]=e[r+3],t[2*r+4]=e[r+4],t[2*r+5]=e[r+5];return v.prototype.setPositions.call(this,t),this},s.prototype.setColors=function(e){for(var n=e.length-3,t=new Float32Array(2*n),r=0;r<n;r+=3)t[2*r]=e[r],t[2*r+1]=e[r+1],t[2*r+2]=e[r+2],t[2*r+3]=e[r+3],t[2*r+4]=e[r+4],t[2*r+5]=e[r+5];return v.prototype.setColors.call(this,t),this},s.prototype.fromLine=function(e){var n=e.geometry;if(n instanceof p.Geometry){var t=new p.BufferGeometry().fromGeometry(n);this.setPositions(t.attributes.position.array)}else n instanceof p.BufferGeometry&&this.setPositions(n.attributes.position.array);return this},s.prototype.copy=function(){return this},s})(St);Object.assign(Zt.prototype,{isLineGeometry:!0});var Yn=(function(v){ve(s,v);function s(e,n){var t=v.call(this,e)||this;t.paths=new Map,t.up=new p.Vector3(0,1,0);var r={enabled:!0,visible:!0,playing:!1};t.state=Object.assign(r,n==null?void 0:n.initialState);var l={lineCount:6,spacing:.02,lineWidth:2,color:16777215,speed:2,range:.3,waveAmp:.05,waveFreq:20,particleCount:50,maxDistance:.1,lineYOffset:.1,subMeshWidth:.3,subMeshColor:65535,subMeshOpacity:.3,subMeshMaxOpacity:.5,subMeshSegmentInterval:3,subMeshHighlightWidth:1};return t._config=B(B({},l),n==null?void 0:n.config),n!=null&&n.paths&&n.paths.length>0&&n.paths.forEach(function(i){t.addPath(i)}),t.state.enabled&&t._enable({userAction:!1}),t}return Object.defineProperty(s.prototype,"config",{get:function(){return B({},this._config)},enumerable:!1,configurable:!0}),s.prototype.updateState=function(e,n){var t=this.state;this.state=B(B({},this.state),e),this.hooks.emit("stateChange",{state:this.state,prevState:t,userAction:n})},s.prototype.load=function(e,n){return Fe(this,void 0,void 0,function(){var t,r=this;return Le(this,function(l){return this.clearAllPaths(),e.paths.forEach(function(i){var h,c,d=i.points.map(function(y){return new p.Vector3(y.x,y.y,y.z)});r.addPath({id:i.id,points:d,enabled:(h=i.enabled)!==null&&h!==void 0?h:!0,visible:(c=i.visible)!==null&&c!==void 0?c:!0,color:i.color,lineWidth:i.lineWidth,speed:i.speed})}),t=new Map,this.paths.forEach(function(i,h){t.set(h,i.config)}),this.data={paths:t},this.hooks.emit("dataLoaded",this.data),n&&this.setState(n),[2]})})},s.prototype.addPath=function(e){var n,t,r,l,i,h,c,d;if(e.points.length<2)return console.warn("DynamicPathLinePlugin: 路径 ".concat(e.id," 至少需要2个点")),!1;if(this.paths.has(e.id))return console.warn("DynamicPathLinePlugin: 路径 ".concat(e.id," 已存在")),!1;var y=new p.CatmullRomCurve3(e.points),M=(n=e.subMeshColor)!==null&&n!==void 0?n:this._config.subMeshColor,w=(t=e.subMeshWidth)!==null&&t!==void 0?t:this._config.subMeshWidth,P=(r=e.subMeshOpacity)!==null&&r!==void 0?r:this._config.subMeshOpacity,S=(l=e.enableSubMesh)!==null&&l!==void 0?l:!0,O=(i=e.speed)!==null&&i!==void 0?i:this._config.speed,E=(h=e.range)!==null&&h!==void 0?h:this._config.range,b=this.createLines(e,y,E),T=this.createParticles(),f=T.particles,C=T.particleGeometry,x=T.particleMaterial,F=T.particleInfos,j=T.particlePositions,Y=this.createSubMeshGeometry(e,y,w),H=y.getLength(),Z=this.createSubMeshMaterial(M,P,H,E);Z.uniforms.totalLength.value=H;var J=new p.Mesh(Y,Z);J.visible=S,this.five.scene.add(J);var R={id:e.id,config:e,curve:y,lines:b,particles:f,particleGeometry:C,particleMaterial:x,particleInfos:F,particlePositions:j,enabled:(c=e.enabled)!==null&&c!==void 0?c:!0,visible:(d=e.visible)!==null&&d!==void 0?d:!0,startOffset:0,endOffset:0,lastAnimationProgress:0,cycleStartTime:performance.now()/1e3,isInitialAnimation:!0,isPathlineInitialAnimation:!0,subMeshUnfoldProgress:0,subMeshUnfoldStarted:!1,subMeshUnfoldStartTime:0,lastUpdateTime:performance.now()/1e3,subMesh:J,subMeshGeometry:Y,subMeshMaterial:Z,subMeshColor:M,subMeshWidth:w,subMeshOpacity:P,speed:O,animationId:null,enableSubMesh:S,isPaused:!1,pausedProgress:0,pausedTime:0};this.paths.set(e.id,R);var K=this.data,L=new Map;return this.paths.forEach(function(k,I){L.set(I,k.config)}),this.data={paths:L},this.hooks.emit("dataChange",this.data,K),this.hooks.emit("pathAdd",e.id,e),this.state.playing&&this.startPathAnimation(e.id),!0},s.prototype.removePath=function(e){var n=this.paths.get(e);if(!n)return console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1;this.stopPathAnimation(e),this.disposePathResources(n),this.paths.delete(e);var t=this.data,r=new Map;return this.paths.forEach(function(l,i){r.set(i,l.config)}),this.data={paths:r},this.hooks.emit("dataChange",this.data,t),this.hooks.emit("pathRemove",e),!0},s.prototype.enablePath=function(e){var n=this.paths.get(e);return n?(n.enabled=!0,this.hooks.emit("pathEnable",e),!0):(console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1)},s.prototype.disablePath=function(e){var n=this.paths.get(e);return n?(n.enabled=!1,this.hooks.emit("pathDisable",e),!0):(console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1)},s.prototype.showPath=function(e){var n=this.paths.get(e);return n?(n.visible=!0,n.lines.forEach(function(t){return t.visible=!0}),n.particles.visible=!0,n.subMesh.visible=!0,this.hooks.emit("pathShow",e),!0):(console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1)},s.prototype.hidePath=function(e){var n=this.paths.get(e);return n?(n.visible=!1,n.lines.forEach(function(t){return t.visible=!1}),n.particles.visible=!1,n.subMesh.visible=!1,this.hooks.emit("pathHide",e),!0):(console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1)},s.prototype.getPathIds=function(){return Array.from(this.paths.keys())},s.prototype.getPathConfig=function(e){var n=this.paths.get(e);return n?B({},n.config):void 0},s.prototype.clearAllPaths=function(){var e=this;this.paths.forEach(function(r,l){e.stopPathAnimation(l),e.disposePathResources(r)}),this.paths.clear();var n=this.data,t=new Map;this.paths.forEach(function(r,l){t.set(l,r.config)}),this.data={paths:t},this.hooks.emit("dataChange",this.data,n)},s.prototype.getPositions=function(e,n){for(var t=[],r=[],l=0,i=[],h=0;h<=n;h++){var c=h/n,d=e.getPoint(c);i.push(d.clone()),h>0&&(l+=d.distanceTo(i[h-1]))}for(var y=0,h=0;h<n;h++){h>0&&(y+=i[h].distanceTo(i[h-1]));var M=y/l;t.push(i[h].x,i[h].y,i[h].z),r.push(M)}return{positions:t,distanceProgress:r}},s.prototype.createLines=function(e,n,t){for(var r=this,l,i,h=[],c=e.points.length*40,d=this._config,y=d.lineCount,M=d.spacing,w=d.waveAmp,P=d.waveFreq,S=d.lineYOffset,O=(l=e.lineWidth)!==null&&l!==void 0?l:this._config.lineWidth,E=(i=e.color)!==null&&i!==void 0?i:this._config.color,b=n.getLength(),T=t/b,f=function(F){var j=(F-(y-1)/2)*M,Y=e.points.map(function(L,k){var I=k/(e.points.length-1),N=n.getTangent(I).normalize(),W=new p.Vector3().crossVectors(r.up,N).normalize(),ee=j*Math.abs((k-e.points.length/2)/e.points.length-.5)*-1;return L.clone().addScaledVector(W,j+ee).add(new p.Vector3(0,S+.02*(F%2===0?1:0),0))}),H=new p.CatmullRomCurve3(Y),Z=C.getPositions(H,c).positions,J=new Zt;J.setPositions(Z);var R=new xt({color:E,linewidth:O*(F%2===0?1:.5),transparent:!0,opacity:1,depthWrite:!1});R.resolution.set(C.five.camera.resolution.x,C.five.camera.resolution.y),F===0?R.waveDir=1:F===1?R.waveDir=2:F===2?R.waveDir=0:F===3?R.waveDir=3:F===4&&(R.waveDir=1),R.waveAmp=w,R.waveFreq=P,Object.assign(R.uniforms,{time:{value:0},startOffset:{value:0},range:{value:T}});var K=new qt(J,R);K.computeLineDistances(),h.push(K),C.five.scene.add(K)},C=this,x=0;x<y;x++)f(x);return h},s.prototype.createParticleMaterial=function(){return new p.ShaderMaterial({transparent:!0,blending:p.AdditiveBlending,depthWrite:!1,uniforms:{pointTexture:{value:new p.TextureLoader().load("https://threejs.org/examples/textures/sprites/circle.png")}},vertexShader:`
|
|
727
|
+
`},we=class extends l.ShaderMaterial{constructor(e){super({uniforms:l.UniformsUtils.clone(Ce.uniforms),vertexShader:Ce.vertexShader,fragmentShader:Ce.fragmentShader,clipping:!0}),this.type=`LineMaterial`,this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get(){return this.uniforms.diffuse.value},set(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get(){return this.uniforms.linewidth.value},set(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get(){return this.uniforms.dashScale.value},set(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get(){return this.uniforms.dashSize.value},set(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get(){return this.uniforms.gapSize.value},set(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},time:{enumerable:!0,get(){return this.uniforms.time.value},set(e){this.uniforms.time.value=e}},waveAmp:{enumerable:!0,get(){return this.uniforms.waveAmp.value},set(e){this.uniforms.waveAmp.value=e}},waveFreq:{enumerable:!0,get(){return this.uniforms.waveFreq.value},set(e){this.uniforms.waveFreq.value=e}},waveDir:{enumerable:!0,get(){return this.uniforms.waveDir.value},set(e){this.uniforms.waveDir.value=e}},startOffset:{enumerable:!0,get(){return this.uniforms.startOffset.value},set(e){this.uniforms.startOffset.value=e}},endOffset:{enumerable:!0,get(){return this.uniforms.endOffset.value},set(e){this.uniforms.endOffset.value=e}},range:{enumerable:!0,get(){return this.uniforms.range.value},set(e){this.uniforms.range.value=e}},animationProgress:{enumerable:!0,get(){return this.uniforms.animationProgress.value},set(e){this.uniforms.animationProgress.value=e}}}),this.setValues(e)}};Object.assign(we.prototype,{isLineMaterial:!0});var Te=class extends l.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new Se:e,this.material=t===void 0?new we({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count),i=new l.Vector3,a=new l.Vector3,o=0;for(let e=0,r=t.count;e<r;e++)i.fromBufferAttribute(t,e),a.fromBufferAttribute(n,e),o+=i.distanceTo(a);this.material.uniforms.totalLength.value=o;for(let e=0,o=0,s=t.count;e<s;e++,o+=2){i.fromBufferAttribute(t,e),a.fromBufferAttribute(n,e);let s=i.distanceTo(a);r[o]=o===0?0:r[o-1],r[o+1]=r[o]+s}let s=new l.InstancedInterleavedBuffer(r,2,1);return e.setAttribute(`instanceDistanceStart`,new l.InterleavedBufferAttribute(s,1,0)),e.setAttribute(`instanceDistanceEnd`,new l.InterleavedBufferAttribute(s,1,1)),this}raycast(e,t){e.camera===null&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.`);let n=e.ray,r=e.camera,i=r.projectionMatrix,a=this.geometry,o=this.material,s=o.resolution,c=o.linewidth,u=a.attributes.instanceStart,d=a.attributes.instanceEnd,f=new l.Vector4,p=new l.Vector4,m=new l.Vector4,h=new l.Vector3,g=new l.Matrix4,_=new l.Line3,v=new l.Vector3;n.at(1,m),m.w=1,m.applyMatrix4(r.matrixWorldInverse),m.applyMatrix4(i),m.multiplyScalar(1/m.w),m.x*=s.x/2,m.y*=s.y/2,m.z=0,h.copy(m);let y=this.matrixWorld;g.multiplyMatrices(r.matrixWorldInverse,y);for(var b=0,x=u.count;b<x;b++){f.fromBufferAttribute(u,b),p.fromBufferAttribute(d,b),f.w=1,p.w=1,f.applyMatrix4(g),p.applyMatrix4(g),f.applyMatrix4(i),p.applyMatrix4(i),f.multiplyScalar(1/f.w),p.multiplyScalar(1/p.w);var S=f.z<-1&&p.z<-1,C=f.z>1&&p.z>1;if(S||C)continue;f.x*=s.x/2,f.y*=s.y/2,p.x*=s.x/2,p.y*=s.y/2,_.start.copy(f),_.start.z=0,_.end.copy(p),_.end.z=0;let e=_.closestPointToPointParameter(h,!0);_.at(e,v);let r=l.MathUtils.lerp(f.z,p.z,e),a=r>=-1&&r<=1;var w=h.distanceTo(v)<c*.5;if(a&&w){_.start.fromBufferAttribute(u,b),_.end.fromBufferAttribute(d,b),_.start.applyMatrix4(y),_.end.applyMatrix4(y);var T=new l.Vector3,E=new l.Vector3;n.distanceSqToSegment(_.start,_.end,E,T),t.push({point:E,pointOnLine:T,distance:n.origin.distanceTo(E),object:this,faceIndex:b})}}}};Object.assign(Te.prototype,{isLineSegments2:!0});var Ee=class extends Te{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(Ee.prototype,{isLine2:!0});var De=class extends Se{constructor(){super(),this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}fromLine(e){let t=e.geometry;if(t instanceof l.Geometry){let e=new l.BufferGeometry().fromGeometry(t);this.setPositions(e.attributes.position.array)}else t instanceof l.BufferGeometry&&this.setPositions(t.attributes.position.array);return this}copy(){return this}};Object.assign(De.prototype,{isLineGeometry:!0});var Oe=class extends u.BasePlugin.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})}constructor(e,t){super(e),this.paths=new Map,this.up=new l.Vector3(0,1,0),this.state=Object.assign({enabled:!0,visible:!0,playing:!1},t==null?void 0:t.initialState),this._config=Object.assign(Object.assign({},{lineCount:6,spacing:.02,lineWidth:2,color:16777215,speed:2,range:.3,waveAmp:.05,waveFreq:20,particleCount:50,maxDistance:.1,lineYOffset:.1,subMeshWidth:.3,subMeshColor:65535,subMeshOpacity:.3,subMeshMaxOpacity:.5,subMeshSegmentInterval:3,subMeshHighlightWidth:1}),t==null?void 0:t.config),t!=null&&t.paths&&t.paths.length>0&&t.paths.forEach(e=>{this.addPath(e)}),this.state.enabled&&this._enable({userAction:!1})}load(e,t){return m(this,void 0,void 0,function*(){this.clearAllPaths(),e.paths.forEach(e=>{var t,n;let r=e.points.map(e=>new l.Vector3(e.x,e.y,e.z));this.addPath({id:e.id,points:r,enabled:(t=e.enabled)==null?!0:t,visible:(n=e.visible)==null?!0:n,color:e.color,lineWidth:e.lineWidth,speed:e.speed})});let n=new Map;this.paths.forEach((e,t)=>{n.set(t,e.config)}),this.data={paths:n},this.hooks.emit(`dataLoaded`,this.data),t&&this.setState(t)})}addPath(e){var t,n,r,i,a,o,s,c;if(e.points.length<2)return console.warn(`DynamicPathLinePlugin: 路径 ${e.id} 至少需要2个点`),!1;if(this.paths.has(e.id))return console.warn(`DynamicPathLinePlugin: 路径 ${e.id} 已存在`),!1;let u=new l.CatmullRomCurve3(e.points),d=(t=e.subMeshColor)==null?this._config.subMeshColor:t,f=(n=e.subMeshWidth)==null?this._config.subMeshWidth:n,p=(r=e.subMeshOpacity)==null?this._config.subMeshOpacity:r,m=(i=e.enableSubMesh)==null?!0:i,h=(a=e.speed)==null?this._config.speed:a,g=(o=e.range)==null?this._config.range:o,_=this.createLines(e,u,g),{particles:v,particleGeometry:y,particleMaterial:b,particleInfos:x,particlePositions:S}=this.createParticles(),C=this.createSubMeshGeometry(e,u,f),w=u.getLength(),T=this.createSubMeshMaterial(d,p,w,g);T.uniforms.totalLength.value=w;let E=new l.Mesh(C,T);E.visible=m,this.five.scene.add(E);let D={id:e.id,config:e,curve:u,lines:_,particles:v,particleGeometry:y,particleMaterial:b,particleInfos:x,particlePositions:S,enabled:(s=e.enabled)==null?!0:s,visible:(c=e.visible)==null?!0:c,startOffset:0,endOffset:0,lastAnimationProgress:0,cycleStartTime:performance.now()/1e3,isInitialAnimation:!0,isPathlineInitialAnimation:!0,subMeshUnfoldProgress:0,subMeshUnfoldStarted:!1,subMeshUnfoldStartTime:0,lastUpdateTime:performance.now()/1e3,subMesh:E,subMeshGeometry:C,subMeshMaterial:T,subMeshColor:d,subMeshWidth:f,subMeshOpacity:p,speed:h,animationId:null,enableSubMesh:m,isPaused:!1,pausedProgress:0,pausedTime:0};this.paths.set(e.id,D);let O=this.data,k=new Map;return this.paths.forEach((e,t)=>{k.set(t,e.config)}),this.data={paths:k},this.hooks.emit(`dataChange`,this.data,O),this.hooks.emit(`pathAdd`,e.id,e),this.state.playing&&this.startPathAnimation(e.id),!0}removePath(e){let t=this.paths.get(e);if(!t)return console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1;this.stopPathAnimation(e),this.disposePathResources(t),this.paths.delete(e);let n=this.data,r=new Map;return this.paths.forEach((e,t)=>{r.set(t,e.config)}),this.data={paths:r},this.hooks.emit(`dataChange`,this.data,n),this.hooks.emit(`pathRemove`,e),!0}enablePath(e){let t=this.paths.get(e);return t?(t.enabled=!0,this.hooks.emit(`pathEnable`,e),!0):(console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1)}disablePath(e){let t=this.paths.get(e);return t?(t.enabled=!1,this.hooks.emit(`pathDisable`,e),!0):(console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1)}showPath(e){let t=this.paths.get(e);return t?(t.visible=!0,t.lines.forEach(e=>e.visible=!0),t.particles.visible=!0,t.subMesh.visible=!0,this.hooks.emit(`pathShow`,e),!0):(console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1)}hidePath(e){let t=this.paths.get(e);return t?(t.visible=!1,t.lines.forEach(e=>e.visible=!1),t.particles.visible=!1,t.subMesh.visible=!1,this.hooks.emit(`pathHide`,e),!0):(console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1)}getPathIds(){return Array.from(this.paths.keys())}getPathConfig(e){let t=this.paths.get(e);return t?Object.assign({},t.config):void 0}clearAllPaths(){this.paths.forEach((e,t)=>{this.stopPathAnimation(t),this.disposePathResources(e)}),this.paths.clear();let e=this.data,t=new Map;this.paths.forEach((e,n)=>{t.set(n,e.config)}),this.data={paths:t},this.hooks.emit(`dataChange`,this.data,e)}getPositions(e,t){let n=[],r=[],i=0,a=[];for(let n=0;n<=t;n++){let r=n/t,o=e.getPoint(r);a.push(o.clone()),n>0&&(i+=o.distanceTo(a[n-1]))}let o=0;for(let e=0;e<t;e++){e>0&&(o+=a[e].distanceTo(a[e-1]));let t=o/i;n.push(a[e].x,a[e].y,a[e].z),r.push(t)}return{positions:n,distanceProgress:r}}createLines(e,t,n){var r,i;let a=[],o=e.points.length*40,{lineCount:s,spacing:c,waveAmp:u,waveFreq:d,lineYOffset:f}=this._config,p=(r=e.lineWidth)==null?this._config.lineWidth:r,m=(i=e.color)==null?this._config.color:i,h=n/t.getLength();for(let n=0;n<s;n++){let r=(n-(s-1)/2)*c,i=e.points.map((i,a)=>{let o=a/(e.points.length-1),s=t.getTangent(o).normalize(),c=new l.Vector3().crossVectors(this.up,s).normalize(),u=r*Math.abs((a-e.points.length/2)/e.points.length-.5)*-1;return i.clone().addScaledVector(c,r+u).add(new l.Vector3(0,f+.02*(n%2==0?1:0),0))}),g=new l.CatmullRomCurve3(i),{positions:_}=this.getPositions(g,o),v=new De;v.setPositions(_);let y=new we({color:m,linewidth:p*(n%2==0?1:.5),transparent:!0,opacity:1,depthWrite:!1});y.resolution.set(this.five.camera.resolution.x,this.five.camera.resolution.y),n===0?y.waveDir=1:n===1?y.waveDir=2:n===2?y.waveDir=0:n===3?y.waveDir=3:n===4&&(y.waveDir=1),y.waveAmp=u,y.waveFreq=d,Object.assign(y.uniforms,{time:{value:0},startOffset:{value:0},range:{value:h}});let b=new Ee(v,y);b.computeLineDistances(),a.push(b),this.five.scene.add(b)}return a}createParticleMaterial(){return new l.ShaderMaterial({transparent:!0,blending:l.AdditiveBlending,depthWrite:!1,uniforms:{pointTexture:{value:new l.TextureLoader().load(`https://threejs.org/examples/textures/sprites/circle.png`)}},vertexShader:`
|
|
732
728
|
attribute float size;
|
|
733
729
|
varying vec2 vUv;
|
|
734
730
|
void main() {
|
|
@@ -743,7 +739,7 @@ void main() {
|
|
|
743
739
|
gl_FragColor = texture2D(pointTexture, gl_PointCoord);
|
|
744
740
|
gl_FragColor.a *= 0.15;
|
|
745
741
|
}
|
|
746
|
-
`})}
|
|
742
|
+
`})}createParticles(){let{particleCount:e}=this._config,t=new Float32Array(e*3),n=new l.BufferGeometry,r=this.createParticleMaterial(),i=new l.Points(n,r),a=new Float32Array(e),o=[];for(let n=0;n<e;n++)t[n*3]=9999,t[n*3+1]=9999,t[n*3+2]=9999,a[n]=l.MathUtils.randFloat(3,9),o.push({velocity:new l.Vector3,life:3+Math.random()*2,age:0,active:!1,alpha:0,startPos:new l.Vector3});return n.setAttribute(`position`,new l.BufferAttribute(t,3)),n.setAttribute(`size`,new l.BufferAttribute(a,1)),i.frustumCulled=!1,this.five.scene.add(i),{particles:i,particleGeometry:n,particleMaterial:r,particleInfos:o,particlePositions:t}}createSubMeshGeometry(e,t,n){let r=e.points.length*40,i=new l.BufferGeometry,a=t.getPoints(r),o=[],s=[],c=[],u=[],d=0,f=[0];for(let e=1;e<a.length;e++)d+=a[e].distanceTo(a[e-1]),f.push(d);let p=d;for(let e=0;e<a.length;e++){let r=a[e],i=e/(a.length-1),c=t.getTangent(i).normalize(),d=new l.Vector3().crossVectors(this.up,c).normalize(),m=n/2,h=r.clone().addScaledVector(d,-m);o.push(h.x,h.y,h.z),s.push(0,f[e]/p),u.push(f[e]/p);let g=r.clone().addScaledVector(d,m);o.push(g.x,g.y,g.z),s.push(1,f[e]/p),u.push(f[e]/p)}for(let e=0;e<a.length-1;e++){let t=e*2;c.push(t,t+1,t+2),c.push(t+1,t+3,t+2)}return i.setAttribute(`position`,new l.Float32BufferAttribute(o,3)),i.setAttribute(`uv`,new l.Float32BufferAttribute(s,2)),i.setAttribute(`distanceProgress`,new l.Float32BufferAttribute(u,1)),i.setIndex(c),i.computeVertexNormals(),i}createAlphaMapTexture(e,t,n,r,i){let a=1024;a*1;let o=new Uint8Array(1024),s=1/e,c=t/(n/e)/2;for(let e=0;e<a;e++){let t=e/a,n=(t-Math.floor(t/s)*s)/s,l=0,u=n;if(u>.5&&(u=1-u),u<c){let e=1-u/c;l=r+(i-r)*e}else l=r;o[e]=Math.floor(l*255)}let u=new l.DataTexture(o,a,1,l.RedFormat);return u.needsUpdate=!0,u.wrapS=l.RepeatWrapping,u.wrapT=l.ClampToEdgeWrapping,u.minFilter=l.LinearFilter,u.magFilter=l.LinearFilter,u}createSubMeshMaterial(e,t,n,r){let{subMeshSegmentInterval:i,subMeshHighlightWidth:a,subMeshMaxOpacity:o}=this._config,s=Math.max(1,Math.round(n/i)),c=r/n,u=this.createAlphaMapTexture(s,a,n,t,o);return new l.ShaderMaterial({transparent:!0,side:l.BackSide,depthWrite:!1,uniforms:{baseColor:{value:new l.Color(e)},baseOpacity:{value:t},globalOpacity:{value:1},animationProgress:{value:0},range:{value:c},startOffset:{value:0},endOffset:{value:0},totalLength:{value:1},unfoldProgress:{value:0},alphaMap:{value:u}},vertexShader:`
|
|
747
743
|
attribute float distanceProgress;
|
|
748
744
|
varying vec2 vUv;
|
|
749
745
|
varying float vDistanceProgress;
|
|
@@ -812,4 +808,22 @@ void main() {
|
|
|
812
808
|
|
|
813
809
|
gl_FragColor = vec4(baseColor, sampledAlpha * globalOpacity);
|
|
814
810
|
}
|
|
815
|
-
`})},s.prototype.projectPointsToScreen=function(e,n){for(var t=[],r=0,l=0;l<e.length;l++){var i=e[l];l>0&&(r+=i.distanceTo(e[l-1]));var h=i.clone().project(n),c=h.x<-1||h.x>1||h.y<-1||h.y>1||h.z<-1||h.z>1;t.push({point:i.clone(),screenPos:new p.Vector2(h.x,h.y),distanceFromStart:r,isOffscreen:c})}return t},s.prototype.findNearestOffscreenPoint=function(e){for(var n=-1,t=0,r=-1,l=0;l<e.length;l++)if(!e[l].isOffscreen){r=l;break}if(r===-1)return null;for(var l=r-1;l>=0;l--)if(e[l].isOffscreen){n=l,t=e[l].distanceFromStart;break}return n===-1?{index:0,distance:0}:{index:n,distance:t}},s.prototype.findFarestOffscreenPoint=function(e){for(var n,t=((n=e[e.length-1])===null||n===void 0?void 0:n.distanceFromStart)||0,r=-1,l=e.length-1;l>=0;l--)if(!e[l].isOffscreen){r=l;break}if(r===-1)return null;var i=r+1;return i<e.length&&e[i].isOffscreen?{index:i,distance:e[i].distanceFromStart,totalLength:t}:{index:e.length-1,distance:t,totalLength:t}},s.prototype.updatePathAnimation=function(e){var n,t,r=this.paths.get(e);if(!(!r||!r.enabled)){var l=performance.now()/1e3,i=this._config,h=i.particleCount,c=i.maxDistance,d=((n=r.lines[0])===null||n===void 0?void 0:n.material.uniforms.totalLength.value)||1,y=Math.max(.01,d-r.startOffset-r.endOffset),M=r.speed,w=(l-r.cycleStartTime)*M/y%1;if(r.isInitialAnimation){var P=w*y;if(r.enableSubMesh&&P>=1&&!r.subMeshUnfoldStarted&&(r.subMeshUnfoldStarted=!0,r.subMeshUnfoldStartTime=l),r.enableSubMesh&&r.subMeshUnfoldStarted&&r.subMeshUnfoldProgress<1&&!r.isPaused){var S=(t=r.config.range)!==null&&t!==void 0?t:this._config.range,O=l-r.subMeshUnfoldStartTime;r.subMeshUnfoldProgress=Math.min(1,O*M/(y-2*S)),r.subMeshMaterial.uniforms.unfoldProgress.value=r.subMeshUnfoldProgress}w<r.lastAnimationProgress&&(r.isPathlineInitialAnimation=!1,(!r.enableSubMesh||r.subMeshUnfoldProgress>=1)&&(r.isInitialAnimation=!1))}else r.enableSubMesh&&(r.subMeshMaterial.uniforms.unfoldProgress.value=1);if(r.lastAnimationProgress=w,r.lastUpdateTime=l,r.isPathlineInitialAnimation&&r.lines.forEach(function(H){H.material.uniforms.time.value=l,H.material.uniforms.animationProgress.value=w}),r.isPathlineInitialAnimation){var E=null,b=1/0;if(r.lines.forEach(function(H){for(var Z=H.geometry,J=Z.attributes.instanceDistanceStart,R=Z.attributes.instanceDistanceEnd,K=J.count,L=0;L<K;L++){var k=J.getX(L)/H.material.uniforms.totalLength.value,I=R.getX(L)/H.material.uniforms.totalLength.value;if(w>=k&&w<=I){var N=(w-k)/(I-k),W=new p.Vector3().fromBufferAttribute(Z.attributes.instanceStart,L),ee=new p.Vector3().fromBufferAttribute(Z.attributes.instanceEnd,L),Q=new p.Vector3().lerpVectors(W,ee,N),U=Math.abs(w-(k+I)/2);U<b&&(b=U,E=Q)}}}),E)for(var T=0;T<h;T++){var f=r.particleInfos[T];!f.active&&Math.random()<.05&&(f.active=!0,f.age=0,f.life=3+Math.random()*2,f.velocity.set((Math.random()-.5)*1e-4,(Math.random()-.5)*1e-4,(Math.random()-.5)*1e-4),r.particlePositions[T*3]=E.x,r.particlePositions[T*3+1]=E.y,r.particlePositions[T*3+2]=E.z,f.startPos.copy(E),f.alpha=0)}for(var T=0;T<h;T++){var f=r.particleInfos[T];if(f.active){f.age+=.016;var C=r.particlePositions[T*3]-f.startPos.x,x=r.particlePositions[T*3+1]-f.startPos.y,F=r.particlePositions[T*3+2]-f.startPos.z,j=Math.sqrt(C*C+x*x+F*F);(j>=c||f.age>=f.life)&&(f.active=!1,r.particlePositions[T*3]=9999,r.particlePositions[T*3+1]=9999,r.particlePositions[T*3+2]=9999,f.alpha=0),f.velocity.x+=(Math.random()-.5)*1e-4,f.velocity.z+=(Math.random()-.5)*1e-4,f.velocity.y+=1e-4,f.velocity.multiplyScalar(.99),r.particlePositions[T*3]+=f.velocity.x,r.particlePositions[T*3+1]+=f.velocity.y,r.particlePositions[T*3+2]+=f.velocity.z;var Y=f.age/f.life;Y<.2?f.alpha=Y/.2:Y>.8?f.alpha=(1-Y)/.2:f.alpha=1}}r.particleGeometry.attributes.position.needsUpdate=!0,r.particleMaterial.opacity=.6}r.enableSubMesh&&(r.subMeshMaterial.uniforms.animationProgress.value=w),this.five.needsRender=!0}},s.prototype.startPathAnimation=function(e,n){var t=this,r,l,i=this.paths.get(e);if(!i)return console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1;if(i.animationId!==null)return!1;var h=(r=n==null?void 0:n.startPointIndex)!==null&&r!==void 0?r:0,c=(l=n==null?void 0:n.fromStart)!==null&&l!==void 0?l:!1;if(!i.isPaused||c){var d=0,y=h;if(y>0){var M=i.config.points;y>=M.length&&(console.warn("DynamicPathLinePlugin: startPointIndex ".concat(y," 超出范围,路径只有 ").concat(M.length," 个点")),y=M.length-1);for(var w=0;w<y;w++)d+=M[w].distanceTo(M[w+1])}i.startOffset=d,i.lines.forEach(function(T){T.material.uniforms.startOffset.value=d}),i.enableSubMesh&&(i.subMeshMaterial.uniforms.startOffset.value=d)}var P=performance.now()/1e3;if(!c&&i.isPaused&&i.pausedProgress>0){var S=i.curve.getLength(),O=Math.max(.01,S-i.startOffset-i.endOffset),E=i.speed;if(i.cycleStartTime=P-i.pausedProgress*O/E,i.subMeshUnfoldStarted&&i.subMeshUnfoldProgress<1){var b=i.pausedTime-i.subMeshUnfoldStartTime;i.subMeshUnfoldStartTime=P-b}i.isPaused=!1}else i.cycleStartTime=P,i.isPaused=!1,i.pausedProgress=0;return i.lastUpdateTime=P,this.highlightPath(e,!0),i.animationId=be.AnimationFrameLoop.shared.add(function(){t.updatePathAnimation(e)}),!0},s.prototype.stopPathAnimation=function(e,n){n===void 0&&(n=!1);var t=this.paths.get(e);if(!t)return console.warn("DynamicPathLinePlugin: 路径 ".concat(e," 不存在")),!1;if(this.highlightPath(e,!1),t.animationId!==null){if(n){var r=performance.now()/1e3,l=t.curve.getLength(),i=Math.max(.01,l-t.startOffset-t.endOffset),h=t.speed;if(t.pausedProgress=(r-t.cycleStartTime)*h/i%1,t.pausedTime=r,t.isPaused=!0,t.subMeshUnfoldStarted&&t.subMeshUnfoldProgress<1){var c=r-t.subMeshUnfoldStartTime;t.subMeshUnfoldStartTime=r-c}}else t.isPaused=!1,t.pausedProgress=0,t.pausedTime=0;t.animationId(),t.animationId=null}return!0},s.prototype._enable=function(e){this.paths.size>0&&this.state.playing&&this.play()},s.prototype._disable=function(e){this.pause()},s.prototype.enable=function(e){var n;if(!this.state.enabled){var t=(n=e==null?void 0:e.userAction)!==null&&n!==void 0?n:!0;this.updateState({enabled:!0},t),this._enable({userAction:t})}},s.prototype.disable=function(e){var n;if(this.state.enabled!==!1){var t=(n=e==null?void 0:e.userAction)!==null&&n!==void 0?n:!0;this.updateState({enabled:!1},t),this._disable({userAction:t})}},s.prototype.show=function(e){var n,t=(n=e==null?void 0:e.userAction)!==null&&n!==void 0?n:!0;this.paths.forEach(function(r){r.lines.forEach(function(l){return l.visible=!0}),r.particles.visible=!0,r.subMesh.visible=!0}),this.updateState({visible:!0},t)},s.prototype.hide=function(e){var n,t=(n=e==null?void 0:e.userAction)!==null&&n!==void 0?n:!0;this.paths.forEach(function(r){r.lines.forEach(function(l){return l.visible=!1}),r.particles.visible=!1,r.subMesh.visible=!1}),this.updateState({visible:!1},t)},s.prototype.setState=function(e,n){var t;t=n==null?void 0:n.userAction,e.enabled!==void 0&&e.enabled!==this.state.enabled&&(e.enabled?this.enable(n):this.disable(n)),e.visible!==void 0&&e.visible!==this.state.visible&&(e.visible?this.show(n):this.hide(n))},s.prototype.play=function(e){var n=this;e===void 0&&(e=!1),this.paths.forEach(function(t,r){n.startPathAnimation(r,{fromStart:e})}),this.updateState({playing:!0},!1),this.hooks.emit("animationStart")},s.prototype.pause=function(){var e=this;this.paths.forEach(function(n,t){e.stopPathAnimation(t,!0)}),this.updateState({playing:!1},!1),this.hooks.emit("animationStop")},s.prototype.reset=function(){var e=this;this.paths.forEach(function(n,t){e.stopPathAnimation(t)}),this.paths.forEach(function(n){n.isInitialAnimation=!0,n.isPathlineInitialAnimation=!0,n.subMeshUnfoldProgress=0,n.subMeshUnfoldStarted=!1,n.subMeshUnfoldStartTime=0,n.lastAnimationProgress=0,n.cycleStartTime=performance.now()/1e3,n.lastUpdateTime=performance.now()/1e3,n.startOffset=0,n.endOffset=0,n.isPaused=!1,n.pausedProgress=0,n.pausedTime=0,n.lines.forEach(function(i){i.visible=!0,i.material.uniforms.time.value=0,i.material.uniforms.animationProgress.value=0,i.material.uniforms.startOffset.value=0,i.material.uniforms.endOffset.value=0}),n.particles.visible=!0;for(var t=e._config.particleCount,r=0;r<t;r++){var l=n.particleInfos[r];l.active=!1,l.age=0,l.alpha=0,n.particlePositions[r*3]=9999,n.particlePositions[r*3+1]=9999,n.particlePositions[r*3+2]=9999}n.particleGeometry.attributes.position.needsUpdate=!0,n.subMeshMaterial&&(n.subMeshMaterial.uniforms.unfoldProgress.value=0,n.subMeshMaterial.uniforms.animationProgress.value=0,n.subMeshMaterial.uniforms.startOffset.value=0,n.subMeshMaterial.uniforms.endOffset.value=0)})},s.prototype.highlightPath=function(e,n){var t=this,r=this.paths.get(e);if(r)var l=r.lines,i=0,h=250,c=be.AnimationFrameLoop.shared.add(function(d,y){i=Math.min(1,i+y/h),n?(l.forEach(function(M){M.material.uniforms.opacity.value=.3+i*.7}),r.particleMaterial.opacity=.3+i*.7,r.enableSubMesh&&(r.subMeshMaterial.uniforms.globalOpacity.value=.3+i*.7)):(l.forEach(function(M){M.material.uniforms.opacity.value=1-i*.7}),r.particleMaterial.opacity=.6*(1-i*.7),r.enableSubMesh&&(r.subMeshMaterial.uniforms.globalOpacity.value=1-i*.7)),t.five.needsRender=!0,i===1&&c()})},s.prototype.updateScreenProjection=function(e){var n=this,t=function(l){var i=n.projectPointsToScreen(l.config.points,n.five.camera),h=n.findNearestOffscreenPoint(i);h&&(l.startOffset=h.distance);var c=n.findFarestOffscreenPoint(i);c&&(l.endOffset=c.totalLength-c.distance),l.lines.forEach(function(d){d.material.uniforms.startOffset.value=l.startOffset,d.material.uniforms.endOffset.value=l.endOffset}),l.subMeshMaterial.uniforms.startOffset.value=l.startOffset,l.subMeshMaterial.uniforms.endOffset.value=l.endOffset,l.cycleStartTime=performance.now()/1e3,l.lastAnimationProgress=0};if(e){var r=this.paths.get(e);r&&t(r)}else this.paths.forEach(function(l){l.enabled&&t(l)})},s.prototype.disposePathResources=function(e){var n=this;e.lines.forEach(function(t){n.five.scene.remove(t),t.geometry.dispose(),t.material.dispose()}),this.five.scene.remove(e.particles),e.particleGeometry.dispose(),e.particleMaterial.dispose(),this.five.scene.remove(e.subMesh),e.subMeshGeometry.dispose(),e.subMeshMaterial.dispose()},s.prototype.dispose=function(){this.pause(),this.clearAllPaths(),this.hooks.emit("dispose")},s})(Mt.BasePlugin.Controller),Wn=function(v,s){return new Yn(v,s)};exports.BackgroundPlugin=Bn;exports.CSS3DRenderer=Wt;exports.DynamicPathLinePlugin=Wn;exports.ItemMaskPlugin=Fn;exports.OrbitControls=Ne;exports.OrientationPlugin=Dn;exports.PanoAnimePlugin=Hn;exports.RoundedBoxGeometry=Kt;exports.TrajectoryPlugin=Vn;
|
|
811
|
+
`})}projectPointsToScreen(e,t){let n=[],r=0;for(let i=0;i<e.length;i++){let a=e[i];i>0&&(r+=a.distanceTo(e[i-1]));let o=a.clone().project(t),s=o.x<-1||o.x>1||o.y<-1||o.y>1||o.z<-1||o.z>1;n.push({point:a.clone(),screenPos:new l.Vector2(o.x,o.y),distanceFromStart:r,isOffscreen:s})}return n}findNearestOffscreenPoint(e){let t=-1,n=0,r=-1;for(let t=0;t<e.length;t++)if(!e[t].isOffscreen){r=t;break}if(r===-1)return null;for(let i=r-1;i>=0;i--)if(e[i].isOffscreen){t=i,n=e[i].distanceFromStart;break}return t===-1?{index:0,distance:0}:{index:t,distance:n}}findFarestOffscreenPoint(e){var t;let n=((t=e[e.length-1])==null?void 0:t.distanceFromStart)||0,r=-1;for(let t=e.length-1;t>=0;t--)if(!e[t].isOffscreen){r=t;break}if(r===-1)return null;let i=r+1;return i<e.length&&e[i].isOffscreen?{index:i,distance:e[i].distanceFromStart,totalLength:n}:{index:e.length-1,distance:n,totalLength:n}}updatePathAnimation(e){var t,n;let r=this.paths.get(e);if(!r||!r.enabled)return;let i=performance.now()/1e3,{particleCount:a,maxDistance:o}=this._config,s=((t=r.lines[0])==null?void 0:t.material.uniforms.totalLength.value)||1,c=Math.max(.01,s-r.startOffset-r.endOffset),u=r.speed,d=(i-r.cycleStartTime)*u/c%1;if(r.isInitialAnimation){let e=d*c;if(r.enableSubMesh&&e>=1&&!r.subMeshUnfoldStarted&&(r.subMeshUnfoldStarted=!0,r.subMeshUnfoldStartTime=i),r.enableSubMesh&&r.subMeshUnfoldStarted&&r.subMeshUnfoldProgress<1&&!r.isPaused){let e=(n=r.config.range)==null?this._config.range:n,t=i-r.subMeshUnfoldStartTime;r.subMeshUnfoldProgress=Math.min(1,t*u/(c-2*e)),r.subMeshMaterial.uniforms.unfoldProgress.value=r.subMeshUnfoldProgress}d<r.lastAnimationProgress&&(r.isPathlineInitialAnimation=!1,(!r.enableSubMesh||r.subMeshUnfoldProgress>=1)&&(r.isInitialAnimation=!1))}else r.enableSubMesh&&(r.subMeshMaterial.uniforms.unfoldProgress.value=1);if(r.lastAnimationProgress=d,r.lastUpdateTime=i,r.isPathlineInitialAnimation&&r.lines.forEach(e=>{e.material.uniforms.time.value=i,e.material.uniforms.animationProgress.value=d}),r.isPathlineInitialAnimation){let e=null,t=1/0;if(r.lines.forEach(n=>{let r=n.geometry,i=r.attributes.instanceDistanceStart,a=r.attributes.instanceDistanceEnd,o=i.count;for(let s=0;s<o;s++){let o=i.getX(s)/n.material.uniforms.totalLength.value,c=a.getX(s)/n.material.uniforms.totalLength.value;if(d>=o&&d<=c){let n=(d-o)/(c-o),i=new l.Vector3().fromBufferAttribute(r.attributes.instanceStart,s),a=new l.Vector3().fromBufferAttribute(r.attributes.instanceEnd,s),u=new l.Vector3().lerpVectors(i,a,n),f=Math.abs(d-(o+c)/2);f<t&&(t=f,e=u)}}}),e)for(let t=0;t<a;t++){let n=r.particleInfos[t];!n.active&&Math.random()<.05&&(n.active=!0,n.age=0,n.life=3+Math.random()*2,n.velocity.set((Math.random()-.5)*1e-4,(Math.random()-.5)*1e-4,(Math.random()-.5)*1e-4),r.particlePositions[t*3]=e.x,r.particlePositions[t*3+1]=e.y,r.particlePositions[t*3+2]=e.z,n.startPos.copy(e),n.alpha=0)}for(let e=0;e<a;e++){let t=r.particleInfos[e];if(t.active){t.age+=.016;let n=r.particlePositions[e*3]-t.startPos.x,i=r.particlePositions[e*3+1]-t.startPos.y,a=r.particlePositions[e*3+2]-t.startPos.z;(Math.sqrt(n*n+i*i+a*a)>=o||t.age>=t.life)&&(t.active=!1,r.particlePositions[e*3]=9999,r.particlePositions[e*3+1]=9999,r.particlePositions[e*3+2]=9999,t.alpha=0),t.velocity.x+=(Math.random()-.5)*1e-4,t.velocity.z+=(Math.random()-.5)*1e-4,t.velocity.y+=1e-4,t.velocity.multiplyScalar(.99),r.particlePositions[e*3]+=t.velocity.x,r.particlePositions[e*3+1]+=t.velocity.y,r.particlePositions[e*3+2]+=t.velocity.z;let s=t.age/t.life;s<.2?t.alpha=s/.2:s>.8?t.alpha=(1-s)/.2:t.alpha=1}}r.particleGeometry.attributes.position.needsUpdate=!0,r.particleMaterial.opacity=.6}r.enableSubMesh&&(r.subMeshMaterial.uniforms.animationProgress.value=d),this.five.needsRender=!0}startPathAnimation(e,t){var n,r;let i=this.paths.get(e);if(!i)return console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1;if(i.animationId!==null)return!1;let a=(n=t==null?void 0:t.startPointIndex)==null?0:n,o=(r=t==null?void 0:t.fromStart)==null?!1:r;if(!i.isPaused||o){let e=0,t=a;if(t>0){let n=i.config.points;t>=n.length&&(console.warn(`DynamicPathLinePlugin: startPointIndex ${t} 超出范围,路径只有 ${n.length} 个点`),t=n.length-1);for(let r=0;r<t;r++)e+=n[r].distanceTo(n[r+1])}i.startOffset=e,i.lines.forEach(t=>{t.material.uniforms.startOffset.value=e}),i.enableSubMesh&&(i.subMeshMaterial.uniforms.startOffset.value=e)}let s=performance.now()/1e3;if(!o&&i.isPaused&&i.pausedProgress>0){let e=i.curve.getLength(),t=Math.max(.01,e-i.startOffset-i.endOffset),n=i.speed;i.cycleStartTime=s-i.pausedProgress*t/n,i.subMeshUnfoldStarted&&i.subMeshUnfoldProgress<1&&(i.subMeshUnfoldStartTime=s-(i.pausedTime-i.subMeshUnfoldStartTime)),i.isPaused=!1}else i.cycleStartTime=s,i.isPaused=!1,i.pausedProgress=0;return i.lastUpdateTime=s,this.highlightPath(e,!0),i.animationId=c.AnimationFrameLoop.shared.add(()=>{this.updatePathAnimation(e)}),!0}stopPathAnimation(e,t=!1){let n=this.paths.get(e);if(!n)return console.warn(`DynamicPathLinePlugin: 路径 ${e} 不存在`),!1;if(this.highlightPath(e,!1),n.animationId!==null){if(t){let e=performance.now()/1e3,t=n.curve.getLength(),r=Math.max(.01,t-n.startOffset-n.endOffset),i=n.speed;n.pausedProgress=(e-n.cycleStartTime)*i/r%1,n.pausedTime=e,n.isPaused=!0,n.subMeshUnfoldStarted&&n.subMeshUnfoldProgress<1&&(n.subMeshUnfoldStartTime=e-(e-n.subMeshUnfoldStartTime))}else n.isPaused=!1,n.pausedProgress=0,n.pausedTime=0;n.animationId(),n.animationId=null}return!0}_enable(e){this.paths.size>0&&this.state.playing&&this.play()}_disable(e){this.pause()}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),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})}show(e){var t;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.paths.forEach(e=>{e.lines.forEach(e=>e.visible=!0),e.particles.visible=!0,e.subMesh.visible=!0}),this.updateState({visible:!0},n)}hide(e){var t;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.paths.forEach(e=>{e.lines.forEach(e=>e.visible=!1),e.particles.visible=!1,e.subMesh.visible=!1}),this.updateState({visible:!1},n)}setState(e,t){t==null||t.userAction,e.enabled!==void 0&&e.enabled!==this.state.enabled&&(e.enabled?this.enable(t):this.disable(t)),e.visible!==void 0&&e.visible!==this.state.visible&&(e.visible?this.show(t):this.hide(t))}play(e=!1){this.paths.forEach((t,n)=>{this.startPathAnimation(n,{fromStart:e})}),this.updateState({playing:!0},!1),this.hooks.emit(`animationStart`)}pause(){this.paths.forEach((e,t)=>{this.stopPathAnimation(t,!0)}),this.updateState({playing:!1},!1),this.hooks.emit(`animationStop`)}reset(){this.paths.forEach((e,t)=>{this.stopPathAnimation(t)}),this.paths.forEach(e=>{e.isInitialAnimation=!0,e.isPathlineInitialAnimation=!0,e.subMeshUnfoldProgress=0,e.subMeshUnfoldStarted=!1,e.subMeshUnfoldStartTime=0,e.lastAnimationProgress=0,e.cycleStartTime=performance.now()/1e3,e.lastUpdateTime=performance.now()/1e3,e.startOffset=0,e.endOffset=0,e.isPaused=!1,e.pausedProgress=0,e.pausedTime=0,e.lines.forEach(e=>{e.visible=!0,e.material.uniforms.time.value=0,e.material.uniforms.animationProgress.value=0,e.material.uniforms.startOffset.value=0,e.material.uniforms.endOffset.value=0}),e.particles.visible=!0;let t=this._config.particleCount;for(let n=0;n<t;n++){let t=e.particleInfos[n];t.active=!1,t.age=0,t.alpha=0,e.particlePositions[n*3]=9999,e.particlePositions[n*3+1]=9999,e.particlePositions[n*3+2]=9999}e.particleGeometry.attributes.position.needsUpdate=!0,e.subMeshMaterial&&(e.subMeshMaterial.uniforms.unfoldProgress.value=0,e.subMeshMaterial.uniforms.animationProgress.value=0,e.subMeshMaterial.uniforms.startOffset.value=0,e.subMeshMaterial.uniforms.endOffset.value=0)})}highlightPath(e,t){let n=this.paths.get(e);if(!n)return;let r=n.lines,i=0,a=c.AnimationFrameLoop.shared.add((e,o)=>{i=Math.min(1,i+o/250),t?(r.forEach(e=>{e.material.uniforms.opacity.value=.3+i*.7}),n.particleMaterial.opacity=.3+i*.7,n.enableSubMesh&&(n.subMeshMaterial.uniforms.globalOpacity.value=.3+i*.7)):(r.forEach(e=>{e.material.uniforms.opacity.value=1-i*.7}),n.particleMaterial.opacity=.6*(1-i*.7),n.enableSubMesh&&(n.subMeshMaterial.uniforms.globalOpacity.value=1-i*.7)),this.five.needsRender=!0,i===1&&a()})}updateScreenProjection(e){let t=e=>{let t=this.projectPointsToScreen(e.config.points,this.five.camera),n=this.findNearestOffscreenPoint(t);n&&(e.startOffset=n.distance);let r=this.findFarestOffscreenPoint(t);r&&(e.endOffset=r.totalLength-r.distance),e.lines.forEach(t=>{t.material.uniforms.startOffset.value=e.startOffset,t.material.uniforms.endOffset.value=e.endOffset}),e.subMeshMaterial.uniforms.startOffset.value=e.startOffset,e.subMeshMaterial.uniforms.endOffset.value=e.endOffset,e.cycleStartTime=performance.now()/1e3,e.lastAnimationProgress=0};if(e){let n=this.paths.get(e);n&&t(n)}else this.paths.forEach(e=>{e.enabled&&t(e)})}disposePathResources(e){e.lines.forEach(e=>{this.five.scene.remove(e),e.geometry.dispose(),e.material.dispose()}),this.five.scene.remove(e.particles),e.particleGeometry.dispose(),e.particleMaterial.dispose(),this.five.scene.remove(e.subMesh),e.subMeshGeometry.dispose(),e.subMeshMaterial.dispose()}dispose(){this.pause(),this.clearAllPaths(),this.hooks.emit(`dispose`)}},ke=(e,t)=>new Oe(e,t),Ae=`#five-CSS3DPlugin {
|
|
812
|
+
position: absolute;
|
|
813
|
+
pointer-events: none;
|
|
814
|
+
user-select: none;
|
|
815
|
+
transform-origin: left top;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
.five-CSS3DPlugin-X {
|
|
819
|
+
--timeout: 300ms;
|
|
820
|
+
transition: opacity ease-in-out var(--timeout);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.five-CSS3DPlugin-hidden {
|
|
824
|
+
opacity: 0;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
#five-CSS3DPlugin .five-CSS3DPlugin-hidden * {
|
|
828
|
+
pointer-events: none;
|
|
829
|
+
}`;function je(){return((1+Math.random())*parseInt(`10000`,36)|0).toString(36).substring(1)}function Me(){let e=je()+je().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 Ne=class extends p.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 l.Scene,this.styleSheet=new CSSStyleSheet,this.camera=new l.PerspectiveCamera,this.cacheMap=new WeakMap,this.createCSS3DObject=({id:e=Me(),name:t,innerHTML:n,sprite:r,normal:i,position:a,scalar:o=.00216,visible:s=!0,timeout:c})=>{let u=document.createElement(`div`);u.className=`five-CSS3DPlugin-X`,s||u.classList.add(`five-CSS3DPlugin-hidden`),c&&u.style.setProperty(`--timeout`,c+`ms`),u.innerHTML=n;let d=r?new ae(u):new M(u);if(d.userData={id:e,_visible:s,_timeout:c,get visible(){return this._visible},set visible(e){e?u.classList.remove(`five-CSS3DPlugin-hidden`):u.classList.add(`five-CSS3DPlugin-hidden`),this._visible=e},get timeout(){return this._timeout},set timeout(e){u.style.setProperty(`--timeout`,e+`ms`),this._timeout=e}},i){let e=new l.Vector3(0,0,1),t=new l.Quaternion().setFromUnitVectors(e,i.clone().normalize());d.quaternion.copy(t)}return a&&d.position.copy(a),o&&d.scale.setScalar(o),t&&(d.name=t),d},this.render=()=>{this.camera.fov=this.five.camera.fov,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 se,this.renderer.domElement.id=`five-CSS3DPlugin`,this.styleSheet.replaceSync(Ae),/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),this.state=Object.assign({enabled:!0,visible:!0},t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return m(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 l.Vector2);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 M&&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)}},Pe=(e,t)=>new Ne(e,t);function Fe(e,t,n){if(n){let r=new l.Vector3().subVectors(e.position,n).applyQuaternion(e.quaternion.clone().inverse()).applyQuaternion(t).add(n);e.position.copy(r)}e.quaternion.copy(t)}function Ie(e){return e==null}var Le=class extends l.Object3D{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 l.Box3().expandByObject(this.originObject3D).getCenter(new l.Vector3)):this.positionFrom instanceof l.Vector3?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 l.Quaternion().setFromUnitVectors(new l.Vector3(1,0,0),i.normalize());this.applyQuaternion(e)}if(a&&!i&&!o){let e=new l.Quaternion().setFromUnitVectors(new l.Vector3(0,1,0),a.normalize());this.applyQuaternion(e)}if(o&&!i&&!a){let e=new l.Quaternion().setFromUnitVectors(new l.Vector3(0,0,1),o.normalize());this.applyQuaternion(e)}if([i,a,o].filter(e=>!Ie(e)).length>=2){i||(i=new l.Vector3().crossVectors(a,o).normalize()),a||(a=new l.Vector3().crossVectors(i,o).normalize()),o||(o=new l.Vector3().crossVectors(i,a).normalize()),i.applyQuaternion(this.quaternion),a.applyQuaternion(this.quaternion),o.applyQuaternion(this.quaternion);let e=new l.Matrix4().makeBasis(i,a,o),t=new l.Quaternion().setFromRotationMatrix(e);this.quaternion.copy(t)}}}applyHelperScaleMatrix4(e,t){this.scale.applyMatrix4(e)}setHelperQuaternion(e,t){this.initQuaternion(),t?Fe(this,this.quaternion.clone().premultiply(e),t):this.quaternion.premultiply(e)}applyHelperQuaternion(e,t){if(t){let n=new l.Vector3().subVectors(this.position,t).applyQuaternion(e).add(t);this.position.copy(n)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}},Re=class extends Le{},ze=class extends Le{},Be=class extends Le{},Ve=class extends l.Group{constructor(e){super(),this.direction=e||`x`}};l.Line;var He=class extends l.Mesh{constructor(e,t,n){super(e,t),this.direction=n||`x`}},Ue={X:16730698,Y:54927,Z:3368703},W=class{static get X(){return new l.Color(Ue.X).convertSRGBToLinear().clone()}static get Y(){return new l.Color(Ue.Y).convertSRGBToLinear().clone()}static get Z(){return new l.Color(Ue.Z).convertSRGBToLinear().clone()}},G={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},We=class extends Ve{constructor(e){var t;super(e.direction),this.lineHeight=.5,this.arrowHeight=.1,this.name=`ArrowGroup`;let n=new l.Color((t=e.color)==null?16214315:t),r=()=>new l.MeshBasicMaterial({color:n,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1});this.arrow=new He(new l.ConeGeometry(.04,this.arrowHeight,32),r(),e.direction),this.arrow.name=`arrow-${e.direction}`,this.arrow.renderOrder=G.MOVE_HELPER_ARROW,this.arrowNeg=new He(new l.ConeGeometry(.04,this.arrowHeight,32),r(),e.direction),this.arrowNeg.name=`arrow-neg-${e.direction}`,this.arrowNeg.renderOrder=G.MOVE_HELPER_ARROW;let i=.004;this.line=new He(new l.CylinderGeometry(i,i,this.lineHeight,32),r(),e.direction),this.line.name=`line-${e.direction}`,this.line.renderOrder=G.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))}},Ge=class extends Ve{constructor(e){var t,n;super(`plane`),this.name=`CenterHandle`,this.faceNormals=[new l.Vector3(1,0,0),new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(0,-1,0),new l.Vector3(0,0,1),new l.Vector3(0,0,-1)],this.baseColor=new l.Color((t=e==null?void 0:e.color)==null?16419862:t);let r=(n=e==null?void 0:e.size)==null?.05:n,i=new l.Color(16755008).convertSRGBToLinear();this.faceMaterials=Array.from({length:6},()=>new l.MeshBasicMaterial({color:i,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,side:l.FrontSide}));let a=new l.BoxGeometry(r,r,r),o=new l.Mesh(a,this.faceMaterials);o.direction=`plane`,o.renderOrder=G.MOVE_HELPER_CENTER,o.name=`center-plane-handle`,this.cube=o,this.add(this.cube)}update(e){let t=new l.Vector3().subVectors(e.position,this.cube.getWorldPosition(new l.Vector3)).normalize(),n=this.cube.getWorldQuaternion(new l.Quaternion),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 l.Color(16755008).convertSRGBToLinear(),new l.Color(16419862).convertSRGBToLinear(),new l.Color(13921032).convertSRGBToLinear()];r.forEach((e,t)=>{let n=Math.floor(t/2);this.faceMaterials[e.index].color.copy(i[n])})}},Ke=class extends Ve{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 l.Color((r=e.color)==null?16776960:r),s=new l.BoxGeometry(i,i,.005),c=new l.MeshBasicMaterial({color:o,transparent:!0,opacity:.4,depthTest:!1,depthWrite:!1,side:l.DoubleSide});switch(this.handle=new l.Mesh(s,c),this.handle.direction=e.direction,this.handle.renderOrder=G.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 qe(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 Je(e){let{latitude:t,longitude:n}=e,r=new l.Vector3;return Ye-t<.03?r.set(0,1,0):Xe(0,n)?r.set(0,0,1):Xe(Math.PI,n)?r.set(0,0,-1):Xe(Ye,n)?r.set(1,0,0):r.set(-1,0,0),r}var Ye=Number((Math.PI/2).toFixed(5));function Xe(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function Ze(e,t){return Qe(document.createElement(t==null?`div`:t),e)}function Qe(e,t){if(!t)return e;for(let n in t)n&&t[n]&&(e.style[n]=t[n]);return e}function K(e){let t=Ze(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 $e=class extends Re{constructor(e,t){super(e,t),this.name=`MoveHelper`,(t==null?void 0:t.xArrowEnable)!==!1&&(this.xArrow=new We({direction:`x`,color:W.X})),(t==null?void 0:t.yArrowEnable)!==!1&&(this.yArrow=new We({direction:`y`,color:W.Y})),(t==null?void 0:t.zArrowEnable)!==!1&&(this.zArrow=new We({direction:`z`,color:W.Z})),(t==null?void 0:t.centerHandleEnable)!==!1&&(this.centerHandle=new Ge),(t==null?void 0:t.xyPlaneEnable)!==!1&&(this.xyPlane=new Ke({direction:`xy`,color:W.Z})),(t==null?void 0:t.xzPlaneEnable)!==!1&&(this.xzPlane=new Ke({direction:`xz`,color:W.Y})),(t==null?void 0:t.yzPlaneEnable)!==!1&&(this.yzPlane=new Ke({direction:`yz`,color:W.X})),t!=null&&t.container&&(t==null?void 0:t.moveTipsEnable)!==!1&&(this.container=t.container,this.moveTips=K({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 l.Vector3(1,0,0).applyQuaternion(this.quaternion),n=new l.Vector3(0,1,0).applyQuaternion(this.quaternion),r=new l.Vector3(0,0,1).applyQuaternion(this.quaternion),i=e.pose,a=Je(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(qe(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()}},et=class extends Be{constructor(e,t){super(e,t),this.name=`RotateHelper`,this.children=[],(t==null?void 0:t.yzCircleEnable)!==!1&&(this.xCircle=new tt({direction:`x`,color:W.X})),(t==null?void 0:t.xzCircleEnable)!==!1&&(this.yCircle=new tt({direction:`y`,color:W.Y})),(t==null?void 0:t.xyCircleEnable)!==!1&&(this.zCircle=new tt({direction:`z`,color:W.Z})),t!=null&&t.container&&(t==null?void 0:t.angleTipsEnable)!==!1&&(this.container=t==null?void 0:t.container,this.angleTips=K({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(qe(e,this.position))}update(e){if(e.type===`OrthographicCamera`)return;let t=this.helperObject.position.clone().sub(e.position).normalize(),n=new l.Vector3(1,0,0).applyQuaternion(this.quaternion),r=new l.Vector3(0,1,0).applyQuaternion(this.quaternion),i=new l.Vector3(0,0,1).applyQuaternion(this.quaternion),a=t.angleTo(n),o=t.angleTo(r),s=t.angleTo(i),c=Math.PI/2,u=o>=c,d=s>=c,f=a>=c;if(this.xCircle){let e=this.xCircle.circle.gapAngle;u&&d?this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):u&&!d?this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!u&&d?this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!u&&!d&&(this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.xCircle.angleSector&&(this.xCircle.angleSector.offsetAngle=e=>e,u&&d||u&&!d?this.xCircle.angleSector.baseAxes=new l.Vector3(0,0,1):!u&&d?(this.xCircle.angleSector.baseAxes=new l.Vector3(0,-1,0),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!u&&!d&&(this.xCircle.angleSector.baseAxes=new l.Vector3(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;f&&d?this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!d?this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&d?this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!d&&(this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),f&&d?this.yCircle.angleSector.baseAxes=new l.Vector3(1,0,0):f&&!d?(this.yCircle.angleSector.baseAxes=new l.Vector3(0,0,-1),this.yCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&d?(this.yCircle.angleSector.baseAxes=new l.Vector3(0,0,1),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!d&&(this.yCircle.angleSector.baseAxes=new l.Vector3(-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;f&&u?this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!u?this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&u?this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!u&&(this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.zCircle.angleSector&&(f&&u?this.zCircle.angleSector.baseAxes=new l.Vector3(1,0,0):f&&!u?(this.zCircle.angleSector.baseAxes=new l.Vector3(0,-1,0),this.zCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&u?(this.zCircle.angleSector.baseAxes=new l.Vector3(0,1,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!u&&(this.zCircle.angleSector.baseAxes=new l.Vector3(-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()}},tt=class extends l.Group{constructor(e){super(),this.direction=e.direction,this.circle=new nt(e),this.ring=new rt(e),this.angleSector=new it(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)}},nt=class extends l.Mesh{constructor(e){var t;super(),this.gapAngle=.02,this.geometry=new l.RingGeometry(.3,.35,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2),this.material=new l.MeshBasicMaterial({opacity:.6,transparent:!0,color:(t=e.color)==null?16777215:t,side:l.DoubleSide,depthTest:!1}),this.direction=e.direction,this.renderOrder=G.ROTATE_HELPER,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}},rt=class extends l.Group{constructor(e){super(),this.direction=e.direction;let t=.015,n=Array(8).fill(null).map((e,n)=>{let r=new l.RingGeometry(.3,.35,20,8,Math.PI/4*n+t,Math.PI/4-t*2),i=new l.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide}),a=new l.Mesh(r,i);return a.name=`AxesDashedRing-${this.direction}-${n}`,a});this.add(...n)}},it=class extends l.Mesh{constructor(e){var t;switch(super(),this.offsetAngle=e=>e,e.direction){case`x`:this.baseAxes=new l.Vector3(0,0,1);break;case`y`:this.baseAxes=new l.Vector3(1,0,0);break;case`z`:this.baseAxes=new l.Vector3(1,0,0);break}this.geometry=new l.CircleGeometry(.3505,48,0,1e-4),this.material=new l.MeshBasicMaterial({opacity:.4,color:(t=e.color)==null?16777215:t,depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide}),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`}},at=class extends ze{constructor(e){super(e),this.name=`BoundingBoxHelper`,this.positionAttribute=new l.BufferAttribute(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){Fe(this,e,t)}raycasterIntersectObject(e,t){return e.intersectObject(this,!1,t)}raycast(e,t){this.box.raycast(e,t)}update(){let e=new l.Box3,t=new l.Matrix4().getInverse(this.originObject3D.matrixWorld),n=new l.Vector3;if(this.originObject3D.updateMatrixWorld(!0),this.originObject3D.traverse(r=>{let i=r.geometry;if(!i)return;r.updateMatrixWorld(!0);let a=new l.Matrix4().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 l.BufferGeometry;t.setIndex(new l.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let n=new l.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),r=new l.LineSegments(t,n);return r.matrixAutoUpdate=!1,r}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 l.BufferGeometry;t.setIndex(new l.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let n=new l.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new l.Mesh(t,n)}},q=new Map;function ot(e){if(q.has(e))return q.get(e).hooks;let t=new c.Subscribe,n=null,r,i=()=>{n=requestAnimationFrame(i);let a=e.projectionMatrix.toArray().join(`,`)+e.matrixWorld.toArray().join(`,`);a!==r&&(r=a,t.emit(`cameraUpdate`))};return i(),q.set(e,{hooks:t,dispose:()=>{q.delete(e),cancelAnimationFrame(n)}}),t}function J(e){return arguments.length===0?[]:Array.isArray(e)?e:[e]}var Y=class{updateOtherControllers(e){this.otherControllers=e}getIsDragging(){return this.isDragging}constructor(e,t){var n,r,i;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 l.Box3().expandByObject(this.originObject3D)),this.boundingBox),this.hooks=(n=e.sharedHooks)==null?new c.Subscribe:n,this.internalHooks=(r=e.sharedInternalHooks)==null?new c.Subscribe:r,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=(i=e.onRender)==null?(()=>{}):i,this.config=t==null?{}:t,this.otherControllers=e.otherControllers,this.initialHelperPosition(),this.initialHelperQuaternion(),this.updateHelperScale(),this.cameraHooks=ot(this.camera),this.enable();let a=this.onSetOriginObjectScale.bind(this),o=this.onSetOriginObjectRotate.bind(this),s=this.onSetOriginObjectPosition.bind(this),u=this.onApplyOriginObjectScale.bind(this),d=this.onApplyOriginObjectRotate.bind(this),f=this.onApplyOriginObjectPosition.bind(this),p=this.initialHelperPosition.bind(this);this.cameraHooks.on(`cameraUpdate`,this.updateHelperScale),this.internalHooks.on(`initialHelperPosition`,p),this.internalHooks.on(`setObjectScale`,a),this.internalHooks.on(`setObjectRotate`,o),this.internalHooks.on(`setObjectPosition`,s),this.internalHooks.on(`applyObjectPosition`,f),this.internalHooks.on(`applyObjectRotate`,d),this.internalHooks.on(`applyObjectScale`,u),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`,p),this.internalHooks.off(`setObjectScale`,a),this.internalHooks.off(`setObjectRotate`,o),this.internalHooks.off(`setObjectPosition`,s),this.internalHooks.off(`applyObjectPosition`,f),this.internalHooks.off(`applyObjectRotate`,d),this.internalHooks.off(`applyObjectScale`,u),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 l.Vector3().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 l.Vector3().subVectors(this.boundingBox.max,t).multiply(e).add(t),r=new l.Vector3().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=J(e).filter(e=>!Ie(e)),i=[];for(let e of r)if(e.material||e instanceof l.Group){let r=e instanceof l.Group?e.children.filter(e=>e instanceof l.Mesh):[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 l.Vector3(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 st(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 X=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:G.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]),u=new l.BufferGeometry;u.setAttribute(`position`,new l.BufferAttribute(c,3));let d=new l.LineBasicMaterial({color:r.color,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.65}),f=new l.Line(u,d);return f.renderOrder=r.renderOrder,f}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]),u=e.geometry,d=u.getAttribute(`position`);d&&d.itemSize===3&&d.array.length===c.length?(d.array.set(c),d.needsUpdate=!0):u.setAttribute(`position`,new l.BufferAttribute(c,3)),(r==null?void 0:r.color)!==void 0&&e.material.color.setHex(r.color)}computeInfiniteLineLength(e){return st(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 Z(e,t,n){if(!t||!n||!e)return;let r=P(t,n);if(Math.abs(r.x)===1||Math.abs(r.y)===1)return;let i=new l.Raycaster;return i.setFromCamera(r,e),i.params.Points&&(i.params.Points.threshold=.1),i}function ct(e){let{raycaster:t,line:n,clampToLine:r=!0}=e,i=new l.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),new l.Vector3),a=i.projectPoint(n.start,new l.Vector3),o=i.projectPoint(n.end,new l.Vector3),s=new l.Line3(a,o),c=s.closestPointToPoint(t.ray.origin,r,new l.Vector3),u=c.distanceTo(o),d=c.distanceTo(a),f=s.distance();if(u>d&&u>f){let e=-c.distanceTo(a)/f,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)/f;return new l.Vector3().lerpVectors(n.start,n.end,e)}}var lt=class extends Y{get moveByMouseEnable(){return this._moveByMouse.enabled}constructor(...e){var t,n,r,i,a;super(...e),this.name=`MoveController`,this.solidGuide=new X(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 l.Vector3(1,0,0),i=new l.Vector3(0,1,0),a=new l.Vector3(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 l.Plane().setFromNormalAndCoplanarPoint(e,s),o=s.clone();this.startInfo={draggingDirection:n,startVectorProject:o,line:new l.Line3(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 l.Plane().setFromNormalAndCoplanarPoint(r,t),a=t.clone();this.startInfo={draggingDirection:n,startVectorProject:a,line:new l.Line3(a.clone(),a.clone()),plane:i}}else{if(!o)return this.dragEnd();this.startInfo={draggingDirection:n,startVectorProject:s,line:new l.Line3(s.clone().sub(o.normalize()),s.clone().add(o.normalize()))};try{let e=o.clone().normalize(),t=this.helperObject3D.getWorldPosition(new l.Vector3),n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:G.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=Z(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 Ge){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),u=()=>{this.helperObject3D.update(this.camera),this.isDragging&&this.updateDragGuideLineScale(),this.render()};u(),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`,u),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`,u)}),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 l.Vector3((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 l.Vector3)}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 l.Vector3);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 l.Vector3,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=ct({raycaster:e,line:t,clampToLine:!1});let o=r.position.clone(),s=a.clone().sub(n),c=new l.Matrix4;c.setPosition(s);let u=r.position.clone().applyMatrix4(c);if(this.hooks.emit(`wantToMove`,u))return;let d=u.clone();this.hooks.emit(`moveBefore`,d);let f=new l.Matrix4;f.setPosition(d.clone().sub(o)),r.position.copy(d),this.setTipsText(d),this.setTipsPosition(d),n.copy(a),this.internalHooks.emit(`applyObjectPosition`,{matrix:f}),this.hooks.emit(`move`,d)}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 l.Vector3).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`)}},ut=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();this.five=e,!(!l||!u||!f||!d)&&(this.helperController=new n({camera:l,model:u,domEvents:t,originObject3D:r,helperObject3D:i,container:f,scene:c==null?d:c,onRender:()=>{e.needsRender=!0},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()}},Q=new l.Quaternion,dt=class extends Y{get rotateCenter(){return this.helperObject3D.position.clone()}constructor(...e){var t,n,r;super(...e),this.name=`RotateController`,this.solidGuide=new X(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 l.Euler(l.MathUtils.degToRad(t),l.MathUtils.degToRad(n),l.MathUtils.degToRad(r)),a=new l.Quaternion().setFromEuler(i);if(this.hooks.emit(`wantToRotate`,a))return;let{originObject3D:o,rotateCenter:s}=this;Fe(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 l.Euler().setFromQuaternion(n.quaternion),i={x:l.MathUtils.radToDeg(r.x),y:l.MathUtils.radToDeg(r.y),z:l.MathUtils.radToDeg(r.z)},a={x:e===`x`?t:i.x,y:e===`y`?t:i.y,z:e===`z`?t:i.z},o=new l.Euler(l.MathUtils.degToRad(a.x),l.MathUtils.degToRad(a.y),l.MathUtils.degToRad(a.z));return new l.Quaternion().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 l.Quaternion,o=n===`x`?new l.Vector3(1,0,0):n===`y`?new l.Vector3(0,1,0):n===`z`?new l.Vector3(0,0,1):new l.Vector3(0,1,0),s=new l.Plane().setFromNormalAndCoplanarPoint(o,r),c=s.projectPoint(r.clone(),new l.Vector3).clone().sub(this.rotateCenter),u=this.getAngleHelper(n);if(!u)return this.dragEnd();let d=c.angleTo(u.baseAxes.clone().applyQuaternion(a)),f=u.offsetAngle(d);this.setAngleHelperStart(n,f),this.setAngleHelperLength(n,0),this.startInfo={direction:n,startVector:c,directionVector:o,plane:s,angleHelper:u,angle:0,helperQuaternion:a.clone(),startQuaternion:this.originObject3D.quaternion.clone()},Q=new l.Quaternion,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 l.Quaternion,e.decompose(new l.Vector3,n,new l.Vector3);let r=new l.Euler().setFromQuaternion(n);if(t===`x`)return Math.round(l.MathUtils.radToDeg(r.z));if(t===`y`)return Math.round(l.MathUtils.radToDeg(r.y));if(t===`z`)return Math.round(l.MathUtils.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 l.Quaternion,r.decompose(new l.Vector3,i,new l.Vector3);let t=new l.Euler().setFromQuaternion(i);if(e===`x`)return Math.round(l.MathUtils.radToDeg(t.z));if(e===`y`)return Math.round(l.MathUtils.radToDeg(t.y));if(e===`z`)return Math.round(l.MathUtils.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=Z(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 l.Vector3);if(!s)return;let c=this.rotateCenter.clone(),u=n.projectPoint(s.clone(),new l.Vector3).clone().sub(c),d=this.startInfo.directionVector.clone().normalize();u=u.clone().projectOnPlane(d).normalize().multiplyScalar(u.length());let f=new l.Quaternion().setFromUnitVectors(t.clone().normalize(),u.clone().normalize()),p=o.quaternion.clone().premultiply(f);if(t.angleTo(u)===0||this.hooks.emit(`wantToRotate`,p))return;let m=new l.Euler().setFromQuaternion(new l.Quaternion().setFromUnitVectors(t.clone().normalize().applyQuaternion(a.clone().inverse()),u.clone().normalize().applyQuaternion(a.clone().inverse())),`${i.toUpperCase()}${`XZY`.replace(i.toUpperCase(),``)}`)[i]*r.angleDirection,h=this.startInfo.angle,g=h+m,_=Math.PI/2,v=l.MathUtils.degToRad(5),y=l.MathUtils.degToRad(10),b=new l.Quaternion().setFromAxisAngle(d,g),x=this.startInfo.startQuaternion.clone().premultiply(b),S=this.extractAxisAngle(x,d),C=Math.round(S/_)*_,w=Math.abs(S-C);if(Math.abs(g)>y&&w<v){let e=C-S;g+=e}let T=g-h;this.startInfo.angle=g;let E=Math.abs(T)<1e-6&&Math.abs(m)>1e-6,D=this.snapGuideLines.length>0;E&&!D?this.showSnapGuideLines(i,c):!E&&D&&this.removeSnapGuideLines(),this.setAngleHelperLength(i,this.startInfo.angle),this.setTipsAngle(l.MathUtils.radToDeg(this.startInfo.angle));let O=new l.Quaternion().setFromAxisAngle(d,T);if(c){let e=new l.Vector3().subVectors(o.position,c).applyQuaternion(O).add(c);o.position.copy(e)}o.applyQuaternion(O),Q.premultiply(O),this.internalHooks.emit(`applyObjectRotate`,{quaternion:O,origin:c}),this.hooks.emit(`rotate`,o.quaternion),E||(this.startInfo.startVector=u)}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 l.Material&&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 l.Mesh&&n.geometry instanceof l.CircleGeometry){let{radius:e,segments:r,thetaLength:i}=n.geometry.parameters;n.geometry=new l.CircleGeometry(e,r,t,i)}else console.warn(`only support THREE.CircleGeometry`)}setAngleHelperLength(e,t){let n=.001,r=e===`x`||e===`y`?-t:t,i=r>=0?Math.max(r,n):Math.min(r,-n),a=this.getAngleHelper(e);if(a instanceof l.Mesh&&a.geometry instanceof l.CircleGeometry){let{radius:e,thetaStart:t}=a.geometry.parameters,n=Math.ceil(Math.abs(i)*(40/(2*Math.PI)));a.geometry=new l.CircleGeometry(e,n,t,i)}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 l.Vector3).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 l.Vector3(0,1,0),new l.Vector3(0,0,1)];case`y`:return[new l.Vector3(1,0,0),new l.Vector3(0,0,1)];case`z`:return[new l.Vector3(1,0,0),new l.Vector3(0,1,0)];default:return[]}})();for(let e of n){let n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:G.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=[]}},ft=class extends Y{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 l.Raycaster,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 l.Vector2;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 u=this._selected;if(s.length>0){var d,f,p,m=s[0],h=m.object;this._selected=h,p=this._bound(`mousemove`,h),u!=h&&(d=this._bound(`mouseover`,h),f=u&&this._bound(`mouseout`,u))}else f=u&&this._bound(`mouseout`,u),this._selected=null;p&&this._notify(`mousemove`,h,r,m),d&&this._notify(`mouseover`,h,r,m),f&&this._notify(`mouseout`,u,r,m)}}},$.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 l.Vector2;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 u=s[0],d=u.object,f=this._objectCtxGet(d),p=d.parent;f===void 0&&p;)f=this._objectCtxGet(p),p=p.parent;f&&this._notify(e,d,r,u)}}}},$.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 pt=`Object3DHelperPlugin`,mt=pt,ht=()=>{console.error(`${mt} is disposed`)},gt=()=>{console.warn(`${mt} is disabled`)},_t=()=>{console.error(`${mt} is disabled`)},vt=class{constructor(e){this.controllers={},this.state={visible:!0,enabled:!0,disposed:!1},this.hooks=new c.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)})}},yt=class extends p.Controller{constructor(e){super(e),this.name=pt,this.state={visible:!0,enabled:!0,disposed:!1},this.objectHelperMap=new Map,this.five=e}show(e){return m(this,void 0,void 0,function*(){this.setState({visible:!0},e)})}hide(e){return m(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 m(this,void 0,void 0,function*(){})}setState(e,t){var n;if(this.state.disposed)return ht();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return _t();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,t={}){var n,r;if(!e){console.error(`Object3D is undefined`);return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} already has helper`);return}let i=new vt,a=[],o=(n=this.five.getElement())==null?void 0:n.parentElement;this.five.camera;let s=Object.assign(Object.assign({},{moveHelper:!0,rotateHelper:!0,boundingBoxHelper:!1,moveHelperTips:!1,positionFrom:`objectPosition`}),t),{moveHelper:u,rotateHelper:d,boundingBoxHelper:f}=s,p=new l.Group;s.helperOffset&&p.position.copy(s.helperOffset),this.five.scene.add(p);let m=i.hooks,h=new c.Subscribe,g=new $(this.five.camera,this.five.getElement()),_=e=>{if(e)return typeof e==`boolean`?e:e.enable},v={};if(_(u)){let t=Object.assign(Object.assign({},this.getConfig(s.moveHelper)),s),n=new $e(e,Object.assign({container:o==null?void 0:o,moveTipsEnable:(r=s.moveHelperTips)==null?!1:r},t)),i=new ut(this.five,g,lt,e,n,t,m,h,p);v.moveController=i.helperController,a.push(()=>i.dispose())}if(_(d)){let t=Object.assign(Object.assign({},this.getConfig(s.rotateHelper)),s),n=new et(e,Object.assign({container:o==null?void 0:o},t)),r=new ut(this.five,g,dt,e,n,t,m,h,p);v.rotateController=r.helperController,a.push(()=>r.dispose())}if(_(f)){let t=new at(e),n=new ut(this.five,g,ft,e,t,void 0,m,h,p);v.boundingBoxController=n.helperController,a.push(()=>n.dispose())}return Object.values(v).forEach(e=>{e&&typeof e.updateOtherControllers==`function`&&e.updateOtherControllers(v)}),i.addControllers(v),this.objectHelperMap.set(e,{helper:i,disposers:a,helperGroup:p}),i.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&>()}getConfig(e){if(e&&typeof e!=`boolean`&&e.enable)return e}},bt=e=>new yt(e),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}},St=class extends p.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?6e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?4e3:i}load(){return m(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();if(e){let t=e.material.uniforms;t.u_aggregationEnabled.value=!1,t.u_aggregationProgress.value=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),u=new Float32Array(r);for(let e=0;e<r;e++)if(e===0)u[e]=0;else{let t=new l.Vector3(n[(e-1)*3],n[(e-1)*3+1],n[(e-1)*3+2]);u[e]=new l.Vector3(n[e*3],n[e*3+1],n[e*3+2]).distanceTo(t)+u[e-1]}for(let i=0;i<r;i++){let a=new l.Vector3(0,0,0),d=0;for(let e=i-5;e<i+6;e++)e>=0&&e<r&&(a.add(new l.Vector3(n[e*3],n[e*3+1],n[e*3+2])),d++);a.divideScalar(d).applyMatrix4(e.transform);let f=o.filter(a.x),p=s.filter(a.y),m=c.filter(a.z);t.push({position:new l.Vector3(f,p,m),location:u[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 l.Vector2(t,r),max:new l.Vector2(n,i)}}findClosestKeyframeToRay(e,t){let n=1/0,r=t[0].position.clone(),i=new l.Vector3;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}getCameraCurve(){return m(this,void 0,void 0,function*(){var e,t,n;let r=(n=(t=(e=this.five.model.viewLayers[0])==null?void 0:e.scene)==null?void 0:t.trajectories)==null?void 0:n[0];if(!r)throw Error(`未找到轨迹数据`);r.visible=!0,yield new Promise(e=>{let t=c.AnimationFrameLoop.shared.add(()=>{r.content.loadState===`READY`&&(t(),e(),r.visible=!1)})});let i=this.extractKeyframes(r);if(i.length<2)throw Error(`轨迹关键帧不足,至少需要2个关键帧`);this.keyframes=i;let a=this.computeAABB2D(i);this.boundingAABB=a;let o=this.curveHeight,s=new l.Vector3((a.min.x+a.max.x)/2,o,(a.min.y+a.max.y)/2),u=(a.max.x-a.min.x)/2,d=(a.max.y-a.min.y)/2,f=Math.sqrt(u*u+d*d),p=e=>{let t=new l.Vector3().subVectors(e,s);return t.length()<.001&&t.set(1,0,0),s.clone().add(t.normalize().multiplyScalar(f))},m=new l.Vector3(i[0].position.x,o,i[0].position.z),h=p(m),g=new l.Vector3().subVectors(s,m).normalize(),_=new l.Ray(m,g),v=new l.Vector3(-g.z,0,g.x).normalize(),y=new l.Ray(s,v),b=this.findClosestKeyframeToRay(y,i),x=p(new l.Vector3(b.x,o,b.z)),S=this.findClosestKeyframeToRay(_,i),C=p(new l.Vector3(S.x,o,S.z));return new l.CatmullRomCurve3([h,x,C],!1,`centripetal`,.5)})}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{e||t instanceof l.Mesh&&t.material&&t.material.uniforms&&t.material.uniforms.u_aggregationEnabled&&(e=t)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}setBounding(e,t,n){let r=this.findRenderMesh();r.material.uniforms.u_aggregationBoundsMin.value.copy(e),r.material.uniforms.u_aggregationBoundsMax.value.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),n=new l.Vector3(e.min.x,0,e.min.y),r=new l.Vector3(e.max.x,3,e.max.y);t.material.uniforms.u_aggregationBoundsMin.value.copy(n),t.material.uniforms.u_aggregationBoundsMax.value.copy(r),this.boundsSet=!0}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material.uniforms;e.u_aggregationEnabled.value=!0,e.u_aggregationProgress.value=0,e.u_aggregationPointDuration.value=Math.min(this.pointDuration/this.duration,1),this.five.needsRender=!0;let t=performance.now(),n=this.duration;this.cancelAnimation=c.AnimationFrameLoop.shared.add(()=>{let r=performance.now()-t,i=Math.min(r/n,1),a=i*i*(3-2*i);e.u_aggregationProgress.value=a,this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.u_aggregationEnabled.value=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return m(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),t=this.boundingAABB,n=new l.Vector3((t.min.x+t.max.x)/2,this.curveHeight,(t.min.y+t.max.y)/2),r=e.getPointAt(0),i=new c.Camera(90).copy(this.five.camera);i.position.copy(r),i.lookAt(n),i.computePose(0),this.five.setState(Object.assign({},i.pose)),this.setBounds();let a=this.findRenderMesh().material.uniforms;a.u_aggregationEnabled.value=!0,a.u_aggregationProgress.value=0,a.u_aggregationPointDuration.value=Math.min(this.pointDuration/this.duration,1),this.five.needsRender=!0;let o=this.duration,s=performance.now();return new Promise(t=>{this.cancelAnimation=c.AnimationFrameLoop.shared.add(()=>{let r=performance.now()-s,c=Math.min(r/o,1),l=c*c*(3-2*c);a.u_aggregationProgress.value=l,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(l);i.position.copy(u),i.lookAt(n),i.computePose(0),this.five.setState(Object.assign({},i.pose)),this.five.needsRender=!0,c>=1&&(a.u_aggregationEnabled.value=!1,a.u_aggregationProgress.value=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),t())})})})}},Ct=(e,t)=>new St(e,t);exports.BackgroundPlugin=ue,Object.defineProperty(exports,`BasePlugin`,{enumerable:!0,get:function(){return p}}),exports.CSS3DObject=M,exports.CSS3DPlugin=Pe,exports.CSS3DRenderer=se,exports.CSS3DSprite=ae,exports.DynamicPathLinePlugin=ke,exports.GaussianSplattingEntranceAnimationPlugin=Ct,exports.ItemMaskPlugin=A,exports.Object3DHelperController=yt,exports.Object3DHelperPlugin=bt,exports.OrbitControls=j,exports.OrientationPlugin=V,exports.PanoAnimePlugin=xe,exports.RoundedBoxGeometry=F,exports.TrajectoryPlugin=U;
|