@d5techs/3dgs-lib 1.4.6 → 1.4.8

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
@@ -77,6 +77,10 @@ export declare class App {
77
77
  * @param coordinateSystem 源数据坐标系,默认 'blender'(Z-up → Y-up 自动转换)
78
78
  */
79
79
  addSplat(urlOrBuffer: string | ArrayBuffer, onProgress?: ProgressCallback, isLocalFile?: boolean, coordinateSystem?: CoordinateSystem): Promise<number>;
80
+ /**
81
+ * 将 SplatCPU[] 转换为 CompactSplatData(用于移动端渲染器)
82
+ */
83
+ private static splatCpuToCompactData;
80
84
  /**
81
85
  * 加载 SOG 文件 (Spatially Ordered Gaussians)
82
86
  * @param coordinateSystem 源数据坐标系,默认 'blender'(Z-up → Y-up 自动转换)
@@ -201,6 +205,33 @@ export declare class App {
201
205
  setAxesVisible(visible: boolean): void;
202
206
  getAxesVisible(): boolean;
203
207
  getSceneAidsRenderer(): SceneAidsRenderer;
208
+ /**
209
+ * 设置渲染缩放比例(影响内部分辨率)
210
+ * 0.5 = 半分辨率(性能提升约 4 倍),1.0 = 正常
211
+ * 适用于移动端提质或桌面端降负载
212
+ */
213
+ setRenderScale(scale: number): void;
214
+ getRenderScale(): number;
215
+ /**
216
+ * 覆盖自动 DPR,传 -1 恢复自动推荐
217
+ */
218
+ setDPR(dpr: number): void;
219
+ getDPR(): number;
220
+ /**
221
+ * 设置桌面端亚像素剔除阈值(默认 1.0)
222
+ * 值越大剔除越激进,近距离性能越好,但远处细节可能丢失
223
+ */
224
+ setPixelCullThreshold(threshold: number): void;
225
+ /**
226
+ * 设置桌面端最大可见 splat 数(0 = 不限制)
227
+ * 限制绘制数量是应对近距离卡顿最直接的手段
228
+ */
229
+ setMaxVisibleSplats(count: number): void;
230
+ /**
231
+ * 设置排序频率(1 = 每帧,2 = 每两帧,以此类推)
232
+ * 降低排序频率可提升帧率,代价是移动时短暂排序瑕疵
233
+ */
234
+ setSortFrequency(frequency: number): void;
204
235
  /**
205
236
  * 销毁应用及所有资源
206
237
  */
@@ -12,6 +12,10 @@ export declare class Renderer {
12
12
  private commandEncoder;
13
13
  private renderPassEncoder;
14
14
  private resizeObserver;
15
+ private _renderScale;
16
+ private _customDPR;
17
+ private _lastCSSWidth;
18
+ private _lastCSSHeight;
15
19
  private _clearColor;
16
20
  constructor(canvas: HTMLCanvasElement);
17
21
  /**
@@ -46,6 +50,21 @@ export declare class Renderer {
46
50
  * 创建深度纹理
47
51
  */
48
52
  private createDepthTexture;
53
+ private getEffectiveDPR;
54
+ /**
55
+ * 设置渲染缩放比例,用于性能/质量权衡
56
+ * 0.5 = 半分辨率(性能提升约 4 倍),1.0 = 正常分辨率
57
+ * 内部等效于降低 DPR,不影响 CSS 布局尺寸
58
+ */
59
+ setRenderScale(scale: number): void;
60
+ getRenderScale(): number;
61
+ /**
62
+ * 覆盖自动 DPR 推荐值
63
+ * 传入 -1 恢复自动模式
64
+ */
65
+ setDPR(dpr: number): void;
66
+ getDPR(): number;
67
+ private applySize;
49
68
  /**
50
69
  * 设置 resize 监听
51
70
  */
@@ -34,6 +34,9 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
34
34
  private cpuPositions;
35
35
  private frameCount;
36
36
  private sortEveryNFrames;
37
+ private lastSortViewMatrix;
38
+ private lastSortProjMatrix;
39
+ private sortStateInitialized;
37
40
  private position;
38
41
  private rotation;
39
42
  private scaleValue;
@@ -82,13 +85,14 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
82
85
  * 获取当前模型矩阵
83
86
  */
84
87
  getModelMatrix(): Float32Array;
88
+ private dummySHTexture;
85
89
  /**
86
90
  * 创建渲染管线
87
91
  */
88
92
  private createPipeline;
89
93
  /**
90
94
  * 创建 uniform buffer
91
- * 布局: view (64) + proj (64) + model (64) + cameraPos (12) + pad (4) + screenSize (8) + pad (8) + textureSize (8) + pad (8) = 240 bytes
95
+ * 布局: view(64) + proj(64) + model(64) + cameraPos(12)+pad(4) + screenSize(8)+pad(8) + textureSize(8)+shEnabled(4)+pad(4) = 240 bytes
92
96
  */
93
97
  private createUniformBuffer;
94
98
  /**
@@ -123,21 +127,10 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
123
127
  * @param n 每 n 帧排序一次
124
128
  */
125
129
  setSortFrequency(n: number): void;
126
- /**
127
- * 设置 SH 模式(移动端仅支持 L0)
128
- */
129
- setSHMode(mode: SHMode): void;
130
- /**
131
- * 获取当前 SH 模式
132
- */
130
+ private hasCameraChanged;
131
+ setSHMode(_mode: SHMode): void;
133
132
  getSHMode(): SHMode;
134
- /**
135
- * 是否支持指定的 SH 模式
136
- */
137
133
  supportsSHMode(mode: SHMode): boolean;
138
- /**
139
- * 获取渲染器能力
140
- */
141
134
  getCapabilities(): RendererCapabilities;
142
135
  /**
143
136
  * 内部销毁资源(不销毁管线)
@@ -11,7 +11,8 @@
11
11
  */
12
12
  /**
13
13
  * 坐标系类型
14
- * - 'blender': Blender 坐标系 (Z-up, 右手系),加载时自动将 Y/Z 对调转换为 WebGPU 的 Y-up 坐标系
14
+ * - 'blender': Blender 坐标系 (Z-up, 右手系),加载时通过 Rx(-90°) 旋转转换为 WebGPU 的 Y-up 坐标系
15
+ * 变换: (x,y,z)→(x,z,-y),保持右手系手性不变
15
16
  * - 'webgpu': WebGPU 坐标系 (Y-up),数据已经是 Y-up 格式,不做转换
16
17
  */
17
18
  export type CoordinateSystem = 'blender' | 'webgpu';
@@ -51,8 +52,8 @@ export interface CompactSplatData {
51
52
  shCoeffs?: Float32Array;
52
53
  }
53
54
  /**
54
- * Y↔Z 轴交换时对 SH 系数的基函数变换(interleaved 格式)。
55
- * 对 L1/L2/L3 三个波段分别施加正交变换矩阵,使 SH 视角相关颜色在坐标变换后保持正确。
55
+ * Blender→WebGPU 坐标变换 Rx(-90°) 对 SH 系数的基函数变换(interleaved 格式)。
56
+ * 对 L1/L2/L3 三个波段分别施加 Wigner D-矩阵,使 SH 视角相关颜色在坐标变换后保持正确。
56
57
  */
57
58
  export declare function transformSHCoeffsYZSwap(sh: Float32Array, base: number, perChannel: number): void;
58
59
  /**
@@ -28,6 +28,10 @@ export interface CompressedSplatTextures {
28
28
  scaleRotTexture1: GPUTexture;
29
29
  scaleRotTexture2: GPUTexture;
30
30
  colorTexture: GPUTexture;
31
+ shBasis0Texture: GPUTexture | null;
32
+ shBasis1Texture: GPUTexture | null;
33
+ shBasis2Texture: GPUTexture | null;
34
+ hasSH: boolean;
31
35
  boundingBox: {
32
36
  min: [number, number, number];
33
37
  max: [number, number, number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d5techs/3dgs-lib",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "可扩展的 WebGPU 3D 渲染引擎",
5
5
  "type": "module",
6
6
  "main": "./dist/3dgs-lib.cjs",