@d5techs/3dgs-lib 1.0.0
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 +236 -0
- package/dist/3dgs-lib.cjs +12012 -0
- package/dist/3dgs-lib.cjs.map +1 -0
- package/dist/3dgs-lib.js +12012 -0
- package/dist/3dgs-lib.js.map +1 -0
- package/dist/App.d.ts +142 -0
- package/dist/core/BoundingBoxRenderer.d.ts +70 -0
- package/dist/core/Camera.d.ts +38 -0
- package/dist/core/OrbitControls.d.ts +101 -0
- package/dist/core/Renderer.d.ts +69 -0
- package/dist/core/ViewportGizmo.d.ts +83 -0
- package/dist/core/gizmo/ArcShape.d.ts +90 -0
- package/dist/core/gizmo/ArrowShape.d.ts +51 -0
- package/dist/core/gizmo/BoxLineShape.d.ts +47 -0
- package/dist/core/gizmo/PlaneShape.d.ts +48 -0
- package/dist/core/gizmo/Shape.d.ts +117 -0
- package/dist/core/gizmo/SphereShape.d.ts +29 -0
- package/dist/core/gizmo/TransformGizmoV2.d.ts +203 -0
- package/dist/core/gizmo/index.d.ts +14 -0
- package/dist/core/math/Mat4.d.ts +38 -0
- package/dist/core/math/Quat.d.ts +52 -0
- package/dist/core/math/Ray.d.ts +65 -0
- package/dist/core/math/Vec3.d.ts +39 -0
- package/dist/gs/GSSplatRenderer.d.ts +217 -0
- package/dist/gs/GSSplatRendererMobile.d.ts +147 -0
- package/dist/gs/GSSplatSorter.d.ts +105 -0
- package/dist/gs/GSSplatSorterMobile.d.ts +86 -0
- package/dist/gs/IGSSplatRenderer.d.ts +123 -0
- package/dist/gs/PLYLoader.d.ts +22 -0
- package/dist/gs/PLYLoaderMobile.d.ts +62 -0
- package/dist/gs/SplatLoader.d.ts +25 -0
- package/dist/gs/TextureCompressor.d.ts +57 -0
- package/dist/index.d.ts +44 -0
- package/dist/interaction/GizmoManager.d.ts +132 -0
- package/dist/loaders/GLBLoader.d.ts +67 -0
- package/dist/loaders/MTLParser.d.ts +65 -0
- package/dist/loaders/OBJLoader.d.ts +68 -0
- package/dist/loaders/OBJParser.d.ts +115 -0
- package/dist/mesh/Mesh.d.ts +52 -0
- package/dist/mesh/MeshRenderer.d.ts +74 -0
- package/dist/scene/SceneManager.d.ts +136 -0
- package/package.json +62 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Vec3 } from "../math/Vec3";
|
|
2
|
+
import { Shape, ShapeConfig } from "./Shape";
|
|
3
|
+
/**
|
|
4
|
+
* PlaneShapeConfig - 平面形状配置
|
|
5
|
+
*/
|
|
6
|
+
export interface PlaneShapeConfig extends ShapeConfig {
|
|
7
|
+
size?: number;
|
|
8
|
+
gap?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* PlaneShape - 平面形状(用于双轴平移)
|
|
12
|
+
* 参考 PlayCanvas 引擎的 PlaneShape 实现
|
|
13
|
+
*/
|
|
14
|
+
export declare class PlaneShape extends Shape {
|
|
15
|
+
private _size;
|
|
16
|
+
private _gap;
|
|
17
|
+
private _geometryCache;
|
|
18
|
+
private _currentFlipKey;
|
|
19
|
+
constructor(config: PlaneShapeConfig);
|
|
20
|
+
get size(): number;
|
|
21
|
+
set size(value: number);
|
|
22
|
+
get gap(): number;
|
|
23
|
+
set gap(value: number);
|
|
24
|
+
/**
|
|
25
|
+
* 更新碰撞数据
|
|
26
|
+
*/
|
|
27
|
+
private _updateTriData;
|
|
28
|
+
/**
|
|
29
|
+
* 创建单位平面几何体
|
|
30
|
+
*/
|
|
31
|
+
private createPlaneGeometry;
|
|
32
|
+
/**
|
|
33
|
+
* 创建渲染用的 GPU 几何体
|
|
34
|
+
*/
|
|
35
|
+
createGeometry(device: GPUDevice): void;
|
|
36
|
+
/**
|
|
37
|
+
* 清除几何缓存
|
|
38
|
+
*/
|
|
39
|
+
private _clearGeometryCache;
|
|
40
|
+
/**
|
|
41
|
+
* 更新翻转状态
|
|
42
|
+
*/
|
|
43
|
+
setFlipped(newFlipped: Vec3): void;
|
|
44
|
+
/**
|
|
45
|
+
* 销毁 GPU 资源
|
|
46
|
+
*/
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Vec3 } from "../math/Vec3";
|
|
2
|
+
import { Ray } from "../math/Ray";
|
|
3
|
+
import { Mat4 } from "../math/Mat4";
|
|
4
|
+
/**
|
|
5
|
+
* GizmoAxis - 轴类型枚举
|
|
6
|
+
*/
|
|
7
|
+
export type GizmoAxisType = 'x' | 'y' | 'z' | 'xy' | 'xz' | 'yz' | 'xyz';
|
|
8
|
+
/**
|
|
9
|
+
* Vec4Color - 带透明度的颜色
|
|
10
|
+
*/
|
|
11
|
+
export interface Vec4Color {
|
|
12
|
+
r: number;
|
|
13
|
+
g: number;
|
|
14
|
+
b: number;
|
|
15
|
+
a: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ShapeConfig - Shape 配置
|
|
19
|
+
*/
|
|
20
|
+
export interface ShapeConfig {
|
|
21
|
+
axis: GizmoAxisType;
|
|
22
|
+
defaultColor: Vec3;
|
|
23
|
+
hoverColor: Vec3;
|
|
24
|
+
disabledColor: Vec3;
|
|
25
|
+
defaultAlpha?: number;
|
|
26
|
+
hoverAlpha?: number;
|
|
27
|
+
rotation?: Vec3;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* TriData - 三角形碰撞数据
|
|
31
|
+
*/
|
|
32
|
+
export interface TriData {
|
|
33
|
+
vertices: Float32Array;
|
|
34
|
+
indices: Uint16Array;
|
|
35
|
+
transform: Mat4;
|
|
36
|
+
priority: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Shape - Gizmo 形状基类
|
|
40
|
+
* 参考 PlayCanvas 引擎的 Shape 实现
|
|
41
|
+
*/
|
|
42
|
+
export declare abstract class Shape {
|
|
43
|
+
axis: GizmoAxisType;
|
|
44
|
+
protected _disabled: boolean;
|
|
45
|
+
protected _visible: boolean;
|
|
46
|
+
protected _hovered: boolean;
|
|
47
|
+
protected _interactable: boolean;
|
|
48
|
+
protected _defaultColor: Vec3;
|
|
49
|
+
protected _hoverColor: Vec3;
|
|
50
|
+
protected _disabledColor: Vec3;
|
|
51
|
+
protected _defaultAlpha: number;
|
|
52
|
+
protected _hoverAlpha: number;
|
|
53
|
+
protected _position: Vec3;
|
|
54
|
+
protected _rotation: Vec3;
|
|
55
|
+
protected _scale: Vec3;
|
|
56
|
+
triData: TriData[];
|
|
57
|
+
protected device: GPUDevice | null;
|
|
58
|
+
protected vertexBuffer: GPUBuffer | null;
|
|
59
|
+
protected indexBuffer: GPUBuffer | null;
|
|
60
|
+
protected vertexCount: number;
|
|
61
|
+
protected indexCount: number;
|
|
62
|
+
flipped: Vec3;
|
|
63
|
+
constructor(config: ShapeConfig);
|
|
64
|
+
get disabled(): boolean;
|
|
65
|
+
set disabled(value: boolean);
|
|
66
|
+
get visible(): boolean;
|
|
67
|
+
set visible(value: boolean);
|
|
68
|
+
get interactable(): boolean;
|
|
69
|
+
set interactable(value: boolean);
|
|
70
|
+
/**
|
|
71
|
+
* 设置 hover 状态
|
|
72
|
+
*/
|
|
73
|
+
hover(state: boolean): void;
|
|
74
|
+
/**
|
|
75
|
+
* 获取当前颜色(包含透明度)
|
|
76
|
+
*/
|
|
77
|
+
getColor(): Vec4Color;
|
|
78
|
+
/**
|
|
79
|
+
* 获取局部变换矩阵
|
|
80
|
+
*/
|
|
81
|
+
getLocalTransform(): Mat4;
|
|
82
|
+
/**
|
|
83
|
+
* 射线碰撞检测
|
|
84
|
+
* @param ray - 世界空间射线
|
|
85
|
+
* @param parentTransform - 父级变换矩阵(gizmo 的世界变换)
|
|
86
|
+
* @returns 碰撞距离,null 表示未碰撞
|
|
87
|
+
*/
|
|
88
|
+
intersect(ray: Ray, parentTransform: Mat4): number | null;
|
|
89
|
+
/**
|
|
90
|
+
* 射线与三角形列表碰撞检测
|
|
91
|
+
*/
|
|
92
|
+
protected intersectTriangles(ray: Ray, vertices: Float32Array, indices: Uint16Array): number | null;
|
|
93
|
+
/**
|
|
94
|
+
* 创建 GPU 资源
|
|
95
|
+
*/
|
|
96
|
+
abstract createGeometry(device: GPUDevice): void;
|
|
97
|
+
/**
|
|
98
|
+
* 获取顶点缓冲区
|
|
99
|
+
*/
|
|
100
|
+
getVertexBuffer(): GPUBuffer | null;
|
|
101
|
+
/**
|
|
102
|
+
* 获取索引缓冲区
|
|
103
|
+
*/
|
|
104
|
+
getIndexBuffer(): GPUBuffer | null;
|
|
105
|
+
/**
|
|
106
|
+
* 获取索引数量
|
|
107
|
+
*/
|
|
108
|
+
getIndexCount(): number;
|
|
109
|
+
/**
|
|
110
|
+
* 销毁 GPU 资源
|
|
111
|
+
*/
|
|
112
|
+
destroy(): void;
|
|
113
|
+
/**
|
|
114
|
+
* 创建 GPU 缓冲区
|
|
115
|
+
*/
|
|
116
|
+
protected createBuffers(device: GPUDevice, vertices: Float32Array, indices: Uint16Array): void;
|
|
117
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Shape, ShapeConfig } from "./Shape";
|
|
2
|
+
/**
|
|
3
|
+
* SphereShapeConfig - 球体形状配置
|
|
4
|
+
*/
|
|
5
|
+
export interface SphereShapeConfig extends ShapeConfig {
|
|
6
|
+
radius?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* SphereShape - 球体形状(用于统一缩放/中心选择)
|
|
10
|
+
* 参考 PlayCanvas 引擎的 SphereShape 实现
|
|
11
|
+
*/
|
|
12
|
+
export declare class SphereShape extends Shape {
|
|
13
|
+
private _radius;
|
|
14
|
+
constructor(config: SphereShapeConfig);
|
|
15
|
+
get radius(): number;
|
|
16
|
+
set radius(value: number);
|
|
17
|
+
/**
|
|
18
|
+
* 更新碰撞数据
|
|
19
|
+
*/
|
|
20
|
+
private _updateTriData;
|
|
21
|
+
/**
|
|
22
|
+
* 创建单位球体几何体(半径0.5,中心在原点)
|
|
23
|
+
*/
|
|
24
|
+
private createSphereGeometry;
|
|
25
|
+
/**
|
|
26
|
+
* 创建渲染用的 GPU 几何体
|
|
27
|
+
*/
|
|
28
|
+
createGeometry(device: GPUDevice): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Renderer } from "../Renderer";
|
|
2
|
+
import { Camera } from "../Camera";
|
|
3
|
+
import { Vec3 } from "../math/Vec3";
|
|
4
|
+
/**
|
|
5
|
+
* GizmoMode - Gizmo 操作模式
|
|
6
|
+
*/
|
|
7
|
+
export declare enum GizmoMode {
|
|
8
|
+
Translate = "translate",
|
|
9
|
+
Rotate = "rotate",
|
|
10
|
+
Scale = "scale"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* GizmoSpace - 坐标空间
|
|
14
|
+
*/
|
|
15
|
+
export type GizmoSpace = 'world' | 'local';
|
|
16
|
+
/**
|
|
17
|
+
* GizmoDragMode - 拖拽时的显示模式
|
|
18
|
+
*/
|
|
19
|
+
export type GizmoDragMode = 'show' | 'hide' | 'selected';
|
|
20
|
+
/**
|
|
21
|
+
* TransformableObject - 可变换对象接口
|
|
22
|
+
*/
|
|
23
|
+
export interface TransformableObject {
|
|
24
|
+
position: [number, number, number] | Float32Array;
|
|
25
|
+
rotation: [number, number, number] | Float32Array;
|
|
26
|
+
scale: [number, number, number] | Float32Array;
|
|
27
|
+
setPosition(x: number, y: number, z: number): void;
|
|
28
|
+
setRotation(x: number, y: number, z: number): void;
|
|
29
|
+
setScale(x: number, y: number, z: number): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* GizmoTheme - Gizmo 主题颜色
|
|
33
|
+
*/
|
|
34
|
+
export interface GizmoTheme {
|
|
35
|
+
shapeBase: {
|
|
36
|
+
x: Vec3;
|
|
37
|
+
y: Vec3;
|
|
38
|
+
z: Vec3;
|
|
39
|
+
xyz: Vec3;
|
|
40
|
+
f: Vec3;
|
|
41
|
+
};
|
|
42
|
+
shapeHover: {
|
|
43
|
+
x: Vec3;
|
|
44
|
+
y: Vec3;
|
|
45
|
+
z: Vec3;
|
|
46
|
+
xyz: Vec3;
|
|
47
|
+
f: Vec3;
|
|
48
|
+
};
|
|
49
|
+
guideBase: {
|
|
50
|
+
x: Vec3;
|
|
51
|
+
y: Vec3;
|
|
52
|
+
z: Vec3;
|
|
53
|
+
};
|
|
54
|
+
disabled: Vec3;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* TransformGizmoConfig - Gizmo 配置
|
|
58
|
+
*/
|
|
59
|
+
export interface TransformGizmoConfig {
|
|
60
|
+
renderer: Renderer;
|
|
61
|
+
camera: Camera;
|
|
62
|
+
canvas: HTMLCanvasElement;
|
|
63
|
+
size?: number;
|
|
64
|
+
snap?: boolean;
|
|
65
|
+
snapIncrement?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* TransformGizmoV2 - 重构后的变换 Gizmo
|
|
69
|
+
* 参考 PlayCanvas 引擎的 TransformGizmo 实现
|
|
70
|
+
*/
|
|
71
|
+
export declare class TransformGizmoV2 {
|
|
72
|
+
private renderer;
|
|
73
|
+
private camera;
|
|
74
|
+
private canvas;
|
|
75
|
+
private _size;
|
|
76
|
+
private _scale;
|
|
77
|
+
private _mode;
|
|
78
|
+
private _coordSpace;
|
|
79
|
+
private _theme;
|
|
80
|
+
snap: boolean;
|
|
81
|
+
snapIncrement: number;
|
|
82
|
+
dragMode: GizmoDragMode;
|
|
83
|
+
flipPlanes: boolean;
|
|
84
|
+
private _target;
|
|
85
|
+
private _shapes;
|
|
86
|
+
private _hoverAxis;
|
|
87
|
+
private _selectedAxis;
|
|
88
|
+
private _hoverIsPlane;
|
|
89
|
+
private _selectedIsPlane;
|
|
90
|
+
private _dragging;
|
|
91
|
+
private _rootStartPos;
|
|
92
|
+
private _rootStartRot;
|
|
93
|
+
private _selectionStartPoint;
|
|
94
|
+
private _dragStartTransform;
|
|
95
|
+
private _facingDir;
|
|
96
|
+
private _onDragStateChange;
|
|
97
|
+
private pipeline;
|
|
98
|
+
private linePipeline;
|
|
99
|
+
private uniformBuffer;
|
|
100
|
+
private bindGroup;
|
|
101
|
+
private bindGroupLayout;
|
|
102
|
+
private shapeUniformBuffers;
|
|
103
|
+
private shapeBindGroups;
|
|
104
|
+
private guideLineBuffer;
|
|
105
|
+
private guideLineBindGroup;
|
|
106
|
+
constructor(config: TransformGizmoConfig);
|
|
107
|
+
/**
|
|
108
|
+
* 初始化 Gizmo
|
|
109
|
+
*/
|
|
110
|
+
init(): void;
|
|
111
|
+
/**
|
|
112
|
+
* 创建 WebGPU 渲染管线
|
|
113
|
+
*/
|
|
114
|
+
private createPipeline;
|
|
115
|
+
/**
|
|
116
|
+
* 创建辅助线渲染管线
|
|
117
|
+
*/
|
|
118
|
+
private createLinePipeline;
|
|
119
|
+
/**
|
|
120
|
+
* 创建形状
|
|
121
|
+
*/
|
|
122
|
+
private createShapes;
|
|
123
|
+
/**
|
|
124
|
+
* 为每个 Shape 创建独立的 uniform buffer 和 bind group
|
|
125
|
+
*/
|
|
126
|
+
private createShapeUniformBuffers;
|
|
127
|
+
/**
|
|
128
|
+
* 创建平移模式的形状
|
|
129
|
+
*/
|
|
130
|
+
private createTranslateShapes;
|
|
131
|
+
/**
|
|
132
|
+
* 创建旋转模式的形状
|
|
133
|
+
*/
|
|
134
|
+
private createRotateShapes;
|
|
135
|
+
/**
|
|
136
|
+
* 创建缩放模式的形状
|
|
137
|
+
*/
|
|
138
|
+
private createScaleShapes;
|
|
139
|
+
get mode(): GizmoMode;
|
|
140
|
+
set mode(value: GizmoMode);
|
|
141
|
+
get coordSpace(): GizmoSpace;
|
|
142
|
+
set coordSpace(value: GizmoSpace);
|
|
143
|
+
get size(): number;
|
|
144
|
+
set size(value: number);
|
|
145
|
+
get target(): TransformableObject | null;
|
|
146
|
+
get isDragging(): boolean;
|
|
147
|
+
setTarget(object: TransformableObject | null): void;
|
|
148
|
+
setOnDragStateChange(callback: ((isDragging: boolean) => void) | null): void;
|
|
149
|
+
private _clearInteractionState;
|
|
150
|
+
private getGizmoPosition;
|
|
151
|
+
/**
|
|
152
|
+
* 获取 Gizmo 的视觉旋转(用于渲染形状)
|
|
153
|
+
* - 平移模式:根据 coordSpace 设置
|
|
154
|
+
* - 旋转模式:始终使用世界坐标(三个轴保持正交)
|
|
155
|
+
* - 缩放模式:始终使用本地坐标(跟随物体旋转)
|
|
156
|
+
*/
|
|
157
|
+
private getGizmoRotation;
|
|
158
|
+
private updateScale;
|
|
159
|
+
/**
|
|
160
|
+
* 获取面向相机的方向(从 Gizmo 指向相机)
|
|
161
|
+
*/
|
|
162
|
+
private getFacingDir;
|
|
163
|
+
/**
|
|
164
|
+
* 更新形状以面向相机
|
|
165
|
+
* 参考 PlayCanvas 的 _shapesLookAtCamera
|
|
166
|
+
*/
|
|
167
|
+
private _shapesLookAtCamera;
|
|
168
|
+
/**
|
|
169
|
+
* 更新平移形状
|
|
170
|
+
*/
|
|
171
|
+
private _updateTranslateShapesForCamera;
|
|
172
|
+
/**
|
|
173
|
+
* 更新旋转形状
|
|
174
|
+
*/
|
|
175
|
+
private _updateRotateShapesForCamera;
|
|
176
|
+
/**
|
|
177
|
+
* 拖拽时更新形状显示
|
|
178
|
+
*/
|
|
179
|
+
private _updateDragVisibility;
|
|
180
|
+
private _updateRotateDragVisibility;
|
|
181
|
+
private _updateTranslateDragVisibility;
|
|
182
|
+
private _updateScaleDragVisibility;
|
|
183
|
+
private screenToRay;
|
|
184
|
+
private performHitTest;
|
|
185
|
+
onPointerMove(event: PointerEvent): void;
|
|
186
|
+
onPointerDown(event: PointerEvent): void;
|
|
187
|
+
onPointerUp(event: PointerEvent): void;
|
|
188
|
+
private _updateHover;
|
|
189
|
+
private _screenToPoint;
|
|
190
|
+
private _createRotationPlane;
|
|
191
|
+
private _createFacingPlane;
|
|
192
|
+
private _createInteractionPlane;
|
|
193
|
+
private _projectToAxis;
|
|
194
|
+
private _applyTransform;
|
|
195
|
+
private _applyTranslation;
|
|
196
|
+
private _applyRotation;
|
|
197
|
+
private _applyFacingRotation;
|
|
198
|
+
private _applyScale;
|
|
199
|
+
private getShapeModelMatrix;
|
|
200
|
+
private updateUniformsForShape;
|
|
201
|
+
render(pass: GPURenderPassEncoder): void;
|
|
202
|
+
destroy(): void;
|
|
203
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Shape } from "./Shape";
|
|
2
|
+
export type { GizmoAxisType, ShapeConfig, TriData, Vec4Color } from "./Shape";
|
|
3
|
+
export { ArrowShape } from "./ArrowShape";
|
|
4
|
+
export type { ArrowShapeConfig } from "./ArrowShape";
|
|
5
|
+
export { PlaneShape } from "./PlaneShape";
|
|
6
|
+
export type { PlaneShapeConfig } from "./PlaneShape";
|
|
7
|
+
export { SphereShape } from "./SphereShape";
|
|
8
|
+
export type { SphereShapeConfig } from "./SphereShape";
|
|
9
|
+
export { ArcShape } from "./ArcShape";
|
|
10
|
+
export type { ArcShapeConfig, ArcDisplayMode } from "./ArcShape";
|
|
11
|
+
export { BoxLineShape } from "./BoxLineShape";
|
|
12
|
+
export type { BoxLineShapeConfig } from "./BoxLineShape";
|
|
13
|
+
export { TransformGizmoV2, GizmoMode } from "./TransformGizmoV2";
|
|
14
|
+
export type { TransformGizmoConfig, TransformableObject, GizmoSpace, GizmoDragMode, GizmoTheme, } from "./TransformGizmoV2";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Vec3 } from "./Vec3";
|
|
2
|
+
import { Quat } from "./Quat";
|
|
3
|
+
/**
|
|
4
|
+
* Mat4 - 4x4 Matrix utility class
|
|
5
|
+
* Provides matrix operations for 3D transformations
|
|
6
|
+
* Storage is column-major order (OpenGL/WebGPU convention)
|
|
7
|
+
*/
|
|
8
|
+
export declare class Mat4 {
|
|
9
|
+
elements: Float32Array;
|
|
10
|
+
constructor();
|
|
11
|
+
static identity(): Mat4;
|
|
12
|
+
static fromTranslation(v: Vec3): Mat4;
|
|
13
|
+
static fromRotation(q: Quat): Mat4;
|
|
14
|
+
static fromScale(v: Vec3): Mat4;
|
|
15
|
+
static compose(position: Vec3, rotation: Quat, scale: Vec3): Mat4;
|
|
16
|
+
multiply(m: Mat4): Mat4;
|
|
17
|
+
multiplyInPlace(m: Mat4): Mat4;
|
|
18
|
+
inverse(): Mat4 | null;
|
|
19
|
+
transpose(): Mat4;
|
|
20
|
+
decompose(): {
|
|
21
|
+
position: Vec3;
|
|
22
|
+
rotation: Quat;
|
|
23
|
+
scale: Vec3;
|
|
24
|
+
} | null;
|
|
25
|
+
transformPoint(v: Vec3): Vec3;
|
|
26
|
+
transformDirection(v: Vec3): Vec3;
|
|
27
|
+
/**
|
|
28
|
+
* Transform a vector (direction) by this matrix (ignores translation)
|
|
29
|
+
* Alias for transformDirection for compatibility
|
|
30
|
+
*/
|
|
31
|
+
transformVector(v: Vec3): Vec3;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the inverse of this matrix
|
|
34
|
+
* Returns identity matrix if singular (non-invertible)
|
|
35
|
+
*/
|
|
36
|
+
invert(): Mat4;
|
|
37
|
+
clone(): Mat4;
|
|
38
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Vec3 } from "./Vec3";
|
|
2
|
+
/**
|
|
3
|
+
* Quat - Quaternion utility class
|
|
4
|
+
* Provides quaternion operations for 3D rotations
|
|
5
|
+
*/
|
|
6
|
+
export declare class Quat {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
z: number;
|
|
10
|
+
w: number;
|
|
11
|
+
constructor(x?: number, y?: number, z?: number, w?: number);
|
|
12
|
+
static identity(): Quat;
|
|
13
|
+
/**
|
|
14
|
+
* Create quaternion from Euler angles (ZYX order)
|
|
15
|
+
* @param x - Rotation around X axis in radians
|
|
16
|
+
* @param y - Rotation around Y axis in radians
|
|
17
|
+
* @param z - Rotation around Z axis in radians
|
|
18
|
+
*/
|
|
19
|
+
static fromEuler(x: number, y: number, z: number): Quat;
|
|
20
|
+
/**
|
|
21
|
+
* Create quaternion from axis-angle representation
|
|
22
|
+
* @param axis - Rotation axis (should be normalized)
|
|
23
|
+
* @param angle - Rotation angle in radians
|
|
24
|
+
*/
|
|
25
|
+
static fromAxisAngle(axis: Vec3, angle: number): Quat;
|
|
26
|
+
/**
|
|
27
|
+
* Multiply this quaternion by another (this * q)
|
|
28
|
+
*/
|
|
29
|
+
multiply(q: Quat): Quat;
|
|
30
|
+
/**
|
|
31
|
+
* Convert quaternion to Euler angles (ZYX order)
|
|
32
|
+
*/
|
|
33
|
+
toEuler(): Vec3;
|
|
34
|
+
normalize(): Quat;
|
|
35
|
+
normalizeInPlace(): Quat;
|
|
36
|
+
/**
|
|
37
|
+
* Spherical linear interpolation between this quaternion and another
|
|
38
|
+
* @param q - Target quaternion
|
|
39
|
+
* @param t - Interpolation factor (0 to 1)
|
|
40
|
+
*/
|
|
41
|
+
slerp(q: Quat, t: number): Quat;
|
|
42
|
+
clone(): Quat;
|
|
43
|
+
/**
|
|
44
|
+
* Get the inverse (conjugate for unit quaternions) of this quaternion
|
|
45
|
+
*/
|
|
46
|
+
inverse(): Quat;
|
|
47
|
+
/**
|
|
48
|
+
* Transform a vector by this quaternion
|
|
49
|
+
* @param v - Vector to transform
|
|
50
|
+
*/
|
|
51
|
+
transformVector(v: Vec3): Vec3;
|
|
52
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Vec3 } from "./Vec3";
|
|
2
|
+
import { Camera } from "../Camera";
|
|
3
|
+
/**
|
|
4
|
+
* Ray - Ray utility class
|
|
5
|
+
* Provides ray operations for 3D picking and intersection tests
|
|
6
|
+
*/
|
|
7
|
+
export declare class Ray {
|
|
8
|
+
origin: Vec3;
|
|
9
|
+
direction: Vec3;
|
|
10
|
+
constructor(origin: Vec3, direction: Vec3);
|
|
11
|
+
/**
|
|
12
|
+
* Create a ray from screen coordinates
|
|
13
|
+
* @param screenX - Screen X coordinate (0 to canvasWidth)
|
|
14
|
+
* @param screenY - Screen Y coordinate (0 to canvasHeight)
|
|
15
|
+
* @param canvasWidth - Canvas width in pixels
|
|
16
|
+
* @param canvasHeight - Canvas height in pixels
|
|
17
|
+
* @param camera - Camera instance
|
|
18
|
+
*/
|
|
19
|
+
static fromScreenPoint(screenX: number, screenY: number, canvasWidth: number, canvasHeight: number, camera: Camera): Ray;
|
|
20
|
+
/**
|
|
21
|
+
* Get point at distance along ray
|
|
22
|
+
* @param distance - Distance along ray
|
|
23
|
+
*/
|
|
24
|
+
at(distance: number): Vec3;
|
|
25
|
+
/**
|
|
26
|
+
* Intersect ray with plane
|
|
27
|
+
* @param planeOrigin - Point on the plane
|
|
28
|
+
* @param planeNormal - Normal vector of the plane (should be normalized)
|
|
29
|
+
* @returns Distance along ray to intersection, or null if parallel/no intersection
|
|
30
|
+
*/
|
|
31
|
+
intersectPlane(planeOrigin: Vec3, planeNormal: Vec3): number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Compute distance from ray to a point
|
|
34
|
+
* @param point - Point in 3D space
|
|
35
|
+
*/
|
|
36
|
+
distanceToPoint(point: Vec3): number;
|
|
37
|
+
/**
|
|
38
|
+
* Compute distance from ray to a line segment (for capsule hit testing)
|
|
39
|
+
* @param segmentStart - Start point of line segment
|
|
40
|
+
* @param segmentEnd - End point of line segment
|
|
41
|
+
*/
|
|
42
|
+
distanceToSegment(segmentStart: Vec3, segmentEnd: Vec3): number;
|
|
43
|
+
/**
|
|
44
|
+
* Clone this ray
|
|
45
|
+
*/
|
|
46
|
+
clone(): Ray;
|
|
47
|
+
/**
|
|
48
|
+
* Transform ray by a matrix
|
|
49
|
+
* @param matrix - Transformation matrix
|
|
50
|
+
*/
|
|
51
|
+
transform(matrix: {
|
|
52
|
+
transformPoint(v: Vec3): Vec3;
|
|
53
|
+
transformVector(v: Vec3): Vec3;
|
|
54
|
+
}): Ray;
|
|
55
|
+
/**
|
|
56
|
+
* Intersect ray with triangle using Möller–Trumbore algorithm
|
|
57
|
+
* @param v0 - First vertex of triangle
|
|
58
|
+
* @param v1 - Second vertex of triangle
|
|
59
|
+
* @param v2 - Third vertex of triangle
|
|
60
|
+
* @returns Distance to intersection, or null if no intersection
|
|
61
|
+
*/
|
|
62
|
+
intersectTriangle(v0: Vec3, v1: Vec3, v2: Vec3): number | null;
|
|
63
|
+
private static invertMatrix;
|
|
64
|
+
private static transformPoint;
|
|
65
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vec3 - 3D Vector utility class
|
|
3
|
+
* Provides vector operations for 3D mathematics
|
|
4
|
+
*/
|
|
5
|
+
export declare class Vec3 {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
z: number;
|
|
9
|
+
constructor(x?: number, y?: number, z?: number);
|
|
10
|
+
static fromArray(arr: Float32Array | number[], offset?: number): Vec3;
|
|
11
|
+
static zero(): Vec3;
|
|
12
|
+
static one(): Vec3;
|
|
13
|
+
add(v: Vec3): Vec3;
|
|
14
|
+
subtract(v: Vec3): Vec3;
|
|
15
|
+
multiply(scalar: number): Vec3;
|
|
16
|
+
divide(scalar: number): Vec3;
|
|
17
|
+
addInPlace(v: Vec3): Vec3;
|
|
18
|
+
subtractInPlace(v: Vec3): Vec3;
|
|
19
|
+
multiplyInPlace(scalar: number): Vec3;
|
|
20
|
+
dot(v: Vec3): number;
|
|
21
|
+
cross(v: Vec3): Vec3;
|
|
22
|
+
length(): number;
|
|
23
|
+
lengthSquared(): number;
|
|
24
|
+
distance(v: Vec3): number;
|
|
25
|
+
distanceSquared(v: Vec3): number;
|
|
26
|
+
normalize(): Vec3;
|
|
27
|
+
normalizeInPlace(): Vec3;
|
|
28
|
+
clone(): Vec3;
|
|
29
|
+
toArray(): [number, number, number];
|
|
30
|
+
set(x: number, y: number, z: number): Vec3;
|
|
31
|
+
/**
|
|
32
|
+
* Check if this vector equals another vector
|
|
33
|
+
*/
|
|
34
|
+
equals(v: Vec3): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if this vector approximately equals another vector
|
|
37
|
+
*/
|
|
38
|
+
equalsApprox(v: Vec3, epsilon?: number): boolean;
|
|
39
|
+
}
|