@realsee/five-webgpu 1.0.0-alpha.11 → 1.0.0-alpha.13

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 (307) hide show
  1. package/{TERMS.txt → LICENSE.txt} +89 -24
  2. package/_virtual/_rolldown/runtime.js +134 -51
  3. package/docs/assets/hierarchy.js +1 -1
  4. package/docs/assets/search.js +1 -1
  5. package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
  6. package/docs/classes/index.EyeDomeLightingPass.html +1 -1
  7. package/docs/classes/index.Five.html +77 -69
  8. package/docs/classes/index.FivePass.html +1 -1
  9. package/docs/classes/index.FiveRenderer.html +7 -2
  10. package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
  11. package/docs/classes/index.FlowingLight2DPass.html +1 -1
  12. package/docs/classes/index.FlowingLight3DPass.html +1 -1
  13. package/docs/classes/index.GaussianBlurPass.html +1 -1
  14. package/docs/classes/index.InternalWebGPURenderer.html +4 -5
  15. package/docs/classes/index.Model.html +1 -1
  16. package/docs/classes/index.ModelScene.html +1 -1
  17. package/docs/classes/index.PBMCustomNode.html +1 -1
  18. package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +9 -9
  19. package/docs/classes/index.PBMGaussianSplattingObject.html +49 -11
  20. package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +71 -16
  21. package/docs/classes/index.PBMGroup.html +1 -1
  22. package/docs/classes/index.PBMMesh.html +1 -1
  23. package/docs/classes/index.PBMMeshBasicMaterial.html +1 -1
  24. package/docs/classes/index.PBMMeshBasicNodeMaterial.html +1 -1
  25. package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +1 -1
  26. package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +1 -1
  27. package/docs/classes/index.PBMMeshPhongMaterial.html +1 -1
  28. package/docs/classes/index.PBMMeshPhongNodeMaterial.html +1 -1
  29. package/docs/classes/index.PBMMeshPhysicalMaterial.html +1 -1
  30. package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +1 -1
  31. package/docs/classes/index.PBMPanoFilter.html +1 -1
  32. package/docs/classes/index.PBMPointCloud.html +1 -1
  33. package/docs/classes/index.PBMPointCloudMaterial.html +1 -1
  34. package/docs/classes/index.PBMSkinnedMesh.html +1 -1
  35. package/docs/classes/index.PBMUpdateable.html +1 -1
  36. package/docs/classes/index.Parameter.html +24 -22
  37. package/docs/classes/index.Tile3D.html +22 -22
  38. package/docs/classes/index.TileNode.html +2 -2
  39. package/docs/classes/index.TrajectoryNode.html +1 -1
  40. package/docs/classes/index.WorkResolvedObserver.html +1 -1
  41. package/docs/functions/index.loadPly.html +10 -1
  42. package/docs/hierarchy.html +1 -1
  43. package/docs/interfaces/index.DeviceProfile.html +2 -2
  44. package/docs/interfaces/index.EventCallback.html +1 -1
  45. package/docs/interfaces/index.IPBMMaterial.html +1 -1
  46. package/docs/interfaces/index.LooseWorkWithExtrinsics.html +1 -1
  47. package/docs/interfaces/index.ModelControllerCustomInitArgs.html +1 -1
  48. package/docs/interfaces/index.PBMGaussianSplattingNodeMaterialOptions.html +3 -3
  49. package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +1 -1
  50. package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +1 -1
  51. package/docs/interfaces/index.ParameterMaterialValue.html +8 -6
  52. package/docs/interfaces/index.ParameterTilesetValue.html +15 -15
  53. package/docs/interfaces/index.ParameterValue.html +21 -19
  54. package/docs/interfaces/index.ResolvedParameterValue.html +22 -20
  55. package/docs/interfaces/index.SplatData.html +10 -6
  56. package/docs/interfaces/index.Tile3DOptions.html +2 -2
  57. package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
  58. package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +1 -1
  59. package/docs/interfaces/index.ViewLayer.html +22 -22
  60. package/docs/interfaces/index.WorkCubeHdrGainmapImage.html +1 -1
  61. package/docs/interfaces/index.WorkCubeImage.html +1 -1
  62. package/docs/interfaces/index.WorkImage.html +1 -1
  63. package/docs/interfaces/index.WorkModelLayer.html +2 -2
  64. package/docs/interfaces/index.WorkObserver.html +1 -1
  65. package/docs/interfaces/index.WorkTile.html +1 -1
  66. package/docs/interfaces/index.XRPanoramaControllerCustomInitArgs.html +1 -1
  67. package/docs/types/index.ParseOptions.html +1 -1
  68. package/five/application/five.d.ts +12 -0
  69. package/five/application/renderPoweredByRealsee.d.ts +2 -2
  70. package/five/controllers/xrPanorama.d.ts +13 -0
  71. package/five/core/internalWebGPURenderer.d.ts +0 -3
  72. package/five/core/panoVideo.d.ts +2 -0
  73. package/five/gaussian-splatting/arena/splatArena.d.ts +227 -0
  74. package/five/gaussian-splatting/cullConstants.d.ts +68 -0
  75. package/five/gaussian-splatting/hybridConstants.d.ts +60 -0
  76. package/five/gaussian-splatting/instancePacking.d.ts +46 -0
  77. package/five/gaussian-splatting/mirrors/layoutMirror.d.ts +44 -0
  78. package/five/gaussian-splatting/mirrors/mirrorBuffer.d.ts +72 -0
  79. package/five/gaussian-splatting/mirrors/mirrorSet.d.ts +17 -0
  80. package/five/gaussian-splatting/mirrors/objectParamsMirror.d.ts +35 -0
  81. package/five/gaussian-splatting/mirrors/transformMirror.d.ts +26 -0
  82. package/five/gaussian-splatting/pipelines/gpuSortPipeline.d.ts +5 -31
  83. package/five/gaussian-splatting/pipelines/pipelineMode.d.ts +1 -2
  84. package/five/gaussian-splatting/sh-core/codec.d.ts +13 -0
  85. package/five/gaussian-splatting/sh-core/constants.d.ts +29 -0
  86. package/five/gaussian-splatting/sh-core/index.d.ts +4 -0
  87. package/five/gaussian-splatting/sh-core/rebakePolicy.d.ts +20 -0
  88. package/five/gaussian-splatting/sh-core/texelRange.d.ts +18 -0
  89. package/five/gaussian-splatting/shAssembler.d.ts +14 -0
  90. package/five/gaussian-splatting/shBakeScheduler.d.ts +26 -0
  91. package/five/gaussian-splatting/shBaker.d.ts +44 -0
  92. package/five/gaussian-splatting/shTileResource.d.ts +22 -0
  93. package/five/gaussian-splatting/splatAssembler.d.ts +1 -1
  94. package/five/gaussian-splatting/transformStore.d.ts +2 -2
  95. package/five/gaussian-splatting/worker/decodeWorker.d.ts +72 -0
  96. package/five/index.js +304 -146
  97. package/five/index.mjs +10789 -7851
  98. package/five/model/loaders/ply.d.ts +22 -6
  99. package/five/model/loaders/spz.d.ts +9 -48
  100. package/five/model/materials/pbmGaussianSplattingNodeMaterial.d.ts +6 -12
  101. package/five/model/objects/pbmGaussianSplattingObject.d.ts +91 -6
  102. package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +357 -15
  103. package/five/model/parameter.d.ts +4 -0
  104. package/five/renderer/compute-renderers/binned/binned-core.d.ts +45 -2
  105. package/five/renderer/compute-renderers/binned/binned-pipelines.d.ts +82 -1
  106. package/five/renderer/compute-renderers/color-space.d.ts +13 -0
  107. package/five/renderer/compute-renderers/composite-pipelines.d.ts +36 -0
  108. package/five/renderer/compute-renderers/frame-plan.d.ts +166 -0
  109. package/five/renderer/compute-renderers/gsplat-hybrid-renderer.d.ts +386 -0
  110. package/five/renderer/compute-renderers/pointcloud-compute-renderer.d.ts +101 -16
  111. package/five/renderer/compute-renderers/shaders/composite-additive.d.ts +2 -0
  112. package/five/renderer/compute-renderers/shaders/composite-blend.d.ts +2 -0
  113. package/five/renderer/compute-renderers/shaders/gsplatHybridIndirect.d.ts +2 -0
  114. package/five/renderer/compute-renderers/shaders/gsplatProjector.d.ts +2 -0
  115. package/five/renderer/compute-renderers/shaders/gsplatQuad.d.ts +2 -0
  116. package/five/renderer/compute-renderers/shaders/lib/write-additive.d.ts +2 -0
  117. package/five/renderer/compute-renderers/shaders/lib/write-blend.d.ts +2 -0
  118. package/five/renderer/compute-renderers/shaders/lib/write-opaque.d.ts +2 -0
  119. package/five/renderer/compute-renderers/tile-uniform-writer.d.ts +70 -0
  120. package/five/renderer/compute-renderers/transparency-buffers.d.ts +59 -0
  121. package/five/renderer/compute-renderers/transparency-math.d.ts +70 -0
  122. package/five/renderer/compute-renderers/transparency-settings.d.ts +24 -0
  123. package/five/renderer/compute-renderers/uniform-layout.d.ts +11 -2
  124. package/five/renderer/five-renderer.d.ts +28 -3
  125. package/five/renderer/postprocessing/passes/pass.js +134 -51
  126. package/five/renderer/postprocessing/passes/pass.mjs +134 -51
  127. package/five/renderer/tools/full-screen-quad.js +134 -51
  128. package/five/renderer/tools/full-screen-quad.mjs +134 -51
  129. package/five/texture/videoTextureBridge.d.ts +43 -0
  130. package/five/utils/calculateThreeMouse.js +134 -51
  131. package/five/utils/calculateThreeMouse.mjs +134 -51
  132. package/five/utils/distance.js +134 -51
  133. package/five/utils/distance.mjs +134 -51
  134. package/five/utils/isNil.js +134 -51
  135. package/five/utils/isNil.mjs +134 -51
  136. package/five/utils/uuid.js +134 -51
  137. package/five/utils/uuid.mjs +134 -51
  138. package/gltf-loader/index.js +135 -52
  139. package/gltf-loader/index.mjs +135 -52
  140. package/line/index.js +135 -52
  141. package/line/index.mjs +135 -52
  142. package/package.json +2 -2
  143. package/plugins/BackgroundPlugin/Controller.js +134 -51
  144. package/plugins/BackgroundPlugin/Controller.mjs +134 -51
  145. package/plugins/BackgroundPlugin/index.js +134 -51
  146. package/plugins/BackgroundPlugin/index.mjs +134 -51
  147. package/plugins/BasePlugin/index.js +134 -51
  148. package/plugins/BasePlugin/index.mjs +134 -51
  149. package/plugins/CSS2DPlugin/Controller.js +134 -51
  150. package/plugins/CSS2DPlugin/Controller.mjs +134 -51
  151. package/plugins/CSS2DPlugin/index.js +134 -51
  152. package/plugins/CSS2DPlugin/index.mjs +134 -51
  153. package/plugins/CSS2DPlugin/style.css_raw.js +134 -51
  154. package/plugins/CSS2DPlugin/style.css_raw.mjs +134 -51
  155. package/plugins/CSS3DPlugin/Controller.js +134 -51
  156. package/plugins/CSS3DPlugin/Controller.mjs +134 -51
  157. package/plugins/CSS3DPlugin/index.js +134 -51
  158. package/plugins/CSS3DPlugin/index.mjs +134 -51
  159. package/plugins/CSS3DPlugin/style.css_raw.js +134 -51
  160. package/plugins/CSS3DPlugin/style.css_raw.mjs +134 -51
  161. package/plugins/FloorplanPlugin/Controller.js +134 -51
  162. package/plugins/FloorplanPlugin/Controller.mjs +134 -51
  163. package/plugins/FloorplanPlugin/index.js +134 -51
  164. package/plugins/FloorplanPlugin/index.mjs +134 -51
  165. package/plugins/FloorplanPlugin/render/assets.js +134 -51
  166. package/plugins/FloorplanPlugin/render/assets.mjs +134 -51
  167. package/plugins/FloorplanPlugin/render/index.js +134 -51
  168. package/plugins/FloorplanPlugin/render/index.mjs +134 -51
  169. package/plugins/FloorplanPlugin/render/isPointInPolygon.js +134 -51
  170. package/plugins/FloorplanPlugin/render/isPointInPolygon.mjs +134 -51
  171. package/plugins/FloorplanPlugin/render/renderFloor.js +134 -51
  172. package/plugins/FloorplanPlugin/render/renderFloor.mjs +134 -51
  173. package/plugins/FloorplanPlugin/render/roomLabelVisibility.js +134 -51
  174. package/plugins/FloorplanPlugin/render/roomLabelVisibility.mjs +134 -51
  175. package/plugins/FloorplanPlugin/render/style.css_raw.js +134 -51
  176. package/plugins/FloorplanPlugin/render/style.css_raw.mjs +134 -51
  177. package/plugins/FloorplanPlugin/utils/changeMode.js +134 -51
  178. package/plugins/FloorplanPlugin/utils/changeMode.mjs +134 -51
  179. package/plugins/FloorplanPlugin/utils/changeModelCanvasOpacity.js +134 -51
  180. package/plugins/FloorplanPlugin/utils/changeModelCanvasOpacity.mjs +134 -51
  181. package/plugins/FloorplanPlugin/utils/correctFiveState.js +134 -51
  182. package/plugins/FloorplanPlugin/utils/correctFiveState.mjs +134 -51
  183. package/plugins/FloorplanPlugin/utils/equal.js +134 -51
  184. package/plugins/FloorplanPlugin/utils/equal.mjs +134 -51
  185. package/plugins/FloorplanPlugin/utils/filter.js +134 -51
  186. package/plugins/FloorplanPlugin/utils/filter.mjs +134 -51
  187. package/plugins/FloorplanPlugin/utils/fiveModelLoad.js +134 -51
  188. package/plugins/FloorplanPlugin/utils/fiveModelLoad.mjs +134 -51
  189. package/plugins/FloorplanPlugin/utils/formatData.js +134 -51
  190. package/plugins/FloorplanPlugin/utils/formatData.mjs +134 -51
  191. package/plugins/FloorplanPlugin/utils/formatFloorplanJson.js +134 -51
  192. package/plugins/FloorplanPlugin/utils/formatFloorplanJson.mjs +134 -51
  193. package/plugins/FloorplanPlugin/utils/formatPosition.js +134 -51
  194. package/plugins/FloorplanPlugin/utils/formatPosition.mjs +134 -51
  195. package/plugins/FloorplanPlugin/utils/getDistanceFromModel.js +134 -51
  196. package/plugins/FloorplanPlugin/utils/getDistanceFromModel.mjs +134 -51
  197. package/plugins/FloorplanPlugin/utils/getPxmm.js +134 -51
  198. package/plugins/FloorplanPlugin/utils/getPxmm.mjs +134 -51
  199. package/plugins/FloorplanPlugin/utils/isTruelyObject.js +134 -51
  200. package/plugins/FloorplanPlugin/utils/isTruelyObject.mjs +134 -51
  201. package/plugins/FloorplanPlugin/utils/nearlyEqual.js +134 -51
  202. package/plugins/FloorplanPlugin/utils/nearlyEqual.mjs +134 -51
  203. package/plugins/FloorplanPlugin/utils/polylabel.js +134 -51
  204. package/plugins/FloorplanPlugin/utils/polylabel.mjs +134 -51
  205. package/plugins/FloorplanPlugin/utils/to.js +134 -51
  206. package/plugins/FloorplanPlugin/utils/to.mjs +134 -51
  207. package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.d.ts +6 -0
  208. package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.js +135 -52
  209. package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.mjs +135 -52
  210. package/plugins/GaussianSplattingEntranceAnimationPlugin/index.js +134 -51
  211. package/plugins/GaussianSplattingEntranceAnimationPlugin/index.mjs +134 -51
  212. package/plugins/Object3DHelperPlugin/Controller.js +134 -51
  213. package/plugins/Object3DHelperPlugin/Controller.mjs +134 -51
  214. package/plugins/Object3DHelperPlugin/Controllers/BaseController.js +134 -51
  215. package/plugins/Object3DHelperPlugin/Controllers/BaseController.mjs +134 -51
  216. package/plugins/Object3DHelperPlugin/Controllers/BoundingBoxController.js +134 -51
  217. package/plugins/Object3DHelperPlugin/Controllers/BoundingBoxController.mjs +134 -51
  218. package/plugins/Object3DHelperPlugin/Controllers/MoveController.js +134 -51
  219. package/plugins/Object3DHelperPlugin/Controllers/MoveController.mjs +134 -51
  220. package/plugins/Object3DHelperPlugin/Controllers/RotateController.js +134 -51
  221. package/plugins/Object3DHelperPlugin/Controllers/RotateController.mjs +134 -51
  222. package/plugins/Object3DHelperPlugin/FiveControllerWrapper.js +134 -51
  223. package/plugins/Object3DHelperPlugin/FiveControllerWrapper.mjs +134 -51
  224. package/plugins/Object3DHelperPlugin/Helper/BaseHelper.js +134 -51
  225. package/plugins/Object3DHelperPlugin/Helper/BaseHelper.mjs +134 -51
  226. package/plugins/Object3DHelperPlugin/Helper/BoundingBoxHelper.js +134 -51
  227. package/plugins/Object3DHelperPlugin/Helper/BoundingBoxHelper.mjs +134 -51
  228. package/plugins/Object3DHelperPlugin/Helper/MoveHelper.js +134 -51
  229. package/plugins/Object3DHelperPlugin/Helper/MoveHelper.mjs +134 -51
  230. package/plugins/Object3DHelperPlugin/Helper/RotateHelper.js +134 -51
  231. package/plugins/Object3DHelperPlugin/Helper/RotateHelper.mjs +134 -51
  232. package/plugins/Object3DHelperPlugin/constant.js +134 -51
  233. package/plugins/Object3DHelperPlugin/constant.mjs +134 -51
  234. package/plugins/Object3DHelperPlugin/index.js +134 -51
  235. package/plugins/Object3DHelperPlugin/index.mjs +134 -51
  236. package/plugins/Object3DHelperPlugin/utils/ArrowGroup.js +134 -51
  237. package/plugins/Object3DHelperPlugin/utils/ArrowGroup.mjs +134 -51
  238. package/plugins/Object3DHelperPlugin/utils/CenterHandle.js +134 -51
  239. package/plugins/Object3DHelperPlugin/utils/CenterHandle.mjs +134 -51
  240. package/plugins/Object3DHelperPlugin/utils/PlaneHandle.js +134 -51
  241. package/plugins/Object3DHelperPlugin/utils/PlaneHandle.mjs +134 -51
  242. package/plugins/Object3DHelperPlugin/utils/calculateScaleByCamera.js +134 -51
  243. package/plugins/Object3DHelperPlugin/utils/calculateScaleByCamera.mjs +134 -51
  244. package/plugins/Object3DHelperPlugin/utils/cameraHooks.js +134 -51
  245. package/plugins/Object3DHelperPlugin/utils/cameraHooks.mjs +134 -51
  246. package/plugins/Object3DHelperPlugin/utils/direction.js +134 -51
  247. package/plugins/Object3DHelperPlugin/utils/direction.mjs +134 -51
  248. package/plugins/Object3DHelperPlugin/utils/getMouseRaycaster.js +134 -51
  249. package/plugins/Object3DHelperPlugin/utils/getMouseRaycaster.mjs +134 -51
  250. package/plugins/Object3DHelperPlugin/utils/getOrthographicCameraDirection.js +134 -51
  251. package/plugins/Object3DHelperPlugin/utils/getOrthographicCameraDirection.mjs +134 -51
  252. package/plugins/Object3DHelperPlugin/utils/setObjectQuaternion.js +134 -51
  253. package/plugins/Object3DHelperPlugin/utils/setObjectQuaternion.mjs +134 -51
  254. package/plugins/Object3DHelperPlugin/utils/solidGuide.js +134 -51
  255. package/plugins/Object3DHelperPlugin/utils/solidGuide.mjs +134 -51
  256. package/plugins/Object3DHelperPlugin/utils/tipsDom.js +134 -51
  257. package/plugins/Object3DHelperPlugin/utils/tipsDom.mjs +134 -51
  258. package/plugins/PanoAnimePlugin/Controller.js +134 -51
  259. package/plugins/PanoAnimePlugin/Controller.mjs +134 -51
  260. package/plugins/PanoAnimePlugin/index.js +134 -51
  261. package/plugins/PanoAnimePlugin/index.mjs +134 -51
  262. package/plugins/WordPassPlugin/Controller.js +134 -51
  263. package/plugins/WordPassPlugin/Controller.mjs +134 -51
  264. package/plugins/WordPassPlugin/hersheyFont.js +134 -51
  265. package/plugins/WordPassPlugin/hersheyFont.mjs +134 -51
  266. package/plugins/WordPassPlugin/index.js +134 -51
  267. package/plugins/WordPassPlugin/index.mjs +134 -51
  268. package/plugins/WordPassPlugin/textToStrokeOrderStrokes.js +134 -51
  269. package/plugins/WordPassPlugin/textToStrokeOrderStrokes.mjs +134 -51
  270. package/plugins/WordPassPlugin/word-pass.js +134 -51
  271. package/plugins/WordPassPlugin/word-pass.mjs +134 -51
  272. package/plugins/index.js +134 -51
  273. package/plugins/index.mjs +134 -51
  274. package/plugins/thirdParty/CSS2DRenderer.js +134 -51
  275. package/plugins/thirdParty/CSS2DRenderer.mjs +134 -51
  276. package/plugins/thirdParty/CSS3DRenderer.js +134 -51
  277. package/plugins/thirdParty/CSS3DRenderer.mjs +134 -51
  278. package/plugins/thirdParty/doctorstrange-model.js +134 -51
  279. package/plugins/thirdParty/doctorstrange-model.mjs +134 -51
  280. package/plugins/thirdParty/domevents.js +134 -51
  281. package/plugins/thirdParty/domevents.mjs +134 -51
  282. package/plugins/utils/absoluteUrl.js +134 -51
  283. package/plugins/utils/absoluteUrl.mjs +134 -51
  284. package/plugins/utils/calculatePath.js +134 -51
  285. package/plugins/utils/calculatePath.mjs +134 -51
  286. package/plugins/utils/clamp.js +134 -51
  287. package/plugins/utils/clamp.mjs +134 -51
  288. package/plugins/utils/uuid.js +134 -51
  289. package/plugins/utils/uuid.mjs +134 -51
  290. package/react/index.js +134 -51
  291. package/react/index.mjs +134 -51
  292. package/sticker/index.d.ts +7 -0
  293. package/sticker/index.js +169 -52
  294. package/sticker/index.mjs +307 -67
  295. package/umd/five-gltf-loader.js +135 -52
  296. package/umd/five-line.js +135 -52
  297. package/umd/five-plugins.js +135 -52
  298. package/umd/five-react.js +134 -51
  299. package/umd/five-sticker.js +169 -52
  300. package/umd/five-vfx.js +134 -51
  301. package/umd/five.js +337 -179
  302. package/vfx/index.js +134 -51
  303. package/vfx/index.mjs +134 -51
  304. package/work-downloader/index.js +134 -51
  305. package/work-downloader/index.mjs +134 -51
  306. package/five/gaussian-splatting/shStore.d.ts +0 -22
  307. /package/five/assets/{realsee-pmg-data-url.d.ts → realsee-png-data-url.d.ts} +0 -0
