@d5techs/3dgs-lib 1.0.1 → 1.1.0
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/README.md +311 -136
- package/dist/3dgs-lib.cjs +1442 -1976
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +1443 -1977
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/App.d.ts +1 -1
- package/dist/core/BoundingBoxRenderer.d.ts +3 -14
- package/dist/gs/GSSplatRenderer.d.ts +26 -176
- package/dist/gs/GSSplatRendererMobile.d.ts +8 -6
- package/dist/gs/GSSplatSorter.d.ts +41 -37
- package/dist/gs/IGSSplatRenderer.d.ts +10 -37
- package/dist/index.d.ts +9 -6
- package/dist/interaction/GizmoManager.d.ts +4 -41
- package/dist/loaders/GLBLoader.d.ts +3 -11
- package/dist/loaders/OBJLoader.d.ts +1 -1
- package/dist/mesh/Mesh.d.ts +6 -10
- package/dist/scene/SceneManager.d.ts +6 -6
- package/dist/scene/proxies/MeshGroupProxy.d.ts +20 -0
- package/dist/scene/proxies/SplatBoundingBoxProvider.d.ts +11 -0
- package/dist/scene/proxies/SplatTransformProxy.d.ts +17 -0
- package/dist/scene/proxies/index.d.ts +6 -0
- package/dist/types/geometry.d.ts +60 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/material.d.ts +27 -0
- package/dist/types/splat.d.ts +25 -0
- package/dist/utils/device.d.ts +17 -0
- package/dist/utils/geometry.d.ts +26 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/texture.d.ts +64 -0
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { MeshRenderer } from "./mesh/MeshRenderer";
|
|
|
17
17
|
import { Mesh } from "./mesh/Mesh";
|
|
18
18
|
import { GSSplatRenderer } from "./gs/GSSplatRenderer";
|
|
19
19
|
import { GSSplatRendererMobile } from "./gs/GSSplatRendererMobile";
|
|
20
|
-
import { BoundingBox } from "./
|
|
20
|
+
import type { BoundingBox } from "./types";
|
|
21
21
|
import { SplatTransformProxy, MeshGroupProxy, SplatBoundingBoxProvider } from "./interaction/GizmoManager";
|
|
22
22
|
import { TransformableObject, GizmoMode } from "./core/gizmo/TransformGizmoV2";
|
|
23
23
|
import { BoundingBoxProvider } from "./core/BoundingBoxRenderer";
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { Renderer } from "./Renderer";
|
|
2
2
|
import { Camera } from "./Camera";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface BoundingBox {
|
|
7
|
-
min: [number, number, number];
|
|
8
|
-
max: [number, number, number];
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* BoundingBoxProvider - 包围盒数据提供者接口
|
|
12
|
-
* 实现此接口的对象可以动态提供包围盒数据
|
|
13
|
-
*/
|
|
14
|
-
export interface BoundingBoxProvider {
|
|
15
|
-
getBoundingBox(): BoundingBox | null;
|
|
16
|
-
}
|
|
3
|
+
import type { SimpleBoundingBox, BoundingBoxProvider } from "../types";
|
|
4
|
+
export type { BoundingBoxProvider };
|
|
5
|
+
export type BoundingBox = SimpleBoundingBox;
|
|
17
6
|
/**
|
|
18
7
|
* BoundingBoxRenderer - 包围盒线框渲染器
|
|
19
8
|
* 用于显示选中对象的包围盒,支持动态跟随
|
|
@@ -1,77 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSSplatRenderer - 优化的 3D Gaussian Splatting 渲染器
|
|
3
|
+
*
|
|
4
|
+
* 基于 rfs-gsplat-render 的实现进行优化:
|
|
5
|
+
* 1. GPU Radix Sort - O(n) 稳定排序
|
|
6
|
+
* 2. Normalized Gaussian - 消除边缘雾化
|
|
7
|
+
* 3. ClipCorner 优化 - 减少 overdraw
|
|
8
|
+
* 4. MipSplatting 抗锯齿
|
|
9
|
+
* 5. 改进的视锥剔除
|
|
10
|
+
*/
|
|
1
11
|
import { Renderer } from "../core/Renderer";
|
|
2
12
|
import { Camera } from "../core/Camera";
|
|
3
13
|
import { SplatCPU } from "./PLYLoader";
|
|
4
14
|
import { CompactSplatData } from "./PLYLoaderMobile";
|
|
5
|
-
import { BoundingBox
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
HIGH = "high",// 桌面高端 GPU
|
|
11
|
-
MEDIUM = "medium",// 桌面中端
|
|
12
|
-
LOW = "low"
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 移动端优化配置
|
|
16
|
-
*/
|
|
17
|
-
export interface MobileOptimizationConfig {
|
|
18
|
-
maxVisibleSplats: number;
|
|
19
|
-
enableSorting: boolean;
|
|
20
|
-
sortEveryNFrames: number;
|
|
21
|
-
useCompactFormat: boolean;
|
|
22
|
-
pixelCullThreshold: number;
|
|
23
|
-
defaultSHMode: SHMode;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* SH 模式枚举
|
|
27
|
-
* @deprecated 使用 IGSSplatRenderer 中的 SHMode
|
|
28
|
-
*/
|
|
29
|
-
export declare enum SHMode {
|
|
30
|
-
L0 = 0,// 仅 DC 颜色 (高性能)
|
|
31
|
-
L1 = 1,// DC + L1 SH
|
|
32
|
-
L2 = 2,// DC + L1 + L2 SH
|
|
33
|
-
L3 = 3
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Bounding Box 结构
|
|
37
|
-
* @deprecated 使用 IGSSplatRenderer 中的 BoundingBox
|
|
38
|
-
*/
|
|
39
|
-
export interface BoundingBox {
|
|
40
|
-
min: [number, number, number];
|
|
41
|
-
max: [number, number, number];
|
|
42
|
-
center: [number, number, number];
|
|
43
|
-
radius: number;
|
|
44
|
-
}
|
|
45
|
-
export type { IBoundingBox as GSBoundingBox };
|
|
15
|
+
import type { BoundingBox, Vec3Tuple } from "../types";
|
|
16
|
+
import { SHMode, RendererCapabilities } from "../types";
|
|
17
|
+
import type { IGSSplatRendererWithCapabilities } from "./IGSSplatRenderer";
|
|
18
|
+
export { SHMode };
|
|
19
|
+
export type { BoundingBox };
|
|
46
20
|
/**
|
|
47
|
-
*
|
|
48
|
-
* 使用 instanced quad 方式渲染 splats
|
|
49
|
-
* 实现 IGSSplatRenderer 接口
|
|
50
|
-
*
|
|
51
|
-
* 优化功能:
|
|
52
|
-
* - GPU 可见性剔除 (视锥/近平面/屏幕尺寸)
|
|
53
|
-
* - DrawIndirect 避免 CPU submit 开销
|
|
54
|
-
* - 仅对可见 splat 排序
|
|
55
|
-
* - 移动端自动优化(降低排序频率、使用紧凑格式)
|
|
21
|
+
* GSSplatRendererV2 - 优化的渲染器
|
|
56
22
|
*/
|
|
57
23
|
export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities {
|
|
58
24
|
private renderer;
|
|
59
25
|
private camera;
|
|
60
|
-
private
|
|
61
|
-
private pipelineL1;
|
|
62
|
-
private pipelineL2;
|
|
63
|
-
private pipelineL3;
|
|
64
|
-
private pipelineL0Compact;
|
|
26
|
+
private pipeline;
|
|
65
27
|
private bindGroupLayout;
|
|
66
|
-
private bindGroupLayoutCompact;
|
|
67
28
|
private uniformBuffer;
|
|
68
29
|
private splatBuffer;
|
|
69
30
|
private splatCount;
|
|
70
31
|
private bindGroup;
|
|
71
32
|
private sorter;
|
|
72
|
-
private useDrawIndirect;
|
|
73
|
-
private isMobile;
|
|
74
|
-
private pixelCullThreshold;
|
|
75
33
|
private shMode;
|
|
76
34
|
private boundingBox;
|
|
77
35
|
private position;
|
|
@@ -79,139 +37,31 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
79
37
|
private scale;
|
|
80
38
|
private pivot;
|
|
81
39
|
private modelMatrix;
|
|
82
|
-
private
|
|
83
|
-
private optimizationConfig;
|
|
84
|
-
private frameCount;
|
|
85
|
-
private useCompactFormat;
|
|
40
|
+
private pixelCullThreshold;
|
|
86
41
|
constructor(renderer: Renderer, camera: Camera);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*/
|
|
42
|
+
private createPipeline;
|
|
43
|
+
private createUniformBuffer;
|
|
90
44
|
setPosition(x: number, y: number, z: number): void;
|
|
91
|
-
|
|
92
|
-
* 获取位置
|
|
93
|
-
*/
|
|
94
|
-
getPosition(): [number, number, number];
|
|
95
|
-
/**
|
|
96
|
-
* 设置旋转 (欧拉角, 弧度)
|
|
97
|
-
*/
|
|
45
|
+
getPosition(): Vec3Tuple;
|
|
98
46
|
setRotation(x: number, y: number, z: number): void;
|
|
99
|
-
|
|
100
|
-
* 获取旋转
|
|
101
|
-
*/
|
|
102
|
-
getRotation(): [number, number, number];
|
|
103
|
-
/**
|
|
104
|
-
* 设置缩放
|
|
105
|
-
*/
|
|
47
|
+
getRotation(): Vec3Tuple;
|
|
106
48
|
setScale(x: number, y: number, z: number): void;
|
|
107
|
-
|
|
108
|
-
* 获取缩放
|
|
109
|
-
*/
|
|
110
|
-
getScale(): [number, number, number];
|
|
111
|
-
/**
|
|
112
|
-
* 设置旋转/缩放中心点 (pivot)
|
|
113
|
-
*/
|
|
49
|
+
getScale(): Vec3Tuple;
|
|
114
50
|
setPivot(x: number, y: number, z: number): void;
|
|
115
|
-
|
|
116
|
-
* 获取旋转/缩放中心点 (pivot)
|
|
117
|
-
*/
|
|
118
|
-
getPivot(): [number, number, number];
|
|
119
|
-
/**
|
|
120
|
-
* 更新模型矩阵
|
|
121
|
-
* 变换顺序: T * Tp * R * S * Tp^-1
|
|
122
|
-
* 即: 先移到原点,缩放,旋转,再移回pivot,最后应用用户平移
|
|
123
|
-
*/
|
|
51
|
+
getPivot(): Vec3Tuple;
|
|
124
52
|
private updateModelMatrix;
|
|
125
|
-
/**
|
|
126
|
-
* 获取当前模型矩阵
|
|
127
|
-
*/
|
|
128
53
|
getModelMatrix(): Float32Array;
|
|
129
|
-
/**
|
|
130
|
-
* 获取当前性能等级
|
|
131
|
-
*/
|
|
132
|
-
getPerformanceTier(): PerformanceTier;
|
|
133
|
-
/**
|
|
134
|
-
* 手动设置优化配置
|
|
135
|
-
*/
|
|
136
|
-
setOptimizationConfig(config: Partial<MobileOptimizationConfig>): void;
|
|
137
|
-
/**
|
|
138
|
-
* 获取当前优化配置
|
|
139
|
-
*/
|
|
140
|
-
getOptimizationConfig(): MobileOptimizationConfig;
|
|
141
|
-
/**
|
|
142
|
-
* 设置 SH 模式
|
|
143
|
-
* @param mode L0/L1/L2/L3
|
|
144
|
-
*/
|
|
145
54
|
setSHMode(mode: SHMode): void;
|
|
146
|
-
/**
|
|
147
|
-
* 获取当前 SH 模式
|
|
148
|
-
*/
|
|
149
55
|
getSHMode(): SHMode;
|
|
150
|
-
/**
|
|
151
|
-
* 设置是否启用 DrawIndirect (剔除优化)
|
|
152
|
-
* 启用后会在 GPU 上进行可见性剔除,仅绘制可见 splat
|
|
153
|
-
*/
|
|
154
|
-
setUseDrawIndirect(enabled: boolean): void;
|
|
155
|
-
/**
|
|
156
|
-
* 设置像素剔除阈值
|
|
157
|
-
* 屏幕上小于此像素数的 splat 会被剔除
|
|
158
|
-
* @param threshold 像素阈值,默认 1.0
|
|
159
|
-
*/
|
|
160
56
|
setPixelCullThreshold(threshold: number): void;
|
|
161
|
-
/**
|
|
162
|
-
* 创建渲染管线 (L0/L1/L2/L3 四个版本)
|
|
163
|
-
*/
|
|
164
|
-
private createPipelines;
|
|
165
|
-
/**
|
|
166
|
-
* 创建 uniform buffer
|
|
167
|
-
* 布局: view (64 bytes) + proj (64 bytes) + model (64 bytes) + cameraPos (12 bytes) + padding (4 bytes) + screenSize (8 bytes) + padding (8 bytes) = 224 bytes
|
|
168
|
-
*/
|
|
169
|
-
private createUniformBuffer;
|
|
170
|
-
/**
|
|
171
|
-
* 设置 splat 数据
|
|
172
|
-
* @param splats CPU 端的 splat 数组
|
|
173
|
-
*/
|
|
174
57
|
setData(splats: SplatCPU[]): void;
|
|
175
|
-
/**
|
|
176
|
-
* 设置紧凑格式的 splat 数据(移动端优化)
|
|
177
|
-
* 直接接受 CompactSplatData,避免创建中间对象
|
|
178
|
-
* @param compactData 紧凑格式的 splat 数据
|
|
179
|
-
*/
|
|
180
58
|
setCompactData(compactData: CompactSplatData): void;
|
|
181
|
-
/**
|
|
182
|
-
* 从紧凑数据计算 bounding box
|
|
183
|
-
*/
|
|
184
|
-
private computeBoundingBoxFromCompact;
|
|
185
|
-
/**
|
|
186
|
-
* 渲染 splats
|
|
187
|
-
* @param pass 渲染通道编码器
|
|
188
|
-
*/
|
|
189
59
|
render(pass: GPURenderPassEncoder): void;
|
|
190
|
-
/**
|
|
191
|
-
* 获取 splat 数量
|
|
192
|
-
*/
|
|
193
60
|
getSplatCount(): number;
|
|
194
|
-
/**
|
|
195
|
-
* 获取点云的 bounding box
|
|
196
|
-
* @returns BoundingBox 或 null(如果没有点云数据)
|
|
197
|
-
*/
|
|
198
61
|
getBoundingBox(): BoundingBox | null;
|
|
199
|
-
/**
|
|
200
|
-
* 计算点云的 bounding box
|
|
201
|
-
* @param splats splat 数组
|
|
202
|
-
* @returns BoundingBox
|
|
203
|
-
*/
|
|
204
62
|
private computeBoundingBox;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
*/
|
|
208
|
-
supportsSHMode(mode: ISHMode): boolean;
|
|
209
|
-
/**
|
|
210
|
-
* 获取渲染器能力
|
|
211
|
-
*/
|
|
63
|
+
private computeBoundingBoxFromCompact;
|
|
64
|
+
supportsSHMode(mode: SHMode): boolean;
|
|
212
65
|
getCapabilities(): RendererCapabilities;
|
|
213
|
-
/**
|
|
214
|
-
* 销毁资源
|
|
215
|
-
*/
|
|
216
66
|
destroy(): void;
|
|
217
67
|
}
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
import { Renderer } from "../core/Renderer";
|
|
11
11
|
import { Camera } from "../core/Camera";
|
|
12
12
|
import { CompactSplatData } from "./PLYLoaderMobile";
|
|
13
|
-
import { BoundingBox,
|
|
14
|
-
|
|
13
|
+
import type { BoundingBox, Vec3Tuple } from "../types";
|
|
14
|
+
import { SHMode, RendererCapabilities } from "../types";
|
|
15
|
+
import type { IGSSplatRendererWithCapabilities } from "./IGSSplatRenderer";
|
|
16
|
+
export type { BoundingBox };
|
|
15
17
|
/**
|
|
16
18
|
* GSSplatRendererMobile - 移动端优化渲染器
|
|
17
19
|
* 实现 IGSSplatRenderer 接口
|
|
@@ -45,7 +47,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
45
47
|
/**
|
|
46
48
|
* 获取位置
|
|
47
49
|
*/
|
|
48
|
-
getPosition():
|
|
50
|
+
getPosition(): Vec3Tuple;
|
|
49
51
|
/**
|
|
50
52
|
* 设置旋转 (欧拉角, 弧度)
|
|
51
53
|
*/
|
|
@@ -53,7 +55,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
53
55
|
/**
|
|
54
56
|
* 获取旋转
|
|
55
57
|
*/
|
|
56
|
-
getRotation():
|
|
58
|
+
getRotation(): Vec3Tuple;
|
|
57
59
|
/**
|
|
58
60
|
* 设置缩放
|
|
59
61
|
*/
|
|
@@ -61,7 +63,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
61
63
|
/**
|
|
62
64
|
* 获取缩放
|
|
63
65
|
*/
|
|
64
|
-
getScale():
|
|
66
|
+
getScale(): Vec3Tuple;
|
|
65
67
|
/**
|
|
66
68
|
* 设置旋转/缩放中心点 (pivot)
|
|
67
69
|
*/
|
|
@@ -69,7 +71,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
69
71
|
/**
|
|
70
72
|
* 获取旋转/缩放中心点 (pivot)
|
|
71
73
|
*/
|
|
72
|
-
getPivot():
|
|
74
|
+
getPivot(): Vec3Tuple;
|
|
73
75
|
/**
|
|
74
76
|
* 更新模型矩阵
|
|
75
77
|
* 变换顺序: T * Tp * R * S * Tp^-1
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GSSplatSorter - GPU
|
|
2
|
+
* GSSplatSorter - GPU Radix Sort 深度排序器
|
|
3
3
|
*
|
|
4
|
-
* 基于
|
|
5
|
-
*
|
|
4
|
+
* 基于 rfs-gsplat-render 的 3-Pass Radix Sort 架构实现:
|
|
5
|
+
* - 4 个 pass (8-bit 增量,总共 32 位)
|
|
6
|
+
* - 每个 pass 包含: Upsweep -> Spine -> Downsweep
|
|
7
|
+
* - 稳定排序,解决远距离闪烁问题
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
* 1. 剔除 + 计算深度 + 统计计数
|
|
9
|
-
* 2. 前缀和计算偏移
|
|
10
|
-
* 3. 散射到最终位置
|
|
11
|
-
*
|
|
12
|
-
* iOS 兼容性:
|
|
13
|
-
* - iOS WebGPU 对大型原子数组支持有限
|
|
14
|
-
* - 默认使用 65536 个桶(桌面/Android)
|
|
15
|
-
* - iOS 使用 4096 个桶(减少原子操作压力)
|
|
9
|
+
* 参考: rfs-gsplat-render/assets/shaders/radix_sort.wgsl
|
|
16
10
|
*/
|
|
17
11
|
/**
|
|
18
12
|
* 屏幕尺寸信息
|
|
@@ -28,48 +22,61 @@ export interface CullingOptions {
|
|
|
28
22
|
nearPlane: number;
|
|
29
23
|
farPlane: number;
|
|
30
24
|
pixelThreshold: number;
|
|
25
|
+
frustumDilation?: number;
|
|
31
26
|
}
|
|
32
27
|
/**
|
|
33
28
|
* 排序器配置选项
|
|
34
29
|
*/
|
|
35
30
|
export interface SorterOptions {
|
|
36
|
-
/**
|
|
31
|
+
/** 暂时保留,Radix Sort 不使用桶配置 */
|
|
37
32
|
numBuckets?: number;
|
|
38
33
|
}
|
|
39
34
|
/**
|
|
40
|
-
* GSSplatSorter - GPU
|
|
35
|
+
* GSSplatSorter - GPU Radix Sort 排序器
|
|
36
|
+
* 基于 rfs-gsplat-render 的 3-Pass Radix Sort 实现
|
|
41
37
|
*/
|
|
42
38
|
export declare class GSSplatSorter {
|
|
43
39
|
private device;
|
|
44
40
|
private splatCount;
|
|
45
41
|
private cullingParamsBuffer;
|
|
46
|
-
private countersBuffer;
|
|
47
|
-
private visibleIndicesBuffer;
|
|
48
42
|
private depthKeysBuffer;
|
|
49
|
-
private
|
|
50
|
-
private
|
|
51
|
-
private
|
|
43
|
+
private visibleIndicesBuffer;
|
|
44
|
+
private indirectBuffer;
|
|
45
|
+
private globalHistogramBuffer;
|
|
46
|
+
private partitionHistogramBuffer;
|
|
47
|
+
private keysTempBuffer;
|
|
48
|
+
private valuesTempBuffer;
|
|
49
|
+
private sortParamsBuffers;
|
|
52
50
|
private sortedIndicesBuffer;
|
|
53
|
-
private
|
|
54
|
-
private
|
|
55
|
-
private resetBucketCountsPipeline;
|
|
56
|
-
private cullAndCountPipeline;
|
|
57
|
-
private updateDrawIndirectPipeline;
|
|
58
|
-
private prefixSumPipeline;
|
|
59
|
-
private resetBucketPositionsPipeline;
|
|
60
|
-
private scatterPipeline;
|
|
51
|
+
private initIndirectPipeline;
|
|
52
|
+
private projectCullPipeline;
|
|
61
53
|
private cullingBindGroupLayout;
|
|
62
54
|
private cullingBindGroup;
|
|
63
|
-
private
|
|
64
|
-
private
|
|
65
|
-
private
|
|
66
|
-
private
|
|
67
|
-
private
|
|
68
|
-
private
|
|
55
|
+
private upsweepPipeline;
|
|
56
|
+
private spinePipeline;
|
|
57
|
+
private downsweepPipeline;
|
|
58
|
+
private upsweepBindGroupLayout;
|
|
59
|
+
private spineBindGroupLayout;
|
|
60
|
+
private downsweepBindGroupLayout;
|
|
61
|
+
private upsweepBindGroups;
|
|
62
|
+
private spineBindGroups;
|
|
63
|
+
private downsweepBindGroups;
|
|
64
|
+
private numPartitions;
|
|
69
65
|
private screenWidth;
|
|
70
66
|
private screenHeight;
|
|
71
67
|
private cullingOptions;
|
|
72
|
-
constructor(device: GPUDevice, splatCount: number, splatBuffer: GPUBuffer, cameraBuffer: GPUBuffer,
|
|
68
|
+
constructor(device: GPUDevice, splatCount: number, splatBuffer: GPUBuffer, cameraBuffer: GPUBuffer, _options?: SorterOptions);
|
|
69
|
+
/**
|
|
70
|
+
* 创建 Radix Sort 的 bind groups
|
|
71
|
+
* 4 个 pass,使用 ping-pong buffers
|
|
72
|
+
*
|
|
73
|
+
* Ping-pong 模式:
|
|
74
|
+
* - Pass 0: depthKeys/visibleIndices -> keysTempBuffer/valuesTempBuffer
|
|
75
|
+
* - Pass 1: keysTempBuffer/valuesTempBuffer -> depthKeys/visibleIndices
|
|
76
|
+
* - Pass 2: depthKeys/visibleIndices -> keysTempBuffer/valuesTempBuffer
|
|
77
|
+
* - Pass 3: keysTempBuffer/valuesTempBuffer -> (depthKeys)/sortedIndicesBuffer
|
|
78
|
+
*/
|
|
79
|
+
private createRadixSortBindGroups;
|
|
73
80
|
/**
|
|
74
81
|
* 设置屏幕尺寸
|
|
75
82
|
*/
|
|
@@ -81,9 +88,6 @@ export declare class GSSplatSorter {
|
|
|
81
88
|
/**
|
|
82
89
|
* 执行剔除和排序
|
|
83
90
|
* 每帧调用
|
|
84
|
-
*
|
|
85
|
-
* 优化:合并所有 compute pass 到单次 GPU 提交
|
|
86
|
-
* WebGPU 保证同一 command buffer 中的命令按顺序执行
|
|
87
91
|
*/
|
|
88
92
|
sort(): void;
|
|
89
93
|
/**
|
|
@@ -3,26 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 桌面端和移动端渲染器都实现此接口,消除平台判断代码
|
|
5
5
|
*/
|
|
6
|
-
import { CompactSplatData } from "./PLYLoaderMobile";
|
|
7
|
-
import { SplatCPU } from "./PLYLoader";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
min: [number, number, number];
|
|
13
|
-
max: [number, number, number];
|
|
14
|
-
center: [number, number, number];
|
|
15
|
-
radius: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* SH 模式枚举
|
|
19
|
-
*/
|
|
20
|
-
export declare enum SHMode {
|
|
21
|
-
L0 = 0,// 仅 DC 颜色(最快)
|
|
22
|
-
L1 = 1,// DC + L1 SH
|
|
23
|
-
L2 = 2,// DC + L1 + L2 SH
|
|
24
|
-
L3 = 3
|
|
25
|
-
}
|
|
6
|
+
import type { CompactSplatData } from "./PLYLoaderMobile";
|
|
7
|
+
import type { SplatCPU } from "./PLYLoader";
|
|
8
|
+
import type { BoundingBox, Vec3Tuple } from "../types";
|
|
9
|
+
import { SHMode, RendererCapabilities } from "../types";
|
|
10
|
+
export type { BoundingBox, Vec3Tuple, RendererCapabilities };
|
|
11
|
+
export { SHMode };
|
|
26
12
|
/**
|
|
27
13
|
* 3D Gaussian Splatting 渲染器接口
|
|
28
14
|
*/
|
|
@@ -47,7 +33,7 @@ export interface IGSSplatRenderer {
|
|
|
47
33
|
/**
|
|
48
34
|
* 获取位置
|
|
49
35
|
*/
|
|
50
|
-
getPosition():
|
|
36
|
+
getPosition(): Vec3Tuple;
|
|
51
37
|
/**
|
|
52
38
|
* 设置旋转(欧拉角,弧度)
|
|
53
39
|
*/
|
|
@@ -55,7 +41,7 @@ export interface IGSSplatRenderer {
|
|
|
55
41
|
/**
|
|
56
42
|
* 获取旋转
|
|
57
43
|
*/
|
|
58
|
-
getRotation():
|
|
44
|
+
getRotation(): Vec3Tuple;
|
|
59
45
|
/**
|
|
60
46
|
* 设置缩放
|
|
61
47
|
*/
|
|
@@ -63,7 +49,7 @@ export interface IGSSplatRenderer {
|
|
|
63
49
|
/**
|
|
64
50
|
* 获取缩放
|
|
65
51
|
*/
|
|
66
|
-
getScale():
|
|
52
|
+
getScale(): Vec3Tuple;
|
|
67
53
|
/**
|
|
68
54
|
* 设置旋转/缩放中心点(pivot)
|
|
69
55
|
*/
|
|
@@ -71,7 +57,7 @@ export interface IGSSplatRenderer {
|
|
|
71
57
|
/**
|
|
72
58
|
* 获取旋转/缩放中心点(pivot)
|
|
73
59
|
*/
|
|
74
|
-
getPivot():
|
|
60
|
+
getPivot(): Vec3Tuple;
|
|
75
61
|
/**
|
|
76
62
|
* 获取模型矩阵
|
|
77
63
|
*/
|
|
@@ -102,19 +88,6 @@ export interface IGSSplatRenderer {
|
|
|
102
88
|
*/
|
|
103
89
|
destroy(): void;
|
|
104
90
|
}
|
|
105
|
-
/**
|
|
106
|
-
* 渲染器能力描述
|
|
107
|
-
*/
|
|
108
|
-
export interface RendererCapabilities {
|
|
109
|
-
/** 支持的最高 SH 模式 */
|
|
110
|
-
maxSHMode: SHMode;
|
|
111
|
-
/** 是否支持原始 SplatCPU 数据 */
|
|
112
|
-
supportsRawData: boolean;
|
|
113
|
-
/** 是否为移动端优化版本 */
|
|
114
|
-
isMobileOptimized: boolean;
|
|
115
|
-
/** 最大支持的 splat 数量(0 表示无限制) */
|
|
116
|
-
maxSplatCount: number;
|
|
117
|
-
}
|
|
118
91
|
/**
|
|
119
92
|
* 获取渲染器能力(可选方法)
|
|
120
93
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* WebGPU 3D 渲染引擎
|
|
3
3
|
* 库入口文件 - 导出所有公共 API
|
|
4
4
|
*/
|
|
5
|
+
export type { Vec3Tuple, Vec4Tuple, BoundingBox, SimpleBoundingBox, Transform, TransformableObject as ITransformableObject, BoundingBoxProvider as IBoundingBoxProvider, MaterialData, RendererCapabilities, } from './types';
|
|
6
|
+
export { SHMode, DEFAULT_MATERIAL, DEFAULT_OBJ_MATERIAL } from './types';
|
|
7
|
+
export { isMobileDevice, getRecommendedDPR, isWebGPUSupported, computeBoundingBox, mergeBoundingBoxes, createBoundingBoxFromMinMax, transformBoundingBox, loadTextureFromURL, loadTextureFromBlob, loadTextureFromBuffer, createTextureFromImageBitmap, TextureCache, } from './utils';
|
|
5
8
|
export { Renderer } from './core/Renderer';
|
|
6
9
|
export { Camera } from './core/Camera';
|
|
7
10
|
export { OrbitControls } from './core/OrbitControls';
|
|
@@ -12,21 +15,20 @@ export { Mesh } from './mesh/Mesh';
|
|
|
12
15
|
export type { MeshBoundingBox } from './mesh/Mesh';
|
|
13
16
|
export { MeshRenderer } from './mesh/MeshRenderer';
|
|
14
17
|
export { GLBLoader } from './loaders/GLBLoader';
|
|
15
|
-
export type {
|
|
18
|
+
export type { LoadedMesh } from './loaders/GLBLoader';
|
|
16
19
|
export { OBJLoader } from './loaders/OBJLoader';
|
|
17
20
|
export { OBJParser } from './loaders/OBJParser';
|
|
18
21
|
export type { ParsedOBJData, ParsedObject } from './loaders/OBJParser';
|
|
19
22
|
export { MTLParser } from './loaders/MTLParser';
|
|
20
23
|
export type { ParsedMaterial } from './loaders/MTLParser';
|
|
21
|
-
export type { IGSSplatRenderer, IGSSplatRendererWithCapabilities,
|
|
24
|
+
export type { IGSSplatRenderer, IGSSplatRendererWithCapabilities, } from './gs/IGSSplatRenderer';
|
|
22
25
|
export { loadPLY } from './gs/PLYLoader';
|
|
23
26
|
export type { SplatCPU } from './gs/PLYLoader';
|
|
24
27
|
export { loadPLYMobile, parsePLYBuffer, compactDataToGPUBuffer } from './gs/PLYLoaderMobile';
|
|
25
28
|
export type { MobileLoadOptions, CompactSplatData } from './gs/PLYLoaderMobile';
|
|
26
29
|
export { loadSplat, deserializeSplat } from './gs/SplatLoader';
|
|
27
|
-
export { GSSplatRenderer,
|
|
28
|
-
export {
|
|
29
|
-
export type { MobileOptimizationConfig } from './gs/GSSplatRenderer';
|
|
30
|
+
export { GSSplatRenderer, SHMode as GSSHMode } from './gs/GSSplatRenderer';
|
|
31
|
+
export type { BoundingBox as GSSplatBoundingBox } from './gs/GSSplatRenderer';
|
|
30
32
|
export { GSSplatSorter } from './gs/GSSplatSorter';
|
|
31
33
|
export type { SorterOptions, CullingOptions, ScreenInfo } from './gs/GSSplatSorter';
|
|
32
34
|
export { GSSplatRendererMobile } from './gs/GSSplatRendererMobile';
|
|
@@ -36,8 +38,9 @@ export { compressSplatsToTextures, destroyCompressedTextures, calculateTextureDi
|
|
|
36
38
|
export type { CompressedSplatTextures } from './gs/TextureCompressor';
|
|
37
39
|
export { SceneManager } from './scene/SceneManager';
|
|
38
40
|
export type { SceneObjectType, SceneObjectInfo } from './scene/SceneManager';
|
|
41
|
+
export { SplatTransformProxy, MeshGroupProxy, SplatBoundingBoxProvider, } from './scene/proxies';
|
|
39
42
|
export { GizmoManager, SplatTransformProxy as GizmoSplatTransformProxy, MeshGroupProxy as GizmoMeshGroupProxy, SplatBoundingBoxProvider as GizmoSplatBoundingBoxProvider } from './interaction/GizmoManager';
|
|
40
|
-
export { App
|
|
43
|
+
export { App } from './App';
|
|
41
44
|
export type { ProgressCallback } from './App';
|
|
42
45
|
export type { TransformableObject } from './core/gizmo/TransformGizmoV2';
|
|
43
46
|
export { TransformGizmoV2, GizmoMode } from './core/gizmo/TransformGizmoV2';
|
|
@@ -12,47 +12,10 @@ import { OrbitControls } from "../core/OrbitControls";
|
|
|
12
12
|
import { ViewportGizmo } from "../core/ViewportGizmo";
|
|
13
13
|
import { TransformGizmoV2, TransformableObject, GizmoMode } from "../core/gizmo/TransformGizmoV2";
|
|
14
14
|
import { BoundingBoxRenderer, BoundingBox as RendererBoundingBox, BoundingBoxProvider } from "../core/BoundingBoxRenderer";
|
|
15
|
-
import { IGSSplatRenderer } from "../gs/IGSSplatRenderer";
|
|
16
|
-
import { Mesh } from "../mesh/Mesh";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* 实现类似 Mesh 的接口,让 TransformGizmo 可以操作 PLY 模型
|
|
20
|
-
*/
|
|
21
|
-
export declare class SplatTransformProxy implements TransformableObject {
|
|
22
|
-
position: [number, number, number];
|
|
23
|
-
rotation: [number, number, number];
|
|
24
|
-
scale: [number, number, number];
|
|
25
|
-
private renderer;
|
|
26
|
-
private center;
|
|
27
|
-
constructor(renderer: IGSSplatRenderer, center: [number, number, number]);
|
|
28
|
-
setPosition(x: number, y: number, z: number): void;
|
|
29
|
-
setRotation(x: number, y: number, z: number): void;
|
|
30
|
-
setScale(x: number, y: number, z: number): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* MeshGroupProxy - 多 Mesh 组变换代理对象
|
|
34
|
-
* 让 TransformGizmo 可以同时操作多个 Mesh
|
|
35
|
-
*/
|
|
36
|
-
export declare class MeshGroupProxy implements TransformableObject {
|
|
37
|
-
position: [number, number, number];
|
|
38
|
-
rotation: [number, number, number];
|
|
39
|
-
scale: [number, number, number];
|
|
40
|
-
private meshes;
|
|
41
|
-
constructor(meshes: Mesh[]);
|
|
42
|
-
setPosition(x: number, y: number, z: number): void;
|
|
43
|
-
setRotation(x: number, y: number, z: number): void;
|
|
44
|
-
setScale(x: number, y: number, z: number): void;
|
|
45
|
-
getBoundingBox(): RendererBoundingBox | null;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* SplatBoundingBoxProvider - PLY/Splat 包围盒提供者
|
|
49
|
-
* 动态获取 PLY 的包围盒(考虑变换)
|
|
50
|
-
*/
|
|
51
|
-
export declare class SplatBoundingBoxProvider implements BoundingBoxProvider {
|
|
52
|
-
private renderer;
|
|
53
|
-
constructor(renderer: IGSSplatRenderer);
|
|
54
|
-
getBoundingBox(): RendererBoundingBox | null;
|
|
55
|
-
}
|
|
15
|
+
import type { IGSSplatRenderer } from "../gs/IGSSplatRenderer";
|
|
16
|
+
import type { Mesh } from "../mesh/Mesh";
|
|
17
|
+
import { SplatTransformProxy, MeshGroupProxy, SplatBoundingBoxProvider } from "../scene/proxies";
|
|
18
|
+
export { SplatTransformProxy, MeshGroupProxy, SplatBoundingBoxProvider };
|
|
56
19
|
/**
|
|
57
20
|
* GizmoManager - Gizmo 交互管理器
|
|
58
21
|
*/
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { Mesh } from '../mesh/Mesh';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export interface MaterialData {
|
|
6
|
-
baseColorFactor: [number, number, number, number];
|
|
7
|
-
baseColorTexture: GPUTexture | null;
|
|
8
|
-
metallicFactor: number;
|
|
9
|
-
roughnessFactor: number;
|
|
10
|
-
doubleSided: boolean;
|
|
11
|
-
}
|
|
2
|
+
import type { MaterialData } from '../types';
|
|
3
|
+
export type { MaterialData };
|
|
12
4
|
/**
|
|
13
5
|
* 加载后的 Mesh 数据(包含材质)
|
|
14
6
|
*/
|
|
@@ -51,7 +43,7 @@ export declare class GLBLoader {
|
|
|
51
43
|
/**
|
|
52
44
|
* 计算顶点数据的 bounding box
|
|
53
45
|
*/
|
|
54
|
-
private
|
|
46
|
+
private computeBoundingBoxFromPositions;
|
|
55
47
|
/**
|
|
56
48
|
* 获取访问器数据 - 修复字节对齐问题
|
|
57
49
|
*/
|