@realsee/five-webgpu 1.0.0-alpha.13 → 1.0.0-alpha.15
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/_virtual/_rolldown/runtime.js +3 -3
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
- package/docs/classes/index.BoundingMesh.html +1 -1
- package/docs/classes/index.Camera.html +1 -1
- package/docs/classes/index.EyeDomeLightingPass.html +1 -1
- package/docs/classes/index.Five.html +65 -64
- package/docs/classes/index.FivePass.html +1 -1
- package/docs/classes/index.FiveRenderer.html +4 -4
- package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
- package/docs/classes/index.FlowingLight2DPass.html +1 -1
- package/docs/classes/index.FlowingLight3DPass.html +1 -1
- package/docs/classes/index.GaussianBlurPass.html +1 -1
- package/docs/classes/index.InternalWebGPURenderer.html +4 -4
- package/docs/classes/index.Model.html +1 -1
- package/docs/classes/index.ModelScene.html +1 -1
- package/docs/classes/index.NetworkSubscribe.html +1 -1
- package/docs/classes/index.PBMCustomNode.html +1 -1
- package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +1 -1
- package/docs/classes/index.PBMGaussianSplattingObject.html +1 -1
- package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +1 -1
- package/docs/classes/index.PBMGroup.html +1 -1
- package/docs/classes/index.PBMMesh.html +1 -1
- package/docs/classes/index.PBMMeshBasicMaterial.html +1 -1
- package/docs/classes/index.PBMMeshBasicNodeMaterial.html +1 -1
- package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +1 -1
- package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +1 -1
- package/docs/classes/index.PBMMeshPhongMaterial.html +1 -1
- package/docs/classes/index.PBMMeshPhongNodeMaterial.html +1 -1
- package/docs/classes/index.PBMMeshPhysicalMaterial.html +1 -1
- package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +1 -1
- package/docs/classes/index.PBMPanoFilter.html +1 -1
- package/docs/classes/index.PBMPointCloud.html +1 -1
- package/docs/classes/index.PBMPointCloudMaterial.html +1 -1
- package/docs/classes/index.PBMSkinnedMesh.html +1 -1
- package/docs/classes/index.PBMUpdateable.html +1 -1
- package/docs/classes/index.PanoCircleMesh.html +9 -5
- package/docs/classes/index.PanoCircleMeshCustom.html +9 -5
- package/docs/classes/index.PanoCircleMeshSolid.html +9 -5
- package/docs/classes/index.Parameter.html +1 -1
- package/docs/classes/index.Scene.html +1 -1
- package/docs/classes/index.Subscribe.html +1 -1
- package/docs/classes/index.Tile3D.html +1 -1
- package/docs/classes/index.TileNode.html +1 -1
- package/docs/classes/index.TrajectoryNode.html +1 -1
- package/docs/classes/index.Work.html +15 -22
- package/docs/classes/index.WorkResolvedObserver.html +22 -22
- package/docs/functions/index.createWorks.html +1 -1
- package/docs/functions/index.parseWork.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/index.AddableObject.html +1 -1
- package/docs/interfaces/index.AjaxOptions.html +1 -1
- package/docs/interfaces/index.BaseEvent.html +1 -1
- package/docs/interfaces/index.Clock.html +1 -1
- package/docs/interfaces/index.EventCallback.html +3 -3
- package/docs/interfaces/index.GestureEvent.html +1 -1
- package/docs/interfaces/index.IPBMMaterial.html +1 -1
- package/docs/interfaces/index.ImageOptions.html +1 -1
- package/docs/interfaces/index.IntersectEvent.html +1 -1
- package/docs/interfaces/index.IntersectMesh.html +1 -1
- package/docs/interfaces/index.IntersectMeshInterface.html +1 -1
- package/docs/interfaces/index.Intersection.html +1 -1
- package/docs/interfaces/index.LooseWorkObserver.html +2 -2
- package/docs/interfaces/index.LooseWorkPanorama.html +2 -2
- package/docs/interfaces/index.LooseWorkWithExtrinsics.html +8 -8
- package/docs/interfaces/index.ModeChangeEvent.html +1 -1
- package/docs/interfaces/index.ModelControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ModelEvent.html +1 -1
- package/docs/interfaces/index.ModelSceneEvent.html +1 -1
- package/docs/interfaces/index.ModelTileEvent.html +1 -1
- package/docs/interfaces/index.MovePanoOptions.html +1 -1
- package/docs/interfaces/index.NetworkAbortError.html +1 -1
- package/docs/interfaces/index.NetworkFirbiddenError.html +1 -1
- package/docs/interfaces/index.NetworkOptions.html +1 -1
- package/docs/interfaces/index.NetworkProxyError.html +1 -1
- package/docs/interfaces/index.NetworkResourceEvent.html +1 -1
- package/docs/interfaces/index.NetworkResponseError.html +1 -1
- package/docs/interfaces/index.NetworkTimeoutError.html +1 -1
- package/docs/interfaces/index.ObjectEvent.html +1 -1
- package/docs/interfaces/index.PanoCircleMeshInterface.html +8 -4
- package/docs/interfaces/index.PanoCircleMeshOptions.html +2 -2
- package/docs/interfaces/index.PanoCircleMeshSolidOptions.html +2 -2
- package/docs/interfaces/index.PanoEvent.html +1 -1
- package/docs/interfaces/index.PanoPrepareEvent.html +1 -1
- package/docs/interfaces/index.PanoTextureEvent.html +1 -1
- package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ParameterMaterialValue.html +1 -1
- package/docs/interfaces/index.ParameterTilesetValue.html +1 -1
- package/docs/interfaces/index.ParameterValue.html +1 -1
- package/docs/interfaces/index.Pose.html +1 -1
- package/docs/interfaces/index.RenderEvent.html +1 -1
- package/docs/interfaces/index.ResolvedParameterValue.html +1 -1
- package/docs/interfaces/index.State.html +1 -1
- package/docs/interfaces/index.StateEvent.html +1 -1
- package/docs/interfaces/index.TextureOptions.html +1 -1
- package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ViewLayer.html +1 -1
- package/docs/interfaces/index.WorkCubeHdrGainmapImage.html +2 -2
- package/docs/interfaces/index.WorkCubeImage.html +2 -2
- package/docs/interfaces/index.WorkImage.html +5 -5
- package/docs/interfaces/index.WorkInitial.html +8 -8
- package/docs/interfaces/index.WorkInitialJson.html +2 -2
- package/docs/interfaces/index.WorkJson.html +2 -4
- package/docs/interfaces/index.WorkModel.html +8 -8
- package/docs/interfaces/index.WorkModelJson.html +2 -2
- package/docs/interfaces/index.WorkModelLayer.html +6 -6
- package/docs/interfaces/index.WorkModelLayerJson.html +2 -2
- package/docs/interfaces/index.WorkObserver.html +23 -23
- package/docs/interfaces/index.WorkObserverJson.html +2 -2
- package/docs/interfaces/index.WorkPanoramaJson.html +2 -2
- package/docs/interfaces/index.WorkPanoramasJson.html +2 -2
- package/docs/interfaces/index.WorkTile.html +5 -5
- package/docs/interfaces/index.WorkVideo.html +4 -4
- package/docs/interfaces/index.WorksEvent.html +1 -1
- package/docs/interfaces/index.XRControllerEvent.html +1 -1
- package/docs/interfaces/index.XRGestureEvent.html +2 -2
- package/docs/interfaces/index.XRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.XRSessionEvent.html +1 -1
- package/docs/modules/index.html +1 -1
- package/docs/types/index.LegacyEventType.html +3 -3
- package/docs/types/index.OutputTextureDataType.html +1 -1
- package/docs/types/index.ParseOptions.html +8 -8
- package/docs/types/index.PointCloudTransparencyMode.html +2 -0
- package/docs/types/index.Works.html +1 -1
- package/docs/variables/index.loadAt3d.html +2 -0
- package/docs/variables/index.loadDome.html +2 -0
- package/docs/variables/index.loadDomez.html +2 -0
- package/docs/variables/index.loadGltf.html +2 -0
- package/docs/variables/index.loadPbm.html +2 -0
- package/docs/variables/index.loadPly.html +2 -0
- package/five/application/five.d.ts +3 -2
- package/five/chunks/at3d.js +338 -0
- package/five/chunks/at3d.mjs +338 -0
- package/five/chunks/dome.js +338 -0
- package/five/chunks/dome.mjs +338 -0
- package/five/chunks/domez.js +338 -0
- package/five/chunks/domez.mjs +338 -0
- package/five/chunks/fbx.js +338 -0
- package/five/chunks/fbx.mjs +338 -0
- package/five/chunks/fflate.js +338 -0
- package/five/chunks/fflate.mjs +338 -0
- package/five/chunks/glTF-helpers.js +804 -0
- package/five/chunks/glTF-helpers.mjs +804 -0
- package/five/chunks/gltf.js +338 -0
- package/five/chunks/gltf.mjs +338 -0
- package/five/chunks/imageBitmap.js +338 -0
- package/five/chunks/imageBitmap.mjs +338 -0
- package/five/chunks/imageSupport.js +338 -0
- package/five/chunks/imageSupport.mjs +338 -0
- package/five/chunks/lzma.js +383 -0
- package/five/chunks/lzma.mjs +383 -0
- package/five/chunks/memoryUsage.js +339 -0
- package/five/chunks/memoryUsage.mjs +339 -0
- package/five/chunks/minimal.js +338 -0
- package/five/chunks/minimal.mjs +338 -0
- package/five/chunks/pbm.js +338 -0
- package/five/chunks/pbm.mjs +338 -0
- package/five/chunks/pbmGaussianSplattingObject.js +338 -0
- package/five/chunks/pbmGaussianSplattingObject.mjs +338 -0
- package/five/chunks/pbmMeshMaterial.js +338 -0
- package/five/chunks/pbmMeshMaterial.mjs +338 -0
- package/five/chunks/pick.js +338 -0
- package/five/chunks/pick.mjs +338 -0
- package/five/chunks/ply.js +339 -0
- package/five/chunks/ply.mjs +339 -0
- package/five/chunks/spz.js +364 -0
- package/five/chunks/spz.mjs +364 -0
- package/five/controllers/panorama.d.ts +6 -0
- package/five/core/webglBlendEquationFix.d.ts +41 -0
- package/five/index.d.ts +0 -1
- package/five/index.js +49 -626
- package/five/index.mjs +229 -32052
- package/five/meshes/panoCircleMesh.d.ts +1 -0
- package/five/meshes/panoCircleMeshCustom.d.ts +1 -0
- package/five/meshes/panoCircleMeshSolid.d.ts +1 -0
- package/five/meshes/panoSphereMesh.d.ts +1 -0
- package/five/model/index.d.ts +18 -6
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz.d.ts +1 -1
- package/five/model/loaders/glTF-helpers/extensions/KHR_gaussian_splatting_compression_spz_2.d.ts +1 -1
- package/five/model/loaders/spz.d.ts +1 -2
- package/five/model/loaders/spz.worker.d.ts +37 -0
- package/five/renderer/five-renderer.d.ts +1 -1
- package/five/renderer/index.d.ts +1 -1
- package/five/renderer/postprocessing/passes/pass.js +3 -3
- package/five/renderer/postprocessing/passes/pass.mjs +3 -3
- package/five/renderer/tools/full-screen-quad.js +3 -3
- package/five/renderer/tools/full-screen-quad.mjs +3 -3
- package/five/texture/initTexture.d.ts +8 -0
- package/five/texture/videoTextureBridge.d.ts +124 -15
- package/five/thirdparty/sha256.d.ts +149 -0
- package/five/types/panoCircleMeshInterface.d.ts +6 -0
- package/five/utils/calculateThreeMouse.js +3 -3
- package/five/utils/calculateThreeMouse.mjs +3 -3
- package/five/utils/distance.js +3 -3
- package/five/utils/distance.mjs +3 -3
- package/five/utils/isNil.js +3 -3
- package/five/utils/isNil.mjs +3 -3
- package/five/utils/memoryUsage.d.ts +1 -1
- package/five/utils/uuid.js +3 -3
- package/five/utils/uuid.mjs +3 -3
- package/five/work/looseWorkType.d.ts +2 -2
- package/five/work/work.d.ts +1 -8
- package/five/work/workJsonType.d.ts +2 -4
- package/gltf-loader/index.js +3 -3
- package/gltf-loader/index.mjs +3 -50
- package/line/index.js +3 -3
- package/line/index.mjs +3 -88
- package/package.json +1 -1
- package/plugins/BackgroundPlugin/Controller.js +4 -4
- package/plugins/BackgroundPlugin/Controller.mjs +4 -4
- package/plugins/BackgroundPlugin/index.js +3 -3
- package/plugins/BackgroundPlugin/index.mjs +3 -3
- package/plugins/BasePlugin/index.js +3 -3
- package/plugins/BasePlugin/index.mjs +3 -3
- package/plugins/CSS2DPlugin/Controller.js +3 -3
- package/plugins/CSS2DPlugin/Controller.mjs +3 -3
- package/plugins/CSS2DPlugin/index.js +3 -3
- package/plugins/CSS2DPlugin/index.mjs +3 -3
- package/plugins/CSS2DPlugin/style.css_raw.js +4 -4
- package/plugins/CSS2DPlugin/style.css_raw.mjs +4 -4
- package/plugins/CSS3DPlugin/Controller.js +3 -3
- package/plugins/CSS3DPlugin/Controller.mjs +3 -3
- package/plugins/CSS3DPlugin/index.js +3 -3
- package/plugins/CSS3DPlugin/index.mjs +3 -3
- package/plugins/CSS3DPlugin/style.css_raw.js +4 -4
- package/plugins/CSS3DPlugin/style.css_raw.mjs +4 -4
- package/plugins/FloorplanPlugin/Controller.js +3 -3
- package/plugins/FloorplanPlugin/Controller.mjs +3 -3
- package/plugins/FloorplanPlugin/index.js +3 -3
- package/plugins/FloorplanPlugin/index.mjs +3 -3
- package/plugins/FloorplanPlugin/render/assets.js +3 -3
- package/plugins/FloorplanPlugin/render/assets.mjs +3 -3
- package/plugins/FloorplanPlugin/render/index.js +3 -3
- package/plugins/FloorplanPlugin/render/index.mjs +3 -3
- package/plugins/FloorplanPlugin/render/isPointInPolygon.js +3 -3
- package/plugins/FloorplanPlugin/render/isPointInPolygon.mjs +3 -3
- package/plugins/FloorplanPlugin/render/renderFloor.js +3 -3
- package/plugins/FloorplanPlugin/render/renderFloor.mjs +3 -3
- package/plugins/FloorplanPlugin/render/roomLabelVisibility.js +3 -3
- package/plugins/FloorplanPlugin/render/roomLabelVisibility.mjs +3 -3
- package/plugins/FloorplanPlugin/render/style.css_raw.js +4 -4
- package/plugins/FloorplanPlugin/render/style.css_raw.mjs +4 -4
- package/plugins/FloorplanPlugin/utils/changeMode.js +3 -3
- package/plugins/FloorplanPlugin/utils/changeMode.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/changeModelCanvasOpacity.js +3 -3
- package/plugins/FloorplanPlugin/utils/changeModelCanvasOpacity.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/correctFiveState.js +3 -3
- package/plugins/FloorplanPlugin/utils/correctFiveState.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/equal.js +3 -3
- package/plugins/FloorplanPlugin/utils/equal.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/filter.js +3 -3
- package/plugins/FloorplanPlugin/utils/filter.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/fiveModelLoad.js +3 -3
- package/plugins/FloorplanPlugin/utils/fiveModelLoad.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/formatData.js +3 -3
- package/plugins/FloorplanPlugin/utils/formatData.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/formatFloorplanJson.js +3 -3
- package/plugins/FloorplanPlugin/utils/formatFloorplanJson.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/formatPosition.js +3 -3
- package/plugins/FloorplanPlugin/utils/formatPosition.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/getDistanceFromModel.js +3 -3
- package/plugins/FloorplanPlugin/utils/getDistanceFromModel.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/getPxmm.js +3 -3
- package/plugins/FloorplanPlugin/utils/getPxmm.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/isTruelyObject.js +3 -3
- package/plugins/FloorplanPlugin/utils/isTruelyObject.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/nearlyEqual.js +3 -3
- package/plugins/FloorplanPlugin/utils/nearlyEqual.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/polylabel.js +3 -3
- package/plugins/FloorplanPlugin/utils/polylabel.mjs +3 -3
- package/plugins/FloorplanPlugin/utils/to.js +3 -3
- package/plugins/FloorplanPlugin/utils/to.mjs +3 -3
- package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.js +3 -3
- package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.mjs +3 -3
- package/plugins/GaussianSplattingEntranceAnimationPlugin/index.js +3 -3
- package/plugins/GaussianSplattingEntranceAnimationPlugin/index.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Controller.js +3 -3
- package/plugins/Object3DHelperPlugin/Controller.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/BaseController.js +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/BaseController.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/BoundingBoxController.js +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/BoundingBoxController.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/MoveController.js +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/MoveController.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/RotateController.js +3 -3
- package/plugins/Object3DHelperPlugin/Controllers/RotateController.mjs +3 -3
- package/plugins/Object3DHelperPlugin/FiveControllerWrapper.js +3 -3
- package/plugins/Object3DHelperPlugin/FiveControllerWrapper.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Helper/BaseHelper.js +3 -3
- package/plugins/Object3DHelperPlugin/Helper/BaseHelper.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Helper/BoundingBoxHelper.js +3 -3
- package/plugins/Object3DHelperPlugin/Helper/BoundingBoxHelper.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Helper/MoveHelper.js +3 -3
- package/plugins/Object3DHelperPlugin/Helper/MoveHelper.mjs +3 -3
- package/plugins/Object3DHelperPlugin/Helper/RotateHelper.js +3 -3
- package/plugins/Object3DHelperPlugin/Helper/RotateHelper.mjs +3 -3
- package/plugins/Object3DHelperPlugin/constant.js +3 -3
- package/plugins/Object3DHelperPlugin/constant.mjs +3 -3
- package/plugins/Object3DHelperPlugin/index.js +3 -3
- package/plugins/Object3DHelperPlugin/index.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/ArrowGroup.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/ArrowGroup.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/CenterHandle.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/CenterHandle.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/PlaneHandle.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/PlaneHandle.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/calculateScaleByCamera.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/calculateScaleByCamera.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/cameraHooks.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/cameraHooks.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/direction.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/direction.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/getMouseRaycaster.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/getMouseRaycaster.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/getOrthographicCameraDirection.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/getOrthographicCameraDirection.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/setObjectQuaternion.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/setObjectQuaternion.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/solidGuide.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/solidGuide.mjs +3 -3
- package/plugins/Object3DHelperPlugin/utils/tipsDom.js +3 -3
- package/plugins/Object3DHelperPlugin/utils/tipsDom.mjs +3 -3
- package/plugins/PanoAnimePlugin/Controller.js +3 -3
- package/plugins/PanoAnimePlugin/Controller.mjs +3 -3
- package/plugins/PanoAnimePlugin/index.js +3 -3
- package/plugins/PanoAnimePlugin/index.mjs +3 -3
- package/plugins/WordPassPlugin/Controller.js +3 -3
- package/plugins/WordPassPlugin/Controller.mjs +3 -3
- package/plugins/WordPassPlugin/hersheyFont.js +3 -3
- package/plugins/WordPassPlugin/hersheyFont.mjs +3 -3
- package/plugins/WordPassPlugin/index.js +3 -3
- package/plugins/WordPassPlugin/index.mjs +3 -3
- package/plugins/WordPassPlugin/textToStrokeOrderStrokes.js +4 -4
- package/plugins/WordPassPlugin/textToStrokeOrderStrokes.mjs +4 -4
- package/plugins/WordPassPlugin/word-pass.js +3 -3
- package/plugins/WordPassPlugin/word-pass.mjs +3 -3
- package/plugins/index.js +3 -3
- package/plugins/index.mjs +3 -3
- package/plugins/thirdParty/CSS2DRenderer.js +3 -3
- package/plugins/thirdParty/CSS2DRenderer.mjs +3 -3
- package/plugins/thirdParty/CSS3DRenderer.js +3 -3
- package/plugins/thirdParty/CSS3DRenderer.mjs +3 -3
- package/plugins/thirdParty/doctorstrange-model.js +75 -75
- package/plugins/thirdParty/doctorstrange-model.mjs +75 -75
- package/plugins/thirdParty/domevents.js +3 -3
- package/plugins/thirdParty/domevents.mjs +3 -3
- package/plugins/utils/absoluteUrl.js +3 -3
- package/plugins/utils/absoluteUrl.mjs +3 -3
- package/plugins/utils/calculatePath.js +3 -3
- package/plugins/utils/calculatePath.mjs +3 -3
- package/plugins/utils/clamp.js +3 -3
- package/plugins/utils/clamp.mjs +3 -3
- package/plugins/utils/uuid.js +3 -3
- package/plugins/utils/uuid.mjs +3 -3
- package/react/hooks/useFiveModelReadyState.d.ts +1 -1
- package/react/index.js +3 -3
- package/react/index.mjs +3 -644
- package/sticker/index.js +13 -4
- package/sticker/index.mjs +43 -260
- package/umd/five-gltf-loader.js +3 -3
- package/umd/five-line.js +3 -3
- package/umd/five-plugins.js +4 -4
- package/umd/five-react.js +2 -2
- package/umd/five-sticker.js +13 -4
- package/umd/five-vfx.js +2 -2
- package/umd/five.js +152 -190
- package/vfx/index.js +3 -3
- package/vfx/index.mjs +3 -486
- package/work-downloader/index.js +3 -3
- package/work-downloader/index.mjs +3 -315
- package/docs/functions/index.loadAt3d.html +0 -1
- package/docs/functions/index.loadDome.html +0 -1
- package/docs/functions/index.loadDomez.html +0 -1
- package/docs/functions/index.loadGltf.html +0 -1
- package/docs/functions/index.loadPbm.html +0 -1
- package/docs/functions/index.loadPly.html +0 -10
- package/five/certificates/hardware.d.ts +0 -1
- package/five/thirdparty/jsrsasign.d.ts +0 -753
- package/five/work/_ALLOW_HOST.d.ts +0 -2
- package/five/work/keychain.d.ts +0 -5
- package/five/work/verify.d.ts +0 -7
- package/five/work/workVerify.d.ts +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,5 +335,5 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/import{loadHersheyFont
|
|
339
|
-
`){
|
|
338
|
+
*/import{loadHersheyFont}from"./hersheyFont.mjs";import{__awaiter}from"tslib";import*as THREE from"three/webgpu";var HANZI_EM=1024,DEFAULT_CDN=`https://cdn.jsdelivr.net/npm/hanzi-writer-data@latest`;function calculatePath3DLength(points){let length=0;for(let i=1;i<points.length;i++)length+=points[i].distanceTo(points[i-1]);return length}var cache=new Map;function loadHanzi(char,loader,cdnBaseUrl){return __awaiter(this,void 0,void 0,function*(){var _a;if(cache.has(char))return cache.get(char);let data=null;try{if(loader)data=(_a=yield loader(char))==null?null:_a;else if(typeof fetch<`u`){let res=yield fetch(`${cdnBaseUrl}/${encodeURIComponent(char)}.json`);res.ok&&(data=yield res.json())}}catch(_b){data=null}return cache.set(char,data),data})}function textToStrokeOrderStrokes(text_1){return __awaiter(this,arguments,void 0,function*(text,options={}){var _a;let{size=1,letterSpacing=0,lineSpacing=1.4,normal,up:upOption,center=!0,position,smooth=!0,smoothSubdivisions=4,cdnBaseUrl=DEFAULT_CDN,charDataLoader,latinScale=.72}=options,hershey=loadHersheyFont(),raw=[],cursorX=0,cursorY=0;for(let ch of Array.from(text)){if(ch===`
|
|
339
|
+
`){cursorX=0,cursorY-=lineSpacing;continue}if(ch===` `){cursorX+=.4+letterSpacing;continue}let code=(_a=ch.codePointAt(0))==null?0:_a;if(code>=33&&code<=126){let hg=hershey==null?void 0:hershey.get(code);if(hg){for(let pl of hg.polylines)pl.length<2||raw.push({pts:pl.map(([x,y])=>new THREE.Vector2(cursorX+x*latinScale,cursorY+y*latinScale)),mode:`corner`});cursorX+=hg.advance*latinScale+letterSpacing;continue}console.warn(`textToStrokeOrderStrokes: 无法生成字符 "${ch}"(非浏览器环境或字形为空),按空格处理`),cursorX+=.5*latinScale+letterSpacing;continue}let data=yield loadHanzi(ch,charDataLoader,cdnBaseUrl);if(data&&data.medians&&data.medians.length){for(let median of data.medians)median.length<2||raw.push({pts:median.map(([x,y])=>new THREE.Vector2(cursorX+x/HANZI_EM,cursorY+y/HANZI_EM)),mode:`full`});cursorX+=1+letterSpacing}else console.warn(`textToStrokeOrderStrokes: 未找到 "${ch}" 的笔画数据,按空格处理`),cursorX+=1+letterSpacing}if(raw.length===0)return[];let minX=1/0,minY=1/0,maxX=-1/0,maxY=-1/0;for(let poly of raw)for(let p of poly.pts)p.x<minX&&(minX=p.x),p.x>maxX&&(maxX=p.x),p.y<minY&&(minY=p.y),p.y>maxY&&(maxY=p.y);let cx=center?(minX+maxX)/2:0,cy=center?(minY+maxY)/2:0,origin=position==null?new THREE.Vector3:position,N=(normal==null?new THREE.Vector3(0,0,1):normal).clone();N.lengthSq()<1e-9&&N.set(0,0,1),N.normalize();let up;if(upOption){let projected=upOption.clone().addScaledVector(N,-upOption.dot(N));projected.lengthSq()>1e-9&&(up=projected.normalize())}let right;if(up)right=new THREE.Vector3().crossVectors(up,N).normalize();else{let ref=Math.abs(N.y)>.99?new THREE.Vector3(0,0,-1):new THREE.Vector3(0,1,0);right=new THREE.Vector3().crossVectors(ref,N).normalize(),up=new THREE.Vector3().crossVectors(N,right).normalize()}let toVec3=p=>new THREE.Vector3().copy(origin).addScaledVector(right,(p.x-cx)*size).addScaledVector(up,(p.y-cy)*size);return raw.map(poly=>{let points=poly.pts.map(toVec3);return smooth&&points.length>=2&&(points=poly.mode===`corner`?smoothPreserveCorners(points,smoothSubdivisions):smoothFull(points,smoothSubdivisions)),{points,totalLength:calculatePath3DLength(points)}})})}function smoothFull(points,subdiv){return points.length<3?points:new THREE.CatmullRomCurve3(points,!1,`centripetal`).getPoints(Math.max(points.length*subdiv,8))}var CORNER_COS=.2;function smoothPreserveCorners(points,subdiv){if(points.length<3)return points;let box=new THREE.Box3().setFromPoints(points),diag=box.min.distanceTo(box.max),closed=diag>1e-9&&points[0].distanceTo(points[points.length-1])<diag*.06,pts=closed?points.slice(0,-1):points,n=pts.length;if(n<3)return points;let a=new THREE.Vector3,b=new THREE.Vector3,isCorner=i=>{if(!closed&&(i===0||i===n-1))return!0;let prev=(i-1+n)%n,next=(i+1)%n;a.subVectors(pts[i],pts[prev]),b.subVectors(pts[next],pts[i]);let la=a.length(),lb=b.length();return la<1e-6||lb<1e-6?!1:a.dot(b)/(la*lb)<CORNER_COS},corners=[];for(let i=0;i<n;i++)isCorner(i)&&corners.push(i);if(corners.length===0)return new THREE.CatmullRomCurve3(pts,closed,`centripetal`).getPoints(Math.max(n*subdiv,8));let collectCyclic=(start,end)=>{let seg=[],i=start;for(;seg.push(pts[i]),i!==end;)i=(i+1)%n;return seg},m=corners.length,runCount=closed?m:m-1,out=[];for(let c=0;c<runCount;c++){let seg=collectCyclic(corners[c],corners[(c+1)%m]),smoothed=seg.length>=3?new THREE.CatmullRomCurve3(seg,!1,`centripetal`).getPoints(Math.max((seg.length-1)*subdiv,2)):seg;for(let k=0;k<smoothed.length;k++)c>0&&k===0||out.push(smoothed[k])}return out}export{textToStrokeOrderStrokes};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/const e=require("../../_virtual/_rolldown/runtime.js"),t=require("../../five/renderer/tools/full-screen-quad.js"),n=require("../../five/renderer/postprocessing/passes/pass.js"),r=require("../../five/utils/uuid.js");let i=require("tslib"),a=require("three/webgpu");a=e.__toESM(a,1);let o=require("three/tsl");var s=16767392,c=3,l=class extends n.FivePass{constructor(e,n=a.UnsignedByteType){super(),this.uTime=0,this.words=[],this.lineMesh=null,this.lineMaterial=null,this.points=null,this.particleMaterial=null,this.particleGeometry=null,this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null,this._tmpTip=new a.Vector3,this.uTimeLine=(0,o.uniform)(0),this.uResolutionLine=(0,o.uniform)(new a.Vector2(1,1)),this.uProjLine=(0,o.uniform)(new a.Matrix4),this.uViewLine=(0,o.uniform)(new a.Matrix4),this.uPixelRatioLine=(0,o.uniform)(1),this.uMaxDisplayBoost=(0,o.uniform)(1),this.uTimeParticle=(0,o.uniform)(0),this.uResolutionParticle=(0,o.uniform)(new a.Vector2(1,1)),this.uProjParticle=(0,o.uniform)(new a.Matrix4),this.uViewParticle=(0,o.uniform)(new a.Matrix4),this.uBase=(0,o.texture)(new a.Texture),this.uEffect=(0,o.texture)(new a.Texture),this.camera=e,this.effectScene=new a.Scene,this.orthoCamera=new a.OrthographicCamera(-1,1,1,-1,0,1),this.effectRenderTarget=new a.RenderTarget(Math.max(1,this.camera.resolution.x),Math.max(1,this.camera.resolution.y),{type:n,minFilter:a.LinearFilter,magFilter:a.LinearFilter,format:a.RGBAFormat}),this.blendMaterial=this.createBlendMaterial(),this.blendQuad=new t.FullScreenQuad(this.blendMaterial)}setWords(e){return this.words=e.map(e=>{var t;return this._resolveWord(e,this.uTime+((t=e.startTime)==null?0:t)/1e3)}),this._rebuild(),this.words.map(e=>e.id)}addWord(...e){let t=e.map(e=>{var t;return this._resolveWord(e,this.uTime+((t=e.startTime)==null?0:t)/1e3)});return this.words.push(...t),this._rebuild(),t.map(e=>e.id)}hasWord(e){return this.words.some(t=>t.id===e)}removeWord(...e){let t=0;for(let n of e){let e=this.words.findIndex(e=>e.id===n);if(e===-1){console.warn(`WordPass: word "${n}" not found`);continue}this.words.splice(e,1),t++}return t>0&&this._rebuild(),t}setWord(e){var t;let{id:n}=e,r=(0,i.__rest)(e,[`id`]),a=this.words.findIndex(e=>e.id===n);if(a===-1){console.warn(`WordPass: word "${n}" not found`);return}let o=this.words[a],s=Object.assign(Object.assign(Object.assign({},o.source),r),{id:n}),c=r.startTime===void 0?o.wordStart:this.uTime+((t=r.startTime)==null?0:t)/1e3;this.words[a]=this._resolveWord(s,c),this._rebuild()}clearWords(){this.words=[],this._rebuild()}setMaxDisplayBoost(e){this.uMaxDisplayBoost.value=Math.max(e,1)}_resolveWord(e,t){let{color:n=new a.Color(s),opacity:i=1,lineWidth:o=3,hdrIntensity:c=1,writeSpeed:l=4,minStrokeDuration:u=200,strokeGap:d=120,holdDuration:f=1500,fadeDuration:p=1200,loop:m=!0,restartPause:h=800,persist:g=!1,fireworks:_=!0,fireworksColor:v,particleCount:y=400,emissionRate:b=500,sparkSpeed:x=.6,particleSize:S=.012,particleLife:C=.8,gravity:w}=e,T=e.strokes.filter(e=>e.points.length>=2),E=[],D=0,O=d/1e3;for(let e of T){let t=Math.max(e.totalLength/Math.max(l,1e-4),u/1e3);E.push({points:e.points,strokeLength:e.totalLength,writeStart:D,writeDuration:t}),D+=t+O}let k=D>0?D-O:0,A=g?1e9:k+f/1e3,j=g?1:p/1e3,M=g?0:m?A+j+h/1e3:0;return{id:e.id||r.uuid(),source:Object.assign(Object.assign({},e),{id:e.id}),blocks:E,color:n.clone(),opacity:i,lineWidth:o,hdrIntensity:Math.max(c,1),wordStart:t,fadeStart:A,fadeDuration:j,cycleLength:M,fireworks:_,sparkColor:v?v.clone():n.clone().lerp(new a.Color(16777215),.4),emissionRate:b,sparkSpeed:x,particleSize:S,particleLife:C,gravity:w?w.clone():new a.Vector3(0,-.6,0),particleCount:_?Math.max(1,Math.floor(y)):0,particleOffset:0,particleCursor:0,emitAccum:E.map(()=>0)}}_rebuild(){this._buildLineMesh(),this._buildParticles()}createLineMaterial(){let e=(0,o.varyingProperty)(`vec4`,`wpColor`),t=(0,o.varyingProperty)(`float`,`wpSegLen`),n=(0,o.varyingProperty)(`float`,`wpAccum`),r=(0,o.varyingProperty)(`float`,`wpStrokeLen`),i=(0,o.varyingProperty)(`float`,`wpDrawnLen`),s=(0,o.varyingProperty)(`float`,`wpFade`),l=(0,o.varyingProperty)(`vec2`,`wpStart`),u=(0,o.varyingProperty)(`vec2`,`wpEnd`),d=(0,o.varyingProperty)(`float`,`wpLineWidth`),f=(0,o.varyingProperty)(`float`,`wpHdrBoost`),p=(0,o.varyingProperty)(`vec2`,`wpNdc`),m=.001,h=(e,t)=>(0,o.attribute)(e,t),g=(0,o.Fn)(()=>{let a=h(`instanceStart`,`vec3`),g=h(`instanceEnd`,`vec3`),_=h(`instanceColor`,`vec4`),v=h(`instanceData`,`vec4`),y=h(`instanceReveal`,`vec2`),b=h(`instanceTime`,`vec4`),x=o.positionGeometry,S=v.x,C=v.y.mul(this.uPixelRatioLine),w=v.z,T=y.x,E=y.y,D=b.x,O=b.y,k=b.z,A=b.w;e.assign(_);let j=(0,o.length)(g.sub(a));t.assign(j),n.assign(S),r.assign(w),d.assign(C);let M=this.uTimeLine.sub(D),N=(0,o.select)(A.greaterThan(0),(0,o.mod)((0,o.max)(M,0),A),M),P=(0,o.clamp)(N.sub(T).div((0,o.max)(E,1e-4)),0,1).mul(w).toVar(),F=(0,o.float)(1).toVar();(0,o.If)(N.greaterThanEqual(O),()=>{F.assign((0,o.float)(1).sub((0,o.clamp)(N.sub(O).div((0,o.max)(k,1e-4)),0,1)))}),(0,o.If)(M.lessThan(0),()=>{F.assign(0),P.assign(0)}),s.assign(F),i.assign(P);let I=v.w,ee=(0,o.max)((0,o.log2)((0,o.max)(I,1.0001)),1e-4),te=(0,o.clamp)((0,o.log2)((0,o.max)(this.uMaxDisplayBoost,1)).div(ee),0,1);f.assign((0,o.mix)(1,I,te));let L=this.uProjLine.mul(this.uViewLine).mul((0,o.vec4)(a,1)).toVar(),R=this.uProjLine.mul(this.uViewLine).mul((0,o.vec4)(g,1)).toVar(),z=(0,o.float)(0).toVar(),B=L.w.lessThan(m).toVar(),V=R.w.lessThan(m).toVar();(0,o.If)(B.and(V),()=>{z.assign(1)}),(0,o.If)(B,()=>{let e=(0,o.float)(m).sub(L.w).div(R.w.sub(L.w));L.assign((0,o.mix)(L,R,e))}),(0,o.If)(V,()=>{let e=(0,o.float)(m).sub(R.w).div(L.w.sub(R.w));R.assign((0,o.mix)(R,L,e))});let H=L.xy.div(L.w),U=R.xy.div(R.w);l.assign(H),u.assign(U);let W=H.add(1).mul(.5).mul(this.uResolutionLine),G=U.add(1).mul(.5).mul(this.uResolutionLine),K=G.sub(W),q=(0,o.length)(K),J=(0,o.select)(q.greaterThan(1e-5),K.div((0,o.max)(q,1e-5)),(0,o.vec2)(1,0)),ne=(0,o.vec2)(J.y.negate(),J.x),Y=x.y.add(.5),X=(0,o.max)(C.mul(.5),.5).add(c),re=W.sub(J.mul(X)),ie=G.add(J.mul(X)),ae=ne.mul(x.x).mul(2).mul(X),Z=(0,o.mix)(re,ie,Y).add(ae).div(this.uResolutionLine).mul(2).sub(1);p.assign(Z);let Q=(0,o.mix)(L,R,Y),$=(0,o.max)(Q.w,m);return(0,o.mix)((0,o.vec4)(Z.mul($),Q.z,$),(0,o.vec4)(0,0,-2,1),z)}),_=(0,o.Fn)(([e,t,n])=>{let r=e.sub(t),i=n.sub(t),a=(0,o.clamp)((0,o.dot)(r,i).div((0,o.dot)(i,i)),0,1);return(0,o.length)(r.sub(i.mul(a)))}),v=(0,o.Fn)(()=>{let a=p,m=u.sub(l),h=(0,o.max)((0,o.length)(m),1e-6),g=m.div(h),v=(0,o.clamp)((0,o.dot)(a.sub(l),g),0,h).div(h),y=n.add(v.mul(t)),b=i.lessThanEqual(1e-4).or(y.greaterThan(i)),x=(0,o.vec2)(this.uResolutionLine.x.div(this.uResolutionLine.y),1),S=_(a.mul(x),l.mul(x),u.mul(x)).mul(this.uResolutionLine.y).mul(.5),C=(0,o.max)(d.mul(.5),.5),w=(0,o.float)(1).sub((0,o.smoothstep)(C.sub(1),C.add(1),S)),T=C.add(c),E=(0,o.clamp)((0,o.max)(S.sub(C),0).div((0,o.max)(T.sub(C),1e-4)),0,1),D=(0,o.pow)((0,o.float)(1).sub(E),4).mul(.9),O=(0,o.clamp)(w.add(D.mul((0,o.float)(1).sub(w))),0,1),k=(0,o.exp)((0,o.max)(i.sub(y),0).mul(-5).div((0,o.max)(r,1e-4))),A=(0,o.float)(1).sub((0,o.smoothstep)(r.mul(.98),r,i)),j=(0,o.float)(1).add(k.mul(.6).mul(A)),M=O.mul(e.a).mul(s),N=(0,o.select)(b.not().and(M.greaterThanEqual(.004)),M,0);return(0,o.vec4)(e.rgb.mul(j).mul(f).mul(N),N)}),y=new a.NodeMaterial;return y.vertexNode=g(),y.fragmentNode=v(),y.transparent=!0,y.depthTest=!1,y.depthWrite=!1,y.side=a.DoubleSide,y.blending=a.CustomBlending,y.blendEquation=a.MaxEquation,y.blendSrc=a.OneFactor,y.blendDst=a.OneFactor,y}_buildLineMesh(){this._disposeLineMesh();let e=0;for(let t of this.words)for(let n of t.blocks)e+=n.points.length-1;if(e===0)return;let t=new a.PlaneGeometry(1,1,1,1),n=new a.InstancedBufferGeometry;n.index=t.index,n.attributes=t.attributes,n.instanceCount=e;let r=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*4),s=new Float32Array(e*4),c=new Float32Array(e*2),l=new Float32Array(e*4),u=0;for(let e of this.words)for(let t of e.blocks){let n=0;for(let a=0;a<t.points.length-1;a++){let d=t.points[a],f=t.points[a+1],p=d.distanceTo(f),m=u*2,h=u*3,g=u*4;r[h+0]=d.x,r[h+1]=d.y,r[h+2]=d.z,i[h+0]=f.x,i[h+1]=f.y,i[h+2]=f.z,o[g+0]=e.color.r,o[g+1]=e.color.g,o[g+2]=e.color.b,o[g+3]=e.opacity,s[g+0]=n,s[g+1]=e.lineWidth,s[g+2]=t.strokeLength,s[g+3]=e.hdrIntensity,c[m+0]=t.writeStart,c[m+1]=t.writeDuration,l[g+0]=e.wordStart,l[g+1]=e.fadeStart,l[g+2]=e.fadeDuration,l[g+3]=e.cycleLength,n+=p,u++}}n.setAttribute(`instanceStart`,new a.InstancedBufferAttribute(r,3)),n.setAttribute(`instanceEnd`,new a.InstancedBufferAttribute(i,3)),n.setAttribute(`instanceColor`,new a.InstancedBufferAttribute(o,4)),n.setAttribute(`instanceData`,new a.InstancedBufferAttribute(s,4)),n.setAttribute(`instanceReveal`,new a.InstancedBufferAttribute(c,2)),n.setAttribute(`instanceTime`,new a.InstancedBufferAttribute(l,4)),this.lineMaterial=this.createLineMaterial(),this.lineMesh=new a.Mesh(n,this.lineMaterial),this.lineMesh.frustumCulled=!1,this.effectScene.add(this.lineMesh)}createParticleMaterial(){let e=(0,o.varyingProperty)(`vec4`,`wpSparkColor`),t=(0,o.varyingProperty)(`float`,`wpSparkAlpha`),n=(0,o.varyingProperty)(`vec2`,`wpSparkLocal`),r=.001,i=(e,t)=>(0,o.attribute)(e,t),s=(0,o.Fn)(()=>{let a=i(`aPosition`,`vec3`),s=i(`aVelocity`,`vec3`),c=i(`aAccel`,`vec3`),l=i(`aColor`,`vec4`),u=i(`aParams`,`vec4`),d=u.x,f=u.y,p=u.z,m=u.w,h=o.positionGeometry.xy;e.assign(l),n.assign(h);let g=this.uTimeParticle.sub(d),_=(0,o.float)(0).toVar();(0,o.If)(f.lessThanEqual(0).or(g.lessThan(0)).or(g.greaterThan(f)),()=>{_.assign(1)});let v=g.div((0,o.max)(f,r)),y=a.add(s.mul(g)).add(c.mul(.5).mul(g).mul(g)),b=this.uProjParticle.mul(this.uViewParticle).mul((0,o.vec4)(y,1)).toVar();(0,o.If)(b.w.lessThanEqual(r),()=>{_.assign(1)});let x=(0,o.max)(b.w,r),S=b.xy.div(x),C=this.uProjParticle.element(1).y,w=(0,o.float)(1).sub(v.mul(.7)),T=(0,o.max)(m.mul(C).mul(.5).mul(this.uResolutionParticle.y).div(x).mul(w),0),E=S.add(1).mul(.5).mul(this.uResolutionParticle).add(h.mul(T)).div(this.uResolutionParticle).mul(2).sub(1),D=(0,o.float)(.7).add((0,o.float)(.3).mul((0,o.sin)(this.uTimeParticle.mul(30).add(p.mul(6.2831)))));return t.assign((0,o.pow)((0,o.float)(1).sub(v),.8).mul(D)),(0,o.mix)((0,o.vec4)(E.mul(x),b.z,x),(0,o.vec4)(0,0,-2,1),_)}),c=(0,o.Fn)(()=>{let r=(0,o.smoothstep)(.5,0,(0,o.length)(n)),i=r.mul(r).mul(t).mul(e.a);return(0,o.vec4)(e.rgb,i)}),l=new a.NodeMaterial;return l.vertexNode=s(),l.fragmentNode=c(),l.transparent=!0,l.depthTest=!1,l.depthWrite=!1,l.blending=a.AdditiveBlending,l}createBlendMaterial(){let e=new a.NodeMaterial,t=this.uBase.sample((0,o.uv)()),n=this.uEffect.sample((0,o.uv)());return e.fragmentNode=(0,o.vec4)(t.rgb.add(n.rgb),t.a),e.transparent=!1,e.depthTest=!1,e.depthWrite=!1,e}_buildParticles(){this._disposeParticles();let e=0;for(let t of this.words)t.particleOffset=e,t.particleCursor=0,e+=t.particleCount;if(e===0)return;this.arrPosition=new Float32Array(e*3),this.arrVelocity=new Float32Array(e*3),this.arrAccel=new Float32Array(e*3),this.arrColor=new Float32Array(e*4),this.arrParams=new Float32Array(e*4);let t=new a.PlaneGeometry(1,1,1,1),n=new a.InstancedBufferGeometry;n.index=t.index,n.attributes=t.attributes,n.instanceCount=e,n.setAttribute(`aPosition`,new a.InstancedBufferAttribute(this.arrPosition,3)),n.setAttribute(`aVelocity`,new a.InstancedBufferAttribute(this.arrVelocity,3)),n.setAttribute(`aAccel`,new a.InstancedBufferAttribute(this.arrAccel,3)),n.setAttribute(`aColor`,new a.InstancedBufferAttribute(this.arrColor,4)),n.setAttribute(`aParams`,new a.InstancedBufferAttribute(this.arrParams,4)),this.particleGeometry=n,this.particleMaterial=this.createParticleMaterial(),this.points=new a.Mesh(n,this.particleMaterial),this.points.frustumCulled=!1,this.effectScene.add(this.points)}_samplePointAtLength(e,t,n){if(e.length===1||t<=0){n.copy(e[0]);return}let r=0;for(let i=0;i<e.length-1;i++){let a=e[i],o=e[i+1],s=a.distanceTo(o);if(!(s<=1e-9)){if(r+s>=t){n.lerpVectors(a,o,(t-r)/s);return}r+=s}}n.copy(e[e.length-1])}_emitParticle(e,t){if(!this.arrPosition)return;let n=e.particleOffset+e.particleCursor;e.particleCursor=(e.particleCursor+1)%e.particleCount;let r=n*3,i=n*4,a=Math.random()*Math.PI*2,o=Math.random(),s=Math.cos(a)*o,c=Math.sin(a)*o,l=.3+Math.random()*.7,u=e.sparkSpeed*(.4+Math.random()*.8);this.arrPosition[r+0]=t.x,this.arrPosition[r+1]=t.y,this.arrPosition[r+2]=t.z,this.arrVelocity[r+0]=s*u,this.arrVelocity[r+1]=l*u,this.arrVelocity[r+2]=c*u,this.arrAccel[r+0]=e.gravity.x,this.arrAccel[r+1]=e.gravity.y,this.arrAccel[r+2]=e.gravity.z;let d=.8+Math.random()*.5;this.arrColor[i+0]=e.sparkColor.r*d,this.arrColor[i+1]=e.sparkColor.g*d,this.arrColor[i+2]=e.sparkColor.b*d,this.arrColor[i+3]=1,this.arrParams[i+0]=this.uTime,this.arrParams[i+1]=e.particleLife*(.6+Math.random()*.8),this.arrParams[i+2]=Math.random(),this.arrParams[i+3]=e.particleSize*(.6+Math.random()*.9)}_emit(e){if(!this.particleGeometry)return;let t=!1;for(let n of this.words){if(!n.fireworks||n.particleCount===0)continue;let r=this.uTime-n.wordStart;if(r<0)continue;let i=n.cycleLength>0?r%n.cycleLength:r;for(let r=0;r<n.blocks.length;r++){let a=n.blocks[r],o=i-a.writeStart;if(o<0||o>a.writeDuration)continue;let s=o/a.writeDuration;this._samplePointAtLength(a.points,s*a.strokeLength,this._tmpTip),n.emitAccum[r]+=n.emissionRate*e;let c=Math.floor(n.emitAccum[r]);n.emitAccum[r]-=c,c=Math.min(c,n.particleCount);for(let e=0;e<c;e++)this._emitParticle(n,this._tmpTip),t=!0}}if(t){let e=this.particleGeometry;e.getAttribute(`aPosition`).needsUpdate=!0,e.getAttribute(`aVelocity`).needsUpdate=!0,e.getAttribute(`aAccel`).needsUpdate=!0,e.getAttribute(`aColor`).needsUpdate=!0,e.getAttribute(`aParams`).needsUpdate=!0}}render(e,t,n,r,i){let a=!!(this.lineMesh||this.points);a&&(this.uTime+=r==null?0:r,this._emit(r==null?0:r));let o=n.width,s=n.height;(this.effectRenderTarget.width!==o||this.effectRenderTarget.height!==s)&&this.effectRenderTarget.setSize(o,s);let c=e.getRenderTarget();if(e.setRenderTarget(this.effectRenderTarget),e.setClearColor(0,0),e.clear(),a){let t=this.camera.projectionMatrix,n=this.camera.matrixWorldInverse;this.lineMaterial&&(this.uTimeLine.value=this.uTime,this.uResolutionLine.value.set(o,s),this.uProjLine.value=t,this.uViewLine.value=n,this.uPixelRatioLine.value=this.camera.pixelRatio),this.particleMaterial&&(this.uTimeParticle.value=this.uTime,this.uResolutionParticle.value.set(o,s),this.uProjParticle.value=t,this.uViewParticle.value=n),e.render(this.effectScene,this.orthoCamera)}e.setRenderTarget(c),this.uBase.value=n.texture,this.uEffect.value=this.effectRenderTarget.texture,e.setRenderTarget(this.renderToScreen?null:t),this.blendQuad.render(e)}_disposeLineMesh(){this.lineMesh&&(this.effectScene.remove(this.lineMesh),this.lineMesh.geometry.dispose(),this.lineMesh=null),this.lineMaterial&&(this.lineMaterial.dispose(),this.lineMaterial=null)}_disposeParticles(){this.points&&(this.effectScene.remove(this.points),this.points=null),this.particleGeometry&&(this.particleGeometry.dispose(),this.particleGeometry=null),this.particleMaterial&&(this.particleMaterial.dispose(),this.particleMaterial=null),this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null}dispose(){this._disposeLineMesh(),this._disposeParticles(),this.effectRenderTarget.dispose(),this.blendMaterial.dispose(),this.blendQuad.dispose()}};exports.WordPass=l;
|
|
338
|
+
*/const require_runtime=require("../../_virtual/_rolldown/runtime.js"),require_full_screen_quad=require("../../five/renderer/tools/full-screen-quad.js"),require_pass=require("../../five/renderer/postprocessing/passes/pass.js"),require_uuid=require("../../five/utils/uuid.js");let tslib=require("tslib"),three_webgpu=require("three/webgpu");three_webgpu=require_runtime.__toESM(three_webgpu,1);let three_tsl=require("three/tsl");var DEFAULT_COLOR=16767392,MAX_FRAME_DELTA_TIME=.1,GLOW_RADIUS_EXTRA=3,WordPass=class extends require_pass.FivePass{constructor(camera,outputType=three_webgpu.UnsignedByteType){super(),this.uTime=0,this.words=[],this.lineMesh=null,this.lineMaterial=null,this.points=null,this.particleMaterial=null,this.particleGeometry=null,this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null,this._tmpTip=new three_webgpu.Vector3,this.uTimeLine=(0,three_tsl.uniform)(0),this.uResolutionLine=(0,three_tsl.uniform)(new three_webgpu.Vector2(1,1)),this.uProjLine=(0,three_tsl.uniform)(new three_webgpu.Matrix4),this.uViewLine=(0,three_tsl.uniform)(new three_webgpu.Matrix4),this.uPixelRatioLine=(0,three_tsl.uniform)(1),this.uMaxDisplayBoost=(0,three_tsl.uniform)(1),this.uTimeParticle=(0,three_tsl.uniform)(0),this.uResolutionParticle=(0,three_tsl.uniform)(new three_webgpu.Vector2(1,1)),this.uProjParticle=(0,three_tsl.uniform)(new three_webgpu.Matrix4),this.uViewParticle=(0,three_tsl.uniform)(new three_webgpu.Matrix4),this.uBase=(0,three_tsl.texture)(new three_webgpu.Texture),this.uEffect=(0,three_tsl.texture)(new three_webgpu.Texture),this.camera=camera,this.effectScene=new three_webgpu.Scene,this.orthoCamera=new three_webgpu.OrthographicCamera(-1,1,1,-1,0,1),this.effectRenderTarget=new three_webgpu.RenderTarget(Math.max(1,this.camera.resolution.x),Math.max(1,this.camera.resolution.y),{type:outputType,minFilter:three_webgpu.LinearFilter,magFilter:three_webgpu.LinearFilter,format:three_webgpu.RGBAFormat}),this.blendMaterial=this.createBlendMaterial(),this.blendQuad=new require_full_screen_quad.FullScreenQuad(this.blendMaterial)}setWords(words){return this.words=words.map(w=>{var _a;return this._resolveWord(w,this.uTime+((_a=w.startTime)==null?0:_a)/1e3)}),this._rebuild(),this.words.map(w=>w.id)}addWord(...words){let added=words.map(w=>{var _a;return this._resolveWord(w,this.uTime+((_a=w.startTime)==null?0:_a)/1e3)});return this.words.push(...added),this._rebuild(),added.map(w=>w.id)}hasWord(id){return this.words.some(w=>w.id===id)}removeWord(...ids){let removed=0;for(let id of ids){let i=this.words.findIndex(w=>w.id===id);if(i===-1){console.warn(`WordPass: word "${id}" not found`);continue}this.words.splice(i,1),removed++}return removed>0&&this._rebuild(),removed}setWord(params){var _a;let{id}=params,updates=(0,tslib.__rest)(params,[`id`]),idx=this.words.findIndex(w=>w.id===id);if(idx===-1){console.warn(`WordPass: word "${id}" not found`);return}let prev=this.words[idx],merged=Object.assign(Object.assign(Object.assign({},prev.source),updates),{id}),wordStart=updates.startTime===void 0?prev.wordStart:this.uTime+((_a=updates.startTime)==null?0:_a)/1e3;this.words[idx]=this._resolveWord(merged,wordStart),this._rebuild()}clearWords(){this.words=[],this._rebuild()}setMaxDisplayBoost(value){this.uMaxDisplayBoost.value=Math.max(value,1)}_resolveWord(w,wordStart){let{color=new three_webgpu.Color(DEFAULT_COLOR),opacity=1,lineWidth=3,hdrIntensity=1,writeSpeed=4,minStrokeDuration=200,strokeGap=120,holdDuration=1500,fadeDuration=1200,loop=!0,restartPause=800,persist=!1,fireworks=!0,fireworksColor,particleCount=400,emissionRate=500,sparkSpeed=.6,particleSize=.012,particleLife=.8,gravity}=w,valid=w.strokes.filter(s=>s.points.length>=2),blocks=[],cursorTime=0,gap=strokeGap/1e3;for(let s of valid){let dur=Math.max(s.totalLength/Math.max(writeSpeed,1e-4),minStrokeDuration/1e3);blocks.push({points:s.points,strokeLength:s.totalLength,writeStart:cursorTime,writeDuration:dur}),cursorTime+=dur+gap}let totalWriteTime=cursorTime>0?cursorTime-gap:0,fadeStart=persist?1e9:totalWriteTime+holdDuration/1e3,fadeDur=persist?1:fadeDuration/1e3,cycleLength=persist?0:loop?fadeStart+fadeDur+restartPause/1e3:0;return{id:w.id||require_uuid.uuid(),source:Object.assign(Object.assign({},w),{id:w.id}),blocks,color:color.clone(),opacity,lineWidth,hdrIntensity:Math.max(hdrIntensity,1),wordStart,fadeStart,fadeDuration:fadeDur,cycleLength,fireworks,sparkColor:fireworksColor?fireworksColor.clone():color.clone().lerp(new three_webgpu.Color(16777215),.4),emissionRate,sparkSpeed,particleSize,particleLife,gravity:gravity?gravity.clone():new three_webgpu.Vector3(0,-.6,0),particleCount:fireworks?Math.max(1,Math.floor(particleCount)):0,particleOffset:0,particleCursor:0,emitAccum:blocks.map(()=>0)}}_rebuild(){this._buildLineMesh(),this._buildParticles()}createLineMaterial(){let vColor=(0,three_tsl.varyingProperty)(`vec4`,`wpColor`),vSegLen=(0,three_tsl.varyingProperty)(`float`,`wpSegLen`),vAccum=(0,three_tsl.varyingProperty)(`float`,`wpAccum`),vStrokeLen=(0,three_tsl.varyingProperty)(`float`,`wpStrokeLen`),vDrawnLen=(0,three_tsl.varyingProperty)(`float`,`wpDrawnLen`),vFade=(0,three_tsl.varyingProperty)(`float`,`wpFade`),vStart=(0,three_tsl.varyingProperty)(`vec2`,`wpStart`),vEnd=(0,three_tsl.varyingProperty)(`vec2`,`wpEnd`),vLineWidth=(0,three_tsl.varyingProperty)(`float`,`wpLineWidth`),vHdrBoost=(0,three_tsl.varyingProperty)(`float`,`wpHdrBoost`),vNdc=(0,three_tsl.varyingProperty)(`vec2`,`wpNdc`),nearEps=.001,attr=(name,type)=>(0,three_tsl.attribute)(name,type),vertex=(0,three_tsl.Fn)(()=>{let instanceStart=attr(`instanceStart`,`vec3`),instanceEnd=attr(`instanceEnd`,`vec3`),instanceColor=attr(`instanceColor`,`vec4`),instanceData=attr(`instanceData`,`vec4`),instanceReveal=attr(`instanceReveal`,`vec2`),instanceTime=attr(`instanceTime`,`vec4`),pos=three_tsl.positionGeometry,accum=instanceData.x,lineWidth=instanceData.y.mul(this.uPixelRatioLine),strokeLen=instanceData.z,writeStart=instanceReveal.x,writeDur=instanceReveal.y,wordStart=instanceTime.x,fadeStart=instanceTime.y,fadeDur=instanceTime.z,cycle=instanceTime.w;vColor.assign(instanceColor);let segLen=(0,three_tsl.length)(instanceEnd.sub(instanceStart));vSegLen.assign(segLen),vAccum.assign(accum),vStrokeLen.assign(strokeLen),vLineWidth.assign(lineWidth);let elapsed=this.uTimeLine.sub(wordStart),local=(0,three_tsl.select)(cycle.greaterThan(0),(0,three_tsl.mod)((0,three_tsl.max)(elapsed,0),cycle),elapsed),drawnLen=(0,three_tsl.clamp)(local.sub(writeStart).div((0,three_tsl.max)(writeDur,1e-4)),0,1).mul(strokeLen).toVar(),fade=(0,three_tsl.float)(1).toVar();(0,three_tsl.If)(local.greaterThanEqual(fadeStart),()=>{fade.assign((0,three_tsl.float)(1).sub((0,three_tsl.clamp)(local.sub(fadeStart).div((0,three_tsl.max)(fadeDur,1e-4)),0,1)))}),(0,three_tsl.If)(elapsed.lessThan(0),()=>{fade.assign(0),drawnLen.assign(0)}),vFade.assign(fade),vDrawnLen.assign(drawnLen);let hdrIntensity=instanceData.w,logContentMax=(0,three_tsl.max)((0,three_tsl.log2)((0,three_tsl.max)(hdrIntensity,1.0001)),1e-4),hdrWeight=(0,three_tsl.clamp)((0,three_tsl.log2)((0,three_tsl.max)(this.uMaxDisplayBoost,1)).div(logContentMax),0,1);vHdrBoost.assign((0,three_tsl.mix)(1,hdrIntensity,hdrWeight));let clipStart=this.uProjLine.mul(this.uViewLine).mul((0,three_tsl.vec4)(instanceStart,1)).toVar(),clipEnd=this.uProjLine.mul(this.uViewLine).mul((0,three_tsl.vec4)(instanceEnd,1)).toVar(),invisible=(0,three_tsl.float)(0).toVar(),startBehind=clipStart.w.lessThan(nearEps).toVar(),endBehind=clipEnd.w.lessThan(nearEps).toVar();(0,three_tsl.If)(startBehind.and(endBehind),()=>{invisible.assign(1)}),(0,three_tsl.If)(startBehind,()=>{let tc=(0,three_tsl.float)(nearEps).sub(clipStart.w).div(clipEnd.w.sub(clipStart.w));clipStart.assign((0,three_tsl.mix)(clipStart,clipEnd,tc))}),(0,three_tsl.If)(endBehind,()=>{let tc=(0,three_tsl.float)(nearEps).sub(clipEnd.w).div(clipStart.w.sub(clipEnd.w));clipEnd.assign((0,three_tsl.mix)(clipEnd,clipStart,tc))});let ndcStart=clipStart.xy.div(clipStart.w),ndcEnd=clipEnd.xy.div(clipEnd.w);vStart.assign(ndcStart),vEnd.assign(ndcEnd);let screenStart=ndcStart.add(1).mul(.5).mul(this.uResolutionLine),screenEnd=ndcEnd.add(1).mul(.5).mul(this.uResolutionLine),seg=screenEnd.sub(screenStart),segLenPix=(0,three_tsl.length)(seg),dir=(0,three_tsl.select)(segLenPix.greaterThan(1e-5),seg.div((0,three_tsl.max)(segLenPix,1e-5)),(0,three_tsl.vec2)(1,0)),normal=(0,three_tsl.vec2)(dir.y.negate(),dir.x),tt=pos.y.add(.5),coverRadius=(0,three_tsl.max)(lineWidth.mul(.5),.5).add(GLOW_RADIUS_EXTRA),extStart=screenStart.sub(dir.mul(coverRadius)),extEnd=screenEnd.add(dir.mul(coverRadius)),offset=normal.mul(pos.x).mul(2).mul(coverRadius),ndc=(0,three_tsl.mix)(extStart,extEnd,tt).add(offset).div(this.uResolutionLine).mul(2).sub(1);vNdc.assign(ndc);let clipPos=(0,three_tsl.mix)(clipStart,clipEnd,tt),safeW=(0,three_tsl.max)(clipPos.w,nearEps);return(0,three_tsl.mix)((0,three_tsl.vec4)(ndc.mul(safeW),clipPos.z,safeW),(0,three_tsl.vec4)(0,0,-2,1),invisible)}),sdCapsule=(0,three_tsl.Fn)(([p,a,b])=>{let pa=p.sub(a),ba=b.sub(a),h=(0,three_tsl.clamp)((0,three_tsl.dot)(pa,ba).div((0,three_tsl.dot)(ba,ba)),0,1);return(0,three_tsl.length)(pa.sub(ba.mul(h)))}),fragment=(0,three_tsl.Fn)(()=>{let uvNdc=vNdc,screenDiff=vEnd.sub(vStart),screenDist=(0,three_tsl.max)((0,three_tsl.length)(screenDiff),1e-6),screenDir=screenDiff.div(screenDist),projRatio=(0,three_tsl.clamp)((0,three_tsl.dot)(uvNdc.sub(vStart),screenDir),0,screenDist).div(screenDist),posAlong=vAccum.add(projRatio.mul(vSegLen)),notDrawn=vDrawnLen.lessThanEqual(1e-4).or(posAlong.greaterThan(vDrawnLen)),aspect=(0,three_tsl.vec2)(this.uResolutionLine.x.div(this.uResolutionLine.y),1),dPix=sdCapsule(uvNdc.mul(aspect),vStart.mul(aspect),vEnd.mul(aspect)).mul(this.uResolutionLine.y).mul(.5),halfW=(0,three_tsl.max)(vLineWidth.mul(.5),.5),core=(0,three_tsl.float)(1).sub((0,three_tsl.smoothstep)(halfW.sub(1),halfW.add(1),dPix)),coverRadius=halfW.add(GLOW_RADIUS_EXTRA),x=(0,three_tsl.clamp)((0,three_tsl.max)(dPix.sub(halfW),0).div((0,three_tsl.max)(coverRadius.sub(halfW),1e-4)),0,1),glow=(0,three_tsl.pow)((0,three_tsl.float)(1).sub(x),4).mul(.9),intensity=(0,three_tsl.clamp)(core.add(glow.mul((0,three_tsl.float)(1).sub(core))),0,1),tip=(0,three_tsl.exp)((0,three_tsl.max)(vDrawnLen.sub(posAlong),0).mul(-5).div((0,three_tsl.max)(vStrokeLen,1e-4))),writing=(0,three_tsl.float)(1).sub((0,three_tsl.smoothstep)(vStrokeLen.mul(.98),vStrokeLen,vDrawnLen)),bright=(0,three_tsl.float)(1).add(tip.mul(.6).mul(writing)),alpha=intensity.mul(vColor.a).mul(vFade),outAlpha=(0,three_tsl.select)(notDrawn.not().and(alpha.greaterThanEqual(.004)),alpha,0);return(0,three_tsl.vec4)(vColor.rgb.mul(bright).mul(vHdrBoost).mul(outAlpha),outAlpha)}),material=new three_webgpu.NodeMaterial;return material.vertexNode=vertex(),material.fragmentNode=fragment(),material.transparent=!0,material.depthTest=!1,material.depthWrite=!1,material.side=three_webgpu.DoubleSide,material.blending=three_webgpu.CustomBlending,material.blendEquation=three_webgpu.MaxEquation,material.blendSrc=three_webgpu.OneFactor,material.blendDst=three_webgpu.OneFactor,material}_buildLineMesh(){this._disposeLineMesh();let totalSegments=0;for(let w of this.words)for(let b of w.blocks)totalSegments+=b.points.length-1;if(totalSegments===0)return;let plane=new three_webgpu.PlaneGeometry(1,1,1,1),geometry=new three_webgpu.InstancedBufferGeometry;geometry.index=plane.index,geometry.attributes=plane.attributes,geometry.instanceCount=totalSegments;let instanceStart=new Float32Array(totalSegments*3),instanceEnd=new Float32Array(totalSegments*3),instanceColor=new Float32Array(totalSegments*4),instanceData=new Float32Array(totalSegments*4),instanceReveal=new Float32Array(totalSegments*2),instanceTime=new Float32Array(totalSegments*4),idx=0;for(let w of this.words)for(let b of w.blocks){let accum=0;for(let i=0;i<b.points.length-1;i++){let start=b.points[i],end=b.points[i+1],segLen=start.distanceTo(end),i2=idx*2,i3=idx*3,i4=idx*4;instanceStart[i3+0]=start.x,instanceStart[i3+1]=start.y,instanceStart[i3+2]=start.z,instanceEnd[i3+0]=end.x,instanceEnd[i3+1]=end.y,instanceEnd[i3+2]=end.z,instanceColor[i4+0]=w.color.r,instanceColor[i4+1]=w.color.g,instanceColor[i4+2]=w.color.b,instanceColor[i4+3]=w.opacity,instanceData[i4+0]=accum,instanceData[i4+1]=w.lineWidth,instanceData[i4+2]=b.strokeLength,instanceData[i4+3]=w.hdrIntensity,instanceReveal[i2+0]=b.writeStart,instanceReveal[i2+1]=b.writeDuration,instanceTime[i4+0]=w.wordStart,instanceTime[i4+1]=w.fadeStart,instanceTime[i4+2]=w.fadeDuration,instanceTime[i4+3]=w.cycleLength,accum+=segLen,idx++}}geometry.setAttribute(`instanceStart`,new three_webgpu.InstancedBufferAttribute(instanceStart,3)),geometry.setAttribute(`instanceEnd`,new three_webgpu.InstancedBufferAttribute(instanceEnd,3)),geometry.setAttribute(`instanceColor`,new three_webgpu.InstancedBufferAttribute(instanceColor,4)),geometry.setAttribute(`instanceData`,new three_webgpu.InstancedBufferAttribute(instanceData,4)),geometry.setAttribute(`instanceReveal`,new three_webgpu.InstancedBufferAttribute(instanceReveal,2)),geometry.setAttribute(`instanceTime`,new three_webgpu.InstancedBufferAttribute(instanceTime,4)),this.lineMaterial=this.createLineMaterial(),this.lineMesh=new three_webgpu.Mesh(geometry,this.lineMaterial),this.lineMesh.frustumCulled=!1,this.effectScene.add(this.lineMesh)}createParticleMaterial(){let vColor=(0,three_tsl.varyingProperty)(`vec4`,`wpSparkColor`),vAlpha=(0,three_tsl.varyingProperty)(`float`,`wpSparkAlpha`),vLocal=(0,three_tsl.varyingProperty)(`vec2`,`wpSparkLocal`),eps=.001,attr=(name,type)=>(0,three_tsl.attribute)(name,type),vertex=(0,three_tsl.Fn)(()=>{let birth=attr(`aPosition`,`vec3`),aVelocity=attr(`aVelocity`,`vec3`),aAccel=attr(`aAccel`,`vec3`),aColor=attr(`aColor`,`vec4`),aParams=attr(`aParams`,`vec4`),aBirthTime=aParams.x,aMaxLife=aParams.y,aSeed=aParams.z,aSize=aParams.w,corner=three_tsl.positionGeometry.xy;vColor.assign(aColor),vLocal.assign(corner);let age=this.uTimeParticle.sub(aBirthTime),invisible=(0,three_tsl.float)(0).toVar();(0,three_tsl.If)(aMaxLife.lessThanEqual(0).or(age.lessThan(0)).or(age.greaterThan(aMaxLife)),()=>{invisible.assign(1)});let lifeT=age.div((0,three_tsl.max)(aMaxLife,eps)),worldPos=birth.add(aVelocity.mul(age)).add(aAccel.mul(.5).mul(age).mul(age)),clip=this.uProjParticle.mul(this.uViewParticle).mul((0,three_tsl.vec4)(worldPos,1)).toVar();(0,three_tsl.If)(clip.w.lessThanEqual(eps),()=>{invisible.assign(1)});let safeW=(0,three_tsl.max)(clip.w,eps),ndc=clip.xy.div(safeW),p11=this.uProjParticle.element(1).y,sizeFade=(0,three_tsl.float)(1).sub(lifeT.mul(.7)),pixelSize=(0,three_tsl.max)(aSize.mul(p11).mul(.5).mul(this.uResolutionParticle.y).div(safeW).mul(sizeFade),0),ndc2=ndc.add(1).mul(.5).mul(this.uResolutionParticle).add(corner.mul(pixelSize)).div(this.uResolutionParticle).mul(2).sub(1),twinkle=(0,three_tsl.float)(.7).add((0,three_tsl.float)(.3).mul((0,three_tsl.sin)(this.uTimeParticle.mul(30).add(aSeed.mul(6.2831)))));return vAlpha.assign((0,three_tsl.pow)((0,three_tsl.float)(1).sub(lifeT),.8).mul(twinkle)),(0,three_tsl.mix)((0,three_tsl.vec4)(ndc2.mul(safeW),clip.z,safeW),(0,three_tsl.vec4)(0,0,-2,1),invisible)}),fragment=(0,three_tsl.Fn)(()=>{let core=(0,three_tsl.smoothstep)(.5,0,(0,three_tsl.length)(vLocal)),intensity=core.mul(core).mul(vAlpha).mul(vColor.a);return(0,three_tsl.vec4)(vColor.rgb,intensity)}),material=new three_webgpu.NodeMaterial;return material.vertexNode=vertex(),material.fragmentNode=fragment(),material.transparent=!0,material.depthTest=!1,material.depthWrite=!1,material.blending=three_webgpu.AdditiveBlending,material}createBlendMaterial(){let material=new three_webgpu.NodeMaterial,base=this.uBase.sample((0,three_tsl.uv)()),effect=this.uEffect.sample((0,three_tsl.uv)());return material.fragmentNode=(0,three_tsl.vec4)(base.rgb.add(effect.rgb),base.a),material.transparent=!1,material.depthTest=!1,material.depthWrite=!1,material}_buildParticles(){this._disposeParticles();let total=0;for(let w of this.words)w.particleOffset=total,w.particleCursor=0,total+=w.particleCount;if(total===0)return;this.arrPosition=new Float32Array(total*3),this.arrVelocity=new Float32Array(total*3),this.arrAccel=new Float32Array(total*3),this.arrColor=new Float32Array(total*4),this.arrParams=new Float32Array(total*4);let quad=new three_webgpu.PlaneGeometry(1,1,1,1),geometry=new three_webgpu.InstancedBufferGeometry;geometry.index=quad.index,geometry.attributes=quad.attributes,geometry.instanceCount=total,geometry.setAttribute(`aPosition`,new three_webgpu.InstancedBufferAttribute(this.arrPosition,3)),geometry.setAttribute(`aVelocity`,new three_webgpu.InstancedBufferAttribute(this.arrVelocity,3)),geometry.setAttribute(`aAccel`,new three_webgpu.InstancedBufferAttribute(this.arrAccel,3)),geometry.setAttribute(`aColor`,new three_webgpu.InstancedBufferAttribute(this.arrColor,4)),geometry.setAttribute(`aParams`,new three_webgpu.InstancedBufferAttribute(this.arrParams,4)),this.particleGeometry=geometry,this.particleMaterial=this.createParticleMaterial(),this.points=new three_webgpu.Mesh(geometry,this.particleMaterial),this.points.frustumCulled=!1,this.effectScene.add(this.points)}_samplePointAtLength(points,s,out){if(points.length===1||s<=0){out.copy(points[0]);return}let acc=0;for(let i=0;i<points.length-1;i++){let a=points[i],b=points[i+1],segLen=a.distanceTo(b);if(!(segLen<=1e-9)){if(acc+segLen>=s){out.lerpVectors(a,b,(s-acc)/segLen);return}acc+=segLen}}out.copy(points[points.length-1])}_emitParticle(w,origin){if(!this.arrPosition)return;let idx=w.particleOffset+w.particleCursor;w.particleCursor=(w.particleCursor+1)%w.particleCount;let i3=idx*3,i4=idx*4,theta=Math.random()*Math.PI*2,r=Math.random(),dx=Math.cos(theta)*r,dz=Math.sin(theta)*r,dy=.3+Math.random()*.7,speed=w.sparkSpeed*(.4+Math.random()*.8);this.arrPosition[i3+0]=origin.x,this.arrPosition[i3+1]=origin.y,this.arrPosition[i3+2]=origin.z,this.arrVelocity[i3+0]=dx*speed,this.arrVelocity[i3+1]=dy*speed,this.arrVelocity[i3+2]=dz*speed,this.arrAccel[i3+0]=w.gravity.x,this.arrAccel[i3+1]=w.gravity.y,this.arrAccel[i3+2]=w.gravity.z;let bright=.8+Math.random()*.5;this.arrColor[i4+0]=w.sparkColor.r*bright,this.arrColor[i4+1]=w.sparkColor.g*bright,this.arrColor[i4+2]=w.sparkColor.b*bright,this.arrColor[i4+3]=1,this.arrParams[i4+0]=this.uTime,this.arrParams[i4+1]=w.particleLife*(.6+Math.random()*.8),this.arrParams[i4+2]=Math.random(),this.arrParams[i4+3]=w.particleSize*(.6+Math.random()*.9)}_emit(deltaTime){if(!this.particleGeometry)return;let dirty=!1;for(let w of this.words){if(!w.fireworks||w.particleCount===0)continue;let elapsed=this.uTime-w.wordStart;if(elapsed<0)continue;let local=w.cycleLength>0?elapsed%w.cycleLength:elapsed;for(let s=0;s<w.blocks.length;s++){let b=w.blocks[s],rel=local-b.writeStart;if(rel<0||rel>b.writeDuration)continue;let t=rel/b.writeDuration;this._samplePointAtLength(b.points,t*b.strokeLength,this._tmpTip),w.emitAccum[s]+=w.emissionRate*deltaTime;let n=Math.floor(w.emitAccum[s]);w.emitAccum[s]-=n,n=Math.min(n,w.particleCount);for(let i=0;i<n;i++)this._emitParticle(w,this._tmpTip),dirty=!0}}if(dirty){let g=this.particleGeometry;g.getAttribute(`aPosition`).needsUpdate=!0,g.getAttribute(`aVelocity`).needsUpdate=!0,g.getAttribute(`aAccel`).needsUpdate=!0,g.getAttribute(`aColor`).needsUpdate=!0,g.getAttribute(`aParams`).needsUpdate=!0}}render(renderer,writeBuffer,readBuffer,deltaTime,_maskActive){let active=!!(this.lineMesh||this.points);if(active){let dt=Math.min(Math.max(deltaTime==null?0:deltaTime,0),MAX_FRAME_DELTA_TIME);this.uTime+=dt,this._emit(dt)}let targetWidth=readBuffer.width,targetHeight=readBuffer.height;(this.effectRenderTarget.width!==targetWidth||this.effectRenderTarget.height!==targetHeight)&&this.effectRenderTarget.setSize(targetWidth,targetHeight);let oldRenderTarget=renderer.getRenderTarget();if(renderer.setRenderTarget(this.effectRenderTarget),renderer.setClearColor(0,0),renderer.clear(),active){let proj=this.camera.projectionMatrix,view=this.camera.matrixWorldInverse;this.lineMaterial&&(this.uTimeLine.value=this.uTime,this.uResolutionLine.value.set(targetWidth,targetHeight),this.uProjLine.value=proj,this.uViewLine.value=view,this.uPixelRatioLine.value=this.camera.pixelRatio),this.particleMaterial&&(this.uTimeParticle.value=this.uTime,this.uResolutionParticle.value.set(targetWidth,targetHeight),this.uProjParticle.value=proj,this.uViewParticle.value=view),renderer.render(this.effectScene,this.orthoCamera)}renderer.setRenderTarget(oldRenderTarget),this.uBase.value=readBuffer.texture,this.uEffect.value=this.effectRenderTarget.texture,renderer.setRenderTarget(this.renderToScreen?null:writeBuffer),this.blendQuad.render(renderer)}_disposeLineMesh(){this.lineMesh&&(this.effectScene.remove(this.lineMesh),this.lineMesh.geometry.dispose(),this.lineMesh=null),this.lineMaterial&&(this.lineMaterial.dispose(),this.lineMaterial=null)}_disposeParticles(){this.points&&(this.effectScene.remove(this.points),this.points=null),this.particleGeometry&&(this.particleGeometry.dispose(),this.particleGeometry=null),this.particleMaterial&&(this.particleMaterial.dispose(),this.particleMaterial=null),this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null}dispose(){this._disposeLineMesh(),this._disposeParticles(),this.effectRenderTarget.dispose(),this.blendMaterial.dispose(),this.blendQuad.dispose()}};exports.WordPass=WordPass;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/import{FullScreenQuad as e}from"../../five/renderer/tools/full-screen-quad.mjs";import{FivePass as t}from"../../five/renderer/postprocessing/passes/pass.mjs";import{uuid as n}from"../../five/utils/uuid.mjs";import{__rest as r}from"tslib";import*as i from"three/webgpu";import{Fn as a,If as o,attribute as s,clamp as c,dot as l,exp as u,float as d,length as f,log2 as p,max as m,mix as h,mod as g,positionGeometry as _,pow as v,select as y,sin as b,smoothstep as x,texture as S,uniform as C,uv as w,varyingProperty as T,vec2 as E,vec4 as D}from"three/tsl";var O=16767392,k=3,A=class extends t{constructor(t,n=i.UnsignedByteType){super(),this.uTime=0,this.words=[],this.lineMesh=null,this.lineMaterial=null,this.points=null,this.particleMaterial=null,this.particleGeometry=null,this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null,this._tmpTip=new i.Vector3,this.uTimeLine=C(0),this.uResolutionLine=C(new i.Vector2(1,1)),this.uProjLine=C(new i.Matrix4),this.uViewLine=C(new i.Matrix4),this.uPixelRatioLine=C(1),this.uMaxDisplayBoost=C(1),this.uTimeParticle=C(0),this.uResolutionParticle=C(new i.Vector2(1,1)),this.uProjParticle=C(new i.Matrix4),this.uViewParticle=C(new i.Matrix4),this.uBase=S(new i.Texture),this.uEffect=S(new i.Texture),this.camera=t,this.effectScene=new i.Scene,this.orthoCamera=new i.OrthographicCamera(-1,1,1,-1,0,1),this.effectRenderTarget=new i.RenderTarget(Math.max(1,this.camera.resolution.x),Math.max(1,this.camera.resolution.y),{type:n,minFilter:i.LinearFilter,magFilter:i.LinearFilter,format:i.RGBAFormat}),this.blendMaterial=this.createBlendMaterial(),this.blendQuad=new e(this.blendMaterial)}setWords(e){return this.words=e.map(e=>{var t;return this._resolveWord(e,this.uTime+((t=e.startTime)==null?0:t)/1e3)}),this._rebuild(),this.words.map(e=>e.id)}addWord(...e){let t=e.map(e=>{var t;return this._resolveWord(e,this.uTime+((t=e.startTime)==null?0:t)/1e3)});return this.words.push(...t),this._rebuild(),t.map(e=>e.id)}hasWord(e){return this.words.some(t=>t.id===e)}removeWord(...e){let t=0;for(let n of e){let e=this.words.findIndex(e=>e.id===n);if(e===-1){console.warn(`WordPass: word "${n}" not found`);continue}this.words.splice(e,1),t++}return t>0&&this._rebuild(),t}setWord(e){var t;let{id:n}=e,i=r(e,[`id`]),a=this.words.findIndex(e=>e.id===n);if(a===-1){console.warn(`WordPass: word "${n}" not found`);return}let o=this.words[a],s=Object.assign(Object.assign(Object.assign({},o.source),i),{id:n}),c=i.startTime===void 0?o.wordStart:this.uTime+((t=i.startTime)==null?0:t)/1e3;this.words[a]=this._resolveWord(s,c),this._rebuild()}clearWords(){this.words=[],this._rebuild()}setMaxDisplayBoost(e){this.uMaxDisplayBoost.value=Math.max(e,1)}_resolveWord(e,t){let{color:r=new i.Color(O),opacity:a=1,lineWidth:o=3,hdrIntensity:s=1,writeSpeed:c=4,minStrokeDuration:l=200,strokeGap:u=120,holdDuration:d=1500,fadeDuration:f=1200,loop:p=!0,restartPause:m=800,persist:h=!1,fireworks:g=!0,fireworksColor:_,particleCount:v=400,emissionRate:y=500,sparkSpeed:b=.6,particleSize:x=.012,particleLife:S=.8,gravity:C}=e,w=e.strokes.filter(e=>e.points.length>=2),T=[],E=0,D=u/1e3;for(let e of w){let t=Math.max(e.totalLength/Math.max(c,1e-4),l/1e3);T.push({points:e.points,strokeLength:e.totalLength,writeStart:E,writeDuration:t}),E+=t+D}let k=E>0?E-D:0,A=h?1e9:k+d/1e3,j=h?1:f/1e3,M=h?0:p?A+j+m/1e3:0;return{id:e.id||n(),source:Object.assign(Object.assign({},e),{id:e.id}),blocks:T,color:r.clone(),opacity:a,lineWidth:o,hdrIntensity:Math.max(s,1),wordStart:t,fadeStart:A,fadeDuration:j,cycleLength:M,fireworks:g,sparkColor:_?_.clone():r.clone().lerp(new i.Color(16777215),.4),emissionRate:y,sparkSpeed:b,particleSize:x,particleLife:S,gravity:C?C.clone():new i.Vector3(0,-.6,0),particleCount:g?Math.max(1,Math.floor(v)):0,particleOffset:0,particleCursor:0,emitAccum:T.map(()=>0)}}_rebuild(){this._buildLineMesh(),this._buildParticles()}createLineMaterial(){let e=T(`vec4`,`wpColor`),t=T(`float`,`wpSegLen`),n=T(`float`,`wpAccum`),r=T(`float`,`wpStrokeLen`),b=T(`float`,`wpDrawnLen`),S=T(`float`,`wpFade`),C=T(`vec2`,`wpStart`),w=T(`vec2`,`wpEnd`),O=T(`float`,`wpLineWidth`),A=T(`float`,`wpHdrBoost`),j=T(`vec2`,`wpNdc`),M=.001,N=(e,t)=>s(e,t),P=a(()=>{let i=N(`instanceStart`,`vec3`),a=N(`instanceEnd`,`vec3`),s=N(`instanceColor`,`vec4`),l=N(`instanceData`,`vec4`),u=N(`instanceReveal`,`vec2`),v=N(`instanceTime`,`vec4`),x=_,T=l.x,P=l.y.mul(this.uPixelRatioLine),F=l.z,I=u.x,L=u.y,R=v.x,z=v.y,ee=v.z,B=v.w;e.assign(s);let V=f(a.sub(i));t.assign(V),n.assign(T),r.assign(F),O.assign(P);let H=this.uTimeLine.sub(R),U=y(B.greaterThan(0),g(m(H,0),B),H),W=c(U.sub(I).div(m(L,1e-4)),0,1).mul(F).toVar(),G=d(1).toVar();o(U.greaterThanEqual(z),()=>{G.assign(d(1).sub(c(U.sub(z).div(m(ee,1e-4)),0,1)))}),o(H.lessThan(0),()=>{G.assign(0),W.assign(0)}),S.assign(G),b.assign(W);let K=l.w,te=m(p(m(K,1.0001)),1e-4),ne=c(p(m(this.uMaxDisplayBoost,1)).div(te),0,1);A.assign(h(1,K,ne));let q=this.uProjLine.mul(this.uViewLine).mul(D(i,1)).toVar(),J=this.uProjLine.mul(this.uViewLine).mul(D(a,1)).toVar(),Y=d(0).toVar(),X=q.w.lessThan(M).toVar(),Z=J.w.lessThan(M).toVar();o(X.and(Z),()=>{Y.assign(1)}),o(X,()=>{let e=d(M).sub(q.w).div(J.w.sub(q.w));q.assign(h(q,J,e))}),o(Z,()=>{let e=d(M).sub(J.w).div(q.w.sub(J.w));J.assign(h(J,q,e))});let re=q.xy.div(q.w),ie=J.xy.div(J.w);C.assign(re),w.assign(ie);let ae=re.add(1).mul(.5).mul(this.uResolutionLine),oe=ie.add(1).mul(.5).mul(this.uResolutionLine),se=oe.sub(ae),ce=f(se),Q=y(ce.greaterThan(1e-5),se.div(m(ce,1e-5)),E(1,0)),le=E(Q.y.negate(),Q.x),ue=x.y.add(.5),$=m(P.mul(.5),.5).add(k),de=ae.sub(Q.mul($)),fe=oe.add(Q.mul($)),pe=le.mul(x.x).mul(2).mul($),me=h(de,fe,ue).add(pe).div(this.uResolutionLine).mul(2).sub(1);j.assign(me);let he=h(q,J,ue),ge=m(he.w,M);return h(D(me.mul(ge),he.z,ge),D(0,0,-2,1),Y)}),F=a(([e,t,n])=>{let r=e.sub(t),i=n.sub(t),a=c(l(r,i).div(l(i,i)),0,1);return f(r.sub(i.mul(a)))}),I=a(()=>{let i=j,a=w.sub(C),o=m(f(a),1e-6),s=a.div(o),p=c(l(i.sub(C),s),0,o).div(o),h=n.add(p.mul(t)),g=b.lessThanEqual(1e-4).or(h.greaterThan(b)),_=E(this.uResolutionLine.x.div(this.uResolutionLine.y),1),T=F(i.mul(_),C.mul(_),w.mul(_)).mul(this.uResolutionLine.y).mul(.5),M=m(O.mul(.5),.5),N=d(1).sub(x(M.sub(1),M.add(1),T)),P=M.add(k),I=c(m(T.sub(M),0).div(m(P.sub(M),1e-4)),0,1),L=v(d(1).sub(I),4).mul(.9),R=c(N.add(L.mul(d(1).sub(N))),0,1),z=u(m(b.sub(h),0).mul(-5).div(m(r,1e-4))),ee=d(1).sub(x(r.mul(.98),r,b)),B=d(1).add(z.mul(.6).mul(ee)),V=R.mul(e.a).mul(S),H=y(g.not().and(V.greaterThanEqual(.004)),V,0);return D(e.rgb.mul(B).mul(A).mul(H),H)}),L=new i.NodeMaterial;return L.vertexNode=P(),L.fragmentNode=I(),L.transparent=!0,L.depthTest=!1,L.depthWrite=!1,L.side=i.DoubleSide,L.blending=i.CustomBlending,L.blendEquation=i.MaxEquation,L.blendSrc=i.OneFactor,L.blendDst=i.OneFactor,L}_buildLineMesh(){this._disposeLineMesh();let e=0;for(let t of this.words)for(let n of t.blocks)e+=n.points.length-1;if(e===0)return;let t=new i.PlaneGeometry(1,1,1,1),n=new i.InstancedBufferGeometry;n.index=t.index,n.attributes=t.attributes,n.instanceCount=e;let r=new Float32Array(e*3),a=new Float32Array(e*3),o=new Float32Array(e*4),s=new Float32Array(e*4),c=new Float32Array(e*2),l=new Float32Array(e*4),u=0;for(let e of this.words)for(let t of e.blocks){let n=0;for(let i=0;i<t.points.length-1;i++){let d=t.points[i],f=t.points[i+1],p=d.distanceTo(f),m=u*2,h=u*3,g=u*4;r[h+0]=d.x,r[h+1]=d.y,r[h+2]=d.z,a[h+0]=f.x,a[h+1]=f.y,a[h+2]=f.z,o[g+0]=e.color.r,o[g+1]=e.color.g,o[g+2]=e.color.b,o[g+3]=e.opacity,s[g+0]=n,s[g+1]=e.lineWidth,s[g+2]=t.strokeLength,s[g+3]=e.hdrIntensity,c[m+0]=t.writeStart,c[m+1]=t.writeDuration,l[g+0]=e.wordStart,l[g+1]=e.fadeStart,l[g+2]=e.fadeDuration,l[g+3]=e.cycleLength,n+=p,u++}}n.setAttribute(`instanceStart`,new i.InstancedBufferAttribute(r,3)),n.setAttribute(`instanceEnd`,new i.InstancedBufferAttribute(a,3)),n.setAttribute(`instanceColor`,new i.InstancedBufferAttribute(o,4)),n.setAttribute(`instanceData`,new i.InstancedBufferAttribute(s,4)),n.setAttribute(`instanceReveal`,new i.InstancedBufferAttribute(c,2)),n.setAttribute(`instanceTime`,new i.InstancedBufferAttribute(l,4)),this.lineMaterial=this.createLineMaterial(),this.lineMesh=new i.Mesh(n,this.lineMaterial),this.lineMesh.frustumCulled=!1,this.effectScene.add(this.lineMesh)}createParticleMaterial(){let e=T(`vec4`,`wpSparkColor`),t=T(`float`,`wpSparkAlpha`),n=T(`vec2`,`wpSparkLocal`),r=.001,c=(e,t)=>s(e,t),l=a(()=>{let i=c(`aPosition`,`vec3`),a=c(`aVelocity`,`vec3`),s=c(`aAccel`,`vec3`),l=c(`aColor`,`vec4`),u=c(`aParams`,`vec4`),f=u.x,p=u.y,g=u.z,y=u.w,x=_.xy;e.assign(l),n.assign(x);let S=this.uTimeParticle.sub(f),C=d(0).toVar();o(p.lessThanEqual(0).or(S.lessThan(0)).or(S.greaterThan(p)),()=>{C.assign(1)});let w=S.div(m(p,r)),T=i.add(a.mul(S)).add(s.mul(.5).mul(S).mul(S)),E=this.uProjParticle.mul(this.uViewParticle).mul(D(T,1)).toVar();o(E.w.lessThanEqual(r),()=>{C.assign(1)});let O=m(E.w,r),k=E.xy.div(O),A=this.uProjParticle.element(1).y,j=d(1).sub(w.mul(.7)),M=m(y.mul(A).mul(.5).mul(this.uResolutionParticle.y).div(O).mul(j),0),N=k.add(1).mul(.5).mul(this.uResolutionParticle).add(x.mul(M)).div(this.uResolutionParticle).mul(2).sub(1),P=d(.7).add(d(.3).mul(b(this.uTimeParticle.mul(30).add(g.mul(6.2831)))));return t.assign(v(d(1).sub(w),.8).mul(P)),h(D(N.mul(O),E.z,O),D(0,0,-2,1),C)}),u=a(()=>{let r=x(.5,0,f(n)),i=r.mul(r).mul(t).mul(e.a);return D(e.rgb,i)}),p=new i.NodeMaterial;return p.vertexNode=l(),p.fragmentNode=u(),p.transparent=!0,p.depthTest=!1,p.depthWrite=!1,p.blending=i.AdditiveBlending,p}createBlendMaterial(){let e=new i.NodeMaterial,t=this.uBase.sample(w()),n=this.uEffect.sample(w());return e.fragmentNode=D(t.rgb.add(n.rgb),t.a),e.transparent=!1,e.depthTest=!1,e.depthWrite=!1,e}_buildParticles(){this._disposeParticles();let e=0;for(let t of this.words)t.particleOffset=e,t.particleCursor=0,e+=t.particleCount;if(e===0)return;this.arrPosition=new Float32Array(e*3),this.arrVelocity=new Float32Array(e*3),this.arrAccel=new Float32Array(e*3),this.arrColor=new Float32Array(e*4),this.arrParams=new Float32Array(e*4);let t=new i.PlaneGeometry(1,1,1,1),n=new i.InstancedBufferGeometry;n.index=t.index,n.attributes=t.attributes,n.instanceCount=e,n.setAttribute(`aPosition`,new i.InstancedBufferAttribute(this.arrPosition,3)),n.setAttribute(`aVelocity`,new i.InstancedBufferAttribute(this.arrVelocity,3)),n.setAttribute(`aAccel`,new i.InstancedBufferAttribute(this.arrAccel,3)),n.setAttribute(`aColor`,new i.InstancedBufferAttribute(this.arrColor,4)),n.setAttribute(`aParams`,new i.InstancedBufferAttribute(this.arrParams,4)),this.particleGeometry=n,this.particleMaterial=this.createParticleMaterial(),this.points=new i.Mesh(n,this.particleMaterial),this.points.frustumCulled=!1,this.effectScene.add(this.points)}_samplePointAtLength(e,t,n){if(e.length===1||t<=0){n.copy(e[0]);return}let r=0;for(let i=0;i<e.length-1;i++){let a=e[i],o=e[i+1],s=a.distanceTo(o);if(!(s<=1e-9)){if(r+s>=t){n.lerpVectors(a,o,(t-r)/s);return}r+=s}}n.copy(e[e.length-1])}_emitParticle(e,t){if(!this.arrPosition)return;let n=e.particleOffset+e.particleCursor;e.particleCursor=(e.particleCursor+1)%e.particleCount;let r=n*3,i=n*4,a=Math.random()*Math.PI*2,o=Math.random(),s=Math.cos(a)*o,c=Math.sin(a)*o,l=.3+Math.random()*.7,u=e.sparkSpeed*(.4+Math.random()*.8);this.arrPosition[r+0]=t.x,this.arrPosition[r+1]=t.y,this.arrPosition[r+2]=t.z,this.arrVelocity[r+0]=s*u,this.arrVelocity[r+1]=l*u,this.arrVelocity[r+2]=c*u,this.arrAccel[r+0]=e.gravity.x,this.arrAccel[r+1]=e.gravity.y,this.arrAccel[r+2]=e.gravity.z;let d=.8+Math.random()*.5;this.arrColor[i+0]=e.sparkColor.r*d,this.arrColor[i+1]=e.sparkColor.g*d,this.arrColor[i+2]=e.sparkColor.b*d,this.arrColor[i+3]=1,this.arrParams[i+0]=this.uTime,this.arrParams[i+1]=e.particleLife*(.6+Math.random()*.8),this.arrParams[i+2]=Math.random(),this.arrParams[i+3]=e.particleSize*(.6+Math.random()*.9)}_emit(e){if(!this.particleGeometry)return;let t=!1;for(let n of this.words){if(!n.fireworks||n.particleCount===0)continue;let r=this.uTime-n.wordStart;if(r<0)continue;let i=n.cycleLength>0?r%n.cycleLength:r;for(let r=0;r<n.blocks.length;r++){let a=n.blocks[r],o=i-a.writeStart;if(o<0||o>a.writeDuration)continue;let s=o/a.writeDuration;this._samplePointAtLength(a.points,s*a.strokeLength,this._tmpTip),n.emitAccum[r]+=n.emissionRate*e;let c=Math.floor(n.emitAccum[r]);n.emitAccum[r]-=c,c=Math.min(c,n.particleCount);for(let e=0;e<c;e++)this._emitParticle(n,this._tmpTip),t=!0}}if(t){let e=this.particleGeometry;e.getAttribute(`aPosition`).needsUpdate=!0,e.getAttribute(`aVelocity`).needsUpdate=!0,e.getAttribute(`aAccel`).needsUpdate=!0,e.getAttribute(`aColor`).needsUpdate=!0,e.getAttribute(`aParams`).needsUpdate=!0}}render(e,t,n,r,i){let a=!!(this.lineMesh||this.points);a&&(this.uTime+=r==null?0:r,this._emit(r==null?0:r));let o=n.width,s=n.height;(this.effectRenderTarget.width!==o||this.effectRenderTarget.height!==s)&&this.effectRenderTarget.setSize(o,s);let c=e.getRenderTarget();if(e.setRenderTarget(this.effectRenderTarget),e.setClearColor(0,0),e.clear(),a){let t=this.camera.projectionMatrix,n=this.camera.matrixWorldInverse;this.lineMaterial&&(this.uTimeLine.value=this.uTime,this.uResolutionLine.value.set(o,s),this.uProjLine.value=t,this.uViewLine.value=n,this.uPixelRatioLine.value=this.camera.pixelRatio),this.particleMaterial&&(this.uTimeParticle.value=this.uTime,this.uResolutionParticle.value.set(o,s),this.uProjParticle.value=t,this.uViewParticle.value=n),e.render(this.effectScene,this.orthoCamera)}e.setRenderTarget(c),this.uBase.value=n.texture,this.uEffect.value=this.effectRenderTarget.texture,e.setRenderTarget(this.renderToScreen?null:t),this.blendQuad.render(e)}_disposeLineMesh(){this.lineMesh&&(this.effectScene.remove(this.lineMesh),this.lineMesh.geometry.dispose(),this.lineMesh=null),this.lineMaterial&&(this.lineMaterial.dispose(),this.lineMaterial=null)}_disposeParticles(){this.points&&(this.effectScene.remove(this.points),this.points=null),this.particleGeometry&&(this.particleGeometry.dispose(),this.particleGeometry=null),this.particleMaterial&&(this.particleMaterial.dispose(),this.particleMaterial=null),this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null}dispose(){this._disposeLineMesh(),this._disposeParticles(),this.effectRenderTarget.dispose(),this.blendMaterial.dispose(),this.blendQuad.dispose()}};export{A as WordPass};
|
|
338
|
+
*/import{FullScreenQuad}from"../../five/renderer/tools/full-screen-quad.mjs";import{FivePass}from"../../five/renderer/postprocessing/passes/pass.mjs";import{uuid as createUuid}from"../../five/utils/uuid.mjs";import{__rest}from"tslib";import*as THREE from"three/webgpu";import{Fn,If,attribute,clamp,dot,exp,float,length,log2,max,mix,mod,positionGeometry,pow,select,sin,smoothstep,texture,uniform,uv,varyingProperty,vec2,vec4}from"three/tsl";var DEFAULT_COLOR=16767392,MAX_FRAME_DELTA_TIME=.1,GLOW_RADIUS_EXTRA=3,WordPass=class extends FivePass{constructor(camera,outputType=THREE.UnsignedByteType){super(),this.uTime=0,this.words=[],this.lineMesh=null,this.lineMaterial=null,this.points=null,this.particleMaterial=null,this.particleGeometry=null,this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null,this._tmpTip=new THREE.Vector3,this.uTimeLine=uniform(0),this.uResolutionLine=uniform(new THREE.Vector2(1,1)),this.uProjLine=uniform(new THREE.Matrix4),this.uViewLine=uniform(new THREE.Matrix4),this.uPixelRatioLine=uniform(1),this.uMaxDisplayBoost=uniform(1),this.uTimeParticle=uniform(0),this.uResolutionParticle=uniform(new THREE.Vector2(1,1)),this.uProjParticle=uniform(new THREE.Matrix4),this.uViewParticle=uniform(new THREE.Matrix4),this.uBase=texture(new THREE.Texture),this.uEffect=texture(new THREE.Texture),this.camera=camera,this.effectScene=new THREE.Scene,this.orthoCamera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),this.effectRenderTarget=new THREE.RenderTarget(Math.max(1,this.camera.resolution.x),Math.max(1,this.camera.resolution.y),{type:outputType,minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),this.blendMaterial=this.createBlendMaterial(),this.blendQuad=new FullScreenQuad(this.blendMaterial)}setWords(words){return this.words=words.map(w=>{var _a;return this._resolveWord(w,this.uTime+((_a=w.startTime)==null?0:_a)/1e3)}),this._rebuild(),this.words.map(w=>w.id)}addWord(...words){let added=words.map(w=>{var _a;return this._resolveWord(w,this.uTime+((_a=w.startTime)==null?0:_a)/1e3)});return this.words.push(...added),this._rebuild(),added.map(w=>w.id)}hasWord(id){return this.words.some(w=>w.id===id)}removeWord(...ids){let removed=0;for(let id of ids){let i=this.words.findIndex(w=>w.id===id);if(i===-1){console.warn(`WordPass: word "${id}" not found`);continue}this.words.splice(i,1),removed++}return removed>0&&this._rebuild(),removed}setWord(params){var _a;let{id}=params,updates=__rest(params,[`id`]),idx=this.words.findIndex(w=>w.id===id);if(idx===-1){console.warn(`WordPass: word "${id}" not found`);return}let prev=this.words[idx],merged=Object.assign(Object.assign(Object.assign({},prev.source),updates),{id}),wordStart=updates.startTime===void 0?prev.wordStart:this.uTime+((_a=updates.startTime)==null?0:_a)/1e3;this.words[idx]=this._resolveWord(merged,wordStart),this._rebuild()}clearWords(){this.words=[],this._rebuild()}setMaxDisplayBoost(value){this.uMaxDisplayBoost.value=Math.max(value,1)}_resolveWord(w,wordStart){let{color=new THREE.Color(DEFAULT_COLOR),opacity=1,lineWidth=3,hdrIntensity=1,writeSpeed=4,minStrokeDuration=200,strokeGap=120,holdDuration=1500,fadeDuration=1200,loop=!0,restartPause=800,persist=!1,fireworks=!0,fireworksColor,particleCount=400,emissionRate=500,sparkSpeed=.6,particleSize=.012,particleLife=.8,gravity}=w,valid=w.strokes.filter(s=>s.points.length>=2),blocks=[],cursorTime=0,gap=strokeGap/1e3;for(let s of valid){let dur=Math.max(s.totalLength/Math.max(writeSpeed,1e-4),minStrokeDuration/1e3);blocks.push({points:s.points,strokeLength:s.totalLength,writeStart:cursorTime,writeDuration:dur}),cursorTime+=dur+gap}let totalWriteTime=cursorTime>0?cursorTime-gap:0,fadeStart=persist?1e9:totalWriteTime+holdDuration/1e3,fadeDur=persist?1:fadeDuration/1e3,cycleLength=persist?0:loop?fadeStart+fadeDur+restartPause/1e3:0;return{id:w.id||createUuid(),source:Object.assign(Object.assign({},w),{id:w.id}),blocks,color:color.clone(),opacity,lineWidth,hdrIntensity:Math.max(hdrIntensity,1),wordStart,fadeStart,fadeDuration:fadeDur,cycleLength,fireworks,sparkColor:fireworksColor?fireworksColor.clone():color.clone().lerp(new THREE.Color(16777215),.4),emissionRate,sparkSpeed,particleSize,particleLife,gravity:gravity?gravity.clone():new THREE.Vector3(0,-.6,0),particleCount:fireworks?Math.max(1,Math.floor(particleCount)):0,particleOffset:0,particleCursor:0,emitAccum:blocks.map(()=>0)}}_rebuild(){this._buildLineMesh(),this._buildParticles()}createLineMaterial(){let vColor=varyingProperty(`vec4`,`wpColor`),vSegLen=varyingProperty(`float`,`wpSegLen`),vAccum=varyingProperty(`float`,`wpAccum`),vStrokeLen=varyingProperty(`float`,`wpStrokeLen`),vDrawnLen=varyingProperty(`float`,`wpDrawnLen`),vFade=varyingProperty(`float`,`wpFade`),vStart=varyingProperty(`vec2`,`wpStart`),vEnd=varyingProperty(`vec2`,`wpEnd`),vLineWidth=varyingProperty(`float`,`wpLineWidth`),vHdrBoost=varyingProperty(`float`,`wpHdrBoost`),vNdc=varyingProperty(`vec2`,`wpNdc`),nearEps=.001,attr=(name,type)=>attribute(name,type),vertex=Fn(()=>{let instanceStart=attr(`instanceStart`,`vec3`),instanceEnd=attr(`instanceEnd`,`vec3`),instanceColor=attr(`instanceColor`,`vec4`),instanceData=attr(`instanceData`,`vec4`),instanceReveal=attr(`instanceReveal`,`vec2`),instanceTime=attr(`instanceTime`,`vec4`),pos=positionGeometry,accum=instanceData.x,lineWidth=instanceData.y.mul(this.uPixelRatioLine),strokeLen=instanceData.z,writeStart=instanceReveal.x,writeDur=instanceReveal.y,wordStart=instanceTime.x,fadeStart=instanceTime.y,fadeDur=instanceTime.z,cycle=instanceTime.w;vColor.assign(instanceColor);let segLen=length(instanceEnd.sub(instanceStart));vSegLen.assign(segLen),vAccum.assign(accum),vStrokeLen.assign(strokeLen),vLineWidth.assign(lineWidth);let elapsed=this.uTimeLine.sub(wordStart),local=select(cycle.greaterThan(0),mod(max(elapsed,0),cycle),elapsed),drawnLen=clamp(local.sub(writeStart).div(max(writeDur,1e-4)),0,1).mul(strokeLen).toVar(),fade=float(1).toVar();If(local.greaterThanEqual(fadeStart),()=>{fade.assign(float(1).sub(clamp(local.sub(fadeStart).div(max(fadeDur,1e-4)),0,1)))}),If(elapsed.lessThan(0),()=>{fade.assign(0),drawnLen.assign(0)}),vFade.assign(fade),vDrawnLen.assign(drawnLen);let hdrIntensity=instanceData.w,logContentMax=max(log2(max(hdrIntensity,1.0001)),1e-4),hdrWeight=clamp(log2(max(this.uMaxDisplayBoost,1)).div(logContentMax),0,1);vHdrBoost.assign(mix(1,hdrIntensity,hdrWeight));let clipStart=this.uProjLine.mul(this.uViewLine).mul(vec4(instanceStart,1)).toVar(),clipEnd=this.uProjLine.mul(this.uViewLine).mul(vec4(instanceEnd,1)).toVar(),invisible=float(0).toVar(),startBehind=clipStart.w.lessThan(nearEps).toVar(),endBehind=clipEnd.w.lessThan(nearEps).toVar();If(startBehind.and(endBehind),()=>{invisible.assign(1)}),If(startBehind,()=>{let tc=float(nearEps).sub(clipStart.w).div(clipEnd.w.sub(clipStart.w));clipStart.assign(mix(clipStart,clipEnd,tc))}),If(endBehind,()=>{let tc=float(nearEps).sub(clipEnd.w).div(clipStart.w.sub(clipEnd.w));clipEnd.assign(mix(clipEnd,clipStart,tc))});let ndcStart=clipStart.xy.div(clipStart.w),ndcEnd=clipEnd.xy.div(clipEnd.w);vStart.assign(ndcStart),vEnd.assign(ndcEnd);let screenStart=ndcStart.add(1).mul(.5).mul(this.uResolutionLine),screenEnd=ndcEnd.add(1).mul(.5).mul(this.uResolutionLine),seg=screenEnd.sub(screenStart),segLenPix=length(seg),dir=select(segLenPix.greaterThan(1e-5),seg.div(max(segLenPix,1e-5)),vec2(1,0)),normal=vec2(dir.y.negate(),dir.x),tt=pos.y.add(.5),coverRadius=max(lineWidth.mul(.5),.5).add(GLOW_RADIUS_EXTRA),extStart=screenStart.sub(dir.mul(coverRadius)),extEnd=screenEnd.add(dir.mul(coverRadius)),offset=normal.mul(pos.x).mul(2).mul(coverRadius),ndc=mix(extStart,extEnd,tt).add(offset).div(this.uResolutionLine).mul(2).sub(1);vNdc.assign(ndc);let clipPos=mix(clipStart,clipEnd,tt),safeW=max(clipPos.w,nearEps);return mix(vec4(ndc.mul(safeW),clipPos.z,safeW),vec4(0,0,-2,1),invisible)}),sdCapsule=Fn(([p,a,b])=>{let pa=p.sub(a),ba=b.sub(a),h=clamp(dot(pa,ba).div(dot(ba,ba)),0,1);return length(pa.sub(ba.mul(h)))}),fragment=Fn(()=>{let uvNdc=vNdc,screenDiff=vEnd.sub(vStart),screenDist=max(length(screenDiff),1e-6),screenDir=screenDiff.div(screenDist),projRatio=clamp(dot(uvNdc.sub(vStart),screenDir),0,screenDist).div(screenDist),posAlong=vAccum.add(projRatio.mul(vSegLen)),notDrawn=vDrawnLen.lessThanEqual(1e-4).or(posAlong.greaterThan(vDrawnLen)),aspect=vec2(this.uResolutionLine.x.div(this.uResolutionLine.y),1),dPix=sdCapsule(uvNdc.mul(aspect),vStart.mul(aspect),vEnd.mul(aspect)).mul(this.uResolutionLine.y).mul(.5),halfW=max(vLineWidth.mul(.5),.5),core=float(1).sub(smoothstep(halfW.sub(1),halfW.add(1),dPix)),coverRadius=halfW.add(GLOW_RADIUS_EXTRA),x=clamp(max(dPix.sub(halfW),0).div(max(coverRadius.sub(halfW),1e-4)),0,1),glow=pow(float(1).sub(x),4).mul(.9),intensity=clamp(core.add(glow.mul(float(1).sub(core))),0,1),tip=exp(max(vDrawnLen.sub(posAlong),0).mul(-5).div(max(vStrokeLen,1e-4))),writing=float(1).sub(smoothstep(vStrokeLen.mul(.98),vStrokeLen,vDrawnLen)),bright=float(1).add(tip.mul(.6).mul(writing)),alpha=intensity.mul(vColor.a).mul(vFade),outAlpha=select(notDrawn.not().and(alpha.greaterThanEqual(.004)),alpha,0);return vec4(vColor.rgb.mul(bright).mul(vHdrBoost).mul(outAlpha),outAlpha)}),material=new THREE.NodeMaterial;return material.vertexNode=vertex(),material.fragmentNode=fragment(),material.transparent=!0,material.depthTest=!1,material.depthWrite=!1,material.side=THREE.DoubleSide,material.blending=THREE.CustomBlending,material.blendEquation=THREE.MaxEquation,material.blendSrc=THREE.OneFactor,material.blendDst=THREE.OneFactor,material}_buildLineMesh(){this._disposeLineMesh();let totalSegments=0;for(let w of this.words)for(let b of w.blocks)totalSegments+=b.points.length-1;if(totalSegments===0)return;let plane=new THREE.PlaneGeometry(1,1,1,1),geometry=new THREE.InstancedBufferGeometry;geometry.index=plane.index,geometry.attributes=plane.attributes,geometry.instanceCount=totalSegments;let instanceStart=new Float32Array(totalSegments*3),instanceEnd=new Float32Array(totalSegments*3),instanceColor=new Float32Array(totalSegments*4),instanceData=new Float32Array(totalSegments*4),instanceReveal=new Float32Array(totalSegments*2),instanceTime=new Float32Array(totalSegments*4),idx=0;for(let w of this.words)for(let b of w.blocks){let accum=0;for(let i=0;i<b.points.length-1;i++){let start=b.points[i],end=b.points[i+1],segLen=start.distanceTo(end),i2=idx*2,i3=idx*3,i4=idx*4;instanceStart[i3+0]=start.x,instanceStart[i3+1]=start.y,instanceStart[i3+2]=start.z,instanceEnd[i3+0]=end.x,instanceEnd[i3+1]=end.y,instanceEnd[i3+2]=end.z,instanceColor[i4+0]=w.color.r,instanceColor[i4+1]=w.color.g,instanceColor[i4+2]=w.color.b,instanceColor[i4+3]=w.opacity,instanceData[i4+0]=accum,instanceData[i4+1]=w.lineWidth,instanceData[i4+2]=b.strokeLength,instanceData[i4+3]=w.hdrIntensity,instanceReveal[i2+0]=b.writeStart,instanceReveal[i2+1]=b.writeDuration,instanceTime[i4+0]=w.wordStart,instanceTime[i4+1]=w.fadeStart,instanceTime[i4+2]=w.fadeDuration,instanceTime[i4+3]=w.cycleLength,accum+=segLen,idx++}}geometry.setAttribute(`instanceStart`,new THREE.InstancedBufferAttribute(instanceStart,3)),geometry.setAttribute(`instanceEnd`,new THREE.InstancedBufferAttribute(instanceEnd,3)),geometry.setAttribute(`instanceColor`,new THREE.InstancedBufferAttribute(instanceColor,4)),geometry.setAttribute(`instanceData`,new THREE.InstancedBufferAttribute(instanceData,4)),geometry.setAttribute(`instanceReveal`,new THREE.InstancedBufferAttribute(instanceReveal,2)),geometry.setAttribute(`instanceTime`,new THREE.InstancedBufferAttribute(instanceTime,4)),this.lineMaterial=this.createLineMaterial(),this.lineMesh=new THREE.Mesh(geometry,this.lineMaterial),this.lineMesh.frustumCulled=!1,this.effectScene.add(this.lineMesh)}createParticleMaterial(){let vColor=varyingProperty(`vec4`,`wpSparkColor`),vAlpha=varyingProperty(`float`,`wpSparkAlpha`),vLocal=varyingProperty(`vec2`,`wpSparkLocal`),eps=.001,attr=(name,type)=>attribute(name,type),vertex=Fn(()=>{let birth=attr(`aPosition`,`vec3`),aVelocity=attr(`aVelocity`,`vec3`),aAccel=attr(`aAccel`,`vec3`),aColor=attr(`aColor`,`vec4`),aParams=attr(`aParams`,`vec4`),aBirthTime=aParams.x,aMaxLife=aParams.y,aSeed=aParams.z,aSize=aParams.w,corner=positionGeometry.xy;vColor.assign(aColor),vLocal.assign(corner);let age=this.uTimeParticle.sub(aBirthTime),invisible=float(0).toVar();If(aMaxLife.lessThanEqual(0).or(age.lessThan(0)).or(age.greaterThan(aMaxLife)),()=>{invisible.assign(1)});let lifeT=age.div(max(aMaxLife,eps)),worldPos=birth.add(aVelocity.mul(age)).add(aAccel.mul(.5).mul(age).mul(age)),clip=this.uProjParticle.mul(this.uViewParticle).mul(vec4(worldPos,1)).toVar();If(clip.w.lessThanEqual(eps),()=>{invisible.assign(1)});let safeW=max(clip.w,eps),ndc=clip.xy.div(safeW),p11=this.uProjParticle.element(1).y,sizeFade=float(1).sub(lifeT.mul(.7)),pixelSize=max(aSize.mul(p11).mul(.5).mul(this.uResolutionParticle.y).div(safeW).mul(sizeFade),0),ndc2=ndc.add(1).mul(.5).mul(this.uResolutionParticle).add(corner.mul(pixelSize)).div(this.uResolutionParticle).mul(2).sub(1),twinkle=float(.7).add(float(.3).mul(sin(this.uTimeParticle.mul(30).add(aSeed.mul(6.2831)))));return vAlpha.assign(pow(float(1).sub(lifeT),.8).mul(twinkle)),mix(vec4(ndc2.mul(safeW),clip.z,safeW),vec4(0,0,-2,1),invisible)}),fragment=Fn(()=>{let core=smoothstep(.5,0,length(vLocal)),intensity=core.mul(core).mul(vAlpha).mul(vColor.a);return vec4(vColor.rgb,intensity)}),material=new THREE.NodeMaterial;return material.vertexNode=vertex(),material.fragmentNode=fragment(),material.transparent=!0,material.depthTest=!1,material.depthWrite=!1,material.blending=THREE.AdditiveBlending,material}createBlendMaterial(){let material=new THREE.NodeMaterial,base=this.uBase.sample(uv()),effect=this.uEffect.sample(uv());return material.fragmentNode=vec4(base.rgb.add(effect.rgb),base.a),material.transparent=!1,material.depthTest=!1,material.depthWrite=!1,material}_buildParticles(){this._disposeParticles();let total=0;for(let w of this.words)w.particleOffset=total,w.particleCursor=0,total+=w.particleCount;if(total===0)return;this.arrPosition=new Float32Array(total*3),this.arrVelocity=new Float32Array(total*3),this.arrAccel=new Float32Array(total*3),this.arrColor=new Float32Array(total*4),this.arrParams=new Float32Array(total*4);let quad=new THREE.PlaneGeometry(1,1,1,1),geometry=new THREE.InstancedBufferGeometry;geometry.index=quad.index,geometry.attributes=quad.attributes,geometry.instanceCount=total,geometry.setAttribute(`aPosition`,new THREE.InstancedBufferAttribute(this.arrPosition,3)),geometry.setAttribute(`aVelocity`,new THREE.InstancedBufferAttribute(this.arrVelocity,3)),geometry.setAttribute(`aAccel`,new THREE.InstancedBufferAttribute(this.arrAccel,3)),geometry.setAttribute(`aColor`,new THREE.InstancedBufferAttribute(this.arrColor,4)),geometry.setAttribute(`aParams`,new THREE.InstancedBufferAttribute(this.arrParams,4)),this.particleGeometry=geometry,this.particleMaterial=this.createParticleMaterial(),this.points=new THREE.Mesh(geometry,this.particleMaterial),this.points.frustumCulled=!1,this.effectScene.add(this.points)}_samplePointAtLength(points,s,out){if(points.length===1||s<=0){out.copy(points[0]);return}let acc=0;for(let i=0;i<points.length-1;i++){let a=points[i],b=points[i+1],segLen=a.distanceTo(b);if(!(segLen<=1e-9)){if(acc+segLen>=s){out.lerpVectors(a,b,(s-acc)/segLen);return}acc+=segLen}}out.copy(points[points.length-1])}_emitParticle(w,origin){if(!this.arrPosition)return;let idx=w.particleOffset+w.particleCursor;w.particleCursor=(w.particleCursor+1)%w.particleCount;let i3=idx*3,i4=idx*4,theta=Math.random()*Math.PI*2,r=Math.random(),dx=Math.cos(theta)*r,dz=Math.sin(theta)*r,dy=.3+Math.random()*.7,speed=w.sparkSpeed*(.4+Math.random()*.8);this.arrPosition[i3+0]=origin.x,this.arrPosition[i3+1]=origin.y,this.arrPosition[i3+2]=origin.z,this.arrVelocity[i3+0]=dx*speed,this.arrVelocity[i3+1]=dy*speed,this.arrVelocity[i3+2]=dz*speed,this.arrAccel[i3+0]=w.gravity.x,this.arrAccel[i3+1]=w.gravity.y,this.arrAccel[i3+2]=w.gravity.z;let bright=.8+Math.random()*.5;this.arrColor[i4+0]=w.sparkColor.r*bright,this.arrColor[i4+1]=w.sparkColor.g*bright,this.arrColor[i4+2]=w.sparkColor.b*bright,this.arrColor[i4+3]=1,this.arrParams[i4+0]=this.uTime,this.arrParams[i4+1]=w.particleLife*(.6+Math.random()*.8),this.arrParams[i4+2]=Math.random(),this.arrParams[i4+3]=w.particleSize*(.6+Math.random()*.9)}_emit(deltaTime){if(!this.particleGeometry)return;let dirty=!1;for(let w of this.words){if(!w.fireworks||w.particleCount===0)continue;let elapsed=this.uTime-w.wordStart;if(elapsed<0)continue;let local=w.cycleLength>0?elapsed%w.cycleLength:elapsed;for(let s=0;s<w.blocks.length;s++){let b=w.blocks[s],rel=local-b.writeStart;if(rel<0||rel>b.writeDuration)continue;let t=rel/b.writeDuration;this._samplePointAtLength(b.points,t*b.strokeLength,this._tmpTip),w.emitAccum[s]+=w.emissionRate*deltaTime;let n=Math.floor(w.emitAccum[s]);w.emitAccum[s]-=n,n=Math.min(n,w.particleCount);for(let i=0;i<n;i++)this._emitParticle(w,this._tmpTip),dirty=!0}}if(dirty){let g=this.particleGeometry;g.getAttribute(`aPosition`).needsUpdate=!0,g.getAttribute(`aVelocity`).needsUpdate=!0,g.getAttribute(`aAccel`).needsUpdate=!0,g.getAttribute(`aColor`).needsUpdate=!0,g.getAttribute(`aParams`).needsUpdate=!0}}render(renderer,writeBuffer,readBuffer,deltaTime,_maskActive){let active=!!(this.lineMesh||this.points);if(active){let dt=Math.min(Math.max(deltaTime==null?0:deltaTime,0),MAX_FRAME_DELTA_TIME);this.uTime+=dt,this._emit(dt)}let targetWidth=readBuffer.width,targetHeight=readBuffer.height;(this.effectRenderTarget.width!==targetWidth||this.effectRenderTarget.height!==targetHeight)&&this.effectRenderTarget.setSize(targetWidth,targetHeight);let oldRenderTarget=renderer.getRenderTarget();if(renderer.setRenderTarget(this.effectRenderTarget),renderer.setClearColor(0,0),renderer.clear(),active){let proj=this.camera.projectionMatrix,view=this.camera.matrixWorldInverse;this.lineMaterial&&(this.uTimeLine.value=this.uTime,this.uResolutionLine.value.set(targetWidth,targetHeight),this.uProjLine.value=proj,this.uViewLine.value=view,this.uPixelRatioLine.value=this.camera.pixelRatio),this.particleMaterial&&(this.uTimeParticle.value=this.uTime,this.uResolutionParticle.value.set(targetWidth,targetHeight),this.uProjParticle.value=proj,this.uViewParticle.value=view),renderer.render(this.effectScene,this.orthoCamera)}renderer.setRenderTarget(oldRenderTarget),this.uBase.value=readBuffer.texture,this.uEffect.value=this.effectRenderTarget.texture,renderer.setRenderTarget(this.renderToScreen?null:writeBuffer),this.blendQuad.render(renderer)}_disposeLineMesh(){this.lineMesh&&(this.effectScene.remove(this.lineMesh),this.lineMesh.geometry.dispose(),this.lineMesh=null),this.lineMaterial&&(this.lineMaterial.dispose(),this.lineMaterial=null)}_disposeParticles(){this.points&&(this.effectScene.remove(this.points),this.points=null),this.particleGeometry&&(this.particleGeometry.dispose(),this.particleGeometry=null),this.particleMaterial&&(this.particleMaterial.dispose(),this.particleMaterial=null),this.arrPosition=null,this.arrVelocity=null,this.arrAccel=null,this.arrColor=null,this.arrParams=null}dispose(){this._disposeLineMesh(),this._disposeParticles(),this.effectRenderTarget.dispose(),this.blendMaterial.dispose(),this.blendQuad.dispose()}};export{WordPass};
|
package/plugins/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const
|
|
338
|
+
*/Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const require_index=require("./BasePlugin/index.js"),require_index$1=require("./BackgroundPlugin/index.js"),require_Controller=require("./Object3DHelperPlugin/Controller.js"),require_index$2=require("./Object3DHelperPlugin/index.js"),require_index$3=require("./PanoAnimePlugin/index.js"),require_index$4=require("./CSS2DPlugin/index.js"),require_index$5=require("./CSS3DPlugin/index.js"),require_formatFloorplanJson=require("./FloorplanPlugin/utils/formatFloorplanJson.js"),require_index$6=require("./FloorplanPlugin/index.js"),require_index$7=require("./GaussianSplattingEntranceAnimationPlugin/index.js"),require_hersheyFont=require("./WordPassPlugin/hersheyFont.js"),require_textToStrokeOrderStrokes=require("./WordPassPlugin/textToStrokeOrderStrokes.js"),require_index$8=require("./WordPassPlugin/index.js"),require_calculatePath=require("./utils/calculatePath.js");exports.BackgroundPlugin=require_index$1.BackgroundPlugin,Object.defineProperty(exports,"BasePlugin",{enumerable:!0,get:function(){return require_index.BasePlugin}}),exports.CSS2DPlugin=require_index$4.CSS2DPlugin,exports.CSS3DPlugin=require_index$5.CSS3DPlugin,exports.FloorplanPlugin=require_index$6.FloorplanPlugin,exports.GaussianSplattingEntranceAnimationPlugin=require_index$7.GaussianSplattingEntranceAnimationPlugin,exports.Object3DHelperController=require_Controller.Controller,exports.Object3DHelperPlugin=require_index$2.Object3DHelperPlugin,exports.PanoAnimePlugin=require_index$3.PanoAnimePlugin,exports.WordPassPlugin=require_index$8.WordPassPlugin,exports.calculatePath2DLength=require_calculatePath.calculatePath2DLength,exports.calculatePath3DLength=require_calculatePath.calculatePath3DLength,exports.formatFloorplanJson=require_formatFloorplanJson.default,exports.loadHersheyFont=require_hersheyFont.loadHersheyFont,exports.textToStrokeOrderStrokes=require_textToStrokeOrderStrokes.textToStrokeOrderStrokes;
|
package/plugins/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/import{BasePlugin
|
|
338
|
+
*/import{BasePlugin}from"./BasePlugin/index.mjs";import{BackgroundPlugin}from"./BackgroundPlugin/index.mjs";import{Controller}from"./Object3DHelperPlugin/Controller.mjs";import{Object3DHelperPlugin}from"./Object3DHelperPlugin/index.mjs";import{PanoAnimePlugin}from"./PanoAnimePlugin/index.mjs";import{CSS2DPlugin}from"./CSS2DPlugin/index.mjs";import{CSS3DPlugin}from"./CSS3DPlugin/index.mjs";import formatFloorplanJson from"./FloorplanPlugin/utils/formatFloorplanJson.mjs";import{FloorplanPlugin}from"./FloorplanPlugin/index.mjs";import{GaussianSplattingEntranceAnimationPlugin}from"./GaussianSplattingEntranceAnimationPlugin/index.mjs";import{loadHersheyFont}from"./WordPassPlugin/hersheyFont.mjs";import{textToStrokeOrderStrokes}from"./WordPassPlugin/textToStrokeOrderStrokes.mjs";import{WordPassPlugin}from"./WordPassPlugin/index.mjs";import{calculatePath2DLength,calculatePath3DLength}from"./utils/calculatePath.mjs";export{BackgroundPlugin,BasePlugin,CSS2DPlugin,CSS3DPlugin,FloorplanPlugin,GaussianSplattingEntranceAnimationPlugin,Controller as Object3DHelperController,Object3DHelperPlugin,PanoAnimePlugin,WordPassPlugin,calculatePath2DLength,calculatePath3DLength,formatFloorplanJson,loadHersheyFont,textToStrokeOrderStrokes};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/let
|
|
338
|
+
*/let three_webgpu=require("three/webgpu");var CSS2DObject=class extends three_webgpu.Object3D{constructor(element=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=element,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new three_webgpu.Vector2(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(object){object.element&&object.element instanceof Element&&object.element.parentNode!==null&&object.element.remove()})})}copy(source,recursive){return super.copy(source,recursive),this.element=source.element.cloneNode(!0),this.center=source.center.clone(),this}},_vector=new three_webgpu.Vector3,_viewMatrix=new three_webgpu.Matrix4,_viewProjectionMatrix=new three_webgpu.Matrix4,_a=new three_webgpu.Vector3,_b=new three_webgpu.Vector3,CSS2DRenderer=class{constructor(parameters={}){let _this=this,_width,_height,_widthHalf,_heightHalf,cache={objects:new WeakMap},domElement=parameters.element===void 0?document.createElement(`div`):parameters.element;domElement.style.overflow=`hidden`,this.domElement=domElement,this.sortObjects=!0,this.getSize=function(){return{width:_width,height:_height}},this.render=function(scene,camera){scene.updateMatrixWorld(),camera.parent===null&&camera.updateMatrixWorld(),_viewMatrix.copy(camera.matrixWorldInverse),_viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix,_viewMatrix),renderObject(scene,scene,camera),_this.sortObjects&&zOrder(scene)},this.setSize=function(width,height){_width=width,_height=height,_widthHalf=_width/2,_heightHalf=_height/2,domElement.style.width=width+`px`,domElement.style.height=height+`px`};function hideObject(object){object.isCSS2DObject&&(object.element.style.display=`none`);for(let i=0,l=object.children.length;i<l;i++)hideObject(object.children[i])}function renderObject(object,scene,camera){if(object.visible===!1){hideObject(object);return}if(object.isCSS2DObject){_vector.setFromMatrixPosition(object.matrixWorld),_vector.applyMatrix4(_viewProjectionMatrix);let visible=_vector.z>=-1&&_vector.z<=1&&object.layers.test(camera.layers)===!0,element=object.element;element.style.display=visible===!0?``:`none`,visible===!0&&(object.onBeforeRender(_this,scene,camera),element.style.transform=`translate(`+-100*object.center.x+`%,`+-100*object.center.y+`%)translate(`+(_vector.x*_widthHalf+_widthHalf)+`px,`+(-_vector.y*_heightHalf+_heightHalf)+`px)`,element.parentNode!==domElement&&domElement.appendChild(element),object.onAfterRender(_this,scene,camera));let objectData={distanceToCameraSquared:getDistanceToSquared(camera,object)};cache.objects.set(object,objectData)}for(let i=0,l=object.children.length;i<l;i++)renderObject(object.children[i],scene,camera)}function getDistanceToSquared(object1,object2){return _a.setFromMatrixPosition(object1.matrixWorld),_b.setFromMatrixPosition(object2.matrixWorld),_a.distanceToSquared(_b)}function filterAndFlatten(scene){let result=[];return scene.traverseVisible(function(object){object.isCSS2DObject&&result.push(object)}),result}function zOrder(scene){let sorted=filterAndFlatten(scene).sort(function(a,b){return a.renderOrder===b.renderOrder?cache.objects.get(a).distanceToCameraSquared-cache.objects.get(b).distanceToCameraSquared:b.renderOrder-a.renderOrder}),zMax=sorted.length;for(let i=0,l=sorted.length;i<l;i++)sorted[i].element.style.zIndex=zMax-i}}};exports.CSS2DObject=CSS2DObject,exports.CSS2DRenderer=CSS2DRenderer;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/import{Matrix4
|
|
338
|
+
*/import{Matrix4,Object3D,Vector2,Vector3}from"three/webgpu";var CSS2DObject=class extends Object3D{constructor(element=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=element,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new Vector2(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(object){object.element&&object.element instanceof Element&&object.element.parentNode!==null&&object.element.remove()})})}copy(source,recursive){return super.copy(source,recursive),this.element=source.element.cloneNode(!0),this.center=source.center.clone(),this}},_vector=new Vector3,_viewMatrix=new Matrix4,_viewProjectionMatrix=new Matrix4,_a=new Vector3,_b=new Vector3,CSS2DRenderer=class{constructor(parameters={}){let _this=this,_width,_height,_widthHalf,_heightHalf,cache={objects:new WeakMap},domElement=parameters.element===void 0?document.createElement(`div`):parameters.element;domElement.style.overflow=`hidden`,this.domElement=domElement,this.sortObjects=!0,this.getSize=function(){return{width:_width,height:_height}},this.render=function(scene,camera){scene.updateMatrixWorld(),camera.parent===null&&camera.updateMatrixWorld(),_viewMatrix.copy(camera.matrixWorldInverse),_viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix,_viewMatrix),renderObject(scene,scene,camera),_this.sortObjects&&zOrder(scene)},this.setSize=function(width,height){_width=width,_height=height,_widthHalf=_width/2,_heightHalf=_height/2,domElement.style.width=width+`px`,domElement.style.height=height+`px`};function hideObject(object){object.isCSS2DObject&&(object.element.style.display=`none`);for(let i=0,l=object.children.length;i<l;i++)hideObject(object.children[i])}function renderObject(object,scene,camera){if(object.visible===!1){hideObject(object);return}if(object.isCSS2DObject){_vector.setFromMatrixPosition(object.matrixWorld),_vector.applyMatrix4(_viewProjectionMatrix);let visible=_vector.z>=-1&&_vector.z<=1&&object.layers.test(camera.layers)===!0,element=object.element;element.style.display=visible===!0?``:`none`,visible===!0&&(object.onBeforeRender(_this,scene,camera),element.style.transform=`translate(`+-100*object.center.x+`%,`+-100*object.center.y+`%)translate(`+(_vector.x*_widthHalf+_widthHalf)+`px,`+(-_vector.y*_heightHalf+_heightHalf)+`px)`,element.parentNode!==domElement&&domElement.appendChild(element),object.onAfterRender(_this,scene,camera));let objectData={distanceToCameraSquared:getDistanceToSquared(camera,object)};cache.objects.set(object,objectData)}for(let i=0,l=object.children.length;i<l;i++)renderObject(object.children[i],scene,camera)}function getDistanceToSquared(object1,object2){return _a.setFromMatrixPosition(object1.matrixWorld),_b.setFromMatrixPosition(object2.matrixWorld),_a.distanceToSquared(_b)}function filterAndFlatten(scene){let result=[];return scene.traverseVisible(function(object){object.isCSS2DObject&&result.push(object)}),result}function zOrder(scene){let sorted=filterAndFlatten(scene).sort(function(a,b){return a.renderOrder===b.renderOrder?cache.objects.get(a).distanceToCameraSquared-cache.objects.get(b).distanceToCameraSquared:b.renderOrder-a.renderOrder}),zMax=sorted.length;for(let i=0,l=sorted.length;i<l;i++)sorted[i].element.style.zIndex=zMax-i}}};export{CSS2DObject,CSS2DRenderer};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/let
|
|
338
|
+
*/let three_webgpu=require("three/webgpu");var _position=new three_webgpu.Vector3,_quaternion=new three_webgpu.Quaternion,_scale=new three_webgpu.Vector3,CSS3DObject=class extends three_webgpu.Object3D{constructor(element=document.createElement(`div`)){super(),this.isCSS3DObject=!0,this.element=element,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.addEventListener(`removed`,function(){this.traverse(function(object){object.element&&object.element instanceof Element&&object.element.parentNode!==null&&object.element.remove()})})}copy(source,recursive){return super.copy(source,recursive),this.element=source.element.cloneNode(!0),this}},CSS3DSprite=class extends CSS3DObject{constructor(element){super(element),this.isCSS3DSprite=!0,this.rotation2D=0}copy(source,recursive){return super.copy(source,recursive),this.rotation2D=source.rotation2D,this}},_matrix=new three_webgpu.Matrix4,_matrix2=new three_webgpu.Matrix4,CSS3DRenderer=class{constructor(parameters={}){let _this=this,_width,_height,_widthHalf,_heightHalf,cache={camera:{style:``},objects:new WeakMap},domElement=parameters.element===void 0?document.createElement(`div`):parameters.element;domElement.style.overflow=`hidden`,this.domElement=domElement;let viewElement=document.createElement(`div`);viewElement.style.transformOrigin=`0 0`,viewElement.style.pointerEvents=`none`,domElement.appendChild(viewElement);let cameraElement=document.createElement(`div`);cameraElement.style.transformStyle=`preserve-3d`,viewElement.appendChild(cameraElement),this.getSize=function(){return{width:_width,height:_height}};let _objectsDirty=!0,_spriteObjects=new Set;this.markDirty=function(){_objectsDirty=!0},this.updateSpriteSet=function(scene){_spriteObjects.clear(),scene.traverse(function(object){object.isCSS3DSprite&&_spriteObjects.add(object)})};function renderSpriteObject(object,scene,camera){if(object.visible===!1)return;let visible=object.layers.test(camera.layers)===!0,element=object.element;if(element.style.display=visible===!0?``:`none`,visible===!0){object.onBeforeRender(_this,scene,camera),_matrix.copy(camera.matrixWorldInverse),_matrix.transpose(),object.rotation2D!==0&&_matrix.multiply(_matrix2.makeRotationZ(object.rotation2D)),object.matrixWorld.decompose(_position,_quaternion,_scale),_matrix.setPosition(_position),_matrix.scale(_scale),_matrix.elements[3]=0,_matrix.elements[7]=0,_matrix.elements[11]=0,_matrix.elements[15]=1;let style=getObjectCSSMatrix(_matrix),cachedObject=cache.objects.get(object);(cachedObject===void 0||cachedObject.style!==style)&&(element.style.transform=style,cache.objects.set(object,{style})),element.parentNode!==cameraElement&&cameraElement.appendChild(element),object.onAfterRender(_this,scene,camera)}}this.render=function(scene,camera){let fov=camera.projectionMatrix.elements[5]*_heightHalf;scene.updateMatrixWorld(),camera.parent===null&&camera.updateMatrixWorld();let tx,ty;camera.isOrthographicCamera&&(tx=-(camera.right+camera.left)/2,ty=(camera.top+camera.bottom)/2);let cameraCSSMatrix=camera.isOrthographicCamera?`scale(`+fov+`)translate(`+epsilon(tx)+`px,`+epsilon(ty)+`px)`+getCameraCSSMatrix(camera.matrixWorldInverse):`translateZ(`+fov+`px)`+getCameraCSSMatrix(camera.matrixWorldInverse),style=(camera.isPerspectiveCamera?`perspective(`+fov+`px) `:``)+cameraCSSMatrix+` translate(`+_widthHalf+`px,`+_heightHalf+`px)`;if(cache.camera.style!==style&&(cameraElement.style.transform=style,cache.camera.style=style),_objectsDirty)renderObject(scene,scene,camera,cameraCSSMatrix),_objectsDirty=!1;else if(_spriteObjects.size>0)for(let sprite of _spriteObjects)renderSpriteObject(sprite,scene,camera)},this.setSize=function(width,height){_width=width,_height=height,_widthHalf=_width/2,_heightHalf=_height/2,domElement.style.width=width+`px`,domElement.style.height=height+`px`,viewElement.style.width=width+`px`,viewElement.style.height=height+`px`,cameraElement.style.width=width+`px`,cameraElement.style.height=height+`px`};function epsilon(value){return Math.abs(value)<1e-10?0:value}function getCameraCSSMatrix(matrix){let elements=matrix.elements;return`matrix3d(`+epsilon(elements[0])+`,`+epsilon(-elements[1])+`,`+epsilon(elements[2])+`,`+epsilon(elements[3])+`,`+epsilon(elements[4])+`,`+epsilon(-elements[5])+`,`+epsilon(elements[6])+`,`+epsilon(elements[7])+`,`+epsilon(elements[8])+`,`+epsilon(-elements[9])+`,`+epsilon(elements[10])+`,`+epsilon(elements[11])+`,`+epsilon(elements[12])+`,`+epsilon(-elements[13])+`,`+epsilon(elements[14])+`,`+epsilon(elements[15])+`)`}function getObjectCSSMatrix(matrix){let e=matrix.elements;return`translate(-50%,-50%) matrix3d(${[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]].map(val=>Math.abs(val)<1e-10?0:val).join(`,`)})`}function hideObject(object){object.isCSS3DObject&&(object.element.style.display=`none`);for(let i=0,l=object.children.length;i<l;i++)hideObject(object.children[i])}function renderObject(object,scene,camera,cameraCSSMatrix){if(object.visible===!1){hideObject(object);return}if(object.isCSS3DObject){let visible=object.layers.test(camera.layers)===!0,element=object.element;if(element.style.display=visible===!0?``:`none`,visible===!0){object.onBeforeRender(_this,scene,camera);let style;object.isCSS3DSprite?(_matrix.copy(camera.matrixWorldInverse),_matrix.transpose(),object.rotation2D!==0&&_matrix.multiply(_matrix2.makeRotationZ(object.rotation2D)),object.matrixWorld.decompose(_position,_quaternion,_scale),_matrix.setPosition(_position),_matrix.scale(_scale),_matrix.elements[3]=0,_matrix.elements[7]=0,_matrix.elements[11]=0,_matrix.elements[15]=1,style=getObjectCSSMatrix(_matrix)):style=getObjectCSSMatrix(object.matrixWorld);let cachedObject=cache.objects.get(object);if(cachedObject===void 0||cachedObject.style!==style){element.style.transform=style;let objectData={style};cache.objects.set(object,objectData)}element.parentNode!==cameraElement&&cameraElement.appendChild(element),object.onAfterRender(_this,scene,camera)}}for(let i=0,l=object.children.length;i<l;i++)renderObject(object.children[i],scene,camera,cameraCSSMatrix)}}};exports.CSS3DObject=CSS3DObject,exports.CSS3DRenderer=CSS3DRenderer,exports.CSS3DSprite=CSS3DSprite;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated: 2026/
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 2026/11/4
|
|
5
|
+
* Version: 1.0.0-alpha.15
|
|
6
6
|
* License:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
|
|
@@ -335,4 +335,4 @@
|
|
|
335
335
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
336
336
|
* Agreement and all related documents shall be drafted in English.
|
|
337
337
|
|
|
338
|
-
*/import{Matrix4
|
|
338
|
+
*/import{Matrix4,Object3D,Quaternion,Vector3}from"three/webgpu";var _position=new Vector3,_quaternion=new Quaternion,_scale=new Vector3,CSS3DObject=class extends Object3D{constructor(element=document.createElement(`div`)){super(),this.isCSS3DObject=!0,this.element=element,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.addEventListener(`removed`,function(){this.traverse(function(object){object.element&&object.element instanceof Element&&object.element.parentNode!==null&&object.element.remove()})})}copy(source,recursive){return super.copy(source,recursive),this.element=source.element.cloneNode(!0),this}},CSS3DSprite=class extends CSS3DObject{constructor(element){super(element),this.isCSS3DSprite=!0,this.rotation2D=0}copy(source,recursive){return super.copy(source,recursive),this.rotation2D=source.rotation2D,this}},_matrix=new Matrix4,_matrix2=new Matrix4,CSS3DRenderer=class{constructor(parameters={}){let _this=this,_width,_height,_widthHalf,_heightHalf,cache={camera:{style:``},objects:new WeakMap},domElement=parameters.element===void 0?document.createElement(`div`):parameters.element;domElement.style.overflow=`hidden`,this.domElement=domElement;let viewElement=document.createElement(`div`);viewElement.style.transformOrigin=`0 0`,viewElement.style.pointerEvents=`none`,domElement.appendChild(viewElement);let cameraElement=document.createElement(`div`);cameraElement.style.transformStyle=`preserve-3d`,viewElement.appendChild(cameraElement),this.getSize=function(){return{width:_width,height:_height}};let _objectsDirty=!0,_spriteObjects=new Set;this.markDirty=function(){_objectsDirty=!0},this.updateSpriteSet=function(scene){_spriteObjects.clear(),scene.traverse(function(object){object.isCSS3DSprite&&_spriteObjects.add(object)})};function renderSpriteObject(object,scene,camera){if(object.visible===!1)return;let visible=object.layers.test(camera.layers)===!0,element=object.element;if(element.style.display=visible===!0?``:`none`,visible===!0){object.onBeforeRender(_this,scene,camera),_matrix.copy(camera.matrixWorldInverse),_matrix.transpose(),object.rotation2D!==0&&_matrix.multiply(_matrix2.makeRotationZ(object.rotation2D)),object.matrixWorld.decompose(_position,_quaternion,_scale),_matrix.setPosition(_position),_matrix.scale(_scale),_matrix.elements[3]=0,_matrix.elements[7]=0,_matrix.elements[11]=0,_matrix.elements[15]=1;let style=getObjectCSSMatrix(_matrix),cachedObject=cache.objects.get(object);(cachedObject===void 0||cachedObject.style!==style)&&(element.style.transform=style,cache.objects.set(object,{style})),element.parentNode!==cameraElement&&cameraElement.appendChild(element),object.onAfterRender(_this,scene,camera)}}this.render=function(scene,camera){let fov=camera.projectionMatrix.elements[5]*_heightHalf;scene.updateMatrixWorld(),camera.parent===null&&camera.updateMatrixWorld();let tx,ty;camera.isOrthographicCamera&&(tx=-(camera.right+camera.left)/2,ty=(camera.top+camera.bottom)/2);let cameraCSSMatrix=camera.isOrthographicCamera?`scale(`+fov+`)translate(`+epsilon(tx)+`px,`+epsilon(ty)+`px)`+getCameraCSSMatrix(camera.matrixWorldInverse):`translateZ(`+fov+`px)`+getCameraCSSMatrix(camera.matrixWorldInverse),style=(camera.isPerspectiveCamera?`perspective(`+fov+`px) `:``)+cameraCSSMatrix+` translate(`+_widthHalf+`px,`+_heightHalf+`px)`;if(cache.camera.style!==style&&(cameraElement.style.transform=style,cache.camera.style=style),_objectsDirty)renderObject(scene,scene,camera,cameraCSSMatrix),_objectsDirty=!1;else if(_spriteObjects.size>0)for(let sprite of _spriteObjects)renderSpriteObject(sprite,scene,camera)},this.setSize=function(width,height){_width=width,_height=height,_widthHalf=_width/2,_heightHalf=_height/2,domElement.style.width=width+`px`,domElement.style.height=height+`px`,viewElement.style.width=width+`px`,viewElement.style.height=height+`px`,cameraElement.style.width=width+`px`,cameraElement.style.height=height+`px`};function epsilon(value){return Math.abs(value)<1e-10?0:value}function getCameraCSSMatrix(matrix){let elements=matrix.elements;return`matrix3d(`+epsilon(elements[0])+`,`+epsilon(-elements[1])+`,`+epsilon(elements[2])+`,`+epsilon(elements[3])+`,`+epsilon(elements[4])+`,`+epsilon(-elements[5])+`,`+epsilon(elements[6])+`,`+epsilon(elements[7])+`,`+epsilon(elements[8])+`,`+epsilon(-elements[9])+`,`+epsilon(elements[10])+`,`+epsilon(elements[11])+`,`+epsilon(elements[12])+`,`+epsilon(-elements[13])+`,`+epsilon(elements[14])+`,`+epsilon(elements[15])+`)`}function getObjectCSSMatrix(matrix){let e=matrix.elements;return`translate(-50%,-50%) matrix3d(${[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]].map(val=>Math.abs(val)<1e-10?0:val).join(`,`)})`}function hideObject(object){object.isCSS3DObject&&(object.element.style.display=`none`);for(let i=0,l=object.children.length;i<l;i++)hideObject(object.children[i])}function renderObject(object,scene,camera,cameraCSSMatrix){if(object.visible===!1){hideObject(object);return}if(object.isCSS3DObject){let visible=object.layers.test(camera.layers)===!0,element=object.element;if(element.style.display=visible===!0?``:`none`,visible===!0){object.onBeforeRender(_this,scene,camera);let style;object.isCSS3DSprite?(_matrix.copy(camera.matrixWorldInverse),_matrix.transpose(),object.rotation2D!==0&&_matrix.multiply(_matrix2.makeRotationZ(object.rotation2D)),object.matrixWorld.decompose(_position,_quaternion,_scale),_matrix.setPosition(_position),_matrix.scale(_scale),_matrix.elements[3]=0,_matrix.elements[7]=0,_matrix.elements[11]=0,_matrix.elements[15]=1,style=getObjectCSSMatrix(_matrix)):style=getObjectCSSMatrix(object.matrixWorld);let cachedObject=cache.objects.get(object);if(cachedObject===void 0||cachedObject.style!==style){element.style.transform=style;let objectData={style};cache.objects.set(object,objectData)}element.parentNode!==cameraElement&&cameraElement.appendChild(element),object.onAfterRender(_this,scene,camera)}}for(let i=0,l=object.children.length;i<l;i++)renderObject(object.children[i],scene,camera,cameraCSSMatrix)}}};export{CSS3DObject,CSS3DRenderer,CSS3DSprite};
|