@d5techs/3dgs-lib 1.4.7 → 1.4.9
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 +502 -593
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +502 -593
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/App.d.ts +27 -0
- package/dist/core/Renderer.d.ts +19 -0
- package/dist/core/gizmo/ViewportGizmo.d.ts +20 -65
- package/dist/gs/GSSplatRendererMobile.d.ts +7 -14
- package/dist/gs/TextureCompressor.d.ts +4 -0
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -205,6 +205,33 @@ export declare class App {
|
|
|
205
205
|
setAxesVisible(visible: boolean): void;
|
|
206
206
|
getAxesVisible(): boolean;
|
|
207
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;
|
|
208
235
|
/**
|
|
209
236
|
* 销毁应用及所有资源
|
|
210
237
|
*/
|
package/dist/core/Renderer.d.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -1,83 +1,38 @@
|
|
|
1
1
|
import { Camera } from "../Camera";
|
|
2
2
|
import { Renderer } from "../Renderer";
|
|
3
3
|
/**
|
|
4
|
-
* ViewportGizmo -
|
|
5
|
-
*
|
|
4
|
+
* ViewportGizmo - 视口坐标轴指示器(SVG 实现)
|
|
5
|
+
* 参考 supersplat 的 ViewCube,在画布右上角用 SVG 显示当前相机朝向
|
|
6
6
|
*/
|
|
7
7
|
export declare class ViewportGizmo {
|
|
8
|
-
private renderer;
|
|
9
8
|
private camera;
|
|
10
9
|
private canvas;
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private indexBuffer;
|
|
16
|
-
private vertexCount;
|
|
17
|
-
private indexCount;
|
|
10
|
+
private container;
|
|
11
|
+
private svg;
|
|
12
|
+
private group;
|
|
13
|
+
private shapes;
|
|
18
14
|
private size;
|
|
19
15
|
private margin;
|
|
20
|
-
private
|
|
21
|
-
private viewMatrix;
|
|
22
|
-
private axes;
|
|
16
|
+
private scale;
|
|
23
17
|
private onAxisClick?;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* 设置轴点击回调
|
|
27
|
-
*/
|
|
18
|
+
private resizeObserver?;
|
|
19
|
+
constructor(_renderer: Renderer, camera: Camera, canvas: HTMLCanvasElement);
|
|
28
20
|
setOnAxisClick(callback: (axis: string, positive: boolean) => void): void;
|
|
21
|
+
private createSVG;
|
|
22
|
+
private createCircle;
|
|
23
|
+
private createLine;
|
|
24
|
+
private bindClickEvents;
|
|
25
|
+
private positionContainer;
|
|
26
|
+
private setupResizeObserver;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
private createPipeline;
|
|
33
|
-
/**
|
|
34
|
-
* 创建 Gizmo 几何体(三个轴 + 箭头)
|
|
35
|
-
*/
|
|
36
|
-
private createGeometry;
|
|
37
|
-
/**
|
|
38
|
-
* 创建圆柱体几何
|
|
39
|
-
*/
|
|
40
|
-
private createCylinder;
|
|
41
|
-
/**
|
|
42
|
-
* 创建圆锥几何
|
|
43
|
-
*/
|
|
44
|
-
private createCone;
|
|
45
|
-
/**
|
|
46
|
-
* 创建球体几何
|
|
47
|
-
*/
|
|
48
|
-
private createSphere;
|
|
49
|
-
/**
|
|
50
|
-
* 创建 uniform buffer
|
|
28
|
+
* 每帧更新 SVG 位置(从相机视图矩阵中提取轴投影)
|
|
51
29
|
*/
|
|
52
|
-
|
|
30
|
+
render(_pass: GPURenderPassEncoder): void;
|
|
53
31
|
/**
|
|
54
|
-
*
|
|
55
|
-
*/
|
|
56
|
-
private setupOrthoProjection;
|
|
57
|
-
/**
|
|
58
|
-
* 更新 Gizmo 视图矩阵(从相机提取旋转部分)
|
|
59
|
-
*/
|
|
60
|
-
private updateViewMatrix;
|
|
61
|
-
/**
|
|
62
|
-
* 渲染 Gizmo
|
|
63
|
-
*/
|
|
64
|
-
render(pass: GPURenderPassEncoder): void;
|
|
65
|
-
/**
|
|
66
|
-
* 处理点击事件,检测是否点击了某个轴
|
|
67
|
-
*/
|
|
68
|
-
handleClick(clientX: number, clientY: number): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* 检测点击了哪个轴
|
|
71
|
-
*/
|
|
72
|
-
private detectClickedAxis;
|
|
73
|
-
private cross;
|
|
74
|
-
private normalize;
|
|
75
|
-
/**
|
|
76
|
-
* 设置 Gizmo 大小
|
|
32
|
+
* 点击检测 — SVG 版本通过 DOM 事件处理,此方法仅保留接口兼容
|
|
77
33
|
*/
|
|
34
|
+
handleClick(_clientX: number, _clientY: number): boolean;
|
|
78
35
|
setSize(size: number): void;
|
|
79
|
-
/**
|
|
80
|
-
* 设置边距
|
|
81
|
-
*/
|
|
82
36
|
setMargin(margin: number): void;
|
|
37
|
+
destroy(): void;
|
|
83
38
|
}
|
|
@@ -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
|
|
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
|
-
|
|
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
|
* 内部销毁资源(不销毁管线)
|
|
@@ -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];
|