@realsee/five 6.8.0-alpha.5 → 6.8.0-alpha.7

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.
Files changed (243) hide show
  1. package/README.md +2 -5
  2. package/ai_guides/README.md +5 -0
  3. package/ai_guides/api.md +13 -0
  4. package/ai_guides/features/flowing-light-2d-pass.md +218 -0
  5. package/ai_guides/features/flowing-light-3d-pass.md +240 -0
  6. package/ai_guides/features/gaussian-blur-pass.md +202 -0
  7. package/ai_guides/features/load-external-model.md +16 -0
  8. package/ai_guides/features/load-progress.md +140 -0
  9. package/ai_guides/features/parameter.md +7 -0
  10. package/ai_guides/features/postprocessing.md +35 -2
  11. package/ai_guides/features/raycast.md +9 -0
  12. package/ai_guides/features/view-layer.md +8 -3
  13. package/ai_guides/features/work.md +17 -0
  14. package/ai_guides/glossary.md +17 -0
  15. package/ai_guides/release_notes/6.8.md +81 -0
  16. package/docs/assets/hierarchy.js +1 -1
  17. package/docs/assets/navigation.js +1 -1
  18. package/docs/assets/search.js +1 -1
  19. package/docs/classes/five.AdaptiveLuminancePass.html +1 -1
  20. package/docs/classes/five.BoundingMesh.html +1 -1
  21. package/docs/classes/five.Camera.html +1 -1
  22. package/docs/classes/five.EyeDomeLightingPass.html +1 -1
  23. package/docs/classes/five.Five.html +71 -71
  24. package/docs/classes/five.FivePass.html +1 -1
  25. package/docs/classes/five.InternalWebGLRenderer.html +1 -1
  26. package/docs/classes/five.Model.html +31 -31
  27. package/docs/classes/five.ModelScene.html +1 -1
  28. package/docs/classes/five.NetworkSubscribe.html +1 -1
  29. package/docs/classes/five.PBMContainer.html +1 -1
  30. package/docs/classes/five.PBMGSObject.html +1 -1
  31. package/docs/classes/five.PBMGroup.html +1 -1
  32. package/docs/classes/five.PBMMesh.html +1 -1
  33. package/docs/classes/five.PBMMeshMaterial.html +1 -1
  34. package/docs/classes/five.PBMPointCloud.html +1 -1
  35. package/docs/classes/five.PBMPointCloudMaterial.html +1 -1
  36. package/docs/classes/five.PBMSkinnedMesh.html +1 -1
  37. package/docs/classes/five.PanoCircleMesh.html +1 -1
  38. package/docs/classes/five.PanoCircleMeshCustom.html +1 -1
  39. package/docs/classes/five.PanoCircleMeshSolid.html +1 -1
  40. package/docs/classes/five.Parameter.html +1 -1
  41. package/docs/classes/five.Scene.html +1 -1
  42. package/docs/classes/five.Subscribe.html +1 -1
  43. package/docs/classes/five.Tile.html +1 -1
  44. package/docs/classes/five.Tile3D.html +30 -26
  45. package/docs/classes/five.TileNode.html +1 -1
  46. package/docs/classes/five.Trajectory.html +1 -1
  47. package/docs/classes/five.TrajectoryNode.html +1 -1
  48. package/docs/classes/five.Work.html +16 -16
  49. package/docs/classes/five.WorkResolvedObserver.html +27 -2
  50. package/docs/classes/gltf-loader.DDSLoader.html +1 -1
  51. package/docs/classes/gltf-loader.DRACOLoader.html +1 -1
  52. package/docs/classes/gltf-loader.GLTFLoader.html +1 -1
  53. package/docs/classes/gltf-loader.GLTFObject.html +1 -1
  54. package/docs/classes/gltf-loader.THREEGLTFLoader.html +1 -1
  55. package/docs/classes/line.Line.html +1 -1
  56. package/docs/classes/line.LineGeometry.html +1 -1
  57. package/docs/classes/line.LineMaterial.html +1 -1
  58. package/docs/classes/line.LineSegmentsGeometry.html +1 -1
  59. package/docs/classes/line.THREE_Line2.html +1 -1
  60. package/docs/classes/line.THREE_LineSegments2.html +1 -1
  61. package/docs/classes/plugins.BasePlugin.Controller.html +1 -1
  62. package/docs/classes/plugins.RoundedBoxGeometry.html +1 -1
  63. package/docs/classes/sticker.Sticker.html +1 -1
  64. package/docs/classes/vfx.Airflow.html +1 -1
  65. package/docs/classes/vfx.Flame.html +1 -1
  66. package/docs/classes/vfx.Particle.html +1 -1
  67. package/docs/classes/vfx.ParticleGPU.html +1 -1
  68. package/docs/classes/vfx.SpotLight.html +1 -1
  69. package/docs/documents/README.html +5 -0
  70. package/docs/documents/api.html +28 -3
  71. package/docs/documents/features_flowing-light-2d-pass.html +124 -0
  72. package/docs/documents/features_flowing-light-3d-pass.html +129 -0
  73. package/docs/documents/features_gaussian-blur-pass.html +182 -0
  74. package/docs/documents/features_load-external-model.html +19 -2
  75. package/docs/documents/features_load-progress.html +110 -0
  76. package/docs/documents/features_parameter.html +7 -0
  77. package/docs/documents/features_postprocessing.html +17 -3
  78. package/docs/documents/features_raycast.html +1 -1
  79. package/docs/documents/features_view-layer.html +9 -3
  80. package/docs/documents/features_work.html +1 -1
  81. package/docs/documents/glossary.html +21 -1
  82. package/docs/documents/release_notes_6.8.html +92 -0
  83. package/docs/functions/five.loadAt3d.html +1 -1
  84. package/docs/functions/five.loadB3dm.html +1 -1
  85. package/docs/functions/five.loadDome.html +1 -1
  86. package/docs/functions/five.loadDomez.html +1 -1
  87. package/docs/functions/five.loadFbx.html +1 -1
  88. package/docs/functions/five.loadGltf.html +1 -1
  89. package/docs/functions/five.loadPbm.html +1 -1
  90. package/docs/functions/five.loadPly.html +1 -1
  91. package/docs/functions/five.loadPnts.html +1 -1
  92. package/docs/functions/five.loadSplat.html +1 -1
  93. package/docs/functions/five.loadSpz.html +1 -1
  94. package/docs/functions/five.loadX3p.html +1 -1
  95. package/docs/functions/five.parseWork.html +1 -1
  96. package/docs/functions/vue.useFiveWorks.html +2 -2
  97. package/docs/hierarchy.html +1 -1
  98. package/docs/index.html +5 -0
  99. package/docs/interfaces/five.AddableObject.html +1 -1
  100. package/docs/interfaces/five.AjaxOptions.html +1 -1
  101. package/docs/interfaces/five.BaseEvent.html +2 -2
  102. package/docs/interfaces/five.EventCallback.html +15 -11
  103. package/docs/interfaces/five.GestureEvent.html +2 -2
  104. package/docs/interfaces/five.ImageOptions.html +1 -1
  105. package/docs/interfaces/five.IntersectEvent.html +2 -2
  106. package/docs/interfaces/five.IntersectMesh.html +1 -1
  107. package/docs/interfaces/five.IntersectMeshInterface.html +1 -1
  108. package/docs/interfaces/five.Intersection.html +4 -3
  109. package/docs/interfaces/five.LooseWorkWithExtrinsics.html +6 -6
  110. package/docs/interfaces/five.ModeChangeEvent.html +2 -2
  111. package/docs/interfaces/five.ModelControllerCustomInitArgs.html +1 -1
  112. package/docs/interfaces/five.ModelEvent.html +2 -2
  113. package/docs/interfaces/five.ModelSceneEvent.html +2 -2
  114. package/docs/interfaces/five.ModelTileEvent.html +8 -0
  115. package/docs/interfaces/five.MovePanoOptions.html +1 -1
  116. package/docs/interfaces/five.NetworkAbortError.html +1 -1
  117. package/docs/interfaces/five.NetworkFirbiddenError.html +1 -1
  118. package/docs/interfaces/five.NetworkOptions.html +1 -1
  119. package/docs/interfaces/five.NetworkProxyError.html +1 -1
  120. package/docs/interfaces/five.NetworkResourceEvent.html +2 -2
  121. package/docs/interfaces/five.NetworkResponseError.html +1 -1
  122. package/docs/interfaces/five.NetworkTimeoutError.html +1 -1
  123. package/docs/interfaces/five.ObjectEvent.html +2 -2
  124. package/docs/interfaces/five.PBMMaterial.html +1 -1
  125. package/docs/interfaces/five.PBMMeshMaterialParameters.html +1 -1
  126. package/docs/interfaces/five.PBMPointCloudMaterialParameters.html +1 -1
  127. package/docs/interfaces/five.PanoCircleMeshInterface.html +1 -1
  128. package/docs/interfaces/five.PanoEvent.html +2 -2
  129. package/docs/interfaces/five.PanoTextureEvent.html +2 -2
  130. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +1 -1
  131. package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +1 -1
  132. package/docs/interfaces/five.ParameterMaterialValue.html +1 -1
  133. package/docs/interfaces/five.ParameterTilesetValue.html +1 -1
  134. package/docs/interfaces/five.ParameterValue.html +1 -1
  135. package/docs/interfaces/five.Pose.html +1 -1
  136. package/docs/interfaces/five.RenderEvent.html +2 -2
  137. package/docs/interfaces/five.ResolvedParameterValue.html +1 -1
  138. package/docs/interfaces/five.State.html +1 -1
  139. package/docs/interfaces/five.StateEvent.html +2 -2
  140. package/docs/interfaces/five.TextureOptions.html +1 -1
  141. package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +1 -1
  142. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +1 -1
  143. package/docs/interfaces/five.ViewLayer.html +30 -26
  144. package/docs/interfaces/five.WorkCubeImage.html +1 -1
  145. package/docs/interfaces/five.WorkImage.html +1 -1
  146. package/docs/interfaces/five.WorkModel.html +8 -8
  147. package/docs/interfaces/five.WorkModelLayer.html +6 -6
  148. package/docs/interfaces/five.WorkObserver.html +27 -2
  149. package/docs/interfaces/five.WorkTile.html +1 -1
  150. package/docs/interfaces/five.WorksEvent.html +2 -2
  151. package/docs/interfaces/five.XRControllerEvent.html +2 -2
  152. package/docs/interfaces/five.XRGestureEvent.html +2 -2
  153. package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +1 -1
  154. package/docs/interfaces/five.XRSessionEvent.html +2 -2
  155. package/docs/interfaces/plugins.BackgroundPluginController.html +1 -1
  156. package/docs/interfaces/plugins.BackgroundPluginType.EventMap.html +1 -1
  157. package/docs/interfaces/plugins.BasePlugin.State.html +1 -1
  158. package/docs/interfaces/plugins.DynamicPathLinePluginController.html +1 -1
  159. package/docs/interfaces/plugins.DynamicPathLinePluginType.EventMap.html +1 -1
  160. package/docs/interfaces/plugins.DynamicPathLinePluginType.State.html +1 -1
  161. package/docs/interfaces/plugins.ItemMaskController.html +1 -1
  162. package/docs/interfaces/plugins.ItemMaskPluginType.EventMap.html +1 -1
  163. package/docs/interfaces/plugins.ItemMaskPluginType.State.html +1 -1
  164. package/docs/interfaces/plugins.OrientationPluginController.html +1 -1
  165. package/docs/interfaces/plugins.OrientationPluginType.EventMap.html +1 -1
  166. package/docs/interfaces/plugins.OrientationPluginType.State.html +1 -1
  167. package/docs/interfaces/plugins.PanoAnimeController.html +1 -1
  168. package/docs/interfaces/plugins.PanoAnimePluginType.EventMap.html +1 -1
  169. package/docs/interfaces/plugins.PanoAnimePluginType.State.html +1 -1
  170. package/docs/interfaces/plugins.PluginTemplateType.EventMap.html +1 -1
  171. package/docs/interfaces/plugins.PluginTemplateType.State.html +1 -1
  172. package/docs/interfaces/plugins.TrajectoryController.html +1 -1
  173. package/docs/interfaces/react.FiveInjectionTypes.html +13 -13
  174. package/docs/modules/five.html +1 -1
  175. package/docs/modules.html +1 -1
  176. package/docs/types/five.EventTypes.html +12 -10
  177. package/docs/types/five.NetworkProgressCallback.html +1 -1
  178. package/docs/types/five.ParseOptions.html +6 -6
  179. package/docs/types/plugins.BasePlugin.EventMap.html +1 -1
  180. package/five/application/events.d.ts +5 -1
  181. package/five/declare.d.ts +2 -1
  182. package/five/index.d.ts +1 -1
  183. package/five/index.js +429 -73
  184. package/five/index.mjs +5385 -4485
  185. package/five/model/intersection.d.ts +2 -0
  186. package/five/model/loaders/at3d.d.ts +1 -0
  187. package/five/model/loaders/b3dm.d.ts +1 -0
  188. package/five/model/loaders/dome.d.ts +1 -0
  189. package/five/model/loaders/domez.d.ts +1 -0
  190. package/five/model/loaders/fbx.d.ts +1 -0
  191. package/five/model/loaders/glTF-helpers/extensions/KHR_animation_pointer.d.ts +6 -0
  192. package/five/model/loaders/glTF-helpers/extensions/KHR_node_visibility.d.ts +6 -0
  193. package/five/model/loaders/glTF-helpers/index.d.ts +4 -0
  194. package/five/model/loaders/gltf.d.ts +1 -0
  195. package/five/model/loaders/obj.d.ts +1 -0
  196. package/five/model/loaders/pbm.d.ts +1 -0
  197. package/five/model/loaders/ply.d.ts +1 -0
  198. package/five/model/loaders/pnts.d.ts +1 -0
  199. package/five/model/loaders/splat.d.ts +1 -0
  200. package/five/model/loaders/spz.d.ts +1 -0
  201. package/five/model/loaders/x3p.d.ts +1 -0
  202. package/five/model/model.d.ts +26 -1
  203. package/five/model/tile3d/index.d.ts +5 -1
  204. package/five/model/tile3d/tile.d.ts +1 -0
  205. package/five/model/tile3d/trajectory.d.ts +1 -0
  206. package/five/model/view-layer.d.ts +1 -2
  207. package/five/renderer/postprocessing/index.d.ts +2 -0
  208. package/five/renderer/postprocessing/passes/flowing-light-2d-pass.d.ts +22 -0
  209. package/five/renderer/postprocessing/passes/flowing-light-3d-pass.d.ts +22 -0
  210. package/five/renderer/postprocessing/passes/gaussian-blur-pass.d.ts +1 -0
  211. package/five/utils/ajax.d.ts +1 -1
  212. package/five/utils/event.d.ts +6 -0
  213. package/five/work/work.d.ts +35 -2
  214. package/five/work/workObserverUtils.d.ts +36 -0
  215. package/gltf-loader/index.js +3 -3
  216. package/gltf-loader/index.mjs +3 -3
  217. package/line/index.js +3 -3
  218. package/line/index.mjs +3 -3
  219. package/llms.txt +5 -0
  220. package/package.json +1 -1
  221. package/plugins/index.js +2 -2
  222. package/plugins/index.mjs +2 -2
  223. package/react/index.js +2 -2
  224. package/react/index.mjs +2 -2
  225. package/shader-lib/index.js +2 -2
  226. package/shader-lib/index.mjs +2 -2
  227. package/sticker/index.js +3 -3
  228. package/sticker/index.mjs +3 -3
  229. package/umd/five-gltf-loader.js +3 -3
  230. package/umd/five-line.js +3 -3
  231. package/umd/five-plugins.js +2 -2
  232. package/umd/five-react.js +2 -2
  233. package/umd/five-shader-lib.js +2 -2
  234. package/umd/five-sticker.js +3 -3
  235. package/umd/five-vfx.js +2 -2
  236. package/umd/five-vue.js +2 -2
  237. package/umd/five.js +429 -73
  238. package/vfx/index.js +2 -2
  239. package/vfx/index.mjs +2 -2
  240. package/vue/index.js +2 -2
  241. package/vue/index.mjs +2 -2
  242. package/work-downloader/index.js +2 -2
  243. package/work-downloader/index.mjs +2 -2
