@galacean/effects-plugin-model 0.0.1-alpha.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 +26 -0
- package/dist/gesture/controller.d.ts +95 -0
- package/dist/gesture/index.d.ts +38 -0
- package/dist/gesture/protocol.d.ts +143 -0
- package/dist/gltf/index.d.ts +3 -0
- package/dist/gltf/loader-ext.d.ts +53 -0
- package/dist/gltf/loader-helper.d.ts +18 -0
- package/dist/gltf/loader-impl.d.ts +84 -0
- package/dist/gltf/protocol.d.ts +90 -0
- package/dist/helper/index.d.ts +2 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +16137 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +9 -0
- package/dist/index.min.js.map +1 -0
- package/dist/index.mjs +16048 -0
- package/dist/index.mjs.map +1 -0
- package/dist/loader.d.ts +2 -0
- package/dist/loader.mjs +12040 -0
- package/dist/loader.mjs.map +1 -0
- package/dist/math/box3.d.ts +140 -0
- package/dist/math/euler.d.ts +139 -0
- package/dist/math/index.d.ts +11 -0
- package/dist/math/matrix2.d.ts +58 -0
- package/dist/math/matrix3.d.ts +113 -0
- package/dist/math/matrix4.d.ts +264 -0
- package/dist/math/quaternion.d.ts +214 -0
- package/dist/math/sphere.d.ts +81 -0
- package/dist/math/type.d.ts +29 -0
- package/dist/math/utilities/index.d.ts +9 -0
- package/dist/math/vector2.d.ts +394 -0
- package/dist/math/vector3.d.ts +164 -0
- package/dist/math/vector4.d.ts +132 -0
- package/dist/plugin/const.d.ts +2 -0
- package/dist/plugin/index.d.ts +6 -0
- package/dist/plugin/model-plugin.d.ts +48 -0
- package/dist/plugin/model-tree-item.d.ts +30 -0
- package/dist/plugin/model-tree-plugin.d.ts +13 -0
- package/dist/plugin/model-tree-vfx-item.d.ts +15 -0
- package/dist/plugin/model-vfx-item.d.ts +25 -0
- package/dist/runtime/anim-sampler.d.ts +13 -0
- package/dist/runtime/animation.d.ts +189 -0
- package/dist/runtime/cache.d.ts +34 -0
- package/dist/runtime/camera.d.ts +43 -0
- package/dist/runtime/common.d.ts +113 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/light.d.ts +34 -0
- package/dist/runtime/material.d.ts +101 -0
- package/dist/runtime/mesh.d.ts +145 -0
- package/dist/runtime/object.d.ts +44 -0
- package/dist/runtime/scene.d.ts +131 -0
- package/dist/runtime/shader-libs/standard-shader-source.d.ts +3 -0
- package/dist/runtime/shader-libs/standard-shader.d.ts +6 -0
- package/dist/runtime/shader.d.ts +18 -0
- package/dist/runtime/shadow.d.ts +227 -0
- package/dist/runtime/skybox.d.ts +91 -0
- package/dist/utility/debug-helper.d.ts +7 -0
- package/dist/utility/hit-test-helper.d.ts +9 -0
- package/dist/utility/index.d.ts +6 -0
- package/dist/utility/plugin-helper.d.ts +197 -0
- package/dist/utility/ri-helper.d.ts +25 -0
- package/dist/utility/shader-helper.d.ts +13 -0
- package/dist/utility/ts-helper.d.ts +34 -0
- package/package.json +56 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { Vector3 } from './vector3';
|
|
2
|
+
import { Vector4 } from './vector4';
|
|
3
|
+
import { Matrix3 } from './matrix3';
|
|
4
|
+
import { Quaternion } from './quaternion';
|
|
5
|
+
import type { Mat4DataType } from './type';
|
|
6
|
+
/**
|
|
7
|
+
* 表示一个 4x4 矩阵
|
|
8
|
+
*/
|
|
9
|
+
declare class Matrix4 {
|
|
10
|
+
private _data;
|
|
11
|
+
constructor(column0Row0?: number, column1Row0?: number, column2Row0?: number, column3Row0?: number, column0Row1?: number, column1Row1?: number, column2Row1?: number, column3Row1?: number, column0Row2?: number, column1Row2?: number, column2Row2?: number, column3Row2?: number, column0Row3?: number, column1Row3?: number, column2Row3?: number, column3Row3?: number);
|
|
12
|
+
/**
|
|
13
|
+
* 获取矩阵内部存储数据的Float32Array对象。
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
getData(): Float32Array;
|
|
17
|
+
setData(data: Float32Array): void;
|
|
18
|
+
get data(): Float32Array;
|
|
19
|
+
lookAt(position: Vector3, target: Vector3, up: Vector3): Matrix4;
|
|
20
|
+
perspective(fovY: number, aspect: number, near: number, far: number, reverse: boolean): Matrix4;
|
|
21
|
+
orth2d(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4;
|
|
22
|
+
compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4;
|
|
23
|
+
decompose(): {
|
|
24
|
+
translation: Vector3;
|
|
25
|
+
rotation: Quaternion;
|
|
26
|
+
scale: Vector3;
|
|
27
|
+
};
|
|
28
|
+
multiplyByPoint3(result: Vector3): Vector3;
|
|
29
|
+
setZero(): void;
|
|
30
|
+
setIdentity(): void;
|
|
31
|
+
/**
|
|
32
|
+
* 打包矩阵数据,将矩阵内部数据从数组指定索引位置打包到数组中。
|
|
33
|
+
* @param value
|
|
34
|
+
* @param array
|
|
35
|
+
* @param startingIndex
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
static pack(value: Matrix4, array: Mat4DataType, startingIndex?: number): Mat4DataType;
|
|
39
|
+
/**
|
|
40
|
+
* 解包矩阵数据,从数组指定索引位置开始解包矩阵数据。
|
|
41
|
+
* @param array
|
|
42
|
+
* @param startingIndex
|
|
43
|
+
* @param result
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
static unpack(array: Mat4DataType, startingIndex: number, result: Matrix4): Matrix4;
|
|
47
|
+
static packArray(array: Matrix4[], result: Mat4DataType): Mat4DataType;
|
|
48
|
+
static unpackArray(array: Mat4DataType, result: Matrix4[]): Matrix4[];
|
|
49
|
+
static clone(matrix: Matrix4 | Readonly<Matrix4>): Matrix4;
|
|
50
|
+
static copyTo(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
51
|
+
static fromArray(array: Mat4DataType): Matrix4;
|
|
52
|
+
static fromColumnMajorArray(values: Mat4DataType, result: Matrix4): Matrix4;
|
|
53
|
+
static fromRowMajorArray(values: Mat4DataType, result: Matrix4): Matrix4;
|
|
54
|
+
static fromRotationTranslation(rotation: Matrix3 | Readonly<Matrix3>, translation: Vector3, result: Matrix4): Matrix4;
|
|
55
|
+
static fromTranslationQuaternionRotationScale(translation: Vector3, rotation: Quaternion, scale: Vector3, result: Matrix4): Matrix4;
|
|
56
|
+
static fromTranslationRotationScale(translationRotationScale: {
|
|
57
|
+
translation: Vector3;
|
|
58
|
+
rotation: Quaternion;
|
|
59
|
+
scale: Vector3;
|
|
60
|
+
}, result: Matrix4): Matrix4;
|
|
61
|
+
static fromTranslation(translation: Vector3, result: Matrix4): Matrix4;
|
|
62
|
+
static fromScale(scale: Vector3, result: Matrix4): Matrix4;
|
|
63
|
+
static fromUniformScale(scale: number, result: Matrix4): Matrix4;
|
|
64
|
+
static fromRotation(rotation: Matrix3, result: Matrix4): Matrix4;
|
|
65
|
+
static fromCamera(camera: {
|
|
66
|
+
position: Vector3;
|
|
67
|
+
direction: Vector3;
|
|
68
|
+
up: Vector3;
|
|
69
|
+
}, result: Matrix4): Matrix4;
|
|
70
|
+
static computePerspectiveFieldOfView(fov: number, aspectRatio: number, near: number, far: number, reverse: boolean, result: Matrix4): Matrix4;
|
|
71
|
+
static computeOrthographicOffCenter(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4): Matrix4;
|
|
72
|
+
static computePerspectiveOffCenter(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4): Matrix4;
|
|
73
|
+
static computeInfinitePerspectiveOffCenter(left: number, right: number, bottom: number, top: number, near: number, result: Matrix4): Matrix4;
|
|
74
|
+
static computeViewportTransformation(viewport: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
}, nearDepthRange: number, farDepthRange: number, result: Matrix4): Matrix4;
|
|
80
|
+
static computeView(position: Vector3, direction: Vector3, up: Vector3, right: Vector3, result: Matrix4): Matrix4;
|
|
81
|
+
static toArray(matrix: Matrix4, result: Mat4DataType): Mat4DataType;
|
|
82
|
+
static getElement(matrix: Matrix4, column: number, row: number): number;
|
|
83
|
+
static getColumn(matrix: Matrix4, index: number, result: Vector4): Vector4;
|
|
84
|
+
static setColumn(matrix: Matrix4, index: number, cartesian: Vector4, result: Matrix4): Matrix4;
|
|
85
|
+
static getRow(matrix: Matrix4, index: number, result: Vector4): Vector4;
|
|
86
|
+
static setRow(matrix: Matrix4, index: number, cartesian: Vector4, result: Matrix4): Matrix4;
|
|
87
|
+
static setTranslation(matrix: Matrix4, translation: Vector3, result: Matrix4): Matrix4;
|
|
88
|
+
static scale(matrix: Matrix4, scale: Vector3, result: Matrix4): Matrix4;
|
|
89
|
+
static setUniformScale(matrix: Matrix4, scale: number, result: Matrix4): Matrix4;
|
|
90
|
+
static getScale(matrix: Matrix4, result: Vector3): Vector3;
|
|
91
|
+
static getMaximumScale(matrix: Matrix4): number;
|
|
92
|
+
static setRotation(matrix: Matrix4, rotation: Matrix4, result: Matrix4): Matrix4;
|
|
93
|
+
static getRotation(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
94
|
+
static getRotationMatrix3(matrix: Matrix4, result: Matrix3): Matrix3;
|
|
95
|
+
static getRotationQuaternion(matrix: Matrix4, result: Quaternion): Quaternion;
|
|
96
|
+
static multiply(leftM: Matrix4, rightM: Matrix4, result: Matrix4): Matrix4;
|
|
97
|
+
static mulScalerAddMatrix(leftM: Matrix4, rightM: Matrix4, rightS: number, result: Matrix4): Matrix4;
|
|
98
|
+
static add(left: Matrix4, right: Matrix4, result: Matrix4): Matrix4;
|
|
99
|
+
static subtract(left: Matrix4, right: Matrix4, result: Matrix4): Matrix4;
|
|
100
|
+
static multiplyTransformation(leftM: Matrix4, rightM: Matrix4, result: Matrix4): Matrix4;
|
|
101
|
+
static multiplyByMatrix3(matrix: Matrix4, rotation: Matrix3, result: Matrix4): Matrix4;
|
|
102
|
+
static multiplyByTranslation(matrix: Matrix4, translation: Vector3, result: Matrix4): Matrix4;
|
|
103
|
+
static multiplyByScale(matrix: Matrix4, scale: Vector3, result: Matrix4): Matrix4;
|
|
104
|
+
static multiplyByUniformScale(matrix: Matrix4, scale: number, result: Matrix4): Matrix4;
|
|
105
|
+
static multiplyByVector(matrix: Matrix4, cartesian: Vector4, result: Vector4): Vector4;
|
|
106
|
+
static multiplyByPointAsVector(matrix: Matrix4, cartesian: Vector3, result: Vector3): Vector3;
|
|
107
|
+
/**
|
|
108
|
+
* 矩阵与三维点/向量相乘,三维点/向量第四个分量 W 为 1 处理
|
|
109
|
+
* @param matrix
|
|
110
|
+
* @param cartesian
|
|
111
|
+
* @param result
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
static multiplyByPoint(matrix: Matrix4, cartesian: Vector3, result: Vector3): Vector3;
|
|
115
|
+
static multiplyByScalar(matrix: Matrix4, scalar: number, result: Matrix4): Matrix4;
|
|
116
|
+
static negate(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
117
|
+
static transpose(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
118
|
+
static abs(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
119
|
+
static equals(left: Matrix4, right: Matrix4): boolean;
|
|
120
|
+
static equalsEpsilon(left: Matrix4, right: Matrix4, epsilon: number): boolean;
|
|
121
|
+
static getTranslation(matrix: Matrix4, result: Vector3): Vector3;
|
|
122
|
+
static getMatrix3(matrix: Matrix4, result: Matrix3): Matrix3;
|
|
123
|
+
static inverse(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
124
|
+
static inverseTransformation(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
125
|
+
static inverseTranspose(matrix: Matrix4, result: Matrix4): Matrix4;
|
|
126
|
+
static equalsArray(matrix: Matrix4, array: Mat4DataType, offset?: number): boolean;
|
|
127
|
+
determinant(): number;
|
|
128
|
+
/**
|
|
129
|
+
* 分解矩阵,将矩阵分解为平移、旋转、缩放三部分
|
|
130
|
+
* @param m - 待分解的矩阵
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
static decompose(m: Matrix4): {
|
|
134
|
+
translation: Vector3;
|
|
135
|
+
rotation: Quaternion;
|
|
136
|
+
scale: Vector3;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* 从平移、旋转、缩放合成一个新变换矩阵
|
|
140
|
+
* @param translation - 平移向量
|
|
141
|
+
* @param rotation - 旋转量,使用四元数表示
|
|
142
|
+
* @param scale - 缩放向量
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
static compose(translation: Vector3, rotation: Quaternion, scale: Vector3, result: Matrix4): Matrix4;
|
|
146
|
+
/**
|
|
147
|
+
* 计算透视投影矩阵
|
|
148
|
+
* @param fovY
|
|
149
|
+
* @param aspect
|
|
150
|
+
* @param near
|
|
151
|
+
* @param far
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
static computePerspective(fovY: number, aspect: number, near: number, far: number, reverse: boolean, result: Matrix4): Matrix4;
|
|
155
|
+
/**
|
|
156
|
+
* 计算正交投影矩阵
|
|
157
|
+
* @param left
|
|
158
|
+
* @param right
|
|
159
|
+
* @param bottom
|
|
160
|
+
* @param top
|
|
161
|
+
* @param near
|
|
162
|
+
* @param far
|
|
163
|
+
* @param result
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
static computeOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4): Matrix4;
|
|
167
|
+
/**
|
|
168
|
+
* 通过 LookAt 参数计算相机的视图矩阵
|
|
169
|
+
* @param position
|
|
170
|
+
* @param target
|
|
171
|
+
* @param up
|
|
172
|
+
* @param result
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
static computeLookAt(position: Vector3, target: Vector3, up: Vector3, result: Matrix4): Matrix4;
|
|
176
|
+
/**
|
|
177
|
+
* 使用矩阵内部数据构造一个新矩阵
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
clone(): Matrix4;
|
|
181
|
+
/**
|
|
182
|
+
* 将矩阵数据拷贝到 result 中
|
|
183
|
+
* @param result
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
copyTo(result: Matrix4): Matrix4;
|
|
187
|
+
/**
|
|
188
|
+
* 将矩阵数据从 source 拷贝回来
|
|
189
|
+
* @param source
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
copyFrom(source: Matrix4): this;
|
|
193
|
+
/**
|
|
194
|
+
* 平移矩阵,相当于该矩阵与使用 vector 构造的平移矩阵相乘
|
|
195
|
+
* @param vector
|
|
196
|
+
* @returns 🎯计算结果将保存在调用矩阵中,并作为函数返回值返回。
|
|
197
|
+
*/
|
|
198
|
+
translate(vector: Vector3): Matrix4;
|
|
199
|
+
/**
|
|
200
|
+
* 使用 vector 缩放矩阵,相当于该矩阵与使用 vector 构造的缩放矩阵相乘。
|
|
201
|
+
* @param vector
|
|
202
|
+
* @returns 🎯计算结果将保存在调用矩阵中,并作为函数返回值返回。
|
|
203
|
+
*/
|
|
204
|
+
scale(vector: Vector3): Matrix4;
|
|
205
|
+
/**
|
|
206
|
+
* 计算矩阵与输入矩阵相乘的结果。
|
|
207
|
+
* @param matrix
|
|
208
|
+
* @returns 🎯计算结果将保存在调用矩阵中,并作为函数返回值返回。
|
|
209
|
+
*/
|
|
210
|
+
multiply(matrix: Matrix4): Matrix4;
|
|
211
|
+
/**
|
|
212
|
+
* 将矩阵数据按照列主序导出为 number[] 对象。
|
|
213
|
+
* @returns
|
|
214
|
+
*/
|
|
215
|
+
toArray(): number[];
|
|
216
|
+
/**
|
|
217
|
+
* 将矩阵按照列主序方式导出为 Float32Array 对象。
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
toFloat32Array(): Float32Array;
|
|
221
|
+
/**
|
|
222
|
+
* 矩阵与四维向量相乘。
|
|
223
|
+
* @param vector
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
multiplyByVector4(vector: Vector4): Vector4;
|
|
227
|
+
/**
|
|
228
|
+
* 矩阵与三维向量相乘,内部将三维向量第四个分量当作 1 来处理。
|
|
229
|
+
* @param vector
|
|
230
|
+
* @returns
|
|
231
|
+
*/
|
|
232
|
+
multiplyByVector3(vector: Vector3): Vector3;
|
|
233
|
+
/**
|
|
234
|
+
* 返回矩阵中指定索引位置数据
|
|
235
|
+
* @param index
|
|
236
|
+
* @returns
|
|
237
|
+
*/
|
|
238
|
+
at(index: number): number;
|
|
239
|
+
/**
|
|
240
|
+
* 矩阵乘一个旋转矩阵,矩阵乘一个绕 axis 轴旋转 angle 角度的旋转矩阵
|
|
241
|
+
* @param angle
|
|
242
|
+
* @param axis
|
|
243
|
+
* @returns
|
|
244
|
+
*/
|
|
245
|
+
rotate(angle: number, axis: Vector3): Matrix4 | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* 计算矩阵的逆矩阵,会修改矩阵数据
|
|
248
|
+
*/
|
|
249
|
+
inverse(): Matrix4;
|
|
250
|
+
/**
|
|
251
|
+
* 计算矩阵的转置,结果保存在原矩阵中(会修改矩阵数据)
|
|
252
|
+
* @returns
|
|
253
|
+
*/
|
|
254
|
+
transpose(): Matrix4;
|
|
255
|
+
/**
|
|
256
|
+
* 4x4 单位矩阵
|
|
257
|
+
*/
|
|
258
|
+
static IDENTITY: Readonly<Matrix4>;
|
|
259
|
+
/**
|
|
260
|
+
* 数据都为 0 的矩阵
|
|
261
|
+
*/
|
|
262
|
+
static ZERO: Readonly<Matrix4>;
|
|
263
|
+
}
|
|
264
|
+
export { Matrix4 };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { Matrix4 } from './matrix4';
|
|
2
|
+
import { Matrix3 } from './matrix3';
|
|
3
|
+
import type { Vec4DataType } from './type';
|
|
4
|
+
import { Vector3 } from './vector3';
|
|
5
|
+
import type { Euler } from './euler';
|
|
6
|
+
/**
|
|
7
|
+
* 使用四元数表示一个旋转
|
|
8
|
+
*/
|
|
9
|
+
declare class Quaternion {
|
|
10
|
+
private _data;
|
|
11
|
+
constructor(x?: number, y?: number, z?: number, w?: number);
|
|
12
|
+
get x(): number;
|
|
13
|
+
set x(value: number);
|
|
14
|
+
getX(): number;
|
|
15
|
+
setX(value: number): void;
|
|
16
|
+
get y(): number;
|
|
17
|
+
set y(value: number);
|
|
18
|
+
getY(): number;
|
|
19
|
+
setY(value: number): void;
|
|
20
|
+
get z(): number;
|
|
21
|
+
set z(value: number);
|
|
22
|
+
getZ(): number;
|
|
23
|
+
setZ(value: number): void;
|
|
24
|
+
get w(): number;
|
|
25
|
+
set w(value: number);
|
|
26
|
+
getW(): number;
|
|
27
|
+
setW(value: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* 构造一个四元素表示绕 axis 轴旋转 angle 角度
|
|
30
|
+
* @param axis
|
|
31
|
+
* @param angle
|
|
32
|
+
* @param result
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
static fromAxisAngle(axis: Vector3 | Readonly<Vector3>, angle: number, result: Quaternion): Quaternion;
|
|
36
|
+
/**
|
|
37
|
+
* 从旋转矩阵构造一个四元数
|
|
38
|
+
* @param matrix
|
|
39
|
+
* @param result
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
static fromRotationMatrix(matrix: Matrix3, result: Quaternion): Quaternion;
|
|
43
|
+
/**
|
|
44
|
+
* 从相机 heading、pitch、roll 构造一个四元数。heading 表示绕 z 轴旋转角度、pitch 表示绕 y 轴旋转角度、roll 表示绕 x 轴旋转角度
|
|
45
|
+
* @param headingPitchRoll
|
|
46
|
+
* @param result
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
static fromHeadingPitchRoll(headingPitchRoll: {
|
|
50
|
+
heading: number;
|
|
51
|
+
pitch: number;
|
|
52
|
+
roll: number;
|
|
53
|
+
}, result: Quaternion): Quaternion;
|
|
54
|
+
/**
|
|
55
|
+
* 将欧拉角转成四元数
|
|
56
|
+
* @param euler
|
|
57
|
+
* @param result
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
static setFromEuler(euler: Euler, result: Quaternion): Quaternion;
|
|
61
|
+
/**
|
|
62
|
+
* 四元数打包成数组
|
|
63
|
+
* @param value
|
|
64
|
+
* @param array
|
|
65
|
+
* @param startingIndex
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
static pack(value: Quaternion, array: Vec4DataType, startingIndex?: number): Vec4DataType;
|
|
69
|
+
/**
|
|
70
|
+
* 从数组中解包四元数
|
|
71
|
+
* @param array
|
|
72
|
+
* @param startingIndex
|
|
73
|
+
* @param result
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
static unpack(array: Vec4DataType, startingIndex: number, result: Quaternion): Quaternion;
|
|
77
|
+
/**
|
|
78
|
+
* 从数组构造一个四元数
|
|
79
|
+
* @param array
|
|
80
|
+
* @param startingIndex
|
|
81
|
+
* @param result
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
static fromArray(array: Vec4DataType): Quaternion;
|
|
85
|
+
/**
|
|
86
|
+
* 两个四元数相乘
|
|
87
|
+
* @param left
|
|
88
|
+
* @param right
|
|
89
|
+
* @param result
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
static multiply(left: Quaternion, right: Quaternion, result: Quaternion): Quaternion;
|
|
93
|
+
/**
|
|
94
|
+
* 从输入四元数克隆一个四元数
|
|
95
|
+
* @param quaternion
|
|
96
|
+
* @param result
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
static clone(quaternion: Quaternion | Readonly<Quaternion>): Quaternion;
|
|
100
|
+
static copyTo(quaternion: Quaternion | Readonly<Quaternion>, result: Quaternion): Quaternion;
|
|
101
|
+
/**
|
|
102
|
+
* 四元数的共轭
|
|
103
|
+
* @param quaternion
|
|
104
|
+
* @param result
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
static conjugate(quaternion: Quaternion, result: Quaternion): Quaternion;
|
|
108
|
+
/**
|
|
109
|
+
* 四元数的模的平方
|
|
110
|
+
* @param quaternion
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
static magnitudeSquared(quaternion: Quaternion): number;
|
|
114
|
+
/**
|
|
115
|
+
* 四元数的模
|
|
116
|
+
* @param quaternion
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
static magnitude(quaternion: Quaternion): number;
|
|
120
|
+
/**
|
|
121
|
+
* 单位化四元数
|
|
122
|
+
* @param quaternion
|
|
123
|
+
* @param result
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
static normalize(quaternion: Quaternion, result: Quaternion): Quaternion;
|
|
127
|
+
/**
|
|
128
|
+
* 四元数求逆
|
|
129
|
+
* @param quaternion
|
|
130
|
+
* @param result
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
static inverse(quaternion: Quaternion, result: Quaternion): Quaternion;
|
|
134
|
+
static add(left: Quaternion, right: Quaternion, result: Quaternion): Quaternion;
|
|
135
|
+
static subtract(left: Quaternion, right: Quaternion, result: Quaternion): Quaternion;
|
|
136
|
+
static negate(quaternion: Quaternion, result: Quaternion): Quaternion;
|
|
137
|
+
static dot(left: Quaternion, right: Quaternion): number;
|
|
138
|
+
static multiplyByScalar(quaternion: Quaternion, scalar: number, result: Quaternion): Quaternion;
|
|
139
|
+
static computeAxis(quaternion: Quaternion, result: Vector3): Vector3;
|
|
140
|
+
/**
|
|
141
|
+
* 计算旋转角度
|
|
142
|
+
* @param quaternion
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
static computeAngle(quaternion: Quaternion): number;
|
|
146
|
+
/**
|
|
147
|
+
* 线性插值
|
|
148
|
+
* @param start
|
|
149
|
+
* @param end
|
|
150
|
+
* @param t
|
|
151
|
+
* @param result
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
static lerp(start: Quaternion, end: Quaternion, t: number, result: Quaternion): Quaternion;
|
|
155
|
+
/**
|
|
156
|
+
* 球面线性插值
|
|
157
|
+
* @param start
|
|
158
|
+
* @param end
|
|
159
|
+
* @param t
|
|
160
|
+
* @param result
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
static slerp(start: Quaternion, end: Quaternion, t: number, result: Quaternion): Quaternion;
|
|
164
|
+
static equals(left: Quaternion, right: Quaternion): boolean;
|
|
165
|
+
static equalsEpsilon(left: Quaternion, right: Quaternion, epsilon?: number): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* 将四元数转变为一个 4x4 矩阵
|
|
168
|
+
* @param result
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
toMatrix4(result: Matrix4): Matrix4;
|
|
172
|
+
/**
|
|
173
|
+
* 使用四元数内部数据克隆出一个新的四元数
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
clone(): Quaternion;
|
|
177
|
+
/**
|
|
178
|
+
* 将四元数数据拷贝给 result
|
|
179
|
+
* @param result
|
|
180
|
+
*/
|
|
181
|
+
copyTo(result: Quaternion): Quaternion;
|
|
182
|
+
/**
|
|
183
|
+
* 将四元数数据从 source 拷贝回来
|
|
184
|
+
* @param source
|
|
185
|
+
*/
|
|
186
|
+
copyFrom(source: Quaternion): this;
|
|
187
|
+
/**
|
|
188
|
+
* 绕 x 轴旋转角度分量
|
|
189
|
+
* @returns
|
|
190
|
+
*/
|
|
191
|
+
roll(): number;
|
|
192
|
+
/**
|
|
193
|
+
* 绕 y 轴旋转分量
|
|
194
|
+
* @returns
|
|
195
|
+
*/
|
|
196
|
+
pitch(): number;
|
|
197
|
+
/**
|
|
198
|
+
* 绕 z 轴旋转分量
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
201
|
+
yaw(): number;
|
|
202
|
+
inverse(): Quaternion;
|
|
203
|
+
conjugate(): Quaternion;
|
|
204
|
+
length(): number;
|
|
205
|
+
normalize(): Quaternion;
|
|
206
|
+
add(other: Quaternion): Quaternion;
|
|
207
|
+
multiply(other: Quaternion): Quaternion;
|
|
208
|
+
set(x: number, y: number, z: number, w: number): Quaternion;
|
|
209
|
+
setFromEuler(euler: Euler): Quaternion;
|
|
210
|
+
toArray(): number[];
|
|
211
|
+
static IDENTITY: Readonly<Quaternion>;
|
|
212
|
+
static ZERO: Readonly<Quaternion>;
|
|
213
|
+
}
|
|
214
|
+
export { Quaternion };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Box3 } from './box3';
|
|
2
|
+
import { Vector3 } from './vector3';
|
|
3
|
+
/**
|
|
4
|
+
* 球体的几何表示
|
|
5
|
+
*/
|
|
6
|
+
declare class Sphere {
|
|
7
|
+
/** 球半径 */
|
|
8
|
+
radius: number;
|
|
9
|
+
/** 球中心点 */
|
|
10
|
+
center: Vector3;
|
|
11
|
+
constructor(center?: Vector3, radius?: number);
|
|
12
|
+
set(center: Vector3, radius: number): Sphere;
|
|
13
|
+
/**
|
|
14
|
+
* 从顶点数组中构造一个球
|
|
15
|
+
* @param points
|
|
16
|
+
* @param optionalCenter
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere;
|
|
20
|
+
copyFrom(sphere: Sphere): Sphere;
|
|
21
|
+
isEmpty(): boolean;
|
|
22
|
+
makeEmpty(): Sphere;
|
|
23
|
+
/**
|
|
24
|
+
* 判断点是否在球内(包含球面)
|
|
25
|
+
* @param point
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
containsPoint(point: Vector3): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 点到球的距离
|
|
31
|
+
* @param point
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
distanceToPoint(point: Vector3): number;
|
|
35
|
+
/**
|
|
36
|
+
* 判断球 this 与球 other 是否相交
|
|
37
|
+
* @param other
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
intersectsSphere(other: Sphere): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 判断球与包围盒是否相交
|
|
43
|
+
* @param box
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
intersectsBox(box: Box3): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 限制点只能取球内值
|
|
49
|
+
* @param point
|
|
50
|
+
* @param target
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
clampPoint(point: Vector3, target: Vector3): Vector3;
|
|
54
|
+
/**
|
|
55
|
+
* 获取球体的包围盒
|
|
56
|
+
* @param target
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
getBoundingBox(target: Box3): Box3;
|
|
60
|
+
/**
|
|
61
|
+
* 球的三维空间平移
|
|
62
|
+
* @param offset
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
translate(offset: Vector3): Sphere;
|
|
66
|
+
/**
|
|
67
|
+
* 通过空间点扩展/缩放球
|
|
68
|
+
* @param offset
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
expandByPoint(point: Vector3): Sphere;
|
|
72
|
+
/**
|
|
73
|
+
* 球的并集
|
|
74
|
+
* @param offset
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
union(sphere: Sphere): Sphere;
|
|
78
|
+
equals(sphere: Sphere): boolean;
|
|
79
|
+
clone(): Sphere;
|
|
80
|
+
}
|
|
81
|
+
export { Sphere };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 二维向量内部数据类型
|
|
3
|
+
*/
|
|
4
|
+
type Vec2DataType = number[] | [number, number] | Float32Array;
|
|
5
|
+
/**
|
|
6
|
+
* 三维向量内部数据类型
|
|
7
|
+
*/
|
|
8
|
+
type Vec3DataType = number[] | [number, number, number] | Float32Array;
|
|
9
|
+
/**
|
|
10
|
+
* 四维向量内部数据类型
|
|
11
|
+
*/
|
|
12
|
+
type Vec4DataType = number[] | [number, number, number, number] | Float32Array;
|
|
13
|
+
/**
|
|
14
|
+
* 二维矩阵内部数据类型
|
|
15
|
+
*/
|
|
16
|
+
type Mat2DataType = number[] | [number, number, number, number] | Float32Array;
|
|
17
|
+
/**
|
|
18
|
+
* 三维矩阵内部数据类型
|
|
19
|
+
*/
|
|
20
|
+
type Mat3DataType = number[] | [number, number, number, number, number, number, number, number, number] | Float32Array;
|
|
21
|
+
/**
|
|
22
|
+
* 四维矩阵内部数据类型
|
|
23
|
+
*/
|
|
24
|
+
type Mat4DataType = number[] | [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number] | Float32Array;
|
|
25
|
+
/**
|
|
26
|
+
* 四元数内部数据类型
|
|
27
|
+
*/
|
|
28
|
+
type QuatDataType = number[] | [number, number, number, number] | Float32Array;
|
|
29
|
+
export { Vec2DataType, Vec3DataType, Vec4DataType, Mat2DataType, Mat3DataType, Mat4DataType, QuatDataType, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare class MathUtils {
|
|
2
|
+
static EPSILON6: number;
|
|
3
|
+
static EPSILON7: number;
|
|
4
|
+
static EPSILON21: number;
|
|
5
|
+
static acosClamped(value: number): number;
|
|
6
|
+
static clamp(value: number, min: number, max: number): number;
|
|
7
|
+
static equalsEpsilon(left: number, right: number, relativeEpsilon: number, absoluteEpsilon: number): boolean;
|
|
8
|
+
}
|
|
9
|
+
export { MathUtils };
|