@d5techs/3dgs-lib 1.4.14 → 1.4.15
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 +878 -115
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +878 -115
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/App.d.ts +60 -3
- package/dist/core/Camera.d.ts +1 -1
- package/dist/core/OrbitControls.d.ts +12 -0
- package/dist/core/Renderer.d.ts +6 -0
- package/dist/editor/SplatEditor.d.ts +13 -0
- package/dist/editor/tools/BoxSelection.d.ts +24 -0
- package/dist/editor/tools/SphereSelection.d.ts +21 -0
- package/dist/gs/GSSplatRenderer.d.ts +13 -0
- package/dist/gs/GSSplatSorter.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -30,7 +30,31 @@ import type { CoordinateSystem } from "./gs/PLYLoaderMobile";
|
|
|
30
30
|
* @param progress 进度值 0-100
|
|
31
31
|
* @param stage 当前阶段: 'download' | 'parse' | 'upload'
|
|
32
32
|
*/
|
|
33
|
-
export type ProgressCallback = (progress: number, stage:
|
|
33
|
+
export type ProgressCallback = (progress: number, stage: "download" | "parse" | "upload") => void;
|
|
34
|
+
/**
|
|
35
|
+
* 自适应性能配置
|
|
36
|
+
* 当相机靠近模型时自动降低渲染负载,远离时恢复全质量
|
|
37
|
+
*/
|
|
38
|
+
export interface AdaptivePerformanceConfig {
|
|
39
|
+
/** 远距离阈值(倍率 × boundingBox.radius),超过此距离使用全质量 */
|
|
40
|
+
farThreshold: number;
|
|
41
|
+
/** 近距离阈值(倍率 × boundingBox.radius),低于此距离使用最大优化 */
|
|
42
|
+
nearThreshold: number;
|
|
43
|
+
/** 最近距离时的渲染分辨率缩放 (0.25~1.0) */
|
|
44
|
+
minRenderScale: number;
|
|
45
|
+
/** 最近距离时的亚像素剔除阈值 (越高剔除越多) */
|
|
46
|
+
maxPixelThreshold: number;
|
|
47
|
+
/** 远距离时的亚像素剔除阈值 */
|
|
48
|
+
minPixelThreshold: number;
|
|
49
|
+
/** 最近距离时的可见 splat 比例上限 (0~1, 0=不限制) */
|
|
50
|
+
nearVisibleRatio: number;
|
|
51
|
+
/** 远距离时是否完全取消可见数量限制 */
|
|
52
|
+
farUnlimited: boolean;
|
|
53
|
+
/** 是否启用深度范围限制(近似 transmittance cutoff) */
|
|
54
|
+
enableDepthRangeLimit: boolean;
|
|
55
|
+
/** 近距离时深度范围限制倍率(× boundingBox.radius),越小剔除后方越多 */
|
|
56
|
+
nearDepthRangeRatio: number;
|
|
57
|
+
}
|
|
34
58
|
/**
|
|
35
59
|
* App - 统一调度入口
|
|
36
60
|
*/
|
|
@@ -50,12 +74,26 @@ export declare class App {
|
|
|
50
74
|
private animationId;
|
|
51
75
|
private useMobileRenderer;
|
|
52
76
|
private lastCompactData;
|
|
77
|
+
private adaptivePerformanceEnabled;
|
|
78
|
+
private adaptiveConfig;
|
|
79
|
+
private lastAppliedRenderScale;
|
|
80
|
+
private baseRenderScale;
|
|
53
81
|
private boundOnResize;
|
|
54
82
|
constructor(canvas: HTMLCanvasElement);
|
|
55
83
|
/**
|
|
56
84
|
* 初始化应用
|
|
57
85
|
*/
|
|
58
86
|
init(): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Apple GPU (M1/M2/M3 等) 自动优化配置
|
|
89
|
+
* TBDR 架构特点:片段着色器开销高、带宽敏感、compute pass 较慢
|
|
90
|
+
* 策略:降低 SH 等级、更积极的自适应参数、禁用无效深度写入
|
|
91
|
+
*/
|
|
92
|
+
private applyAppleGPUDefaults;
|
|
93
|
+
/**
|
|
94
|
+
* 创建桌面端 GSSplatRenderer 并自动应用平台优化
|
|
95
|
+
*/
|
|
96
|
+
private createDesktopGSRenderer;
|
|
59
97
|
/**
|
|
60
98
|
* 加载 GLB 文件
|
|
61
99
|
*/
|
|
@@ -103,6 +141,7 @@ export declare class App {
|
|
|
103
141
|
*/
|
|
104
142
|
stop(): void;
|
|
105
143
|
private animate;
|
|
144
|
+
private updateAdaptivePerformance;
|
|
106
145
|
private render;
|
|
107
146
|
private onResize;
|
|
108
147
|
getMeshCount(): number;
|
|
@@ -161,8 +200,8 @@ export declare class App {
|
|
|
161
200
|
getGSRenderer(): GSSplatRenderer | undefined;
|
|
162
201
|
getGSRendererMobile(): GSSplatRendererMobile | undefined;
|
|
163
202
|
isUsingMobileRenderer(): boolean;
|
|
164
|
-
getLastCompactData(): import(
|
|
165
|
-
setLastCompactData(data: import(
|
|
203
|
+
getLastCompactData(): import("./gs/PLYLoaderMobile").CompactSplatData | null;
|
|
204
|
+
setLastCompactData(data: import("./gs/PLYLoaderMobile").CompactSplatData): void;
|
|
166
205
|
getHotspotManager(): HotspotManager;
|
|
167
206
|
enterHotspotMode(objUrl: string): void;
|
|
168
207
|
exitHotspotMode(): void;
|
|
@@ -234,6 +273,24 @@ export declare class App {
|
|
|
234
273
|
* 降低排序频率可提升帧率,代价是移动时短暂排序瑕疵
|
|
235
274
|
*/
|
|
236
275
|
setSortFrequency(frequency: number): void;
|
|
276
|
+
/**
|
|
277
|
+
* 是否检测到 Apple GPU(M1/M2/M3 等)
|
|
278
|
+
*/
|
|
279
|
+
get isAppleGPU(): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* 启用/禁用自适应性能优化
|
|
282
|
+
* 开启后系统会根据相机与模型的距离自动调节:
|
|
283
|
+
* - 渲染分辨率(renderScale)
|
|
284
|
+
* - 亚像素剔除阈值(pixelThreshold)
|
|
285
|
+
* - 最大可见 splat 数量(maxVisibleSplats)
|
|
286
|
+
*/
|
|
287
|
+
setAdaptivePerformance(enabled: boolean): void;
|
|
288
|
+
getAdaptivePerformance(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* 设置自适应性能配置参数
|
|
291
|
+
*/
|
|
292
|
+
setAdaptivePerformanceConfig(config: Partial<AdaptivePerformanceConfig>): void;
|
|
293
|
+
getAdaptivePerformanceConfig(): AdaptivePerformanceConfig;
|
|
237
294
|
/**
|
|
238
295
|
* 销毁应用及所有资源
|
|
239
296
|
*/
|
package/dist/core/Camera.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare class OrbitControls {
|
|
|
29
29
|
private velocityPanX;
|
|
30
30
|
private velocityPanY;
|
|
31
31
|
private velocityPanZ;
|
|
32
|
+
moveSpeed: number;
|
|
33
|
+
private pressedKeys;
|
|
32
34
|
private touchMode;
|
|
33
35
|
private lastTouchDistance;
|
|
34
36
|
private lastTouchCenter;
|
|
@@ -37,6 +39,9 @@ export declare class OrbitControls {
|
|
|
37
39
|
private boundOnMouseMove;
|
|
38
40
|
private boundOnMouseUp;
|
|
39
41
|
private boundOnWheel;
|
|
42
|
+
private boundOnDblClick;
|
|
43
|
+
private boundOnKeyDown;
|
|
44
|
+
private boundOnKeyUp;
|
|
40
45
|
private boundOnTouchStart;
|
|
41
46
|
private boundOnTouchMove;
|
|
42
47
|
private boundOnTouchEnd;
|
|
@@ -57,6 +62,13 @@ export declare class OrbitControls {
|
|
|
57
62
|
private onMouseMove;
|
|
58
63
|
private onMouseUp;
|
|
59
64
|
private onWheel;
|
|
65
|
+
/** 移动键 */
|
|
66
|
+
private static MOVE_KEYS;
|
|
67
|
+
private onKeyDown;
|
|
68
|
+
private onKeyUp;
|
|
69
|
+
private applyKeyboardMovement;
|
|
70
|
+
private onDblClick;
|
|
71
|
+
private animateToTarget;
|
|
60
72
|
private onTouchStart;
|
|
61
73
|
private onTouchMove;
|
|
62
74
|
private onTouchEnd;
|
package/dist/core/Renderer.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export declare class Renderer {
|
|
|
17
17
|
private _lastCSSWidth;
|
|
18
18
|
private _lastCSSHeight;
|
|
19
19
|
private _clearColor;
|
|
20
|
+
private _isAppleGPU;
|
|
21
|
+
private _gpuVendor;
|
|
22
|
+
private _gpuArchitecture;
|
|
20
23
|
constructor(canvas: HTMLCanvasElement);
|
|
21
24
|
/**
|
|
22
25
|
* 设置背景颜色
|
|
@@ -34,6 +37,9 @@ export declare class Renderer {
|
|
|
34
37
|
get context(): GPUCanvasContext;
|
|
35
38
|
get format(): GPUTextureFormat;
|
|
36
39
|
get depthFormat(): GPUTextureFormat;
|
|
40
|
+
get isAppleGPU(): boolean;
|
|
41
|
+
get gpuVendor(): string;
|
|
42
|
+
get gpuArchitecture(): string;
|
|
37
43
|
/**
|
|
38
44
|
* 获取渲染宽度(像素)
|
|
39
45
|
*/
|
|
@@ -68,6 +68,19 @@ export declare class SplatEditor {
|
|
|
68
68
|
private selectByRect;
|
|
69
69
|
private selectByMask;
|
|
70
70
|
private selectByColor;
|
|
71
|
+
/**
|
|
72
|
+
* 球选择:以点击处最近 splat 为中心,拖拽半径定义世界空间球体
|
|
73
|
+
*/
|
|
74
|
+
private selectBySphere;
|
|
75
|
+
/**
|
|
76
|
+
* 盒选择:以点击处最近 splat 为中心,拖拽定义世界空间 AABB
|
|
77
|
+
* X/Y 半宽由屏幕拖拽距离转换,Z 半深度取 max(halfW, halfH)
|
|
78
|
+
*/
|
|
79
|
+
private selectByBox;
|
|
80
|
+
/**
|
|
81
|
+
* 根据屏幕像素坐标,找到最近的可见 splat 并返回其世界坐标及深度换算系数
|
|
82
|
+
*/
|
|
83
|
+
private pickWorldPosition;
|
|
71
84
|
/**
|
|
72
85
|
* 每帧调用,标记投影需要更新
|
|
73
86
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Tool } from './ToolManager';
|
|
2
|
+
export declare class BoxSelection implements Tool {
|
|
3
|
+
private parent;
|
|
4
|
+
private svg;
|
|
5
|
+
private rect;
|
|
6
|
+
private crossV;
|
|
7
|
+
private crossH;
|
|
8
|
+
private onSelect;
|
|
9
|
+
private center;
|
|
10
|
+
private halfW;
|
|
11
|
+
private halfH;
|
|
12
|
+
private dragId;
|
|
13
|
+
constructor(parent: HTMLElement, onSelect: (op: 'add' | 'remove' | 'set', centerPx: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}, halfW: number, halfH: number) => void);
|
|
17
|
+
activate(): void;
|
|
18
|
+
deactivate(): void;
|
|
19
|
+
private updateVisuals;
|
|
20
|
+
private pointerdown;
|
|
21
|
+
private pointermove;
|
|
22
|
+
private dragEnd;
|
|
23
|
+
private pointerup;
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Tool } from './ToolManager';
|
|
2
|
+
export declare class SphereSelection implements Tool {
|
|
3
|
+
private parent;
|
|
4
|
+
private svg;
|
|
5
|
+
private circle;
|
|
6
|
+
private onSelect;
|
|
7
|
+
private center;
|
|
8
|
+
private radiusPx;
|
|
9
|
+
private dragId;
|
|
10
|
+
constructor(parent: HTMLElement, onSelect: (op: 'add' | 'remove' | 'set', centerPx: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}, radiusPx: number) => void);
|
|
14
|
+
activate(): void;
|
|
15
|
+
deactivate(): void;
|
|
16
|
+
private updateCircle;
|
|
17
|
+
private pointerdown;
|
|
18
|
+
private pointermove;
|
|
19
|
+
private dragEnd;
|
|
20
|
+
private pointerup;
|
|
21
|
+
}
|
|
@@ -30,6 +30,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
30
30
|
private sorter;
|
|
31
31
|
private shMode;
|
|
32
32
|
private boundingBox;
|
|
33
|
+
private uniformData;
|
|
33
34
|
private cpuPositions;
|
|
34
35
|
private position;
|
|
35
36
|
private rotation;
|
|
@@ -38,6 +39,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
38
39
|
private modelMatrix;
|
|
39
40
|
private pixelCullThreshold;
|
|
40
41
|
private maxVisibleSplats;
|
|
42
|
+
private depthRangeLimit;
|
|
41
43
|
private lastSortViewMatrix;
|
|
42
44
|
private lastSortProjMatrix;
|
|
43
45
|
private lastSortModelMatrix;
|
|
@@ -45,6 +47,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
45
47
|
private lastSortHeight;
|
|
46
48
|
private lastSortPixelThreshold;
|
|
47
49
|
private lastSortMaxVisible;
|
|
50
|
+
private lastSortDepthRange;
|
|
48
51
|
private sortStateInitialized;
|
|
49
52
|
private sortFrequency;
|
|
50
53
|
private frameCounter;
|
|
@@ -53,6 +56,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
53
56
|
private editorBindGroupLayout;
|
|
54
57
|
private editorBindGroup;
|
|
55
58
|
private editorEnabled;
|
|
59
|
+
private depthWriteEnabled;
|
|
56
60
|
private depthNormalPipeline;
|
|
57
61
|
private depthRT;
|
|
58
62
|
private depthRTView;
|
|
@@ -63,6 +67,7 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
63
67
|
private dnResult;
|
|
64
68
|
constructor(renderer: Renderer, camera: Camera);
|
|
65
69
|
private createPipeline;
|
|
70
|
+
setDepthWriteEnabled(enabled: boolean): void;
|
|
66
71
|
private createUniformBuffer;
|
|
67
72
|
private createDepthNormalPipeline;
|
|
68
73
|
private ensureDepthNormalTextures;
|
|
@@ -86,6 +91,14 @@ export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities
|
|
|
86
91
|
*/
|
|
87
92
|
setMaxVisibleSplats(count: number): void;
|
|
88
93
|
getMaxVisibleSplats(): number;
|
|
94
|
+
/**
|
|
95
|
+
* 设置深度范围限制(view-space 距离)
|
|
96
|
+
* 只渲染距相机此距离范围内的 splat,超出部分被剔除
|
|
97
|
+
* 近似 transmittance cutoff:近距离时大量 splat 堆叠在后方但被前方遮挡
|
|
98
|
+
* 0 = 不限制
|
|
99
|
+
*/
|
|
100
|
+
setDepthRangeLimit(limit: number): void;
|
|
101
|
+
getDepthRangeLimit(): number;
|
|
89
102
|
/**
|
|
90
103
|
* 设置排序频率
|
|
91
104
|
* 1 = 每帧排序(默认),2 = 每 2 帧排序一次,以此类推
|
package/dist/index.d.ts
CHANGED
|
@@ -53,4 +53,4 @@ export { ToolManager } from './editor/tools/ToolManager';
|
|
|
53
53
|
export type { Tool } from './editor/tools/ToolManager';
|
|
54
54
|
export { exportEditedPLY } from './editor/SplatExporter';
|
|
55
55
|
export { App } from './App';
|
|
56
|
-
export type { ProgressCallback } from './App';
|
|
56
|
+
export type { ProgressCallback, AdaptivePerformanceConfig } from './App';
|