@realsee/five-webgpu 1.0.0-alpha.12 → 1.0.0-alpha.14
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 +41 -32
- package/docs/classes/index.FivePass.html +1 -1
- package/docs/classes/index.FiveRenderer.html +7 -2
- 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 -5
- 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 +9 -9
- package/docs/classes/index.PBMGaussianSplattingObject.html +49 -11
- package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +71 -16
- 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 +1 -1
- package/docs/classes/index.PanoCircleMeshCustom.html +1 -1
- package/docs/classes/index.PanoCircleMeshSolid.html +1 -1
- package/docs/classes/index.Parameter.html +24 -22
- package/docs/classes/index.Scene.html +1 -1
- package/docs/classes/index.Subscribe.html +1 -1
- package/docs/classes/index.Tile3D.html +22 -22
- package/docs/classes/index.TileNode.html +2 -2
- 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.DeviceProfile.html +2 -2
- 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.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.PBMGaussianSplattingNodeMaterialOptions.html +3 -3
- package/docs/interfaces/index.PanoCircleMeshInterface.html +1 -1
- 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 +8 -6
- package/docs/interfaces/index.ParameterTilesetValue.html +15 -15
- package/docs/interfaces/index.ParameterValue.html +21 -19
- package/docs/interfaces/index.Pose.html +1 -1
- package/docs/interfaces/index.RenderEvent.html +1 -1
- package/docs/interfaces/index.ResolvedParameterValue.html +22 -20
- package/docs/interfaces/index.SplatData.html +10 -6
- 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.Tile3DOptions.html +2 -2
- package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/index.ViewLayer.html +22 -22
- 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 +13 -0
- 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/xrPanorama.d.ts +13 -0
- package/five/core/internalWebGPURenderer.d.ts +0 -3
- package/five/core/panoVideo.d.ts +2 -0
- package/five/core/webglBlendEquationFix.d.ts +41 -0
- package/five/gaussian-splatting/arena/splatArena.d.ts +227 -0
- package/five/gaussian-splatting/cullConstants.d.ts +68 -0
- package/five/gaussian-splatting/hybridConstants.d.ts +60 -0
- package/five/gaussian-splatting/instancePacking.d.ts +46 -0
- package/five/gaussian-splatting/mirrors/layoutMirror.d.ts +44 -0
- package/five/gaussian-splatting/mirrors/mirrorBuffer.d.ts +72 -0
- package/five/gaussian-splatting/mirrors/mirrorSet.d.ts +17 -0
- package/five/gaussian-splatting/mirrors/objectParamsMirror.d.ts +35 -0
- package/five/gaussian-splatting/mirrors/transformMirror.d.ts +26 -0
- package/five/gaussian-splatting/pipelines/gpuSortPipeline.d.ts +5 -31
- package/five/gaussian-splatting/pipelines/pipelineMode.d.ts +1 -2
- package/five/gaussian-splatting/sh-core/codec.d.ts +13 -0
- package/five/gaussian-splatting/sh-core/constants.d.ts +29 -0
- package/five/gaussian-splatting/sh-core/index.d.ts +4 -0
- package/five/gaussian-splatting/sh-core/rebakePolicy.d.ts +20 -0
- package/five/gaussian-splatting/sh-core/texelRange.d.ts +18 -0
- package/five/gaussian-splatting/shAssembler.d.ts +14 -0
- package/five/gaussian-splatting/shBakeScheduler.d.ts +26 -0
- package/five/gaussian-splatting/shBaker.d.ts +44 -0
- package/five/gaussian-splatting/shTileResource.d.ts +22 -0
- package/five/gaussian-splatting/splatAssembler.d.ts +1 -1
- package/five/gaussian-splatting/transformStore.d.ts +2 -2
- package/five/gaussian-splatting/worker/decodeWorker.d.ts +72 -0
- package/five/index.d.ts +0 -1
- package/five/index.js +138 -640
- package/five/index.mjs +229 -29261
- 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/ply.d.ts +22 -6
- package/five/model/loaders/spz.d.ts +9 -49
- package/five/model/loaders/spz.worker.d.ts +37 -0
- package/five/model/materials/pbmGaussianSplattingNodeMaterial.d.ts +6 -12
- package/five/model/objects/pbmGaussianSplattingObject.d.ts +91 -6
- package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +357 -15
- package/five/model/parameter.d.ts +4 -0
- package/five/renderer/compute-renderers/binned/binned-core.d.ts +45 -2
- package/five/renderer/compute-renderers/binned/binned-pipelines.d.ts +82 -1
- package/five/renderer/compute-renderers/color-space.d.ts +13 -0
- package/five/renderer/compute-renderers/composite-pipelines.d.ts +36 -0
- package/five/renderer/compute-renderers/frame-plan.d.ts +166 -0
- package/five/renderer/compute-renderers/gsplat-hybrid-renderer.d.ts +386 -0
- package/five/renderer/compute-renderers/pointcloud-compute-renderer.d.ts +101 -16
- package/five/renderer/compute-renderers/shaders/composite-blend.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/gsplatHybridIndirect.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/gsplatProjector.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/gsplatQuad.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/lib/write-additive.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/lib/write-blend.d.ts +2 -0
- package/five/renderer/compute-renderers/shaders/lib/write-opaque.d.ts +2 -0
- package/five/renderer/compute-renderers/tile-uniform-writer.d.ts +70 -0
- package/five/renderer/compute-renderers/transparency-buffers.d.ts +59 -0
- package/five/renderer/compute-renderers/transparency-math.d.ts +70 -0
- package/five/renderer/compute-renderers/transparency-settings.d.ts +24 -0
- package/five/renderer/compute-renderers/uniform-layout.d.ts +11 -2
- package/five/renderer/five-renderer.d.ts +28 -3
- 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/videoTextureBridge.d.ts +152 -0
- package/five/thirdparty/sha256.d.ts +149 -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/work.d.ts +0 -7
- package/five/work/workJsonType.d.ts +0 -2
- 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.d.ts +6 -0
- 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.d.ts +7 -0
- package/sticker/index.js +46 -3
- package/sticker/index.mjs +43 -103
- package/umd/five-gltf-loader.js +3 -3
- package/umd/five-line.js +3 -3
- package/umd/five-plugins.js +3 -3
- package/umd/five-react.js +2 -2
- package/umd/five-sticker.js +46 -3
- package/umd/five-vfx.js +2 -2
- package/umd/five.js +216 -179
- 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 -1
- package/five/certificates/hardware.d.ts +0 -1
- package/five/gaussian-splatting/shStore.d.ts +0 -22
- package/five/thirdparty/jsrsasign.d.ts +0 -753
- package/five/work/keychain.d.ts +0 -5
- package/five/work/verify.d.ts +0 -7
- package/five/work/workVerify.d.ts +0 -2
- /package/five/{work/_ALLOW_HOST.d.ts → renderer/compute-renderers/shaders/composite-additive.d.ts} +0 -0
|
@@ -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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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{WordPass}from"./word-pass.mjs";import{textToStrokeOrderStrokes}from"./textToStrokeOrderStrokes.mjs";import{__awaiter,__rest}from"tslib";import*as THREE from"three/webgpu";var Controller=class extends BasePlugin.Controller{updateState(state,userAction){let prevState=this.state;this.state=Object.assign(Object.assign({},this.state),state),this.hooks.emit(`stateChange`,{state:this.state,prevState,userAction})}constructor(five,params){var _a,_b;super(five),this.dispose=()=>{this.disable(),this.wordPass.dispose()},this.five=five;let defaultState={enabled:!1,visible:!0};this.state=Object.assign(defaultState,params==null?void 0:params.initialState);let outputType=(_b=(_a=params==null?void 0:params.config)==null?void 0:_a.outputType)==null?five.enableHDR?THREE.HalfFloatType:THREE.UnsignedByteType:_b;this.wordPass=new WordPass(five.camera,outputType),this.state.enabled&&this._enable()}load(){return __awaiter(this,void 0,void 0,function*(){})}_enable(){this.five.addPass(this.wordPass),this.wordPass.enabled=this.state.visible,this.five.needsRender=!0}_disable(){this.five.removePass(this.wordPass),this.wordPass.clearWords(),this.five.needsRender=!0}enable(options){var _a;if(this.state.enabled)return;let userAction=(_a=options==null?void 0:options.userAction)==null?!0:_a;this.updateState({enabled:!0},userAction),this._enable()}disable(options){var _a;if(this.state.enabled===!1)return;let userAction=(_a=options==null?void 0:options.userAction)==null?!0:_a;this.updateState({enabled:!1},userAction),this._disable()}setState(state,options={}){var _a;let prevState=this.state,userAction=(_a=options.userAction)==null?!0:_a;this.updateState(state,userAction),state.enabled!==void 0&&prevState.enabled!==state.enabled&&(state.enabled?this._enable():this._disable()),state.visible!==void 0&&prevState.visible!==state.visible&&(this.wordPass.enabled=state.visible,this.five.needsRender=!0)}setWords(words){let ids=this.wordPass.setWords(words);return this.five.needsRender=!0,ids}addWord(...words){let ids=this.wordPass.addWord(...words);return this.five.needsRender=!0,ids}removeWord(...ids){let removed=this.wordPass.removeWord(...ids);return this.five.needsRender=!0,removed}setWord(params){this.wordPass.setWord(params),this.five.needsRender=!0}clearWords(){this.wordPass.clearWords(),this.five.needsRender=!0}hasWord(id){return this.wordPass.hasWord(id)}setMaxDisplayBoost(value){this.wordPass.setMaxDisplayBoost(value),this.five.needsRender=!0}writeText(text_1){return __awaiter(this,arguments,void 0,function*(text,options={}){let{size,letterSpacing,lineSpacing,normal,up,center,position,smooth,smoothSubdivisions,cdnBaseUrl,charDataLoader,latinScale}=options,style=__rest(options,[`size`,`letterSpacing`,`lineSpacing`,`normal`,`up`,`center`,`position`,`smooth`,`smoothSubdivisions`,`cdnBaseUrl`,`charDataLoader`,`latinScale`]),strokes=yield textToStrokeOrderStrokes(text,{size,letterSpacing,lineSpacing,normal,up,center,position,smooth,smoothSubdivisions,cdnBaseUrl,charDataLoader,latinScale});this.state.enabled||this.enable(),style.id!==void 0&&this.hasWord(style.id)&&this.removeWord(style.id);let[wordId]=this.addWord(Object.assign(Object.assign({},style),{strokes}));return wordId})}};export{Controller};
|
|
@@ -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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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
|
-
*/var
|
|
338
|
+
*/var FUTURAL={name:`Sans 1-stroke`,chars:[{d:`M5,1 L5,15 M5,20 L4,21 5,22 6,21 5,20`,o:5},{d:`M4,1 L4,8 M12,1 L12,8`,o:8},{d:`M11,-3 L4,29 M17,-3 L10,29 M4,10 L18,10 M3,16 L17,16`,o:11},{d:`M8,-3 L8,26 M12,-3 L12,26 M17,4 L15,2 12,1 8,1 5,2 3,4 3,6 4,8 5,9 7,10 13,12 15,13 16,14 17,16 17,19 15,21 12,22 8,22 5,21 3,19`,o:10},{d:`M21,1 L3,22 M8,1 L10,3 10,5 9,7 7,8 5,8 3,6 3,4 4,2 6,1 8,1 10,2 13,3 16,3 19,2 21,1 M17,15 L15,16 14,18 14,20 16,22 18,22 20,21 21,19 21,17 19,15 17,15`,o:12},{d:`M23,10 L23,9 22,8 21,8 20,9 19,11 17,16 15,19 13,21 11,22 7,22 5,21 4,20 3,18 3,16 4,14 5,13 12,9 13,8 14,6 14,4 13,2 11,1 9,2 8,4 8,6 9,9 11,12 16,19 18,21 20,22 22,22 23,21 23,20`,o:13},{d:`M5,3 L4,2 5,1 6,2 6,4 5,6 4,7`,o:5},{d:`M11,-3 L9,-1 7,2 5,6 4,11 4,15 5,20 7,24 9,27 11,29`,o:7},{d:`M3,-3 L5,-1 7,2 9,6 10,11 10,15 9,20 7,24 5,27 3,29`,o:7},{d:`M8,7 L8,19 M3,10 L13,16 M13,10 L3,16`,o:8},{d:`M13,4 L13,22 M4,13 L22,13`,o:13},{d:`M5,18 L4,19 3,18 4,17 5,18 5,20 3,22`,o:4},{d:`M4,13 L22,13`,o:13},{d:`M4,17 L3,18 4,19 5,18 4,17`,o:4},{d:`M20,-3 L2,29`,o:11},{d:`M9,1 L6,2 4,5 3,10 3,13 4,18 6,21 9,22 11,22 14,21 16,18 17,13 17,10 16,5 14,2 11,1 9,1`,o:10},{d:`M6,5 L8,4 11,1 11,22`,o:10},{d:`M4,6 L4,5 5,3 6,2 8,1 12,1 14,2 15,3 16,5 16,7 15,9 13,12 3,22 17,22`,o:10},{d:`M5,1 L16,1 10,9 13,9 15,10 16,11 17,14 17,16 16,19 14,21 11,22 8,22 5,21 4,20 3,18`,o:10},{d:`M13,1 L3,15 18,15 M13,1 L13,22`,o:10},{d:`M15,1 L5,1 4,10 5,9 8,8 11,8 14,9 16,11 17,14 17,16 16,19 14,21 11,22 8,22 5,21 4,20 3,18`,o:10},{d:`M16,4 L15,2 12,1 10,1 7,2 5,5 4,10 4,15 5,19 7,21 10,22 11,22 14,21 16,19 17,16 17,15 16,12 14,10 11,9 10,9 7,10 5,12 4,15`,o:10},{d:`M17,1 L7,22 M3,1 L17,1`,o:10},{d:`M8,1 L5,2 4,4 4,6 5,8 7,9 11,10 14,11 16,13 17,15 17,18 16,20 15,21 12,22 8,22 5,21 4,20 3,18 3,15 4,13 6,11 9,10 13,9 15,8 16,6 16,4 15,2 12,1 8,1`,o:10},{d:`M16,8 L15,11 13,13 10,14 9,14 6,13 4,11 3,8 3,7 4,4 6,2 9,1 10,1 13,2 15,4 16,8 16,13 15,18 13,21 10,22 8,22 5,21 4,19`,o:10},{d:`M4,10 L3,11 4,12 5,11 4,10 M4,17 L3,18 4,19 5,18 4,17`,o:4},{d:`M4,10 L3,11 4,12 5,11 4,10 M5,18 L4,19 3,18 4,17 5,18 5,20 3,22`,o:4},{d:`M20,4 L4,13 20,22`,o:12},{d:`M4,10 L22,10 M4,16 L22,16`,o:13},{d:`M4,4 L20,13 4,22`,o:12},{d:`M3,6 L3,5 4,3 5,2 7,1 11,1 13,2 14,3 15,5 15,7 14,9 13,10 9,12 9,15 M9,20 L8,21 9,22 10,21 9,20`,o:9},{d:`M18,9 L17,7 15,6 12,6 10,7 9,8 8,11 8,14 9,16 11,17 14,17 16,16 17,14 M12,6 L10,8 9,11 9,14 10,16 11,17 M18,6 L17,14 17,16 19,17 21,17 23,15 24,12 24,10 23,7 22,5 20,3 18,2 15,1 12,1 9,2 7,3 5,5 4,7 3,10 3,13 4,16 5,18 7,20 9,21 12,22 15,22 18,21 20,20 21,19 M19,6 L18,14 18,16 19,17`,o:14},{d:`M9,1 L1,22 M9,1 L17,22 M4,15 L14,15`,o:9},{d:`M4,1 L4,22 M4,1 L13,1 16,2 17,3 18,5 18,7 17,9 16,10 13,11 M4,11 L13,11 16,12 17,13 18,15 18,18 17,20 16,21 13,22 4,22`,o:10},{d:`M18,6 L17,4 15,2 13,1 9,1 7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17`,o:11},{d:`M4,1 L4,22 M4,1 L11,1 14,2 16,4 17,6 18,9 18,14 17,17 16,19 14,21 11,22 4,22`,o:10},{d:`M4,1 L4,22 M4,1 L17,1 M4,11 L12,11 M4,22 L17,22`,o:9},{d:`M4,1 L4,22 M4,1 L17,1 M4,11 L12,11`,o:8},{d:`M18,6 L17,4 15,2 13,1 9,1 7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17 18,14 M13,14 L18,14`,o:11},{d:`M4,1 L4,22 M18,1 L18,22 M4,11 L18,11`,o:11},{d:`M4,1 L4,22`,o:4},{d:`M12,1 L12,17 11,20 10,21 8,22 6,22 4,21 3,20 2,17 2,15`,o:8},{d:`M4,1 L4,22 M18,1 L4,15 M9,10 L18,22`,o:10},{d:`M4,1 L4,22 M4,22 L16,22`,o:7},{d:`M4,1 L4,22 M4,1 L12,22 M20,1 L12,22 M20,1 L20,22`,o:12},{d:`M4,1 L4,22 M4,1 L18,22 M18,1 L18,22`,o:11},{d:`M9,1 L7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17 19,14 19,9 18,6 17,4 15,2 13,1 9,1`,o:11},{d:`M4,1 L4,22 M4,1 L13,1 16,2 17,3 18,5 18,8 17,10 16,11 13,12 4,12`,o:10},{d:`M9,1 L7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17 19,14 19,9 18,6 17,4 15,2 13,1 9,1 M12,18 L18,24`,o:11},{d:`M4,1 L4,22 M4,1 L13,1 16,2 17,3 18,5 18,7 17,9 16,10 13,11 4,11 M11,11 L18,22`,o:10},{d:`M17,4 L15,2 12,1 8,1 5,2 3,4 3,6 4,8 5,9 7,10 13,12 15,13 16,14 17,16 17,19 15,21 12,22 8,22 5,21 3,19`,o:10},{d:`M8,1 L8,22 M1,1 L15,1`,o:8},{d:`M4,1 L4,16 5,19 7,21 10,22 12,22 15,21 17,19 18,16 18,1`,o:11},{d:`M1,1 L9,22 M17,1 L9,22`,o:9},{d:`M2,1 L7,22 M12,1 L7,22 M12,1 L17,22 M22,1 L17,22`,o:12},{d:`M3,1 L17,22 M17,1 L3,22`,o:10},{d:`M1,1 L9,11 9,22 M17,1 L9,11`,o:9},{d:`M17,1 L3,22 M3,1 L17,1 M3,22 L17,22`,o:10},{d:`M4,-3 L4,29 M5,-3 L5,29 M4,-3 L11,-3 M4,29 L11,29`,o:7},{d:`M0,1 L14,25`,o:7},{d:`M9,-3 L9,29 M10,-3 L10,29 M3,-3 L10,-3 M3,29 L10,29`,o:7},{d:`M8,-1 L0,13 M8,-1 L16,13`,o:8},{d:`M0,29 L18,29`,o:9},{d:`M5,6 L3,8 3,10 4,11 5,10 4,9 3,10`,o:4},{d:`M15,8 L15,22 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M4,1 L4,22 M4,11 L6,9 8,8 11,8 13,9 15,11 16,14 16,16 15,19 13,21 11,22 8,22 6,21 4,19`,o:9},{d:`M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:9},{d:`M15,1 L15,22 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M3,14 L15,14 15,12 14,10 13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:9},{d:`M10,1 L8,1 6,2 5,5 5,22 M2,8 L9,8`,o:7},{d:`M15,8 L15,24 14,27 13,28 11,29 8,29 6,28 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M4,1 L4,22 M4,12 L7,9 9,8 12,8 14,9 15,12 15,22`,o:10},{d:`M3,1 L4,2 5,1 4,0 3,1 M4,8 L4,22`,o:4},{d:`M5,1 L6,2 7,1 6,0 5,1 M6,8 L6,25 5,28 3,29 1,29`,o:5},{d:`M4,1 L4,22 M14,8 L4,18 M8,14 L15,22`,o:8},{d:`M4,1 L4,22`,o:4},{d:`M4,8 L4,22 M4,12 L7,9 9,8 12,8 14,9 15,12 15,22 M15,12 L18,9 20,8 23,8 25,9 26,12 26,22`,o:15},{d:`M4,8 L4,22 M4,12 L7,9 9,8 12,8 14,9 15,12 15,22`,o:10},{d:`M8,8 L6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19 16,16 16,14 15,11 13,9 11,8 8,8`,o:10},{d:`M4,8 L4,29 M4,11 L6,9 8,8 11,8 13,9 15,11 16,14 16,16 15,19 13,21 11,22 8,22 6,21 4,19`,o:9},{d:`M15,8 L15,29 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M4,8 L4,22 M4,14 L5,11 7,9 9,8 12,8`,o:6},{d:`M14,11 L13,9 10,8 7,8 4,9 3,11 4,13 6,14 11,15 13,16 14,18 14,19 13,21 10,22 7,22 4,21 3,19`,o:9},{d:`M5,1 L5,18 6,21 8,22 10,22 M2,8 L9,8`,o:7},{d:`M4,8 L4,18 5,21 7,22 10,22 12,21 15,18 M15,8 L15,22`,o:10},{d:`M2,8 L8,22 M14,8 L8,22`,o:8},{d:`M3,8 L7,22 M11,8 L7,22 M11,8 L15,22 M19,8 L15,22`,o:11},{d:`M3,8 L14,22 M14,8 L3,22`,o:9},{d:`M2,8 L8,22 M14,8 L8,22 6,26 4,28 2,29 1,29`,o:8},{d:`M14,8 L3,22 M3,8 L14,8 M3,22 L14,22`,o:9},{d:`M9,-3 L7,-2 6,-1 5,1 5,3 6,5 7,6 8,8 8,10 6,12 M7,-2 L6,0 6,2 7,4 8,5 9,7 9,9 8,11 4,13 8,15 9,17 9,19 8,21 7,22 6,24 6,26 7,28 M6,14 L8,16 8,18 7,20 6,21 5,23 5,25 6,27 7,28 9,29`,o:7},{d:`M4,-3 L4,29`,o:4},{d:`M5,-3 L7,-2 8,-1 9,1 9,3 8,5 7,6 6,8 6,10 8,12 M7,-2 L8,0 8,2 7,4 6,5 5,7 5,9 6,11 10,13 6,15 5,17 5,19 6,21 7,22 8,24 8,26 7,28 M8,14 L6,16 6,18 7,20 8,21 9,23 9,25 8,27 7,28 5,29`,o:7},{d:`M3,16 L3,14 4,11 6,10 8,10 10,11 14,14 16,15 18,15 20,14 21,12 M3,14 L4,12 6,11 8,11 10,12 14,15 16,16 18,16 20,15 21,12 21,10`,o:12},{d:`M0,1 L0,22 1,22 1,1 2,1 2,22 3,22 3,1 4,1 4,22 5,22 5,1 6,1 6,22 7,22 7,1 8,1 8,22 9,22 9,1 10,1 10,22 11,22 11,1 12,1 12,22 13,22 13,1 14,1 14,22 15,22 15,1 16,1 16,22`,o:8}]},cachedMap=null;function parseHersheyPath(d){let polylines=[],cur=null;for(let tok of d.trim().split(/\s+/)){let s=tok,cmd=``;(s[0]===`M`||s[0]===`L`)&&(cmd=s[0],s=s.slice(1));let comma=s.indexOf(`,`);if(comma<0)continue;let x=parseFloat(s.slice(0,comma)),y=parseFloat(s.slice(comma+1));Number.isNaN(x)||Number.isNaN(y)||(cmd===`M`?(cur=[[x,y]],polylines.push(cur)):cur?cur.push([x,y]):(cur=[[x,y]],polylines.push(cur)))}return polylines}function loadHersheyFont(data=FUTURAL){if(cachedMap&&data===FUTURAL)return cachedMap;if(!data||!Array.isArray(data.chars))return null;let rawGlyphs=data.chars.map(c=>({polylines:parseHersheyPath(c.d||``),o:c.o})),capTop=1/0,baseline=-1/0,measure=code=>{let g=rawGlyphs[code-33];if(!g)return!1;let found=!1;for(let pl of g.polylines)for(let p of pl)p[1]<capTop&&(capTop=p[1]),p[1]>baseline&&(baseline=p[1]),found=!0;return found};measure(72)||measure(69)||measure(88)||measure(73),(!Number.isFinite(capTop)||!Number.isFinite(baseline)||baseline<=capTop)&&(capTop=4,baseline=21);let capHeight=baseline-capTop,gap=capHeight*.14,map=new Map;for(let i=0;i<rawGlyphs.length;i++){let g=rawGlyphs[i],minX=1/0,maxX=-1/0;for(let pl of g.polylines)for(let p of pl)p[0]<minX&&(minX=p[0]),p[0]>maxX&&(maxX=p[0]);let hasPoints=Number.isFinite(minX),left=hasPoints?minX:0,width=hasPoints?maxX-minX:g.o,polylines=g.polylines.map(pl=>pl.map(([x,y])=>[(x-left)/capHeight,(baseline-y)/capHeight]));map.set(33+i,{polylines,advance:(width+gap)/capHeight})}return data===FUTURAL&&(cachedMap=map),map}exports.loadHersheyFont=loadHersheyFont;
|
|
@@ -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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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
|
-
*/var
|
|
338
|
+
*/var FUTURAL={name:`Sans 1-stroke`,chars:[{d:`M5,1 L5,15 M5,20 L4,21 5,22 6,21 5,20`,o:5},{d:`M4,1 L4,8 M12,1 L12,8`,o:8},{d:`M11,-3 L4,29 M17,-3 L10,29 M4,10 L18,10 M3,16 L17,16`,o:11},{d:`M8,-3 L8,26 M12,-3 L12,26 M17,4 L15,2 12,1 8,1 5,2 3,4 3,6 4,8 5,9 7,10 13,12 15,13 16,14 17,16 17,19 15,21 12,22 8,22 5,21 3,19`,o:10},{d:`M21,1 L3,22 M8,1 L10,3 10,5 9,7 7,8 5,8 3,6 3,4 4,2 6,1 8,1 10,2 13,3 16,3 19,2 21,1 M17,15 L15,16 14,18 14,20 16,22 18,22 20,21 21,19 21,17 19,15 17,15`,o:12},{d:`M23,10 L23,9 22,8 21,8 20,9 19,11 17,16 15,19 13,21 11,22 7,22 5,21 4,20 3,18 3,16 4,14 5,13 12,9 13,8 14,6 14,4 13,2 11,1 9,2 8,4 8,6 9,9 11,12 16,19 18,21 20,22 22,22 23,21 23,20`,o:13},{d:`M5,3 L4,2 5,1 6,2 6,4 5,6 4,7`,o:5},{d:`M11,-3 L9,-1 7,2 5,6 4,11 4,15 5,20 7,24 9,27 11,29`,o:7},{d:`M3,-3 L5,-1 7,2 9,6 10,11 10,15 9,20 7,24 5,27 3,29`,o:7},{d:`M8,7 L8,19 M3,10 L13,16 M13,10 L3,16`,o:8},{d:`M13,4 L13,22 M4,13 L22,13`,o:13},{d:`M5,18 L4,19 3,18 4,17 5,18 5,20 3,22`,o:4},{d:`M4,13 L22,13`,o:13},{d:`M4,17 L3,18 4,19 5,18 4,17`,o:4},{d:`M20,-3 L2,29`,o:11},{d:`M9,1 L6,2 4,5 3,10 3,13 4,18 6,21 9,22 11,22 14,21 16,18 17,13 17,10 16,5 14,2 11,1 9,1`,o:10},{d:`M6,5 L8,4 11,1 11,22`,o:10},{d:`M4,6 L4,5 5,3 6,2 8,1 12,1 14,2 15,3 16,5 16,7 15,9 13,12 3,22 17,22`,o:10},{d:`M5,1 L16,1 10,9 13,9 15,10 16,11 17,14 17,16 16,19 14,21 11,22 8,22 5,21 4,20 3,18`,o:10},{d:`M13,1 L3,15 18,15 M13,1 L13,22`,o:10},{d:`M15,1 L5,1 4,10 5,9 8,8 11,8 14,9 16,11 17,14 17,16 16,19 14,21 11,22 8,22 5,21 4,20 3,18`,o:10},{d:`M16,4 L15,2 12,1 10,1 7,2 5,5 4,10 4,15 5,19 7,21 10,22 11,22 14,21 16,19 17,16 17,15 16,12 14,10 11,9 10,9 7,10 5,12 4,15`,o:10},{d:`M17,1 L7,22 M3,1 L17,1`,o:10},{d:`M8,1 L5,2 4,4 4,6 5,8 7,9 11,10 14,11 16,13 17,15 17,18 16,20 15,21 12,22 8,22 5,21 4,20 3,18 3,15 4,13 6,11 9,10 13,9 15,8 16,6 16,4 15,2 12,1 8,1`,o:10},{d:`M16,8 L15,11 13,13 10,14 9,14 6,13 4,11 3,8 3,7 4,4 6,2 9,1 10,1 13,2 15,4 16,8 16,13 15,18 13,21 10,22 8,22 5,21 4,19`,o:10},{d:`M4,10 L3,11 4,12 5,11 4,10 M4,17 L3,18 4,19 5,18 4,17`,o:4},{d:`M4,10 L3,11 4,12 5,11 4,10 M5,18 L4,19 3,18 4,17 5,18 5,20 3,22`,o:4},{d:`M20,4 L4,13 20,22`,o:12},{d:`M4,10 L22,10 M4,16 L22,16`,o:13},{d:`M4,4 L20,13 4,22`,o:12},{d:`M3,6 L3,5 4,3 5,2 7,1 11,1 13,2 14,3 15,5 15,7 14,9 13,10 9,12 9,15 M9,20 L8,21 9,22 10,21 9,20`,o:9},{d:`M18,9 L17,7 15,6 12,6 10,7 9,8 8,11 8,14 9,16 11,17 14,17 16,16 17,14 M12,6 L10,8 9,11 9,14 10,16 11,17 M18,6 L17,14 17,16 19,17 21,17 23,15 24,12 24,10 23,7 22,5 20,3 18,2 15,1 12,1 9,2 7,3 5,5 4,7 3,10 3,13 4,16 5,18 7,20 9,21 12,22 15,22 18,21 20,20 21,19 M19,6 L18,14 18,16 19,17`,o:14},{d:`M9,1 L1,22 M9,1 L17,22 M4,15 L14,15`,o:9},{d:`M4,1 L4,22 M4,1 L13,1 16,2 17,3 18,5 18,7 17,9 16,10 13,11 M4,11 L13,11 16,12 17,13 18,15 18,18 17,20 16,21 13,22 4,22`,o:10},{d:`M18,6 L17,4 15,2 13,1 9,1 7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17`,o:11},{d:`M4,1 L4,22 M4,1 L11,1 14,2 16,4 17,6 18,9 18,14 17,17 16,19 14,21 11,22 4,22`,o:10},{d:`M4,1 L4,22 M4,1 L17,1 M4,11 L12,11 M4,22 L17,22`,o:9},{d:`M4,1 L4,22 M4,1 L17,1 M4,11 L12,11`,o:8},{d:`M18,6 L17,4 15,2 13,1 9,1 7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17 18,14 M13,14 L18,14`,o:11},{d:`M4,1 L4,22 M18,1 L18,22 M4,11 L18,11`,o:11},{d:`M4,1 L4,22`,o:4},{d:`M12,1 L12,17 11,20 10,21 8,22 6,22 4,21 3,20 2,17 2,15`,o:8},{d:`M4,1 L4,22 M18,1 L4,15 M9,10 L18,22`,o:10},{d:`M4,1 L4,22 M4,22 L16,22`,o:7},{d:`M4,1 L4,22 M4,1 L12,22 M20,1 L12,22 M20,1 L20,22`,o:12},{d:`M4,1 L4,22 M4,1 L18,22 M18,1 L18,22`,o:11},{d:`M9,1 L7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17 19,14 19,9 18,6 17,4 15,2 13,1 9,1`,o:11},{d:`M4,1 L4,22 M4,1 L13,1 16,2 17,3 18,5 18,8 17,10 16,11 13,12 4,12`,o:10},{d:`M9,1 L7,2 5,4 4,6 3,9 3,14 4,17 5,19 7,21 9,22 13,22 15,21 17,19 18,17 19,14 19,9 18,6 17,4 15,2 13,1 9,1 M12,18 L18,24`,o:11},{d:`M4,1 L4,22 M4,1 L13,1 16,2 17,3 18,5 18,7 17,9 16,10 13,11 4,11 M11,11 L18,22`,o:10},{d:`M17,4 L15,2 12,1 8,1 5,2 3,4 3,6 4,8 5,9 7,10 13,12 15,13 16,14 17,16 17,19 15,21 12,22 8,22 5,21 3,19`,o:10},{d:`M8,1 L8,22 M1,1 L15,1`,o:8},{d:`M4,1 L4,16 5,19 7,21 10,22 12,22 15,21 17,19 18,16 18,1`,o:11},{d:`M1,1 L9,22 M17,1 L9,22`,o:9},{d:`M2,1 L7,22 M12,1 L7,22 M12,1 L17,22 M22,1 L17,22`,o:12},{d:`M3,1 L17,22 M17,1 L3,22`,o:10},{d:`M1,1 L9,11 9,22 M17,1 L9,11`,o:9},{d:`M17,1 L3,22 M3,1 L17,1 M3,22 L17,22`,o:10},{d:`M4,-3 L4,29 M5,-3 L5,29 M4,-3 L11,-3 M4,29 L11,29`,o:7},{d:`M0,1 L14,25`,o:7},{d:`M9,-3 L9,29 M10,-3 L10,29 M3,-3 L10,-3 M3,29 L10,29`,o:7},{d:`M8,-1 L0,13 M8,-1 L16,13`,o:8},{d:`M0,29 L18,29`,o:9},{d:`M5,6 L3,8 3,10 4,11 5,10 4,9 3,10`,o:4},{d:`M15,8 L15,22 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M4,1 L4,22 M4,11 L6,9 8,8 11,8 13,9 15,11 16,14 16,16 15,19 13,21 11,22 8,22 6,21 4,19`,o:9},{d:`M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:9},{d:`M15,1 L15,22 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M3,14 L15,14 15,12 14,10 13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:9},{d:`M10,1 L8,1 6,2 5,5 5,22 M2,8 L9,8`,o:7},{d:`M15,8 L15,24 14,27 13,28 11,29 8,29 6,28 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M4,1 L4,22 M4,12 L7,9 9,8 12,8 14,9 15,12 15,22`,o:10},{d:`M3,1 L4,2 5,1 4,0 3,1 M4,8 L4,22`,o:4},{d:`M5,1 L6,2 7,1 6,0 5,1 M6,8 L6,25 5,28 3,29 1,29`,o:5},{d:`M4,1 L4,22 M14,8 L4,18 M8,14 L15,22`,o:8},{d:`M4,1 L4,22`,o:4},{d:`M4,8 L4,22 M4,12 L7,9 9,8 12,8 14,9 15,12 15,22 M15,12 L18,9 20,8 23,8 25,9 26,12 26,22`,o:15},{d:`M4,8 L4,22 M4,12 L7,9 9,8 12,8 14,9 15,12 15,22`,o:10},{d:`M8,8 L6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19 16,16 16,14 15,11 13,9 11,8 8,8`,o:10},{d:`M4,8 L4,29 M4,11 L6,9 8,8 11,8 13,9 15,11 16,14 16,16 15,19 13,21 11,22 8,22 6,21 4,19`,o:9},{d:`M15,8 L15,29 M15,11 L13,9 11,8 8,8 6,9 4,11 3,14 3,16 4,19 6,21 8,22 11,22 13,21 15,19`,o:10},{d:`M4,8 L4,22 M4,14 L5,11 7,9 9,8 12,8`,o:6},{d:`M14,11 L13,9 10,8 7,8 4,9 3,11 4,13 6,14 11,15 13,16 14,18 14,19 13,21 10,22 7,22 4,21 3,19`,o:9},{d:`M5,1 L5,18 6,21 8,22 10,22 M2,8 L9,8`,o:7},{d:`M4,8 L4,18 5,21 7,22 10,22 12,21 15,18 M15,8 L15,22`,o:10},{d:`M2,8 L8,22 M14,8 L8,22`,o:8},{d:`M3,8 L7,22 M11,8 L7,22 M11,8 L15,22 M19,8 L15,22`,o:11},{d:`M3,8 L14,22 M14,8 L3,22`,o:9},{d:`M2,8 L8,22 M14,8 L8,22 6,26 4,28 2,29 1,29`,o:8},{d:`M14,8 L3,22 M3,8 L14,8 M3,22 L14,22`,o:9},{d:`M9,-3 L7,-2 6,-1 5,1 5,3 6,5 7,6 8,8 8,10 6,12 M7,-2 L6,0 6,2 7,4 8,5 9,7 9,9 8,11 4,13 8,15 9,17 9,19 8,21 7,22 6,24 6,26 7,28 M6,14 L8,16 8,18 7,20 6,21 5,23 5,25 6,27 7,28 9,29`,o:7},{d:`M4,-3 L4,29`,o:4},{d:`M5,-3 L7,-2 8,-1 9,1 9,3 8,5 7,6 6,8 6,10 8,12 M7,-2 L8,0 8,2 7,4 6,5 5,7 5,9 6,11 10,13 6,15 5,17 5,19 6,21 7,22 8,24 8,26 7,28 M8,14 L6,16 6,18 7,20 8,21 9,23 9,25 8,27 7,28 5,29`,o:7},{d:`M3,16 L3,14 4,11 6,10 8,10 10,11 14,14 16,15 18,15 20,14 21,12 M3,14 L4,12 6,11 8,11 10,12 14,15 16,16 18,16 20,15 21,12 21,10`,o:12},{d:`M0,1 L0,22 1,22 1,1 2,1 2,22 3,22 3,1 4,1 4,22 5,22 5,1 6,1 6,22 7,22 7,1 8,1 8,22 9,22 9,1 10,1 10,22 11,22 11,1 12,1 12,22 13,22 13,1 14,1 14,22 15,22 15,1 16,1 16,22`,o:8}]},cachedMap=null;function parseHersheyPath(d){let polylines=[],cur=null;for(let tok of d.trim().split(/\s+/)){let s=tok,cmd=``;(s[0]===`M`||s[0]===`L`)&&(cmd=s[0],s=s.slice(1));let comma=s.indexOf(`,`);if(comma<0)continue;let x=parseFloat(s.slice(0,comma)),y=parseFloat(s.slice(comma+1));Number.isNaN(x)||Number.isNaN(y)||(cmd===`M`?(cur=[[x,y]],polylines.push(cur)):cur?cur.push([x,y]):(cur=[[x,y]],polylines.push(cur)))}return polylines}function loadHersheyFont(data=FUTURAL){if(cachedMap&&data===FUTURAL)return cachedMap;if(!data||!Array.isArray(data.chars))return null;let rawGlyphs=data.chars.map(c=>({polylines:parseHersheyPath(c.d||``),o:c.o})),capTop=1/0,baseline=-1/0,measure=code=>{let g=rawGlyphs[code-33];if(!g)return!1;let found=!1;for(let pl of g.polylines)for(let p of pl)p[1]<capTop&&(capTop=p[1]),p[1]>baseline&&(baseline=p[1]),found=!0;return found};measure(72)||measure(69)||measure(88)||measure(73),(!Number.isFinite(capTop)||!Number.isFinite(baseline)||baseline<=capTop)&&(capTop=4,baseline=21);let capHeight=baseline-capTop,gap=capHeight*.14,map=new Map;for(let i=0;i<rawGlyphs.length;i++){let g=rawGlyphs[i],minX=1/0,maxX=-1/0;for(let pl of g.polylines)for(let p of pl)p[0]<minX&&(minX=p[0]),p[0]>maxX&&(maxX=p[0]);let hasPoints=Number.isFinite(minX),left=hasPoints?minX:0,width=hasPoints?maxX-minX:g.o,polylines=g.polylines.map(pl=>pl.map(([x,y])=>[(x-left)/capHeight,(baseline-y)/capHeight]));map.set(33+i,{polylines,advance:(width+gap)/capHeight})}return data===FUTURAL&&(cachedMap=map),map}export{loadHersheyFont};
|
|
@@ -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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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
|
|
338
|
+
*/const require_hersheyFont=require("./hersheyFont.js"),require_textToStrokeOrderStrokes=require("./textToStrokeOrderStrokes.js"),require_Controller=require("./Controller.js");var WordPassPlugin=(five,params)=>new require_Controller.Controller(five,params);exports.WordPassPlugin=WordPassPlugin,exports.loadHersheyFont=require_hersheyFont.loadHersheyFont,exports.textToStrokeOrderStrokes=require_textToStrokeOrderStrokes.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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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{loadHersheyFont
|
|
338
|
+
*/import{loadHersheyFont}from"./hersheyFont.mjs";import{textToStrokeOrderStrokes}from"./textToStrokeOrderStrokes.mjs";import{Controller}from"./Controller.mjs";var WordPassPlugin=(five,params)=>new Controller(five,params);export{WordPassPlugin,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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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
|
-
*/const
|
|
339
|
-
`){
|
|
338
|
+
*/const require_runtime=require("../../_virtual/_rolldown/runtime.js"),require_hersheyFont=require("./hersheyFont.js");let tslib=require("tslib"),three_webgpu=require("three/webgpu");three_webgpu=require_runtime.__toESM(three_webgpu,1);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(0,tslib.__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(0,tslib.__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=require_hersheyFont.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_webgpu.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_webgpu.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_webgpu.Vector3:position,N=(normal==null?new three_webgpu.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_webgpu.Vector3().crossVectors(up,N).normalize();else{let ref=Math.abs(N.y)>.99?new three_webgpu.Vector3(0,0,-1):new three_webgpu.Vector3(0,1,0);right=new three_webgpu.Vector3().crossVectors(ref,N).normalize(),up=new three_webgpu.Vector3().crossVectors(N,right).normalize()}let toVec3=p=>new three_webgpu.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_webgpu.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_webgpu.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_webgpu.Vector3,b=new three_webgpu.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_webgpu.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_webgpu.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}exports.textToStrokeOrderStrokes=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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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,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);active&&(this.uTime+=deltaTime==null?0:deltaTime,this._emit(deltaTime==null?0:deltaTime));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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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,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);active&&(this.uTime+=deltaTime==null?0:deltaTime,this._emit(deltaTime==null?0:deltaTime));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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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/3
|
|
5
|
+
* Version: 1.0.0-alpha.14
|
|
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;
|