@realsee/five 6.8.0-alpha.2 → 6.8.0-alpha.21
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 +4 -0
- package/AI_CONTEXT.md +4 -0
- package/README.md +9 -6
- package/{guides → ai_guides}/README.md +12 -2
- package/ai_guides/ai-doc-guidelines.md +102 -0
- package/{guides → ai_guides}/api.md +24 -1
- package/ai_guides/features/3dtile.md +172 -0
- package/{guides → ai_guides}/features/camera-animation.md +24 -3
- package/{guides → ai_guides}/features/clipper.md +2 -0
- package/{guides/features/coordnate-system.md → ai_guides/features/coordinate-system.md} +2 -0
- package/{guides → ai_guides}/features/event.md +2 -0
- package/{guides → ai_guides}/features/five.md +4 -0
- package/ai_guides/features/flowing-light-2d-pass.md +438 -0
- package/ai_guides/features/flowing-light-3d-pass.md +420 -0
- package/ai_guides/features/gaussian-blur-pass.md +202 -0
- package/{guides → ai_guides}/features/gesture.md +3 -0
- package/{guides → ai_guides}/features/get-screen-pixels.md +2 -0
- package/{guides → ai_guides}/features/image-options.md +3 -0
- package/{guides → ai_guides}/features/load-external-model.md +21 -0
- package/ai_guides/features/load-progress.md +140 -0
- package/ai_guides/features/material.md +153 -0
- package/{guides → ai_guides}/features/mode.md +4 -0
- package/{guides → ai_guides}/features/model.md +4 -1
- package/{guides → ai_guides}/features/move-pano-effect.md +2 -0
- package/{guides → ai_guides}/features/multi-work.md +2 -0
- package/ai_guides/features/pano-filter.md +148 -0
- package/{guides → ai_guides}/features/pano-tile.md +7 -14
- package/ai_guides/features/pano-uv.md +131 -0
- package/ai_guides/features/parameter.md +153 -0
- package/ai_guides/features/plugin.md +210 -0
- package/{guides → ai_guides}/features/postprocessing.md +39 -4
- package/{guides → ai_guides}/features/raycast.md +11 -0
- package/{guides → ai_guides}/features/request-proxy.md +2 -0
- package/{guides → ai_guides}/features/screen-project.md +2 -0
- package/{guides → ai_guides}/features/state.md +2 -0
- package/ai_guides/features/view-layer.md +187 -0
- package/{guides → ai_guides}/features/work.md +63 -2
- package/{guides → ai_guides}/glossary.md +26 -5
- package/{guides → ai_guides}/intro.md +1 -1
- package/{guides → ai_guides}/quick-start.md +1 -0
- package/ai_guides/release_notes/6.8.md +208 -0
- package/{guides → ai_guides}/template.md +17 -3
- package/docs/00_FOR_AI_AGENTS.md +11 -0
- package/docs/README.md +4 -7
- package/docs/assets/hierarchy.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.BoundingMesh.html +2 -2
- package/docs/classes/five.Camera.html +1 -1
- package/docs/classes/five.EyeDomeLightingPass.html +1 -1
- package/docs/classes/five.Five.html +73 -72
- 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 +31 -31
- package/docs/classes/five.ModelScene.html +1 -1
- package/docs/classes/five.NetworkSubscribe.html +1 -1
- 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 +16 -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 -53
- package/docs/classes/five.Scene.html +1 -1
- package/docs/classes/five.Subscribe.html +1 -1
- package/docs/classes/five.Tile.html +1 -1
- package/docs/classes/five.Tile3D.html +30 -26
- package/docs/classes/five.TileNode.html +1 -1
- package/docs/classes/five.Trajectory.html +1 -1
- package/docs/classes/five.TrajectoryNode.html +1 -1
- package/docs/classes/five.Work.html +16 -16
- package/docs/classes/five.WorkResolvedObserver.html +27 -2
- 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 +1 -1
- 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 +1 -1
- 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.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 +1 -1
- package/docs/classes/vfx.ParticleGPU.html +1 -1
- package/docs/classes/vfx.SpotLight.html +1 -1
- package/docs/documents/README.html +11 -2
- package/docs/documents/ai-doc-guidelines.html +60 -15
- package/docs/documents/api.html +40 -15
- package/docs/documents/features_3dtile.html +142 -45
- package/docs/documents/features_camera-animation.html +62 -5
- package/docs/documents/features_clipper.html +3 -0
- package/docs/documents/{features_coordnate-system.html → features_coordinate-system.html} +4 -1
- package/docs/documents/features_event.html +3 -0
- package/docs/documents/features_five.html +4 -0
- package/docs/documents/features_flowing-light-2d-pass.html +356 -0
- package/docs/documents/features_flowing-light-3d-pass.html +351 -0
- package/docs/documents/features_gaussian-blur-pass.html +182 -0
- package/docs/documents/features_gesture.html +4 -0
- package/docs/documents/features_get-screen-pixels.html +3 -0
- package/docs/documents/features_image-options.html +3 -0
- package/docs/documents/features_load-external-model.html +25 -2
- package/docs/documents/features_load-progress.html +110 -0
- package/docs/documents/features_material.html +341 -0
- package/docs/documents/features_mode.html +5 -0
- package/docs/documents/features_model.html +5 -1
- package/docs/documents/features_move-pano-effect.html +3 -0
- package/docs/documents/features_multi-work.html +3 -0
- package/docs/documents/features_pano-filter.html +122 -0
- package/docs/documents/features_pano-tile.html +34 -19
- package/docs/documents/features_pano-uv.html +82 -0
- package/docs/documents/features_parameter.html +76 -56
- package/docs/documents/features_plugin.html +105 -0
- package/docs/documents/features_postprocessing.html +22 -5
- package/docs/documents/features_raycast.html +4 -1
- package/docs/documents/features_request-proxy.html +3 -0
- package/docs/documents/features_screen-project.html +3 -0
- package/docs/documents/features_state.html +3 -0
- package/docs/documents/features_view-layer.html +158 -0
- package/docs/documents/features_work.html +63 -2
- package/docs/documents/glossary.html +31 -6
- package/docs/documents/intro.html +1 -1
- package/docs/documents/quick-start.html +1 -0
- package/docs/documents/release_notes_6.8.html +189 -0
- package/docs/documents/template.html +45 -4
- package/docs/functions/five.loadAt3d.html +1 -1
- package/docs/functions/five.loadB3dm.html +1 -1
- package/docs/functions/five.loadDome.html +1 -1
- package/docs/functions/five.loadDomez.html +1 -1
- package/docs/functions/five.loadFbx.html +1 -1
- package/docs/functions/five.loadGltf.html +1 -1
- package/docs/functions/five.loadPbm.html +1 -1
- package/docs/functions/five.loadPly.html +1 -1
- package/docs/functions/five.loadPnts.html +1 -1
- package/docs/functions/five.loadSplat.html +1 -1
- package/docs/functions/five.loadSpz.html +1 -1
- package/docs/functions/five.loadX3p.html +1 -1
- package/docs/functions/five.parseWork.html +1 -1
- package/docs/functions/vue.useFiveWorks.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +11 -2
- package/docs/interfaces/five.AddableObject.html +1 -1
- package/docs/interfaces/five.AjaxOptions.html +1 -1
- package/docs/interfaces/five.BaseEvent.html +2 -2
- package/docs/interfaces/five.EventCallback.html +53 -47
- package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +9 -9
- package/docs/interfaces/five.GestureEvent.html +2 -2
- package/docs/interfaces/five.ImageOptions.html +1 -1
- package/docs/interfaces/five.IntersectEvent.html +2 -2
- package/docs/interfaces/five.IntersectMesh.html +1 -1
- package/docs/interfaces/five.IntersectMeshInterface.html +1 -1
- package/docs/interfaces/five.Intersection.html +4 -3
- package/docs/interfaces/five.LooseWorkWithExtrinsics.html +6 -6
- package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +9 -9
- package/docs/interfaces/five.ModeChangeEvent.html +2 -2
- package/docs/interfaces/five.ModelControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ModelEvent.html +2 -2
- package/docs/interfaces/five.ModelSceneEvent.html +2 -2
- package/docs/interfaces/five.ModelTileEvent.html +8 -0
- package/docs/interfaces/five.MovePanoOptions.html +7 -7
- 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 +2 -2
- package/docs/interfaces/five.NetworkResponseError.html +1 -1
- package/docs/interfaces/five.NetworkTimeoutError.html +1 -1
- package/docs/interfaces/five.ObjectEvent.html +2 -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 +1 -1
- package/docs/interfaces/five.PanoEvent.html +2 -2
- package/docs/interfaces/five.PanoTextureEvent.html +2 -2
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ParameterMaterialValue.html +42 -38
- package/docs/interfaces/five.ParameterTilesetValue.html +15 -15
- package/docs/interfaces/five.ParameterValue.html +56 -52
- package/docs/interfaces/five.Pose.html +1 -1
- package/docs/interfaces/five.RenderEvent.html +2 -2
- package/docs/interfaces/five.ResolvedParameterValue.html +56 -52
- 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 +2 -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 +30 -26
- package/docs/interfaces/five.WorkCubeImage.html +1 -1
- package/docs/interfaces/five.WorkImage.html +1 -1
- package/docs/interfaces/five.WorkModel.html +8 -8
- package/docs/interfaces/five.WorkModelLayer.html +6 -6
- package/docs/interfaces/five.WorkObserver.html +27 -2
- package/docs/interfaces/five.WorkTile.html +1 -1
- package/docs/interfaces/five.WorksEvent.html +2 -2
- package/docs/interfaces/five.XRControllerEvent.html +2 -2
- package/docs/interfaces/five.XRGestureEvent.html +2 -2
- package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.XRSessionEvent.html +2 -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.DynamicPathLinePluginController.html +1 -1
- package/docs/interfaces/plugins.DynamicPathLinePluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.DynamicPathLinePluginType.State.html +1 -1
- package/docs/interfaces/plugins.ItemMaskController.html +1 -1
- package/docs/interfaces/plugins.ItemMaskPluginType.EventMap.html +1 -1
- package/docs/interfaces/plugins.ItemMaskPluginType.State.html +1 -1
- package/docs/interfaces/plugins.OrientationPluginController.html +1 -1
- 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.PluginTemplateType.EventMap.html +1 -1
- package/docs/interfaces/plugins.PluginTemplateType.State.html +1 -1
- package/docs/interfaces/plugins.TrajectoryController.html +1 -1
- package/docs/interfaces/react.FiveInjectionTypes.html +13 -13
- package/docs/modules/five.html +1 -1
- package/docs/modules.html +1 -1
- package/docs/types/five.ControllerEventTypes.html +27 -25
- package/docs/types/five.EasingFunction.html +1 -0
- package/docs/types/five.EventTypes.html +27 -25
- package/docs/types/five.FivePlugin.html +1 -1
- package/docs/types/five.FivePluginInit.html +1 -1
- package/docs/types/five.FivePluginInstance.html +1 -1
- package/docs/types/five.NetworkProgressCallback.html +1 -1
- 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/plugins.BasePlugin.EventMap.html +1 -1
- package/docs/variables/five.PROXY_CONTROLLER_EVENT_NAMES.html +1 -1
- package/five/application/analysis.d.ts +40 -0
- package/five/application/controllers.d.ts +41 -0
- package/five/application/events-legacy.d.ts +454 -0
- package/five/application/events.d.ts +69 -0
- package/five/application/five.d.ts +519 -0
- package/five/application/fiveInitArgs.d.ts +176 -0
- package/five/application/fiveLoadOptions.d.ts +21 -0
- package/five/application/generateDefaultVideoElement.d.ts +2 -0
- package/five/application/getViewportScale.d.ts +2 -0
- package/five/application/initLights.d.ts +3 -0
- package/five/application/mode.d.ts +28 -0
- package/five/application/renderPoweredByRealsee.d.ts +3 -0
- package/five/assets/cardboard-png-data-url.d.ts +2 -0
- package/five/assets/gradient-png-data-url.d.ts +2 -0
- package/five/assets/loading-png-data-url.d.ts +2 -0
- package/five/assets/phone-png-data-url.d.ts +2 -0
- package/five/assets/realsee-png-data-url.d.ts +2 -0
- package/five/bvh/bvhMath.d.ts +33 -0
- package/five/bvh/bvhMesh.d.ts +7 -0
- package/five/bvh/bvhNode.d.ts +29 -0
- package/five/bvh/bvhObject.d.ts +18 -0
- package/five/bvh/bvhPoints.d.ts +6 -0
- package/five/bvh/index.d.ts +10 -0
- package/five/bvh/worker.d.ts +35 -0
- package/five/cardboard/helper.d.ts +2 -0
- package/five/cardboard/index.d.ts +13 -0
- package/five/cardboard/sensor.d.ts +158 -0
- package/five/certificates/hardware.d.ts +1 -0
- package/five/controllers/base.d.ts +167 -0
- package/five/controllers/events.d.ts +71 -0
- package/five/controllers/floorplan.d.ts +119 -0
- package/five/controllers/mapview.d.ts +139 -0
- package/five/controllers/model.d.ts +57 -0
- package/five/controllers/panorama.d.ts +143 -0
- package/five/controllers/panoramaLike.d.ts +87 -0
- package/five/controllers/topview.d.ts +42 -0
- package/five/controllers/vrPanorama.d.ts +56 -0
- package/five/controllers/xrPanorama.d.ts +81 -0
- package/five/core/camera.d.ts +65 -0
- package/five/core/internalWebGLRenderer.d.ts +14 -0
- package/five/core/panoVideo.d.ts +18 -0
- package/five/core/scene.d.ts +10 -0
- package/five/core/tiling.d.ts +43 -0
- package/five/declare.d.ts +2 -1
- package/five/gaussian-splatting/util/renderData.d.ts +52 -0
- package/five/gaussian-splatting/wasm/data.d.ts +20 -0
- package/five/gaussian-splatting/wasm/sort.d.ts +18 -0
- package/five/gaussian-splatting/worker/dataWorker.d.ts +1 -0
- package/five/gaussian-splatting/worker/sortWorker.d.ts +1 -0
- package/five/index.d.ts +60 -4637
- package/five/index.js +193 -341
- package/five/index.mjs +26455 -31011
- package/five/meshes/boundingMesh.d.ts +12 -0
- package/five/meshes/intersectMesh.d.ts +8 -0
- package/five/meshes/panoCircleMesh.d.ts +35 -0
- package/five/meshes/panoCircleMeshCustom.d.ts +40 -0
- package/five/meshes/panoCircleMeshSolid.d.ts +34 -0
- package/five/meshes/panoSphereMesh.d.ts +27 -0
- package/five/model/helpers/coordinate-transform.d.ts +3 -0
- package/five/model/helpers/ellipsoid-coordinates.d.ts +14 -0
- package/five/model/helpers/get-edges-by-sphere.d.ts +8 -0
- package/five/model/helpers/get-recommend-tile3d-parameters.d.ts +8 -0
- package/five/model/index.d.ts +70 -0
- package/five/model/intersection.d.ts +18 -0
- package/five/model/loaders/at3d.d.ts +12 -0
- package/five/model/loaders/b3dm.d.ts +9 -0
- package/five/model/loaders/dome.d.ts +22 -0
- package/five/model/loaders/domez.d.ts +11 -0
- package/five/model/loaders/fbx.d.ts +8 -0
- package/five/model/loaders/glTF-helpers/extensions/CESIUM_RTC.d.ts +9 -0
- package/five/model/loaders/glTF-helpers/extensions/EXT_meshopt_compression.d.ts +8 -0
- package/five/model/loaders/glTF-helpers/extensions/EXT_texture_webp.d.ts +11 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_animation_pointer.d.ts +6 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_binary_glTF.d.ts +25 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_draco_mesh_compression.d.ts +11 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz.d.ts +9 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_materials_clearcoat.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_materials_emissive_strength.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_materials_sheen.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_materials_transmission.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_materials_unlit.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_mesh_quantization.d.ts +6 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_node_visibility.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_texture_basisu.d.ts +9 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_texture_transform.d.ts +10 -0
- package/five/model/loaders/glTF-helpers/extensions/REALSEE_materials_lightmap.d.ts +7 -0
- package/five/model/loaders/glTF-helpers/extensions/base.d.ts +24 -0
- package/five/model/loaders/glTF-helpers/glTF.d.ts +713 -0
- package/five/model/loaders/glTF-helpers/index.d.ts +47 -0
- package/five/model/loaders/glTF-helpers/parser.d.ts +114 -0
- package/five/model/loaders/glTF-helpers/type.d.ts +14 -0
- package/five/model/loaders/gltf.d.ts +10 -0
- package/five/model/loaders/obj.d.ts +9 -0
- package/five/model/loaders/pbm.d.ts +26 -0
- package/five/model/loaders/ply.d.ts +24 -0
- package/five/model/loaders/pnts.d.ts +8 -0
- package/five/model/loaders/protobuf/dome.d.ts +540 -0
- package/five/model/loaders/protobuf/pbm.d.ts +203 -0
- package/five/model/loaders/shared.d.ts +16 -0
- package/five/model/loaders/splat.d.ts +8 -0
- package/five/model/loaders/spz.d.ts +14 -0
- package/five/model/loaders/tile3d-helpers/feature-table.d.ts +15 -0
- package/five/model/loaders/tile3d-helpers/gl-type.d.ts +20 -0
- package/five/model/loaders/tile3d-helpers/parse-gltf-array-buffer.d.ts +2 -0
- package/five/model/loaders/tile3d-helpers/parse-header.d.ts +2 -0
- package/five/model/loaders/tile3d-helpers/parse-point-cloud-attributes.d.ts +2 -0
- package/five/model/loaders/tile3d-helpers/parse-point-cloud-attributes.worker.d.ts +6 -0
- package/five/model/loaders/tile3d-helpers/parse-table.d.ts +3 -0
- package/five/model/loaders/tile3d-helpers/tile3d-type.d.ts +35 -0
- package/five/model/loaders/x3p.d.ts +22 -0
- package/five/model/materials/pbmMaterial.d.ts +137 -0
- package/five/model/materials/pbmMeshMaterial.d.ts +126 -0
- package/five/model/materials/pbmPointCloudMaterial.d.ts +70 -0
- package/five/model/model-scene.d.ts +172 -0
- package/five/model/model.d.ts +209 -0
- package/five/model/objects/pbmContainer.d.ts +28 -0
- package/five/model/objects/pbmGaussianSplattingObject.d.ts +43 -0
- package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +55 -0
- package/five/model/objects/pbmGaussianSplattingTestMesh.d.ts +7 -0
- package/five/model/objects/pbmGroup.d.ts +8 -0
- package/five/model/objects/pbmMesh.d.ts +10 -0
- package/five/model/objects/pbmPointCloud.d.ts +7 -0
- package/five/model/parameter.d.ts +140 -0
- package/five/model/shaders/pbm_gaussian_splatting/fragment.d.ts +2 -0
- package/five/model/shaders/pbm_gaussian_splatting/vertex.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_basic/fragment.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_basic/vertex.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_none/fragment.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_none/vertex.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_phong/fragment.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_phong/vertex.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_standard/fragment.d.ts +2 -0
- package/five/model/shaders/pbm_mesh_standard/vertex.d.ts +2 -0
- package/five/model/shaders/pbm_pointcloud/fragment.d.ts +2 -0
- package/five/model/shaders/pbm_pointcloud/vertex.d.ts +2 -0
- package/five/model/tile3d/header.d.ts +88 -0
- package/five/model/tile3d/index.d.ts +214 -0
- package/five/model/tile3d/tile-cache.d.ts +18 -0
- package/five/model/tile3d/tile-content.d.ts +10 -0
- package/five/model/tile3d/tile-node.d.ts +24 -0
- package/five/model/tile3d/tile-request-scheduler.d.ts +17 -0
- package/five/model/tile3d/tile.d.ts +79 -0
- package/five/model/tile3d/tileset-base-traverser.d.ts +59 -0
- package/five/model/tile3d/tileset-most-detail-traverser.d.ts +14 -0
- package/five/model/tile3d/tileset-normal-traverser.d.ts +15 -0
- package/five/model/tile3d/tileset-skip-traverser.d.ts +60 -0
- package/five/model/tile3d/tileset.d.ts +69 -0
- package/five/model/tile3d/trajectory-content.d.ts +9 -0
- package/five/model/tile3d/trajectory-node.d.ts +15 -0
- package/five/model/tile3d/trajectory.d.ts +30 -0
- package/five/model/tile3d/types.d.ts +33 -0
- package/five/model/view-layer.d.ts +20 -0
- package/five/renderer/five-renderer.d.ts +17 -0
- package/five/renderer/index.d.ts +3 -0
- package/five/renderer/postprocessing/composer.d.ts +37 -0
- package/five/renderer/postprocessing/index.d.ts +7 -0
- package/five/renderer/postprocessing/passes/adaptive-luminance-pass.d.ts +17 -0
- package/five/renderer/postprocessing/passes/eye-dome-lighting-pass.d.ts +14 -0
- package/five/renderer/postprocessing/passes/flowing-light-2d-pass.d.ts +36 -0
- package/five/renderer/postprocessing/passes/flowing-light-3d-pass.d.ts +36 -0
- package/five/renderer/postprocessing/passes/gaussian-blur-pass.d.ts +12 -0
- package/five/renderer/postprocessing/passes/pass.d.ts +38 -0
- package/five/renderer/scene-renderers/point-cloud-high-quality-scene-renderer.d.ts +11 -0
- package/five/renderer/scene-renderers/scene-renderer.d.ts +9 -0
- package/five/renderer/scene-renderers/ssaa-scene-renderer.d.ts +15 -0
- package/five/renderer/tools/full-screen-quad.d.ts +15 -0
- package/five/renderer/tools/render-cube-to-equirectangular.d.ts +7 -0
- package/five/renderer/tools/render-full-screen-depth.d.ts +2 -0
- package/five/renderer/tools/render-full-screen.d.ts +2 -0
- package/five/texture/histogram.d.ts +54 -0
- package/five/texture/imageBitmap.d.ts +13 -0
- package/five/texture/initTexture.d.ts +3 -0
- package/five/texture/loader.d.ts +39 -0
- package/five/texture/textureData.d.ts +11 -0
- package/five/thirdparty/fflate.d.ts +1407 -0
- package/five/thirdparty/hammer.d.ts +375 -0
- package/five/thirdparty/jsrsasign.d.ts +753 -0
- package/five/thirdparty/meshopt_decoder.d.ts +15 -0
- package/five/three-version-check.d.ts +1 -0
- package/five/types/addableObject.d.ts +12 -0
- package/five/types/cube.d.ts +1 -0
- package/five/types/gestureInput.d.ts +24 -0
- package/five/types/imageOptions.d.ts +20 -0
- package/five/types/intersectMeshInterface.d.ts +8 -0
- package/five/types/movePanoEffect.d.ts +13 -0
- package/five/types/movePanoOptions.d.ts +36 -0
- package/five/types/panoCircleMeshInterface.d.ts +34 -0
- package/five/types/plugin.d.ts +25 -0
- package/five/types/pose.d.ts +17 -0
- package/five/types/state.d.ts +20 -0
- package/five/types/viewport.d.ts +22 -0
- package/five/utils/ajax.d.ts +66 -0
- package/five/utils/animationFrameLoop.d.ts +45 -0
- package/five/utils/array.d.ts +31 -0
- package/five/utils/asyncTaskQueue.d.ts +8 -0
- package/five/utils/bufferGeometry.d.ts +33 -0
- package/five/utils/calculateProgress.d.ts +39 -0
- package/five/utils/calculateThreeMouse.d.ts +13 -0
- package/five/utils/canplayVideo.d.ts +2 -0
- package/five/utils/clamp.d.ts +2 -0
- package/five/utils/clock.d.ts +17 -0
- package/five/utils/createSymbol.d.ts +5 -0
- package/five/utils/decodeText.d.ts +2 -0
- package/five/utils/deepEqual.d.ts +2 -0
- package/five/utils/deepFreeze.d.ts +2 -0
- package/five/utils/defineProperty.d.ts +9 -0
- package/five/utils/detector.d.ts +14 -0
- package/five/utils/distance.d.ts +10 -0
- package/five/utils/draco.d.ts +26 -0
- package/five/utils/easing.d.ts +63 -0
- package/five/utils/event.d.ts +159 -0
- package/five/utils/formatRad.d.ts +7 -0
- package/five/utils/imageSupport.d.ts +6 -0
- package/five/utils/imageURL.d.ts +42 -0
- package/five/utils/isEmptyObject.d.ts +2 -0
- package/five/utils/isNil.d.ts +6 -0
- package/five/utils/isNumber.d.ts +2 -0
- package/five/utils/isPowerOfTwo.d.ts +2 -0
- package/five/utils/isPromise.d.ts +2 -0
- package/five/utils/isSimilar.d.ts +6 -0
- package/five/utils/json.d.ts +7 -0
- package/five/utils/ktx2.d.ts +30 -0
- package/five/utils/lzma/index.d.ts +2 -0
- package/five/utils/lzma/lzma.d.ts +3 -0
- package/five/utils/lzma/lzmaWASM.d.ts +2 -0
- package/five/utils/lzma/lzmaWorker.d.ts +14 -0
- package/five/utils/memoryUsage.d.ts +29 -0
- package/five/utils/motion.d.ts +38 -0
- package/five/utils/noop.d.ts +6 -0
- package/five/utils/now.d.ts +7 -0
- package/five/utils/pano.d.ts +9 -0
- package/five/utils/pick.d.ts +3 -0
- package/five/utils/poseUtils.d.ts +5 -0
- package/five/utils/renderCubeTextureToCubeRenderTarget.d.ts +3 -0
- package/five/utils/renderDepth.d.ts +2 -0
- package/five/utils/renderTexturesToCubeRenderTarget.d.ts +10 -0
- package/five/utils/requestPermission.d.ts +3 -0
- package/five/utils/shaderContentFix.d.ts +7 -0
- package/five/utils/shaderMaterial.d.ts +20 -0
- package/five/utils/stateUtils.d.ts +5 -0
- package/five/utils/string-pattern.d.ts +8 -0
- package/five/utils/subscribe.d.ts +67 -0
- package/five/utils/tileCube.d.ts +19 -0
- package/five/utils/toFastProperties.d.ts +1 -0
- package/five/utils/typedCache.d.ts +10 -0
- package/five/utils/uniform.d.ts +15 -0
- package/five/utils/url.d.ts +35 -0
- package/five/utils/uuid.d.ts +5 -0
- package/five/utils/values.d.ts +2 -0
- package/five/utils/vectorCoordinates.d.ts +29 -0
- package/five/utils/volume.d.ts +111 -0
- package/five/utils/webglError.d.ts +7 -0
- package/five/utils/worker.d.ts +26 -0
- package/five/webxr/XRControllerModelFactory.d.ts +28 -0
- package/five/webxr/motionHelper.d.ts +68 -0
- package/five/webxr/xrButton.d.ts +4 -0
- package/five/webxr/xrController.d.ts +24 -0
- package/five/webxr/xrManager.d.ts +84 -0
- package/five/work/_ALLOW_HOST.d.ts +2 -0
- package/five/work/index.d.ts +6 -0
- package/five/work/keychain.d.ts +5 -0
- package/five/work/looseWorkType.d.ts +121 -0
- package/five/work/verify.d.ts +7 -0
- package/five/work/work.d.ts +236 -0
- package/five/work/workFetcher.d.ts +4 -0
- package/five/work/workJson.d.ts +3 -0
- package/five/work/workJsonType.d.ts +73 -0
- package/five/work/workObserverUtils.d.ts +36 -0
- package/five/work/workParser.d.ts +6 -0
- package/five/work/workResolvedObserver.d.ts +12 -0
- package/five/work/workVerify.d.ts +2 -0
- package/five/work/works.d.ts +10 -0
- package/gltf-loader/gltf-object.d.ts +17 -0
- package/gltf-loader/index.d.ts +60 -160
- package/gltf-loader/index.js +9 -9
- package/gltf-loader/index.mjs +1351 -1451
- package/gltf-loader/thirdparty/DDSLoader.d.ts +23 -0
- package/gltf-loader/thirdparty/DRACOLoader.d.ts +18 -0
- package/gltf-loader/thirdparty/GLTFLoader.d.ts +59 -0
- package/line/circle_png.d.ts +1 -0
- package/line/index.d.ts +19 -69
- package/line/index.js +4 -4
- package/line/index.mjs +334 -513
- package/line/utils/Line2.d.ts +7 -0
- package/line/utils/LineGeometry.d.ts +10 -0
- package/line/utils/LineMaterial.d.ts +20 -0
- package/line/utils/LineSegments2.d.ts +11 -0
- package/line/utils/LineSegmentsGeometry.d.ts +15 -0
- package/llms.txt +43 -31
- package/package.json +11 -2
- package/plugins/BackgroundPlugin/Controller.d.ts +20 -0
- package/plugins/BackgroundPlugin/index.d.ts +5 -0
- package/plugins/BackgroundPlugin/typings.d.ts +44 -0
- package/plugins/BasePlugin/index.d.ts +119 -0
- package/plugins/DynamicPathLinePlugin/Controller.d.ts +167 -0
- package/plugins/DynamicPathLinePlugin/index.d.ts +5 -0
- package/plugins/DynamicPathLinePlugin/line2/Line2.d.ts +7 -0
- package/plugins/DynamicPathLinePlugin/line2/LineGeometry.d.ts +10 -0
- package/plugins/DynamicPathLinePlugin/line2/LineMaterial.d.ts +17 -0
- package/plugins/DynamicPathLinePlugin/line2/LineSegments2.d.ts +11 -0
- package/plugins/DynamicPathLinePlugin/line2/LineSegmentsGeometry.d.ts +15 -0
- package/plugins/DynamicPathLinePlugin/typing.d.ts +129 -0
- package/plugins/DynamicPathLinePlugin/typings.d.ts +72 -0
- package/plugins/ItemMaskPlugin/Controller.d.ts +48 -0
- package/plugins/ItemMaskPlugin/index.d.ts +5 -0
- package/plugins/ItemMaskPlugin/typing.d.ts +58 -0
- package/plugins/OrientationPlugin/Controller.d.ts +82 -0
- package/plugins/OrientationPlugin/RoundedBoxGeometry.d.ts +11 -0
- package/plugins/OrientationPlugin/index.d.ts +6 -0
- package/plugins/OrientationPlugin/typing.d.ts +25 -0
- package/plugins/PanoAnimePlugin/Controller.d.ts +46 -0
- package/plugins/PanoAnimePlugin/index.d.ts +5 -0
- package/plugins/PanoAnimePlugin/typing.d.ts +37 -0
- package/plugins/PluginTemplate/Controller.d.ts +27 -0
- package/plugins/PluginTemplate/index.d.ts +5 -0
- package/plugins/PluginTemplate/typing.d.ts +21 -0
- package/plugins/TrajectoryPlugin/Controller.d.ts +85 -0
- package/plugins/TrajectoryPlugin/index.d.ts +6 -0
- package/plugins/TrajectoryPlugin/typing.d.ts +25 -0
- package/plugins/index.d.ts +9 -1102
- package/plugins/index.js +17 -21
- package/plugins/index.mjs +3342 -4245
- package/plugins/thirdParty/CSS3DRenderer.d.ts +32 -0
- package/plugins/thirdParty/OrbitControls.d.ts +78 -0
- package/plugins/utils/absoluteUrl.d.ts +5 -0
- package/plugins/utils/clamp.d.ts +2 -0
- package/plugins/utils/loadImage.d.ts +1 -0
- package/plugins/utils/motion.d.ts +38 -0
- package/plugins/utils/now.d.ts +6 -0
- package/plugins/utils/uuid.d.ts +5 -0
- package/react/canvas.d.ts +19 -0
- package/react/context.d.ts +11 -0
- package/react/createProvider.d.ts +95 -0
- package/react/createStore.d.ts +144 -0
- package/react/hooks/unsafe__useFiveInstance.d.ts +9 -0
- package/react/hooks/useFiveAction.d.ts +147 -0
- package/react/hooks/useFiveCameraDirection.d.ts +7 -0
- package/react/hooks/useFiveCameraRaycaster.d.ts +7 -0
- package/react/hooks/useFiveCurrentObserver.d.ts +11 -0
- package/react/hooks/useFiveCurrentState.d.ts +15 -0
- package/react/hooks/useFiveEventCallback.d.ts +12 -0
- package/react/hooks/useFiveFloor.d.ts +15 -0
- package/react/hooks/useFiveHelper.d.ts +14 -0
- package/react/hooks/useFiveModelBounding.d.ts +5 -0
- package/react/hooks/useFiveModelEffect.d.ts +14 -0
- package/react/hooks/useFiveModelIntersectRaycaster.d.ts +22 -0
- package/react/hooks/useFiveModelReadyState.d.ts +8 -0
- package/react/hooks/useFiveProject2d.d.ts +20 -0
- package/react/hooks/useFiveSceneEffect.d.ts +21 -0
- package/react/hooks/useFiveState.d.ts +6 -0
- package/react/hooks/useFiveWork.d.ts +29 -0
- package/react/index.d.ts +24 -830
- package/react/index.js +3 -3
- package/react/index.mjs +572 -783
- package/react/rendererPool.d.ts +7 -0
- package/react/withFive.d.ts +213 -0
- package/shader-lib/EvenessPlane/index.d.ts +10 -0
- package/shader-lib/PointCloudExpand/index.d.ts +59 -0
- package/shader-lib/PolygonCuter/index.d.ts +52 -0
- package/shader-lib/PolygonCuter/worker.d.ts +14 -0
- package/shader-lib/ShineModel/index.d.ts +7 -0
- package/shader-lib/SweepModel/index.d.ts +7 -0
- package/shader-lib/index.d.ts +5 -86
- package/shader-lib/index.js +13 -14
- package/shader-lib/index.mjs +424 -824
- package/sticker/geometry.d.ts +3 -0
- package/sticker/index.d.ts +68 -71
- 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 +17 -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 +188 -336
- package/vfx/airflow/airflow.d.ts +18 -0
- package/vfx/airflow/fragment-shader.d.ts +2 -0
- package/vfx/airflow/vertex-shader.d.ts +2 -0
- package/vfx/common/scale-shader.d.ts +2 -0
- package/vfx/common/simplex-noise-shader.d.ts +2 -0
- package/vfx/frame/fragment-shader.d.ts +2 -0
- package/vfx/frame/frame.d.ts +22 -0
- package/vfx/frame/vertex-shader.d.ts +2 -0
- package/vfx/index.d.ts +7 -363
- package/vfx/index.js +21 -21
- package/vfx/index.mjs +454 -910
- package/vfx/particle/fragment-shader.d.ts +2 -0
- package/vfx/particle/instance.d.ts +36 -0
- package/vfx/particle/particle.d.ts +205 -0
- package/vfx/particle/utils.d.ts +11 -0
- package/vfx/particle/vertex-shader.d.ts +2 -0
- package/vfx/particle-gpu/fragment-shader.d.ts +2 -0
- package/vfx/particle-gpu/instance.d.ts +36 -0
- package/vfx/particle-gpu/particle.d.ts +95 -0
- package/vfx/particle-gpu/utils.d.ts +11 -0
- package/vfx/particle-gpu/vertex-shader.d.ts +2 -0
- package/vfx/spotLight/fragment-shader.d.ts +2 -0
- package/vfx/spotLight/spotLight.d.ts +15 -0
- package/vfx/spotLight/vertex-shader.d.ts +2 -0
- package/vue/context.d.ts +7 -0
- package/vue/hooks/FiveCanvas.d.ts +36 -0
- package/vue/hooks/FiveProvider.d.ts +35 -0
- package/vue/hooks/unsafe__useFiveInject.d.ts +9 -0
- package/vue/hooks/useFiveAction.d.ts +178 -0
- package/vue/hooks/useFiveCameraDirection.d.ts +8 -0
- package/vue/hooks/useFiveCameraRaycaster.d.ts +8 -0
- package/vue/hooks/useFiveCurrentObserver.d.ts +12 -0
- package/vue/hooks/useFiveCurrentState.d.ts +16 -0
- package/vue/hooks/useFiveEventCallback.d.ts +11 -0
- package/vue/hooks/useFiveFloor.d.ts +16 -0
- package/vue/hooks/useFiveHelper.d.ts +15 -0
- package/vue/hooks/useFiveModel.d.ts +7 -0
- package/vue/hooks/useFiveModelBounding.d.ts +7 -0
- package/vue/hooks/useFiveModelIntersectRaycaster.d.ts +23 -0
- package/vue/hooks/useFiveModelReadyState.d.ts +9 -0
- package/vue/hooks/useFiveProject2d.d.ts +26 -0
- package/vue/hooks/useFiveScene.d.ts +6 -0
- package/vue/hooks/useFiveState.d.ts +16 -0
- package/vue/hooks/useFiveWork.d.ts +30 -0
- package/vue/index.d.ts +23 -467
- package/vue/index.js +3 -3
- package/vue/index.mjs +309 -301
- package/vue/rendererPool.d.ts +10 -0
- package/work-downloader/components/model-3d-tile.d.ts +2 -0
- package/work-downloader/components/model.d.ts +3 -0
- package/work-downloader/components/observer.d.ts +7 -0
- package/work-downloader/download.d.ts +16 -0
- package/work-downloader/index.d.ts +2 -33
- package/work-downloader/index.js +3 -3
- package/work-downloader/index.mjs +317 -556
- package/work-downloader/type.d.ts +28 -0
- package/work-downloader/utils/download-to-file.d.ts +1 -0
- package/work-downloader/utils/image-processing.d.ts +7 -0
- package/work-downloader/utils/join-url.d.ts +2 -0
- package/work-downloader/utils/log.d.ts +1 -0
- package/work-downloader/utils/relative-url.d.ts +1 -0
- package/docs/documents/five.FivePlugin.plugin.html +0 -60
- package/docs/documents/plugin.html +0 -60
- package/docs/media/five.ts +0 -2881
- package/docs/media/pass.ts +0 -64
- package/guides/ai-doc-guidelines.md +0 -72
- package/guides/features/3dtile.md +0 -264
- package/guides/features/parameter.md +0 -178
- package/guides/plugin.md +0 -206
- /package/{guides → ai_guides}/release_notes/6.6.md +0 -0
- /package/{guides → ai_guides}/release_notes/6.7.md +0 -0
- /package/{guides → ai_guides}/support.md +0 -0
package/docs/media/five.ts
DELETED
|
@@ -1,2881 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import { Camera } from "../core/camera";
|
|
3
|
-
import { Scene } from "../core/scene";
|
|
4
|
-
import { InternalWebGLRenderer } from "../core/internalWebGLRenderer";
|
|
5
|
-
import { noop } from "../utils/noop";
|
|
6
|
-
import { uuid } from "../utils/uuid";
|
|
7
|
-
import { clamp } from "../utils/clamp";
|
|
8
|
-
import { Pano, PanoId, panoStringify, panoEqual } from "../utils/pano";
|
|
9
|
-
import { pick, omitUndefinedFields } from "../utils/pick";
|
|
10
|
-
import { notSimilarValue, notSimilarVector3 } from "../utils/isSimilar";
|
|
11
|
-
import { AnimationFrameLoop } from "../utils/animationFrameLoop";
|
|
12
|
-
import { ModelScene, Model, Models, ModelOptions } from "../model";
|
|
13
|
-
import { now } from "../utils/now";
|
|
14
|
-
import { imageURL, ImageURLOptions } from "../utils/imageURL";
|
|
15
|
-
import { Fetcher, NetworkSubscribe } from "../utils/ajax";
|
|
16
|
-
import { stepNumber, stepCoordinates, stepVector } from "../utils/calculateProgress";
|
|
17
|
-
import { isPromise } from "../utils/isPromise";
|
|
18
|
-
import { Subscribe } from "../utils/subscribe";
|
|
19
|
-
import { isMobile } from "../utils/detector";
|
|
20
|
-
import { defineProperty } from "../utils/defineProperty";
|
|
21
|
-
import { createEvent, StateEvent, WorksEvent, ModelEvent, ModelSceneEvent, ModeChangeEvent, RenderEvent, ObjectEvent, NetworkResourceEvent } from "../utils/event";
|
|
22
|
-
import { requestDeviceOrientationPermission, requestXRSessionPermission } from "../utils/requestPermission";
|
|
23
|
-
import { Works, createWorks, Work, LooseWork, parseWork, LooseWorkWithExtrinsics } from "../work";
|
|
24
|
-
import { registerFetcher, getFetcher } from "../work/workFetcher";
|
|
25
|
-
import { verifyURL } from "../work/verify";
|
|
26
|
-
import { assignState, stateEqual } from "../utils/stateUtils";
|
|
27
|
-
import { assignPose } from "../utils/poseUtils";
|
|
28
|
-
import { ImageOptions, TextureOptions } from "../types/imageOptions";
|
|
29
|
-
import { Pose } from "../types/pose";
|
|
30
|
-
import { State } from "../types/state";
|
|
31
|
-
import { Viewport } from "../types/viewport";
|
|
32
|
-
import { MovePanoEffect } from "../types/movePanoEffect";
|
|
33
|
-
import { MovePanoOptions } from "../types/movePanoOptions";
|
|
34
|
-
import { Controllers } from "./controllers";
|
|
35
|
-
import { Mode } from "./mode";
|
|
36
|
-
import {
|
|
37
|
-
ControllerType, ControllerInitType, ControllerCustomInitTypes,
|
|
38
|
-
BaseControllerInitType, ControllerInstanceType
|
|
39
|
-
} from "./controllers";
|
|
40
|
-
import { FiveRenderer, type Pass, EyeDomeLightingPass, AdaptiveLuminancePass } from '../renderer';
|
|
41
|
-
import { PROXY_CONTROLLER_EVENT_NAMES, EventTypes } from "./events";
|
|
42
|
-
import { initLegacyEvent } from "./events-legacy";
|
|
43
|
-
import { generateDefaultVideoElement } from "./generateDefaultVideoElement";
|
|
44
|
-
import { initLights } from "./initLights";
|
|
45
|
-
import { FivePluginInstance } from "../types/plugin";
|
|
46
|
-
import type { FiveInitArgs } from "./fiveInitArgs";
|
|
47
|
-
import type { FiveLoadOptions } from "./fiveLoadOptions";
|
|
48
|
-
import { getViewportScale } from "./getViewportScale";
|
|
49
|
-
import { renderPoweredByRealsee } from "./renderPoweredByRealsee";
|
|
50
|
-
import { Analysis } from "./analysis";
|
|
51
|
-
import { draco } from '../utils/draco';
|
|
52
|
-
import { ktx2 } from '../utils/ktx2';
|
|
53
|
-
import { useNativeImageBitmap, canUseNativeImageBitmap } from '../texture/imageBitmap';
|
|
54
|
-
import { PBMGSRenderMesh } from '../model/objects/pbmGSRenderMesh';
|
|
55
|
-
/** 默认模态间切换动画时长 */
|
|
56
|
-
const DEFAULT_MODE_CHANGE_DURATION = 1000;
|
|
57
|
-
|
|
58
|
-
/** 默认相机FOV */
|
|
59
|
-
const DEFAULT_CAMERA_FOV = 90;
|
|
60
|
-
|
|
61
|
-
/** 默认代理 */
|
|
62
|
-
const DEFAULT_REQUEST_PROXY = (url: string) => {
|
|
63
|
-
return url
|
|
64
|
-
.replace('//vrlab-public.ljcdn.com/', '//vr-public.realsee-cdn.cn/')
|
|
65
|
-
.replace('//vrlab-image4.ljcdn.com/', '//vr-image-4.realsee-cdn.cn/')
|
|
66
|
-
.replace('//vrlab-image3.ljcdn.com/', '//vr-image-3.realsee-cdn.cn/')
|
|
67
|
-
.replace('//vrlab-image2.ljcdn.com/', '//vr-image-2.realsee-cdn.cn/')
|
|
68
|
-
.replace('//vrlab-image1.ljcdn.com/', '//vr-image-1.realsee-cdn.cn/');
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/* 一些共用的临时对象 */
|
|
72
|
-
const scratchSphere = new THREE.Sphere();
|
|
73
|
-
const scratchBox3 = new THREE.Box3();
|
|
74
|
-
const scratchViewport = new THREE.Vector4();
|
|
75
|
-
const scratchScissor = new THREE.Vector4();
|
|
76
|
-
const scratchClearColor = new THREE.Color();
|
|
77
|
-
const scratchRenderSize = new THREE.Vector2();
|
|
78
|
-
|
|
79
|
-
const worksMap = new WeakMap<Five, Works>();
|
|
80
|
-
const emptyWorks = createWorks([ parseWork(null) ]);
|
|
81
|
-
|
|
82
|
-
const Five_Instances: Record<string, Five> = {};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 如视 VR Web展示器
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```
|
|
89
|
-
* // 初始化构造函数
|
|
90
|
-
* const five = new Five();
|
|
91
|
-
* // 将绘制区域添加到页面上
|
|
92
|
-
* five.appendTo(document.body);
|
|
93
|
-
* // 加载 Work 数据
|
|
94
|
-
* five.load({...});
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
class Five extends Subscribe<EventTypes> {
|
|
98
|
-
|
|
99
|
-
static get version(): string {
|
|
100
|
-
//@ts-ignore
|
|
101
|
-
return process.env.FIVE_VERSION;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static get dracoPath(): string {
|
|
105
|
-
return draco.decoderPath;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static set dracoPath(path: string) {
|
|
109
|
-
draco.setDecoderPath(path);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
static get ktx2Path(): string {
|
|
113
|
-
return ktx2.transcoderPath;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static set ktx2Path(path: string) {
|
|
117
|
-
ktx2.setTranscoderPath(path);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
static get useNativeImageBitmap() {
|
|
121
|
-
return canUseNativeImageBitmap();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
static set useNativeImageBitmap(enable: boolean) {
|
|
125
|
-
useNativeImageBitmap(enable);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Five 的显示模式,可以通过 `five.changeMode` `five.setState` 来切换
|
|
130
|
-
* @description
|
|
131
|
-
* ```text
|
|
132
|
-
* Panorama 全景图游走模式
|
|
133
|
-
* Model 模型游走模式
|
|
134
|
-
* Floorplan 模型查看模式
|
|
135
|
-
* Topview 户型图模式
|
|
136
|
-
* VRPanorama VR眼镜模式
|
|
137
|
-
* XRPanorama VR硬件模式
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
static Mode = {
|
|
141
|
-
Panorama: "Panorama",
|
|
142
|
-
Model: "Model",
|
|
143
|
-
Floorplan: "Floorplan",
|
|
144
|
-
Topview: "Topview",
|
|
145
|
-
Mapview: "Mapview",
|
|
146
|
-
VRPanorama: "VRPanorama",
|
|
147
|
-
XRPanorama: "XRPanorama",
|
|
148
|
-
} as const;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 自动播放状态是否暂停
|
|
152
|
-
* @description
|
|
153
|
-
* 可以通过 `five.play` `five.pause` 方法播放或暂停
|
|
154
|
-
*/
|
|
155
|
-
public paused: boolean;
|
|
156
|
-
|
|
157
|
-
/** 当前点位序号 */
|
|
158
|
-
public pano: Pano;
|
|
159
|
-
|
|
160
|
-
/** 当前展示的模式 */
|
|
161
|
-
public currentMode: Mode;
|
|
162
|
-
|
|
163
|
-
/** 非模型部分使用的 `THREE.Scene` */
|
|
164
|
-
public scene: Scene;
|
|
165
|
-
/** 内部模型部分使用的 `THREE.Scene` */
|
|
166
|
-
public modelScene: ModelScene;
|
|
167
|
-
|
|
168
|
-
/** 供外部放置需要在xr场景下产生遮挡的物体们*/
|
|
169
|
-
public xrCustomObjectsScene: THREE.Scene;
|
|
170
|
-
|
|
171
|
-
/** 内部使用的 `Camera` */
|
|
172
|
-
public camera: Camera;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 当前设置的 `viewport`
|
|
176
|
-
* @description
|
|
177
|
-
* 可通过初始化,或者 setScissor 方式设置
|
|
178
|
-
* `viewport` 是将屏幕中的内容渲染到 `renderer` 的指定区域。
|
|
179
|
-
* 页面整体长宽均为 `1`。通过类似 css 的 `left` `bottom` `width` `height` 来确定区域。
|
|
180
|
-
* @example
|
|
181
|
-
* ```
|
|
182
|
-
* viewport: { left: 0.75, bottom: 0, width: 0.25, height: 1 }
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
public viewport: Viewport;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 当前使用的 THREE.WebGLRenderer。
|
|
189
|
-
* @description
|
|
190
|
-
* 如果初始化时传入了 `renderer` 则直接时该值
|
|
191
|
-
* 否则会通过 `preserveDrawingBuffer` `backgroundColor` `backgroundAlpha` `antialias` 创建一个 `THREE.WebGLRenderer`
|
|
192
|
-
*/
|
|
193
|
-
public renderer?: THREE.WebGLRenderer;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* 是否需要渲染
|
|
197
|
-
* @description
|
|
198
|
-
* 如果初始化设置了 `onlyRenderIfNeeds: true`, 则会激活按需渲染
|
|
199
|
-
* 可以通过设置 `five.needsRender = true` 来告知,five 会在下一帧渲染画面。
|
|
200
|
-
*/
|
|
201
|
-
public needsRender: boolean;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* 是否按需渲染
|
|
205
|
-
*/
|
|
206
|
-
public onlyRenderIfNeeds: boolean;
|
|
207
|
-
|
|
208
|
-
/** 是否显示 Powered By Realsee */
|
|
209
|
-
public poweredByRealsee: boolean;
|
|
210
|
-
|
|
211
|
-
/** 背景颜色 */
|
|
212
|
-
public backgroundColor: THREE.Color;
|
|
213
|
-
|
|
214
|
-
/** 背景透明度 */
|
|
215
|
-
public backgroundAlpha: number;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* 全景图的配置参数
|
|
219
|
-
* @description
|
|
220
|
-
* 可以动态对配置在 `work` 数据中的全景图片在 runtime 做 url 调整。
|
|
221
|
-
* 平衡加载时间和图片质量
|
|
222
|
-
*/
|
|
223
|
-
public imageOptions: ImageOptions;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 模型贴图的配置参数
|
|
227
|
-
* @description
|
|
228
|
-
* 可以动态对配置在 `work` 数据中的模型贴图在 runtime 做 url 调整。
|
|
229
|
-
* 平衡加载时间和图片质量
|
|
230
|
-
*/
|
|
231
|
-
public textureOptions: TextureOptions;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* 模型贴图的配置参数
|
|
235
|
-
* @description
|
|
236
|
-
* 可以动态对配置在 `work` 数据中的模型贴图在 runtime 做 url 调整。
|
|
237
|
-
* 平衡加载时间和图片质量
|
|
238
|
-
*/
|
|
239
|
-
public videoTexture: THREE.VideoTexture;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* 当前状态
|
|
243
|
-
* @description
|
|
244
|
-
* ```text
|
|
245
|
-
* five 设置了以下状态
|
|
246
|
-
*
|
|
247
|
-
* - mode: Mode
|
|
248
|
-
* - panoIndex: number
|
|
249
|
-
* - longitude: number
|
|
250
|
-
* - latitude: number
|
|
251
|
-
* - fov: number
|
|
252
|
-
* - offset: THREE.Vector3
|
|
253
|
-
*
|
|
254
|
-
* 可以通过 five.state 和 five.setState 来获取和设置。
|
|
255
|
-
* 通过 state 设置后,five 会通过合适的动画运动来达到设置的位置。
|
|
256
|
-
* 来迎合一些通过数据驱动的场景。
|
|
257
|
-
* ```
|
|
258
|
-
*/
|
|
259
|
-
public state: State;
|
|
260
|
-
|
|
261
|
-
/** 插件暴露的方法 */
|
|
262
|
-
public plugins: { [key: string]: FivePluginInstance<any> };
|
|
263
|
-
|
|
264
|
-
public readonly fiveId: string;
|
|
265
|
-
|
|
266
|
-
private stopAnimationLoop?: () => void;
|
|
267
|
-
private fps: { testTime: number, testCount: number };
|
|
268
|
-
private helperGroup: THREE.Group;
|
|
269
|
-
private modeChangeDuration: number;
|
|
270
|
-
private enableWheel: boolean;
|
|
271
|
-
private controller?: ControllerInstanceType;
|
|
272
|
-
private destroyed: boolean;
|
|
273
|
-
private stateSynced: boolean;
|
|
274
|
-
private controllerInits: { [P in Mode]: ControllerCustomInitTypes[P] };
|
|
275
|
-
private extraElements: HTMLElement[];
|
|
276
|
-
private getPixelsRenderTarget: THREE.WebGLRenderTarget;
|
|
277
|
-
private readyCallbacks: ((() => void) & { tile: boolean })[];
|
|
278
|
-
private syncingState: boolean;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
private loadWorkTask: Promise<void>;
|
|
282
|
-
private requestProxy: (url: string, referer: string) => string | Promise<string>;
|
|
283
|
-
private networkSubscribe: NetworkSubscribe;
|
|
284
|
-
private analysis?: Analysis;
|
|
285
|
-
private currentUpdateArgs: { time: number, args: any[] };
|
|
286
|
-
|
|
287
|
-
private fiveRenderer: FiveRenderer;
|
|
288
|
-
private adaptiveLuminancePass: AdaptiveLuminancePass;
|
|
289
|
-
private eyeDomeLightingPass: EyeDomeLightingPass;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
private pbmGSRenderMesh: PBMGSRenderMesh | null = null;
|
|
293
|
-
constructor(initArgs: FiveInitArgs = {}) {
|
|
294
|
-
super();
|
|
295
|
-
|
|
296
|
-
this.fiveId = uuid();
|
|
297
|
-
Five_Instances[this.fiveId] = this;
|
|
298
|
-
|
|
299
|
-
this.currentUpdateArgs = { time: now(), args: [] };
|
|
300
|
-
this.currentMode = 'Panorama';
|
|
301
|
-
this.pano = {
|
|
302
|
-
workCode: '',
|
|
303
|
-
panoIndex: 0,
|
|
304
|
-
};
|
|
305
|
-
this.needsRender = false;
|
|
306
|
-
this.onlyRenderIfNeeds = initArgs.onlyRenderIfNeeds ?? true;
|
|
307
|
-
this.imageOptions = { ...(initArgs.imageOptions ?? {}) };
|
|
308
|
-
this.textureOptions = { ...(initArgs.textureOptions ?? {}) };
|
|
309
|
-
this.poweredByRealsee = initArgs.poweredByRealsee ?? true;
|
|
310
|
-
this.backgroundColor = new THREE.Color(initArgs.backgroundColor ?? 0x181A1C);
|
|
311
|
-
this.backgroundAlpha = initArgs.backgroundAlpha ?? 1;
|
|
312
|
-
|
|
313
|
-
this.extraElements = [];
|
|
314
|
-
|
|
315
|
-
this.controllerInits = {
|
|
316
|
-
Panorama: Object.assign({}, initArgs.panorama),
|
|
317
|
-
Model: Object.assign({}, initArgs.model),
|
|
318
|
-
Floorplan: Object.assign({}, initArgs.floorplan),
|
|
319
|
-
Topview: Object.assign({}, initArgs.topview),
|
|
320
|
-
Mapview: Object.assign({}, initArgs.mapview),
|
|
321
|
-
VRPanorama: Object.assign({}, initArgs.vrPanorama),
|
|
322
|
-
XRPanorama: Object.assign({}, initArgs.xrPanorama),
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
this.fps = { testCount: 0, testTime: now() };
|
|
326
|
-
|
|
327
|
-
this.modeChangeDuration = initArgs.modeChangeDuration ?? DEFAULT_MODE_CHANGE_DURATION;
|
|
328
|
-
this.enableWheel = initArgs.enableWheel ?? true;
|
|
329
|
-
if (typeof window !== "undefined") {
|
|
330
|
-
if ('renderer' in initArgs) {
|
|
331
|
-
if (initArgs.renderer instanceof InternalWebGLRenderer) {
|
|
332
|
-
this.throwError(new Error("cannot render a internal renderer"));
|
|
333
|
-
}
|
|
334
|
-
this.renderer = initArgs.renderer;
|
|
335
|
-
} else {
|
|
336
|
-
try {
|
|
337
|
-
this.renderer = new InternalWebGLRenderer({
|
|
338
|
-
preserveDrawingBuffer: initArgs.preserveDrawingBuffer,
|
|
339
|
-
antialias: initArgs.antialias,
|
|
340
|
-
webgl2: initArgs.webgl2,
|
|
341
|
-
logarithmicDepthBuffer: initArgs.logarithmicDepthBuffer,
|
|
342
|
-
precision: initArgs.precision,
|
|
343
|
-
powerPreference: initArgs.powerPreference,
|
|
344
|
-
});
|
|
345
|
-
const viewportScale = getViewportScale();
|
|
346
|
-
this.renderer.setPixelRatio(viewportScale === 1 ? window.devicePixelRatio : 1);
|
|
347
|
-
this.renderer.setSize(512, 512);
|
|
348
|
-
this.renderer.setClearColor(this.backgroundColor, this.backgroundAlpha);
|
|
349
|
-
} catch (anyError) {
|
|
350
|
-
const error = anyError instanceof Error ? anyError : new Error(String(anyError));
|
|
351
|
-
this.throwError(error);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
this.getPixelsRenderTarget = new THREE.WebGLRenderTarget(1, 1, {
|
|
357
|
-
encoding: this.renderer?.outputEncoding ?? THREE.sRGBEncoding,
|
|
358
|
-
generateMipmaps: false,
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
this.viewport = Object.assign({ left: 0, bottom: 0, width: 1, height: 1 }, initArgs.viewport);
|
|
362
|
-
this.camera = new Camera(DEFAULT_CAMERA_FOV);
|
|
363
|
-
this.scene = new Scene();
|
|
364
|
-
this.xrCustomObjectsScene = new THREE.Scene();
|
|
365
|
-
this.scene.add(this.xrCustomObjectsScene);
|
|
366
|
-
this.scene.matrixAutoUpdate = false;
|
|
367
|
-
this.loadWorkTask = Promise.resolve();
|
|
368
|
-
|
|
369
|
-
this.requestProxy = initArgs.requestProxy ?? DEFAULT_REQUEST_PROXY;
|
|
370
|
-
this.networkSubscribe = new NetworkSubscribe();
|
|
371
|
-
this.networkSubscribe.on("network", (source, type, state, detail) => {
|
|
372
|
-
this.emit('network.resource', createEvent<NetworkResourceEvent>('network.resource', {
|
|
373
|
-
source,
|
|
374
|
-
requestType: type,
|
|
375
|
-
requestState: state,
|
|
376
|
-
detail,
|
|
377
|
-
}));
|
|
378
|
-
this.analysis?.network(this.works, source, type, state, detail);
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
this.readyCallbacks = [];
|
|
382
|
-
this.syncingState = false;
|
|
383
|
-
|
|
384
|
-
this.helperGroup = new THREE.Group();
|
|
385
|
-
this.helperGroup.name = "helper";
|
|
386
|
-
this.helperGroup.matrixAutoUpdate = false;
|
|
387
|
-
this.scene.add(this.helperGroup);
|
|
388
|
-
|
|
389
|
-
worksMap.set(this, emptyWorks);
|
|
390
|
-
|
|
391
|
-
this.modelScene = new ModelScene({
|
|
392
|
-
fiveId: this.fiveId,
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
this.modelScene.addEventListener('model.create', event => {
|
|
396
|
-
this.bindModel(event.model);
|
|
397
|
-
});
|
|
398
|
-
this.scene.add(this.modelScene);
|
|
399
|
-
|
|
400
|
-
const [ emptyModel ] = this.modelScene.setModels(emptyWorks, { forceReplaceImmediately: true });
|
|
401
|
-
// 认为 emptyModel 是 loaded 的情况。
|
|
402
|
-
// 防止 emptyModel 触发 model load 事件
|
|
403
|
-
// this.modelScene.loaded = true;
|
|
404
|
-
// 兼容业务的奇怪规则
|
|
405
|
-
// 认为 emptyModel 永远不会 loaded
|
|
406
|
-
defineProperty(emptyModel, 'loaded', {
|
|
407
|
-
get() {
|
|
408
|
-
return false;
|
|
409
|
-
},
|
|
410
|
-
set(_value) {},
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
this.videoTexture = new THREE.VideoTexture(initArgs.videoInstance || generateDefaultVideoElement());
|
|
414
|
-
|
|
415
|
-
const lights = initLights();
|
|
416
|
-
this.scene.add(lights);
|
|
417
|
-
|
|
418
|
-
this.state = {
|
|
419
|
-
mode: this.currentMode,
|
|
420
|
-
workCode: this.pano.workCode,
|
|
421
|
-
panoIndex: this.pano.panoIndex,
|
|
422
|
-
longitude: this.camera.pose.longitude,
|
|
423
|
-
latitude: this.camera.pose.latitude,
|
|
424
|
-
fov: this.camera.pose.fov,
|
|
425
|
-
offset: this.camera.pose.offset.clone(),
|
|
426
|
-
distance: this.camera.pose.distance,
|
|
427
|
-
};
|
|
428
|
-
this.stateSynced = false;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
this.destroyed = false;
|
|
432
|
-
this.paused = true;
|
|
433
|
-
if (typeof window !== "undefined") {
|
|
434
|
-
if (initArgs.play !== false) {
|
|
435
|
-
this.play();
|
|
436
|
-
}
|
|
437
|
-
this.stopAnimationLoop = AnimationFrameLoop.shared.add((time, deltaTime, ...args: any[]) => {
|
|
438
|
-
this.updateTime(time, deltaTime, ...args);
|
|
439
|
-
}, false, 0, 10);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
const fullscreenchange = () => {
|
|
443
|
-
if (typeof document !== "undefined" && document.fullscreenElement === null && this.currentMode === "VRPanorama") {
|
|
444
|
-
(this.controller as ControllerInstanceType<"VRPanorama">).emit("vr.requestExit", createEvent('vr.requestExit', {}));
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
const webglcontextrestored = () => {
|
|
448
|
-
this.needsRender = true;
|
|
449
|
-
};
|
|
450
|
-
if (typeof document !== "undefined") {
|
|
451
|
-
document.addEventListener("fullscreenchange", fullscreenchange, false);
|
|
452
|
-
}
|
|
453
|
-
if (this.renderer) {
|
|
454
|
-
this.renderer.domElement.addEventListener('webglcontextrestored', webglcontextrestored, false);
|
|
455
|
-
}
|
|
456
|
-
this.removeEventListeners = () => {
|
|
457
|
-
if (typeof document !== "undefined") {
|
|
458
|
-
document.removeEventListener("fullscreenchange", fullscreenchange, false);
|
|
459
|
-
}
|
|
460
|
-
if (this.renderer) {
|
|
461
|
-
this.renderer.domElement.removeEventListener('webglcontextrestored', webglcontextrestored, false);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// 加载插件
|
|
466
|
-
this.plugins = {};
|
|
467
|
-
if (initArgs.plugins && initArgs.plugins.length) {
|
|
468
|
-
for (const pluginInit of initArgs.plugins) {
|
|
469
|
-
if (typeof pluginInit === "function") {
|
|
470
|
-
pluginInit(this)
|
|
471
|
-
} else if (Array.isArray(pluginInit)) {
|
|
472
|
-
const [factory, instanceName, parameters] = pluginInit;
|
|
473
|
-
if (typeof factory === "function") {
|
|
474
|
-
const instance = factory(this, parameters);
|
|
475
|
-
if (typeof instanceName === "string") {
|
|
476
|
-
if (this.plugins[instanceName]) {
|
|
477
|
-
this.throwError(new Error(`plugin name ${instanceName} is exists.`));
|
|
478
|
-
} else {
|
|
479
|
-
this.plugins[instanceName] = instance;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
initLegacyEvent(this);
|
|
488
|
-
|
|
489
|
-
this.fiveRenderer = new FiveRenderer();
|
|
490
|
-
|
|
491
|
-
this.adaptiveLuminancePass = new AdaptiveLuminancePass();
|
|
492
|
-
this.adaptiveLuminancePass.enabled = false;
|
|
493
|
-
this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass);
|
|
494
|
-
|
|
495
|
-
this.eyeDomeLightingPass = new EyeDomeLightingPass(this.camera);
|
|
496
|
-
this.eyeDomeLightingPass.enabled = false;
|
|
497
|
-
this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass);
|
|
498
|
-
//3dgs,只有在webgl2下才能开启
|
|
499
|
-
if(initArgs.webgl2) {
|
|
500
|
-
this.pbmGSRenderMesh = new PBMGSRenderMesh();
|
|
501
|
-
this.scene.add(this.pbmGSRenderMesh);
|
|
502
|
-
}else{
|
|
503
|
-
console.warn("未开启webgl2,3dgs功能不可用");
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
get ident() {
|
|
508
|
-
return this.fiveId;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
get panoIndex(): number {
|
|
512
|
-
return this.pano.panoIndex;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* 析构 five 对象。
|
|
517
|
-
* @description
|
|
518
|
-
* 一旦调用了析构方法,则不能再使用当前 five 对象了。
|
|
519
|
-
* 你可以新建一个新的。
|
|
520
|
-
*/
|
|
521
|
-
public dispose(): void {
|
|
522
|
-
if (this.destroyed === true) return;
|
|
523
|
-
|
|
524
|
-
delete Five_Instances[this.fiveId];
|
|
525
|
-
|
|
526
|
-
this.emit("dispose");
|
|
527
|
-
|
|
528
|
-
this.destroyed = true;
|
|
529
|
-
this.pause();
|
|
530
|
-
if (this.stopAnimationLoop) {
|
|
531
|
-
this.stopAnimationLoop()
|
|
532
|
-
this.stopAnimationLoop = undefined;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
this.off();
|
|
536
|
-
this.networkSubscribe.off();
|
|
537
|
-
if (this.controller) {
|
|
538
|
-
this.controller.destroy();
|
|
539
|
-
this.controller = undefined;
|
|
540
|
-
}
|
|
541
|
-
const element = this.getElement();
|
|
542
|
-
if (element && element.parentNode) {
|
|
543
|
-
element.parentNode.removeChild(element);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const parameter = this.modelScene.parameter;
|
|
547
|
-
if (parameter.pano0) {
|
|
548
|
-
parameter.pano0.map.dispose();
|
|
549
|
-
}
|
|
550
|
-
if (parameter.pano1 && parameter.pano1.map !== parameter.pano0?.map) {
|
|
551
|
-
parameter.pano1.map.dispose();
|
|
552
|
-
}
|
|
553
|
-
parameter.reset('pano0', 'pano1');
|
|
554
|
-
|
|
555
|
-
this.modelScene.dispose();
|
|
556
|
-
this.scene.dispose();
|
|
557
|
-
this.xrCustomObjectsScene.dispose();
|
|
558
|
-
|
|
559
|
-
worksMap.set(this, emptyWorks);
|
|
560
|
-
|
|
561
|
-
if (this.renderer) {
|
|
562
|
-
this.renderer.render(new THREE.Scene(), new THREE.Camera());
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
this.fiveRenderer.dispose();
|
|
566
|
-
|
|
567
|
-
if (this.renderer instanceof InternalWebGLRenderer) {
|
|
568
|
-
if (this.renderer.forceContextLoss) {
|
|
569
|
-
this.renderer.forceContextLoss();
|
|
570
|
-
}
|
|
571
|
-
this.renderer.dispose();
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* 设置 `viewport`
|
|
577
|
-
* @param viewport - 指定区域
|
|
578
|
-
* `scissor` 是将屏幕中的内容渲染到 `renderer` 的指定区域。
|
|
579
|
-
* 请确保在 five 初始化时传入 `renderer` 对象
|
|
580
|
-
* 页面整体长宽均为 `1`。通过类似 css 的 `left` `bottom` `width` `height` 来确定区域。
|
|
581
|
-
* @example
|
|
582
|
-
* ```
|
|
583
|
-
* five.setViewport({ left: 0.75, bottom: 0, width: 0.25, height: 1 })
|
|
584
|
-
* ```
|
|
585
|
-
*/
|
|
586
|
-
public setViewport(viewport: Viewport): void {
|
|
587
|
-
Object.assign(this.viewport, viewport);
|
|
588
|
-
this.needsRender = true;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* 获取 boundingMesh
|
|
593
|
-
*/
|
|
594
|
-
public get boundingMesh() {
|
|
595
|
-
return this.modelScene.boundingMesh;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* 帮助元素显示/隐藏
|
|
600
|
-
*/
|
|
601
|
-
public get helperVisible() {
|
|
602
|
-
return this.helperGroup.visible;
|
|
603
|
-
}
|
|
604
|
-
public set helperVisible(visible: boolean) {
|
|
605
|
-
if (this.helperGroup.visible !== visible) {
|
|
606
|
-
this.helperGroup.visible = visible;
|
|
607
|
-
this.emit('helpers.visible', createEvent<ObjectEvent>('helpers.visible', {
|
|
608
|
-
object: this.helperGroup,
|
|
609
|
-
}));
|
|
610
|
-
this.needsRender = true;
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
public updateConfiguration(args: Pick<FiveInitArgs, "panorama" | "model" | "floorplan" | "topview" | "mapview" | "vrPanorama" | "imageOptions" | "textureOptions">, refresh: boolean = true) {
|
|
616
|
-
let needsUpdateController = false;
|
|
617
|
-
let forceUpdateController = false;
|
|
618
|
-
if (args.panorama) {
|
|
619
|
-
Object.assign(this.controllerInits["Panorama"], omitUndefinedFields(args.panorama));
|
|
620
|
-
if (this.currentMode === "Panorama") {
|
|
621
|
-
needsUpdateController = true;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
if (args.model) {
|
|
625
|
-
Object.assign(this.controllerInits["Model"], omitUndefinedFields(args.model));
|
|
626
|
-
if (this.currentMode === "Model") {
|
|
627
|
-
needsUpdateController = true;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
if (args.floorplan) {
|
|
631
|
-
Object.assign(this.controllerInits["Floorplan"], omitUndefinedFields(args.floorplan));
|
|
632
|
-
if (this.currentMode === "Floorplan") {
|
|
633
|
-
needsUpdateController = true;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
if (args.topview) {
|
|
637
|
-
Object.assign(this.controllerInits["Topview"], omitUndefinedFields(args.topview));
|
|
638
|
-
if (this.currentMode === "Topview") {
|
|
639
|
-
needsUpdateController = true;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (args.mapview) {
|
|
643
|
-
Object.assign(this.controllerInits["Mapview"], omitUndefinedFields(args.mapview));
|
|
644
|
-
if (this.currentMode === "Mapview") {
|
|
645
|
-
needsUpdateController = true;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
if (args.vrPanorama) {
|
|
649
|
-
Object.assign(this.controllerInits["VRPanorama"], omitUndefinedFields(args.vrPanorama));
|
|
650
|
-
if (this.currentMode === "VRPanorama") {
|
|
651
|
-
needsUpdateController = true;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
if (args.imageOptions) {
|
|
655
|
-
Object.assign(this.imageOptions, args.imageOptions);
|
|
656
|
-
if (this.currentMode === "Panorama" || this.currentMode === "VRPanorama") {
|
|
657
|
-
forceUpdateController = true;
|
|
658
|
-
needsUpdateController = true;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
if (args.textureOptions) {
|
|
662
|
-
Object.assign(this.textureOptions, args.textureOptions);
|
|
663
|
-
}
|
|
664
|
-
if (refresh && needsUpdateController && this.controller && this.currentMode) {
|
|
665
|
-
const result = this.controller.updateConfiguration(this.controllerInits[this.currentMode]);
|
|
666
|
-
if (!result || forceUpdateController) {
|
|
667
|
-
this.changeMode(this.currentMode, this.getCurrentState(), 0, false, true);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* 将显示区域加载到页面 DOM 中
|
|
674
|
-
* @description
|
|
675
|
-
* 如果你是传入的 `renderer`. 则你需要自行来方式显示区域该方法并不生效
|
|
676
|
-
*
|
|
677
|
-
* @param element - 加载到页面的 DOM 元素
|
|
678
|
-
* @param size - 显示区域尺寸 默认铺满这个 DOM 元素
|
|
679
|
-
*/
|
|
680
|
-
public appendTo(element: HTMLElement, size: { width?: number, height?: number } = {}): void {
|
|
681
|
-
if (!this.renderer) return;
|
|
682
|
-
if (!(this.renderer instanceof InternalWebGLRenderer)) {
|
|
683
|
-
this.throwError(new Error("cannot call appendTo method when render a external renderer"));
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
const renderElement = this.getElement();
|
|
687
|
-
if (!renderElement) return;
|
|
688
|
-
element.appendChild(renderElement);
|
|
689
|
-
this.refresh(size);
|
|
690
|
-
const positionType = window.getComputedStyle(element).position;
|
|
691
|
-
if (
|
|
692
|
-
positionType !== "relative" &&
|
|
693
|
-
positionType !== "absolute" &&
|
|
694
|
-
positionType !== "fixed" &&
|
|
695
|
-
positionType !== "sticky"
|
|
696
|
-
) {
|
|
697
|
-
element.style.position = "relative";
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* 设置显示区域尺寸
|
|
703
|
-
* @description
|
|
704
|
-
* 如果你是传入的 `renderer`. 则你需要自行来设置显示区域尺寸,该方法并不生效
|
|
705
|
-
*
|
|
706
|
-
* @param size - 显示区域尺寸 默认铺满这个 DOM 元素
|
|
707
|
-
* @param pixelRatio - 像素比 默认继承之前的设置
|
|
708
|
-
*/
|
|
709
|
-
public refresh(size: { width?: number, height?: number } = {}, pixelRatio?: number): void {
|
|
710
|
-
if (!this.renderer) return;
|
|
711
|
-
|
|
712
|
-
const element = this.renderer.domElement;
|
|
713
|
-
const container = element.parentNode as (HTMLElement | null);
|
|
714
|
-
|
|
715
|
-
let { width = container?.offsetWidth ?? 512, height = container?.offsetHeight ?? 512 } = size;
|
|
716
|
-
|
|
717
|
-
width = Math.max(1, width);
|
|
718
|
-
height = Math.max(1, height);
|
|
719
|
-
|
|
720
|
-
if (!pixelRatio) {
|
|
721
|
-
const viewportScale = getViewportScale();
|
|
722
|
-
const devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
723
|
-
pixelRatio = (viewportScale === 1 ? devicePixelRatio : 1) ?? 1;
|
|
724
|
-
if (pixelRatio > 1) {
|
|
725
|
-
const maxSize = Math.max(width, height) * pixelRatio;
|
|
726
|
-
const maxTextureSize = Math.min(this.renderer.capabilities.maxTextureSize, 4096);
|
|
727
|
-
if (maxSize > maxTextureSize) {
|
|
728
|
-
pixelRatio = Math.max(pixelRatio / maxSize * maxTextureSize, 1);
|
|
729
|
-
pixelRatio = Math.floor(pixelRatio * 100) / 100;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
this.renderer.setPixelRatio(pixelRatio);
|
|
735
|
-
this.renderer.setSize(width, height);
|
|
736
|
-
|
|
737
|
-
this.needsRender = true;
|
|
738
|
-
|
|
739
|
-
const time = now();
|
|
740
|
-
const deltaTime = time - this.currentUpdateArgs.time;
|
|
741
|
-
const args = this.currentUpdateArgs.args;
|
|
742
|
-
this.updateTime(time, deltaTime, ...args);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
* 绑定一个额外 DOM 区域,接受触控/鼠标事件
|
|
747
|
-
* @returns 解除该绑定
|
|
748
|
-
*/
|
|
749
|
-
public addExtraElement(element: HTMLElement): () => void {
|
|
750
|
-
if (this.extraElements.indexOf(element) === -1) {
|
|
751
|
-
this.extraElements.push(element);
|
|
752
|
-
if (this.controller) {
|
|
753
|
-
this.controller.bindExtraElement(element);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
return () => this.removeExtraElement(element);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* 解除绑定的一个额外 DOM 区域
|
|
761
|
-
*/
|
|
762
|
-
public removeExtraElement(element: HTMLElement): void {
|
|
763
|
-
const index = this.extraElements.indexOf(element);
|
|
764
|
-
if (index === -1) return;
|
|
765
|
-
this.extraElements.splice(index, 1);
|
|
766
|
-
if (this.controller) {
|
|
767
|
-
this.controller.unbindExtraElement(element);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
public getSize(target: THREE.Vector2): THREE.Vector2 {
|
|
772
|
-
if (!this.renderer) {
|
|
773
|
-
throw new Error("renderer is not initialized");
|
|
774
|
-
}
|
|
775
|
-
this.renderer.getSize(target);
|
|
776
|
-
target.x *= this.viewport.width;
|
|
777
|
-
target.y *= this.viewport.height;
|
|
778
|
-
return target;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
public getDrawingBufferSize(target: THREE.Vector2): THREE.Vector2 {
|
|
782
|
-
if (!this.renderer) {
|
|
783
|
-
throw new Error("renderer is not initialized");
|
|
784
|
-
}
|
|
785
|
-
this.renderer.getDrawingBufferSize(target);
|
|
786
|
-
target.x *= this.viewport.width;
|
|
787
|
-
target.y *= this.viewport.height;
|
|
788
|
-
return target;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* 移动相机。(不触发点位移动)
|
|
793
|
-
* @description
|
|
794
|
-
* 如果动画中途被打断(用户触发行为,或者调用 setState, load, changeMode)的等
|
|
795
|
-
* 会 Promise.reject。运动完成则 Promise.resolve
|
|
796
|
-
* @param pose - 相机目标位置
|
|
797
|
-
* @param duration - 动画触发的时常
|
|
798
|
-
* @param userAction - 是否用户触发
|
|
799
|
-
* @returns Promise 是否移动成功
|
|
800
|
-
*/
|
|
801
|
-
public updateCamera(pose: Partial<Pose>, duration: number, userAction: boolean = true): Promise<void> {
|
|
802
|
-
if (!this.controller) {
|
|
803
|
-
throw new Error('controller is not initialized.');
|
|
804
|
-
}
|
|
805
|
-
return this.controller.updateCamera(pose, duration, userAction);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
* 通过帧动画移动相机。(不触发点位移动)
|
|
810
|
-
* @description
|
|
811
|
-
* 如果动画中途被打断(用户触发行为,或者调用 setState, load, changeMode)的等
|
|
812
|
-
* 会 Promise.reject。运动完成则 Promise.resolve
|
|
813
|
-
* @param keyframes - 动画帧
|
|
814
|
-
* @param duration - 动画触发的时常
|
|
815
|
-
* @param userAction - 是否用户触发
|
|
816
|
-
* @returns Promise 是否移动成功
|
|
817
|
-
*/
|
|
818
|
-
public updateCameraWithKeyframes(keyframes: { progress: number; value: Pose; key?: string; }[], duration: number, userAction: boolean = true): Promise<void> {
|
|
819
|
-
if (!this.controller) {
|
|
820
|
-
throw new Error('controller is not initialized.');
|
|
821
|
-
}
|
|
822
|
-
return this.controller.updateCameraWithKeyframes(keyframes, duration, userAction);
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
/** 当前加载的 work 数据 */
|
|
826
|
-
public get works(): Works {
|
|
827
|
-
const works = worksMap.get(this);
|
|
828
|
-
if (!works) {
|
|
829
|
-
return emptyWorks;
|
|
830
|
-
}
|
|
831
|
-
return works;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
public get work(): Work {
|
|
835
|
-
return this.works[0];
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
public get observers() {
|
|
839
|
-
return this.work.observers;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
public get models(): Models {
|
|
843
|
-
return this.modelScene.models;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
public get model(): Model {
|
|
847
|
-
return this.modelScene.models[0];
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* 加载 Work 数据
|
|
852
|
-
* @param inputWork - Work 数据
|
|
853
|
-
* @param state - 初始化姿态
|
|
854
|
-
* - "inherit" 使用当前姿态
|
|
855
|
-
* - "initial" 使用 Work 数据中的 initial 姿态
|
|
856
|
-
* - State 自定义姿态
|
|
857
|
-
* @param options - 切换时间, 切换效果
|
|
858
|
-
*/
|
|
859
|
-
public load(
|
|
860
|
-
inputWork: string | Work | LooseWork | string[] | Work[] | LooseWork[] | LooseWorkWithExtrinsics[] | Promise<Work | LooseWork | Work[] | LooseWork[] | LooseWorkWithExtrinsics[]>,
|
|
861
|
-
state?: "inherit" | "initial" | Partial<State>,
|
|
862
|
-
options?: number | FiveLoadOptions,
|
|
863
|
-
userAction: boolean = true,
|
|
864
|
-
): Promise<void> {
|
|
865
|
-
if (!this.renderer) {
|
|
866
|
-
throw new Error("renderer is not initialized");
|
|
867
|
-
}
|
|
868
|
-
const task = this.loadWorkTask.then(() => {
|
|
869
|
-
if (isPromise(inputWork)) {
|
|
870
|
-
return inputWork.then(inputWork => {
|
|
871
|
-
return this.load_(inputWork, state, options, userAction);
|
|
872
|
-
});
|
|
873
|
-
} else {
|
|
874
|
-
return this.load_(inputWork, state, options, userAction);
|
|
875
|
-
}
|
|
876
|
-
});
|
|
877
|
-
this.loadWorkTask = task.catch(error => {
|
|
878
|
-
this.throwError(error);
|
|
879
|
-
});
|
|
880
|
-
return task;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
private load_(
|
|
884
|
-
inputWork: string | Work | LooseWork | string[] | Work[] | LooseWork[] | LooseWorkWithExtrinsics[],
|
|
885
|
-
state?: "inherit" | "initial" | Partial<State>,
|
|
886
|
-
options?: number | FiveLoadOptions,
|
|
887
|
-
userAction: boolean = true,
|
|
888
|
-
): Promise<void> {
|
|
889
|
-
const loadOptions: FiveLoadOptions = {};
|
|
890
|
-
if (typeof options === 'number') {
|
|
891
|
-
loadOptions.duration = options;
|
|
892
|
-
} else if (typeof options === 'object') {
|
|
893
|
-
Object.assign(loadOptions, options);
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
if (this.works === emptyWorks) {
|
|
897
|
-
if (loadOptions.duration === undefined) {
|
|
898
|
-
loadOptions.duration = 0;
|
|
899
|
-
}
|
|
900
|
-
if (loadOptions.effect === undefined) {
|
|
901
|
-
loadOptions.effect = 'instant';
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
const modelOptions: ModelOptions = {};
|
|
906
|
-
Object.assign(modelOptions, loadOptions.model);
|
|
907
|
-
|
|
908
|
-
// 处理历史 alias
|
|
909
|
-
if (!modelOptions["3d-tiles"] && loadOptions["3d-tiles"]) {
|
|
910
|
-
modelOptions["3d-tiles"] = loadOptions["3d-tiles"];
|
|
911
|
-
}
|
|
912
|
-
if (!modelOptions.textureOptions && loadOptions.textureOptions) {
|
|
913
|
-
modelOptions.textureOptions = loadOptions.textureOptions;
|
|
914
|
-
}
|
|
915
|
-
if (!modelOptions.textureOptions && this.textureOptions) {
|
|
916
|
-
modelOptions.textureOptions = this.textureOptions;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
let workArray: Work[] = [];
|
|
920
|
-
if (Array.isArray(inputWork)) {
|
|
921
|
-
for (const input of inputWork) {
|
|
922
|
-
if (input instanceof Work) {
|
|
923
|
-
workArray.push(input);
|
|
924
|
-
} else if (typeof input !== 'string' && 'work' in input) {
|
|
925
|
-
workArray.push(parseWork(input.work, input));
|
|
926
|
-
} else {
|
|
927
|
-
workArray.push(parseWork(input));
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
} else {
|
|
931
|
-
if (inputWork instanceof Work) {
|
|
932
|
-
workArray.push(inputWork);
|
|
933
|
-
} else {
|
|
934
|
-
workArray.push(parseWork(inputWork));
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
if (loadOptions.mode === 'add') {
|
|
939
|
-
workArray = ([] as Work[]).concat(this.works, workArray);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
let works: Works;
|
|
943
|
-
try {
|
|
944
|
-
works = createWorks(workArray);
|
|
945
|
-
} catch(error) {
|
|
946
|
-
this.throwError(error as Error);
|
|
947
|
-
return Promise.reject(error);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
for (const work of works) {
|
|
951
|
-
this.bindWorkFetcher(work);
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
if (state === undefined) {
|
|
955
|
-
state = "inherit";
|
|
956
|
-
}
|
|
957
|
-
if (state === 'inherit') {
|
|
958
|
-
if (this.works === emptyWorks) {
|
|
959
|
-
state = 'initial';
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
const prevMode = this.currentMode;
|
|
964
|
-
|
|
965
|
-
const initial = works.initial;
|
|
966
|
-
const initialObserver = initial.work.observers[0];
|
|
967
|
-
let initialPano: Pano = initialObserver ?
|
|
968
|
-
{
|
|
969
|
-
workCode: initialObserver.work.workCode,
|
|
970
|
-
panoIndex: initialObserver.panoIndex,
|
|
971
|
-
}:
|
|
972
|
-
{
|
|
973
|
-
workCode: initial.work.workCode,
|
|
974
|
-
panoIndex: 0,
|
|
975
|
-
};
|
|
976
|
-
let initialMode: Mode = initial.mode ?? (initialObserver ? 'Panorama' : 'Mapview');
|
|
977
|
-
let initialPose: Partial<Pose> = {};
|
|
978
|
-
|
|
979
|
-
if (state === "inherit") {
|
|
980
|
-
const currentState = this.getCurrentState();
|
|
981
|
-
const [currentWork] = works.filter(work => work.workCode === currentState.workCode);
|
|
982
|
-
if (currentWork) {
|
|
983
|
-
initialPano = {
|
|
984
|
-
workCode: currentState.workCode,
|
|
985
|
-
panoIndex: currentState.panoIndex,
|
|
986
|
-
}
|
|
987
|
-
initialMode = currentState.mode;
|
|
988
|
-
initialPose = {
|
|
989
|
-
longitude: currentState.latitude,
|
|
990
|
-
latitude: currentState.latitude,
|
|
991
|
-
fov: currentState.fov,
|
|
992
|
-
distance: currentState.distance,
|
|
993
|
-
offset: currentState.offset.clone(),
|
|
994
|
-
};
|
|
995
|
-
} else {
|
|
996
|
-
state = {
|
|
997
|
-
mode: prevMode,
|
|
998
|
-
}
|
|
999
|
-
const observer = works[0]?.observers?.[this.panoIndex];
|
|
1000
|
-
if (observer) {
|
|
1001
|
-
state.workCode = observer.work.workCode;
|
|
1002
|
-
state.panoIndex = observer.panoIndex;
|
|
1003
|
-
} else if (typeof works.initial.panoIndex === 'number') {
|
|
1004
|
-
state.workCode = works.initial.work.workCode;
|
|
1005
|
-
state.panoIndex = works.initial.panoIndex;
|
|
1006
|
-
} else {
|
|
1007
|
-
if (state.mode === 'Panorama' || state.mode === 'VRPanorama' || state.mode === 'XRPanorama') {
|
|
1008
|
-
state.mode = 'Mapview';
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
if (state.mode === prevMode) {
|
|
1012
|
-
state.longitude = this.camera.pose.longitude;
|
|
1013
|
-
state.latitude = this.camera.pose.latitude;
|
|
1014
|
-
state.fov = this.camera.pose.fov;
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
if (state === "initial") {
|
|
1020
|
-
if (typeof initial.panoIndex === 'number') {
|
|
1021
|
-
initialPano = {
|
|
1022
|
-
workCode: initial.work.workCode,
|
|
1023
|
-
panoIndex: initial.panoIndex,
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
if (initial.mode) {
|
|
1027
|
-
initialMode = initial.mode;
|
|
1028
|
-
}
|
|
1029
|
-
initialPose = {
|
|
1030
|
-
longitude: initial.longitude,
|
|
1031
|
-
latitude: initial.latitude,
|
|
1032
|
-
fov: initial.fov,
|
|
1033
|
-
distance: initial.distance,
|
|
1034
|
-
offset: initial.offset?.clone(),
|
|
1035
|
-
};
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
if (typeof state === 'object') {
|
|
1039
|
-
initialMode = state.mode ?? prevMode;
|
|
1040
|
-
if (typeof state.panoIndex === 'number') {
|
|
1041
|
-
const observer = works.getObserver({
|
|
1042
|
-
workCode: state.workCode ?? initial.work.workCode ?? '',
|
|
1043
|
-
panoIndex: state.panoIndex,
|
|
1044
|
-
});
|
|
1045
|
-
if (observer) {
|
|
1046
|
-
initialPano = {
|
|
1047
|
-
workCode: observer.work.workCode,
|
|
1048
|
-
panoIndex: observer.panoIndex,
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
initialPose = {
|
|
1053
|
-
longitude: state.longitude,
|
|
1054
|
-
latitude: state.latitude,
|
|
1055
|
-
fov: state.fov,
|
|
1056
|
-
distance: state.distance,
|
|
1057
|
-
offset: state.offset ? new THREE.Vector3().copy(state.offset) : undefined,
|
|
1058
|
-
};
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
let duration = loadOptions.duration ?? this.modeChangeDuration;
|
|
1062
|
-
if (
|
|
1063
|
-
(initialMode === 'Floorplan' || initialMode === 'Topview' || initialMode === 'Mapview') &&
|
|
1064
|
-
prevMode === initialMode
|
|
1065
|
-
) {
|
|
1066
|
-
duration = 0;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
let effect: MovePanoEffect = 'fly';
|
|
1070
|
-
if (
|
|
1071
|
-
(initialMode === 'Panorama' || initialMode === 'VRPanorama' || initialMode === 'XRPanorama') &&
|
|
1072
|
-
prevMode === initialMode
|
|
1073
|
-
) {
|
|
1074
|
-
effect = loadOptions.effect ?? 'fade';
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
this.emit('works.request', createEvent<WorksEvent>('works.request', {
|
|
1078
|
-
input: inputWork,
|
|
1079
|
-
works,
|
|
1080
|
-
userAction,
|
|
1081
|
-
}));
|
|
1082
|
-
|
|
1083
|
-
const applyController = (initialMode: Mode, initialPano: Pano, initialPose: Partial<Pose>) => {
|
|
1084
|
-
const currentState = this.getCurrentState();
|
|
1085
|
-
|
|
1086
|
-
let initialState = {
|
|
1087
|
-
mode: initialMode,
|
|
1088
|
-
...initialPano,
|
|
1089
|
-
...initialPose,
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
|
-
if (state === 'inherit') {
|
|
1093
|
-
initialState = this.getCurrentState();
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
this.pano = initialPano;
|
|
1097
|
-
const initialParams: ControllerInitType<Mode> = {
|
|
1098
|
-
initial: {
|
|
1099
|
-
state: initialState,
|
|
1100
|
-
currentState: currentState,
|
|
1101
|
-
duration,
|
|
1102
|
-
effect,
|
|
1103
|
-
userAction,
|
|
1104
|
-
},
|
|
1105
|
-
...this.commonParams(),
|
|
1106
|
-
...this.controllerInits[initialMode],
|
|
1107
|
-
};
|
|
1108
|
-
const initAnimationEndState = Controllers[initialState.mode].initAnimationEndState(initialParams);
|
|
1109
|
-
if (this.controller && prevMode === initialMode) {
|
|
1110
|
-
if (this.controller.updateWork(works, initAnimationEndState, { effect, duration }, userAction) === false) {
|
|
1111
|
-
this.controller.destroy();
|
|
1112
|
-
this.controller = this.applyController(initialMode, initialParams);
|
|
1113
|
-
}
|
|
1114
|
-
} else {
|
|
1115
|
-
if (this.controller) {
|
|
1116
|
-
this.controller.destroy();
|
|
1117
|
-
} else {
|
|
1118
|
-
const state = Controllers[initialMode].initAnimationEndState(initialParams);
|
|
1119
|
-
this.camera.setFromPose(state);
|
|
1120
|
-
this.emit("camera.update", createEvent<StateEvent>('camera.update', {
|
|
1121
|
-
state: this.getCurrentState(),
|
|
1122
|
-
userAction,
|
|
1123
|
-
}));
|
|
1124
|
-
}
|
|
1125
|
-
this.controller = this.applyController(initialMode, initialParams);
|
|
1126
|
-
const modeChangeEvent = createEvent<ModeChangeEvent>('mode.change', {
|
|
1127
|
-
prevMode,
|
|
1128
|
-
mode: initialMode,
|
|
1129
|
-
state: initAnimationEndState,
|
|
1130
|
-
userAction,
|
|
1131
|
-
});
|
|
1132
|
-
try {
|
|
1133
|
-
this.emit('mode.change', modeChangeEvent);
|
|
1134
|
-
} catch(error: any) {
|
|
1135
|
-
console.error(error);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
this.updateTime(this.currentUpdateArgs.time, 0, ...this.currentUpdateArgs.args);
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
worksMap.set(this, works);
|
|
1142
|
-
|
|
1143
|
-
let loadModelPromise = Promise.resolve();
|
|
1144
|
-
if (
|
|
1145
|
-
initialMode === Five.Mode.Floorplan ||
|
|
1146
|
-
initialMode === Five.Mode.Topview ||
|
|
1147
|
-
initialMode === Five.Mode.Mapview ||
|
|
1148
|
-
initialMode === Five.Mode.Model
|
|
1149
|
-
) {
|
|
1150
|
-
if (this.modelScene.loaded === false) {
|
|
1151
|
-
this.camera.setFromPose(initialPose);
|
|
1152
|
-
assignPose(this.state, this.camera.pose);
|
|
1153
|
-
}
|
|
1154
|
-
const models = this.modelScene.setModels(works, modelOptions);
|
|
1155
|
-
loadModelPromise = Promise.all(models.map(model => model.loadedReady)).then(() => {
|
|
1156
|
-
this.needsRender = true;
|
|
1157
|
-
applyController(initialMode, initialPano, initialPose);
|
|
1158
|
-
this.emit("camera.update", createEvent<StateEvent>('camera.update', {
|
|
1159
|
-
state: this.getCurrentState(),
|
|
1160
|
-
userAction,
|
|
1161
|
-
}));
|
|
1162
|
-
});
|
|
1163
|
-
} else {
|
|
1164
|
-
applyController(initialMode, initialPano, initialPose);
|
|
1165
|
-
const controller = this.controller!;
|
|
1166
|
-
let callbacked = false;
|
|
1167
|
-
this.modelScene.autoRefine = false;
|
|
1168
|
-
const callback = () => {
|
|
1169
|
-
if (this.works === works && callbacked === false) {
|
|
1170
|
-
this.needsRender = true;
|
|
1171
|
-
this.emit("camera.update", createEvent<StateEvent>('camera.update', {
|
|
1172
|
-
state: this.getCurrentState(),
|
|
1173
|
-
userAction,
|
|
1174
|
-
}));
|
|
1175
|
-
callbacked = true;
|
|
1176
|
-
this.modelScene.autoRefine = true;
|
|
1177
|
-
}
|
|
1178
|
-
controller!.off("pano.arrived", callback);
|
|
1179
|
-
controller!.off("pano.cancel", callback);
|
|
1180
|
-
}
|
|
1181
|
-
const models = this.modelScene.setModels(works, modelOptions);
|
|
1182
|
-
loadModelPromise = Promise.all(models.map(model => model.initReady)).then(noop);
|
|
1183
|
-
controller!.once("pano.arrived", callback);
|
|
1184
|
-
controller!.once("pano.cancel", callback);
|
|
1185
|
-
setTimeout(callback, (loadOptions.duration ?? this.modeChangeDuration) + 1000);
|
|
1186
|
-
}
|
|
1187
|
-
this.emit("works.load", createEvent<WorksEvent>('works.load', {
|
|
1188
|
-
input: inputWork,
|
|
1189
|
-
userAction,
|
|
1190
|
-
works,
|
|
1191
|
-
}));
|
|
1192
|
-
return loadModelPromise
|
|
1193
|
-
.then(() => this.ready())
|
|
1194
|
-
.then(() => {
|
|
1195
|
-
this.emit("works.ready", createEvent<WorksEvent>('works.ready', {
|
|
1196
|
-
input: inputWork,
|
|
1197
|
-
userAction,
|
|
1198
|
-
works,
|
|
1199
|
-
}));
|
|
1200
|
-
this.analysis?.work(works);
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
public reset(): Promise<void> {
|
|
1205
|
-
const task = this.loadWorkTask.then(() => {
|
|
1206
|
-
return this.reset_();
|
|
1207
|
-
});
|
|
1208
|
-
this.loadWorkTask = task.catch(error => {
|
|
1209
|
-
this.throwError(error);
|
|
1210
|
-
});
|
|
1211
|
-
return task;
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
public reset_(): Promise<void> {
|
|
1215
|
-
return new Promise(resolve => {
|
|
1216
|
-
if (this.controller) {
|
|
1217
|
-
this.controller.destroy();
|
|
1218
|
-
this.controller = undefined;
|
|
1219
|
-
}
|
|
1220
|
-
const parameter = this.modelScene.parameter;
|
|
1221
|
-
if (parameter.pano0) {
|
|
1222
|
-
parameter.pano0.map.dispose();
|
|
1223
|
-
}
|
|
1224
|
-
if (parameter.pano1 && parameter.pano1.map !== parameter.pano0?.map) {
|
|
1225
|
-
parameter.pano1.map.dispose();
|
|
1226
|
-
}
|
|
1227
|
-
parameter.set({ pano0: null, pano1: null, modelAlpha: 1 });
|
|
1228
|
-
|
|
1229
|
-
worksMap.set(this, emptyWorks);
|
|
1230
|
-
this.modelScene.setModels(emptyWorks, { forceReplaceImmediately: true });
|
|
1231
|
-
if (this.renderer) {
|
|
1232
|
-
this.modelScene.update(this.renderer, this.camera);
|
|
1233
|
-
}
|
|
1234
|
-
this.needsRender = true;
|
|
1235
|
-
|
|
1236
|
-
this.currentMode = 'Panorama';
|
|
1237
|
-
this.pano = {
|
|
1238
|
-
workCode: '',
|
|
1239
|
-
panoIndex: 0,
|
|
1240
|
-
};
|
|
1241
|
-
this.camera.setFromPose({
|
|
1242
|
-
distance: 0,
|
|
1243
|
-
fov: DEFAULT_CAMERA_FOV,
|
|
1244
|
-
longitude: 0,
|
|
1245
|
-
latitude: 0,
|
|
1246
|
-
offset: new THREE.Vector3(0, 0, 0),
|
|
1247
|
-
})
|
|
1248
|
-
this.state = {
|
|
1249
|
-
mode: this.currentMode,
|
|
1250
|
-
workCode: this.pano.workCode,
|
|
1251
|
-
panoIndex: this.pano.panoIndex,
|
|
1252
|
-
longitude: this.camera.pose.longitude,
|
|
1253
|
-
latitude: this.camera.pose.latitude,
|
|
1254
|
-
fov: this.camera.pose.fov,
|
|
1255
|
-
offset: this.camera.pose.offset.clone(),
|
|
1256
|
-
distance: this.camera.pose.distance,
|
|
1257
|
-
};
|
|
1258
|
-
this.camera.needsRender = false;
|
|
1259
|
-
this.needsRender = false;
|
|
1260
|
-
resolve();
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
/**
|
|
1265
|
-
* 切换模态
|
|
1266
|
-
* @param mode - 切换到的模态
|
|
1267
|
-
* @param state - 切换完成时的姿态
|
|
1268
|
-
* @param options - 模态切换动画用时
|
|
1269
|
-
* @param userAction - 是否时用户动作触发 默认 true
|
|
1270
|
-
* @param force - 必须重新初始化 controller
|
|
1271
|
-
*/
|
|
1272
|
-
public changeMode<T extends Mode>(
|
|
1273
|
-
mode: T,
|
|
1274
|
-
state: Partial<Omit<State, "mode">> = {},
|
|
1275
|
-
options?: number | { duration?: number, effect?: MovePanoEffect },
|
|
1276
|
-
userAction: boolean = true,
|
|
1277
|
-
force: boolean = false,
|
|
1278
|
-
): Promise<void> {
|
|
1279
|
-
return new Promise((resolve, reject) => {
|
|
1280
|
-
|
|
1281
|
-
if (!this.renderer) {
|
|
1282
|
-
throw new Error("renderer is not initialized.");
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
state = { ...state };
|
|
1286
|
-
|
|
1287
|
-
let duration = 0;
|
|
1288
|
-
if (this.controller) {
|
|
1289
|
-
if (typeof options === 'number') {
|
|
1290
|
-
duration = options;
|
|
1291
|
-
} else {
|
|
1292
|
-
duration = options?.duration ?? this.modeChangeDuration;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
let effect: MovePanoEffect = 'fly';
|
|
1297
|
-
if (this.controller) {
|
|
1298
|
-
if (typeof options === 'object' && options.effect) {
|
|
1299
|
-
effect = options.effect;
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
const nextPano: Pano = typeof state.panoIndex === 'number' ?
|
|
1304
|
-
{
|
|
1305
|
-
workCode: state.workCode ?? this.work?.workCode ?? '',
|
|
1306
|
-
panoIndex: state.panoIndex,
|
|
1307
|
-
} :
|
|
1308
|
-
this.pano;
|
|
1309
|
-
|
|
1310
|
-
if (!Five.Mode.hasOwnProperty(mode)) {
|
|
1311
|
-
const error = new Error(`mode "${mode}" is not existed`);
|
|
1312
|
-
this.throwError(error);
|
|
1313
|
-
reject(error);
|
|
1314
|
-
return;
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
if (
|
|
1318
|
-
mode === Five.Mode.Panorama ||
|
|
1319
|
-
mode === Five.Mode.VRPanorama ||
|
|
1320
|
-
mode === Five.Mode.XRPanorama
|
|
1321
|
-
) {
|
|
1322
|
-
if (!this.works.getObserver(nextPano)) {
|
|
1323
|
-
const error = new Error(`PanoId ${panoStringify(nextPano)} not existed.`);
|
|
1324
|
-
this.throwError(error);
|
|
1325
|
-
reject(error);
|
|
1326
|
-
return;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
if (
|
|
1331
|
-
mode === Five.Mode.Floorplan ||
|
|
1332
|
-
mode === Five.Mode.Topview ||
|
|
1333
|
-
mode === Five.Mode.Mapview ||
|
|
1334
|
-
mode === Five.Mode.Model
|
|
1335
|
-
) {
|
|
1336
|
-
if (this.modelScene.empty) {
|
|
1337
|
-
duration = 0;
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
const prevController = this.controller;
|
|
1342
|
-
const prevMode = this.currentMode;
|
|
1343
|
-
|
|
1344
|
-
const doChangeMode = () => {
|
|
1345
|
-
if (this.controller) {
|
|
1346
|
-
this.controller.stopMomentumMovement();
|
|
1347
|
-
}
|
|
1348
|
-
if (this.controller && force === false && prevMode === mode) {
|
|
1349
|
-
if (
|
|
1350
|
-
mode === Five.Mode.Panorama ||
|
|
1351
|
-
mode === Five.Mode.Model ||
|
|
1352
|
-
mode === Five.Mode.VRPanorama ||
|
|
1353
|
-
mode === Five.Mode.XRPanorama
|
|
1354
|
-
) {
|
|
1355
|
-
if (!panoEqual(this.pano, nextPano) && 'moveToPano' in this.controller && typeof this.controller.moveToPano === 'function') {
|
|
1356
|
-
this.controller.moveToPano(nextPano, { duration, ...state }, userAction);
|
|
1357
|
-
} else {
|
|
1358
|
-
this.controller.updateCamera(state, duration, userAction).catch(noop);
|
|
1359
|
-
}
|
|
1360
|
-
} else {
|
|
1361
|
-
if (!panoEqual(this.pano, nextPano)) {
|
|
1362
|
-
this.pano = nextPano;
|
|
1363
|
-
}
|
|
1364
|
-
this.controller.updateCamera(state, duration, userAction).catch(noop);
|
|
1365
|
-
}
|
|
1366
|
-
} else {
|
|
1367
|
-
const initialState: Partial<State> = {
|
|
1368
|
-
...state,
|
|
1369
|
-
...nextPano,
|
|
1370
|
-
};
|
|
1371
|
-
const params: ControllerInitType<T> = {
|
|
1372
|
-
initial: {
|
|
1373
|
-
state: initialState,
|
|
1374
|
-
currentState: this.getCurrentState(),
|
|
1375
|
-
duration,
|
|
1376
|
-
effect,
|
|
1377
|
-
userAction
|
|
1378
|
-
},
|
|
1379
|
-
...this.commonParams(),
|
|
1380
|
-
...this.controllerInits[mode]
|
|
1381
|
-
};
|
|
1382
|
-
const initAnimationEndState = Controllers[mode].initAnimationEndState(params);
|
|
1383
|
-
|
|
1384
|
-
const modeChangeEvent = createEvent<ModeChangeEvent>('mode.change.request', {
|
|
1385
|
-
prevMode: this.currentMode,
|
|
1386
|
-
mode: mode,
|
|
1387
|
-
state: initAnimationEndState,
|
|
1388
|
-
userAction,
|
|
1389
|
-
});
|
|
1390
|
-
this.emit('mode.change.request', modeChangeEvent);
|
|
1391
|
-
if (!modeChangeEvent.defaultPrevented) {
|
|
1392
|
-
if (prevController) {
|
|
1393
|
-
prevController.destroy();
|
|
1394
|
-
}
|
|
1395
|
-
this.controller = this.applyController(mode, params);
|
|
1396
|
-
const modeChangeEvent = createEvent<ModeChangeEvent>('mode.change', {
|
|
1397
|
-
prevMode: this.currentMode,
|
|
1398
|
-
mode: mode,
|
|
1399
|
-
state: initAnimationEndState,
|
|
1400
|
-
userAction,
|
|
1401
|
-
});
|
|
1402
|
-
this.emit('mode.change', modeChangeEvent);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
resolve();
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
const session = AnimationFrameLoop.shared.getContext();
|
|
1409
|
-
if (session) {
|
|
1410
|
-
if (typeof XRSession !== 'undefined' && session instanceof XRSession) {
|
|
1411
|
-
session.end();
|
|
1412
|
-
}
|
|
1413
|
-
AnimationFrameLoop.shared.setContext(null);
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
if (mode === Five.Mode.VRPanorama) {
|
|
1417
|
-
this.requestFullscreen();
|
|
1418
|
-
requestDeviceOrientationPermission().then(() => doChangeMode()).catch(anyError => {
|
|
1419
|
-
const error = anyError instanceof Error ? anyError : new Error(String(anyError));
|
|
1420
|
-
this.exitFullscreen();
|
|
1421
|
-
this.throwError(error);
|
|
1422
|
-
reject(error);
|
|
1423
|
-
});
|
|
1424
|
-
} else if (mode === Five.Mode.XRPanorama) {
|
|
1425
|
-
requestXRSessionPermission().then((session: any) => {
|
|
1426
|
-
//给button提供一个钩子事件
|
|
1427
|
-
AnimationFrameLoop.shared.setContext(session);
|
|
1428
|
-
force = true;
|
|
1429
|
-
doChangeMode();
|
|
1430
|
-
}).catch(anyError => {
|
|
1431
|
-
const error = anyError instanceof Error ? anyError : new Error(String(anyError));
|
|
1432
|
-
this.throwError(error);
|
|
1433
|
-
reject(error);
|
|
1434
|
-
});
|
|
1435
|
-
} else {
|
|
1436
|
-
doChangeMode();
|
|
1437
|
-
}
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
/**
|
|
1442
|
-
* 获取画面中的像素颜色
|
|
1443
|
-
* @param x - 获取像素区域的起始坐标 x
|
|
1444
|
-
* @param y - 获取像素区域的起始坐标 y
|
|
1445
|
-
* @param width - 获取像素区域的宽度
|
|
1446
|
-
* @param height - 获取像素区域的高度
|
|
1447
|
-
* @param pixelRatio - 获取区域的像素比
|
|
1448
|
-
* @param flipY - 是否Y轴翻转
|
|
1449
|
-
* @param buffer - 存储数组
|
|
1450
|
-
* @returns rgba颜色平铺的 Uint8Array
|
|
1451
|
-
*/
|
|
1452
|
-
public getPixels<T extends Uint8Array | Uint8ClampedArray = Uint8Array>(
|
|
1453
|
-
x: number,
|
|
1454
|
-
y: number,
|
|
1455
|
-
width: number,
|
|
1456
|
-
height: number,
|
|
1457
|
-
pixelRatio?: number,
|
|
1458
|
-
flipY?: boolean,
|
|
1459
|
-
buffer?: T
|
|
1460
|
-
): T
|
|
1461
|
-
/**
|
|
1462
|
-
* 获取画面中的像素颜色
|
|
1463
|
-
* @param options - 参数
|
|
1464
|
-
* @returns
|
|
1465
|
-
*/
|
|
1466
|
-
public getPixels<T extends Uint8Array | Uint8ClampedArray = Uint8Array>(
|
|
1467
|
-
options: {
|
|
1468
|
-
/** 获取像素区域的起始坐标 x */
|
|
1469
|
-
x: number,
|
|
1470
|
-
/** 获取像素区域的起始坐标 y */
|
|
1471
|
-
y: number,
|
|
1472
|
-
/** 获取像素区域的宽度 */
|
|
1473
|
-
width: number,
|
|
1474
|
-
/** 获取像素区域的高度 */
|
|
1475
|
-
height: number,
|
|
1476
|
-
/** 获取区域的像素比 */
|
|
1477
|
-
pixelRatio?: number,
|
|
1478
|
-
/* 是否展示 helper */
|
|
1479
|
-
helperVisible?: boolean,
|
|
1480
|
-
/* 是否忽略全景图 */
|
|
1481
|
-
skipPanorama?: boolean,
|
|
1482
|
-
/** 是否Y轴翻转 */
|
|
1483
|
-
flipY?: boolean,
|
|
1484
|
-
/** 存储数组 */
|
|
1485
|
-
buffer?: T
|
|
1486
|
-
}
|
|
1487
|
-
): T
|
|
1488
|
-
public getPixels<T extends Uint8Array | Uint8ClampedArray = Uint8Array>(
|
|
1489
|
-
xOrOptions: any,
|
|
1490
|
-
_y?: number, _width?: number, _height?: number, _pixelRatio?: number, _flipY?: boolean, _buffer?: T
|
|
1491
|
-
): T {
|
|
1492
|
-
|
|
1493
|
-
if (!this.renderer) {
|
|
1494
|
-
throw new Error("renderer is not initialized.");
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
const currentTime = now();
|
|
1498
|
-
const prevPixelRatio = this.renderer.getPixelRatio();
|
|
1499
|
-
const prevRenderTarget = this.renderer.getRenderTarget();
|
|
1500
|
-
const renderSize = this.getSize(new THREE.Vector2());
|
|
1501
|
-
|
|
1502
|
-
// 数据兼容
|
|
1503
|
-
let x: number = 0;
|
|
1504
|
-
let y: number = 0;
|
|
1505
|
-
let width: number = 1;
|
|
1506
|
-
let height: number = 1;
|
|
1507
|
-
let pixelRatio: number | undefined;
|
|
1508
|
-
let flipY: boolean | undefined;
|
|
1509
|
-
let helperVisible: boolean | undefined;
|
|
1510
|
-
let skipPanorama: boolean | undefined;
|
|
1511
|
-
let buffer: T | undefined;
|
|
1512
|
-
|
|
1513
|
-
if (typeof xOrOptions === 'number') {
|
|
1514
|
-
x = xOrOptions;
|
|
1515
|
-
if (typeof _y === 'number') {
|
|
1516
|
-
y = _y;
|
|
1517
|
-
}
|
|
1518
|
-
if (typeof _width === 'number') {
|
|
1519
|
-
width = _width;
|
|
1520
|
-
}
|
|
1521
|
-
if (typeof _height === 'number') {
|
|
1522
|
-
height = _height;
|
|
1523
|
-
}
|
|
1524
|
-
pixelRatio = _pixelRatio;
|
|
1525
|
-
flipY = _flipY;
|
|
1526
|
-
buffer = _buffer;
|
|
1527
|
-
} else {
|
|
1528
|
-
x = xOrOptions.x;
|
|
1529
|
-
y = xOrOptions.y;
|
|
1530
|
-
width = xOrOptions.width;
|
|
1531
|
-
height = xOrOptions.height;
|
|
1532
|
-
pixelRatio = xOrOptions.pixelRatio;
|
|
1533
|
-
flipY = xOrOptions.flipY;
|
|
1534
|
-
helperVisible = xOrOptions.helperVisible;
|
|
1535
|
-
skipPanorama = xOrOptions.skipPanorama;
|
|
1536
|
-
buffer = xOrOptions.buffer;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
// 将所有数据作为整数,减少错误
|
|
1540
|
-
x = Math.floor(x);
|
|
1541
|
-
y = Math.floor(y);
|
|
1542
|
-
width = Math.floor(width);
|
|
1543
|
-
height = Math.floor(height);
|
|
1544
|
-
pixelRatio = Math.floor(pixelRatio ?? prevPixelRatio);
|
|
1545
|
-
flipY = flipY ?? false;
|
|
1546
|
-
|
|
1547
|
-
const prevHelperVisible = this.helperVisible;
|
|
1548
|
-
const prevModelAlpha = this.modelScene.parameter.modelAlpha;
|
|
1549
|
-
this.helperVisible = helperVisible ?? this.helperVisible;
|
|
1550
|
-
|
|
1551
|
-
if (
|
|
1552
|
-
skipPanorama &&
|
|
1553
|
-
(
|
|
1554
|
-
this.controller instanceof Controllers['Panorama'] ||
|
|
1555
|
-
this.controller instanceof Controllers['VRPanorama'] ||
|
|
1556
|
-
this.controller instanceof Controllers['XRPanorama']
|
|
1557
|
-
)
|
|
1558
|
-
) {
|
|
1559
|
-
if (skipPanorama === true) {
|
|
1560
|
-
this.modelScene.parameter.set('modelAlpha', 1);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
this.modelScene.update(this.renderer, this.camera);
|
|
1564
|
-
|
|
1565
|
-
// update camera / renderer
|
|
1566
|
-
const renderTarget = this.getPixelsRenderTarget;
|
|
1567
|
-
renderTarget.setSize(width * pixelRatio, height * pixelRatio);
|
|
1568
|
-
this.renderer.setRenderTarget(renderTarget);
|
|
1569
|
-
this.camera.pixelRatio = pixelRatio;
|
|
1570
|
-
this.camera.resolution.set(width, height);
|
|
1571
|
-
this.camera.setViewOffset(renderSize.width, renderSize.height, x, renderSize.height - y - height, width, height);
|
|
1572
|
-
// 这里必须重置 aspect 不然和 threejs 内部的 setViewOffset 冲突。
|
|
1573
|
-
this.camera.aspect = renderSize.width / renderSize.height;
|
|
1574
|
-
this.camera.updateTime(currentTime);
|
|
1575
|
-
this.scene.update(this.renderer, this.camera);
|
|
1576
|
-
|
|
1577
|
-
const prevAutoClear = this.renderer.autoClear;
|
|
1578
|
-
const prevAutoClearColor = this.renderer.autoClearColor;
|
|
1579
|
-
const prevAutoClearDepth = this.renderer.autoClearDepth;
|
|
1580
|
-
const prevAutoClearStencil = this.renderer.autoClearStencil;
|
|
1581
|
-
const prevClearColor = scratchClearColor.copy(this.renderer.getClearColor());
|
|
1582
|
-
const prevClearAlpha = this.renderer.getClearAlpha();
|
|
1583
|
-
const prevScissorTest = this.renderer.getScissorTest();
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
this.renderer.autoClear = true;
|
|
1587
|
-
this.renderer.autoClearColor = true;
|
|
1588
|
-
this.renderer.autoClearDepth = true;
|
|
1589
|
-
this.renderer.autoClearStencil = true;
|
|
1590
|
-
this.renderer.setScissorTest(false);
|
|
1591
|
-
|
|
1592
|
-
const background = this.scene.background;
|
|
1593
|
-
this.scene.background = this.camera.isOrthographicCamera ? null : background;
|
|
1594
|
-
|
|
1595
|
-
this.renderer.render(this.scene, this.camera);
|
|
1596
|
-
|
|
1597
|
-
this.scene.background = background;
|
|
1598
|
-
|
|
1599
|
-
this.renderer.autoClear = prevAutoClear;
|
|
1600
|
-
this.renderer.autoClearColor = prevAutoClearColor;
|
|
1601
|
-
this.renderer.autoClearDepth = prevAutoClearDepth;
|
|
1602
|
-
this.renderer.autoClearStencil = prevAutoClearStencil;
|
|
1603
|
-
this.renderer.setClearColor(prevClearColor, prevClearAlpha);
|
|
1604
|
-
this.renderer.setScissorTest(prevScissorTest);
|
|
1605
|
-
|
|
1606
|
-
this.helperVisible = prevHelperVisible;
|
|
1607
|
-
if (prevModelAlpha === undefined) {
|
|
1608
|
-
this.modelScene.parameter.reset('modelAlpha');
|
|
1609
|
-
} else {
|
|
1610
|
-
this.modelScene.parameter.set('modelAlpha', prevModelAlpha);
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
// reset camera and renderer
|
|
1614
|
-
this.renderer.setRenderTarget(prevRenderTarget);
|
|
1615
|
-
this.camera.clearViewOffset();
|
|
1616
|
-
this.camera.pixelRatio = prevPixelRatio;
|
|
1617
|
-
this.camera.resolution.copy(renderSize);
|
|
1618
|
-
this.camera.aspect = this.camera.resolution.width / this.camera.resolution.height;
|
|
1619
|
-
this.camera.updateTime(currentTime);
|
|
1620
|
-
|
|
1621
|
-
this.modelScene.update(this.renderer, this.camera);
|
|
1622
|
-
this.scene.update(this.renderer, this.camera);
|
|
1623
|
-
|
|
1624
|
-
// output color
|
|
1625
|
-
const pixelWidth = width * pixelRatio;
|
|
1626
|
-
const pixelHeight = height * pixelRatio;
|
|
1627
|
-
const pixelLength = pixelWidth * pixelHeight;
|
|
1628
|
-
const byteLength = pixelLength * (4/* rgba */);
|
|
1629
|
-
|
|
1630
|
-
if (buffer) {
|
|
1631
|
-
if (buffer.length !== byteLength) {
|
|
1632
|
-
throw new Error(`buffer length is not equals pixels ${byteLength}`);
|
|
1633
|
-
}
|
|
1634
|
-
} else {
|
|
1635
|
-
buffer = new Uint8Array(byteLength) as T;
|
|
1636
|
-
}
|
|
1637
|
-
this.renderer.readRenderTargetPixels(renderTarget, 0, 0, width * pixelRatio, height * pixelRatio, buffer);
|
|
1638
|
-
if (flipY) {
|
|
1639
|
-
const halfPixelLength = pixelLength / 2;
|
|
1640
|
-
for (let temp: number = 0, index = 0, rgbaIndex = 0, targetIndex = 0; index < halfPixelLength; index++) {
|
|
1641
|
-
targetIndex = (pixelHeight - Math.floor(index / pixelWidth) - 1) * pixelWidth + (index % pixelWidth);
|
|
1642
|
-
for (rgbaIndex = 0; rgbaIndex < 4; rgbaIndex++) {
|
|
1643
|
-
temp = buffer[index * 4 + rgbaIndex];
|
|
1644
|
-
buffer[index * 4 + rgbaIndex] = buffer[targetIndex * 4 + rgbaIndex];
|
|
1645
|
-
buffer[targetIndex * 4 + rgbaIndex] = temp;
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
return buffer;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
/**
|
|
1654
|
-
* 获取显示用的画布(Canvas DOM节点)
|
|
1655
|
-
*/
|
|
1656
|
-
public getElement(): HTMLCanvasElement | undefined {
|
|
1657
|
-
return this.renderer?.domElement;
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
/**
|
|
1661
|
-
* 强制渲染
|
|
1662
|
-
* @description
|
|
1663
|
-
* 调用 `five.render()` 和设置 `five.needsRender = true` 均可在按需渲染时,使得画面渲染一次
|
|
1664
|
-
* 区别在于:
|
|
1665
|
-
* - `five.needsRender = true` 为在下帧渲染画面
|
|
1666
|
-
* - `five.render()` 在当前帧渲染画面
|
|
1667
|
-
* 推荐使用 `five.needsRender = true`, 可以更加流畅。但是如果需要截图等同步操作,可以使用 `five.render()`
|
|
1668
|
-
*
|
|
1669
|
-
* @param callback - 渲染完成回调
|
|
1670
|
-
*/
|
|
1671
|
-
public render(callback?: () => void) {
|
|
1672
|
-
|
|
1673
|
-
const renderer = this.renderer;
|
|
1674
|
-
if (!renderer) return;
|
|
1675
|
-
|
|
1676
|
-
const prevRenderTarget = renderer.getRenderTarget();
|
|
1677
|
-
|
|
1678
|
-
renderer.setRenderTarget(null); // 默认一定渲染到屏幕
|
|
1679
|
-
|
|
1680
|
-
const prevAutoClear = renderer.autoClear;
|
|
1681
|
-
const prevAutoClearColor = renderer.autoClearColor;
|
|
1682
|
-
const prevAutoClearDepth = renderer.autoClearDepth;
|
|
1683
|
-
const prevAutoClearStencil = renderer.autoClearStencil;
|
|
1684
|
-
const prevClearColor = scratchClearColor.copy(renderer.getClearColor());
|
|
1685
|
-
const prevClearAlpha = renderer.getClearAlpha();
|
|
1686
|
-
const prevViewport = renderer.getViewport(scratchViewport);
|
|
1687
|
-
const prevScissor = renderer.getScissor(scratchScissor);
|
|
1688
|
-
const prevScissorTest = renderer.getScissorTest();
|
|
1689
|
-
|
|
1690
|
-
renderer.autoClear = true;
|
|
1691
|
-
renderer.autoClearColor = true;
|
|
1692
|
-
renderer.autoClearDepth = true;
|
|
1693
|
-
renderer.autoClearStencil = true;
|
|
1694
|
-
const renderSize = renderer.getSize(scratchRenderSize);
|
|
1695
|
-
const left = Math.floor(renderSize.x * this.viewport.left);
|
|
1696
|
-
const bottom = Math.floor(renderSize.y * this.viewport.bottom);
|
|
1697
|
-
const width = Math.floor(renderSize.x * this.viewport.width);
|
|
1698
|
-
const height = Math.floor(renderSize.y * this.viewport.height);
|
|
1699
|
-
renderer.setClearColor(this.backgroundColor, this.backgroundAlpha);
|
|
1700
|
-
renderer.setViewport(left, bottom, width, height);
|
|
1701
|
-
renderer.setScissor(left, bottom, width, height);
|
|
1702
|
-
|
|
1703
|
-
const needsScissor = this.viewport.bottom !== 0 || this.viewport.left !== 0 || this.viewport.width !== 1 || this.viewport.height !== 1;
|
|
1704
|
-
// setScissorTest after setRenderTarget(null)
|
|
1705
|
-
renderer.setScissorTest(needsScissor);
|
|
1706
|
-
|
|
1707
|
-
const background = this.scene.background;
|
|
1708
|
-
this.scene.background = this.camera.isOrthographicCamera ? null : background;
|
|
1709
|
-
|
|
1710
|
-
let needFiveRender = true;
|
|
1711
|
-
if (this.controller) {
|
|
1712
|
-
const renderByController = this.controller.render();
|
|
1713
|
-
if (renderByController) {
|
|
1714
|
-
needFiveRender = false;
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
if (needFiveRender) {
|
|
1718
|
-
const rendered = this.fiveRenderer.render(renderer, this.scene, this.modelScene, this.camera, this.needsRender);
|
|
1719
|
-
if (this.poweredByRealsee && rendered) {
|
|
1720
|
-
renderPoweredByRealsee(renderer);
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
this.scene.background = background;
|
|
1725
|
-
renderer.autoClear = prevAutoClear;
|
|
1726
|
-
renderer.autoClearColor = prevAutoClearColor;
|
|
1727
|
-
renderer.autoClearDepth = prevAutoClearDepth;
|
|
1728
|
-
renderer.autoClearStencil = prevAutoClearStencil;
|
|
1729
|
-
renderer.setClearColor(prevClearColor, prevClearAlpha);
|
|
1730
|
-
renderer.setViewport(prevViewport);
|
|
1731
|
-
renderer.setScissor(prevScissor);
|
|
1732
|
-
renderer.setScissorTest(prevScissorTest);
|
|
1733
|
-
renderer.setRenderTarget(prevRenderTarget);
|
|
1734
|
-
|
|
1735
|
-
if (callback) AnimationFrameLoop.shared.add(callback, true);
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
public updateTime(time: number, deltaTime: number, ...args: any[]) {
|
|
1739
|
-
|
|
1740
|
-
this.currentUpdateArgs = { time, args };
|
|
1741
|
-
|
|
1742
|
-
// 如果被销毁了,那就不工作了
|
|
1743
|
-
if (this.destroyed) return;
|
|
1744
|
-
|
|
1745
|
-
if (this.renderer) {
|
|
1746
|
-
ktx2.detectSupport(this.renderer);
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
// ======= 同步状态 =======
|
|
1750
|
-
// 同步状态 必须和 controller update 时计算 syncingState
|
|
1751
|
-
this.syncingState = this.syncState(time, deltaTime);
|
|
1752
|
-
|
|
1753
|
-
// ======= 调用 controller 的 updateTime =====
|
|
1754
|
-
if (this.controller) {
|
|
1755
|
-
this.controller.updateTime(time, deltaTime, ...args);
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
// ======= 更新相机 ========
|
|
1759
|
-
if (this.renderer) {
|
|
1760
|
-
this.camera.pixelRatio = this.renderer.getPixelRatio();
|
|
1761
|
-
this.getSize(this.camera.resolution);
|
|
1762
|
-
this.camera.aspect = this.camera.resolution.width / this.camera.resolution.height;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
this.camera.controllerMode = this.currentMode;
|
|
1766
|
-
this.camera.updateTime(time);
|
|
1767
|
-
|
|
1768
|
-
// ======= 更新模型 =============
|
|
1769
|
-
if (this.renderer) {
|
|
1770
|
-
|
|
1771
|
-
const lastLoaded = this.modelScene.loaded;
|
|
1772
|
-
const lastRefined = this.modelScene.refined;
|
|
1773
|
-
|
|
1774
|
-
this.modelScene.update(this.renderer, this.camera);
|
|
1775
|
-
|
|
1776
|
-
if (lastLoaded === false && this.modelScene.loaded === true) {
|
|
1777
|
-
if (this.controller) {
|
|
1778
|
-
this.controller.updateModel(this.modelScene);
|
|
1779
|
-
}
|
|
1780
|
-
// 延迟,保证模型状态
|
|
1781
|
-
AnimationFrameLoop.shared.add(() => {
|
|
1782
|
-
this.emit('models.load', createEvent<ModelSceneEvent>('models.load', {
|
|
1783
|
-
modelScene: this.modelScene,
|
|
1784
|
-
}));
|
|
1785
|
-
}, true, 0, 10);
|
|
1786
|
-
}
|
|
1787
|
-
if (lastRefined === false && this.modelScene.refined === true) {
|
|
1788
|
-
// 延迟,保证模型状态
|
|
1789
|
-
AnimationFrameLoop.shared.add(() => {
|
|
1790
|
-
this.emit('models.refined', createEvent<ModelSceneEvent>('models.refined', {
|
|
1791
|
-
modelScene: this.modelScene,
|
|
1792
|
-
}));
|
|
1793
|
-
}, true, 0, 10);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
if (this.camera.autoNearFar) {
|
|
1798
|
-
scratchBox3.makeEmpty();
|
|
1799
|
-
scratchBox3.expandByObject(this.modelScene.boundingMesh);
|
|
1800
|
-
const shpere = scratchBox3.getBoundingSphere(scratchSphere);
|
|
1801
|
-
let far = shpere.radius * 2;
|
|
1802
|
-
if (!shpere.containsPoint(this.camera.position)) {
|
|
1803
|
-
far = this.camera.position.distanceTo(shpere.center) + shpere.radius;
|
|
1804
|
-
}
|
|
1805
|
-
far = clamp(far, 800);
|
|
1806
|
-
|
|
1807
|
-
let near = far / 10000;
|
|
1808
|
-
near = clamp(near, 0.03, 0.1);
|
|
1809
|
-
|
|
1810
|
-
let needsUpdate = false;
|
|
1811
|
-
if (this.camera.near !== near) {
|
|
1812
|
-
this.camera.near = near;
|
|
1813
|
-
needsUpdate = true;
|
|
1814
|
-
}
|
|
1815
|
-
if (this.camera.far !== far) {
|
|
1816
|
-
this.camera.far = far;
|
|
1817
|
-
needsUpdate = true;
|
|
1818
|
-
}
|
|
1819
|
-
this.camera.updateTime(time);
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
// ====== 处理三维场景中的东西 =============
|
|
1823
|
-
// 包括:收集视锥可见的模型,处理模型动画
|
|
1824
|
-
if (this.renderer) {
|
|
1825
|
-
const modelSceneVisible = this.modelScene.visible;
|
|
1826
|
-
this.modelScene.visible = false;
|
|
1827
|
-
this.scene.update(this.renderer, this.camera);
|
|
1828
|
-
this.modelScene.visible = modelSceneVisible;
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
this.syncingState = false;
|
|
1832
|
-
// ========== 同步状态 =======
|
|
1833
|
-
|
|
1834
|
-
if (this.controller) {
|
|
1835
|
-
if (this.controller.needsRender === true) {
|
|
1836
|
-
this.controller.needsRender = false;
|
|
1837
|
-
this.needsRender = true;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
if (this.camera.needsRender === true) {
|
|
1841
|
-
this.camera.needsRender = false;
|
|
1842
|
-
this.needsRender = true;
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
if (this.modelScene.needsRender === true) {
|
|
1846
|
-
this.modelScene.needsRender = false;
|
|
1847
|
-
this.needsRender = true;
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
if (this.scene.needsRender === true) {
|
|
1851
|
-
this.scene.needsRender = false;
|
|
1852
|
-
this.needsRender = true;
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
if (this.pbmGSRenderMesh) {
|
|
1856
|
-
if (this.pbmGSRenderMesh.needsRender === true) {
|
|
1857
|
-
this.pbmGSRenderMesh.needsRender = false;
|
|
1858
|
-
this.needsRender = true;
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
if (this.onlyRenderIfNeeds !== true) {
|
|
1863
|
-
this.needsRender = true;
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
// ====== 暂停 ========
|
|
1867
|
-
if (this.paused === true) {
|
|
1868
|
-
return
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
// ====== 开始渲染 =========
|
|
1872
|
-
|
|
1873
|
-
const renderEvent = createEvent<RenderEvent>('render.prepare', {
|
|
1874
|
-
needsRender: this.needsRender,
|
|
1875
|
-
});
|
|
1876
|
-
this.emit("render.prepare", renderEvent);
|
|
1877
|
-
if (renderEvent.defaultPrevented) {
|
|
1878
|
-
this.needsRender = false;
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
const currentNeedsRender = this.needsRender;
|
|
1882
|
-
|
|
1883
|
-
this.render();
|
|
1884
|
-
|
|
1885
|
-
this.needsRender = false;
|
|
1886
|
-
|
|
1887
|
-
this.emit("render", createEvent<RenderEvent>('render', {
|
|
1888
|
-
needsRender: currentNeedsRender,
|
|
1889
|
-
}));
|
|
1890
|
-
|
|
1891
|
-
// 测试帧效率
|
|
1892
|
-
if (this.hasListener('fps')) {
|
|
1893
|
-
if (this.fps.testTime && time - this.fps.testTime < 1000) {
|
|
1894
|
-
this.fps.testCount++;
|
|
1895
|
-
} else {
|
|
1896
|
-
this.emit("fps", this.fps.testCount);
|
|
1897
|
-
this.fps.testTime = time;
|
|
1898
|
-
this.fps.testCount = 0;
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
/**
|
|
1905
|
-
* 暂停自动播放
|
|
1906
|
-
*/
|
|
1907
|
-
public pause() {
|
|
1908
|
-
this.paused = true;
|
|
1909
|
-
if (this.renderer && this.renderer instanceof InternalWebGLRenderer) {
|
|
1910
|
-
this.renderer.clear(true, true, true);
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
public play() {
|
|
1915
|
-
this.needsRender = true;
|
|
1916
|
-
this.paused = false;
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
/**
|
|
1920
|
-
* 转化到 Panorama 模态,并移动到对应序号的观察点。
|
|
1921
|
-
* @param pano - 观察点序号
|
|
1922
|
-
* @param options - 移动点位参数
|
|
1923
|
-
* @param userAction - 是否用户触犯
|
|
1924
|
-
*/
|
|
1925
|
-
public moveToPano(pano: Pano | PanoId | number, options: MovePanoOptions = {}, userAction: boolean = true): Promise<void> {
|
|
1926
|
-
const { controller, renderer } = this;
|
|
1927
|
-
if (!controller) {
|
|
1928
|
-
this.throwError(new Error("controller is not initialized."));
|
|
1929
|
-
return Promise.resolve();
|
|
1930
|
-
}
|
|
1931
|
-
if (!renderer) {
|
|
1932
|
-
this.throwError(new Error("renderer is not initialized."));
|
|
1933
|
-
return Promise.resolve();
|
|
1934
|
-
}
|
|
1935
|
-
// 如果没有 workCode 用当前点位的 workCode
|
|
1936
|
-
if (typeof pano === 'number' && this.pano.workCode) {
|
|
1937
|
-
pano = {
|
|
1938
|
-
workCode: this.pano.workCode,
|
|
1939
|
-
panoIndex: pano,
|
|
1940
|
-
};
|
|
1941
|
-
}
|
|
1942
|
-
const observer = this.works.getObserver(pano);
|
|
1943
|
-
if (!observer) {
|
|
1944
|
-
this.throwError(new Error(`pano ${JSON.stringify(pano)} not existed.`));
|
|
1945
|
-
return Promise.resolve();
|
|
1946
|
-
}
|
|
1947
|
-
const nextPano: Pano = {
|
|
1948
|
-
workCode: observer.work.workCode,
|
|
1949
|
-
panoIndex: observer.panoIndex
|
|
1950
|
-
};
|
|
1951
|
-
if ('moveToPano' in controller && typeof controller.moveToPano === 'function') {
|
|
1952
|
-
controller.moveToPano(nextPano, options, userAction);
|
|
1953
|
-
} else {
|
|
1954
|
-
if (observer) {
|
|
1955
|
-
this.pano = nextPano;
|
|
1956
|
-
this.once('initAnimation.start', event => {
|
|
1957
|
-
if (options.moveStartCallback) {
|
|
1958
|
-
options.moveStartCallback(event.state);
|
|
1959
|
-
}
|
|
1960
|
-
});
|
|
1961
|
-
this.once('initAnimation.end', event => {
|
|
1962
|
-
if (options.moveEndCallback) {
|
|
1963
|
-
options.moveEndCallback(event.state);
|
|
1964
|
-
}
|
|
1965
|
-
});
|
|
1966
|
-
this.changeMode(Five.Mode.Panorama, options, { effect: options.effect }, userAction);
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
return this.ready();
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
/**
|
|
1973
|
-
* 预加载点位图片资源
|
|
1974
|
-
* @param pano - 观察点序号
|
|
1975
|
-
* @param callback - 加载完成回调, 并传递加载用时。
|
|
1976
|
-
* @returns 加载完成的 Promise 参数同 callback
|
|
1977
|
-
*/
|
|
1978
|
-
public preloadPano(pano: Pano | PanoId | number, callback: (costs: number) => void = noop): Promise<number> {
|
|
1979
|
-
|
|
1980
|
-
const observer = this.works.getObserver(pano);
|
|
1981
|
-
if (!observer) {
|
|
1982
|
-
return Promise.reject(new Error(`Pano ${JSON.stringify(pano)} never found`));
|
|
1983
|
-
}
|
|
1984
|
-
const types = ["right", "left", "up", "down", "front", "back"] as const;
|
|
1985
|
-
const startTime = now();
|
|
1986
|
-
return Promise.all(types.map(type => {
|
|
1987
|
-
const panoId = panoStringify({
|
|
1988
|
-
panoIndex: observer.panoIndex,
|
|
1989
|
-
workCode: observer.work.workCode,
|
|
1990
|
-
})
|
|
1991
|
-
const options: ImageURLOptions = {
|
|
1992
|
-
key: `pano.${panoId}.${type}`,
|
|
1993
|
-
...pick(this.imageOptions, ["size", "format", "quality", 'forceUseExifOrientation', "mappings"]),
|
|
1994
|
-
};
|
|
1995
|
-
const origin = observer.work.getURL(observer.images[type]);
|
|
1996
|
-
const target = this.imageOptions.transform ? this.imageOptions.transform(origin, options) : imageURL(origin, options);
|
|
1997
|
-
return getFetcher(this.fiveId, observer.work).preload(target);
|
|
1998
|
-
})).then(() => {
|
|
1999
|
-
const costs = now() - startTime;
|
|
2000
|
-
callback(costs);
|
|
2001
|
-
return costs;
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
/**
|
|
2006
|
-
* 计算三维坐标对应到屏幕的二维坐标
|
|
2007
|
-
* @description
|
|
2008
|
-
* 如果三维坐标不在屏幕中,则返回 null
|
|
2009
|
-
* @param vector - 三维坐标
|
|
2010
|
-
* @param testModel - 是否计算模型遮挡
|
|
2011
|
-
* @returns 二维坐标 或者 null
|
|
2012
|
-
*/
|
|
2013
|
-
public project2d(vector: THREE.Vector3, testModel: boolean = false): THREE.Vector2 | null {
|
|
2014
|
-
if (!this.renderer) return null;
|
|
2015
|
-
if (testModel) {
|
|
2016
|
-
const origin = this.camera.position;
|
|
2017
|
-
const subVector = vector.clone().sub(origin);
|
|
2018
|
-
const raycaster = new THREE.Raycaster(origin, subVector.clone().normalize());
|
|
2019
|
-
raycaster.params.Points = { threshold: 0.1 };
|
|
2020
|
-
const [intersect] = this.modelScene.intersectRaycaster(raycaster);
|
|
2021
|
-
// 0.01 是因为模型碰撞的误差的 z fighting 的情况
|
|
2022
|
-
if (intersect && intersect.distance + 0.01 < subVector.length()) return null;
|
|
2023
|
-
}
|
|
2024
|
-
const screen = vector.clone().project(this.camera);
|
|
2025
|
-
if (Math.abs(screen.z) > 1) return null;
|
|
2026
|
-
const size = this.renderer.getSize(new THREE.Vector2());
|
|
2027
|
-
const width = size.x * this.viewport.width;
|
|
2028
|
-
const height = size.y * this.viewport.height;
|
|
2029
|
-
const left = size.x * this.viewport.left + (screen.x + 1) / 2 * width;
|
|
2030
|
-
const top = (size.y * (1 - this.viewport.bottom - this.viewport.height)) + (- screen.y + 1) / 2 * height;
|
|
2031
|
-
return new THREE.Vector2(left, top);
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
public getCurrentState(): State {
|
|
2035
|
-
return {
|
|
2036
|
-
...this.camera.copyPose(),
|
|
2037
|
-
mode: this.currentMode,
|
|
2038
|
-
workCode: this.pano.workCode,
|
|
2039
|
-
panoIndex: this.pano.panoIndex,
|
|
2040
|
-
};
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
/**
|
|
2044
|
-
* 设置 State
|
|
2045
|
-
* @description
|
|
2046
|
-
* ```text
|
|
2047
|
-
* five 设置了以下状态
|
|
2048
|
-
*
|
|
2049
|
-
* - mode: Mode
|
|
2050
|
-
* - panoIndex: number
|
|
2051
|
-
* - longitude: number
|
|
2052
|
-
* - latitude: number
|
|
2053
|
-
* - distance: number
|
|
2054
|
-
* - fov: number
|
|
2055
|
-
* - offset: THREE.Vector3
|
|
2056
|
-
*
|
|
2057
|
-
* 可以通过 five.state 和 five.setState 来获取和设置。
|
|
2058
|
-
* 通过 state 设置后,five 会通过合适的动画运动来达到设置的位置。
|
|
2059
|
-
* 来迎合一些通过数据驱动的场景。
|
|
2060
|
-
* ```
|
|
2061
|
-
* @param state - 目标状态
|
|
2062
|
-
* @param immediately - 是否马上转换,马上转换会尽快达到目标状态,尽量减少中间状态,更少动画。
|
|
2063
|
-
* @param userAction - 是否是用户触发的动作
|
|
2064
|
-
*/
|
|
2065
|
-
public setState(state: Partial<State>, immediately: boolean = false, userAction: boolean = true) {
|
|
2066
|
-
// 兼容 state.offset 被转成了 object 的情况
|
|
2067
|
-
state = pick( state, [
|
|
2068
|
-
'mode',
|
|
2069
|
-
'workCode',
|
|
2070
|
-
'panoIndex',
|
|
2071
|
-
'longitude',
|
|
2072
|
-
'latitude',
|
|
2073
|
-
'fov',
|
|
2074
|
-
'offset',
|
|
2075
|
-
'distance',
|
|
2076
|
-
]);
|
|
2077
|
-
if (state.offset && !(state instanceof THREE.Vector3)) {
|
|
2078
|
-
state.offset = new THREE.Vector3(state.offset.x, state.offset.y, state.offset.z);
|
|
2079
|
-
}
|
|
2080
|
-
|
|
2081
|
-
let pano: Pano | undefined;
|
|
2082
|
-
|
|
2083
|
-
if (typeof state.panoIndex === 'number') {
|
|
2084
|
-
if (state.workCode) {
|
|
2085
|
-
pano = {
|
|
2086
|
-
workCode: state.workCode,
|
|
2087
|
-
panoIndex: state.panoIndex,
|
|
2088
|
-
};
|
|
2089
|
-
} else {
|
|
2090
|
-
let workCode = this.work?.workCode ?? '';
|
|
2091
|
-
const prevWorkCode = this.state.workCode;
|
|
2092
|
-
if (this.works.filter(work => work.workCode === prevWorkCode).length > 0) {
|
|
2093
|
-
workCode = prevWorkCode;
|
|
2094
|
-
}
|
|
2095
|
-
pano = {
|
|
2096
|
-
workCode: workCode,
|
|
2097
|
-
panoIndex: state.panoIndex,
|
|
2098
|
-
};
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
const mode = state.mode ?? this.state.mode;
|
|
2102
|
-
|
|
2103
|
-
let longitude: number;
|
|
2104
|
-
let latitude: number;
|
|
2105
|
-
let fov: number;
|
|
2106
|
-
let offset: THREE.Vector3;
|
|
2107
|
-
let distance: number;
|
|
2108
|
-
|
|
2109
|
-
if (this.controller) {
|
|
2110
|
-
this.controller.stopMomentumMovement();
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
// === 开始 ===
|
|
2114
|
-
// 在切换模态时,这里的设计比较难受
|
|
2115
|
-
// setState 必须在 controller 初始化(或者切换controller)之前就拿到新 controller 动画结束的 state,不然切换就不是想要的样子
|
|
2116
|
-
// 这就比较难受了, 目前的想法时 Controller 类方法上 添加 initAnimationEndPose 来处理
|
|
2117
|
-
if (this.state.mode !== mode) {
|
|
2118
|
-
|
|
2119
|
-
// 如果是VR眼镜模式。需要特殊处理
|
|
2120
|
-
if (mode === "VRPanorama") {
|
|
2121
|
-
this.changeMode("VRPanorama", undefined, undefined, true);
|
|
2122
|
-
return;
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
// 这边 pose 的处理也是一样
|
|
2126
|
-
// 因为 切换controller 并没有实际完成,saveControllerPose 是不会执行到的
|
|
2127
|
-
// 所以也需要奇怪的判断
|
|
2128
|
-
let initialState: Partial<State> = {
|
|
2129
|
-
workCode: pano?.workCode,
|
|
2130
|
-
panoIndex: pano?.panoIndex,
|
|
2131
|
-
};
|
|
2132
|
-
if (typeof state.longitude === "number") {
|
|
2133
|
-
initialState.longitude = state.longitude;
|
|
2134
|
-
}
|
|
2135
|
-
if (typeof state.latitude === "number") {
|
|
2136
|
-
initialState.latitude = state.latitude;
|
|
2137
|
-
}
|
|
2138
|
-
if (typeof state.fov === "number") {
|
|
2139
|
-
initialState.fov = state.fov;
|
|
2140
|
-
}
|
|
2141
|
-
if (typeof state.distance === 'number') {
|
|
2142
|
-
initialState.distance = state.distance;
|
|
2143
|
-
}
|
|
2144
|
-
if (state.offset instanceof THREE.Vector3) {
|
|
2145
|
-
initialState.offset = state.offset;
|
|
2146
|
-
}
|
|
2147
|
-
const params: ControllerInitType = {
|
|
2148
|
-
initial: {
|
|
2149
|
-
state: initialState,
|
|
2150
|
-
currentState: this.getCurrentState(),
|
|
2151
|
-
duration: this.modeChangeDuration,
|
|
2152
|
-
effect: 'fly',
|
|
2153
|
-
userAction: false
|
|
2154
|
-
},
|
|
2155
|
-
...this.commonParams(),
|
|
2156
|
-
...this.controllerInits[mode],
|
|
2157
|
-
};
|
|
2158
|
-
const initAnimationEndState = Controllers[mode].initAnimationEndState(params);
|
|
2159
|
-
longitude = initAnimationEndState.longitude;
|
|
2160
|
-
latitude = initAnimationEndState.latitude;
|
|
2161
|
-
fov = initAnimationEndState.fov;
|
|
2162
|
-
offset = initAnimationEndState.offset;
|
|
2163
|
-
distance = initAnimationEndState.distance;
|
|
2164
|
-
} else {
|
|
2165
|
-
longitude = state.longitude ?? this.state.longitude;
|
|
2166
|
-
latitude = state.latitude ?? this.state.latitude;
|
|
2167
|
-
fov = state.fov ?? this.state.fov;
|
|
2168
|
-
offset = state.offset ?? this.state.offset;
|
|
2169
|
-
distance = state.distance ?? this.state.distance;
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
|
-
// === 结束 ===
|
|
2173
|
-
|
|
2174
|
-
const nextState: State = {
|
|
2175
|
-
workCode: (pano ?? this.pano).workCode,
|
|
2176
|
-
panoIndex: (pano ?? this.pano).panoIndex,
|
|
2177
|
-
mode,
|
|
2178
|
-
longitude,
|
|
2179
|
-
latitude,
|
|
2180
|
-
fov,
|
|
2181
|
-
offset,
|
|
2182
|
-
distance
|
|
2183
|
-
};
|
|
2184
|
-
this.emit("state.set", createEvent<StateEvent>('state.set', {
|
|
2185
|
-
userAction,
|
|
2186
|
-
state: nextState,
|
|
2187
|
-
}));
|
|
2188
|
-
|
|
2189
|
-
if (!stateEqual(this.state, nextState)) {
|
|
2190
|
-
if (this.controller && nextState.mode === "VRPanorama" && nextState.mode !== this.state.mode) {
|
|
2191
|
-
assignState(this.state, nextState);
|
|
2192
|
-
this.changeMode("VRPanorama");
|
|
2193
|
-
} else if (this.controller && nextState.mode === "XRPanorama" && nextState.mode !== this.state.mode) {
|
|
2194
|
-
assignState(this.state, nextState);
|
|
2195
|
-
this.changeMode("XRPanorama");
|
|
2196
|
-
} else {
|
|
2197
|
-
assignState(this.state, nextState);
|
|
2198
|
-
// 既定认为 setState 行为一定是用户触发的
|
|
2199
|
-
if (this.controller && userAction) {
|
|
2200
|
-
this.controller.userAction = false;
|
|
2201
|
-
}
|
|
2202
|
-
if (immediately && this.state.mode === nextState.mode) {
|
|
2203
|
-
this.syncingState = this.syncState(now(), 0, immediately);
|
|
2204
|
-
if (this.syncingState) {
|
|
2205
|
-
this.controller?.updateTime(now(), 0);
|
|
2206
|
-
this.syncingState = false;
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2210
|
-
userAction,
|
|
2211
|
-
state: this.state,
|
|
2212
|
-
}));
|
|
2213
|
-
this.analysis?.state(this.works, this.state);
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
private syncState(time: number, deltaTime: number, immediately: boolean = false): boolean {
|
|
2219
|
-
let lastStateSynced = this.stateSynced;
|
|
2220
|
-
this.stateSynced = false;
|
|
2221
|
-
|
|
2222
|
-
if (!this.controller) {
|
|
2223
|
-
return false;
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
// 同步模态
|
|
2227
|
-
if (this.state.mode !== this.currentMode) {
|
|
2228
|
-
const state: State = {
|
|
2229
|
-
mode: this.state.mode,
|
|
2230
|
-
workCode: this.state.workCode,
|
|
2231
|
-
panoIndex: this.state.panoIndex,
|
|
2232
|
-
longitude: this.state.longitude,
|
|
2233
|
-
latitude: this.state.latitude,
|
|
2234
|
-
fov: this.state.fov,
|
|
2235
|
-
offset: this.state.offset,
|
|
2236
|
-
distance: this.state.distance
|
|
2237
|
-
}
|
|
2238
|
-
this.changeMode(this.state.mode, state, this.modeChangeDuration, this.controller.userAction);
|
|
2239
|
-
return true;
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
// 如果在动画中,则等待动画完成
|
|
2243
|
-
if (!this.controller.isReady()) return false;
|
|
2244
|
-
|
|
2245
|
-
// 同步位置
|
|
2246
|
-
if (this.controller instanceof Controllers["Model"]) {
|
|
2247
|
-
// 如果是 Model 模式,同步坐标
|
|
2248
|
-
if (notSimilarVector3(this.camera.pose.offset,this.state.offset)) {
|
|
2249
|
-
const pose: Partial<Pose> = {
|
|
2250
|
-
longitude: this.state.longitude,
|
|
2251
|
-
latitude: this.state.latitude,
|
|
2252
|
-
fov: this.state.fov,
|
|
2253
|
-
offset: this.state.offset,
|
|
2254
|
-
};
|
|
2255
|
-
this.controller.moveToPosition(this.state.offset, {
|
|
2256
|
-
...pose,
|
|
2257
|
-
duration: immediately ? 0 : undefined,
|
|
2258
|
-
}, false);
|
|
2259
|
-
return true;
|
|
2260
|
-
}
|
|
2261
|
-
} else {
|
|
2262
|
-
// 如果是 其他模式,同步点位
|
|
2263
|
-
const statePano: Pano = {
|
|
2264
|
-
workCode: this.state.workCode,
|
|
2265
|
-
panoIndex: this.state.panoIndex,
|
|
2266
|
-
};
|
|
2267
|
-
if (!panoEqual(statePano, this.pano) && 'moveToPano' in this.controller && typeof this.controller.moveToPano === 'function') {
|
|
2268
|
-
const pose: Pose = {
|
|
2269
|
-
longitude: this.state.longitude,
|
|
2270
|
-
latitude: this.state.latitude,
|
|
2271
|
-
fov: this.state.fov,
|
|
2272
|
-
offset: this.state.offset,
|
|
2273
|
-
distance: this.state.distance,
|
|
2274
|
-
};
|
|
2275
|
-
this.controller.moveToPano(statePano, pose, false);
|
|
2276
|
-
return true;
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
// 同步摄像机
|
|
2281
|
-
if (
|
|
2282
|
-
this.controller instanceof Controllers["Floorplan"] ||
|
|
2283
|
-
this.controller instanceof Controllers["Topview"] ||
|
|
2284
|
-
this.controller instanceof Controllers["Mapview"]
|
|
2285
|
-
) {
|
|
2286
|
-
// 如果是 Topview 模式同步位置
|
|
2287
|
-
const defaultFovStep = 1;
|
|
2288
|
-
const defaultDistanceStep = 0.2;
|
|
2289
|
-
const defaultOffsetStep = 0.2;
|
|
2290
|
-
const defaultCoordinatesStep = Math.PI / 45;
|
|
2291
|
-
|
|
2292
|
-
const nextFov = immediately ?
|
|
2293
|
-
this.state.fov :
|
|
2294
|
-
stepNumber(this.camera.pose.fov, this.state.fov, defaultFovStep);
|
|
2295
|
-
|
|
2296
|
-
const deltaDistance = Math.abs(this.camera.pose.distance - this.state.distance);
|
|
2297
|
-
const distanceStep = deltaDistance > defaultOffsetStep * 15 ? deltaDistance / 15 : defaultDistanceStep;
|
|
2298
|
-
const nextDistance = immediately ?
|
|
2299
|
-
this.state.distance :
|
|
2300
|
-
stepNumber(this.camera.pose.distance, this.state.distance, distanceStep);
|
|
2301
|
-
|
|
2302
|
-
const deltaOffsetDistance = this.camera.pose.offset.distanceTo(this.state.offset);
|
|
2303
|
-
const offsetDtep = deltaOffsetDistance > defaultOffsetStep * 15 ? deltaOffsetDistance / 15 : defaultOffsetStep;
|
|
2304
|
-
const nextOffset = immediately ?
|
|
2305
|
-
new THREE.Vector3().copy(this.state.offset) :
|
|
2306
|
-
stepVector(this.camera.pose.offset, this.state.offset, offsetDtep);
|
|
2307
|
-
|
|
2308
|
-
const nextCoordinates = immediately ?
|
|
2309
|
-
{ longitude: this.state.longitude, latitude: this.state.latitude } :
|
|
2310
|
-
stepCoordinates(
|
|
2311
|
-
{ longitude: this.camera.pose.longitude, latitude: this.camera.pose.latitude },
|
|
2312
|
-
{ longitude: this.state.longitude, latitude: this.state.latitude },
|
|
2313
|
-
defaultCoordinatesStep,
|
|
2314
|
-
);
|
|
2315
|
-
const { longitude: nextLongitude, latitude: nextLatitude } = nextCoordinates;
|
|
2316
|
-
if (
|
|
2317
|
-
notSimilarValue(nextFov, this.camera.pose.fov) ||
|
|
2318
|
-
notSimilarVector3(nextOffset, this.camera.pose.offset) ||
|
|
2319
|
-
notSimilarValue(nextDistance, this.camera.pose.distance) ||
|
|
2320
|
-
notSimilarValue(nextLongitude, this.camera.pose.longitude, Math.PI * 2) ||
|
|
2321
|
-
notSimilarValue(nextLatitude, this.camera.pose.latitude)
|
|
2322
|
-
) {
|
|
2323
|
-
const nextLocationMotionValue = { x: nextOffset.x, y: nextOffset.y, z: nextOffset.z }
|
|
2324
|
-
const nextCameraMotionValue = { fov: nextFov }
|
|
2325
|
-
|
|
2326
|
-
Object.assign(nextLocationMotionValue, {
|
|
2327
|
-
distance: nextDistance,
|
|
2328
|
-
})
|
|
2329
|
-
Object.assign(nextCameraMotionValue, {
|
|
2330
|
-
longitude: nextLongitude,
|
|
2331
|
-
latitude: nextLatitude,
|
|
2332
|
-
})
|
|
2333
|
-
this.controller.stopMomentumMovement();
|
|
2334
|
-
this.controller.cameraMotion.set(nextCameraMotionValue, 0).catch(noop);
|
|
2335
|
-
this.controller.locationMotion.set( nextLocationMotionValue, 0).catch(noop);
|
|
2336
|
-
return true;
|
|
2337
|
-
}
|
|
2338
|
-
} else {
|
|
2339
|
-
// 如果是 其他模式同步经纬度
|
|
2340
|
-
const fovStep = 1;
|
|
2341
|
-
const coordinatesStep = Math.PI / 45;
|
|
2342
|
-
const nextFov = immediately ? this.state.fov : stepNumber(this.camera.pose.fov, this.state.fov, fovStep);
|
|
2343
|
-
const { longitude: nextLongitude, latitude: nextLatitude } = immediately ?
|
|
2344
|
-
{ longitude: this.state.longitude, latitude: this.state.latitude } :
|
|
2345
|
-
stepCoordinates(
|
|
2346
|
-
{ longitude: this.camera.pose.longitude, latitude: this.camera.pose.latitude },
|
|
2347
|
-
{ longitude: this.state.longitude, latitude: this.state.latitude },
|
|
2348
|
-
coordinatesStep,
|
|
2349
|
-
);
|
|
2350
|
-
const nextDistance = this.state.distance;
|
|
2351
|
-
const nextOffset = new THREE.Vector3().copy(this.state.offset);
|
|
2352
|
-
if (notSimilarValue(nextDistance, this.camera.pose.distance)) {
|
|
2353
|
-
this.state.distance = this.camera.pose.distance;
|
|
2354
|
-
}
|
|
2355
|
-
if (notSimilarVector3(nextOffset, this.camera.pose.offset)) {
|
|
2356
|
-
this.state.offset = this.camera.pose.offset.clone();
|
|
2357
|
-
}
|
|
2358
|
-
if (
|
|
2359
|
-
notSimilarValue(nextLongitude, this.camera.pose.longitude, Math.PI * 2) ||
|
|
2360
|
-
notSimilarValue(nextLatitude, this.camera.pose.latitude) ||
|
|
2361
|
-
notSimilarValue(nextFov, this.camera.pose.fov)
|
|
2362
|
-
) {
|
|
2363
|
-
this.controller.stopMomentumMovement();
|
|
2364
|
-
this.controller.cameraMotion.set({ longitude: nextLongitude, latitude: nextLatitude, fov: nextFov }, 0).catch(noop);
|
|
2365
|
-
return true;
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
this.stateSynced = true;
|
|
2369
|
-
if (lastStateSynced === false) {
|
|
2370
|
-
this.emit("state.synced", createEvent<StateEvent>('state.synced', {
|
|
2371
|
-
userAction: false,
|
|
2372
|
-
state: this.state,
|
|
2373
|
-
}));
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
if (this.readyCallbacks.length && this.stateSynced) {
|
|
2377
|
-
const mode = this.currentMode;
|
|
2378
|
-
const needsModelReady = mode === Five.Mode.Floorplan || mode === Five.Mode.Topview || mode === Five.Mode.Mapview || mode === Five.Mode.Model;
|
|
2379
|
-
if (needsModelReady ? this.modelScene.loaded : true) {
|
|
2380
|
-
const readyCallbacks = this.readyCallbacks.slice();
|
|
2381
|
-
this.readyCallbacks.length = 0;
|
|
2382
|
-
for (const callback of readyCallbacks) {
|
|
2383
|
-
if (this.controller instanceof Controllers['Panorama']) {
|
|
2384
|
-
if (callback.tile === true && !this.controller.isTileReady()) {
|
|
2385
|
-
this.readyCallbacks.push(callback);
|
|
2386
|
-
} else {
|
|
2387
|
-
callback();
|
|
2388
|
-
}
|
|
2389
|
-
} else {
|
|
2390
|
-
callback();
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
return false;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
/**
|
|
2399
|
-
* 当前页面静态
|
|
2400
|
-
*/
|
|
2401
|
-
public ready(args: {tile?: boolean} = {}): Promise<void> {
|
|
2402
|
-
return new Promise<void>(resolve => {
|
|
2403
|
-
this.readyCallbacks.push(
|
|
2404
|
-
Object.assign(resolve, { tile: args.tile ?? false })
|
|
2405
|
-
);
|
|
2406
|
-
})
|
|
2407
|
-
.then(() => {
|
|
2408
|
-
// 确保模型初始化完成
|
|
2409
|
-
return this.model.initReady;
|
|
2410
|
-
})
|
|
2411
|
-
.then(noop);
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
/**
|
|
2415
|
-
* 请求全屏
|
|
2416
|
-
*/
|
|
2417
|
-
public requestFullscreen() {
|
|
2418
|
-
if (!isMobile) return;
|
|
2419
|
-
const parentNode = this.getElement()?.parentNode;
|
|
2420
|
-
if (parentNode && "requestFullscreen" in parentNode && typeof document !== "undefined" && document.fullscreenElement === null) {
|
|
2421
|
-
(parentNode as HTMLElement).requestFullscreen();
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
/**
|
|
2426
|
-
* 退出全屏
|
|
2427
|
-
*/
|
|
2428
|
-
public exitFullscreen() {
|
|
2429
|
-
if (typeof document !== "undefined" && document.fullscreenElement && "exitFullscreen" in document) {
|
|
2430
|
-
document.exitFullscreen();
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
private throwError(error: Error) {
|
|
2435
|
-
if (this.hasListener("error")) {
|
|
2436
|
-
this.emit("error", error);
|
|
2437
|
-
} else {
|
|
2438
|
-
console.error(error);
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
private bindModel(model: Model) {
|
|
2443
|
-
const onModelLoad = () => {
|
|
2444
|
-
AnimationFrameLoop.shared.add(() => {
|
|
2445
|
-
this.emit('model.load', createEvent<ModelEvent>('model.load', { work: model.work, model, error: null }));
|
|
2446
|
-
}, true);
|
|
2447
|
-
};
|
|
2448
|
-
const onModelError = (event: {error: Error}) => {
|
|
2449
|
-
const { error } = event;
|
|
2450
|
-
this.emit('model.error', createEvent<ModelEvent>('model.error', { work: model.work, model, error }));
|
|
2451
|
-
this.throwError(error);
|
|
2452
|
-
};
|
|
2453
|
-
const onModelChangeShownFloor = () => {
|
|
2454
|
-
this.emit('model.changeShownFloor', createEvent<ModelEvent>('model.changeShownFloor', { work: model.work, model, error: null }));
|
|
2455
|
-
};
|
|
2456
|
-
const onModelDispose = () => {
|
|
2457
|
-
model.removeEventListener('load', onModelLoad);
|
|
2458
|
-
model.removeEventListener('error', onModelError);
|
|
2459
|
-
model.removeEventListener('changeShownFloor', onModelChangeShownFloor);
|
|
2460
|
-
model.removeEventListener('dispose', onModelDispose);
|
|
2461
|
-
}
|
|
2462
|
-
model.addEventListener('load', onModelLoad);
|
|
2463
|
-
model.addEventListener('error', onModelError);
|
|
2464
|
-
model.addEventListener('changeShownFloor', onModelChangeShownFloor);
|
|
2465
|
-
model.addEventListener('dispose', onModelDispose);
|
|
2466
|
-
|
|
2467
|
-
this.emit('model.request', createEvent<ModelEvent>('model.request', { work: model.work, model, error: null }));
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
private bindWorkFetcher(work: Work) {
|
|
2471
|
-
const five = this;
|
|
2472
|
-
const workCode = work.workCode;
|
|
2473
|
-
const allowHosts = work.allowHosts;
|
|
2474
|
-
const fetcher = new Fetcher({
|
|
2475
|
-
get networkSubscribe() {
|
|
2476
|
-
return five.networkSubscribe;
|
|
2477
|
-
},
|
|
2478
|
-
requestProxy(url) {
|
|
2479
|
-
return Promise.resolve(url)
|
|
2480
|
-
.then(url => five.requestProxy(url, workCode))
|
|
2481
|
-
.then(url => {
|
|
2482
|
-
const result = verifyURL(url, allowHosts);
|
|
2483
|
-
if (result instanceof Error) {
|
|
2484
|
-
return Promise.reject(result);
|
|
2485
|
-
}
|
|
2486
|
-
return result;
|
|
2487
|
-
});
|
|
2488
|
-
},
|
|
2489
|
-
});
|
|
2490
|
-
registerFetcher(this.fiveId, work, fetcher);
|
|
2491
|
-
}
|
|
2492
|
-
|
|
2493
|
-
private commonParams(): Omit<BaseControllerInitType, "panoIndex" | "initial"> {
|
|
2494
|
-
return {
|
|
2495
|
-
fiveId: this.fiveId,
|
|
2496
|
-
scene: this.scene,
|
|
2497
|
-
xrCustomObjectsScene: this.xrCustomObjectsScene,
|
|
2498
|
-
helper: this.helperGroup,
|
|
2499
|
-
camera: this.camera,
|
|
2500
|
-
renderer: this.renderer!,
|
|
2501
|
-
viewport: this.viewport,
|
|
2502
|
-
element: this.getElement()!,
|
|
2503
|
-
works: this.works,
|
|
2504
|
-
imageOptions: this.imageOptions,
|
|
2505
|
-
enableWheel: this.enableWheel,
|
|
2506
|
-
extraElements: this.extraElements,
|
|
2507
|
-
videoTexture: this.videoTexture,
|
|
2508
|
-
modelScene: this.modelScene,
|
|
2509
|
-
};
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2512
|
-
private applyController<T extends Mode>(
|
|
2513
|
-
mode: T,
|
|
2514
|
-
initialParams: ControllerInitType<T>
|
|
2515
|
-
): ControllerInstanceType<T> {
|
|
2516
|
-
|
|
2517
|
-
if (!this.renderer) {
|
|
2518
|
-
throw new Error("renderer is not initialized.");
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
const Controller = Controllers[mode] as ControllerType<T>;
|
|
2522
|
-
|
|
2523
|
-
this.currentMode = mode;
|
|
2524
|
-
|
|
2525
|
-
const controller = new Controller(initialParams);
|
|
2526
|
-
|
|
2527
|
-
// 透传出去事件
|
|
2528
|
-
for (let name of PROXY_CONTROLLER_EVENT_NAMES) {
|
|
2529
|
-
controller.on(name as any, (...args: any[]) => {
|
|
2530
|
-
const canceled = this.emit(name as any, ...args);
|
|
2531
|
-
if (canceled) return false;
|
|
2532
|
-
});
|
|
2533
|
-
}
|
|
2534
|
-
|
|
2535
|
-
// 如果 userAction 为 true, 则设置 state 为最终值
|
|
2536
|
-
{
|
|
2537
|
-
const nextState = Controllers[mode].initAnimationEndState(initialParams);
|
|
2538
|
-
const userAction = initialParams.initial.userAction;
|
|
2539
|
-
if (!stateEqual(this.state, nextState)) {
|
|
2540
|
-
assignState(this.state, nextState);
|
|
2541
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2542
|
-
userAction,
|
|
2543
|
-
state: this.state,
|
|
2544
|
-
}));
|
|
2545
|
-
}
|
|
2546
|
-
this.emit("currentState.change", createEvent<StateEvent>('currentState.change', {
|
|
2547
|
-
userAction,
|
|
2548
|
-
state: this.getCurrentState(),
|
|
2549
|
-
}));
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
controller.on("camera.update", event => {
|
|
2553
|
-
if (this.controller) {
|
|
2554
|
-
const nextState: State = this.controller.getTargetState();
|
|
2555
|
-
if (
|
|
2556
|
-
event.userAction &&
|
|
2557
|
-
this.syncingState === false &&
|
|
2558
|
-
this.state.mode === nextState.mode &&
|
|
2559
|
-
!stateEqual(this.state, nextState)
|
|
2560
|
-
) {
|
|
2561
|
-
assignState(this.state, nextState);
|
|
2562
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2563
|
-
userAction: event.userAction,
|
|
2564
|
-
state: this.state,
|
|
2565
|
-
}));
|
|
2566
|
-
this.analysis?.state(this.works, this.state);
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
this.emit("currentState.change", createEvent<StateEvent>('currentState.change', {
|
|
2570
|
-
userAction: event.userAction,
|
|
2571
|
-
state: this.getCurrentState(),
|
|
2572
|
-
}));
|
|
2573
|
-
});
|
|
2574
|
-
|
|
2575
|
-
controller.on("initAnimation.start", event => {
|
|
2576
|
-
const { state, userAction } = event;
|
|
2577
|
-
if (userAction && this.state.mode === state.mode && !stateEqual(this.state, state)) {
|
|
2578
|
-
assignState(this.state, state);
|
|
2579
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2580
|
-
userAction,
|
|
2581
|
-
state: this.state,
|
|
2582
|
-
}));
|
|
2583
|
-
this.analysis?.state(this.works, this.state);
|
|
2584
|
-
}
|
|
2585
|
-
});
|
|
2586
|
-
|
|
2587
|
-
controller.on("initAnimation.end", event => {
|
|
2588
|
-
const { state, userAction } = event;
|
|
2589
|
-
this.pano = {
|
|
2590
|
-
workCode: state.workCode,
|
|
2591
|
-
panoIndex: state.panoIndex,
|
|
2592
|
-
};
|
|
2593
|
-
if (userAction && this.state.mode === state.mode && !stateEqual(this.state, state)) {
|
|
2594
|
-
assignState(this.state, state);
|
|
2595
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2596
|
-
userAction,
|
|
2597
|
-
state: this.state,
|
|
2598
|
-
}));
|
|
2599
|
-
this.analysis?.state(this.works, this.state);
|
|
2600
|
-
}
|
|
2601
|
-
});
|
|
2602
|
-
|
|
2603
|
-
controller.on("pano.moveTo", event => {
|
|
2604
|
-
const { state, userAction } = event;
|
|
2605
|
-
this.pano = {
|
|
2606
|
-
workCode: state.workCode,
|
|
2607
|
-
panoIndex: state.panoIndex,
|
|
2608
|
-
};
|
|
2609
|
-
if (userAction && this.state.mode === state.mode && !stateEqual(this.state, state)) {
|
|
2610
|
-
assignState(this.state, state);
|
|
2611
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2612
|
-
userAction,
|
|
2613
|
-
state: this.state,
|
|
2614
|
-
}));
|
|
2615
|
-
this.analysis?.state(this.works, this.state);
|
|
2616
|
-
}
|
|
2617
|
-
});
|
|
2618
|
-
|
|
2619
|
-
controller.on("pano.arrived", event => {
|
|
2620
|
-
const { state, userAction } = event;
|
|
2621
|
-
this.pano = {
|
|
2622
|
-
workCode: state.workCode,
|
|
2623
|
-
panoIndex: state.panoIndex,
|
|
2624
|
-
};
|
|
2625
|
-
if (userAction && this.state.mode === state.mode && !stateEqual(this.state, state)) {
|
|
2626
|
-
assignState(this.state, state);
|
|
2627
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2628
|
-
userAction,
|
|
2629
|
-
state: this.state,
|
|
2630
|
-
}));
|
|
2631
|
-
this.analysis?.state(this.works, this.state);
|
|
2632
|
-
}
|
|
2633
|
-
});
|
|
2634
|
-
|
|
2635
|
-
controller.on("pano.cancel", event => {
|
|
2636
|
-
const { state, userAction } = event;
|
|
2637
|
-
if (userAction && this.state.mode === state.mode && !stateEqual(this.state, state)) {
|
|
2638
|
-
assignState(this.state, state);
|
|
2639
|
-
this.emit("state.change", createEvent<StateEvent>('state.change', {
|
|
2640
|
-
userAction,
|
|
2641
|
-
state: this.state,
|
|
2642
|
-
}));
|
|
2643
|
-
this.analysis?.state(this.works, this.state);
|
|
2644
|
-
}
|
|
2645
|
-
});
|
|
2646
|
-
|
|
2647
|
-
controller.on("pano.moveTo", event => {
|
|
2648
|
-
const { userAction } = event;
|
|
2649
|
-
this.emit("currentState.change", createEvent<StateEvent>('currentState.change', {
|
|
2650
|
-
userAction,
|
|
2651
|
-
state: this.getCurrentState(),
|
|
2652
|
-
}));
|
|
2653
|
-
});
|
|
2654
|
-
|
|
2655
|
-
controller.on("pano.request", event => {
|
|
2656
|
-
this.emit('pano.request', event);
|
|
2657
|
-
if (!event.defaultPrevented) {
|
|
2658
|
-
this.moveToPano(event.state, event.options, event.userAction);
|
|
2659
|
-
}
|
|
2660
|
-
});
|
|
2661
|
-
|
|
2662
|
-
controller.on("vr.requestExit", () => {
|
|
2663
|
-
if (this.currentMode !== Five.Mode.VRPanorama) return;
|
|
2664
|
-
this.exitFullscreen();
|
|
2665
|
-
this.changeMode(Five.Mode.Panorama);
|
|
2666
|
-
});
|
|
2667
|
-
|
|
2668
|
-
controller.on("error", error => this.throwError(error));
|
|
2669
|
-
|
|
2670
|
-
return controller as ControllerInstanceType<T>;
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
/** 移除事件绑定 */
|
|
2674
|
-
private removeEventListeners() {}
|
|
2675
|
-
|
|
2676
|
-
public get internalLightsEnabled(): boolean {
|
|
2677
|
-
const internalLights = this.scene.children.find(child => child.name === 'internalLights');
|
|
2678
|
-
if(!internalLights) {
|
|
2679
|
-
return false
|
|
2680
|
-
}else{
|
|
2681
|
-
return internalLights.visible;
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
|
|
2685
|
-
public set internalLightsEnabled(value: boolean) {
|
|
2686
|
-
let internalLights = this.scene.children.find(child => child.name === 'internalLights');
|
|
2687
|
-
if(internalLights) {
|
|
2688
|
-
internalLights.visible = value;
|
|
2689
|
-
}
|
|
2690
|
-
internalLights = this.modelScene.children.find(child => child.name === 'internalLights')
|
|
2691
|
-
if (internalLights) {
|
|
2692
|
-
internalLights.visible = value;
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
|
|
2696
|
-
//=========== deprecated ===============
|
|
2697
|
-
|
|
2698
|
-
/**
|
|
2699
|
-
* @deprecated
|
|
2700
|
-
* use Viewport instead.
|
|
2701
|
-
*/
|
|
2702
|
-
public get scissor() {
|
|
2703
|
-
return this.viewport;
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
/**
|
|
2707
|
-
* @deprecated
|
|
2708
|
-
* use setViewport instead.
|
|
2709
|
-
*/
|
|
2710
|
-
public setScissor(scissor: Viewport) {
|
|
2711
|
-
return this.setViewport(scissor);
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
/**
|
|
2715
|
-
* @deprecated
|
|
2716
|
-
* 获取当前相机姿态, 可以使用 getCurrentState 代替
|
|
2717
|
-
*/
|
|
2718
|
-
public getPose(): Pose {
|
|
2719
|
-
const { longitude, latitude, fov, offset, distance } = this.camera.copyPose();
|
|
2720
|
-
return { longitude, latitude, fov, offset: offset.clone(), distance };
|
|
2721
|
-
}
|
|
2722
|
-
|
|
2723
|
-
/**
|
|
2724
|
-
* 获取当前相机经纬度
|
|
2725
|
-
* @deprecated 请使用使用 getPose
|
|
2726
|
-
*/
|
|
2727
|
-
public getLongitudeAndLatitude(): Pick<Pose, "longitude" | "latitude"> {
|
|
2728
|
-
const { longitude, latitude } = this.getPose();
|
|
2729
|
-
return { longitude, latitude };
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
/**
|
|
2733
|
-
* 获取当前相机位置
|
|
2734
|
-
* @deprecated 请使用使用 getPose
|
|
2735
|
-
*/
|
|
2736
|
-
public getOffset(): Pose["offset"] {
|
|
2737
|
-
return this.getPose().offset;
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
/**
|
|
2741
|
-
* 获取当前相机的姿态(用于内部的 python 脚本截图)
|
|
2742
|
-
* @deprecated 这是用于内部的 python 脚本截图
|
|
2743
|
-
*/
|
|
2744
|
-
public getCameraLocal() {
|
|
2745
|
-
if (this.pano.workCode && this.controller && this.works) {
|
|
2746
|
-
const observer = this.works.getObserver(this.pano);
|
|
2747
|
-
if (observer) {
|
|
2748
|
-
const object = new THREE.Object3D();
|
|
2749
|
-
object.matrix.copy(observer.matrix).premultiply(observer.work.transform);
|
|
2750
|
-
object.matrix.decompose(object.position, object.quaternion, object.scale);
|
|
2751
|
-
object.matrixAutoUpdate = false;
|
|
2752
|
-
|
|
2753
|
-
const lookAtVector = new THREE.Vector3(0, 0, -1);
|
|
2754
|
-
lookAtVector.applyQuaternion(this.camera.quaternion);
|
|
2755
|
-
|
|
2756
|
-
const quaternion = object.quaternion.clone().inverse();
|
|
2757
|
-
lookAtVector.applyQuaternion(quaternion);
|
|
2758
|
-
|
|
2759
|
-
const theta = Math.atan2(lookAtVector.x, - lookAtVector.z);
|
|
2760
|
-
const phi = - Math.asin(lookAtVector.y);
|
|
2761
|
-
|
|
2762
|
-
return { theta, phi, lookAtVector };
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
return null;
|
|
2766
|
-
}
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
/**
|
|
2770
|
-
* 增加后处理PASS
|
|
2771
|
-
* @param pass - 要添加的Pass实例
|
|
2772
|
-
*/
|
|
2773
|
-
|
|
2774
|
-
public addPass(pass: Pass) {
|
|
2775
|
-
this.fiveRenderer.composer.addPass(pass);
|
|
2776
|
-
}
|
|
2777
|
-
|
|
2778
|
-
/**
|
|
2779
|
-
* 移除后处理Pass
|
|
2780
|
-
* @param pass - 要移除的Pass实例
|
|
2781
|
-
*/
|
|
2782
|
-
public removePass(pass: Pass) {
|
|
2783
|
-
const index = this.fiveRenderer.composer.passes.indexOf(pass);
|
|
2784
|
-
if (index !== -1) {
|
|
2785
|
-
this.fiveRenderer.composer.passes.splice(index, 1);
|
|
2786
|
-
}
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
/**
|
|
2790
|
-
* 在指定位置插入后处理Pass
|
|
2791
|
-
* @param pass - 要插入的Pass实例
|
|
2792
|
-
* @param index - 插入位置的索引
|
|
2793
|
-
*/
|
|
2794
|
-
public insertPass(pass: Pass, index: number) {
|
|
2795
|
-
this.fiveRenderer.composer.insertPass(pass, index);
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
|
-
/**
|
|
2799
|
-
* 设置渲染模式
|
|
2800
|
-
*/
|
|
2801
|
-
public get renderMode() {
|
|
2802
|
-
return this.fiveRenderer.renderMode;
|
|
2803
|
-
}
|
|
2804
|
-
public set renderMode(value) {
|
|
2805
|
-
this.fiveRenderer.renderMode = value;
|
|
2806
|
-
}
|
|
2807
|
-
|
|
2808
|
-
/** 开启 HQ */
|
|
2809
|
-
public get enableHQ(): boolean {
|
|
2810
|
-
return this.fiveRenderer.renderMode === 'point-cloud-high-quality';
|
|
2811
|
-
}
|
|
2812
|
-
public set enableHQ(enable: boolean) {
|
|
2813
|
-
this.fiveRenderer.renderMode = enable ? 'point-cloud-high-quality' : 'default';
|
|
2814
|
-
this.needsRender = true;
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2817
|
-
/** 开启 edl */
|
|
2818
|
-
public get enableEDL(): boolean {
|
|
2819
|
-
return this.eyeDomeLightingPass.enabled;
|
|
2820
|
-
}
|
|
2821
|
-
public set enableEDL(enable: boolean) {
|
|
2822
|
-
this.eyeDomeLightingPass.enabled = enable;
|
|
2823
|
-
this.needsRender = true;
|
|
2824
|
-
}
|
|
2825
|
-
|
|
2826
|
-
/** 开启 AdaptiveLuminance */
|
|
2827
|
-
public get enableAdaptiveLuminance(): boolean {
|
|
2828
|
-
return this.adaptiveLuminancePass.enabled;
|
|
2829
|
-
}
|
|
2830
|
-
public set enableAdaptiveLuminance(enable: boolean) {
|
|
2831
|
-
this.adaptiveLuminancePass.enabled = enable;
|
|
2832
|
-
this.needsRender = true;
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
|
-
/**
|
|
2836
|
-
* @deprecated
|
|
2837
|
-
* 不可用
|
|
2838
|
-
*/
|
|
2839
|
-
public get enableIOSEDR(): boolean {
|
|
2840
|
-
return false;
|
|
2841
|
-
}
|
|
2842
|
-
public set enableIOSEDR(enable: boolean) {
|
|
2843
|
-
}
|
|
2844
|
-
|
|
2845
|
-
/**
|
|
2846
|
-
* @deprecated
|
|
2847
|
-
* 不可用
|
|
2848
|
-
*/
|
|
2849
|
-
public get enablePostProcessing(): boolean {
|
|
2850
|
-
return true;
|
|
2851
|
-
}
|
|
2852
|
-
public set enablePostProcessing(enable: boolean) {
|
|
2853
|
-
}
|
|
2854
|
-
|
|
2855
|
-
/**
|
|
2856
|
-
* @deprecated
|
|
2857
|
-
* use five.modelScene.needsRender instead
|
|
2858
|
-
*/
|
|
2859
|
-
public get modelSceneNeedsRender(): boolean {
|
|
2860
|
-
return this.modelScene.needsRender;
|
|
2861
|
-
}
|
|
2862
|
-
public set modelSceneNeedsRender(needsRender: boolean) {
|
|
2863
|
-
this.modelScene.needsRender = needsRender;
|
|
2864
|
-
}
|
|
2865
|
-
|
|
2866
|
-
}
|
|
2867
|
-
|
|
2868
|
-
if (typeof window !== "undefined") {
|
|
2869
|
-
const __FIVE_DEBUG__: {
|
|
2870
|
-
THREE: typeof THREE,
|
|
2871
|
-
constructor: typeof Five;
|
|
2872
|
-
instances: Record<string, Five>;
|
|
2873
|
-
} = {
|
|
2874
|
-
THREE,
|
|
2875
|
-
constructor: Five,
|
|
2876
|
-
instances: Five_Instances,
|
|
2877
|
-
};
|
|
2878
|
-
Object.assign(window, { __FIVE_DEBUG__ });
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
export { Five, FiveInitArgs };
|