@d5techs/3dgs-lib 1.4.83 → 1.4.85
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/dist/3dgs-lib.cjs +748 -357
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +748 -357
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/App.d.ts +18 -2
- package/dist/core/OrbitControls.d.ts +1 -0
- package/dist/editor/SplatEditor.d.ts +4 -0
- package/dist/editor/tools/BoxSelection.d.ts +2 -12
- package/dist/editor/tools/SphereSelection.d.ts +2 -9
- package/dist/gs/GSSplatRenderer.d.ts +30 -0
- package/dist/gs/GSSplatSorter.d.ts +12 -9
- package/dist/gs/PLYLoaderMobile.d.ts +6 -0
- package/dist/utils/DebugOverlay.d.ts +30 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -74,11 +74,20 @@ export declare class App {
|
|
|
74
74
|
private isRunning;
|
|
75
75
|
private animationId;
|
|
76
76
|
private useMobileRenderer;
|
|
77
|
+
private isMobile;
|
|
78
|
+
private mobileMaxVisibleCap;
|
|
77
79
|
private lastCompactData;
|
|
78
80
|
private adaptivePerformanceEnabled;
|
|
79
81
|
private adaptiveConfig;
|
|
80
82
|
private lastAppliedRenderScale;
|
|
81
83
|
private baseRenderScale;
|
|
84
|
+
private dynamicResolutionEnabled;
|
|
85
|
+
private dynResLastViewMatrix;
|
|
86
|
+
private dynResStillFrames;
|
|
87
|
+
private dynResCurrentScale;
|
|
88
|
+
private readonly DYNRES_MOVE_SCALE;
|
|
89
|
+
private readonly DYNRES_STILL_SCALE;
|
|
90
|
+
private readonly DYNRES_STILL_THRESHOLD;
|
|
82
91
|
private boundOnResize;
|
|
83
92
|
/** 额外渲染回调(在 gizmo 之前、场景辅助之后执行) */
|
|
84
93
|
private extraRenderCallbacks;
|
|
@@ -94,9 +103,15 @@ export declare class App {
|
|
|
94
103
|
*/
|
|
95
104
|
private applyAppleGPUDefaults;
|
|
96
105
|
/**
|
|
97
|
-
*
|
|
106
|
+
* 移动端自动性能优化
|
|
107
|
+
* 核心策略:降 DPR + 降分辨率 + 激进剔除 + 降排序频率
|
|
98
108
|
*/
|
|
99
|
-
private
|
|
109
|
+
private applyMobileDefaults;
|
|
110
|
+
/**
|
|
111
|
+
* 创建 GSSplatRenderer 并自动应用平台优化
|
|
112
|
+
* @param forMobile 移动端模式:半精度(32B/splat)+ SH L0,内存降为 1/8
|
|
113
|
+
*/
|
|
114
|
+
private createGSRendererUnified;
|
|
100
115
|
/**
|
|
101
116
|
* 加载 GLB 文件
|
|
102
117
|
*/
|
|
@@ -144,6 +159,7 @@ export declare class App {
|
|
|
144
159
|
*/
|
|
145
160
|
stop(): void;
|
|
146
161
|
private animate;
|
|
162
|
+
private updateDynamicResolution;
|
|
147
163
|
private updateAdaptivePerformance;
|
|
148
164
|
private render;
|
|
149
165
|
private onResize;
|
|
@@ -111,6 +111,10 @@ export declare class SplatEditor {
|
|
|
111
111
|
* 创建体积位置的 TransformableObject 代理,供 gizmo 控制
|
|
112
112
|
*/
|
|
113
113
|
createVolumeTransformProxy(): TransformableObject | null;
|
|
114
|
+
setBoxDimensions(lx: number, ly: number, lz: number): void;
|
|
115
|
+
getBoxDimensions(): [number, number, number];
|
|
116
|
+
setSphereRadius(radius: number): void;
|
|
117
|
+
getSphereRadius(): number;
|
|
114
118
|
/**
|
|
115
119
|
* 获取模型世界空间包围盒(中心 + 尺寸)
|
|
116
120
|
*/
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import type { Tool } from './ToolManager';
|
|
2
|
-
export interface BoxSelectionCallbacks {
|
|
3
|
-
onApply: (op: 'add' | 'remove' | 'set') => void;
|
|
4
|
-
onDimensionsChanged: (lenX: number, lenY: number, lenZ: number) => void;
|
|
5
|
-
}
|
|
6
2
|
export declare class BoxSelection implements Tool {
|
|
7
|
-
private parent;
|
|
8
|
-
private toolbar;
|
|
9
|
-
private callbacks;
|
|
10
3
|
private _lenX;
|
|
11
4
|
private _lenY;
|
|
12
5
|
private _lenZ;
|
|
13
|
-
private
|
|
14
|
-
private inputY;
|
|
15
|
-
private inputZ;
|
|
6
|
+
private _onDimensionsChanged?;
|
|
16
7
|
get lenX(): number;
|
|
17
8
|
get lenY(): number;
|
|
18
9
|
get lenZ(): number;
|
|
19
|
-
constructor(
|
|
10
|
+
constructor(onDimensionsChanged?: (lenX: number, lenY: number, lenZ: number) => void);
|
|
20
11
|
setDimensions(lenX: number, lenY: number, lenZ: number): void;
|
|
21
12
|
activate(): void;
|
|
22
13
|
deactivate(): void;
|
|
23
|
-
private emitDims;
|
|
24
14
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import type { Tool } from './ToolManager';
|
|
2
|
-
export interface SphereSelectionCallbacks {
|
|
3
|
-
onApply: (op: 'add' | 'remove' | 'set') => void;
|
|
4
|
-
onRadiusChanged: (radius: number) => void;
|
|
5
|
-
}
|
|
6
2
|
export declare class SphereSelection implements Tool {
|
|
7
|
-
private parent;
|
|
8
|
-
private toolbar;
|
|
9
|
-
private callbacks;
|
|
10
3
|
private _radius;
|
|
11
|
-
private
|
|
4
|
+
private _onRadiusChanged?;
|
|
12
5
|
get radius(): number;
|
|
13
|
-
constructor(
|
|
6
|
+
constructor(onRadiusChanged?: (radius: number) => void);
|
|
14
7
|
setRadius(radius: number): void;
|
|
15
8
|
activate(): void;
|
|
16
9
|
deactivate(): void;
|
|
@@ -30,6 +30,12 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
30
30
|
private sorter;
|
|
31
31
|
private shMode;
|
|
32
32
|
private boundingBox;
|
|
33
|
+
/** 紧凑布局模式:64B/splat,无 SH,适合移动端 */
|
|
34
|
+
private compactLayout;
|
|
35
|
+
/** 半精度模式:32B/splat,所有数据用 f16 打包 */
|
|
36
|
+
private halfPrecision;
|
|
37
|
+
/** 排序位宽:16-bit 排序减少一半 radix sort pass */
|
|
38
|
+
private sortBits;
|
|
33
39
|
private uniformData;
|
|
34
40
|
private cpuPositions;
|
|
35
41
|
private position;
|
|
@@ -40,6 +46,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
40
46
|
private pixelCullThreshold;
|
|
41
47
|
private maxVisibleSplats;
|
|
42
48
|
private depthRangeLimit;
|
|
49
|
+
private lodSkipRate;
|
|
43
50
|
private lastSortViewMatrix;
|
|
44
51
|
private lastSortProjMatrix;
|
|
45
52
|
private lastSortModelMatrix;
|
|
@@ -51,6 +58,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
51
58
|
private sortStateInitialized;
|
|
52
59
|
private sortFrequency;
|
|
53
60
|
private frameCounter;
|
|
61
|
+
private debugFrameLogged;
|
|
54
62
|
private editorStateBuffer;
|
|
55
63
|
private editorPipeline;
|
|
56
64
|
private editorBindGroupLayout;
|
|
@@ -66,6 +74,21 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
66
74
|
private dnRTHeight;
|
|
67
75
|
private dnResult;
|
|
68
76
|
constructor(renderer: Renderer, camera: Camera);
|
|
77
|
+
/**
|
|
78
|
+
* 启用/禁用紧凑布局模式(64B/splat,无 SH)。
|
|
79
|
+
* 必须在 setCompactData / setData 之前调用。
|
|
80
|
+
*/
|
|
81
|
+
setCompactLayout(compact: boolean): void;
|
|
82
|
+
/**
|
|
83
|
+
* 设置排序位宽。16-bit 模式排序 pass 从 4 降到 2,排序速度翻倍。
|
|
84
|
+
* 必须在 setData / setCompactData 之前调用。
|
|
85
|
+
*/
|
|
86
|
+
setSortBits(bits: 16 | 32): void;
|
|
87
|
+
/**
|
|
88
|
+
* 启用/禁用半精度模式(32B/splat,所有数据 f16 打包)。
|
|
89
|
+
* 自动启用 compactLayout。必须在 setCompactData 之前调用。
|
|
90
|
+
*/
|
|
91
|
+
setHalfPrecision(half: boolean): void;
|
|
69
92
|
private createPipeline;
|
|
70
93
|
setDepthWriteEnabled(enabled: boolean): void;
|
|
71
94
|
private createUniformBuffer;
|
|
@@ -99,6 +122,13 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
99
122
|
*/
|
|
100
123
|
setDepthRangeLimit(limit: number): void;
|
|
101
124
|
getDepthRangeLimit(): number;
|
|
125
|
+
/**
|
|
126
|
+
* 设置 LOD 抽稀率(0~1)
|
|
127
|
+
* 远处 splat 按此比例随机跳过(确定性哈希,无闪烁)
|
|
128
|
+
* 0 = 不抽稀
|
|
129
|
+
*/
|
|
130
|
+
setLodSkipRate(rate: number): void;
|
|
131
|
+
getLodSkipRate(): number;
|
|
102
132
|
/**
|
|
103
133
|
* 设置排序频率
|
|
104
134
|
* 1 = 每帧排序(默认),2 = 每 2 帧排序一次,以此类推
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* GSSplatSorter - GPU Radix Sort 深度排序器
|
|
3
3
|
*
|
|
4
4
|
* 基于 rfs-gsplat-render 的 3-Pass Radix Sort 架构实现:
|
|
5
|
-
* -
|
|
5
|
+
* - N 个 pass (8-bit 增量,32 位或 16 位模式)
|
|
6
6
|
* - 每个 pass 包含: Upsweep -> Spine -> Downsweep
|
|
7
7
|
* - 稳定排序,解决远距离闪烁问题
|
|
8
8
|
*
|
|
@@ -27,6 +27,8 @@ export interface CullingOptions {
|
|
|
27
27
|
maxVisibleCount?: number;
|
|
28
28
|
/** 深度范围限制(view-space 距离),超过此深度的 splat 被剔除,0 = 不限制 */
|
|
29
29
|
depthRangeLimit?: number;
|
|
30
|
+
/** LOD 抽稀率(0~1),远处 splat 最多跳过此比例,0 = 不抽稀 */
|
|
31
|
+
lodSkipRate?: number;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* 排序器配置选项
|
|
@@ -67,19 +69,15 @@ export declare class GSSplatSorter {
|
|
|
67
69
|
private spineBindGroups;
|
|
68
70
|
private downsweepBindGroups;
|
|
69
71
|
private numPartitions;
|
|
72
|
+
private numSortPasses;
|
|
70
73
|
private screenWidth;
|
|
71
74
|
private screenHeight;
|
|
72
75
|
private cullingOptions;
|
|
73
|
-
constructor(device: GPUDevice, splatCount: number, splatBuffer: GPUBuffer, cameraBuffer: GPUBuffer, _options?: SorterOptions);
|
|
76
|
+
constructor(device: GPUDevice, splatCount: number, splatBuffer: GPUBuffer, cameraBuffer: GPUBuffer, _options?: SorterOptions, compact?: boolean, half?: boolean, sortBits?: 16 | 32);
|
|
74
77
|
/**
|
|
75
78
|
* 创建 Radix Sort 的 bind groups
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* Ping-pong 模式:
|
|
79
|
-
* - Pass 0: depthKeys/visibleIndices -> keysTempBuffer/valuesTempBuffer
|
|
80
|
-
* - Pass 1: keysTempBuffer/valuesTempBuffer -> depthKeys/visibleIndices
|
|
81
|
-
* - Pass 2: depthKeys/visibleIndices -> keysTempBuffer/valuesTempBuffer
|
|
82
|
-
* - Pass 3: keysTempBuffer/valuesTempBuffer -> (depthKeys)/sortedIndicesBuffer
|
|
79
|
+
* numSortPasses 个 pass,使用 ping-pong buffers
|
|
80
|
+
* 最后一个 pass 的 values 输出到 sortedIndicesBuffer
|
|
83
81
|
*/
|
|
84
82
|
private createRadixSortBindGroups;
|
|
85
83
|
/**
|
|
@@ -103,6 +101,11 @@ export declare class GSSplatSorter {
|
|
|
103
101
|
* 获取 DrawIndirect buffer
|
|
104
102
|
*/
|
|
105
103
|
getDrawIndirectBuffer(): GPUBuffer;
|
|
104
|
+
/**
|
|
105
|
+
* 异步读回 drawIndirect buffer 内容(调试用)
|
|
106
|
+
* 返回 [vertexCount, instanceCount, firstVertex, firstInstance]
|
|
107
|
+
*/
|
|
108
|
+
readbackIndirect(): Promise<Uint32Array>;
|
|
106
109
|
/**
|
|
107
110
|
* 获取 splat 总数量
|
|
108
111
|
*/
|
|
@@ -74,3 +74,9 @@ export declare function parsePLYBuffer(buffer: ArrayBuffer, options?: MobileLoad
|
|
|
74
74
|
* @param includeFullSH 是否包含完整 SH 系数(256 字节/splat),否则只包含基本数据(64 字节/splat)
|
|
75
75
|
*/
|
|
76
76
|
export declare function compactDataToGPUBuffer(data: CompactSplatData, includeFullSH?: boolean): Float32Array;
|
|
77
|
+
/**
|
|
78
|
+
* 半精度 GPU buffer:32 字节/splat = 8 × u32
|
|
79
|
+
* 布局:[mean.xy, mean.z|0, scale.xy, scale.z|opacity, rot.xy, rot.zw, color.rg, color.b|0]
|
|
80
|
+
* 使用 WGSL unpack2x16float 解码
|
|
81
|
+
*/
|
|
82
|
+
export declare function compactDataToGPUBufferHalf(data: CompactSplatData): Uint32Array;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DebugOverlay — 移动端屏幕上的调试面板
|
|
3
|
+
* 用于在无法连接开发者工具时查看 WebGPU 错误和日志
|
|
4
|
+
*/
|
|
5
|
+
export declare class DebugOverlay {
|
|
6
|
+
private container;
|
|
7
|
+
private logList;
|
|
8
|
+
private maxEntries;
|
|
9
|
+
constructor(maxEntries?: number);
|
|
10
|
+
log(msg: string, level?: "info" | "warn" | "error"): void;
|
|
11
|
+
info(msg: string): void;
|
|
12
|
+
warn(msg: string): void;
|
|
13
|
+
error(msg: string): void;
|
|
14
|
+
hide(): void;
|
|
15
|
+
show(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 绑定 WebGPU device 的全局错误捕获
|
|
18
|
+
*/
|
|
19
|
+
attachDevice(device: GPUDevice): void;
|
|
20
|
+
/**
|
|
21
|
+
* 检查 shader 编译结果
|
|
22
|
+
*/
|
|
23
|
+
checkShader(module: GPUShaderModule, label: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* 包裹一个异步操作,捕获 validation/oom 错误
|
|
26
|
+
*/
|
|
27
|
+
wrapGPU<T>(device: GPUDevice, label: string, fn: () => T): Promise<T>;
|
|
28
|
+
}
|
|
29
|
+
export declare function getDebugOverlay(): DebugOverlay | null;
|
|
30
|
+
export declare function createDebugOverlay(): DebugOverlay;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { isMobileDevice, getRecommendedDPR, isWebGPUSupported, } from './device';
|
|
5
5
|
export { computeBoundingBox, mergeBoundingBoxes, createBoundingBoxFromMinMax, transformBoundingBox, } from './geometry';
|
|
6
|
+
export { DebugOverlay, getDebugOverlay, createDebugOverlay, } from './DebugOverlay';
|
|
6
7
|
export { loadTextureFromURL, loadTextureFromBlob, loadTextureFromBuffer, createTextureFromImageBitmap, TextureCache, } from './texture';
|