@@ -0,0 +1,36 @@
1
+ /** 单个合成管线及其 group(0) 绑定布局。 */
2
+ export interface CompositePipeline {
3
+ readonly pipeline: GPURenderPipeline;
4
+ readonly bindGroupLayout: GPUBindGroupLayout;
5
+ }
6
+ /** 合成管线集合;颜色格式变化时整体重建。 */
7
+ export interface CompositePipelines {
8
+ readonly colorFormat: GPUTextureFormat;
9
+ /**
10
+ * 叠加合成。group(0):binding 0 = 叠加平面(一个缓冲 R / G / B 三段,只读存储),
11
+ * binding 1 = {screenWidth, screenHeight}(u32×2 uniform,可复用显示参数缓冲)。
12
+ * 绘制:`draw(3)`,渲染通道只挂颜色附件。
13
+ */
14
+ readonly additive: CompositePipeline;
15
+ /**
16
+ * 层合成(混合半透明组)。group(0):binding 0 = 透明层缓冲(只读存储),
17
+ * binding 1 = {screenWidth, screenHeight}(u32×2 uniform)。
18
+ * 混合因子用混合常量:每组渲染通道 `setBlendConstant(a)` 后 `draw(3)`,只挂颜色附件。
19
+ */
20
+ readonly blend: CompositePipeline;
21
+ }
22
+ /** 叠加合成着色器完整代码(常量 + composite-additive.wgsl)。 */
23
+ export declare function buildCompositeAdditiveShaderCode(): string;
24
+ /** 层合成着色器完整代码(composite-blend.wgsl,不依赖透明常量)。 */
25
+ export declare function buildCompositeBlendShaderCode(): string;
26
+ /** 叠加合成管线描述符的颜色目标:color = one/one/add,alpha = zero/one,只写 RGB。 */
27
+ export declare function additiveColorTarget(colorFormat: GPUTextureFormat): GPUColorTargetState;
28
+ /**
29
+ * 层合成管线描述符的颜色目标:color = constant/one-minus-constant/add(a 为混合常量),
30
+ * alpha = zero/one,只写 RGB。结果 = 层颜色 × a + 原颜色 × (1 − a)。
31
+ */
32
+ export declare function blendColorTarget(colorFormat: GPUTextureFormat): GPUColorTargetState;
33
+ /**
34
+ * 按合成渲染目标颜色格式创建合成管线。颜色格式变化时调用方应重新调用本函数。
35
+ */
36
+ export declare function createCompositePipelines(device: GPUDevice, colorFormat: GPUTextureFormat): CompositePipelines;
@@ -0,0 +1,166 @@
1
+ /**
2
+ * 计算着色器点云每帧的绘制规划(纯函数,无 GPU 依赖)。
3
+ *
4
+ * - `classifyBlocks`:按块参数判定每块类别(跳过 / 不透明 / 叠加 / 混合半透明),并给出 a;
5
+ * - `groupBlendBlocks`:混合半透明块按 (楼层号, f32(a)) 分组,组间从远到近排序;
6
+ * - `planFrame`:按分类与分组结果生成本帧步骤序列(纯数据);
7
+ * - `planExtraBufferReleases`:额外缓冲释放决策。
8
+ *
9
+ * 分类只看块自身参数与帧级相机朝向,结果与块顺序无关。
10
+ */
11
+ import { type TileCategory } from './transparency-math';
12
+ import type { PointCloudTransparencyMode } from './transparency-settings';
13
+ /** 分类所需的块参数。 */
14
+ export interface BlockParams {
15
+ floorIndex: number;
16
+ shownFloorIndex: number;
17
+ floorStyle: string;
18
+ opacity: number;
19
+ modelAlpha: number;
20
+ useAddBlend: boolean;
21
+ }
22
+ /** 每块绘制类别。 */
23
+ export type BlockKind = 'skip' | 'opaque' | 'additive' | 'blend';
24
+ /** 单块分类结果。 */
25
+ export interface BlockClassification {
26
+ kind: BlockKind;
27
+ /** 点透明度 a(64 位,写入块参数时由 Float32 存储舍入) */
28
+ alpha: number;
29
+ }
30
+ /** 分类输入(帧级量 + 每块参数)。 */
31
+ export interface ClassifyBlocksInput {
32
+ blocks: readonly BlockParams[];
33
+ /** 相机朝向 y 分量 */
34
+ cameraForwardY: number;
35
+ /** 半透明处理方式 */
36
+ mode: PointCloudTransparencyMode;
37
+ /** 透明层(及层写入流水线、层合成管线)是否可用;不可用时半透明块按不透明绘制 */
38
+ blendLayerAvailable: boolean;
39
+ /** 叠加平面(及叠加流水线、叠加合成管线)是否可用;不可用时跳过叠加块 */
40
+ additiveBufferAvailable: boolean;
41
+ }
42
+ /** 分类输出。`blocks[i]` 与输入 `blocks[i]` 一一对应。 */
43
+ export interface ClassifyBlocksResult {
44
+ blocks: BlockClassification[];
45
+ hasAdditive: boolean;
46
+ hasBlend: boolean;
47
+ }
48
+ /** 单块分类,`classifyBlocks` 逐块调用。 */
49
+ export declare function classifyBlock(block: BlockParams, cameraForwardY: number, mode: PointCloudTransparencyMode, blendLayerAvailable: boolean, additiveBufferAvailable: boolean): BlockClassification;
50
+ /** 按块参数判定每块类别,输出顺序与输入一致。 */
51
+ export declare function classifyBlocks(input: ClassifyBlocksInput): ClassifyBlocksResult;
52
+ /** 非跳过类别对应的 `tilePack.z` 取值;跳过块返回 null。 */
53
+ export declare function tileCategoryOf(kind: BlockKind): TileCategory | null;
54
+ /** 分组输入:只取混合半透明块。 */
55
+ export interface BlendBlockInput {
56
+ /** classifyBlocks 输出下标 */
57
+ index: number;
58
+ floorIndex: number;
59
+ /** 64 位 a,内部取 Math.fround */
60
+ alpha: number;
61
+ /** 世界空间包围盒 [minX, minY, minZ, maxX, maxY, maxZ];没有包围盒时为 null */
62
+ worldBox: readonly number[] | null;
63
+ }
64
+ /** 一个半透明组。 */
65
+ export interface BlendGroup {
66
+ /** 规整后的楼层号 */
67
+ floorIndex: number;
68
+ /** Math.fround(a),层合成的混合常量 */
69
+ alpha: number;
70
+ /** 组距离:相机到组包围盒(各块世界包围盒的并集)的最近点距离 */
71
+ distance: number;
72
+ /** 组内块下标,升序 */
73
+ blockIndices: number[];
74
+ }
75
+ /**
76
+ * 楼层号规整:非有限值(NaN、±∞)→ 0(与 `PBMPointCloud.floorIndex` 的默认值相同),−0 → 0。
77
+ * 规整后才能作为分组键并参与排序比较。
78
+ */
79
+ export declare function normalizeFloorIndex(f: number): number;
80
+ /**
81
+ * 混合半透明块分组并按从远到近排序:
82
+ * 1. 键 = (normalizeFloorIndex(floorIndex), Math.fround(alpha));
83
+ * 2. 组包围盒 = 组内各块 worldBox 的并集,缺失的不参与;
84
+ * 3. 组距离 = 相机到组包围盒的最近点距离,全部缺失时为 Number.MAX_VALUE;
85
+ * 4. 距离降序 → 楼层号升序 → a 升序(键唯一,排序为全序,与输入顺序无关);
86
+ * 5. 每组 blockIndices 升序。
87
+ */
88
+ export declare function groupBlendBlocks(blocks: readonly BlendBlockInput[], cameraPos: readonly [number, number, number]): BlendGroup[];
89
+ /** 计算阶段:不透明(含非拆分帧的唯一计算通道)/ 混合半透明(每组一次)/ 叠加。 */
90
+ export type FrameStage = 'opaque' | 'blend' | 'additive';
91
+ /**
92
+ * 帧步骤(纯数据),描述本帧的执行顺序;five-renderer 从中取各计算阶段的块列表。
93
+ * - `clearCounters`:`encoder.clearBuffer(counters)`,每个计算阶段开始前一次;半透明组带组号;
94
+ * - `compute`:计算通道,`blockIndices` 为该阶段参与的块(`classifyBlocks` 输出下标,升序);
95
+ * - `display`:像素缓冲全屏写入合成渲染目标的颜色和深度;
96
+ * - `threeScene`:非拆分帧整场景一次 `renderer.render`;
97
+ * - `threeOpaque` / `threeTransparent`:拆分帧的 three 不透明段 / 透明段;
98
+ * - `clearLayer`:清透明层(该组计算通道内的第一个调度);
99
+ * - `compositeBlend`:层合成(混合常量 = 该组 a);
100
+ * - `clearAdditive`:清零叠加平面(整个缓冲);
101
+ * - `compositeAdditive`:叠加合成。
102
+ */
103
+ export type FrameStep = {
104
+ kind: 'clearCounters';
105
+ stage: FrameStage;
106
+ group?: number;
107
+ } | {
108
+ kind: 'compute';
109
+ stage: FrameStage;
110
+ group?: number;
111
+ blockIndices: number[];
112
+ } | {
113
+ kind: 'display';
114
+ } | {
115
+ kind: 'threeScene';
116
+ } | {
117
+ kind: 'threeOpaque';
118
+ } | {
119
+ kind: 'threeTransparent';
120
+ } | {
121
+ kind: 'clearLayer';
122
+ group: number;
123
+ } | {
124
+ kind: 'compositeBlend';
125
+ group: number;
126
+ alpha: number;
127
+ } | {
128
+ kind: 'clearAdditive';
129
+ } | {
130
+ kind: 'compositeAdditive';
131
+ };
132
+ /** 帧规划结果。 */
133
+ export interface FramePlan {
134
+ /** 是否为拆分帧(存在混合半透明块或叠加块) */
135
+ split: boolean;
136
+ hasBlend: boolean;
137
+ hasAdditive: boolean;
138
+ /** 半透明组(远 → 近),与输入相同 */
139
+ groups: readonly BlendGroup[];
140
+ steps: FrameStep[];
141
+ }
142
+ /**
143
+ * 按分类与分组结果生成本帧步骤序列。
144
+ *
145
+ * 非拆分帧:清计数器 → 计算通道 → 显示通道 → three 整场景一次。
146
+ * 拆分帧:清计数器 → 计算通道1(不透明块)→ 显示通道 → three 不透明段
147
+ * → [每组 g(远 → 近):清计数器 → 清透明层 → 计算(blend) → 层合成(a_g)]
148
+ * → [有叠加块:清零叠加平面 → 清计数器 → 叠加计算 → 叠加合成] → three 透明段。
149
+ * 拆分帧没有不透明块时计算通道1与显示通道照常执行,`blockIndices` 为空。
150
+ * 是否拆分只由本帧输入决定,流程切换从变化后的第一帧生效。
151
+ */
152
+ export declare function planFrame(classification: ClassifyBlocksResult, groups: readonly BlendGroup[]): FramePlan;
153
+ export interface ExtraBufferReleaseInput {
154
+ /** 本帧 scene.traverse 收集到的全部点云块中是否有 useAddBlend 为真的块 */
155
+ anyAddBlendParam: boolean;
156
+ /** 设置项的 pendingBlendRelease */
157
+ pendingBlendRelease: boolean;
158
+ }
159
+ export interface ExtraBufferReleasePlan {
160
+ /** 帧开头释放透明层('blend' → 'opaque' 之后的第一次重绘) */
161
+ releaseLayerAtStart: boolean;
162
+ /** 帧末释放叠加平面(所有点云块的 useAddBlend 都为假) */
163
+ releaseAdditiveAtEnd: boolean;
164
+ }
165
+ /** 额外缓冲释放决策;缓冲不存在时调用方的释放为空操作。 */
166
+ export declare function planExtraBufferReleases(input: ExtraBufferReleaseInput): ExtraBufferReleasePlan;
@@ -0,0 +1,386 @@
1
+ import * as THREE from 'three/webgpu';
2
+ import type { SplatArena } from '../../gaussian-splatting/arena/splatArena';
3
+ import type { GSplatMirrorSet } from '../../gaussian-splatting/mirrors/mirrorSet';
4
+ /**
5
+ * 取 three 纹理背后 `GPUTexture` 所需的最小 backend 接口(即 `renderer.backend`)。
6
+ * 只用 `get(texture).texture`,故不引入 three 内部类型。
7
+ */
8
+ export interface HybridTextureBackend {
9
+ get(object: object): {
10
+ texture?: GPUTexture;
11
+ } | undefined;
12
+ }
13
+ /**
14
+ * 基于 compute 预投影 + 硬件光栅化的 3DGS 渲染器。
15
+ *
16
+ * 从调用方接收 `GPUDevice`,自身不请求 adapter / device。每帧一个 `GPUCommandEncoder`、
17
+ * 恰好一次 `queue.submit`;编码次序见 `submitFrame`。
18
+ */
19
+ export declare class GSplatHybridRenderer {
20
+ private readonly device;
21
+ /** Composite_Target 的颜色格式,Draw_Pass 的管线状态需要它。 */
22
+ private readonly format;
23
+ /** 深度附件格式。与 three 的 Composite_Target 一致,构造期传入。 */
24
+ private readonly depthFormat;
25
+ /**
26
+ * 复用的通用基数排序模块。Fallback_Path 的排序链路正在用同一个类,**只实例化与调用、
27
+ * 不改其源码**。
28
+ *
29
+ * 它**不支持间接派发**(元素数恒为 CPU 已知值),故深度排序仍按 `Total_Points` 上界派发、
30
+ * 拿不到紧凑输出的收益;无效槽位靠哨兵排到末尾。
31
+ */
32
+ private radixSort;
33
+ /** Projector_Pass 的 uniform(176 字节,与 `gsplatCull.wgsl` 的 `FrameUniforms` 逐字段相同)。 */
34
+ private projectorUniformBuffer;
35
+ /** Draw_Pass 的 uniform(32 字节:viewport + projP22 + projP32 + pad)。 */
36
+ private drawUniformBuffer;
37
+ /**
38
+ * SH 烘焙 / clipper / 入场动画的逐帧参数(64 字节,与 `gsplatProjector.wgsl` 的
39
+ * `EffectUniforms` 逐字段相同)。写入见 `writeEffectUniform`。
40
+ */
41
+ private effectUniformBuffer;
42
+ /** 取 three 纹理背后 `GPUTexture` 用的 backend(构造期注入,缺省时恒走非 BAKED 变体)。 */
43
+ private readonly backend;
44
+ /** `SHBaker` 的 RenderTarget 纹理(引用,本类不持有其生命周期)。 */
45
+ private bakedTexture;
46
+ /** 调用方是否要求使用烘焙颜色(`appliedDegree > 0`)。 */
47
+ private bakedEnabled;
48
+ /**
49
+ * `GPUTexture → GPUTextureView` 缓存。RT 重建后 `GPUTexture` 换手,新句柄查不到缓存即新建
50
+ * view,view 换手又自然触发 bind group 重建;旧句柄随 GC 回收,不需要显式失效。
51
+ */
52
+ private readonly bakedViewCache;
53
+ /** 烘焙纹理内容版本号,`notifyBakedContentChanged` 自增;用于让静止帧复用失效。 */
54
+ private bakedContentRevision;
55
+ /**
56
+ * 每存活点 20 字节的紧凑记录。按 `Total_Points` 分配(存活数由 GPU 产生、CPU 分配时不可知),
57
+ * 高水位增长、单调不减。
58
+ */
59
+ private projectedCacheBuffer;
60
+ /** `projectedCacheBuffer` 已分配的点数容量(高水位)。 */
61
+ private projectedCacheCapacityPoints;
62
+ /**
63
+ * 深度排序键,每点一个 u32。容量按 2048 元素向上对齐,与
64
+ * `RadixSortModule.ELEMENTS_PER_WORKGROUP` 同粒度——该模块以 `destructiveKeys: true` 借用本
65
+ * 缓冲作 ping-pong 的一侧,容量小于它自己的分配会让末尾工作组写到缓冲之外。
66
+ */
67
+ private sortKeysBuffer;
68
+ /** `sortKeysBuffer` 已分配的元素数(2048 的整数倍,高水位)。 */
69
+ private sortKeysCapacityElements;
70
+ /**
71
+ * 存活点数,4 字节的原子计数器。三个消费者:Indirect_Pass 换算 instance 数、顶点着色器判
72
+ * 越界、回读给诊断。**顶点着色器读它必须绑为 `read-only-storage`**——它由 GPU 写,而
73
+ * uniform 只能由 CPU 写。
74
+ */
75
+ private renderCountBuffer;
76
+ /**
77
+ * `drawIndexedIndirect` 的参数(32 字节)。usage 必须含 `INDIRECT`。前 5 个字是 draw 五元组,
78
+ * 字 5-7 保留给排序间接派发化之后的 dispatch 三元组。
79
+ */
80
+ private indirectArgsBuffer;
81
+ /**
82
+ * quad 的索引缓冲,构造期一次性建、与点数无关。顶点着色器没有顶点缓冲(`CORNERS` 是着色器
83
+ * 内的常量数组),索引只用来驱动 `vertex_index`——**因此内容必须是恒等序列**,见
84
+ * `createQuadIndexBuffer`。
85
+ */
86
+ private quadIndexBuffer;
87
+ /** 廉价回读的 staging(4 字节,只带回 Render_Count)。 */
88
+ private readbackBuffer;
89
+ private readbackInFlight;
90
+ /** 最近一次成功回读到的存活点数;尚未回读成功过时为 `null`。 */
91
+ private lastRenderCount;
92
+ /**
93
+ * Projector 的两个编译变体(BAKED / 非 BAKED),每个含 `main` 与 `fill_sort_keys` 两条管线。
94
+ *
95
+ * `fill_sort_keys` 把 `sortKeys` 前 `Total_Points` 项填 `SORT_KEY_INVALID`。**与 Projector 同
96
+ * 模块、同 layout**,故不需要额外的 bind group,且必须在 Projector 之前、同一个 compute pass
97
+ * 内派发。不用 `clearBuffer`(填 0 会让无效槽位排到最前被优先绘制),也不用 CPU `writeBuffer`
98
+ * (每帧要上传 `Total_Points × 4` 字节)。
99
+ */
100
+ private readonly plainVariant;
101
+ private readonly bakedVariant;
102
+ private readonly indirectPipeline;
103
+ /**
104
+ * Draw_Pass 的渲染管线。混合与深度状态与 Fallback 材质等价(`NormalBlending`、深度只测不写)。
105
+ * 片元着色器输出**非预乘** alpha,由混合状态完成合成。
106
+ */
107
+ private readonly drawPipeline;
108
+ private readonly indirectBindGroupLayout;
109
+ /**
110
+ * Draw_Pass 的 bind group layout。**显式声明,不用 `layout: 'auto'`**——本项目在自动布局上
111
+ * 踩过坑(纹理可过滤性推导错误导致 `createBindGroup` 每帧抛错),且显式布局才能让「哪个
112
+ * binding 是什么」在 TS 侧一眼可查。
113
+ */
114
+ private readonly drawBindGroupLayout;
115
+ private projectorBindGroup;
116
+ /**
117
+ * Projector 通道的句柄快照。**含变体的 layout 与烘焙纹理的 `GPUTextureView`**,故元素类型比
118
+ * 另两条通道宽——纹理视图与缓冲一样可能被换手,同样要纳入比对。
119
+ */
120
+ private projectorSources;
121
+ private indirectBindGroup;
122
+ private indirectSources;
123
+ private drawBindGroup;
124
+ private drawSources;
125
+ private disposed;
126
+ /** 画面像素宽高,由 `resize` 维护。为 0 时 `submitFrame` 直接返回。 */
127
+ private width;
128
+ private height;
129
+ /** 上一帧的相机快照:`matrixWorld`(前 16)与 `projectionMatrix`(后 16)。 */
130
+ private readonly lastCameraSnapshot;
131
+ private lastArenaRevision;
132
+ private lastTotalPoints;
133
+ private lastViewportWidth;
134
+ private lastViewportHeight;
135
+ /** 上一帧所用的烘焙 view(非 BAKED 变体为 `null`)与烘焙内容版本。 */
136
+ private lastBakedView;
137
+ private lastBakedRevision;
138
+ /**
139
+ * 上一帧是否成功编码了完整的 compute 链。
140
+ *
141
+ * 只有为真时才允许复用——否则 `projectedCache` 与 `renderCount` 可能从未被写过,复用会画出
142
+ * 未初始化的内容。
143
+ */
144
+ private lastFrameComplete;
145
+ /** 已 `dispose`。为真时 `submitFrame` 第一行返回。 */
146
+ get unusable(): boolean;
147
+ /** 最近一次成功回读到的存活点数。`null` 表示尚未取到,与「存活为 0」语义不同。 */
148
+ get renderCount(): number | null;
149
+ private static readonly PROJECTOR_UNIFORM_SIZE;
150
+ private static readonly OFF_VIEW;
151
+ private static readonly OFF_VIEW_PROJ;
152
+ private static readonly OFF_FOCAL;
153
+ private static readonly OFF_VIEWPORT;
154
+ private static readonly OFF_TOTAL_POINTS;
155
+ private static readonly OFF_ENTRY_COUNT;
156
+ private static readonly OFF_MIN_PIXEL_SIZE;
157
+ private static readonly OFF_MAX_RADIUS_CAP;
158
+ private static readonly OFF_COV_PACK_SCALE;
159
+ private static readonly OFF_TERM2_SQ_FLOOR;
160
+ private static readonly OFF_DEPTH_EPSILON;
161
+ private static readonly OFF_DET_EPSILON;
162
+ private readonly projectorUniformScratch;
163
+ private static readonly DRAW_UNIFORM_SIZE;
164
+ private static readonly OFF_DRAW_VIEWPORT;
165
+ private static readonly OFF_DRAW_P22;
166
+ private static readonly OFF_DRAW_P32;
167
+ private readonly drawUniformScratch;
168
+ private static readonly EFFECT_UNIFORM_SIZE;
169
+ private static readonly OFF_AGG_BOUNDS_MIN;
170
+ private static readonly OFF_AGG_PROGRESS;
171
+ private static readonly OFF_AGG_BOUNDS_MAX;
172
+ private static readonly OFF_AGG_POINT_DURATION;
173
+ private static readonly OFF_CAMERA_WORLD_POS;
174
+ private static readonly OFF_AGG_ENABLED;
175
+ private static readonly OFF_SH_BAKED;
176
+ private static readonly OFF_NUM_GS_LAYERS;
177
+ private static readonly OFF_NUM_GS_CLIPPERS;
178
+ private readonly effectUniformScratch;
179
+ /** 廉价回读的字节数:只带回 Render_Count 一个 u32。 */
180
+ private static readonly CHEAP_READBACK_SIZE;
181
+ /** 每帧复用的 u32 写入 scratch,避免逐帧新建 typed array。 */
182
+ private readonly u32Scratch;
183
+ /**
184
+ * @param backend three 的 `renderer.backend`,用于取烘焙 RenderTarget 背后的 `GPUTexture`。
185
+ * 缺省时 `setBakedSource` 无效、恒走非 BAKED 变体
186
+ */
187
+ constructor(device: GPUDevice, format: GPUTextureFormat, depthFormat: GPUTextureFormat, backend?: HybridTextureBackend | null);
188
+ /**
189
+ * 建一个 Projector 变体:bind group layout + `main` / `fill_sort_keys` 两条管线。
190
+ *
191
+ * 前四项与 `gsplatCull.wgsl` 相同(Arena 与三块镜像),4-7 是本特性的输出与 uniform,
192
+ * 9(仅 BAKED)是烘焙纹理,11 是 Effect uniform。8 留给诊断变体的 gateCounters,10 未使用。
193
+ */
194
+ private createProjectorVariant;
195
+ /**
196
+ * 设置 SH 烘焙纹理来源。只保存引用,`GPUTexture` 在每帧 `prepareFrame` 时经
197
+ * `backend.get(texture).texture` 解析(RT 重建会换手)。`GPUTexture` 尚不存在(RT 未被渲染过)、
198
+ * 未注入 backend 或 `enabled = false` 时,本帧用非 BAKED 变体(SPZ DC 颜色)。
199
+ */
200
+ setBakedSource(texture: THREE.Texture | null, enabled: boolean): void;
201
+ /**
202
+ * 通知烘焙纹理内容已更新(本帧有烘焙任务)。纹理对象不变而内容变化时,静止帧的整链复用
203
+ * 必须失效,否则会重放旧颜色。
204
+ */
205
+ notifyBakedContentChanged(): void;
206
+ /** 解析本帧的烘焙 view;不可用时返回 `null`(本帧走非 BAKED 变体)。 */
207
+ private resolveBakedView;
208
+ /**
209
+ * 画面尺寸变更。**只记录尺寸,不重建任何资源**——本渲染器的缓冲全部按点数分配,与画面
210
+ * 尺寸无关(软光栅那条路径才有按方格数分配的缓冲)。
211
+ *
212
+ * 尺寸进入两处 uniform:Projector 的 `focal` / `viewport`(决定椭圆的像素尺寸与出屏判定),
213
+ * Draw 的 `viewport`(把像素单位的椭圆轴换算回 NDC)。两处都在 `submitFrame` 里逐帧写。
214
+ */
215
+ resize(width: number, height: number): void;
216
+ /** 创建一块缓冲。失败即抛,由调用栈冒泡出去暴露问题,不做降级。 */
217
+ private createBuffer;
218
+ private destroyBufferSafely;
219
+ /**
220
+ * 建 quad 的索引缓冲:`0, 1, 2, …, 6 * QUAD_PER_INSTANCE - 1` 的**恒等序列**。
221
+ *
222
+ * **indexed draw 里 `@builtin(vertex_index)` 就是索引缓冲里取出的那个值**,不是绘制序号。
223
+ * 而 `gsplatQuad.wgsl` 按 `vi / 6` 取 quadSlot、`vi % 6` 取 corner,因此索引内容只能是恒等
224
+ * 序列。最初照搬 Fallback packing 几何体的 `quad * 4 + [0,1,2, 0,2,3]`,结果 `vi` 拿到
225
+ * `0,1,2,0,2,3, 4,5,6,…`:第一个 quad 恰好正确、从第二个起全部错位,顶点互相串到别的 quad
226
+ * 上,画面变成无数无规则三角形而所有指标都正常。两者索引的职责不同——Fallback 有真正的顶点
227
+ * 缓冲、索引用来寻址顶点属性,本路径没有顶点缓冲、索引值直接成为 `vertex_index`。
228
+ *
229
+ * 恒等序列意味着这块缓冲不携带信息,`drawIndexedIndirect` 已退化成 `drawIndirect`。
230
+ * **后续可去掉本缓冲与 `setIndexBuffer`、把 Indirect_Pass 的输出改回 4 元组。**
231
+ */
232
+ private createQuadIndexBuffer;
233
+ /**
234
+ * 确保 Projected_Cache 的容量足够 `totalPoints` 个点。高水位增长、点数缩小时不缩容。
235
+ *
236
+ * @returns 是否可用。为 false 时调用方应跳过本帧
237
+ */
238
+ private ensureProjectedCache;
239
+ /**
240
+ * 确保排序键缓冲的容量足够。容量按 2048 元素向上对齐——与
241
+ * `RadixSortModule.ELEMENTS_PER_WORKGROUP` 同粒度,**这是硬要求而非保守估计**(理由见字段
242
+ * 声明处)。
243
+ */
244
+ private ensureSortKeys;
245
+ /**
246
+ * 写 Projector uniform 里**不随帧变化**的六个常量。构造期一次,此后不再写。
247
+ *
248
+ * 六个常量全部取自 `cullConstants.ts`,与 Fallback_Path 及诊断的 CPU 参考实现同源——
249
+ * 这是「常量唯一来源」这条性质的实现方式,不在着色器里写字面量。
250
+ */
251
+ private writeProjectorUniformConstants;
252
+ /**
253
+ * 写 Projector uniform 的逐帧字段:两个矩阵、focal、viewport、点数与布局表项数。
254
+ *
255
+ * 整块写 176 字节而不是逐字段写:常量部分早已在同一块 scratch 里,一次 `writeBuffer` 比
256
+ * 六次更省,且避免「改了字段忘了同步偏移」这类错误只在某个字段上显现。
257
+ */
258
+ private writeProjectorFrameUniform;
259
+ /**
260
+ * 写 Draw uniform:viewport 与投影矩阵的 `elements[10]` / `elements[14]`。顶点着色器用后两者
261
+ * 从线性视深度重建 `clip.z`。**用矩阵元素而非 `far/(far-near)` 闭式**,以自动适配正交与
262
+ * 非对称投影。
263
+ */
264
+ private writeDrawUniform;
265
+ private static sourcesEqual;
266
+ /**
267
+ * Projector 的 bind group。`variant` 与 `bakedView` 都纳入句柄快照:换变体(layout 不同)或
268
+ * 烘焙 RT 重建(view 换手)都会重建。
269
+ */
270
+ private ensureProjectorBindGroup;
271
+ private ensureIndirectBindGroup;
272
+ /**
273
+ * Draw_Pass 的 bind group。
274
+ *
275
+ * `sortedIndices` 由 `RadixSortModule.encode` 返回,**必须显式取用返回的句柄**并纳入快照:
276
+ * 它是模块内部 ping-pong 的一侧,身份随排序趟数的奇偶切换,不可按趟数推算。
277
+ */
278
+ private ensureDrawBindGroup;
279
+ /**
280
+ * 本帧数据未就绪,跳过绘制。多数原因(Arena 尚未 sync、点数为 0)是正常路径。
281
+ *
282
+ * 置 `lastFrameComplete = false`:本帧没有完整链路,下一帧不得复用
283
+ *(`projectedCache` 可能从未被写过)。
284
+ */
285
+ private reportSkip;
286
+ /**
287
+ * 写 Effect uniform 的逐帧字段:`cameraWorldPos`、`shBaked`(与本帧所选变体一致)。
288
+ * 入场动画与 clipper 的字段先占位(尚未迁进着色器),命中这两种情形的场景由
289
+ * `Render_Mesh` 侧强制回落 Fallback。
290
+ *
291
+ * `cameraWorldPos` 取 `matrixWorld` 的平移列而**不是** `matrixWorldInverse` 的——后者是
292
+ * `-R·t`、不是相机位置。
293
+ */
294
+ private writeEffectUniform;
295
+ /**
296
+ * 判定本帧能否直接重放上一帧的绘制结果(相机与数据都未变)。
297
+ *
298
+ * **必须在 `prepareFrame` 之前调用**:那里会 `upload()` 三块镜像,而 `upload` 会清掉
299
+ * `isDirty`,之后就查不出数据是否变过了。
300
+ *
301
+ * 相机比对取 `matrixWorld` 与 `projectionMatrix` 的全部元素而不是算出来的 `viewProj`:
302
+ * 前者是后者的唯一来源,逐元素相等即 `viewProj` 与 `focal` 都不变,且省一次矩阵乘法。
303
+ */
304
+ private canReplayLastFrame;
305
+ /** 记录本帧的相机与数据快照,供下一帧的复用判定使用。 */
306
+ private captureFrameSnapshot;
307
+ /**
308
+ * 把 3DGS 的绘制命令录进**外部传入的** render pass,不自己 `beginRenderPass`。
309
+ *
310
+ * 之所以不自建 pass:3DGS 在 Fallback 语义下是 transparent 队列的**第一个**对象
311
+ * (`Render_Mesh.renderOrder = -99999999999`),其后所有半透明与 overlay 对象都要叠在它之上。
312
+ * 自建 pass 只能排在 three 整个 `render()` 之后,等于把 3DGS 挪到全场最后画,把 grid、
313
+ * `intersectMesh`(`renderOrder = 9999999999`)这类顶层辅助元素全盖住。录进 three 正在用的
314
+ * 那条 pass、且时机取在 `Render_Mesh.onAfterRender`,位置才与 Fallback 逐帧一致。
315
+ *
316
+ * 附件与深度状态由 three 的 pass 决定,本方法只设 pipeline / bindGroup / indexBuffer。
317
+ * 「只测不写」仍由 `drawPipeline` 的 `depthWriteEnabled: false` 保证。
318
+ */
319
+ private encodeDrawInto;
320
+ /**
321
+ * 帧前准备:全部在 encoder 之外完成(镜像 upload、uniform 写入、按需扩容、bind group)。
322
+ *
323
+ * 返回 `null` 表示本帧不具备绘制条件,调用方跳过 ③~⑥ 但仍提交已编码的装配与清零(两者与
324
+ * 画面无关且幂等)。**镜像不可用不标记本渲染器不可用**——那是容量超限,与本渲染器自身的
325
+ * 资源无关,且降级由镜像自己记住。
326
+ */
327
+ private prepareFrame;
328
+ /**
329
+ * 编码并提交一帧。每帧一个 `GPUCommandEncoder`、恰好一次 `queue.submit`。
330
+ *
331
+ * ## 编码次序
332
+ *
333
+ * ```
334
+ * ① Arena 装配 → ② 清 renderCount / indirectArgs
335
+ * → ③ 一个 compute pass:fill_sort_keys → Projector → Indirect
336
+ * → ④ 深度排序 → ⑤ Render_Count 回读拷贝 → ⑥ submit(本类自己的 encoder)
337
+ * → ⑦ 把 Draw 命令录进 three 的 render pass(属于 three 的 command buffer)
338
+ * ```
339
+ *
340
+ * **⑥ 与 ⑦ 分属两个 command buffer**,这是被 WebGPU 的规则逼出来的:compute pass 不能在
341
+ * render pass 活跃期间开启,而本方法的调用时机(`Render_Mesh.onAfterRender`)正处在 three
342
+ * 的 render pass 内。于是 compute 走自己的 encoder 先 submit,draw 录进 three 那条 pass、
343
+ * 随 three 的 buffer 后 submit。同一 queue 按 submit 顺序执行且有隐式内存屏障,故 draw 一定
344
+ * 看得到 compute 的结果。反过来(draw 先 submit)会读到上一帧的 `projectedCache`。
345
+ *
346
+ * **① 必须最先**:拷贝命令一旦落在 pass 之后,Projector 读到的就是上一帧的 Arena 内容。
347
+ *
348
+ * **③ 三趟能合进一个 pass**:同 pass 内相邻 dispatch 之间有隐式的执行序与内存可见性保证,
349
+ * 而这三趟是一条线性依赖链(填哨兵 → 覆盖前 `Render_Count` 项并写计数器 → 读计数器写
350
+ * draw args)。前两趟共用同一个 bind group,故 `setBindGroup` 只调一次。
351
+ *
352
+ * **④ 不能也合进去**:`RadixSortModule.encode` 内部自己 `beginComputePass`。
353
+ *
354
+ * **⑦ 的附件由 three 的 pass 决定**,本类不再自建 render pass(理由见 `encodeDrawInto`)。
355
+ * `Render_Count` 为 0 时 `instanceCount` 也是 0,`drawIndexedIndirect` 是合法空操作,**故这
356
+ * 条命令照常录制**——跳过它需要 CPU 知道 Render_Count,而回读滞后一帧。
357
+ *
358
+ * @param drawPass three 当前活跃的 render pass,Draw 命令录进它(本类不 begin / 不 end)
359
+ * @param arena 装配器,为 `null` 时不编码任何拷贝、且跳过 ③~⑦
360
+ * @param camera 当前相机,`view` / `viewProj` / `focal` 都由它导出
361
+ * @param mirrors Projector_Pass 所需的三块镜像,为 `null` 时跳过 ③~⑦
362
+ */
363
+ submitFrame(drawPass: GPURenderPassEncoder, arena: SplatArena | null, camera: THREE.Camera, mirrors: GSplatMirrorSet | null): void;
364
+ /**
365
+ * 编码 Render_Count 的回读拷贝。已有回读在途时不编码(返回 `null`)。
366
+ *
367
+ * staging 每次新建、用完即销毁:4 字节的分配开销远低于「维护一个池子」的复杂度,且新建
368
+ * 天然避免「上一次的映射还没解除」这类状态纠缠。在途标志因此只用于抑制并发,不用于复用。
369
+ */
370
+ private encodeCheapReadback;
371
+ /**
372
+ * 完成一次 Render_Count 的回读。
373
+ *
374
+ * 失败静默:`dispose` 或 device lost 之后映射必然失败,那属于正常收尾而非故障。回读只服务
375
+ * 诊断(面板上的存活点数),失败不影响画面。
376
+ */
377
+ private finishCheapReadback;
378
+ /**
379
+ * 释放全部 GPU 资源。**幂等。** 管线与 layout 无需显式释放(WebGPU 无对应 API);bind group
380
+ * 的引用置空使它们不再钉住被销毁的缓冲。
381
+ *
382
+ * 回读的 staging 不在这里销毁:它可能正处于 `mapAsync` 在途,由 `finishCheapReadback` 的
383
+ * `finally` 负责。
384
+ */
385
+ dispose(): void;
386
+ }