package/README.md CHANGED
@@ -5,11 +5,8 @@
5
5
  贝壳如视三维渲染框架
6
6
 
7
7
  > **🤖 For AI Assistants (Copilot, Cursor, etc.):**
8
- > This package includes a **comprehensive local documentation suite** optimized for LLMs.
9
- > Please **READ** `node_modules/@realsee/five/ai_guides/README.md` as your primary source of truth before searching the web.
10
- > It contains the full API reference, feature guides, and best practices.
11
- > This package is self-documented. Please refer to `llms.txt` and the `ai_guides/` directory for the most accurate and up-to-date information.
12
-
8
+ > If this package is installed in your project, you can find **AI-friendly documentation** directly in `node_modules/@realsee/five/`. Please **READ** `node_modules/@realsee/five/ai_guides/README.md` as your primary source of truth. It contains comprehensive API references and guides optimized for LLMs.
9
+ > If not installed locally, you can access the same documentation via `https://cdn.jsdelivr.net/npm/@realsee/five@alpha/ai_guides/README.md` or `https://unpkg.com/@realsee/five@alpha/ai_guides/README.md`.
13
10
  ## Introduction
14
11
 
15
12
  **Five** 是 [贝壳如视(realsee.com)](https://realsee.com) 提供的在浏览器中运行的三维空间渲染 Javascript SDK。基于 [Three.js](https://threejs.org/) 开发,帮助开发者在浏览器中构建高质量的 VR 看房与空间交互应用。
@@ -62,6 +62,7 @@
62
62
  数据加载与资源管理配置。
63
63
 
64
64
  * [Load External Model](./features/load-external-model.md): 加载外部 3D 模型 (GLTF, OBJ 等)。
65
+ * [Load Progress](./features/load-progress.md): 监控模型与全景图的加载进度 (Loaded/Refined)。
65
66
  * [Multi-Work (Sandbox)](./features/multi-work.md): 多 Work 加载与沙盘场景管理。
66
67
  * [Request Proxy](./features/request-proxy.md): 请求拦截与代理 (CDN 替换、鉴权)。
67
68
  * [Image Options](./features/image-options.md): 图片资源配置 (CDN, 格式, 尺寸)。
@@ -72,6 +73,9 @@
72
73
  * [Pano Tile](./features/pano-tile.md): 全景瓦片渲染机制(高分辨率分片加载)。
73
74
  * [Model](./features/model.md): 内置模型渲染 (Mesh/Geometry)。
74
75
  * [Postprocessing](./features/postprocessing.md): 后处理效果 (Pass, EffectComposer)。
76
+ * [Flowing Light 2D Pass](./features/flowing-light-2d-pass.md): 屏幕空间流光特效。
77
+ * [Flowing Light 3D Pass](./features/flowing-light-3d-pass.md): 基于模型深度的流光特效。
78
+ * [Gaussian Blur Pass](./features/gaussian-blur-pass.md): 高斯模糊特效。
75
79
  * [Material](./features/material.md): 材质参数配置 (透明度、点云大小、顶点标记)。
76
80
  * [Get Screen Pixels](./features/get-screen-pixels.md): 获取屏幕像素 (放大镜/截图)。
77
81
  * [Move Pano Effect](./features/move-pano-effect.md): 全景点位切换的过渡效果。
@@ -98,6 +102,7 @@
98
102
  * [Support](./support.md): 浏览器兼容性。
99
103
  * [AI Documentation Guidelines](./ai-doc-guidelines.md): AI 文档编写与维护规范 (必读)。
100
104
  * Release Notes: 版本更新记录。
105
+ * [6.8](./release_notes/6.8.md)
101
106
  * [6.7](./release_notes/6.7.md)
102
107
  * [6.6](./release_notes/6.6.md)
103
108
 
package/ai_guides/api.md CHANGED
@@ -139,6 +139,16 @@ Get pixel data from the renderer (e.g. for color picking or magnifier).
139
139
  - **raycaster**: `THREE.Raycaster`.
140
140
  - **returns**: `THREE.Intersection[]`.
141
141
 
142
+ ### `addPass(pass)`
143
+ Add a post-processing pass to the rendering chain.
144
+
145
+ - **pass**: `FivePass` instance (e.g. `Gaussian Blur Pass`).
146
+
147
+ ### `removePass(pass)`
148
+ Remove a post-processing pass from the rendering chain.
149
+
150
+ - **pass**: `FivePass` instance to remove.
151
+
142
152
  ### `dispose()`
143
153
  Destroys the Five instance and releases resources.
144
154
 
@@ -223,7 +233,10 @@ These events follow a standard naming convention and provide typed event objects
223
233
  | :--- | :--- | :--- |
224
234
  | `works.load` | Triggered when work data starts loading. | `WorksEvent` |
225
235
  | `models.load` | Triggered when models are loaded. | `ModelSceneEvent` |
236
+ | `model.tileLoad` | Triggered when a 3D tile is loaded. | `Tile` |
237
+ | `model.tileUnload` | Triggered when a 3D tile is unloaded. | `Tile` |
226
238
  | `pano.arrived` | Triggered when arrival at a panorama node. | `PanoEvent` |
239
+ | `pano.texture.progress` | Triggered when panorama texture loading progresses. | `{ progress, panoIndex }` |
227
240
  | `render` | Triggered after each render frame. | `RenderEvent` |
228
241
  | `error` | Triggered on internal errors. | `Error` |
229
242
 
@@ -0,0 +1,218 @@
1
+ # Flowing Light 2D Pass (流光 2D 通道)
2
+
3
+ - **Summary**: `FlowingLight2DPass` 提供屏幕空间的流光(光带)特效,沿着 2D 路径点绘制动态光流,适用于突出导航路径、指示线或动态路径演示。
4
+ - **Schema**: `FlowingLight2DPass` 类及 Line 数据结构。
5
+ - **Concepts**: 后处理通道、屏幕空间光带、路径数据驱动、时间动画。
6
+ - **Configuration**: 路径点集合、颜色、不透明度、动画时长。
7
+ - **Examples**: 基础集成、多条路径、动态更新。
8
+
9
+ ## Schema
10
+
11
+ > **Definition**: [FlowingLight2DPass](../../five/renderer/postprocessing/passes/flowing-light-2d-pass.d.ts)
12
+
13
+ `FlowingLight2DPass` 是 `FivePass` 的子类,核心接口如下:
14
+
15
+ ```ts
16
+ import * as THREE from 'three';
17
+ import { FivePass } from './pass';
18
+ import { type Camera } from '../../../core/camera';
19
+
20
+ type Line = {
21
+ points: THREE.Vector2[]; // 屏幕空间路径点 [x, y]
22
+ totalLength: number; // 路径总长度(像素)
23
+ color: THREE.Color; // 光带颜色
24
+ opacity?: number; // 光带不透明度(0-1)
25
+ duration?: number; // 动画时长(毫秒)
26
+ };
27
+
28
+ export class FlowingLight2DPass extends FivePass {
29
+ constructor(camera: Camera);
30
+
31
+ // 设置要渲染的路径列表
32
+ public setLines(lines: Line[]): void;
33
+
34
+ public render(
35
+ renderer: THREE.WebGLRenderer,
36
+ writeBuffer: THREE.WebGLRenderTarget,
37
+ readBuffer: THREE.WebGLRenderTarget,
38
+ deltaTime: number,
39
+ maskActive?: boolean,
40
+ ): void;
41
+
42
+ public dispose(): void;
43
+ }
44
+ ```
45
+
46
+ ## Concepts
47
+
48
+ ### 屏幕空间路径 (Screen-space Lines)
49
+ 路径点在屏幕坐标系中定义(像素单位),不受 3D 场景变化影响。光流沿路径顶点顺序流动,自动计算相邻顶点间距离。
50
+
51
+ ### 时间驱动光头 (Time-driven Head)
52
+ 光带"头部"根据 `duration` 和经过时间循环移动。`duration` 定义一个完整周期(从起点到终点再回到起点)所需的毫秒数。光带尾部长度固定为路径总长的 1/4。
53
+
54
+ ### 数据纹理驱动 (Data Texture)
55
+ 路径数据编码为 Float32 纹理上传到 GPU,使 shader 能高效计算光效。支持同时渲染多条路径。
56
+
57
+ ## Configuration
58
+
59
+ ### Line 配置参数
60
+
61
+ | Parameter | Type | Required | Default | Description |
62
+ | :--- | :--- | :--- | :--- | :--- |
63
+ | `points` | `THREE.Vector2[]` | ✓ | - | 屏幕空间路径点数组。至少 2 个点。 |
64
+ | `totalLength` | `number` | ✓ | - | 路径总长度(像素)。通常为所有相邻点间距离之和。 |
65
+ | `color` | `THREE.Color` | ✓ | - | 光带颜色(RGB)。 |
66
+ | `opacity` | `number` | | `1` | 光带不透明度(0-1)。控制与背景的混合强度。 |
67
+ | `duration` | `number` | | `1000` | 动画周期(毫秒)。光头从路径起点完成一个周期的时长。 |
68
+
69
+ > **注意**: `totalLength` 应精确计算。若传入错误值,光流速度会显著偏差。
70
+
71
+ ## Instance Methods
72
+
73
+ ### `constructor(camera: Camera)`
74
+ 初始化 Pass,需传入相机以获取屏幕分辨率。
75
+
76
+ ### `setLines(lines: Line[])`
77
+ 更新要渲染的路径列表。可随时调用以修改或新增路径。
78
+
79
+ **示例**:
80
+ ```ts
81
+ const pathLine: Line = {
82
+ points: [
83
+ new THREE.Vector2(100, 100),
84
+ new THREE.Vector2(300, 150),
85
+ new THREE.Vector2(500, 100),
86
+ ],
87
+ totalLength: 400, // 实际路径总长度
88
+ color: new THREE.Color(0x00c2ff),
89
+ opacity: 0.8,
90
+ duration: 2000,
91
+ };
92
+ pass.setLines([pathLine]);
93
+ ```
94
+
95
+ ### `render(...)`
96
+ 由 EffectComposer 自动调用,无需手动调用。
97
+
98
+ ### `dispose()`
99
+ 释放着色材质和纹理资源,避免内存泄漏。销毁 Pass 时必须调用。
100
+
101
+ ## Examples
102
+
103
+ ### 快速上手 (Quick Example)
104
+
105
+ ```ts
106
+ import { Five } from '@realsee/five';
107
+ import { FlowingLight2DPass } from '../../lib/five/renderer/postprocessing';
108
+ import * as THREE from 'three';
109
+
110
+ const five = new Five();
111
+
112
+ // 创建 2D 流光通道
113
+ const flowing2D = new FlowingLight2DPass(five.camera);
114
+
115
+ // 定义一条屏幕空间的路径
116
+ const path = [
117
+ new THREE.Vector2(100, 100),
118
+ new THREE.Vector2(300, 200),
119
+ new THREE.Vector2(500, 100),
120
+ new THREE.Vector2(700, 250),
121
+ ];
122
+ const totalLen = 600; // 近似路径长度
123
+
124
+ flowing2D.setLines([{
125
+ points: path,
126
+ totalLength: totalLen,
127
+ color: new THREE.Color(0x00ff00),
128
+ opacity: 0.9,
129
+ duration: 2000,
130
+ }]);
131
+
132
+ five.addPass(flowing2D);
133
+
134
+ function animate() {
135
+ requestAnimationFrame(animate);
136
+ five.render();
137
+ }
138
+ animate();
139
+ ```
140
+
141
+ ### 多条路径 & 动态更新
142
+
143
+ ```ts
144
+ const pass = new FlowingLight2DPass(five.camera);
145
+
146
+ // 初始路径集合
147
+ const paths = [
148
+ {
149
+ points: [...],
150
+ totalLength: 500,
151
+ color: new THREE.Color(0xff6600),
152
+ duration: 1500,
153
+ },
154
+ {
155
+ points: [...],
156
+ totalLength: 400,
157
+ color: new THREE.Color(0x0066ff),
158
+ opacity: 0.7,
159
+ duration: 2000,
160
+ },
161
+ ];
162
+
163
+ pass.setLines(paths);
164
+ five.addPass(pass);
165
+
166
+ // 响应用户交互动态更新路径
167
+ document.addEventListener('click', (e) => {
168
+ const newPath = {
169
+ points: [/* 鼠标点击生成的路径点 */],
170
+ totalLength: 300,
171
+ color: new THREE.Color(Math.random() * 0xffffff),
172
+ duration: 1200,
173
+ };
174
+ pass.setLines([...paths, newPath]);
175
+ });
176
+ ```
177
+
178
+ ### 计算路径总长度
179
+
180
+ ```ts
181
+ function calculatePathLength(points: THREE.Vector2[]): number {
182
+ let length = 0;
183
+ for (let i = 1; i < points.length; i++) {
184
+ length += points[i].distanceTo(points[i - 1]);
185
+ }
186
+ return length;
187
+ }
188
+
189
+ const pathLine = {
190
+ points: [...],
191
+ totalLength: calculatePathLength(points),
192
+ color: new THREE.Color(0x00ffff),
193
+ duration: 2000,
194
+ };
195
+ ```
196
+
197
+ ## Debugging
198
+
199
+ - **光带不出现**:检查 `color` 和 `opacity`,确保非全透明;验证 `points` 至少 2 个。
200
+ - **流速不对**:检查 `totalLength` 计算是否准确;若流速过快/过慢,调整 `duration`。
201
+ - **性能问题**:降低路径点数或使用更简单的路径。
202
+
203
+ ## Common Pitfalls
204
+
205
+ 1. **totalLength 计算错误**:光流速度直接依赖 `totalLength`。手动计算时务必精确。
206
+ 2. **屏幕坐标系混淆**:`points` 使用屏幕坐标(原点通常在左下角),不是 Canvas 默认坐标系。
207
+ 3. **未及时 dispose()**:移除 Pass 时必须调用 `dispose()`,否则 GPU 纹理资源泄漏。
208
+
209
+ ## Related
210
+
211
+ * [Postprocessing](./postprocessing.md): 后处理通用概念与 EffectComposer 使用指南。
212
+ * [Flowing Light 3D Pass](./flowing-light-3d-pass.md): 基于 3D 世界坐标的流光效果。
213
+
214
+ ---
215
+
216
+ ```yaml
217
+ tags: [postprocessing, effect, flowing, light, pass, rendering, screenspace]
218
+ ```
@@ -0,0 +1,240 @@
1
+ # Flowing Light 3D Pass (流光 3D 通道)
2
+
3
+ - **Summary**: `FlowingLight3DPass` 基于 3D 世界坐标绘制流光效果,自动投影到屏幕空间,适合沿模型表面、路径或空间轨迹演示动态流动光带。
4
+ - **Schema**: `FlowingLight3DPass` 类及 Line 数据结构。
5
+ - **Concepts**: 基于相机投影的 3D 光带、世界坐标到屏幕坐标映射、动画驱动。
6
+ - **Configuration**: 3D 路径点、颜色、不透明度、动画周期。
7
+ - **Examples**: 空间轨迹演示、结合相机动画、多条 3D 路径。
8
+
9
+ ## Schema
10
+
11
+ > **Definition**: [FlowingLight3DPass](../../five/renderer/postprocessing/passes/flowing-light-3d-pass.d.ts)
12
+
13
+ `FlowingLight3DPass` 继承自 `FivePass`,支持投影到当前相机视锥。核心接口如下:
14
+
15
+ ```ts
16
+ import * as THREE from 'three';
17
+ import { FivePass } from './pass';
18
+ import { type Camera } from '../../../core/camera';
19
+
20
+ type Line = {
21
+ points: THREE.Vector3[]; // 世界坐标系路径点
22
+ totalLength: number; // 路径总长度(世界单位)
23
+ color: THREE.Color; // 光带颜色
24
+ opacity?: number; // 光带不透明度(0-1)
25
+ duration?: number; // 动画周期(毫秒)
26
+ };
27
+
28
+ export class FlowingLight3DPass extends FivePass {
29
+ constructor(camera: Camera);
30
+
31
+ // 设置要渲染的路径列表
32
+ public setLines(lines: Line[]): void;
33
+
34
+ public render(
35
+ renderer: THREE.WebGLRenderer,
36
+ writeBuffer: THREE.WebGLRenderTarget,
37
+ readBuffer: THREE.WebGLRenderTarget,
38
+ deltaTime: number,
39
+ maskActive?: boolean,
40
+ ): void;
41
+
42
+ public dispose(): void;
43
+ }
44
+ ```
45
+
46
+ ## Concepts
47
+
48
+ ### 世界空间路径与投影 (World-space Projection)
49
+ 路径点定义在 3D 世界坐标系中。Pass 内部自动根据当前相机投影矩阵将 3D 点映射到屏幕空间,从而实现"随相机变化"的动态光带效果。
50
+
51
+ ### 循环流动 (Looping Flow)
52
+ 默认使用循环模式(`LOOP = true`),光头在路径上循环流动,无起点/终点的区分。尾部长度为路径总长的 1/4。
53
+
54
+ ### 相机同步
55
+ Pass 自动同步相机的投影矩阵和视图矩阵,无需手动管理。支持相机运动时光带跟随。
56
+
57
+ ## Configuration
58
+
59
+ ### Line 配置参数
60
+
61
+ | Parameter | Type | Required | Default | Description |
62
+ | :--- | :--- | :--- | :--- | :--- |
63
+ | `points` | `THREE.Vector3[]` | ✓ | - | 世界坐标系路径点数组。至少 2 个点。 |
64
+ | `totalLength` | `number` | ✓ | - | 路径总长度(世界单位)。通常为所有相邻点间距离之和。 |
65
+ | `color` | `THREE.Color` | ✓ | - | 光带颜色(RGB)。 |
66
+ | `opacity` | `number` | | `1` | 光带不透明度(0-1)。控制与背景的混合强度。 |
67
+ | `duration` | `number` | | `1000` | 动画周期(毫秒)。光头完成一个循环所需时长。 |
68
+
69
+ > **注意**: `totalLength` 应为世界坐标单位。若不准确,流速会偏差。
70
+
71
+ ## Instance Methods
72
+
73
+ ### `constructor(camera: Camera)`
74
+ 初始化 Pass,需传入相机以获取投影矩阵和视图矩阵。
75
+
76
+ ### `setLines(lines: Line[])`
77
+ 更新要渲染的路径列表。支持运行时动态更改。
78
+
79
+ **示例**:
80
+ ```ts
81
+ const pathLine: Line = {
82
+ points: [
83
+ new THREE.Vector3(0, 0, 0),
84
+ new THREE.Vector3(5, 2, 3),
85
+ new THREE.Vector3(10, 1, 6),
86
+ ],
87
+ totalLength: 12, // 世界坐标单位
88
+ color: new THREE.Color(0xff6600),
89
+ opacity: 0.85,
90
+ duration: 3000,
91
+ };
92
+ pass.setLines([pathLine]);
93
+ ```
94
+
95
+ ### `render(...)`
96
+ 由 EffectComposer 自动调用,无需手动调用。自动同步相机矩阵。
97
+
98
+ ### `dispose()`
99
+ 释放着色材质和数据纹理资源,销毁 Pass 时必须调用。
100
+
101
+ ## Examples
102
+
103
+ ### 快速上手 (Quick Example)
104
+
105
+ ```ts
106
+ import { Five } from '@realsee/five';
107
+ import { FlowingLight3DPass } from '../../lib/five/renderer/postprocessing';
108
+ import * as THREE from 'three';
109
+
110
+ const five = new Five();
111
+
112
+ // 创建 3D 流光通道
113
+ const flowing3D = new FlowingLight3DPass(five.camera);
114
+
115
+ // 定义一条 3D 路径(世界坐标)
116
+ const path = [
117
+ new THREE.Vector3(-5, 0, 0),
118
+ new THREE.Vector3(-2, 3, 2),
119
+ new THREE.Vector3(2, 3, -2),
120
+ new THREE.Vector3(5, 0, 0),
121
+ ];
122
+ const totalLen = 15; // 世界单位
123
+
124
+ flowing3D.setLines([{
125
+ points: path,
126
+ totalLength: totalLen,
127
+ color: new THREE.Color(0x00ff88),
128
+ opacity: 0.8,
129
+ duration: 4000,
130
+ }]);
131
+
132
+ five.addPass(flowing3D);
133
+
134
+ function animate() {
135
+ requestAnimationFrame(animate);
136
+ five.render();
137
+ }
138
+ animate();
139
+ ```
140
+
141
+ ### 多条 3D 路径
142
+
143
+ ```ts
144
+ const pass = new FlowingLight3DPass(camera);
145
+
146
+ const paths = [
147
+ {
148
+ points: [
149
+ new THREE.Vector3(0, 0, 0),
150
+ new THREE.Vector3(10, 5, 0),
151
+ ],
152
+ totalLength: 11,
153
+ color: new THREE.Color(0xff0000),
154
+ duration: 2000,
155
+ },
156
+ {
157
+ points: [
158
+ new THREE.Vector3(0, 0, 0),
159
+ new THREE.Vector3(0, 10, 5),
160
+ ],
161
+ totalLength: 12,
162
+ color: new THREE.Color(0x00ff00),
163
+ duration: 2500,
164
+ },
165
+ {
166
+ points: [
167
+ new THREE.Vector3(0, 0, 0),
168
+ new THREE.Vector3(5, 0, 10),
169
+ ],
170
+ totalLength: 11,
171
+ color: new THREE.Color(0x0000ff),
172
+ duration: 2200,
173
+ },
174
+ ];
175
+
176
+ pass.setLines(paths);
177
+ ```
178
+
179
+ ### 计算 3D 路径长度
180
+
181
+ ```ts
182
+ function calculatePath3DLength(points: THREE.Vector3[]): number {
183
+ let length = 0;
184
+ for (let i = 1; i < points.length; i++) {
185
+ length += points[i].distanceTo(points[i - 1]);
186
+ }
187
+ return length;
188
+ }
189
+
190
+ const pathLine = {
191
+ points: [...],
192
+ totalLength: calculatePath3DLength(points),
193
+ color: new THREE.Color(0x00ccff),
194
+ duration: 3000,
195
+ };
196
+ ```
197
+
198
+ ### 结合相机动画
199
+
200
+ ```ts
201
+ // 光带路径随相机移动自动投影
202
+ const pass = new FlowingLight3DPass(camera);
203
+
204
+ pass.setLines([{
205
+ points: [...],
206
+ totalLength: 20,
207
+ color: new THREE.Color(0xffff00),
208
+ duration: 3000,
209
+ }]);
210
+
211
+ // 相机动画过程中光带自动跟随投影
212
+ five.setState({
213
+ mode: Five.Mode.Model,
214
+ // ... 其他参数
215
+ });
216
+ ```
217
+
218
+ ## Debugging
219
+
220
+ - **光带不可见**:检查路径点是否在相机视锥内;验证 `color` 和 `opacity` 非全透明。
221
+ - **光带抖动或消失**:确认路径在相机背面时自动丢弃(3D 投影的预期行为)。
222
+ - **流速不对**:检查 `totalLength` 计算是否为世界单位;调整 `duration` 以改变流速。
223
+
224
+ ## Common Pitfalls
225
+
226
+ 1. **totalLength 单位混淆**:必须使用世界坐标单位,不能混用屏幕像素或其他单位。
227
+ 2. **投影失败**:确保相机矩阵有效,相机在构造时已初始化。
228
+ 3. **路径在背面**:相机背后的点自动投影到屏幕外,无需手动处理。
229
+ 4. **未调用 dispose()**:销毁 Pass 时必须调用 `dispose()`,避免 GPU 资源泄漏。
230
+
231
+ ## Related
232
+
233
+ * [Postprocessing](./postprocessing.md): 后处理通用概念与 EffectComposer 使用指南。
234
+ * [Flowing Light 2D Pass](./flowing-light-2d-pass.md): 屏幕空间的流光效果。
235
+
236
+ ---
237
+
238
+ ```yaml
239
+ tags: [postprocessing, effect, flowing, light, pass, rendering, worldspace, projection]
240
+ ```