@d5techs/3dgs-lib 1.0.1 → 1.1.1
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/README.md +311 -136
- package/dist/3dgs-lib.cjs +4215 -2150
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +4216 -2151
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/App.d.ts +28 -7
- package/dist/core/BoundingBoxRenderer.d.ts +2 -15
- package/dist/core/OrbitControls.d.ts +21 -41
- package/dist/core/gizmo/{TransformGizmoV2.d.ts → TransformGizmo.d.ts} +2 -2
- package/dist/core/{ViewportGizmo.d.ts → gizmo/ViewportGizmo.d.ts} +2 -2
- package/dist/core/gizmo/index.d.ts +3 -2
- package/dist/core/index.d.ts +7 -0
- package/dist/gs/GSSplatRenderer.d.ts +68 -172
- package/dist/gs/GSSplatRendererMobile.d.ts +9 -6
- package/dist/gs/GSSplatSorter.d.ts +44 -37
- package/dist/gs/IGSSplatRenderer.d.ts +39 -37
- package/dist/gs/SOGLoader.d.ts +25 -0
- package/dist/index.d.ts +17 -13
- package/dist/interaction/GizmoManager.d.ts +9 -46
- package/dist/interaction/HotspotManager.d.ts +142 -0
- package/dist/loaders/GLBLoader.d.ts +3 -11
- package/dist/loaders/OBJLoader.d.ts +1 -1
- package/dist/mesh/Mesh.d.ts +8 -16
- package/dist/mesh/MeshRenderer.d.ts +30 -14
- package/dist/scene/SceneManager.d.ts +12 -6
- package/dist/scene/proxies/MeshGroupProxy.d.ts +20 -0
- package/dist/scene/proxies/SplatBoundingBoxProvider.d.ts +11 -0
- package/dist/scene/proxies/SplatTransformProxy.d.ts +17 -0
- package/dist/scene/proxies/index.d.ts +6 -0
- package/dist/types/geometry.d.ts +60 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/material.d.ts +27 -0
- package/dist/types/splat.d.ts +25 -0
- package/dist/utils/device.d.ts +17 -0
- package/dist/utils/geometry.d.ts +26 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/texture.d.ts +64 -0
- package/package.json +4 -1
package/dist/App.d.ts
CHANGED
|
@@ -17,11 +17,12 @@ import { MeshRenderer } from "./mesh/MeshRenderer";
|
|
|
17
17
|
import { Mesh } from "./mesh/Mesh";
|
|
18
18
|
import { GSSplatRenderer } from "./gs/GSSplatRenderer";
|
|
19
19
|
import { GSSplatRendererMobile } from "./gs/GSSplatRendererMobile";
|
|
20
|
-
import { BoundingBox } from "./
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
20
|
+
import type { BoundingBox, SimpleBoundingBox } from "./types";
|
|
21
|
+
import { HotspotManager } from "./interaction/HotspotManager";
|
|
22
|
+
import type { HotspotInfo } from "./interaction/HotspotManager";
|
|
23
|
+
import { SplatTransformProxy, MeshGroupProxy, SplatBoundingBoxProvider } from "./scene/proxies";
|
|
24
|
+
import { TransformableObject, GizmoMode } from "./core/gizmo/TransformGizmo";
|
|
25
|
+
import type { BoundingBoxProvider } from "./types";
|
|
25
26
|
/**
|
|
26
27
|
* 统一进度回调类型
|
|
27
28
|
* @param progress 进度值 0-100
|
|
@@ -41,6 +42,7 @@ export declare class App {
|
|
|
41
42
|
private objLoader;
|
|
42
43
|
private sceneManager;
|
|
43
44
|
private gizmoManager;
|
|
45
|
+
private hotspotManager;
|
|
44
46
|
private isRunning;
|
|
45
47
|
private animationId;
|
|
46
48
|
private useMobileRenderer;
|
|
@@ -66,6 +68,10 @@ export declare class App {
|
|
|
66
68
|
* 加载 Splat 文件
|
|
67
69
|
*/
|
|
68
70
|
addSplat(urlOrBuffer: string | ArrayBuffer, onProgress?: ProgressCallback, isLocalFile?: boolean): Promise<number>;
|
|
71
|
+
/**
|
|
72
|
+
* 加载 SOG 文件 (Spatially Ordered Gaussians)
|
|
73
|
+
*/
|
|
74
|
+
addSOG(urlOrBuffer: string | ArrayBuffer, onProgress?: ProgressCallback, isLocalFile?: boolean): Promise<number>;
|
|
69
75
|
/**
|
|
70
76
|
* 添加测试立方体
|
|
71
77
|
*/
|
|
@@ -105,13 +111,18 @@ export declare class App {
|
|
|
105
111
|
getMeshColor(index: number): [number, number, number, number] | null;
|
|
106
112
|
setMeshColor(index: number, r: number, g: number, b: number, a?: number): boolean;
|
|
107
113
|
setMeshRangeColor(startIndex: number, count: number, r: number, g: number, b: number, a?: number): number;
|
|
114
|
+
getOverlayMeshCount(): number;
|
|
115
|
+
removeOverlayMeshByIndex(index: number): boolean;
|
|
116
|
+
getOverlayMeshColor(index: number): [number, number, number, number] | null;
|
|
117
|
+
setOverlayMeshRangeColor(startIndex: number, count: number, r: number, g: number, b: number, a?: number): number;
|
|
118
|
+
createOverlayMeshGroupProxy(startIndex: number, count: number): MeshGroupProxy | null;
|
|
108
119
|
frameCurrentModel(animate?: boolean): boolean;
|
|
109
|
-
getTransformGizmo(): import(".").
|
|
120
|
+
getTransformGizmo(): import(".").TransformGizmo;
|
|
110
121
|
getViewportGizmo(): import(".").ViewportGizmo;
|
|
111
122
|
getBoundingBoxRenderer(): import(".").BoundingBoxRenderer;
|
|
112
123
|
setGizmoMode(mode: GizmoMode): void;
|
|
113
124
|
setGizmoTarget(object: TransformableObject | null): void;
|
|
114
|
-
setSelectionBoundingBox(box:
|
|
125
|
+
setSelectionBoundingBox(box: SimpleBoundingBox | null): void;
|
|
115
126
|
setSelectionBoundingBoxProvider(provider: BoundingBoxProvider | null): void;
|
|
116
127
|
clearSelectionBoundingBox(): void;
|
|
117
128
|
/**
|
|
@@ -133,6 +144,16 @@ export declare class App {
|
|
|
133
144
|
getGSRenderer(): GSSplatRenderer | undefined;
|
|
134
145
|
getGSRendererMobile(): GSSplatRendererMobile | undefined;
|
|
135
146
|
isUsingMobileRenderer(): boolean;
|
|
147
|
+
getHotspotManager(): HotspotManager;
|
|
148
|
+
enterHotspotMode(objUrl: string): void;
|
|
149
|
+
exitHotspotMode(): void;
|
|
150
|
+
isHotspotModeActive(): boolean;
|
|
151
|
+
getHotspots(): HotspotInfo[];
|
|
152
|
+
setHotspotBillboard(hotspotIndex: number, enabled: boolean): boolean;
|
|
153
|
+
getHotspotBillboard(hotspotIndex: number): boolean;
|
|
154
|
+
getHotspotCount(): number;
|
|
155
|
+
findHotspotIndexByMeshStart(overlayMeshStartIndex: number): number;
|
|
156
|
+
getOverlayMeshByIndex(index: number): import("./mesh/Mesh").Mesh | null;
|
|
136
157
|
private fetchWithProgress;
|
|
137
158
|
private parsePLYBuffer;
|
|
138
159
|
/**
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import { Renderer } from "./Renderer";
|
|
2
2
|
import { Camera } from "./Camera";
|
|
3
|
-
|
|
4
|
-
* BoundingBox 数据结构
|
|
5
|
-
*/
|
|
6
|
-
export interface BoundingBox {
|
|
7
|
-
min: [number, number, number];
|
|
8
|
-
max: [number, number, number];
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* BoundingBoxProvider - 包围盒数据提供者接口
|
|
12
|
-
* 实现此接口的对象可以动态提供包围盒数据
|
|
13
|
-
*/
|
|
14
|
-
export interface BoundingBoxProvider {
|
|
15
|
-
getBoundingBox(): BoundingBox | null;
|
|
16
|
-
}
|
|
3
|
+
import type { SimpleBoundingBox, BoundingBoxProvider } from "../types";
|
|
17
4
|
/**
|
|
18
5
|
* BoundingBoxRenderer - 包围盒线框渲染器
|
|
19
6
|
* 用于显示选中对象的包围盒,支持动态跟随
|
|
@@ -46,7 +33,7 @@ export declare class BoundingBoxRenderer {
|
|
|
46
33
|
/**
|
|
47
34
|
* 设置静态包围盒(不会自动更新)
|
|
48
35
|
*/
|
|
49
|
-
setBoundingBox(box:
|
|
36
|
+
setBoundingBox(box: SimpleBoundingBox | null): void;
|
|
50
37
|
/**
|
|
51
38
|
* 清除包围盒
|
|
52
39
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Camera } from "./Camera";
|
|
2
2
|
/**
|
|
3
3
|
* OrbitControls - 轨道控制器
|
|
4
|
-
*
|
|
4
|
+
* 支持阻尼惯性、屏幕空间平移、中键拖拽、指数缩放
|
|
5
5
|
*/
|
|
6
6
|
export declare class OrbitControls {
|
|
7
7
|
private camera;
|
|
@@ -18,9 +18,17 @@ export declare class OrbitControls {
|
|
|
18
18
|
panSpeed: number;
|
|
19
19
|
touchZoomSpeed: number;
|
|
20
20
|
touchPanSpeed: number;
|
|
21
|
+
enableDamping: boolean;
|
|
22
|
+
dampingFactor: number;
|
|
21
23
|
private isDragging;
|
|
22
24
|
private lastX;
|
|
23
25
|
private lastY;
|
|
26
|
+
private velocityTheta;
|
|
27
|
+
private velocityPhi;
|
|
28
|
+
private velocityDistance;
|
|
29
|
+
private velocityPanX;
|
|
30
|
+
private velocityPanY;
|
|
31
|
+
private velocityPanZ;
|
|
24
32
|
private touchMode;
|
|
25
33
|
private lastTouchDistance;
|
|
26
34
|
private lastTouchCenter;
|
|
@@ -34,18 +42,17 @@ export declare class OrbitControls {
|
|
|
34
42
|
private boundOnTouchEnd;
|
|
35
43
|
private boundOnContextMenu;
|
|
36
44
|
constructor(camera: Camera, canvas: HTMLCanvasElement);
|
|
37
|
-
/**
|
|
38
|
-
* 设置事件监听
|
|
39
|
-
*/
|
|
40
45
|
private setupEventListeners;
|
|
46
|
+
private removeEventListeners;
|
|
47
|
+
destroy(): void;
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
49
|
+
* 从视图矩阵提取相机的 right 和 up 向量,用于屏幕空间平移
|
|
43
50
|
*/
|
|
44
|
-
private
|
|
51
|
+
private getCameraAxes;
|
|
45
52
|
/**
|
|
46
|
-
*
|
|
53
|
+
* 屏幕空间平移:将屏幕 delta 映射到相机 right/up 方向
|
|
47
54
|
*/
|
|
48
|
-
|
|
55
|
+
private panByScreenDelta;
|
|
49
56
|
private onMouseDown;
|
|
50
57
|
private onMouseMove;
|
|
51
58
|
private onMouseUp;
|
|
@@ -53,49 +60,22 @@ export declare class OrbitControls {
|
|
|
53
60
|
private onTouchStart;
|
|
54
61
|
private onTouchMove;
|
|
55
62
|
private onTouchEnd;
|
|
56
|
-
/**
|
|
57
|
-
* 计算双指之间的距离
|
|
58
|
-
*/
|
|
59
63
|
private getTouchDistance;
|
|
60
|
-
/**
|
|
61
|
-
* 计算双指的中心点
|
|
62
|
-
*/
|
|
63
64
|
private getTouchCenter;
|
|
64
65
|
/**
|
|
65
|
-
*
|
|
66
|
+
* 将球坐标写入相机位置(内部方法,不处理阻尼)
|
|
66
67
|
*/
|
|
67
|
-
|
|
68
|
+
private applySpherical;
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @param positive 是否正向
|
|
72
|
-
* @param animate 是否动画过渡
|
|
70
|
+
* 每帧调用:应用阻尼衰减并更新相机
|
|
71
|
+
* 在渲染循环中调用此方法以获得平滑惯性效果
|
|
73
72
|
*/
|
|
73
|
+
update(): void;
|
|
74
74
|
setViewAxis(axis: string, positive: boolean, animate?: boolean): void;
|
|
75
|
-
/**
|
|
76
|
-
* 动画过渡到目标视图
|
|
77
|
-
*/
|
|
78
75
|
private animateToView;
|
|
79
|
-
/**
|
|
80
|
-
* 设置相机目标点(控制器旋转中心)
|
|
81
|
-
* @param x X 坐标
|
|
82
|
-
* @param y Y 坐标
|
|
83
|
-
* @param z Z 坐标
|
|
84
|
-
*/
|
|
85
76
|
setTarget(x: number, y: number, z: number): void;
|
|
86
|
-
/**
|
|
87
|
-
* 获取当前目标点
|
|
88
|
-
*/
|
|
89
77
|
getTarget(): [number, number, number];
|
|
90
|
-
/**
|
|
91
|
-
* 根据模型参数自动调整相机位置和参数
|
|
92
|
-
* @param center 模型中心点
|
|
93
|
-
* @param radius 模型包围球半径
|
|
94
|
-
* @param animate 是否使用动画过渡
|
|
95
|
-
*/
|
|
96
78
|
frameModel(center: [number, number, number], radius: number, animate?: boolean): void;
|
|
97
|
-
/**
|
|
98
|
-
* 动画过渡到目标帧(包含目标点和距离)
|
|
99
|
-
*/
|
|
100
79
|
private animateToFrame;
|
|
80
|
+
clearVelocity(): void;
|
|
101
81
|
}
|
|
@@ -65,10 +65,10 @@ export interface TransformGizmoConfig {
|
|
|
65
65
|
snapIncrement?: number;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* TransformGizmo - 变换 Gizmo
|
|
69
69
|
* 参考 PlayCanvas 引擎的 TransformGizmo 实现
|
|
70
70
|
*/
|
|
71
|
-
export declare class
|
|
71
|
+
export declare class TransformGizmo {
|
|
72
72
|
private renderer;
|
|
73
73
|
private camera;
|
|
74
74
|
private canvas;
|
|
@@ -10,5 +10,6 @@ export { ArcShape } from "./ArcShape";
|
|
|
10
10
|
export type { ArcShapeConfig, ArcDisplayMode } from "./ArcShape";
|
|
11
11
|
export { BoxLineShape } from "./BoxLineShape";
|
|
12
12
|
export type { BoxLineShapeConfig } from "./BoxLineShape";
|
|
13
|
-
export {
|
|
14
|
-
export
|
|
13
|
+
export { ViewportGizmo } from "./ViewportGizmo";
|
|
14
|
+
export { TransformGizmo, GizmoMode } from "./TransformGizmo";
|
|
15
|
+
export type { TransformGizmoConfig, TransformableObject, GizmoSpace, GizmoDragMode, GizmoTheme, } from "./TransformGizmo";
|
|
@@ -1,217 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSSplatRenderer - 优化的 3D Gaussian Splatting 渲染器
|
|
3
|
+
*
|
|
4
|
+
* 基于 rfs-gsplat-render 的实现进行优化:
|
|
5
|
+
* 1. GPU Radix Sort - O(n) 稳定排序
|
|
6
|
+
* 2. Normalized Gaussian - 消除边缘雾化
|
|
7
|
+
* 3. ClipCorner 优化 - 减少 overdraw
|
|
8
|
+
* 4. MipSplatting 抗锯齿
|
|
9
|
+
* 5. 改进的视锥剔除
|
|
10
|
+
*/
|
|
1
11
|
import { Renderer } from "../core/Renderer";
|
|
2
12
|
import { Camera } from "../core/Camera";
|
|
3
13
|
import { SplatCPU } from "./PLYLoader";
|
|
4
14
|
import { CompactSplatData } from "./PLYLoaderMobile";
|
|
5
|
-
import { BoundingBox
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export declare enum PerformanceTier {
|
|
10
|
-
HIGH = "high",// 桌面高端 GPU
|
|
11
|
-
MEDIUM = "medium",// 桌面中端
|
|
12
|
-
LOW = "low"
|
|
13
|
-
}
|
|
15
|
+
import type { BoundingBox, Vec3Tuple } from "../types";
|
|
16
|
+
import { SHMode, RendererCapabilities } from "../types";
|
|
17
|
+
import type { IGSSplatRendererWithCapabilities } from "./IGSSplatRenderer";
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export interface MobileOptimizationConfig {
|
|
18
|
-
maxVisibleSplats: number;
|
|
19
|
-
enableSorting: boolean;
|
|
20
|
-
sortEveryNFrames: number;
|
|
21
|
-
useCompactFormat: boolean;
|
|
22
|
-
pixelCullThreshold: number;
|
|
23
|
-
defaultSHMode: SHMode;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* SH 模式枚举
|
|
27
|
-
* @deprecated 使用 IGSSplatRenderer 中的 SHMode
|
|
28
|
-
*/
|
|
29
|
-
export declare enum SHMode {
|
|
30
|
-
L0 = 0,// 仅 DC 颜色 (高性能)
|
|
31
|
-
L1 = 1,// DC + L1 SH
|
|
32
|
-
L2 = 2,// DC + L1 + L2 SH
|
|
33
|
-
L3 = 3
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Bounding Box 结构
|
|
37
|
-
* @deprecated 使用 IGSSplatRenderer 中的 BoundingBox
|
|
38
|
-
*/
|
|
39
|
-
export interface BoundingBox {
|
|
40
|
-
min: [number, number, number];
|
|
41
|
-
max: [number, number, number];
|
|
42
|
-
center: [number, number, number];
|
|
43
|
-
radius: number;
|
|
44
|
-
}
|
|
45
|
-
export type { IBoundingBox as GSBoundingBox };
|
|
46
|
-
/**
|
|
47
|
-
* GSSplatRenderer - 3D Gaussian Splatting 渲染器
|
|
48
|
-
* 使用 instanced quad 方式渲染 splats
|
|
49
|
-
* 实现 IGSSplatRenderer 接口
|
|
50
|
-
*
|
|
51
|
-
* 优化功能:
|
|
52
|
-
* - GPU 可见性剔除 (视锥/近平面/屏幕尺寸)
|
|
53
|
-
* - DrawIndirect 避免 CPU submit 开销
|
|
54
|
-
* - 仅对可见 splat 排序
|
|
55
|
-
* - 移动端自动优化(降低排序频率、使用紧凑格式)
|
|
19
|
+
* GSSplatRendererV2 - 优化的渲染器
|
|
56
20
|
*/
|
|
57
21
|
export declare class GSSplatRenderer implements IGSSplatRendererWithCapabilities {
|
|
58
22
|
private renderer;
|
|
59
23
|
private camera;
|
|
60
|
-
private
|
|
61
|
-
private pipelineL1;
|
|
62
|
-
private pipelineL2;
|
|
63
|
-
private pipelineL3;
|
|
64
|
-
private pipelineL0Compact;
|
|
24
|
+
private pipeline;
|
|
65
25
|
private bindGroupLayout;
|
|
66
|
-
private bindGroupLayoutCompact;
|
|
67
26
|
private uniformBuffer;
|
|
68
27
|
private splatBuffer;
|
|
69
28
|
private splatCount;
|
|
70
29
|
private bindGroup;
|
|
71
30
|
private sorter;
|
|
72
|
-
private useDrawIndirect;
|
|
73
|
-
private isMobile;
|
|
74
|
-
private pixelCullThreshold;
|
|
75
31
|
private shMode;
|
|
76
32
|
private boundingBox;
|
|
33
|
+
private cpuPositions;
|
|
77
34
|
private position;
|
|
78
35
|
private rotation;
|
|
79
36
|
private scale;
|
|
80
37
|
private pivot;
|
|
81
38
|
private modelMatrix;
|
|
82
|
-
private
|
|
83
|
-
private
|
|
84
|
-
private
|
|
85
|
-
private
|
|
39
|
+
private pixelCullThreshold;
|
|
40
|
+
private maxVisibleSplats;
|
|
41
|
+
private lastSortViewMatrix;
|
|
42
|
+
private lastSortProjMatrix;
|
|
43
|
+
private lastSortModelMatrix;
|
|
44
|
+
private lastSortWidth;
|
|
45
|
+
private lastSortHeight;
|
|
46
|
+
private lastSortPixelThreshold;
|
|
47
|
+
private lastSortMaxVisible;
|
|
48
|
+
private sortStateInitialized;
|
|
49
|
+
private sortFrequency;
|
|
50
|
+
private frameCounter;
|
|
51
|
+
private depthNormalPipeline;
|
|
52
|
+
private depthRT;
|
|
53
|
+
private depthRTView;
|
|
54
|
+
private normalRT;
|
|
55
|
+
private normalRTView;
|
|
56
|
+
private dnRTWidth;
|
|
57
|
+
private dnRTHeight;
|
|
58
|
+
private dnResult;
|
|
86
59
|
constructor(renderer: Renderer, camera: Camera);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
60
|
+
private createPipeline;
|
|
61
|
+
private createUniformBuffer;
|
|
62
|
+
private createDepthNormalPipeline;
|
|
63
|
+
private ensureDepthNormalTextures;
|
|
90
64
|
setPosition(x: number, y: number, z: number): void;
|
|
91
|
-
|
|
92
|
-
* 获取位置
|
|
93
|
-
*/
|
|
94
|
-
getPosition(): [number, number, number];
|
|
95
|
-
/**
|
|
96
|
-
* 设置旋转 (欧拉角, 弧度)
|
|
97
|
-
*/
|
|
65
|
+
getPosition(): Vec3Tuple;
|
|
98
66
|
setRotation(x: number, y: number, z: number): void;
|
|
99
|
-
|
|
100
|
-
* 获取旋转
|
|
101
|
-
*/
|
|
102
|
-
getRotation(): [number, number, number];
|
|
103
|
-
/**
|
|
104
|
-
* 设置缩放
|
|
105
|
-
*/
|
|
67
|
+
getRotation(): Vec3Tuple;
|
|
106
68
|
setScale(x: number, y: number, z: number): void;
|
|
107
|
-
|
|
108
|
-
* 获取缩放
|
|
109
|
-
*/
|
|
110
|
-
getScale(): [number, number, number];
|
|
111
|
-
/**
|
|
112
|
-
* 设置旋转/缩放中心点 (pivot)
|
|
113
|
-
*/
|
|
69
|
+
getScale(): Vec3Tuple;
|
|
114
70
|
setPivot(x: number, y: number, z: number): void;
|
|
115
|
-
|
|
116
|
-
* 获取旋转/缩放中心点 (pivot)
|
|
117
|
-
*/
|
|
118
|
-
getPivot(): [number, number, number];
|
|
119
|
-
/**
|
|
120
|
-
* 更新模型矩阵
|
|
121
|
-
* 变换顺序: T * Tp * R * S * Tp^-1
|
|
122
|
-
* 即: 先移到原点,缩放,旋转,再移回pivot,最后应用用户平移
|
|
123
|
-
*/
|
|
71
|
+
getPivot(): Vec3Tuple;
|
|
124
72
|
private updateModelMatrix;
|
|
125
|
-
/**
|
|
126
|
-
* 获取当前模型矩阵
|
|
127
|
-
*/
|
|
128
73
|
getModelMatrix(): Float32Array;
|
|
129
|
-
/**
|
|
130
|
-
* 获取当前性能等级
|
|
131
|
-
*/
|
|
132
|
-
getPerformanceTier(): PerformanceTier;
|
|
133
|
-
/**
|
|
134
|
-
* 手动设置优化配置
|
|
135
|
-
*/
|
|
136
|
-
setOptimizationConfig(config: Partial<MobileOptimizationConfig>): void;
|
|
137
|
-
/**
|
|
138
|
-
* 获取当前优化配置
|
|
139
|
-
*/
|
|
140
|
-
getOptimizationConfig(): MobileOptimizationConfig;
|
|
141
|
-
/**
|
|
142
|
-
* 设置 SH 模式
|
|
143
|
-
* @param mode L0/L1/L2/L3
|
|
144
|
-
*/
|
|
145
74
|
setSHMode(mode: SHMode): void;
|
|
146
|
-
/**
|
|
147
|
-
* 获取当前 SH 模式
|
|
148
|
-
*/
|
|
149
75
|
getSHMode(): SHMode;
|
|
150
|
-
/**
|
|
151
|
-
* 设置是否启用 DrawIndirect (剔除优化)
|
|
152
|
-
* 启用后会在 GPU 上进行可见性剔除,仅绘制可见 splat
|
|
153
|
-
*/
|
|
154
|
-
setUseDrawIndirect(enabled: boolean): void;
|
|
155
|
-
/**
|
|
156
|
-
* 设置像素剔除阈值
|
|
157
|
-
* 屏幕上小于此像素数的 splat 会被剔除
|
|
158
|
-
* @param threshold 像素阈值,默认 1.0
|
|
159
|
-
*/
|
|
160
76
|
setPixelCullThreshold(threshold: number): void;
|
|
161
77
|
/**
|
|
162
|
-
*
|
|
78
|
+
* 设置最大可见 splat 数量
|
|
79
|
+
* 排序后只保留距离最近的 N 个 splat,远处被遮挡的 splat 被丢弃
|
|
80
|
+
* 0 = 不限制
|
|
163
81
|
*/
|
|
164
|
-
|
|
82
|
+
setMaxVisibleSplats(count: number): void;
|
|
83
|
+
getMaxVisibleSplats(): number;
|
|
165
84
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
private createUniformBuffer;
|
|
170
|
-
/**
|
|
171
|
-
* 设置 splat 数据
|
|
172
|
-
* @param splats CPU 端的 splat 数组
|
|
85
|
+
* 设置排序频率
|
|
86
|
+
* 1 = 每帧排序(默认),2 = 每 2 帧排序一次,以此类推
|
|
87
|
+
* 相机静止时自动跳过排序,不受此参数影响
|
|
173
88
|
*/
|
|
89
|
+
setSortFrequency(frequency: number): void;
|
|
90
|
+
getSortFrequency(): number;
|
|
91
|
+
private needsSort;
|
|
92
|
+
private saveSortState;
|
|
174
93
|
setData(splats: SplatCPU[]): void;
|
|
175
|
-
/**
|
|
176
|
-
* 设置紧凑格式的 splat 数据(移动端优化)
|
|
177
|
-
* 直接接受 CompactSplatData,避免创建中间对象
|
|
178
|
-
* @param compactData 紧凑格式的 splat 数据
|
|
179
|
-
*/
|
|
180
94
|
setCompactData(compactData: CompactSplatData): void;
|
|
181
|
-
/**
|
|
182
|
-
* 从紧凑数据计算 bounding box
|
|
183
|
-
*/
|
|
184
|
-
private computeBoundingBoxFromCompact;
|
|
185
|
-
/**
|
|
186
|
-
* 渲染 splats
|
|
187
|
-
* @param pass 渲染通道编码器
|
|
188
|
-
*/
|
|
189
95
|
render(pass: GPURenderPassEncoder): void;
|
|
190
|
-
/**
|
|
191
|
-
* 获取 splat 数量
|
|
192
|
-
*/
|
|
193
96
|
getSplatCount(): number;
|
|
194
|
-
/**
|
|
195
|
-
* 获取点云的 bounding box
|
|
196
|
-
* @returns BoundingBox 或 null(如果没有点云数据)
|
|
197
|
-
*/
|
|
198
97
|
getBoundingBox(): BoundingBox | null;
|
|
199
|
-
|
|
200
|
-
* 计算点云的 bounding box
|
|
201
|
-
* @param splats splat 数组
|
|
202
|
-
* @returns BoundingBox
|
|
203
|
-
*/
|
|
98
|
+
getCPUPositions(): Float32Array | null;
|
|
204
99
|
private computeBoundingBox;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
100
|
+
private computeBoundingBoxFromCompact;
|
|
101
|
+
prepareDepthNormalPass(px?: number, py?: number): void;
|
|
102
|
+
private static half2Float;
|
|
103
|
+
private static _f32;
|
|
104
|
+
private static _u32;
|
|
105
|
+
getDepthNormal(): {
|
|
106
|
+
depth: number;
|
|
107
|
+
normal: Vec3Tuple;
|
|
108
|
+
worldPos: Vec3Tuple;
|
|
109
|
+
} | null;
|
|
110
|
+
supportsSHMode(mode: SHMode): boolean;
|
|
212
111
|
getCapabilities(): RendererCapabilities;
|
|
213
|
-
/**
|
|
214
|
-
* 销毁资源
|
|
215
|
-
*/
|
|
216
112
|
destroy(): void;
|
|
217
113
|
}
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
import { Renderer } from "../core/Renderer";
|
|
11
11
|
import { Camera } from "../core/Camera";
|
|
12
12
|
import { CompactSplatData } from "./PLYLoaderMobile";
|
|
13
|
-
import { BoundingBox,
|
|
14
|
-
|
|
13
|
+
import type { BoundingBox, Vec3Tuple } from "../types";
|
|
14
|
+
import { SHMode, RendererCapabilities } from "../types";
|
|
15
|
+
import type { IGSSplatRendererWithCapabilities } from "./IGSSplatRenderer";
|
|
15
16
|
/**
|
|
16
17
|
* GSSplatRendererMobile - 移动端优化渲染器
|
|
17
18
|
* 实现 IGSSplatRenderer 接口
|
|
@@ -30,6 +31,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
30
31
|
private sorter;
|
|
31
32
|
private positionsBuffer;
|
|
32
33
|
private boundingBox;
|
|
34
|
+
private cpuPositions;
|
|
33
35
|
private frameCount;
|
|
34
36
|
private sortEveryNFrames;
|
|
35
37
|
private position;
|
|
@@ -45,7 +47,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
45
47
|
/**
|
|
46
48
|
* 获取位置
|
|
47
49
|
*/
|
|
48
|
-
getPosition():
|
|
50
|
+
getPosition(): Vec3Tuple;
|
|
49
51
|
/**
|
|
50
52
|
* 设置旋转 (欧拉角, 弧度)
|
|
51
53
|
*/
|
|
@@ -53,7 +55,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
53
55
|
/**
|
|
54
56
|
* 获取旋转
|
|
55
57
|
*/
|
|
56
|
-
getRotation():
|
|
58
|
+
getRotation(): Vec3Tuple;
|
|
57
59
|
/**
|
|
58
60
|
* 设置缩放
|
|
59
61
|
*/
|
|
@@ -61,7 +63,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
61
63
|
/**
|
|
62
64
|
* 获取缩放
|
|
63
65
|
*/
|
|
64
|
-
getScale():
|
|
66
|
+
getScale(): Vec3Tuple;
|
|
65
67
|
/**
|
|
66
68
|
* 设置旋转/缩放中心点 (pivot)
|
|
67
69
|
*/
|
|
@@ -69,7 +71,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
69
71
|
/**
|
|
70
72
|
* 获取旋转/缩放中心点 (pivot)
|
|
71
73
|
*/
|
|
72
|
-
getPivot():
|
|
74
|
+
getPivot(): Vec3Tuple;
|
|
73
75
|
/**
|
|
74
76
|
* 更新模型矩阵
|
|
75
77
|
* 变换顺序: T * Tp * R * S * Tp^-1
|
|
@@ -115,6 +117,7 @@ export declare class GSSplatRendererMobile implements IGSSplatRendererWithCapabi
|
|
|
115
117
|
* 获取 bounding box
|
|
116
118
|
*/
|
|
117
119
|
getBoundingBox(): BoundingBox | null;
|
|
120
|
+
getCPUPositions(): Float32Array | null;
|
|
118
121
|
/**
|
|
119
122
|
* 设置排序频率
|
|
120
123
|
* @param n 每 n 帧排序一次
|