@d5techs/3dgs-lib 1.4.84 → 1.4.86

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/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 mobileOptimizationsEnabled;
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,17 @@ export declare class App {
94
103
  */
95
104
  private applyAppleGPUDefaults;
96
105
  /**
97
- * 创建桌面端 GSSplatRenderer 并自动应用平台优化
106
+ * 启用/禁用移动端性能优化(默认关闭)
107
+ * 开启后,加载模型时将自动应用:f16 半精度、16-bit 排序、像素剔除、动态分辨率等。
108
+ * 应在 init() 之后、加载模型之前调用。
98
109
  */
99
- private createDesktopGSRenderer;
110
+ enableMobileOptimizations(enabled?: boolean): void;
111
+ isMobileOptimized(): boolean;
112
+ /**
113
+ * 创建 GSSplatRenderer 并自动应用平台优化
114
+ * @param forMobile 移动端模式:半精度(32B/splat)+ SH L0,内存降为 1/8
115
+ */
116
+ private createGSRendererUnified;
100
117
  /**
101
118
  * 加载 GLB 文件
102
119
  */
@@ -144,6 +161,7 @@ export declare class App {
144
161
  */
145
162
  stop(): void;
146
163
  private animate;
164
+ private updateDynamicResolution;
147
165
  private updateAdaptivePerformance;
148
166
  private render;
149
167
  private onResize;
@@ -23,6 +23,7 @@ export declare class OrbitControls {
23
23
  enableDamping: boolean;
24
24
  dampingFactor: number;
25
25
  private isDragging;
26
+ get isInteracting(): boolean;
26
27
  private lastX;
27
28
  private lastY;
28
29
  private deltaTheta;
@@ -33,6 +34,7 @@ export declare class OrbitControls {
33
34
  private deltaPanZ;
34
35
  moveSpeed: number;
35
36
  private pressedKeys;
37
+ private _wasKeyboardMoving;
36
38
  private touchMode;
37
39
  private lastTouchDistance;
38
40
  private lastTouchCenter;
@@ -77,6 +79,12 @@ export declare class OrbitControls {
77
79
  private onTouchEnd;
78
80
  private getTouchDistance;
79
81
  private getTouchCenter;
82
+ /**
83
+ * 将 orbit 目标重新锚定到屏幕中心的模型表面点,
84
+ * 保持相机世界坐标不变,仅重算 distance/theta/phi。
85
+ * 用于 WASD 移动或触摸缩放结束后修复旋转中心偏移。
86
+ */
87
+ private recenterOrbitTarget;
80
88
  /**
81
89
  * 将球坐标写入相机位置(内部方法,不处理阻尼)
82
90
  */
@@ -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
- * - 4 个 pass (8-bit 增量,总共 32 )
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
- * 4 个 pass,使用 ping-pong buffers
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;
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d5techs/3dgs-lib",
3
- "version": "1.4.84",
3
+ "version": "1.4.86",
4
4
  "description": "可扩展的 WebGPU 3D 渲染引擎",
5
5
  "type": "module",
6
6
  "main": "./dist/3dgs-lib.cjs",