@realsee/five-webgpu 1.0.0-alpha.1
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 +9 -0
- package/AI_CONTEXT.md +9 -0
- package/README.md +80 -0
- package/TERMS.txt +54 -0
- package/ai_guides/README.md +118 -0
- package/ai_guides/ai-doc-guidelines.md +102 -0
- package/ai_guides/api.md +274 -0
- package/ai_guides/features/3dtile.md +172 -0
- package/ai_guides/features/camera-animation.md +205 -0
- package/ai_guides/features/clipper.md +135 -0
- package/ai_guides/features/coordinate-system.md +128 -0
- package/ai_guides/features/event.md +154 -0
- package/ai_guides/features/five.md +184 -0
- package/ai_guides/features/gesture.md +181 -0
- package/ai_guides/features/get-screen-pixels.md +182 -0
- package/ai_guides/features/image-options.md +164 -0
- package/ai_guides/features/load-external-model.md +350 -0
- package/ai_guides/features/load-progress.md +140 -0
- package/ai_guides/features/material.md +153 -0
- package/ai_guides/features/mode.md +269 -0
- package/ai_guides/features/model.md +186 -0
- package/ai_guides/features/move-pano-effect.md +145 -0
- package/ai_guides/features/multi-work.md +146 -0
- package/ai_guides/features/pano-filter.md +144 -0
- package/ai_guides/features/pano-tile.md +132 -0
- package/ai_guides/features/pano-uv.md +131 -0
- package/ai_guides/features/parameter.md +153 -0
- package/ai_guides/features/raycast.md +175 -0
- package/ai_guides/features/request-proxy.md +112 -0
- package/ai_guides/features/screen-project.md +165 -0
- package/ai_guides/features/state.md +101 -0
- package/ai_guides/features/ultra-hdr.md +204 -0
- package/ai_guides/features/view-layer.md +187 -0
- package/ai_guides/features/work.md +303 -0
- package/ai_guides/glossary.md +93 -0
- package/ai_guides/intro.md +23 -0
- package/ai_guides/quick-start.md +69 -0
- package/ai_guides/release_notes/6.6.md +86 -0
- package/ai_guides/release_notes/6.7.md +401 -0
- package/ai_guides/release_notes/6.8.md +208 -0
- package/ai_guides/support.md +23 -0
- package/ai_guides/template.md +70 -0
- package/docs/.nojekyll +1 -0
- package/docs/00_FOR_AI_AGENTS.md +12 -0
- package/docs/README.md +12 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +134 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/index.AdaptiveLuminancePass.html +23 -0
- package/docs/classes/index.AnimationFrameLoop.html +18 -0
- package/docs/classes/index.BoundingMesh.html +4 -0
- package/docs/classes/index.Camera.html +42 -0
- package/docs/classes/index.EffectComposer.html +25 -0
- package/docs/classes/index.EyeDomeLightingPass.html +20 -0
- package/docs/classes/index.Fetcher.html +5 -0
- package/docs/classes/index.Five.html +311 -0
- package/docs/classes/index.FivePass.html +17 -0
- package/docs/classes/index.FiveRenderer.html +8 -0
- package/docs/classes/index.FlowingFireworks3DPass.html +22 -0
- package/docs/classes/index.FlowingLight2DPass.html +21 -0
- package/docs/classes/index.FlowingLight3DPass.html +23 -0
- package/docs/classes/index.FullScreenQuad.html +7 -0
- package/docs/classes/index.GaussianBlurPass.html +19 -0
- package/docs/classes/index.Histogram.html +19 -0
- package/docs/classes/index.InternalWebGPURenderer.html +4 -0
- package/docs/classes/index.Model.html +93 -0
- package/docs/classes/index.ModelScene.html +40 -0
- package/docs/classes/index.Motion.html +17 -0
- package/docs/classes/index.NetworkSubscribe.html +41 -0
- package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +37 -0
- package/docs/classes/index.PBMGaussianSplattingObject.html +32 -0
- package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +19 -0
- package/docs/classes/index.PBMGroup.html +5 -0
- package/docs/classes/index.PBMMesh.html +2 -0
- package/docs/classes/index.PBMMeshBasicMaterial.html +70 -0
- package/docs/classes/index.PBMMeshBasicNodeMaterial.html +74 -0
- package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +70 -0
- package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +74 -0
- package/docs/classes/index.PBMMeshPhongMaterial.html +69 -0
- package/docs/classes/index.PBMMeshPhongNodeMaterial.html +73 -0
- package/docs/classes/index.PBMMeshPhysicalMaterial.html +69 -0
- package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +73 -0
- package/docs/classes/index.PBMPanoFilter.html +61 -0
- package/docs/classes/index.PBMPointCloud.html +50 -0
- package/docs/classes/index.PBMSkinnedMesh.html +8 -0
- package/docs/classes/index.PBMUpdateable.html +41 -0
- package/docs/classes/index.PanoCircleMesh.html +30 -0
- package/docs/classes/index.PanoCircleMeshCustom.html +30 -0
- package/docs/classes/index.PanoCircleMeshSolid.html +30 -0
- package/docs/classes/index.Parameter.html +114 -0
- package/docs/classes/index.Scene.html +18 -0
- package/docs/classes/index.Subscribe.html +43 -0
- package/docs/classes/index.TextureLoader.html +4 -0
- package/docs/classes/index.Tile.html +34 -0
- package/docs/classes/index.Tile3D.html +98 -0
- package/docs/classes/index.TileCache.html +8 -0
- package/docs/classes/index.TileNode.html +14 -0
- package/docs/classes/index.TileRequestScheduler.html +4 -0
- package/docs/classes/index.Tileset.html +38 -0
- package/docs/classes/index.Trajectory.html +8 -0
- package/docs/classes/index.TrajectoryNode.html +8 -0
- package/docs/classes/index.Work.html +52 -0
- package/docs/classes/index.WorkResolvedObserver.html +68 -0
- package/docs/documents/README.html +134 -0
- package/docs/documents/ai-doc-guidelines.html +117 -0
- package/docs/documents/api.html +337 -0
- package/docs/documents/features_3dtile.html +216 -0
- package/docs/documents/features_camera-animation.html +157 -0
- package/docs/documents/features_clipper.html +80 -0
- package/docs/documents/features_coordinate-system.html +127 -0
- package/docs/documents/features_event.html +104 -0
- package/docs/documents/features_five.html +147 -0
- package/docs/documents/features_gesture.html +121 -0
- package/docs/documents/features_get-screen-pixels.html +88 -0
- package/docs/documents/features_image-options.html +108 -0
- package/docs/documents/features_load-external-model.html +600 -0
- package/docs/documents/features_load-progress.html +110 -0
- package/docs/documents/features_material.html +341 -0
- package/docs/documents/features_mode.html +114 -0
- package/docs/documents/features_model.html +141 -0
- package/docs/documents/features_move-pano-effect.html +110 -0
- package/docs/documents/features_multi-work.html +97 -0
- package/docs/documents/features_pano-filter.html +119 -0
- package/docs/documents/features_pano-tile.html +100 -0
- package/docs/documents/features_pano-uv.html +82 -0
- package/docs/documents/features_parameter.html +101 -0
- package/docs/documents/features_raycast.html +98 -0
- package/docs/documents/features_request-proxy.html +78 -0
- package/docs/documents/features_screen-project.html +112 -0
- package/docs/documents/features_state.html +71 -0
- package/docs/documents/features_ultra-hdr.html +188 -0
- package/docs/documents/features_view-layer.html +158 -0
- package/docs/documents/features_work.html +129 -0
- package/docs/documents/glossary.html +94 -0
- package/docs/documents/intro.html +24 -0
- package/docs/documents/quick-start.html +32 -0
- package/docs/documents/release_notes_6.6.html +79 -0
- package/docs/documents/release_notes_6.7.html +209 -0
- package/docs/documents/release_notes_6.8.html +189 -0
- package/docs/documents/support.html +49 -0
- package/docs/documents/template.html +80 -0
- package/docs/enums/index.VolumePlaneIntersect.html +4 -0
- package/docs/functions/index.coordinatesToVector.html +2 -0
- package/docs/functions/index.createDebugBoundingMesh.html +1 -0
- package/docs/functions/index.createWorks.html +1 -0
- package/docs/functions/index.defaultImageURLTransform.html +5 -0
- package/docs/functions/index.getViewportScale.html +1 -0
- package/docs/functions/index.headingToLongitude.html +4 -0
- package/docs/functions/index.imageSupport.html +1 -0
- package/docs/functions/index.isBoundingVolume.html +1 -0
- package/docs/functions/index.isPanoId.html +1 -0
- package/docs/functions/index.loadAt3d.html +1 -0
- package/docs/functions/index.loadDome.html +1 -0
- package/docs/functions/index.loadDomez.html +1 -0
- package/docs/functions/index.loadGltf.html +1 -0
- package/docs/functions/index.loadPbm.html +1 -0
- package/docs/functions/index.loadPly.html +1 -0
- package/docs/functions/index.longitudeToHeading.html +4 -0
- package/docs/functions/index.makeBoundingVolume.html +1 -0
- package/docs/functions/index.panoEqual.html +1 -0
- package/docs/functions/index.panoParse.html +1 -0
- package/docs/functions/index.panoStringify.html +1 -0
- package/docs/functions/index.parseWork.html +7 -0
- package/docs/functions/index.registerPBMMaterials.html +3 -0
- package/docs/functions/index.vectorToCoordinates.html +2 -0
- package/docs/functions/index.workToJson.html +1 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +134 -0
- package/docs/interfaces/index.AddableObject.html +9 -0
- package/docs/interfaces/index.AjaxOptions.html +9 -0
- package/docs/interfaces/index.AnimationFrame.html +6 -0
- package/docs/interfaces/index.AnimationFrameContext.html +3 -0
- package/docs/interfaces/index.BaseEvent.html +5 -0
- package/docs/interfaces/index.BoundingVolume.html +15 -0
- package/docs/interfaces/index.BoxBoundingVolume.html +18 -0
- package/docs/interfaces/index.CameraPose.html +6 -0
- package/docs/interfaces/index.CullingVolume.html +9 -0
- package/docs/interfaces/index.Draco.html +12 -0
- package/docs/interfaces/index.EventCallback.html +394 -0
- package/docs/interfaces/index.FiveInitArgs.html +104 -0
- package/docs/interfaces/index.FiveLoadOptions.html +12 -0
- package/docs/interfaces/index.FloorplanControllerCustomInitArgs.html +17 -0
- package/docs/interfaces/index.GestureEvent.html +19 -0
- package/docs/interfaces/index.IPBMMaterial.html +64 -0
- package/docs/interfaces/index.ImageOptions.html +21 -0
- package/docs/interfaces/index.ImageURLMappings.html +1 -0
- package/docs/interfaces/index.ImageURLOptions.html +17 -0
- package/docs/interfaces/index.IntersectEvent.html +8 -0
- package/docs/interfaces/index.IntersectMesh.html +2 -0
- package/docs/interfaces/index.IntersectMeshInterface.html +3 -0
- package/docs/interfaces/index.Intersection.html +9 -0
- package/docs/interfaces/index.LoosePanoWork.html +10 -0
- package/docs/interfaces/index.LooseWork.html +15 -0
- package/docs/interfaces/index.LooseWorkInitial.html +11 -0
- package/docs/interfaces/index.LooseWorkModel.html +8 -0
- package/docs/interfaces/index.LooseWorkObserver.html +17 -0
- package/docs/interfaces/index.LooseWorkPanorama.html +22 -0
- package/docs/interfaces/index.LooseWorkVideo.html +4 -0
- package/docs/interfaces/index.LooseWorkWithExtrinsics.html +15 -0
- package/docs/interfaces/index.MapviewControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/index.ModeChangeEvent.html +9 -0
- package/docs/interfaces/index.ModelControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/index.ModelEvent.html +8 -0
- package/docs/interfaces/index.ModelOptions.html +11 -0
- package/docs/interfaces/index.ModelSceneEvent.html +6 -0
- package/docs/interfaces/index.ModelTileEvent.html +8 -0
- package/docs/interfaces/index.MotionKeyframe.html +4 -0
- package/docs/interfaces/index.MovePanoOptions.html +35 -0
- package/docs/interfaces/index.NetworkAbortError.html +1 -0
- package/docs/interfaces/index.NetworkFirbiddenError.html +1 -0
- package/docs/interfaces/index.NetworkOptions.html +7 -0
- package/docs/interfaces/index.NetworkProxyError.html +1 -0
- package/docs/interfaces/index.NetworkResourceEvent.html +9 -0
- package/docs/interfaces/index.NetworkResponseError.html +2 -0
- package/docs/interfaces/index.NetworkTimeoutError.html +1 -0
- package/docs/interfaces/index.ObjectEvent.html +6 -0
- package/docs/interfaces/index.PBMClipperParameter.html +3 -0
- package/docs/interfaces/index.PBMHDRConfig.html +12 -0
- package/docs/interfaces/index.PBMPanoDepth.html +9 -0
- package/docs/interfaces/index.PBMPanoFilterValue.html +6 -0
- package/docs/interfaces/index.PBMPanoPicture.html +14 -0
- package/docs/interfaces/index.PBMRefinedScreen.html +6 -0
- package/docs/interfaces/index.PanoCircleMeshCustomOptions.html +9 -0
- package/docs/interfaces/index.PanoCircleMeshInterface.html +30 -0
- package/docs/interfaces/index.PanoCircleMeshOptions.html +3 -0
- package/docs/interfaces/index.PanoCircleMeshSolidOptions.html +3 -0
- package/docs/interfaces/index.PanoEvent.html +11 -0
- package/docs/interfaces/index.PanoTextureEvent.html +9 -0
- package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +41 -0
- package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/index.ParameterMaterialValue.html +74 -0
- package/docs/interfaces/index.ParameterTilesetValue.html +30 -0
- package/docs/interfaces/index.ParameterValue.html +103 -0
- package/docs/interfaces/index.Pass.html +9 -0
- package/docs/interfaces/index.PointCloudData.html +6 -0
- package/docs/interfaces/index.Pose.html +12 -0
- package/docs/interfaces/index.RegionBoundingVolume.html +21 -0
- package/docs/interfaces/index.RenderEvent.html +6 -0
- package/docs/interfaces/index.ResolvedParameterValue.html +104 -0
- package/docs/interfaces/index.RgbaData.html +7 -0
- package/docs/interfaces/index.SphereBoundingVolume.html +17 -0
- package/docs/interfaces/index.SplatData.html +10 -0
- package/docs/interfaces/index.State.html +23 -0
- package/docs/interfaces/index.StateEvent.html +7 -0
- package/docs/interfaces/index.TextureOptions.html +23 -0
- package/docs/interfaces/index.Tile3DOptions.html +11 -0
- package/docs/interfaces/index.TileCoordinateSystem.html +3 -0
- package/docs/interfaces/index.TileHeader.html +9 -0
- package/docs/interfaces/index.TilesetHeader.html +20 -0
- package/docs/interfaces/index.TilesetOptions.html +7 -0
- package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +13 -0
- package/docs/interfaces/index.TrajectoryHeader.html +5 -0
- package/docs/interfaces/index.ViewLayer.html +97 -0
- package/docs/interfaces/index.Viewport.html +13 -0
- package/docs/interfaces/index.WebXRAxesParams.html +4 -0
- package/docs/interfaces/index.WebXRControllerParams.html +2 -0
- package/docs/interfaces/index.WorkCubeImage.html +15 -0
- package/docs/interfaces/index.WorkImage.html +22 -0
- package/docs/interfaces/index.WorkInitial.html +17 -0
- package/docs/interfaces/index.WorkInitialJson.html +8 -0
- package/docs/interfaces/index.WorkJson.html +11 -0
- package/docs/interfaces/index.WorkModel.html +16 -0
- package/docs/interfaces/index.WorkModelJson.html +6 -0
- package/docs/interfaces/index.WorkModelLayer.html +11 -0
- package/docs/interfaces/index.WorkModelLayerJson.html +5 -0
- package/docs/interfaces/index.WorkObserver.html +63 -0
- package/docs/interfaces/index.WorkObserverJson.html +10 -0
- package/docs/interfaces/index.WorkPanoramaJson.html +14 -0
- package/docs/interfaces/index.WorkPanoramasJson.html +3 -0
- package/docs/interfaces/index.WorkTile.html +21 -0
- package/docs/interfaces/index.WorkVideo.html +9 -0
- package/docs/interfaces/index.WorksEvent.html +8 -0
- package/docs/interfaces/index.XRControllerEvent.html +8 -0
- package/docs/interfaces/index.XRGestureEvent.html +11 -0
- package/docs/interfaces/index.XRSessionEvent.html +7 -0
- package/docs/modules/index.html +1 -0
- package/docs/modules.html +1 -0
- package/docs/types/index.AjaxResponseType.html +1 -0
- package/docs/types/index.AjaxResponseTypeMapping.html +1 -0
- package/docs/types/index.AnimationFrameLoopType.html +1 -0
- package/docs/types/index.BoundingVolumeJson.html +1 -0
- package/docs/types/index.BoxBoundingVolumeJson.html +2 -0
- package/docs/types/index.ControllerCustomInitTypes.html +6 -0
- package/docs/types/index.ControllerEventTypes.html +68 -0
- package/docs/types/index.CubeFace.html +1 -0
- package/docs/types/index.EasingFunction.html +1 -0
- package/docs/types/index.EventTypes.html +28 -0
- package/docs/types/index.FivePlugin.html +4 -0
- package/docs/types/index.FivePluginInit.html +3 -0
- package/docs/types/index.FivePluginInstance.html +3 -0
- package/docs/types/index.FlowingFireworks3DPassLine.html +16 -0
- package/docs/types/index.FlowingLight2DPassLine.html +10 -0
- package/docs/types/index.FlowingLight3DPassLine.html +10 -0
- package/docs/types/index.GestureTypes.html +1 -0
- package/docs/types/index.LegacyEventType.html +282 -0
- package/docs/types/index.LoadResultType.html +12 -0
- package/docs/types/index.Mode.html +15 -0
- package/docs/types/index.Models.html +11 -0
- package/docs/types/index.MotionCircle.html +2 -0
- package/docs/types/index.MotionConfig.html +1 -0
- package/docs/types/index.MotionInitalValue.html +1 -0
- package/docs/types/index.MotionValue.html +1 -0
- package/docs/types/index.MovePanoEffect.html +12 -0
- package/docs/types/index.NetWorkMeta.html +8 -0
- package/docs/types/index.NetworkError.html +1 -0
- package/docs/types/index.NetworkErrorCallback.html +1 -0
- package/docs/types/index.NetworkProgressCallback.html +1 -0
- package/docs/types/index.NetworkResponse.html +3 -0
- package/docs/types/index.NetworkState.html +1 -0
- package/docs/types/index.NetworkSuccessCallback.html +1 -0
- package/docs/types/index.NetworkType.html +1 -0
- package/docs/types/index.OutputTextureDataType.html +1 -0
- package/docs/types/index.PBMAlphaMode.html +1 -0
- package/docs/types/index.PBMColorStyle.html +1 -0
- package/docs/types/index.PBMFloorStyle.html +1 -0
- package/docs/types/index.PBMMeshMaterial.html +1 -0
- package/docs/types/index.PBMPointBack.html +1 -0
- package/docs/types/index.PBMPointCloudShaderType.html +1 -0
- package/docs/types/index.PBMPointShape.html +1 -0
- package/docs/types/index.PBMPointSize.html +1 -0
- package/docs/types/index.PBMTransition.html +1 -0
- package/docs/types/index.Pano.html +3 -0
- package/docs/types/index.PanoId.html +1 -0
- package/docs/types/index.ParseOptions.html +13 -0
- package/docs/types/index.PostProcessingType.html +1 -0
- package/docs/types/index.RegionBoundingVolumeJson.html +2 -0
- package/docs/types/index.RequestAnimationFrameArgs.html +1 -0
- package/docs/types/index.Scissor.html +2 -0
- package/docs/types/index.SphereBoundingVolumeJson.html +2 -0
- package/docs/types/index.SubscribeEventMap.html +1 -0
- package/docs/types/index.TileCacheOptions.html +3 -0
- package/docs/types/index.TileContentData.html +6 -0
- package/docs/types/index.TileRequestOrder.html +1 -0
- package/docs/types/index.TileRequestSchedulerOptions.html +4 -0
- package/docs/types/index.TilesetFrameState.html +21 -0
- package/docs/types/index.TrajectoryContentData.html +7 -0
- package/docs/types/index.WebXRControllerKey.html +1 -0
- package/docs/types/index.WebXRControllerType.html +1 -0
- package/docs/types/index.Works.html +1 -0
- package/docs/variables/index.PROXY_CONTROLLER_EVENT_NAMES.html +1 -0
- package/docs/variables/index.controllersDefaultInitArgs.html +1 -0
- package/docs/variables/index.draco.html +1 -0
- package/five/application/analysis.d.ts +40 -0
- package/five/application/controllers.d.ts +33 -0
- package/five/application/events-legacy.d.ts +454 -0
- package/five/application/events.d.ts +69 -0
- package/five/application/five.d.ts +498 -0
- package/five/application/fiveInitArgs.d.ts +173 -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 +24 -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-pmg-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 +19 -0
- package/five/bvh/bvhPoints.d.ts +6 -0
- package/five/bvh/index.d.ts +14 -0
- package/five/bvh/type.d.ts +1 -0
- package/five/bvh/worker.d.ts +36 -0
- package/five/certificates/hardware.d.ts +1 -0
- package/five/controllers/base.d.ts +166 -0
- package/five/controllers/events.d.ts +71 -0
- package/five/controllers/floorplan.d.ts +119 -0
- package/five/controllers/mapview.d.ts +138 -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/core/camera.d.ts +65 -0
- package/five/core/internalWebGPURenderer.d.ts +13 -0
- package/five/core/panoVideo.d.ts +18 -0
- package/five/core/scene.d.ts +10 -0
- package/five/core/tiling.d.ts +56 -0
- package/five/declare.d.ts +35 -0
- package/five/gaussian-splatting/util/renderData.d.ts +66 -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 +58 -0
- package/five/index.js +1179 -0
- package/five/index.mjs +25111 -0
- package/five/meshes/boundingMesh.d.ts +12 -0
- package/five/meshes/intersectMesh.d.ts +8 -0
- package/five/meshes/panoCircleMesh.d.ts +36 -0
- package/five/meshes/panoCircleMeshCustom.d.ts +40 -0
- package/five/meshes/panoCircleMeshSolid.d.ts +35 -0
- package/five/meshes/panoSphereMesh.d.ts +29 -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 +55 -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 +10 -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.d.ts +26 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz.d.ts +11 -0
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz_2.d.ts +13 -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 +12 -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 +25 -0
- package/five/model/loaders/glTF-helpers/glTF.d.ts +713 -0
- package/five/model/loaders/glTF-helpers/index.d.ts +51 -0
- package/five/model/loaders/glTF-helpers/parser.d.ts +115 -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 +36 -0
- package/five/model/loaders/x3p.d.ts +22 -0
- package/five/model/materials/nodes/pbmMeshBasicNodeMaterial.d.ts +14 -0
- package/five/model/materials/nodes/pbmMeshPanoOnlyNodeMaterial.d.ts +14 -0
- package/five/model/materials/nodes/pbmMeshPhongNodeMaterial.d.ts +14 -0
- package/five/model/materials/nodes/pbmMeshPhysicalNodeMaterial.d.ts +14 -0
- package/five/model/materials/nodes/pbmPointCloudNodeMaterial.d.ts +22 -0
- package/five/model/materials/pbmGaussianSplattingNodeMaterial.d.ts +78 -0
- package/five/model/materials/pbmMaterial.d.ts +171 -0
- package/five/model/materials/pbmMaterialRegister.d.ts +6 -0
- package/five/model/materials/pbmMeshMaterial.d.ts +57 -0
- package/five/model/materials/pbmPointCloudMaterial.d.ts +20 -0
- package/five/model/materials/pbmPointCloudNodeMaterial.d.ts +46 -0
- package/five/model/materials/tsl/colorFilter.d.ts +9 -0
- package/five/model/materials/tsl/defines.d.ts +68 -0
- package/five/model/materials/tsl/nodeTypes.d.ts +12 -0
- package/five/model/materials/tsl/outputBuilder.d.ts +26 -0
- package/five/model/materials/tsl/panoColor.d.ts +17 -0
- package/five/model/materials/tsl/panoTransition.d.ts +8 -0
- package/five/model/materials/tsl/utils.d.ts +11 -0
- package/five/model/model-scene.d.ts +172 -0
- package/five/model/model.d.ts +203 -0
- package/five/model/objects/pbmGaussianSplattingObject.d.ts +47 -0
- package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +73 -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 +89 -0
- package/five/model/objects/pbmPointCloudObject.d.ts +81 -0
- package/five/model/parameter.d.ts +138 -0
- package/five/model/tile3d/header.d.ts +88 -0
- package/five/model/tile3d/index.d.ts +213 -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 +26 -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 +65 -0
- package/five/model/tile3d/trajectory-content.d.ts +0 -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/compute-renderers/pointcloud-compute-renderer.d.ts +154 -0
- package/five/renderer/compute-renderers/rgb565.d.ts +45 -0
- package/five/renderer/compute-renderers/shaders/clear.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/fullscreenQuad.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/rasterize.d.ts +2 -0
- package/five/renderer/five-renderer.d.ts +33 -0
- package/five/renderer/index.d.ts +3 -0
- package/five/renderer/postprocessing/composer.d.ts +45 -0
- package/five/renderer/postprocessing/index.d.ts +8 -0
- package/five/renderer/postprocessing/passes/adaptive-luminance-pass.d.ts +27 -0
- package/five/renderer/postprocessing/passes/eye-dome-lighting-pass.d.ts +31 -0
- package/five/renderer/postprocessing/passes/flowing-fireworks-3d-pass.d.ts +71 -0
- package/five/renderer/postprocessing/passes/flowing-light-2d-pass.d.ts +26 -0
- package/five/renderer/postprocessing/passes/flowing-light-3d-pass.d.ts +75 -0
- package/five/renderer/postprocessing/passes/gaussian-blur-pass.d.ts +22 -0
- package/five/renderer/postprocessing/passes/pass.d.ts +38 -0
- package/five/renderer/scene-renderers/scene-renderer.d.ts +9 -0
- package/five/renderer/tools/full-screen-quad.d.ts +17 -0
- package/five/renderer/tools/postprocess-uv.d.ts +11 -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 +2 -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 +30 -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/face3.d.ts +12 -0
- package/five/utils/formatRad.d.ts +7 -0
- package/five/utils/hdr-data.d.ts +13 -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 +37 -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/worker.d.ts +26 -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 +128 -0
- package/five/work/verify.d.ts +7 -0
- package/five/work/work.d.ts +246 -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/llms.txt +66 -0
- package/package.json +56 -0
- package/plugins/BasePlugin/index.d.ts +96 -0
- package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.d.ts +66 -0
- package/plugins/GaussianSplattingEntranceAnimationPlugin/index.d.ts +5 -0
- package/plugins/GaussianSplattingEntranceAnimationPlugin/typing.d.ts +32 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +255 -0
- package/plugins/index.mjs +539 -0
- package/plugins/utils/absoluteUrl.d.ts +5 -0
- package/react/autoCanvas.d.ts +9 -0
- package/react/canvas.d.ts +19 -0
- package/react/context.d.ts +12 -0
- package/react/createProvider.d.ts +98 -0
- package/react/createStore.d.ts +144 -0
- package/react/fiveApp.d.ts +22 -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/useFivePlugin.d.ts +22 -0
- package/react/hooks/useFiveProject2d.d.ts +21 -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 +28 -0
- package/react/index.js +255 -0
- package/react/index.mjs +896 -0
- package/react/withFive.d.ts +213 -0
- package/resource/basis/1.16/basis_transcoder.js +22 -0
- package/resource/basis/1.16/basis_transcoder.wasm +0 -0
- package/resource/basis/README.md +5 -0
- package/resource/draco/1.5.6/draco_decoder.js +34 -0
- package/resource/draco/1.5.6/draco_decoder.wasm +0 -0
- package/resource/draco/1.5.6/draco_decoder_gltf.js +33 -0
- package/resource/draco/1.5.6/draco_decoder_gltf.wasm +0 -0
- package/resource/draco/1.5.6/draco_encoder.js +35 -0
- package/resource/draco/1.5.6/draco_encoder.wasm +0 -0
- package/resource/draco/1.5.6/draco_encoder_wrapper.js +97 -0
- package/resource/draco/1.5.6/draco_wasm_wrapper.js +117 -0
- package/resource/draco/1.5.6/draco_wasm_wrapper_gltf.js +116 -0
- package/resource/draco/README.md +5 -0
- package/umd/five-plugins.js +255 -0
- package/umd/five-react.js +255 -0
- package/umd/five.js +1579 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Parameter (配置系统)
|
|
2
|
+
|
|
3
|
+
- **Summary**: Five 用于控制三维模型渲染表现的核心配置系统,采用树形继承设计。
|
|
4
|
+
- **Schema**: 是所有配置项的容器,通过继承机制管理 Material 和 3DTile 等子配置。
|
|
5
|
+
- **Concepts**: Hierarchy (树形继承), Override (覆盖), Resolution (解析)。
|
|
6
|
+
- **Examples**: 全局配置、局部覆盖、参数重置。
|
|
7
|
+
|
|
8
|
+
## Schema
|
|
9
|
+
|
|
10
|
+
> **Definition**: [Parameter](../../five/model/parameter.d.ts)
|
|
11
|
+
|
|
12
|
+
`Parameter` 类是配置的入口。它并不直接包含所有配置字段的定义,而是将它们组织在不同的接口中。
|
|
13
|
+
|
|
14
|
+
### Parameter Categories (参数分类)
|
|
15
|
+
|
|
16
|
+
为了便于理解,我们将参数分为两大类:
|
|
17
|
+
|
|
18
|
+
| Category | Description | Link |
|
|
19
|
+
| :--- | :--- | :--- |
|
|
20
|
+
| **Material & Appearance** | 控制“长什么样”。包括材质、颜色、楼层显示、阴影、点云样式等。 | [Material Params](./material.md) |
|
|
21
|
+
| **3DTile & Performance** | 控制“怎么加载”。包括 LOD (细节层级)、显存配额、网络并发、SSE 阈值等。 | [3DTile Params](./3dtile.md) |
|
|
22
|
+
|
|
23
|
+
### Parameter Class API
|
|
24
|
+
|
|
25
|
+
#### 1. Getting Values (获取值)
|
|
26
|
+
|
|
27
|
+
获取参数值**不使用** `get()` 方法,而是直接访问属性。
|
|
28
|
+
|
|
29
|
+
* **Direct Access (直接访问)**: 获取当前 `Parameter` 实例上设置的值。如果未设置,返回 `undefined`。
|
|
30
|
+
* **Resolve Value (计算最终值)**: 获取经过树形继承计算后的最终生效值。
|
|
31
|
+
* 如果不传参,则基于默认值计算 (Default -> Current)。
|
|
32
|
+
* 如果传入上游 Parameter,则基于默认值 + 上游 Parameter 计算 (Default -> Upstream -> Current)。
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// 方式 A: 直接访问 (获取当前层级配置)
|
|
36
|
+
const currentVal = parameter.maxMemoryUsage;
|
|
37
|
+
|
|
38
|
+
// 方式 B: 计算最终值 (包含继承逻辑)
|
|
39
|
+
|
|
40
|
+
// 1. 基础用法:仅继承默认值
|
|
41
|
+
const finalVal = parameter.resolveValue().maxMemoryUsage;
|
|
42
|
+
|
|
43
|
+
// 2. 进阶用法:指定继承源 (例如 ViewLayer 继承自 Model)
|
|
44
|
+
const inheritedVal = viewLayerParam.resolveValue(parentParameter).maxMemoryUsage;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### 2. Methods (方法)
|
|
48
|
+
|
|
49
|
+
`Parameter` 实例提供了以下核心方法来管理配置:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
class Parameter {
|
|
53
|
+
/**
|
|
54
|
+
* 设置配置项
|
|
55
|
+
* @param key 参数名 (如 'opacity', 'maxMemoryUsage')
|
|
56
|
+
* @param value 参数值
|
|
57
|
+
*/
|
|
58
|
+
set(key: string, value: any): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 重置配置项(移除当前层级的设置,恢复继承上游的值)
|
|
62
|
+
* @param keys 要重置的参数名列表
|
|
63
|
+
*/
|
|
64
|
+
reset(...keys: string[]): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 获取经过继承计算后的最终值
|
|
68
|
+
* @param upstream 上游 Parameter 对象列表(通常由引擎自动传入)
|
|
69
|
+
*/
|
|
70
|
+
resolveValue(...upstream: Parameter[]): ResolvedParameterValue;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Concepts
|
|
75
|
+
|
|
76
|
+
### 树形继承关系 (Hierarchy)
|
|
77
|
+
|
|
78
|
+
Parameter 遵循 **“就近原则” (Override)** 的继承逻辑。
|
|
79
|
+
|
|
80
|
+
1. **ViewLayer Parameter**: 最具体,优先级最高。通常对应一个具体的 `.gltf` 文件或数据块。
|
|
81
|
+
2. **Model Parameter**: 覆盖该 Model 下的所有 ViewLayer。一个 Model 可能包含多个 ViewLayer (如 Mesh 层和 PointCloud 层)。
|
|
82
|
+
3. **ModelScene Parameter**: 全局默认值,优先级最低。影响整个场景。
|
|
83
|
+
|
|
84
|
+
```mermaid
|
|
85
|
+
graph TD
|
|
86
|
+
Scene[ModelScene.parameter] -->|Inherit| Model[Model.parameter]
|
|
87
|
+
Model -->|Inherit| Layer1[ViewLayer.parameter]
|
|
88
|
+
Model -->|Inherit| Layer2[ViewLayer.parameter]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> **Global Configuration (全局设置)**:
|
|
92
|
+
> 若需修改所有模型的默认表现(如统一调暗亮度、统一设置显存上限),**请直接配置 `five.modelScene.parameter`**。它是继承链的根节点,其设置会向下传递给所有 Model 和 ViewLayer。
|
|
93
|
+
>
|
|
94
|
+
> **Why modelScene? (生命周期优势)**:
|
|
95
|
+
> `Model` 实例是跟随 Work 加载生命周期的(需 `five.load(work)` 后才能访问,且切换 Work 会销毁重建)。
|
|
96
|
+
> 相比之下,`ModelScene` 是常驻对象。因此,**使用 `modelScene` 进行配置更安全且持久**,既无需等待 Work 加载完成,也无需担心切换 Work 导致配置丢失。
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
### 1. 基础配置 (Basic Usage)
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// 1. 设置全局最大显存 (影响所有模型)
|
|
104
|
+
five.modelScene.parameter.set('maxMemoryUsage', 512);
|
|
105
|
+
|
|
106
|
+
// 2. 设置全局半透明
|
|
107
|
+
five.modelScene.parameter.set('opacity', 0.5);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 2. 局部覆盖 (Override)
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// 场景中大部分模型不产生阴影
|
|
114
|
+
five.modelScene.parameter.set('castShadow', false);
|
|
115
|
+
|
|
116
|
+
// 但让特定的“主角”模型产生阴影
|
|
117
|
+
const heroModel = five.models[0];
|
|
118
|
+
heroModel.parameter.set('castShadow', true);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 3. 重置配置 (Reset)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
// 假设之前设置了 opacity
|
|
125
|
+
five.modelScene.parameter.set('opacity', 0.5);
|
|
126
|
+
|
|
127
|
+
// ... 一段时间后 ...
|
|
128
|
+
|
|
129
|
+
// 移除该设置,恢复默认值 (或继承值)
|
|
130
|
+
five.modelScene.parameter.reset('opacity');
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 4. 获取配置 (Get Value)
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// 获取当前对象上的配置(如果未设置,则为 undefined)
|
|
137
|
+
const ownOpacity = five.modelScene.parameter.opacity;
|
|
138
|
+
|
|
139
|
+
// 获取最终生效的配置(计算继承链后的值)
|
|
140
|
+
const finalOpacity = five.modelScene.parameter.resolveValue().opacity;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Related
|
|
144
|
+
|
|
145
|
+
* [Material Parameters](./material.md): 材质与外观参数详情。
|
|
146
|
+
* [3DTile Parameters](./3dtile.md): 性能与加载参数详情。
|
|
147
|
+
* [Model](./model.md): Parameter 的宿主。
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
```yaml
|
|
152
|
+
tags: [parameter, config, hierarchy, api]
|
|
153
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Raycast (射线检测)
|
|
2
|
+
|
|
3
|
+
- **Summary**: Five 提供了增强版的射线检测机制,内置 BVH 加速,并扩展了 Three.js Raycaster 以支持更灵活的过滤和性能优化。
|
|
4
|
+
- **Schema**: 参见下方 `Three.js Raycaster Extensions`。
|
|
5
|
+
- **Concepts**: BVH, IntersectRaycaster, Raycaster Extensions。
|
|
6
|
+
- **Examples**: 提供基础检测与性能优化示例。
|
|
7
|
+
|
|
8
|
+
## Schema: Three.js Raycaster Extensions
|
|
9
|
+
|
|
10
|
+
> **Definition**: [Raycaster](../../five/declare.d.ts)
|
|
11
|
+
|
|
12
|
+
Five 对 Three.js 的 `Raycaster` 进行了扩展,在 `declare module 'three'` 中增加了以下属性:
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// defined in five/declare.d.ts
|
|
16
|
+
declare module 'three' {
|
|
17
|
+
export interface Raycaster {
|
|
18
|
+
/**
|
|
19
|
+
* 只捕获第一个焦点 (性能优化)
|
|
20
|
+
* - true: 找到第一个交点后立即停止检测,返回结果。
|
|
21
|
+
* - false (默认): 检测所有可能的交点。
|
|
22
|
+
*/
|
|
23
|
+
firstHitOnly?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 自定义交点过滤器
|
|
27
|
+
* - 回调函数,返回 boolean。
|
|
28
|
+
* - true: 保留该交点。
|
|
29
|
+
* - false: 丢弃该交点。
|
|
30
|
+
*/
|
|
31
|
+
hitFilter?: (intersect: THREE.Intersection) => boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 是否由近及远排序
|
|
35
|
+
* - true (默认): 返回的结果数组按距离摄像机从近到远排序。
|
|
36
|
+
* - false: 结果顺序不确定(通常按遍历顺序)。
|
|
37
|
+
*/
|
|
38
|
+
sortByDistance?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 作用楼层 (Five 特有逻辑)
|
|
42
|
+
* - 用于多楼层场景过滤。
|
|
43
|
+
*/
|
|
44
|
+
floorIndex?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface Intersection {
|
|
48
|
+
/** 命中的具体 Tile 对象 (仅 3DTiles) */
|
|
49
|
+
tile?: Tile;
|
|
50
|
+
/** 命中的 ViewLayer 对象 */
|
|
51
|
+
viewLayer?: ViewLayer;
|
|
52
|
+
/** 命中的 Model 对象 */
|
|
53
|
+
model?: Model;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Concepts
|
|
59
|
+
|
|
60
|
+
### 1. Five 内置 BVH (Bounding Volume Hierarchy)
|
|
61
|
+
Five 内置了一套高效的 BVH 实现,用于优化 `Mesh` 和 `Points` 的射线检测。
|
|
62
|
+
* **作用**: 在进行射线检测时,不直接遍历所有三角形或点,而是先与构建好的 BVH 树(包围盒层次结构)进行相交测试。只有当射线穿过包围盒时,才进一步检测内部的几何体。
|
|
63
|
+
* **优势**: 极大提升了复杂模型(如数十万面的 Mesh 或百万级 Points)的碰撞检测性能。
|
|
64
|
+
* **透明性**: 开发者通常无需手动操作 BVH,Five 在加载模型时会自动构建,并在调用 `intersectRaycaster` 时自动应用。
|
|
65
|
+
|
|
66
|
+
### 2. models.intersectRaycaster / model.intersectRaycaster vs 原生 intersectObject
|
|
67
|
+
|
|
68
|
+
Five 提供了 `model.intersectRaycaster` 方法,与 Three.js 原生的 `raycaster.intersectObject` 有显著区别:
|
|
69
|
+
|
|
70
|
+
| 特性 | `five.model.intersectRaycaster` | `raycaster.intersectObject` (Three.js 原生) |
|
|
71
|
+
| :--- | :--- | :--- |
|
|
72
|
+
| **检测范围** | 聚合检测 `five.model.shownModels` 中所有可见模型。 | 仅检测指定的单个 Object3D 及其子节点。 |
|
|
73
|
+
| **结果排序** | 自动合并所有模型的检测结果,并根据 `raycaster.sortByDistance` 排序。 | 仅对当前 Object 及其子节点的结果排序。 |
|
|
74
|
+
| **扩展支持** | **支持** `firstHitOnly`, `hitFilter`, `sortByDistance` 等扩展属性。 | 不支持 Five 的扩展属性(需手动实现)。 |
|
|
75
|
+
| **内部优化** | 自动调用模型内部的优化逻辑(如 BVH, Tile3D 的空间索引)。 | 仅进行标准的场景图遍历检测。 |
|
|
76
|
+
| **使用场景** | **推荐**。适用于全局点击、地板检测、物体拾取等业务场景。 | 仅在需要检测特定原生 Object3D 时使用。 |
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
### 基础用法:检测点击位置
|
|
81
|
+
|
|
82
|
+
最常见的场景是将鼠标点击的屏幕坐标转换为 3D 空间中的点。
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import * as THREE from 'three';
|
|
86
|
+
import { Five } from '@realsee/five';
|
|
87
|
+
|
|
88
|
+
const five = new Five();
|
|
89
|
+
// ... 初始化 ...
|
|
90
|
+
|
|
91
|
+
const raycaster = new THREE.Raycaster();
|
|
92
|
+
const vector = new THREE.Vector2();
|
|
93
|
+
|
|
94
|
+
// 假设 onTap 是点击事件处理函数
|
|
95
|
+
function onTap(event: { x: number, y: number }) {
|
|
96
|
+
// 1. 将屏幕坐标转换为归一化设备坐标 (NDC)
|
|
97
|
+
// 注意:five.getElement() 获取 canvas 容器
|
|
98
|
+
const element = five.getElement();
|
|
99
|
+
if (!element) return;
|
|
100
|
+
|
|
101
|
+
const rect = element.getBoundingClientRect();
|
|
102
|
+
vector.x = ((event.x - rect.left) / rect.width) * 2 - 1;
|
|
103
|
+
vector.y = -((event.y - rect.top) / rect.height) * 2 + 1;
|
|
104
|
+
|
|
105
|
+
// 2. 设置射线
|
|
106
|
+
raycaster.setFromCamera(vector, five.camera);
|
|
107
|
+
|
|
108
|
+
// 3. 调用 Five 的检测方法
|
|
109
|
+
const intersects = five.model.intersectRaycaster(raycaster);
|
|
110
|
+
|
|
111
|
+
if (intersects.length > 0) {
|
|
112
|
+
const firstHit = intersects[0];
|
|
113
|
+
console.log('点击到了模型:', firstHit.object);
|
|
114
|
+
console.log('交点坐标 (世界坐标):', firstHit.point);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 性能优化:只获取第一个交点
|
|
120
|
+
|
|
121
|
+
在进行如“地面检测”或“视线遮挡检测”时,通常只需要知道最近的交点。此时开启 `firstHitOnly` 可以显著提升性能。
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const raycaster = new THREE.Raycaster();
|
|
125
|
+
raycaster.setFromCamera(mouseVector, five.camera);
|
|
126
|
+
|
|
127
|
+
// 开启性能优化:找到最近的一个交点后立即停止
|
|
128
|
+
raycaster.firstHitOnly = true;
|
|
129
|
+
|
|
130
|
+
// 结果数组长度最多为 1
|
|
131
|
+
const intersects = five.model.intersectRaycaster(raycaster);
|
|
132
|
+
|
|
133
|
+
if (intersects.length > 0) {
|
|
134
|
+
// 处理最近的交点
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 高级用法:使用过滤器
|
|
139
|
+
|
|
140
|
+
如果你只想检测特定类型的物体(例如只检测地板,忽略天花板),可以使用 `hitFilter`。
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
raycaster.hitFilter = (intersect) => {
|
|
144
|
+
// 示例:假设地板的法线是向上的 (0, 1, 0)
|
|
145
|
+
// 只保留法线朝上的交点(地板)
|
|
146
|
+
if (intersect.face && intersect.face.normal.y > 0.5) {
|
|
147
|
+
return true; // 保留
|
|
148
|
+
}
|
|
149
|
+
return false; // 丢弃
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const intersects = five.model.intersectRaycaster(raycaster);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Debugging
|
|
156
|
+
|
|
157
|
+
* **验证交点**: 在开发阶段,可以在交点处添加一个临时的红色小球 `THREE.Mesh`,直观地确认检测位置是否正确。
|
|
158
|
+
* **检查模型可见性**: `intersectRaycaster` 只会检测 `visible = true` 的模型。如果检测不到,请检查模型的可见性状态。
|
|
159
|
+
* **Performance**: 如果射线检测导致掉帧,检查是否频繁调用了全场景检测。尝试使用 `firstHitOnly` 或减小检测频率(如节流)。
|
|
160
|
+
|
|
161
|
+
## Common Pitfalls
|
|
162
|
+
|
|
163
|
+
1. **混淆 API**: 错误地使用 `raycaster.intersectObject(five.scene)`。虽然这也能工作,但会失去 Five 的 BVH 优化和多模型聚合能力,导致性能下降或漏检。请始终优先使用 `five.model.intersectRaycaster(raycaster)`。
|
|
164
|
+
2. **忽略坐标系**: `raycaster.setFromCamera` 需要 NDC 坐标(-1 到 1),而不是像素坐标。务必进行正确的坐标转换。
|
|
165
|
+
3. **Tile3D 模型的特殊性**: 对于大型 Tile3D 场景,射线检测可能涉及动态加载的瓦片。Five 内部已处理这些逻辑,外部调用方式不变,但返回的 `object` 可能是某个具体的 Tile 节点。
|
|
166
|
+
|
|
167
|
+
## Related
|
|
168
|
+
|
|
169
|
+
* [parameter.md](./parameter.md): 了解模型参数配置。
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
tags: [raycast, bvh, interaction, performance]
|
|
175
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Request Proxy (请求代理)
|
|
2
|
+
|
|
3
|
+
- **Summary**: `requestProxy` 是 Five 初始化时的关键参数,用于在发起网络请求前对 URL 进行拦截和修改,常用于鉴权、资源重定向或 CDN 域名替换。
|
|
4
|
+
- **Schema**: `(url: string) => string | Promise<string>`
|
|
5
|
+
- **Concepts**: 请求拦截、资源重定向、鉴权签名。
|
|
6
|
+
- **Configuration**: `FiveInitArgs.requestProxy`。
|
|
7
|
+
- **Examples**: CDN 替换、私有化部署鉴权、调试模式。
|
|
8
|
+
|
|
9
|
+
## Schema
|
|
10
|
+
|
|
11
|
+
> **Definition**: [FiveInitArgs](../../five/application/fiveInitArgs.d.ts)
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
interface FiveInitArgs {
|
|
15
|
+
/**
|
|
16
|
+
* 请求代理函数
|
|
17
|
+
* @description 在 Five 内部发起任何网络请求(如加载图片、模型、配置)之前调用。
|
|
18
|
+
* @param url - 原始请求 URL
|
|
19
|
+
* @returns 修改后的 URL (string) 或异步返回修改后的 URL (Promise<string>)
|
|
20
|
+
*/
|
|
21
|
+
requestProxy?: (url: string) => string | Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Concepts
|
|
26
|
+
|
|
27
|
+
### 拦截时机
|
|
28
|
+
Five 内部加载资源(全景图瓦片、3D 模型、纹理贴图等)时,会通过统一的 Fetcher 层发起请求。`requestProxy` 钩子函数会在每次请求发起**前**被触发。
|
|
29
|
+
|
|
30
|
+
### 核心用途
|
|
31
|
+
1. **域名替换 (CDN Domain Sharding)**: 将资源请求分散到多个 CDN 域名以突破浏览器并发限制。
|
|
32
|
+
2. **鉴权签名 (Authentication)**: 针对私有化部署或受保护资源,在 URL 后追加鉴权 Token (如 SAS Token)。
|
|
33
|
+
3. **资源重定向 (Redirection)**: 在开发环境下将线上资源重定向到本地或测试环境。
|
|
34
|
+
4. **协议适配**: 强制将 `http` 协议升级为 `https`。
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
`requestProxy` 是 `Five` 构造函数的配置项之一。
|
|
39
|
+
|
|
40
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
41
|
+
| :--- | :--- | :--- | :--- |
|
|
42
|
+
| `requestProxy` | `(url: string) => string \| Promise<string>` | `undefined` | 代理函数,返回修改后的 URL。支持同步或异步返回。 |
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
### 1. 基础用法:CDN 域名替换
|
|
47
|
+
|
|
48
|
+
将图片资源请求分散到不同的 CDN 节点,加速加载。
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const five = new Five({
|
|
52
|
+
requestProxy: (url) => {
|
|
53
|
+
// 简单的字符串替换示例
|
|
54
|
+
return url.replace('//vrlab-public.ljcdn.com/', '//vr-public.realsee-cdn.cn/');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2. 进阶用法:异步鉴权 (Async Auth)
|
|
60
|
+
|
|
61
|
+
对于需要动态获取 Token 的场景,可以使用 `Promise` 异步返回 URL。
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const five = new Five({
|
|
65
|
+
requestProxy: async (url) => {
|
|
66
|
+
// 仅对私有桶资源进行签名
|
|
67
|
+
if (url.includes('private-bucket')) {
|
|
68
|
+
const token = await fetchToken(); // 假设 fetchToken 是一个获取鉴权的异步函数
|
|
69
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
70
|
+
return `${url}${separator}token=${token}`;
|
|
71
|
+
}
|
|
72
|
+
return url;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. 开发调试:本地资源代理
|
|
78
|
+
|
|
79
|
+
在开发阶段,将特定资源重定向到本地文件。
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const proxyMap: Record<string, string> = {};
|
|
83
|
+
|
|
84
|
+
const five = new Five({
|
|
85
|
+
requestProxy: (url) => {
|
|
86
|
+
// 如果该 URL 在映射表中存在(例如通过 <input type="file"> 加载的本地 Blob URL),则使用映射值
|
|
87
|
+
if (proxyMap[url]) {
|
|
88
|
+
console.log(`[Proxy] Redirecting ${url} -> ${proxyMap[url]}`);
|
|
89
|
+
return proxyMap[url];
|
|
90
|
+
}
|
|
91
|
+
return url;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Common Pitfalls
|
|
97
|
+
|
|
98
|
+
1. **死循环风险**: 不要在 `requestProxy` 内部再次发起会导致 `requestProxy` 触发的 Five 资源请求,否则可能导致递归调用。
|
|
99
|
+
2. **性能损耗**: `requestProxy` 会在**所有**资源请求前触发(包括成百上千个瓦片请求)。请确保该函数执行效率极高,避免进行耗时的同步操作。如果是异步操作,应做好缓存。
|
|
100
|
+
3. **URL 格式**: 确保返回的 URL 格式正确。如果原 URL 包含 Query 参数,拼接 Token 时要注意判断是使用 `?` 还是 `&`。
|
|
101
|
+
4. **缓存一致性**: 如果修改了 URL(例如加了 Token),可能会影响浏览器的缓存命中策略。
|
|
102
|
+
|
|
103
|
+
## Related
|
|
104
|
+
|
|
105
|
+
* [Parameter](./parameter.md): Five 初始化参数总览。
|
|
106
|
+
* [Load External Model](./load-external-model.md): 加载外部模型时也会触发 requestProxy。
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
tags: [configuration, network, proxy, authentication]
|
|
112
|
+
```
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Screen & Space Projection (屏幕与空间坐标转换)
|
|
2
|
+
|
|
3
|
+
- **Summary**: 详解屏幕二维坐标与三维空间坐标/射线之间的相互转换关系,以及如何在 DOM 层与 3D 场景进行联动(如显示标签)。
|
|
4
|
+
- **Schema**: `five.project2d` 接口定义。
|
|
5
|
+
- **Concepts**: World Space, Screen Space, NDC, Raycasting.
|
|
6
|
+
- **Examples**: 空间点位转屏幕坐标 (标签功能)、屏幕坐标转空间射线。
|
|
7
|
+
|
|
8
|
+
## Schema
|
|
9
|
+
|
|
10
|
+
> **Definition**: [Five](../../five/application/five.d.ts)
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// defined in Five class
|
|
14
|
+
interface Five {
|
|
15
|
+
/**
|
|
16
|
+
* 计算三维坐标对应到屏幕的二维坐标
|
|
17
|
+
* @param vector - 三维空间坐标 (World Space)
|
|
18
|
+
* @param testModel - 是否进行模型遮挡检测 (默认 false)。如果为 true,且该点被模型遮挡,则返回 null。
|
|
19
|
+
* @returns 二维屏幕坐标 (相对于 Canvas 左上角) 或 null (如果点在视野外或被遮挡)
|
|
20
|
+
*/
|
|
21
|
+
project2d(vector: THREE.Vector3, testModel?: boolean): THREE.Vector2 | null;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Concepts
|
|
26
|
+
|
|
27
|
+
### 1. 坐标系转换流程
|
|
28
|
+
|
|
29
|
+
在 Five (Three.js) 中,坐标转换通常遵循以下流程:
|
|
30
|
+
|
|
31
|
+
* **World Space (世界坐标)**: 三维场景中的绝对坐标 (x, y, z),单位通常为米。
|
|
32
|
+
* **Camera Space (相机坐标)**: 相对于相机的坐标。
|
|
33
|
+
* **NDC (Normalized Device Coordinates)**: 归一化设备坐标,x, y, z 范围均为 [-1, 1]。
|
|
34
|
+
* **Screen Space (屏幕坐标)**: 对应 Canvas 画布的像素坐标。原点 (0, 0) 在左上角,x 向右增加,y 向下增加。
|
|
35
|
+
|
|
36
|
+
### 2. 转换关系
|
|
37
|
+
|
|
38
|
+
| 方向 | 方法 | 核心逻辑 | 用途 |
|
|
39
|
+
| :--- | :--- | :--- | :--- |
|
|
40
|
+
| **3D ➔ 2D** | `five.project2d(vector)` | World ➔ NDC ➔ Screen | 标签 (Tag)、HUD、跟随 3D 物体的 UI |
|
|
41
|
+
| **2D ➔ 3D** | `Raycaster` | Screen ➔ NDC ➔ Ray | 点击拾取 (Picking)、地面检测、放置物体 |
|
|
42
|
+
|
|
43
|
+
### 3. five.project2d
|
|
44
|
+
|
|
45
|
+
`five.project2d` 是 Five 提供的便捷方法,它封装了以下逻辑:
|
|
46
|
+
1. 将世界坐标投影 (Project) 到相机的 NDC 空间。
|
|
47
|
+
2. 判断点是否在视锥体 (Frustum) 内(即是否在视野范围内)。
|
|
48
|
+
3. (可选) 发射射线检测该点与相机之间是否有模型遮挡。
|
|
49
|
+
4. 将 NDC 坐标转换为相对于 Canvas 左上角的像素坐标 (px)。
|
|
50
|
+
|
|
51
|
+
## Examples
|
|
52
|
+
|
|
53
|
+
### 1. 空间标签 (3D Point to DOM Label)
|
|
54
|
+
|
|
55
|
+
最典型的应用场景是在 3D 场景中的某个物体上方显示一个 HTML 标签。
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Five, Mode } from "@realsee/five";
|
|
59
|
+
import * as THREE from "three/webgpu";
|
|
60
|
+
|
|
61
|
+
const five = new Five();
|
|
62
|
+
// ... 初始化 five ...
|
|
63
|
+
|
|
64
|
+
// 1. 创建标签 DOM 元素
|
|
65
|
+
const label = document.createElement("div");
|
|
66
|
+
label.textContent = "Living Room";
|
|
67
|
+
label.style.position = "absolute";
|
|
68
|
+
label.style.padding = "4px 8px";
|
|
69
|
+
label.style.background = "rgba(0, 0, 0, 0.6)";
|
|
70
|
+
label.style.color = "white";
|
|
71
|
+
label.style.borderRadius = "4px";
|
|
72
|
+
label.style.pointerEvents = "none"; // 避免阻挡鼠标事件
|
|
73
|
+
label.style.transform = "translate(-50%, -100%)"; // 居中并显示在点上方
|
|
74
|
+
label.style.display = "none"; // 默认隐藏
|
|
75
|
+
document.body.appendChild(label); // 添加到 container (注意 container 的定位 context)
|
|
76
|
+
|
|
77
|
+
// 2. 定义目标空间坐标 (例如客厅中心)
|
|
78
|
+
const targetPosition = new THREE.Vector3(1.5, 2.0, -3.0);
|
|
79
|
+
|
|
80
|
+
// 3. 在每一帧渲染时更新标签位置
|
|
81
|
+
five.on("render.prepare", () => {
|
|
82
|
+
// 计算屏幕坐标
|
|
83
|
+
// 参数2: false 表示不检测遮挡 (性能更好);true 表示如果被墙挡住则隐藏
|
|
84
|
+
const screenPos = five.project2d(targetPosition, true);
|
|
85
|
+
|
|
86
|
+
if (screenPos === null) {
|
|
87
|
+
// 如果返回 null,说明点在相机背面,或者被遮挡(如果开启了 testModel)
|
|
88
|
+
label.style.display = "none";
|
|
89
|
+
} else {
|
|
90
|
+
label.style.display = "block";
|
|
91
|
+
// 更新 DOM 位置
|
|
92
|
+
// 注意:screenPos 是相对于 Canvas 的坐标。
|
|
93
|
+
// 如果 Canvas 占满全屏,直接使用即可。
|
|
94
|
+
// 如果 Canvas 有偏移,需加上 Canvas 的 offset。
|
|
95
|
+
label.style.left = `${screenPos.x}px`;
|
|
96
|
+
label.style.top = `${screenPos.y}px`;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 2. 屏幕点击转射线 (Screen to Ray)
|
|
102
|
+
|
|
103
|
+
将鼠标点击的屏幕坐标转换为 3D 射线,用于检测物体。
|
|
104
|
+
|
|
105
|
+
> **注意**: 更多射线检测细节请参考 [Raycast](./raycast.md)。
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import * as THREE from "three/webgpu";
|
|
109
|
+
|
|
110
|
+
// 假设 container 是 five 的容器元素
|
|
111
|
+
const container = five.getElement()!.parentElement!;
|
|
112
|
+
|
|
113
|
+
container.addEventListener("click", (event) => {
|
|
114
|
+
const raycaster = new THREE.Raycaster();
|
|
115
|
+
const mouse = new THREE.Vector2();
|
|
116
|
+
|
|
117
|
+
// 1. 计算 NDC 坐标 (x, y 范围 [-1, 1])
|
|
118
|
+
// event.clientX/Y 是相对于视口的坐标
|
|
119
|
+
// getBoundingClientRect 用于获取容器的位置
|
|
120
|
+
const rect = container.getBoundingClientRect();
|
|
121
|
+
|
|
122
|
+
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
123
|
+
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; // 注意 Y 轴翻转
|
|
124
|
+
|
|
125
|
+
// 2. 从相机发射射线
|
|
126
|
+
raycaster.setFromCamera(mouse, five.camera);
|
|
127
|
+
|
|
128
|
+
// 3. 进行相交检测
|
|
129
|
+
const intersects = five.model.intersectRaycaster(raycaster);
|
|
130
|
+
|
|
131
|
+
if (intersects.length > 0) {
|
|
132
|
+
console.log("Hit point:", intersects[0].point);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Common Pitfalls
|
|
138
|
+
|
|
139
|
+
1. **坐标系原点**:
|
|
140
|
+
* DOM/CSS 坐标系原点在左上角,Y 轴向下。
|
|
141
|
+
* NDC/WebGL 坐标系原点在中心,Y 轴向上。
|
|
142
|
+
* `project2d` 返回的是 **DOM 风格** 的坐标 (左上角原点),可以直接赋给 CSS `left`/`top`。
|
|
143
|
+
* 但在进行 Raycaster 转换时,需要手动将 DOM 坐标转换为 NDC (Y 轴翻转)。
|
|
144
|
+
|
|
145
|
+
2. **性能开销**:
|
|
146
|
+
* `project2d(pos, true)` 开启 `testModel` 会进行射线检测,性能开销较大。如果在 `render.prepare` 中对大量点进行检测,可能会导致掉帧。
|
|
147
|
+
* 建议:对于大量标签,默认使用 `false`;或者仅对可视范围内的关键标签进行遮挡检测;或者限制检测频率(如每 10 帧检测一次)。
|
|
148
|
+
|
|
149
|
+
3. **Canvas 尺寸**:
|
|
150
|
+
* `project2d` 内部使用 `five.renderer.getSize()` 和 `five.viewport` 计算。确保 Canvas 尺寸与 DOM 显示尺寸一致 (通常 Five 会自动处理,但如果使用了 CSS 缩放需注意)。
|
|
151
|
+
|
|
152
|
+
4. **Null 返回值**:
|
|
153
|
+
* 务必检查 `project2d` 的返回值是否为 `null`。点在相机背面、超出视锥体裁剪范围、或被遮挡(开启 testModel 时)都会返回 `null`。
|
|
154
|
+
|
|
155
|
+
## Related
|
|
156
|
+
|
|
157
|
+
* [Raycast](./raycast.md): 详细的射线检测文档。
|
|
158
|
+
* [Five](./five.md): Five 核心类说明。
|
|
159
|
+
* [State](./state.md): 了解相机位姿 (Pose)。
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
tags: [coordinate, screen, project, label, ui]
|
|
165
|
+
```
|