@esengine/ecs-framework-math 1.0.2 → 1.0.5
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/index.cjs +2 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +1968 -0
- package/index.mjs +2 -0
- package/index.mjs.map +1 -0
- package/index.umd.js +2 -0
- package/index.umd.js.map +1 -0
- package/package.json +27 -43
- package/bin/Animation/Easing.d.ts +0 -244
- package/bin/Animation/Easing.d.ts.map +0 -1
- package/bin/Animation/Easing.js +0 -407
- package/bin/Animation/Easing.js.map +0 -1
- package/bin/Animation/Interpolation.d.ts +0 -172
- package/bin/Animation/Interpolation.d.ts.map +0 -1
- package/bin/Animation/Interpolation.js +0 -327
- package/bin/Animation/Interpolation.js.map +0 -1
- package/bin/Animation/index.d.ts +0 -8
- package/bin/Animation/index.d.ts.map +0 -1
- package/bin/Animation/index.js +0 -8
- package/bin/Animation/index.js.map +0 -1
- package/bin/Circle.d.ts +0 -277
- package/bin/Circle.d.ts.map +0 -1
- package/bin/Circle.js +0 -496
- package/bin/Circle.js.map +0 -1
- package/bin/Collision/CollisionDetector.d.ts +0 -114
- package/bin/Collision/CollisionDetector.d.ts.map +0 -1
- package/bin/Collision/CollisionDetector.js +0 -353
- package/bin/Collision/CollisionDetector.js.map +0 -1
- package/bin/Collision/index.d.ts +0 -7
- package/bin/Collision/index.d.ts.map +0 -1
- package/bin/Collision/index.js +0 -7
- package/bin/Collision/index.js.map +0 -1
- package/bin/MathUtils.d.ts +0 -312
- package/bin/MathUtils.d.ts.map +0 -1
- package/bin/MathUtils.js +0 -500
- package/bin/MathUtils.js.map +0 -1
- package/bin/Matrix3.d.ts +0 -269
- package/bin/Matrix3.d.ts.map +0 -1
- package/bin/Matrix3.js +0 -514
- package/bin/Matrix3.js.map +0 -1
- package/bin/Rectangle.d.ts +0 -266
- package/bin/Rectangle.d.ts.map +0 -1
- package/bin/Rectangle.js +0 -437
- package/bin/Rectangle.js.map +0 -1
- package/bin/Vector2.d.ts +0 -317
- package/bin/Vector2.d.ts.map +0 -1
- package/bin/Vector2.js +0 -474
- package/bin/Vector2.js.map +0 -1
- package/bin/index.d.ts +0 -17
- package/bin/index.d.ts.map +0 -1
- package/bin/index.js +0 -21
- package/bin/index.js.map +0 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,1968 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @esengine/ecs-framework-math v1.0.5
|
|
3
|
+
* TypeScript definitions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 2D向量类
|
|
7
|
+
*
|
|
8
|
+
* 提供完整的2D向量运算功能,包括:
|
|
9
|
+
* - 基础运算(加减乘除)
|
|
10
|
+
* - 向量运算(点积、叉积、归一化)
|
|
11
|
+
* - 几何运算(距离、角度、投影)
|
|
12
|
+
* - 变换操作(旋转、反射、插值)
|
|
13
|
+
*/
|
|
14
|
+
declare class Vector2 {
|
|
15
|
+
/** X分量 */
|
|
16
|
+
x: number;
|
|
17
|
+
/** Y分量 */
|
|
18
|
+
y: number;
|
|
19
|
+
/**
|
|
20
|
+
* 创建2D向量
|
|
21
|
+
* @param x X分量,默认为0
|
|
22
|
+
* @param y Y分量,默认为0
|
|
23
|
+
*/
|
|
24
|
+
constructor(x?: number, y?: number);
|
|
25
|
+
/** 零向量 (0, 0) */
|
|
26
|
+
static readonly ZERO: Vector2;
|
|
27
|
+
/** 单位向量 (1, 1) */
|
|
28
|
+
static readonly ONE: Vector2;
|
|
29
|
+
/** 右方向向量 (1, 0) */
|
|
30
|
+
static readonly RIGHT: Vector2;
|
|
31
|
+
/** 左方向向量 (-1, 0) */
|
|
32
|
+
static readonly LEFT: Vector2;
|
|
33
|
+
/** 上方向向量 (0, 1) */
|
|
34
|
+
static readonly UP: Vector2;
|
|
35
|
+
/** 下方向向量 (0, -1) */
|
|
36
|
+
static readonly DOWN: Vector2;
|
|
37
|
+
/**
|
|
38
|
+
* 获取向量长度(模)
|
|
39
|
+
*/
|
|
40
|
+
get length(): number;
|
|
41
|
+
/**
|
|
42
|
+
* 获取向量长度的平方
|
|
43
|
+
*/
|
|
44
|
+
get lengthSquared(): number;
|
|
45
|
+
/**
|
|
46
|
+
* 获取向量角度(弧度)
|
|
47
|
+
*/
|
|
48
|
+
get angle(): number;
|
|
49
|
+
/**
|
|
50
|
+
* 检查是否为零向量
|
|
51
|
+
*/
|
|
52
|
+
get isZero(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 检查是否为单位向量
|
|
55
|
+
*/
|
|
56
|
+
get isUnit(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 设置向量分量
|
|
59
|
+
* @param x X分量
|
|
60
|
+
* @param y Y分量
|
|
61
|
+
* @returns 当前向量实例(链式调用)
|
|
62
|
+
*/
|
|
63
|
+
set(x: number, y: number): this;
|
|
64
|
+
/**
|
|
65
|
+
* 复制另一个向量的值
|
|
66
|
+
* @param other 源向量
|
|
67
|
+
* @returns 当前向量实例(链式调用)
|
|
68
|
+
*/
|
|
69
|
+
copy(other: Vector2): this;
|
|
70
|
+
/**
|
|
71
|
+
* 克隆当前向量
|
|
72
|
+
* @returns 新的向量实例
|
|
73
|
+
*/
|
|
74
|
+
clone(): Vector2;
|
|
75
|
+
/**
|
|
76
|
+
* 向量加法
|
|
77
|
+
* @param other 另一个向量
|
|
78
|
+
* @returns 当前向量实例(链式调用)
|
|
79
|
+
*/
|
|
80
|
+
add(other: Vector2): this;
|
|
81
|
+
/**
|
|
82
|
+
* 向量减法
|
|
83
|
+
* @param other 另一个向量
|
|
84
|
+
* @returns 当前向量实例(链式调用)
|
|
85
|
+
*/
|
|
86
|
+
subtract(other: Vector2): this;
|
|
87
|
+
/**
|
|
88
|
+
* 向量数乘
|
|
89
|
+
* @param scalar 标量
|
|
90
|
+
* @returns 当前向量实例(链式调用)
|
|
91
|
+
*/
|
|
92
|
+
multiply(scalar: number): this;
|
|
93
|
+
/**
|
|
94
|
+
* 向量数除
|
|
95
|
+
* @param scalar 标量
|
|
96
|
+
* @returns 当前向量实例(链式调用)
|
|
97
|
+
*/
|
|
98
|
+
divide(scalar: number): this;
|
|
99
|
+
/**
|
|
100
|
+
* 向量取反
|
|
101
|
+
* @returns 当前向量实例(链式调用)
|
|
102
|
+
*/
|
|
103
|
+
negate(): this;
|
|
104
|
+
/**
|
|
105
|
+
* 计算与另一个向量的点积
|
|
106
|
+
* @param other 另一个向量
|
|
107
|
+
* @returns 点积值
|
|
108
|
+
*/
|
|
109
|
+
dot(other: Vector2): number;
|
|
110
|
+
/**
|
|
111
|
+
* 计算与另一个向量的叉积(2D中返回标量)
|
|
112
|
+
* @param other 另一个向量
|
|
113
|
+
* @returns 叉积值
|
|
114
|
+
*/
|
|
115
|
+
cross(other: Vector2): number;
|
|
116
|
+
/**
|
|
117
|
+
* 向量归一化(转换为单位向量)
|
|
118
|
+
* @returns 当前向量实例(链式调用)
|
|
119
|
+
*/
|
|
120
|
+
normalize(): this;
|
|
121
|
+
/**
|
|
122
|
+
* 获取归一化后的向量(不修改原向量)
|
|
123
|
+
* @returns 新的单位向量
|
|
124
|
+
*/
|
|
125
|
+
normalized(): Vector2;
|
|
126
|
+
/**
|
|
127
|
+
* 计算到另一个向量的距离
|
|
128
|
+
* @param other 另一个向量
|
|
129
|
+
* @returns 距离值
|
|
130
|
+
*/
|
|
131
|
+
distanceTo(other: Vector2): number;
|
|
132
|
+
/**
|
|
133
|
+
* 计算到另一个向量的距离平方
|
|
134
|
+
* @param other 另一个向量
|
|
135
|
+
* @returns 距离平方值
|
|
136
|
+
*/
|
|
137
|
+
distanceToSquared(other: Vector2): number;
|
|
138
|
+
/**
|
|
139
|
+
* 计算与另一个向量的夹角(弧度)
|
|
140
|
+
* @param other 另一个向量
|
|
141
|
+
* @returns 夹角(0到π)
|
|
142
|
+
*/
|
|
143
|
+
angleTo(other: Vector2): number;
|
|
144
|
+
/**
|
|
145
|
+
* 计算向量在另一个向量上的投影
|
|
146
|
+
* @param onto 投影目标向量
|
|
147
|
+
* @returns 新的投影向量
|
|
148
|
+
*/
|
|
149
|
+
projectOnto(onto: Vector2): Vector2;
|
|
150
|
+
/**
|
|
151
|
+
* 计算向量在另一个向量上的投影长度
|
|
152
|
+
* @param onto 投影目标向量
|
|
153
|
+
* @returns 投影长度(带符号)
|
|
154
|
+
*/
|
|
155
|
+
projectOntoLength(onto: Vector2): number;
|
|
156
|
+
/**
|
|
157
|
+
* 获取垂直向量(逆时针旋转90度)
|
|
158
|
+
* @returns 新的垂直向量
|
|
159
|
+
*/
|
|
160
|
+
perpendicular(): Vector2;
|
|
161
|
+
/**
|
|
162
|
+
* 向量旋转
|
|
163
|
+
* @param angle 旋转角度(弧度)
|
|
164
|
+
* @returns 当前向量实例(链式调用)
|
|
165
|
+
*/
|
|
166
|
+
rotate(angle: number): this;
|
|
167
|
+
/**
|
|
168
|
+
* 获取旋转后的向量(不修改原向量)
|
|
169
|
+
* @param angle 旋转角度(弧度)
|
|
170
|
+
* @returns 新的旋转后向量
|
|
171
|
+
*/
|
|
172
|
+
rotated(angle: number): Vector2;
|
|
173
|
+
/**
|
|
174
|
+
* 围绕一个点旋转
|
|
175
|
+
* @param center 旋转中心点
|
|
176
|
+
* @param angle 旋转角度(弧度)
|
|
177
|
+
* @returns 当前向量实例(链式调用)
|
|
178
|
+
*/
|
|
179
|
+
rotateAround(center: Vector2, angle: number): this;
|
|
180
|
+
/**
|
|
181
|
+
* 反射向量(关于法线)
|
|
182
|
+
* @param normal 法线向量(应为单位向量)
|
|
183
|
+
* @returns 当前向量实例(链式调用)
|
|
184
|
+
*/
|
|
185
|
+
reflect(normal: Vector2): this;
|
|
186
|
+
/**
|
|
187
|
+
* 获取反射后的向量(不修改原向量)
|
|
188
|
+
* @param normal 法线向量(应为单位向量)
|
|
189
|
+
* @returns 新的反射向量
|
|
190
|
+
*/
|
|
191
|
+
reflected(normal: Vector2): Vector2;
|
|
192
|
+
/**
|
|
193
|
+
* 线性插值
|
|
194
|
+
* @param target 目标向量
|
|
195
|
+
* @param t 插值参数(0到1)
|
|
196
|
+
* @returns 当前向量实例(链式调用)
|
|
197
|
+
*/
|
|
198
|
+
lerp(target: Vector2, t: number): this;
|
|
199
|
+
/**
|
|
200
|
+
* 限制向量长度
|
|
201
|
+
* @param maxLength 最大长度
|
|
202
|
+
* @returns 当前向量实例(链式调用)
|
|
203
|
+
*/
|
|
204
|
+
clampLength(maxLength: number): this;
|
|
205
|
+
/**
|
|
206
|
+
* 限制向量分量
|
|
207
|
+
* @param min 最小值向量
|
|
208
|
+
* @param max 最大值向量
|
|
209
|
+
* @returns 当前向量实例(链式调用)
|
|
210
|
+
*/
|
|
211
|
+
clamp(min: Vector2, max: Vector2): this;
|
|
212
|
+
/**
|
|
213
|
+
* 检查两个向量是否相等
|
|
214
|
+
* @param other 另一个向量
|
|
215
|
+
* @param epsilon 容差,默认为Number.EPSILON
|
|
216
|
+
* @returns 是否相等
|
|
217
|
+
*/
|
|
218
|
+
equals(other: Vector2, epsilon?: number): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* 检查两个向量是否完全相等
|
|
221
|
+
* @param other 另一个向量
|
|
222
|
+
* @returns 是否完全相等
|
|
223
|
+
*/
|
|
224
|
+
exactEquals(other: Vector2): boolean;
|
|
225
|
+
/**
|
|
226
|
+
* 向量加法(静态方法)
|
|
227
|
+
* @param a 向量a
|
|
228
|
+
* @param b 向量b
|
|
229
|
+
* @returns 新的结果向量
|
|
230
|
+
*/
|
|
231
|
+
static add(a: Vector2, b: Vector2): Vector2;
|
|
232
|
+
/**
|
|
233
|
+
* 向量减法(静态方法)
|
|
234
|
+
* @param a 向量a
|
|
235
|
+
* @param b 向量b
|
|
236
|
+
* @returns 新的结果向量
|
|
237
|
+
*/
|
|
238
|
+
static subtract(a: Vector2, b: Vector2): Vector2;
|
|
239
|
+
/**
|
|
240
|
+
* 向量数乘(静态方法)
|
|
241
|
+
* @param vector 向量
|
|
242
|
+
* @param scalar 标量
|
|
243
|
+
* @returns 新的结果向量
|
|
244
|
+
*/
|
|
245
|
+
static multiply(vector: Vector2, scalar: number): Vector2;
|
|
246
|
+
/**
|
|
247
|
+
* 向量点积(静态方法)
|
|
248
|
+
* @param a 向量a
|
|
249
|
+
* @param b 向量b
|
|
250
|
+
* @returns 点积值
|
|
251
|
+
*/
|
|
252
|
+
static dot(a: Vector2, b: Vector2): number;
|
|
253
|
+
/**
|
|
254
|
+
* 向量叉积(静态方法)
|
|
255
|
+
* @param a 向量a
|
|
256
|
+
* @param b 向量b
|
|
257
|
+
* @returns 叉积值
|
|
258
|
+
*/
|
|
259
|
+
static cross(a: Vector2, b: Vector2): number;
|
|
260
|
+
/**
|
|
261
|
+
* 计算两点间距离(静态方法)
|
|
262
|
+
* @param a 点a
|
|
263
|
+
* @param b 点b
|
|
264
|
+
* @returns 距离值
|
|
265
|
+
*/
|
|
266
|
+
static distance(a: Vector2, b: Vector2): number;
|
|
267
|
+
/**
|
|
268
|
+
* 线性插值(静态方法)
|
|
269
|
+
* @param a 起始向量
|
|
270
|
+
* @param b 目标向量
|
|
271
|
+
* @param t 插值参数(0到1)
|
|
272
|
+
* @returns 新的插值结果向量
|
|
273
|
+
*/
|
|
274
|
+
static lerp(a: Vector2, b: Vector2, t: number): Vector2;
|
|
275
|
+
/**
|
|
276
|
+
* 从角度创建单位向量(静态方法)
|
|
277
|
+
* @param angle 角度(弧度)
|
|
278
|
+
* @returns 新的单位向量
|
|
279
|
+
*/
|
|
280
|
+
static fromAngle(angle: number): Vector2;
|
|
281
|
+
/**
|
|
282
|
+
* 从极坐标创建向量(静态方法)
|
|
283
|
+
* @param length 长度
|
|
284
|
+
* @param angle 角度(弧度)
|
|
285
|
+
* @returns 新的向量
|
|
286
|
+
*/
|
|
287
|
+
static fromPolar(length: number, angle: number): Vector2;
|
|
288
|
+
/**
|
|
289
|
+
* 获取两个向量中的最小分量向量(静态方法)
|
|
290
|
+
* @param a 向量a
|
|
291
|
+
* @param b 向量b
|
|
292
|
+
* @returns 新的最小分量向量
|
|
293
|
+
*/
|
|
294
|
+
static min(a: Vector2, b: Vector2): Vector2;
|
|
295
|
+
/**
|
|
296
|
+
* 获取两个向量中的最大分量向量(静态方法)
|
|
297
|
+
* @param a 向量a
|
|
298
|
+
* @param b 向量b
|
|
299
|
+
* @returns 新的最大分量向量
|
|
300
|
+
*/
|
|
301
|
+
static max(a: Vector2, b: Vector2): Vector2;
|
|
302
|
+
/**
|
|
303
|
+
* 转换为字符串
|
|
304
|
+
* @returns 字符串表示
|
|
305
|
+
*/
|
|
306
|
+
toString(): string;
|
|
307
|
+
/**
|
|
308
|
+
* 转换为数组
|
|
309
|
+
* @returns [x, y] 数组
|
|
310
|
+
*/
|
|
311
|
+
toArray(): [number, number];
|
|
312
|
+
/**
|
|
313
|
+
* 转换为普通对象
|
|
314
|
+
* @returns {x, y} 对象
|
|
315
|
+
*/
|
|
316
|
+
toObject(): {
|
|
317
|
+
x: number;
|
|
318
|
+
y: number;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 3x3变换矩阵类
|
|
324
|
+
*
|
|
325
|
+
* 用于2D变换(平移、旋转、缩放)的3x3矩阵
|
|
326
|
+
* 矩阵布局:
|
|
327
|
+
* [m00, m01, m02] [scaleX * cos, -scaleY * sin, translateX]
|
|
328
|
+
* [m10, m11, m12] = [scaleX * sin, scaleY * cos, translateY]
|
|
329
|
+
* [m20, m21, m22] [0, 0, 1]
|
|
330
|
+
*/
|
|
331
|
+
declare class Matrix3 {
|
|
332
|
+
/** 矩阵元素,按行优先存储 */
|
|
333
|
+
elements: Float32Array;
|
|
334
|
+
/**
|
|
335
|
+
* 创建3x3矩阵
|
|
336
|
+
* @param elements 矩阵元素数组(可选),默认为单位矩阵
|
|
337
|
+
*/
|
|
338
|
+
constructor(elements?: ArrayLike<number>);
|
|
339
|
+
/** 单位矩阵 */
|
|
340
|
+
static readonly IDENTITY: Matrix3;
|
|
341
|
+
/** 零矩阵 */
|
|
342
|
+
static readonly ZERO: Matrix3;
|
|
343
|
+
/** 获取矩阵元素 */
|
|
344
|
+
get(row: number, col: number): number;
|
|
345
|
+
/** 设置矩阵元素 */
|
|
346
|
+
set(row: number, col: number, value: number): this;
|
|
347
|
+
get m00(): number;
|
|
348
|
+
set m00(value: number);
|
|
349
|
+
get m01(): number;
|
|
350
|
+
set m01(value: number);
|
|
351
|
+
get m02(): number;
|
|
352
|
+
set m02(value: number);
|
|
353
|
+
get m10(): number;
|
|
354
|
+
set m10(value: number);
|
|
355
|
+
get m11(): number;
|
|
356
|
+
set m11(value: number);
|
|
357
|
+
get m12(): number;
|
|
358
|
+
set m12(value: number);
|
|
359
|
+
get m20(): number;
|
|
360
|
+
set m20(value: number);
|
|
361
|
+
get m21(): number;
|
|
362
|
+
set m21(value: number);
|
|
363
|
+
get m22(): number;
|
|
364
|
+
set m22(value: number);
|
|
365
|
+
/**
|
|
366
|
+
* 设置矩阵为单位矩阵
|
|
367
|
+
* @returns 当前矩阵实例(链式调用)
|
|
368
|
+
*/
|
|
369
|
+
identity(): this;
|
|
370
|
+
/**
|
|
371
|
+
* 设置矩阵为零矩阵
|
|
372
|
+
* @returns 当前矩阵实例(链式调用)
|
|
373
|
+
*/
|
|
374
|
+
zero(): this;
|
|
375
|
+
/**
|
|
376
|
+
* 复制另一个矩阵的值
|
|
377
|
+
* @param other 源矩阵
|
|
378
|
+
* @returns 当前矩阵实例(链式调用)
|
|
379
|
+
*/
|
|
380
|
+
copy(other: Matrix3): this;
|
|
381
|
+
/**
|
|
382
|
+
* 克隆当前矩阵
|
|
383
|
+
* @returns 新的矩阵实例
|
|
384
|
+
*/
|
|
385
|
+
clone(): Matrix3;
|
|
386
|
+
/**
|
|
387
|
+
* 从数组设置矩阵元素
|
|
388
|
+
* @param elements 矩阵元素数组
|
|
389
|
+
* @returns 当前矩阵实例(链式调用)
|
|
390
|
+
*/
|
|
391
|
+
fromArray(elements: ArrayLike<number>): this;
|
|
392
|
+
/**
|
|
393
|
+
* 矩阵加法
|
|
394
|
+
* @param other 另一个矩阵
|
|
395
|
+
* @returns 当前矩阵实例(链式调用)
|
|
396
|
+
*/
|
|
397
|
+
add(other: Matrix3): this;
|
|
398
|
+
/**
|
|
399
|
+
* 矩阵减法
|
|
400
|
+
* @param other 另一个矩阵
|
|
401
|
+
* @returns 当前矩阵实例(链式调用)
|
|
402
|
+
*/
|
|
403
|
+
subtract(other: Matrix3): this;
|
|
404
|
+
/**
|
|
405
|
+
* 矩阵标量乘法
|
|
406
|
+
* @param scalar 标量
|
|
407
|
+
* @returns 当前矩阵实例(链式调用)
|
|
408
|
+
*/
|
|
409
|
+
multiplyScalar(scalar: number): this;
|
|
410
|
+
/**
|
|
411
|
+
* 矩阵乘法
|
|
412
|
+
* @param other 另一个矩阵
|
|
413
|
+
* @returns 当前矩阵实例(链式调用)
|
|
414
|
+
*/
|
|
415
|
+
multiply(other: Matrix3): this;
|
|
416
|
+
/**
|
|
417
|
+
* 左乘另一个矩阵(other * this)
|
|
418
|
+
* @param other 左乘矩阵
|
|
419
|
+
* @returns 当前矩阵实例(链式调用)
|
|
420
|
+
*/
|
|
421
|
+
premultiply(other: Matrix3): this;
|
|
422
|
+
/**
|
|
423
|
+
* 设置为平移矩阵
|
|
424
|
+
* @param x X方向平移
|
|
425
|
+
* @param y Y方向平移
|
|
426
|
+
* @returns 当前矩阵实例(链式调用)
|
|
427
|
+
*/
|
|
428
|
+
makeTranslation(x: number, y: number): this;
|
|
429
|
+
/**
|
|
430
|
+
* 设置为旋转矩阵
|
|
431
|
+
* @param angle 旋转角度(弧度)
|
|
432
|
+
* @returns 当前矩阵实例(链式调用)
|
|
433
|
+
*/
|
|
434
|
+
makeRotation(angle: number): this;
|
|
435
|
+
/**
|
|
436
|
+
* 设置为缩放矩阵
|
|
437
|
+
* @param scaleX X方向缩放
|
|
438
|
+
* @param scaleY Y方向缩放
|
|
439
|
+
* @returns 当前矩阵实例(链式调用)
|
|
440
|
+
*/
|
|
441
|
+
makeScale(scaleX: number, scaleY: number): this;
|
|
442
|
+
/**
|
|
443
|
+
* 复合平移
|
|
444
|
+
* @param x X方向平移
|
|
445
|
+
* @param y Y方向平移
|
|
446
|
+
* @returns 当前矩阵实例(链式调用)
|
|
447
|
+
*/
|
|
448
|
+
translate(x: number, y: number): this;
|
|
449
|
+
/**
|
|
450
|
+
* 复合旋转
|
|
451
|
+
* @param angle 旋转角度(弧度)
|
|
452
|
+
* @returns 当前矩阵实例(链式调用)
|
|
453
|
+
*/
|
|
454
|
+
rotate(angle: number): this;
|
|
455
|
+
/**
|
|
456
|
+
* 复合缩放
|
|
457
|
+
* @param scaleX X方向缩放
|
|
458
|
+
* @param scaleY Y方向缩放
|
|
459
|
+
* @returns 当前矩阵实例(链式调用)
|
|
460
|
+
*/
|
|
461
|
+
scale(scaleX: number, scaleY: number): this;
|
|
462
|
+
/**
|
|
463
|
+
* 矩阵转置
|
|
464
|
+
* @returns 当前矩阵实例(链式调用)
|
|
465
|
+
*/
|
|
466
|
+
transpose(): this;
|
|
467
|
+
/**
|
|
468
|
+
* 计算矩阵行列式
|
|
469
|
+
* @returns 行列式值
|
|
470
|
+
*/
|
|
471
|
+
determinant(): number;
|
|
472
|
+
/**
|
|
473
|
+
* 矩阵求逆
|
|
474
|
+
* @returns 当前矩阵实例(链式调用),如果矩阵不可逆则保持不变
|
|
475
|
+
*/
|
|
476
|
+
invert(): this;
|
|
477
|
+
/**
|
|
478
|
+
* 变换向量(应用完整的3x3变换)
|
|
479
|
+
* @param vector 向量
|
|
480
|
+
* @returns 新的变换后的向量
|
|
481
|
+
*/
|
|
482
|
+
transformVector(vector: Vector2): Vector2;
|
|
483
|
+
/**
|
|
484
|
+
* 变换向量(仅应用旋转和缩放,忽略平移)
|
|
485
|
+
* @param vector 向量
|
|
486
|
+
* @returns 新的变换后的向量
|
|
487
|
+
*/
|
|
488
|
+
transformDirection(vector: Vector2): Vector2;
|
|
489
|
+
/**
|
|
490
|
+
* 批量变换向量数组
|
|
491
|
+
* @param vectors 向量数组
|
|
492
|
+
* @returns 变换后的向量数组
|
|
493
|
+
*/
|
|
494
|
+
transformVectors(vectors: Vector2[]): Vector2[];
|
|
495
|
+
/**
|
|
496
|
+
* 获取平移分量
|
|
497
|
+
* @returns 平移向量
|
|
498
|
+
*/
|
|
499
|
+
getTranslation(): Vector2;
|
|
500
|
+
/**
|
|
501
|
+
* 获取旋转角度
|
|
502
|
+
* @returns 旋转角度(弧度)
|
|
503
|
+
*/
|
|
504
|
+
getRotation(): number;
|
|
505
|
+
/**
|
|
506
|
+
* 获取缩放分量
|
|
507
|
+
* @returns 缩放向量
|
|
508
|
+
*/
|
|
509
|
+
getScale(): Vector2;
|
|
510
|
+
/**
|
|
511
|
+
* 分解变换矩阵为平移、旋转、缩放分量
|
|
512
|
+
* @returns {translation, rotation, scale}
|
|
513
|
+
*/
|
|
514
|
+
decompose(): {
|
|
515
|
+
translation: Vector2;
|
|
516
|
+
rotation: number;
|
|
517
|
+
scale: Vector2;
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* 检查两个矩阵是否相等
|
|
521
|
+
* @param other 另一个矩阵
|
|
522
|
+
* @param epsilon 容差,默认为Number.EPSILON
|
|
523
|
+
* @returns 是否相等
|
|
524
|
+
*/
|
|
525
|
+
equals(other: Matrix3, epsilon?: number): boolean;
|
|
526
|
+
/**
|
|
527
|
+
* 检查两个矩阵是否完全相等
|
|
528
|
+
* @param other 另一个矩阵
|
|
529
|
+
* @returns 是否完全相等
|
|
530
|
+
*/
|
|
531
|
+
exactEquals(other: Matrix3): boolean;
|
|
532
|
+
/**
|
|
533
|
+
* 检查是否为单位矩阵
|
|
534
|
+
* @param epsilon 容差,默认为Number.EPSILON
|
|
535
|
+
* @returns 是否为单位矩阵
|
|
536
|
+
*/
|
|
537
|
+
isIdentity(epsilon?: number): boolean;
|
|
538
|
+
/**
|
|
539
|
+
* 矩阵乘法(静态方法)
|
|
540
|
+
* @param a 矩阵a
|
|
541
|
+
* @param b 矩阵b
|
|
542
|
+
* @returns 新的结果矩阵
|
|
543
|
+
*/
|
|
544
|
+
static multiply(a: Matrix3, b: Matrix3): Matrix3;
|
|
545
|
+
/**
|
|
546
|
+
* 创建平移矩阵(静态方法)
|
|
547
|
+
* @param x X方向平移
|
|
548
|
+
* @param y Y方向平移
|
|
549
|
+
* @returns 新的平移矩阵
|
|
550
|
+
*/
|
|
551
|
+
static translation(x: number, y: number): Matrix3;
|
|
552
|
+
/**
|
|
553
|
+
* 创建旋转矩阵(静态方法)
|
|
554
|
+
* @param angle 旋转角度(弧度)
|
|
555
|
+
* @returns 新的旋转矩阵
|
|
556
|
+
*/
|
|
557
|
+
static rotation(angle: number): Matrix3;
|
|
558
|
+
/**
|
|
559
|
+
* 创建缩放矩阵(静态方法)
|
|
560
|
+
* @param scaleX X方向缩放
|
|
561
|
+
* @param scaleY Y方向缩放
|
|
562
|
+
* @returns 新的缩放矩阵
|
|
563
|
+
*/
|
|
564
|
+
static scale(scaleX: number, scaleY: number): Matrix3;
|
|
565
|
+
/**
|
|
566
|
+
* 创建TRS(平移-旋转-缩放)变换矩阵
|
|
567
|
+
* @param translation 平移向量
|
|
568
|
+
* @param rotation 旋转角度(弧度)
|
|
569
|
+
* @param scale 缩放向量
|
|
570
|
+
* @returns 新的TRS矩阵
|
|
571
|
+
*/
|
|
572
|
+
static TRS(translation: Vector2, rotation: number, scale: Vector2): Matrix3;
|
|
573
|
+
/**
|
|
574
|
+
* 转换为字符串
|
|
575
|
+
* @returns 字符串表示
|
|
576
|
+
*/
|
|
577
|
+
toString(): string;
|
|
578
|
+
/**
|
|
579
|
+
* 转换为数组
|
|
580
|
+
* @returns 矩阵元素数组
|
|
581
|
+
*/
|
|
582
|
+
toArray(): number[];
|
|
583
|
+
/**
|
|
584
|
+
* 转换为CSS transform字符串
|
|
585
|
+
* @returns CSS transform字符串
|
|
586
|
+
*/
|
|
587
|
+
toCSSTransform(): string;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* 2D矩形类
|
|
592
|
+
*
|
|
593
|
+
* 表示一个轴对齐的矩形,提供矩形相关的几何运算功能:
|
|
594
|
+
* - 矩形创建和属性获取
|
|
595
|
+
* - 包含检测(点、矩形)
|
|
596
|
+
* - 相交检测和计算
|
|
597
|
+
* - 变换和操作
|
|
598
|
+
*/
|
|
599
|
+
declare class Rectangle {
|
|
600
|
+
/** 矩形左上角X坐标 */
|
|
601
|
+
x: number;
|
|
602
|
+
/** 矩形左上角Y坐标 */
|
|
603
|
+
y: number;
|
|
604
|
+
/** 矩形宽度 */
|
|
605
|
+
width: number;
|
|
606
|
+
/** 矩形高度 */
|
|
607
|
+
height: number;
|
|
608
|
+
/**
|
|
609
|
+
* 创建矩形
|
|
610
|
+
* @param x 左上角X坐标,默认为0
|
|
611
|
+
* @param y 左上角Y坐标,默认为0
|
|
612
|
+
* @param width 宽度,默认为0
|
|
613
|
+
* @param height 高度,默认为0
|
|
614
|
+
*/
|
|
615
|
+
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
616
|
+
/** 空矩形 */
|
|
617
|
+
static readonly EMPTY: Rectangle;
|
|
618
|
+
/** 获取左边界 */
|
|
619
|
+
get left(): number;
|
|
620
|
+
/** 获取右边界 */
|
|
621
|
+
get right(): number;
|
|
622
|
+
/** 获取上边界 */
|
|
623
|
+
get top(): number;
|
|
624
|
+
/** 获取下边界 */
|
|
625
|
+
get bottom(): number;
|
|
626
|
+
/** 获取中心X坐标 */
|
|
627
|
+
get centerX(): number;
|
|
628
|
+
/** 获取中心Y坐标 */
|
|
629
|
+
get centerY(): number;
|
|
630
|
+
/** 获取中心点 */
|
|
631
|
+
get center(): Vector2;
|
|
632
|
+
/** 获取左上角点 */
|
|
633
|
+
get topLeft(): Vector2;
|
|
634
|
+
/** 获取右上角点 */
|
|
635
|
+
get topRight(): Vector2;
|
|
636
|
+
/** 获取左下角点 */
|
|
637
|
+
get bottomLeft(): Vector2;
|
|
638
|
+
/** 获取右下角点 */
|
|
639
|
+
get bottomRight(): Vector2;
|
|
640
|
+
/** 获取面积 */
|
|
641
|
+
get area(): number;
|
|
642
|
+
/** 获取周长 */
|
|
643
|
+
get perimeter(): number;
|
|
644
|
+
/** 检查是否为空矩形 */
|
|
645
|
+
get isEmpty(): boolean;
|
|
646
|
+
/** 检查是否为正方形 */
|
|
647
|
+
get isSquare(): boolean;
|
|
648
|
+
/**
|
|
649
|
+
* 设置矩形属性
|
|
650
|
+
* @param x 左上角X坐标
|
|
651
|
+
* @param y 左上角Y坐标
|
|
652
|
+
* @param width 宽度
|
|
653
|
+
* @param height 高度
|
|
654
|
+
* @returns 当前矩形实例(链式调用)
|
|
655
|
+
*/
|
|
656
|
+
set(x: number, y: number, width: number, height: number): this;
|
|
657
|
+
/**
|
|
658
|
+
* 复制另一个矩形的值
|
|
659
|
+
* @param other 源矩形
|
|
660
|
+
* @returns 当前矩形实例(链式调用)
|
|
661
|
+
*/
|
|
662
|
+
copy(other: Rectangle): this;
|
|
663
|
+
/**
|
|
664
|
+
* 克隆当前矩形
|
|
665
|
+
* @returns 新的矩形实例
|
|
666
|
+
*/
|
|
667
|
+
clone(): Rectangle;
|
|
668
|
+
/**
|
|
669
|
+
* 设置矩形位置
|
|
670
|
+
* @param x 新的X坐标
|
|
671
|
+
* @param y 新的Y坐标
|
|
672
|
+
* @returns 当前矩形实例(链式调用)
|
|
673
|
+
*/
|
|
674
|
+
setPosition(x: number, y: number): this;
|
|
675
|
+
/**
|
|
676
|
+
* 设置矩形大小
|
|
677
|
+
* @param width 新的宽度
|
|
678
|
+
* @param height 新的高度
|
|
679
|
+
* @returns 当前矩形实例(链式调用)
|
|
680
|
+
*/
|
|
681
|
+
setSize(width: number, height: number): this;
|
|
682
|
+
/**
|
|
683
|
+
* 设置矩形中心点
|
|
684
|
+
* @param centerX 中心X坐标
|
|
685
|
+
* @param centerY 中心Y坐标
|
|
686
|
+
* @returns 当前矩形实例(链式调用)
|
|
687
|
+
*/
|
|
688
|
+
setCenter(centerX: number, centerY: number): this;
|
|
689
|
+
/**
|
|
690
|
+
* 平移矩形
|
|
691
|
+
* @param dx X方向偏移
|
|
692
|
+
* @param dy Y方向偏移
|
|
693
|
+
* @returns 当前矩形实例(链式调用)
|
|
694
|
+
*/
|
|
695
|
+
translate(dx: number, dy: number): this;
|
|
696
|
+
/**
|
|
697
|
+
* 缩放矩形(从中心缩放)
|
|
698
|
+
* @param scaleX X方向缩放因子
|
|
699
|
+
* @param scaleY Y方向缩放因子,默认等于scaleX
|
|
700
|
+
* @returns 当前矩形实例(链式调用)
|
|
701
|
+
*/
|
|
702
|
+
scale(scaleX: number, scaleY?: number): this;
|
|
703
|
+
/**
|
|
704
|
+
* 扩展矩形
|
|
705
|
+
* @param amount 扩展量(正值扩大,负值缩小)
|
|
706
|
+
* @returns 当前矩形实例(链式调用)
|
|
707
|
+
*/
|
|
708
|
+
inflate(amount: number): this;
|
|
709
|
+
/**
|
|
710
|
+
* 扩展矩形(分别指定水平和垂直方向)
|
|
711
|
+
* @param horizontal 水平方向扩展量
|
|
712
|
+
* @param vertical 垂直方向扩展量
|
|
713
|
+
* @returns 当前矩形实例(链式调用)
|
|
714
|
+
*/
|
|
715
|
+
inflateXY(horizontal: number, vertical: number): this;
|
|
716
|
+
/**
|
|
717
|
+
* 检查是否包含指定点
|
|
718
|
+
* @param point 点
|
|
719
|
+
* @returns 是否包含
|
|
720
|
+
*/
|
|
721
|
+
containsPoint(point: Vector2): boolean;
|
|
722
|
+
/**
|
|
723
|
+
* 检查是否包含指定坐标
|
|
724
|
+
* @param x X坐标
|
|
725
|
+
* @param y Y坐标
|
|
726
|
+
* @returns 是否包含
|
|
727
|
+
*/
|
|
728
|
+
contains(x: number, y: number): boolean;
|
|
729
|
+
/**
|
|
730
|
+
* 检查是否完全包含另一个矩形
|
|
731
|
+
* @param other 另一个矩形
|
|
732
|
+
* @returns 是否完全包含
|
|
733
|
+
*/
|
|
734
|
+
containsRect(other: Rectangle): boolean;
|
|
735
|
+
/**
|
|
736
|
+
* 检查是否与另一个矩形相交
|
|
737
|
+
* @param other 另一个矩形
|
|
738
|
+
* @returns 是否相交
|
|
739
|
+
*/
|
|
740
|
+
intersects(other: Rectangle): boolean;
|
|
741
|
+
/**
|
|
742
|
+
* 计算与另一个矩形的相交矩形
|
|
743
|
+
* @param other 另一个矩形
|
|
744
|
+
* @returns 相交矩形,如果不相交返回空矩形
|
|
745
|
+
*/
|
|
746
|
+
intersection(other: Rectangle): Rectangle;
|
|
747
|
+
/**
|
|
748
|
+
* 计算与另一个矩形的并集矩形
|
|
749
|
+
* @param other 另一个矩形
|
|
750
|
+
* @returns 并集矩形
|
|
751
|
+
*/
|
|
752
|
+
union(other: Rectangle): Rectangle;
|
|
753
|
+
/**
|
|
754
|
+
* 计算相交面积
|
|
755
|
+
* @param other 另一个矩形
|
|
756
|
+
* @returns 相交面积
|
|
757
|
+
*/
|
|
758
|
+
intersectionArea(other: Rectangle): number;
|
|
759
|
+
/**
|
|
760
|
+
* 计算点到矩形的最短距离
|
|
761
|
+
* @param point 点
|
|
762
|
+
* @returns 最短距离
|
|
763
|
+
*/
|
|
764
|
+
distanceToPoint(point: Vector2): number;
|
|
765
|
+
/**
|
|
766
|
+
* 计算两个矩形间的最短距离
|
|
767
|
+
* @param other 另一个矩形
|
|
768
|
+
* @returns 最短距离(相交时为0)
|
|
769
|
+
*/
|
|
770
|
+
distanceToRect(other: Rectangle): number;
|
|
771
|
+
/**
|
|
772
|
+
* 获取矩形上距离指定点最近的点
|
|
773
|
+
* @param point 指定点
|
|
774
|
+
* @returns 最近点
|
|
775
|
+
*/
|
|
776
|
+
closestPointTo(point: Vector2): Vector2;
|
|
777
|
+
/**
|
|
778
|
+
* 检查两个矩形是否相等
|
|
779
|
+
* @param other 另一个矩形
|
|
780
|
+
* @param epsilon 容差,默认为Number.EPSILON
|
|
781
|
+
* @returns 是否相等
|
|
782
|
+
*/
|
|
783
|
+
equals(other: Rectangle, epsilon?: number): boolean;
|
|
784
|
+
/**
|
|
785
|
+
* 检查两个矩形是否完全相等
|
|
786
|
+
* @param other 另一个矩形
|
|
787
|
+
* @returns 是否完全相等
|
|
788
|
+
*/
|
|
789
|
+
exactEquals(other: Rectangle): boolean;
|
|
790
|
+
/**
|
|
791
|
+
* 从中心点和大小创建矩形
|
|
792
|
+
* @param centerX 中心X坐标
|
|
793
|
+
* @param centerY 中心Y坐标
|
|
794
|
+
* @param width 宽度
|
|
795
|
+
* @param height 高度
|
|
796
|
+
* @returns 新的矩形实例
|
|
797
|
+
*/
|
|
798
|
+
static fromCenter(centerX: number, centerY: number, width: number, height: number): Rectangle;
|
|
799
|
+
/**
|
|
800
|
+
* 从两个点创建矩形
|
|
801
|
+
* @param point1 第一个点
|
|
802
|
+
* @param point2 第二个点
|
|
803
|
+
* @returns 新的矩形实例
|
|
804
|
+
*/
|
|
805
|
+
static fromPoints(point1: Vector2, point2: Vector2): Rectangle;
|
|
806
|
+
/**
|
|
807
|
+
* 从点数组创建包围矩形
|
|
808
|
+
* @param points 点数组
|
|
809
|
+
* @returns 包围矩形
|
|
810
|
+
*/
|
|
811
|
+
static fromPointArray(points: Vector2[]): Rectangle;
|
|
812
|
+
/**
|
|
813
|
+
* 创建正方形
|
|
814
|
+
* @param x 左上角X坐标
|
|
815
|
+
* @param y 左上角Y坐标
|
|
816
|
+
* @param size 边长
|
|
817
|
+
* @returns 新的正方形矩形
|
|
818
|
+
*/
|
|
819
|
+
static square(x: number, y: number, size: number): Rectangle;
|
|
820
|
+
/**
|
|
821
|
+
* 线性插值两个矩形
|
|
822
|
+
* @param a 起始矩形
|
|
823
|
+
* @param b 目标矩形
|
|
824
|
+
* @param t 插值参数(0到1)
|
|
825
|
+
* @returns 新的插值结果矩形
|
|
826
|
+
*/
|
|
827
|
+
static lerp(a: Rectangle, b: Rectangle, t: number): Rectangle;
|
|
828
|
+
/**
|
|
829
|
+
* 转换为字符串
|
|
830
|
+
* @returns 字符串表示
|
|
831
|
+
*/
|
|
832
|
+
toString(): string;
|
|
833
|
+
/**
|
|
834
|
+
* 转换为数组
|
|
835
|
+
* @returns [x, y, width, height] 数组
|
|
836
|
+
*/
|
|
837
|
+
toArray(): [number, number, number, number];
|
|
838
|
+
/**
|
|
839
|
+
* 转换为普通对象
|
|
840
|
+
* @returns {x, y, width, height} 对象
|
|
841
|
+
*/
|
|
842
|
+
toObject(): {
|
|
843
|
+
x: number;
|
|
844
|
+
y: number;
|
|
845
|
+
width: number;
|
|
846
|
+
height: number;
|
|
847
|
+
};
|
|
848
|
+
/**
|
|
849
|
+
* 获取四个顶点
|
|
850
|
+
* @returns 顶点数组 [topLeft, topRight, bottomRight, bottomLeft]
|
|
851
|
+
*/
|
|
852
|
+
getVertices(): Vector2[];
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* 2D圆形类
|
|
857
|
+
*
|
|
858
|
+
* 表示一个圆形,提供圆形相关的几何运算功能:
|
|
859
|
+
* - 圆形创建和属性获取
|
|
860
|
+
* - 包含检测(点、圆形)
|
|
861
|
+
* - 相交检测和计算
|
|
862
|
+
* - 变换和操作
|
|
863
|
+
*/
|
|
864
|
+
declare class Circle {
|
|
865
|
+
/** 圆心X坐标 */
|
|
866
|
+
x: number;
|
|
867
|
+
/** 圆心Y坐标 */
|
|
868
|
+
y: number;
|
|
869
|
+
/** 半径 */
|
|
870
|
+
radius: number;
|
|
871
|
+
/**
|
|
872
|
+
* 创建圆形
|
|
873
|
+
* @param x 圆心X坐标,默认为0
|
|
874
|
+
* @param y 圆心Y坐标,默认为0
|
|
875
|
+
* @param radius 半径,默认为0
|
|
876
|
+
*/
|
|
877
|
+
constructor(x?: number, y?: number, radius?: number);
|
|
878
|
+
/** 空圆形 */
|
|
879
|
+
static readonly EMPTY: Circle;
|
|
880
|
+
/** 单位圆 */
|
|
881
|
+
static readonly UNIT: Circle;
|
|
882
|
+
/** 获取圆心坐标 */
|
|
883
|
+
get center(): Vector2;
|
|
884
|
+
/** 设置圆心坐标 */
|
|
885
|
+
set center(value: Vector2);
|
|
886
|
+
/** 获取直径 */
|
|
887
|
+
get diameter(): number;
|
|
888
|
+
/** 设置直径 */
|
|
889
|
+
set diameter(value: number);
|
|
890
|
+
/** 获取面积 */
|
|
891
|
+
get area(): number;
|
|
892
|
+
/** 获取周长 */
|
|
893
|
+
get circumference(): number;
|
|
894
|
+
/** 获取包围矩形 */
|
|
895
|
+
get bounds(): Rectangle;
|
|
896
|
+
/** 检查是否为空圆形 */
|
|
897
|
+
get isEmpty(): boolean;
|
|
898
|
+
/**
|
|
899
|
+
* 设置圆形属性
|
|
900
|
+
* @param x 圆心X坐标
|
|
901
|
+
* @param y 圆心Y坐标
|
|
902
|
+
* @param radius 半径
|
|
903
|
+
* @returns 当前圆形实例(链式调用)
|
|
904
|
+
*/
|
|
905
|
+
set(x: number, y: number, radius: number): this;
|
|
906
|
+
/**
|
|
907
|
+
* 复制另一个圆形的值
|
|
908
|
+
* @param other 源圆形
|
|
909
|
+
* @returns 当前圆形实例(链式调用)
|
|
910
|
+
*/
|
|
911
|
+
copy(other: Circle): this;
|
|
912
|
+
/**
|
|
913
|
+
* 克隆当前圆形
|
|
914
|
+
* @returns 新的圆形实例
|
|
915
|
+
*/
|
|
916
|
+
clone(): Circle;
|
|
917
|
+
/**
|
|
918
|
+
* 设置圆心位置
|
|
919
|
+
* @param x 新的X坐标
|
|
920
|
+
* @param y 新的Y坐标
|
|
921
|
+
* @returns 当前圆形实例(链式调用)
|
|
922
|
+
*/
|
|
923
|
+
setPosition(x: number, y: number): this;
|
|
924
|
+
/**
|
|
925
|
+
* 设置圆心位置(使用向量)
|
|
926
|
+
* @param center 新的圆心位置
|
|
927
|
+
* @returns 当前圆形实例(链式调用)
|
|
928
|
+
*/
|
|
929
|
+
setCenter(center: Vector2): this;
|
|
930
|
+
/**
|
|
931
|
+
* 设置半径
|
|
932
|
+
* @param radius 新的半径
|
|
933
|
+
* @returns 当前圆形实例(链式调用)
|
|
934
|
+
*/
|
|
935
|
+
setRadius(radius: number): this;
|
|
936
|
+
/**
|
|
937
|
+
* 平移圆形
|
|
938
|
+
* @param dx X方向偏移
|
|
939
|
+
* @param dy Y方向偏移
|
|
940
|
+
* @returns 当前圆形实例(链式调用)
|
|
941
|
+
*/
|
|
942
|
+
translate(dx: number, dy: number): this;
|
|
943
|
+
/**
|
|
944
|
+
* 平移圆形(使用向量)
|
|
945
|
+
* @param offset 偏移向量
|
|
946
|
+
* @returns 当前圆形实例(链式调用)
|
|
947
|
+
*/
|
|
948
|
+
translateBy(offset: Vector2): this;
|
|
949
|
+
/**
|
|
950
|
+
* 缩放圆形
|
|
951
|
+
* @param scale 缩放因子
|
|
952
|
+
* @returns 当前圆形实例(链式调用)
|
|
953
|
+
*/
|
|
954
|
+
scale(scale: number): this;
|
|
955
|
+
/**
|
|
956
|
+
* 扩展圆形
|
|
957
|
+
* @param amount 扩展量(正值扩大半径,负值缩小半径)
|
|
958
|
+
* @returns 当前圆形实例(链式调用)
|
|
959
|
+
*/
|
|
960
|
+
inflate(amount: number): this;
|
|
961
|
+
/**
|
|
962
|
+
* 检查是否包含指定点
|
|
963
|
+
* @param point 点
|
|
964
|
+
* @returns 是否包含
|
|
965
|
+
*/
|
|
966
|
+
containsPoint(point: Vector2): boolean;
|
|
967
|
+
/**
|
|
968
|
+
* 检查是否包含指定坐标
|
|
969
|
+
* @param x X坐标
|
|
970
|
+
* @param y Y坐标
|
|
971
|
+
* @returns 是否包含
|
|
972
|
+
*/
|
|
973
|
+
contains(x: number, y: number): boolean;
|
|
974
|
+
/**
|
|
975
|
+
* 检查是否完全包含另一个圆形
|
|
976
|
+
* @param other 另一个圆形
|
|
977
|
+
* @returns 是否完全包含
|
|
978
|
+
*/
|
|
979
|
+
containsCircle(other: Circle): boolean;
|
|
980
|
+
/**
|
|
981
|
+
* 检查点是否在圆的边界上
|
|
982
|
+
* @param point 点
|
|
983
|
+
* @param epsilon 容差,默认为Number.EPSILON
|
|
984
|
+
* @returns 是否在边界上
|
|
985
|
+
*/
|
|
986
|
+
pointOnBoundary(point: Vector2, epsilon?: number): boolean;
|
|
987
|
+
/**
|
|
988
|
+
* 检查是否与另一个圆形相交
|
|
989
|
+
* @param other 另一个圆形
|
|
990
|
+
* @returns 是否相交
|
|
991
|
+
*/
|
|
992
|
+
intersects(other: Circle): boolean;
|
|
993
|
+
/**
|
|
994
|
+
* 检查是否与矩形相交
|
|
995
|
+
* @param rect 矩形
|
|
996
|
+
* @returns 是否相交
|
|
997
|
+
*/
|
|
998
|
+
intersectsRect(rect: Rectangle): boolean;
|
|
999
|
+
/**
|
|
1000
|
+
* 计算与另一个圆形的相交面积
|
|
1001
|
+
* @param other 另一个圆形
|
|
1002
|
+
* @returns 相交面积
|
|
1003
|
+
*/
|
|
1004
|
+
intersectionArea(other: Circle): number;
|
|
1005
|
+
/**
|
|
1006
|
+
* 计算圆心到点的距离
|
|
1007
|
+
* @param point 点
|
|
1008
|
+
* @returns 距离
|
|
1009
|
+
*/
|
|
1010
|
+
distanceToPoint(point: Vector2): number;
|
|
1011
|
+
/**
|
|
1012
|
+
* 计算圆形边界到点的最短距离
|
|
1013
|
+
* @param point 点
|
|
1014
|
+
* @returns 最短距离(点在圆内时为负值)
|
|
1015
|
+
*/
|
|
1016
|
+
distanceToPointFromBoundary(point: Vector2): number;
|
|
1017
|
+
/**
|
|
1018
|
+
* 计算两个圆心之间的距离
|
|
1019
|
+
* @param other 另一个圆形
|
|
1020
|
+
* @returns 圆心距离
|
|
1021
|
+
*/
|
|
1022
|
+
distanceToCircle(other: Circle): number;
|
|
1023
|
+
/**
|
|
1024
|
+
* 计算两个圆形边界之间的最短距离
|
|
1025
|
+
* @param other 另一个圆形
|
|
1026
|
+
* @returns 最短距离(相交时为负值)
|
|
1027
|
+
*/
|
|
1028
|
+
distanceToCircleFromBoundary(other: Circle): number;
|
|
1029
|
+
/**
|
|
1030
|
+
* 计算圆形到矩形的最短距离
|
|
1031
|
+
* @param rect 矩形
|
|
1032
|
+
* @returns 最短距离
|
|
1033
|
+
*/
|
|
1034
|
+
distanceToRect(rect: Rectangle): number;
|
|
1035
|
+
/**
|
|
1036
|
+
* 获取圆形上距离指定点最近的点
|
|
1037
|
+
* @param point 指定点
|
|
1038
|
+
* @returns 最近点
|
|
1039
|
+
*/
|
|
1040
|
+
closestPointTo(point: Vector2): Vector2;
|
|
1041
|
+
/**
|
|
1042
|
+
* 获取圆形上距离指定点最远的点
|
|
1043
|
+
* @param point 指定点
|
|
1044
|
+
* @returns 最远点
|
|
1045
|
+
*/
|
|
1046
|
+
farthestPointFrom(point: Vector2): Vector2;
|
|
1047
|
+
/**
|
|
1048
|
+
* 获取指定角度上的圆周点
|
|
1049
|
+
* @param angle 角度(弧度)
|
|
1050
|
+
* @returns 圆周点
|
|
1051
|
+
*/
|
|
1052
|
+
getPointAtAngle(angle: number): Vector2;
|
|
1053
|
+
/**
|
|
1054
|
+
* 获取点相对于圆心的角度
|
|
1055
|
+
* @param point 点
|
|
1056
|
+
* @returns 角度(弧度)
|
|
1057
|
+
*/
|
|
1058
|
+
getAngleToPoint(point: Vector2): number;
|
|
1059
|
+
/**
|
|
1060
|
+
* 获取圆形与直线的交点
|
|
1061
|
+
* @param lineStart 直线起点
|
|
1062
|
+
* @param lineEnd 直线终点
|
|
1063
|
+
* @returns 交点数组(0-2个点)
|
|
1064
|
+
*/
|
|
1065
|
+
getLineIntersections(lineStart: Vector2, lineEnd: Vector2): Vector2[];
|
|
1066
|
+
/**
|
|
1067
|
+
* 检查两个圆形是否相等
|
|
1068
|
+
* @param other 另一个圆形
|
|
1069
|
+
* @param epsilon 容差,默认为Number.EPSILON
|
|
1070
|
+
* @returns 是否相等
|
|
1071
|
+
*/
|
|
1072
|
+
equals(other: Circle, epsilon?: number): boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* 检查两个圆形是否完全相等
|
|
1075
|
+
* @param other 另一个圆形
|
|
1076
|
+
* @returns 是否完全相等
|
|
1077
|
+
*/
|
|
1078
|
+
exactEquals(other: Circle): boolean;
|
|
1079
|
+
/**
|
|
1080
|
+
* 从直径创建圆形
|
|
1081
|
+
* @param x 圆心X坐标
|
|
1082
|
+
* @param y 圆心Y坐标
|
|
1083
|
+
* @param diameter 直径
|
|
1084
|
+
* @returns 新的圆形实例
|
|
1085
|
+
*/
|
|
1086
|
+
static fromDiameter(x: number, y: number, diameter: number): Circle;
|
|
1087
|
+
/**
|
|
1088
|
+
* 从三个点创建外接圆
|
|
1089
|
+
* @param p1 第一个点
|
|
1090
|
+
* @param p2 第二个点
|
|
1091
|
+
* @param p3 第三个点
|
|
1092
|
+
* @returns 外接圆,如果三点共线返回null
|
|
1093
|
+
*/
|
|
1094
|
+
static fromThreePoints(p1: Vector2, p2: Vector2, p3: Vector2): Circle | null;
|
|
1095
|
+
/**
|
|
1096
|
+
* 从点数组创建最小包围圆
|
|
1097
|
+
* @param points 点数组
|
|
1098
|
+
* @returns 最小包围圆
|
|
1099
|
+
*/
|
|
1100
|
+
static fromPointArray(points: Vector2[]): Circle;
|
|
1101
|
+
/**
|
|
1102
|
+
* 线性插值两个圆形
|
|
1103
|
+
* @param a 起始圆形
|
|
1104
|
+
* @param b 目标圆形
|
|
1105
|
+
* @param t 插值参数(0到1)
|
|
1106
|
+
* @returns 新的插值结果圆形
|
|
1107
|
+
*/
|
|
1108
|
+
static lerp(a: Circle, b: Circle, t: number): Circle;
|
|
1109
|
+
/**
|
|
1110
|
+
* 转换为字符串
|
|
1111
|
+
* @returns 字符串表示
|
|
1112
|
+
*/
|
|
1113
|
+
toString(): string;
|
|
1114
|
+
/**
|
|
1115
|
+
* 转换为数组
|
|
1116
|
+
* @returns [x, y, radius] 数组
|
|
1117
|
+
*/
|
|
1118
|
+
toArray(): [number, number, number];
|
|
1119
|
+
/**
|
|
1120
|
+
* 转换为普通对象
|
|
1121
|
+
* @returns {x, y, radius} 对象
|
|
1122
|
+
*/
|
|
1123
|
+
toObject(): {
|
|
1124
|
+
x: number;
|
|
1125
|
+
y: number;
|
|
1126
|
+
radius: number;
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* 数学工具函数集合
|
|
1132
|
+
*
|
|
1133
|
+
* 提供常用的数学运算、插值、随机数生成等实用工具函数
|
|
1134
|
+
*/
|
|
1135
|
+
declare class MathUtils {
|
|
1136
|
+
/** 圆周率 */
|
|
1137
|
+
static readonly PI: number;
|
|
1138
|
+
/** 2π */
|
|
1139
|
+
static readonly TWO_PI: number;
|
|
1140
|
+
/** π/2 */
|
|
1141
|
+
static readonly HALF_PI: number;
|
|
1142
|
+
/** π/4 */
|
|
1143
|
+
static readonly QUARTER_PI: number;
|
|
1144
|
+
/** 角度到弧度转换系数 */
|
|
1145
|
+
static readonly DEG_TO_RAD: number;
|
|
1146
|
+
/** 弧度到角度转换系数 */
|
|
1147
|
+
static readonly RAD_TO_DEG: number;
|
|
1148
|
+
/** 黄金比例 */
|
|
1149
|
+
static readonly GOLDEN_RATIO: number;
|
|
1150
|
+
/** 默认浮点数比较容差 */
|
|
1151
|
+
static readonly EPSILON: number;
|
|
1152
|
+
/**
|
|
1153
|
+
* 角度转弧度
|
|
1154
|
+
* @param degrees 角度值
|
|
1155
|
+
* @returns 弧度值
|
|
1156
|
+
*/
|
|
1157
|
+
static degToRad(degrees: number): number;
|
|
1158
|
+
/**
|
|
1159
|
+
* 弧度转角度
|
|
1160
|
+
* @param radians 弧度值
|
|
1161
|
+
* @returns 角度值
|
|
1162
|
+
*/
|
|
1163
|
+
static radToDeg(radians: number): number;
|
|
1164
|
+
/**
|
|
1165
|
+
* 规范化角度到[0, 2π)范围
|
|
1166
|
+
* @param radians 角度(弧度)
|
|
1167
|
+
* @returns 规范化后的角度
|
|
1168
|
+
*/
|
|
1169
|
+
static normalizeAngle(radians: number): number;
|
|
1170
|
+
/**
|
|
1171
|
+
* 规范化角度到(-π, π]范围
|
|
1172
|
+
* @param radians 角度(弧度)
|
|
1173
|
+
* @returns 规范化后的角度
|
|
1174
|
+
*/
|
|
1175
|
+
static normalizeAngleSigned(radians: number): number;
|
|
1176
|
+
/**
|
|
1177
|
+
* 计算两个角度之间的最短角度差
|
|
1178
|
+
* @param from 起始角度(弧度)
|
|
1179
|
+
* @param to 目标角度(弧度)
|
|
1180
|
+
* @returns 角度差(-π到π)
|
|
1181
|
+
*/
|
|
1182
|
+
static angleDifference(from: number, to: number): number;
|
|
1183
|
+
/**
|
|
1184
|
+
* 角度插值(处理角度环绕)
|
|
1185
|
+
* @param from 起始角度(弧度)
|
|
1186
|
+
* @param to 目标角度(弧度)
|
|
1187
|
+
* @param t 插值参数(0到1)
|
|
1188
|
+
* @returns 插值结果角度
|
|
1189
|
+
*/
|
|
1190
|
+
static lerpAngle(from: number, to: number, t: number): number;
|
|
1191
|
+
/**
|
|
1192
|
+
* 限制数值在指定范围内
|
|
1193
|
+
* @param value 待限制的值
|
|
1194
|
+
* @param min 最小值
|
|
1195
|
+
* @param max 最大值
|
|
1196
|
+
* @returns 限制后的值
|
|
1197
|
+
*/
|
|
1198
|
+
static clamp(value: number, min: number, max: number): number;
|
|
1199
|
+
/**
|
|
1200
|
+
* 限制数值在0到1之间
|
|
1201
|
+
* @param value 待限制的值
|
|
1202
|
+
* @returns 限制后的值
|
|
1203
|
+
*/
|
|
1204
|
+
static clamp01(value: number): number;
|
|
1205
|
+
/**
|
|
1206
|
+
* 线性插值
|
|
1207
|
+
* @param a 起始值
|
|
1208
|
+
* @param b 目标值
|
|
1209
|
+
* @param t 插值参数(0到1)
|
|
1210
|
+
* @returns 插值结果
|
|
1211
|
+
*/
|
|
1212
|
+
static lerp(a: number, b: number, t: number): number;
|
|
1213
|
+
/**
|
|
1214
|
+
* 反向线性插值(获取插值参数)
|
|
1215
|
+
* @param a 起始值
|
|
1216
|
+
* @param b 目标值
|
|
1217
|
+
* @param value 当前值
|
|
1218
|
+
* @returns 插值参数
|
|
1219
|
+
*/
|
|
1220
|
+
static inverseLerp(a: number, b: number, value: number): number;
|
|
1221
|
+
/**
|
|
1222
|
+
* 重映射数值从一个范围到另一个范围
|
|
1223
|
+
* @param value 输入值
|
|
1224
|
+
* @param inMin 输入范围最小值
|
|
1225
|
+
* @param inMax 输入范围最大值
|
|
1226
|
+
* @param outMin 输出范围最小值
|
|
1227
|
+
* @param outMax 输出范围最大值
|
|
1228
|
+
* @returns 重映射后的值
|
|
1229
|
+
*/
|
|
1230
|
+
static remap(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
|
|
1231
|
+
/**
|
|
1232
|
+
* 平滑阶跃函数(Hermite插值)
|
|
1233
|
+
* @param t 输入参数(0到1)
|
|
1234
|
+
* @returns 平滑输出(0到1)
|
|
1235
|
+
*/
|
|
1236
|
+
static smoothStep(t: number): number;
|
|
1237
|
+
/**
|
|
1238
|
+
* 更平滑的阶跃函数
|
|
1239
|
+
* @param t 输入参数(0到1)
|
|
1240
|
+
* @returns 平滑输出(0到1)
|
|
1241
|
+
*/
|
|
1242
|
+
static smootherStep(t: number): number;
|
|
1243
|
+
/**
|
|
1244
|
+
* 浮点数相等比较
|
|
1245
|
+
* @param a 数值a
|
|
1246
|
+
* @param b 数值b
|
|
1247
|
+
* @param epsilon 容差,默认为EPSILON
|
|
1248
|
+
* @returns 是否相等
|
|
1249
|
+
*/
|
|
1250
|
+
static approximately(a: number, b: number, epsilon?: number): boolean;
|
|
1251
|
+
/**
|
|
1252
|
+
* 检查数值是否为零
|
|
1253
|
+
* @param value 数值
|
|
1254
|
+
* @param epsilon 容差,默认为EPSILON
|
|
1255
|
+
* @returns 是否为零
|
|
1256
|
+
*/
|
|
1257
|
+
static isZero(value: number, epsilon?: number): boolean;
|
|
1258
|
+
/**
|
|
1259
|
+
* 获取数值的符号
|
|
1260
|
+
* @param value 数值
|
|
1261
|
+
* @returns 1、-1或0
|
|
1262
|
+
*/
|
|
1263
|
+
static sign(value: number): number;
|
|
1264
|
+
/**
|
|
1265
|
+
* 生成指定范围内的随机数
|
|
1266
|
+
* @param min 最小值(包含)
|
|
1267
|
+
* @param max 最大值(不包含)
|
|
1268
|
+
* @returns 随机数
|
|
1269
|
+
*/
|
|
1270
|
+
static random(min?: number, max?: number): number;
|
|
1271
|
+
/**
|
|
1272
|
+
* 生成指定范围内的随机整数
|
|
1273
|
+
* @param min 最小值(包含)
|
|
1274
|
+
* @param max 最大值(包含)
|
|
1275
|
+
* @returns 随机整数
|
|
1276
|
+
*/
|
|
1277
|
+
static randomInt(min: number, max: number): number;
|
|
1278
|
+
/**
|
|
1279
|
+
* 随机选择数组中的一个元素
|
|
1280
|
+
* @param array 数组
|
|
1281
|
+
* @returns 随机元素
|
|
1282
|
+
*/
|
|
1283
|
+
static randomChoice<T>(array: T[]): T;
|
|
1284
|
+
/**
|
|
1285
|
+
* 生成随机布尔值
|
|
1286
|
+
* @param probability 为true的概率(0到1),默认0.5
|
|
1287
|
+
* @returns 随机布尔值
|
|
1288
|
+
*/
|
|
1289
|
+
static randomBoolean(probability?: number): boolean;
|
|
1290
|
+
/**
|
|
1291
|
+
* 生成单位圆内的随机点
|
|
1292
|
+
* @returns 随机向量
|
|
1293
|
+
*/
|
|
1294
|
+
static randomInUnitCircle(): Vector2;
|
|
1295
|
+
/**
|
|
1296
|
+
* 生成单位圆上的随机点
|
|
1297
|
+
* @returns 随机单位向量
|
|
1298
|
+
*/
|
|
1299
|
+
static randomOnUnitCircle(): Vector2;
|
|
1300
|
+
/**
|
|
1301
|
+
* 快速平方根倒数(用于归一化)
|
|
1302
|
+
* @param value 输入值
|
|
1303
|
+
* @returns 平方根倒数
|
|
1304
|
+
*/
|
|
1305
|
+
static fastInverseSqrt(value: number): number;
|
|
1306
|
+
/**
|
|
1307
|
+
* 快速幂运算(整数指数)
|
|
1308
|
+
* @param base 底数
|
|
1309
|
+
* @param exponent 指数(整数)
|
|
1310
|
+
* @returns 幂运算结果
|
|
1311
|
+
*/
|
|
1312
|
+
static fastPow(base: number, exponent: number): number;
|
|
1313
|
+
/**
|
|
1314
|
+
* 阶乘
|
|
1315
|
+
* @param n 非负整数
|
|
1316
|
+
* @returns 阶乘结果
|
|
1317
|
+
*/
|
|
1318
|
+
static factorial(n: number): number;
|
|
1319
|
+
/**
|
|
1320
|
+
* 最大公约数
|
|
1321
|
+
* @param a 整数a
|
|
1322
|
+
* @param b 整数b
|
|
1323
|
+
* @returns 最大公约数
|
|
1324
|
+
*/
|
|
1325
|
+
static gcd(a: number, b: number): number;
|
|
1326
|
+
/**
|
|
1327
|
+
* 最小公倍数
|
|
1328
|
+
* @param a 整数a
|
|
1329
|
+
* @param b 整数b
|
|
1330
|
+
* @returns 最小公倍数
|
|
1331
|
+
*/
|
|
1332
|
+
static lcm(a: number, b: number): number;
|
|
1333
|
+
/**
|
|
1334
|
+
* 斐波那契数列
|
|
1335
|
+
* @param n 项数
|
|
1336
|
+
* @returns 第n项斐波那契数
|
|
1337
|
+
*/
|
|
1338
|
+
static fibonacci(n: number): number;
|
|
1339
|
+
/**
|
|
1340
|
+
* 等差数列求和
|
|
1341
|
+
* @param first 首项
|
|
1342
|
+
* @param last 末项
|
|
1343
|
+
* @param count 项数
|
|
1344
|
+
* @returns 等差数列和
|
|
1345
|
+
*/
|
|
1346
|
+
static arithmeticSum(first: number, last: number, count: number): number;
|
|
1347
|
+
/**
|
|
1348
|
+
* 等比数列求和
|
|
1349
|
+
* @param first 首项
|
|
1350
|
+
* @param ratio 公比
|
|
1351
|
+
* @param count 项数
|
|
1352
|
+
* @returns 等比数列和
|
|
1353
|
+
*/
|
|
1354
|
+
static geometricSum(first: number, ratio: number, count: number): number;
|
|
1355
|
+
/**
|
|
1356
|
+
* 贝塞尔二次曲线
|
|
1357
|
+
* @param p0 控制点0
|
|
1358
|
+
* @param p1 控制点1
|
|
1359
|
+
* @param p2 控制点2
|
|
1360
|
+
* @param t 参数(0到1)
|
|
1361
|
+
* @returns 曲线上的点
|
|
1362
|
+
*/
|
|
1363
|
+
static quadraticBezier(p0: Vector2, p1: Vector2, p2: Vector2, t: number): Vector2;
|
|
1364
|
+
/**
|
|
1365
|
+
* 贝塞尔三次曲线
|
|
1366
|
+
* @param p0 控制点0
|
|
1367
|
+
* @param p1 控制点1
|
|
1368
|
+
* @param p2 控制点2
|
|
1369
|
+
* @param p3 控制点3
|
|
1370
|
+
* @param t 参数(0到1)
|
|
1371
|
+
* @returns 曲线上的点
|
|
1372
|
+
*/
|
|
1373
|
+
static cubicBezier(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, t: number): Vector2;
|
|
1374
|
+
/**
|
|
1375
|
+
* Catmull-Rom样条插值
|
|
1376
|
+
* @param p0 控制点0
|
|
1377
|
+
* @param p1 控制点1
|
|
1378
|
+
* @param p2 控制点2
|
|
1379
|
+
* @param p3 控制点3
|
|
1380
|
+
* @param t 参数(0到1)
|
|
1381
|
+
* @returns 插值结果点
|
|
1382
|
+
*/
|
|
1383
|
+
static catmullRom(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, t: number): Vector2;
|
|
1384
|
+
/**
|
|
1385
|
+
* 简单伪随机噪声(基于种子)
|
|
1386
|
+
* @param x 输入X
|
|
1387
|
+
* @param y 输入Y
|
|
1388
|
+
* @param seed 种子
|
|
1389
|
+
* @returns 噪声值(0到1)
|
|
1390
|
+
*/
|
|
1391
|
+
static noise(x: number, y?: number, seed?: number): number;
|
|
1392
|
+
/**
|
|
1393
|
+
* 平滑噪声
|
|
1394
|
+
* @param x 输入X
|
|
1395
|
+
* @param y 输入Y
|
|
1396
|
+
* @param seed 种子
|
|
1397
|
+
* @returns 平滑噪声值(0到1)
|
|
1398
|
+
*/
|
|
1399
|
+
static smoothNoise(x: number, y?: number, seed?: number): number;
|
|
1400
|
+
/**
|
|
1401
|
+
* 将数值转换为指定精度
|
|
1402
|
+
* @param value 数值
|
|
1403
|
+
* @param precision 精度(小数位数)
|
|
1404
|
+
* @returns 转换后的数值
|
|
1405
|
+
*/
|
|
1406
|
+
static toPrecision(value: number, precision: number): number;
|
|
1407
|
+
/**
|
|
1408
|
+
* 检查数值是否在指定范围内
|
|
1409
|
+
* @param value 数值
|
|
1410
|
+
* @param min 最小值
|
|
1411
|
+
* @param max 最大值
|
|
1412
|
+
* @returns 是否在范围内
|
|
1413
|
+
*/
|
|
1414
|
+
static inRange(value: number, min: number, max: number): boolean;
|
|
1415
|
+
/**
|
|
1416
|
+
* 获取数组中的最小值
|
|
1417
|
+
* @param values 数值数组
|
|
1418
|
+
* @returns 最小值
|
|
1419
|
+
*/
|
|
1420
|
+
static min(...values: number[]): number;
|
|
1421
|
+
/**
|
|
1422
|
+
* 获取数组中的最大值
|
|
1423
|
+
* @param values 数值数组
|
|
1424
|
+
* @returns 最大值
|
|
1425
|
+
*/
|
|
1426
|
+
static max(...values: number[]): number;
|
|
1427
|
+
/**
|
|
1428
|
+
* 计算数组的平均值
|
|
1429
|
+
* @param values 数值数组
|
|
1430
|
+
* @returns 平均值
|
|
1431
|
+
*/
|
|
1432
|
+
static average(values: number[]): number;
|
|
1433
|
+
/**
|
|
1434
|
+
* 计算数组的中位数
|
|
1435
|
+
* @param values 数值数组
|
|
1436
|
+
* @returns 中位数
|
|
1437
|
+
*/
|
|
1438
|
+
static median(values: number[]): number;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* 碰撞信息接口
|
|
1443
|
+
*/
|
|
1444
|
+
interface CollisionInfo {
|
|
1445
|
+
/** 是否发生碰撞 */
|
|
1446
|
+
collided: boolean;
|
|
1447
|
+
/** 碰撞法线(指向第二个对象) */
|
|
1448
|
+
normal?: Vector2;
|
|
1449
|
+
/** 穿透深度 */
|
|
1450
|
+
penetration?: number;
|
|
1451
|
+
/** 碰撞点 */
|
|
1452
|
+
contactPoint?: Vector2;
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* 碰撞检测器
|
|
1456
|
+
*
|
|
1457
|
+
* 提供各种几何体之间的碰撞检测功能
|
|
1458
|
+
*/
|
|
1459
|
+
declare class CollisionDetector {
|
|
1460
|
+
/**
|
|
1461
|
+
* 点与圆形碰撞检测
|
|
1462
|
+
* @param point 点
|
|
1463
|
+
* @param circle 圆形
|
|
1464
|
+
* @returns 碰撞信息
|
|
1465
|
+
*/
|
|
1466
|
+
static pointCircle(point: Vector2, circle: Circle): CollisionInfo;
|
|
1467
|
+
/**
|
|
1468
|
+
* 点与矩形碰撞检测
|
|
1469
|
+
* @param point 点
|
|
1470
|
+
* @param rect 矩形
|
|
1471
|
+
* @returns 碰撞信息
|
|
1472
|
+
*/
|
|
1473
|
+
static pointRect(point: Vector2, rect: Rectangle): CollisionInfo;
|
|
1474
|
+
/**
|
|
1475
|
+
* 圆形与圆形碰撞检测
|
|
1476
|
+
* @param circle1 第一个圆形
|
|
1477
|
+
* @param circle2 第二个圆形
|
|
1478
|
+
* @returns 碰撞信息
|
|
1479
|
+
*/
|
|
1480
|
+
static circleCircle(circle1: Circle, circle2: Circle): CollisionInfo;
|
|
1481
|
+
/**
|
|
1482
|
+
* 圆形与矩形碰撞检测
|
|
1483
|
+
* @param circle 圆形
|
|
1484
|
+
* @param rect 矩形
|
|
1485
|
+
* @returns 碰撞信息
|
|
1486
|
+
*/
|
|
1487
|
+
static circleRect(circle: Circle, rect: Rectangle): CollisionInfo;
|
|
1488
|
+
/**
|
|
1489
|
+
* 矩形与矩形碰撞检测(AABB)
|
|
1490
|
+
* @param rect1 第一个矩形
|
|
1491
|
+
* @param rect2 第二个矩形
|
|
1492
|
+
* @returns 碰撞信息
|
|
1493
|
+
*/
|
|
1494
|
+
static rectRect(rect1: Rectangle, rect2: Rectangle): CollisionInfo;
|
|
1495
|
+
/**
|
|
1496
|
+
* 射线与圆形相交检测
|
|
1497
|
+
* @param rayOrigin 射线起点
|
|
1498
|
+
* @param rayDirection 射线方向(单位向量)
|
|
1499
|
+
* @param circle 圆形
|
|
1500
|
+
* @param maxDistance 最大检测距离,默认无限
|
|
1501
|
+
* @returns 碰撞信息,包含距离信息
|
|
1502
|
+
*/
|
|
1503
|
+
static rayCircle(rayOrigin: Vector2, rayDirection: Vector2, circle: Circle, maxDistance?: number): CollisionInfo & {
|
|
1504
|
+
distance?: number;
|
|
1505
|
+
};
|
|
1506
|
+
/**
|
|
1507
|
+
* 射线与矩形相交检测
|
|
1508
|
+
* @param rayOrigin 射线起点
|
|
1509
|
+
* @param rayDirection 射线方向(单位向量)
|
|
1510
|
+
* @param rect 矩形
|
|
1511
|
+
* @param maxDistance 最大检测距离,默认无限
|
|
1512
|
+
* @returns 碰撞信息,包含距离信息
|
|
1513
|
+
*/
|
|
1514
|
+
static rayRect(rayOrigin: Vector2, rayDirection: Vector2, rect: Rectangle, maxDistance?: number): CollisionInfo & {
|
|
1515
|
+
distance?: number;
|
|
1516
|
+
};
|
|
1517
|
+
/**
|
|
1518
|
+
* 线段与线段相交检测
|
|
1519
|
+
* @param p1 第一条线段起点
|
|
1520
|
+
* @param p2 第一条线段终点
|
|
1521
|
+
* @param p3 第二条线段起点
|
|
1522
|
+
* @param p4 第二条线段终点
|
|
1523
|
+
* @returns 碰撞信息
|
|
1524
|
+
*/
|
|
1525
|
+
static lineSegmentLineSegment(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2): CollisionInfo;
|
|
1526
|
+
/**
|
|
1527
|
+
* 线段与圆形相交检测
|
|
1528
|
+
* @param lineStart 线段起点
|
|
1529
|
+
* @param lineEnd 线段终点
|
|
1530
|
+
* @param circle 圆形
|
|
1531
|
+
* @returns 碰撞信息
|
|
1532
|
+
*/
|
|
1533
|
+
static lineSegmentCircle(lineStart: Vector2, lineEnd: Vector2, circle: Circle): CollisionInfo;
|
|
1534
|
+
/**
|
|
1535
|
+
* AABB包围盒快速排斥测试
|
|
1536
|
+
* @param bounds1 第一个包围盒
|
|
1537
|
+
* @param bounds2 第二个包围盒
|
|
1538
|
+
* @returns 是否可能相交
|
|
1539
|
+
*/
|
|
1540
|
+
static aabbTest(bounds1: Rectangle, bounds2: Rectangle): boolean;
|
|
1541
|
+
/**
|
|
1542
|
+
* 圆形包围盒快速排斥测试
|
|
1543
|
+
* @param center1 第一个圆心
|
|
1544
|
+
* @param radius1 第一个半径
|
|
1545
|
+
* @param center2 第二个圆心
|
|
1546
|
+
* @param radius2 第二个半径
|
|
1547
|
+
* @returns 是否可能相交
|
|
1548
|
+
*/
|
|
1549
|
+
static circleTest(center1: Vector2, radius1: number, center2: Vector2, radius2: number): boolean;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* 缓动函数集合
|
|
1554
|
+
*
|
|
1555
|
+
* 提供各种常用的缓动函数,用于创建平滑的动画效果
|
|
1556
|
+
* 所有函数接受时间参数 t (0-1),返回缓动后的值 (通常0-1)
|
|
1557
|
+
*/
|
|
1558
|
+
declare class Easing {
|
|
1559
|
+
/**
|
|
1560
|
+
* 线性缓动(无缓动)
|
|
1561
|
+
* @param t 时间参数 (0-1)
|
|
1562
|
+
* @returns 缓动值
|
|
1563
|
+
*/
|
|
1564
|
+
static linear(t: number): number;
|
|
1565
|
+
/**
|
|
1566
|
+
* 二次方缓入
|
|
1567
|
+
* @param t 时间参数 (0-1)
|
|
1568
|
+
* @returns 缓动值
|
|
1569
|
+
*/
|
|
1570
|
+
static quadIn(t: number): number;
|
|
1571
|
+
/**
|
|
1572
|
+
* 二次方缓出
|
|
1573
|
+
* @param t 时间参数 (0-1)
|
|
1574
|
+
* @returns 缓动值
|
|
1575
|
+
*/
|
|
1576
|
+
static quadOut(t: number): number;
|
|
1577
|
+
/**
|
|
1578
|
+
* 二次方缓入缓出
|
|
1579
|
+
* @param t 时间参数 (0-1)
|
|
1580
|
+
* @returns 缓动值
|
|
1581
|
+
*/
|
|
1582
|
+
static quadInOut(t: number): number;
|
|
1583
|
+
/**
|
|
1584
|
+
* 三次方缓入
|
|
1585
|
+
* @param t 时间参数 (0-1)
|
|
1586
|
+
* @returns 缓动值
|
|
1587
|
+
*/
|
|
1588
|
+
static cubicIn(t: number): number;
|
|
1589
|
+
/**
|
|
1590
|
+
* 三次方缓出
|
|
1591
|
+
* @param t 时间参数 (0-1)
|
|
1592
|
+
* @returns 缓动值
|
|
1593
|
+
*/
|
|
1594
|
+
static cubicOut(t: number): number;
|
|
1595
|
+
/**
|
|
1596
|
+
* 三次方缓入缓出
|
|
1597
|
+
* @param t 时间参数 (0-1)
|
|
1598
|
+
* @returns 缓动值
|
|
1599
|
+
*/
|
|
1600
|
+
static cubicInOut(t: number): number;
|
|
1601
|
+
/**
|
|
1602
|
+
* 四次方缓入
|
|
1603
|
+
* @param t 时间参数 (0-1)
|
|
1604
|
+
* @returns 缓动值
|
|
1605
|
+
*/
|
|
1606
|
+
static quartIn(t: number): number;
|
|
1607
|
+
/**
|
|
1608
|
+
* 四次方缓出
|
|
1609
|
+
* @param t 时间参数 (0-1)
|
|
1610
|
+
* @returns 缓动值
|
|
1611
|
+
*/
|
|
1612
|
+
static quartOut(t: number): number;
|
|
1613
|
+
/**
|
|
1614
|
+
* 四次方缓入缓出
|
|
1615
|
+
* @param t 时间参数 (0-1)
|
|
1616
|
+
* @returns 缓动值
|
|
1617
|
+
*/
|
|
1618
|
+
static quartInOut(t: number): number;
|
|
1619
|
+
/**
|
|
1620
|
+
* 五次方缓入
|
|
1621
|
+
* @param t 时间参数 (0-1)
|
|
1622
|
+
* @returns 缓动值
|
|
1623
|
+
*/
|
|
1624
|
+
static quintIn(t: number): number;
|
|
1625
|
+
/**
|
|
1626
|
+
* 五次方缓出
|
|
1627
|
+
* @param t 时间参数 (0-1)
|
|
1628
|
+
* @returns 缓动值
|
|
1629
|
+
*/
|
|
1630
|
+
static quintOut(t: number): number;
|
|
1631
|
+
/**
|
|
1632
|
+
* 五次方缓入缓出
|
|
1633
|
+
* @param t 时间参数 (0-1)
|
|
1634
|
+
* @returns 缓动值
|
|
1635
|
+
*/
|
|
1636
|
+
static quintInOut(t: number): number;
|
|
1637
|
+
/**
|
|
1638
|
+
* 正弦缓入
|
|
1639
|
+
* @param t 时间参数 (0-1)
|
|
1640
|
+
* @returns 缓动值
|
|
1641
|
+
*/
|
|
1642
|
+
static sineIn(t: number): number;
|
|
1643
|
+
/**
|
|
1644
|
+
* 正弦缓出
|
|
1645
|
+
* @param t 时间参数 (0-1)
|
|
1646
|
+
* @returns 缓动值
|
|
1647
|
+
*/
|
|
1648
|
+
static sineOut(t: number): number;
|
|
1649
|
+
/**
|
|
1650
|
+
* 正弦缓入缓出
|
|
1651
|
+
* @param t 时间参数 (0-1)
|
|
1652
|
+
* @returns 缓动值
|
|
1653
|
+
*/
|
|
1654
|
+
static sineInOut(t: number): number;
|
|
1655
|
+
/**
|
|
1656
|
+
* 指数缓入
|
|
1657
|
+
* @param t 时间参数 (0-1)
|
|
1658
|
+
* @returns 缓动值
|
|
1659
|
+
*/
|
|
1660
|
+
static expoIn(t: number): number;
|
|
1661
|
+
/**
|
|
1662
|
+
* 指数缓出
|
|
1663
|
+
* @param t 时间参数 (0-1)
|
|
1664
|
+
* @returns 缓动值
|
|
1665
|
+
*/
|
|
1666
|
+
static expoOut(t: number): number;
|
|
1667
|
+
/**
|
|
1668
|
+
* 指数缓入缓出
|
|
1669
|
+
* @param t 时间参数 (0-1)
|
|
1670
|
+
* @returns 缓动值
|
|
1671
|
+
*/
|
|
1672
|
+
static expoInOut(t: number): number;
|
|
1673
|
+
/**
|
|
1674
|
+
* 圆形缓入
|
|
1675
|
+
* @param t 时间参数 (0-1)
|
|
1676
|
+
* @returns 缓动值
|
|
1677
|
+
*/
|
|
1678
|
+
static circIn(t: number): number;
|
|
1679
|
+
/**
|
|
1680
|
+
* 圆形缓出
|
|
1681
|
+
* @param t 时间参数 (0-1)
|
|
1682
|
+
* @returns 缓动值
|
|
1683
|
+
*/
|
|
1684
|
+
static circOut(t: number): number;
|
|
1685
|
+
/**
|
|
1686
|
+
* 圆形缓入缓出
|
|
1687
|
+
* @param t 时间参数 (0-1)
|
|
1688
|
+
* @returns 缓动值
|
|
1689
|
+
*/
|
|
1690
|
+
static circInOut(t: number): number;
|
|
1691
|
+
/**
|
|
1692
|
+
* 回弹缓入
|
|
1693
|
+
* @param t 时间参数 (0-1)
|
|
1694
|
+
* @param s 回弹强度,默认1.70158
|
|
1695
|
+
* @returns 缓动值
|
|
1696
|
+
*/
|
|
1697
|
+
static backIn(t: number, s?: number): number;
|
|
1698
|
+
/**
|
|
1699
|
+
* 回弹缓出
|
|
1700
|
+
* @param t 时间参数 (0-1)
|
|
1701
|
+
* @param s 回弹强度,默认1.70158
|
|
1702
|
+
* @returns 缓动值
|
|
1703
|
+
*/
|
|
1704
|
+
static backOut(t: number, s?: number): number;
|
|
1705
|
+
/**
|
|
1706
|
+
* 回弹缓入缓出
|
|
1707
|
+
* @param t 时间参数 (0-1)
|
|
1708
|
+
* @param s 回弹强度,默认1.70158
|
|
1709
|
+
* @returns 缓动值
|
|
1710
|
+
*/
|
|
1711
|
+
static backInOut(t: number, s?: number): number;
|
|
1712
|
+
/**
|
|
1713
|
+
* 弹性缓入
|
|
1714
|
+
* @param t 时间参数 (0-1)
|
|
1715
|
+
* @param amplitude 振幅,默认1
|
|
1716
|
+
* @param period 周期,默认0.3
|
|
1717
|
+
* @returns 缓动值
|
|
1718
|
+
*/
|
|
1719
|
+
static elasticIn(t: number, amplitude?: number, period?: number): number;
|
|
1720
|
+
/**
|
|
1721
|
+
* 弹性缓出
|
|
1722
|
+
* @param t 时间参数 (0-1)
|
|
1723
|
+
* @param amplitude 振幅,默认1
|
|
1724
|
+
* @param period 周期,默认0.3
|
|
1725
|
+
* @returns 缓动值
|
|
1726
|
+
*/
|
|
1727
|
+
static elasticOut(t: number, amplitude?: number, period?: number): number;
|
|
1728
|
+
/**
|
|
1729
|
+
* 弹性缓入缓出
|
|
1730
|
+
* @param t 时间参数 (0-1)
|
|
1731
|
+
* @param amplitude 振幅,默认1
|
|
1732
|
+
* @param period 周期,默认0.45
|
|
1733
|
+
* @returns 缓动值
|
|
1734
|
+
*/
|
|
1735
|
+
static elasticInOut(t: number, amplitude?: number, period?: number): number;
|
|
1736
|
+
/**
|
|
1737
|
+
* 跳跃缓入
|
|
1738
|
+
* @param t 时间参数 (0-1)
|
|
1739
|
+
* @returns 缓动值
|
|
1740
|
+
*/
|
|
1741
|
+
static bounceIn(t: number): number;
|
|
1742
|
+
/**
|
|
1743
|
+
* 跳跃缓出
|
|
1744
|
+
* @param t 时间参数 (0-1)
|
|
1745
|
+
* @returns 缓动值
|
|
1746
|
+
*/
|
|
1747
|
+
static bounceOut(t: number): number;
|
|
1748
|
+
/**
|
|
1749
|
+
* 跳跃缓入缓出
|
|
1750
|
+
* @param t 时间参数 (0-1)
|
|
1751
|
+
* @returns 缓动值
|
|
1752
|
+
*/
|
|
1753
|
+
static bounceInOut(t: number): number;
|
|
1754
|
+
/**
|
|
1755
|
+
* 创建自定义缓动函数(组合多个缓动)
|
|
1756
|
+
* @param easingFunctions 缓动函数数组
|
|
1757
|
+
* @param weights 权重数组,默认均等
|
|
1758
|
+
* @returns 组合后的缓动函数
|
|
1759
|
+
*/
|
|
1760
|
+
static combine(easingFunctions: ((t: number) => number)[], weights?: number[]): (t: number) => number;
|
|
1761
|
+
/**
|
|
1762
|
+
* 创建分段缓动函数
|
|
1763
|
+
* @param segments 分段配置数组,每段包含 {duration, easing}
|
|
1764
|
+
* @returns 分段缓动函数
|
|
1765
|
+
*/
|
|
1766
|
+
static piecewise(segments: Array<{
|
|
1767
|
+
duration: number;
|
|
1768
|
+
easing: (t: number) => number;
|
|
1769
|
+
}>): (t: number) => number;
|
|
1770
|
+
/**
|
|
1771
|
+
* 创建反向缓动函数
|
|
1772
|
+
* @param easing 原缓动函数
|
|
1773
|
+
* @returns 反向缓动函数
|
|
1774
|
+
*/
|
|
1775
|
+
static reverse(easing: (t: number) => number): (t: number) => number;
|
|
1776
|
+
/**
|
|
1777
|
+
* 创建镜像缓动函数(先正向再反向)
|
|
1778
|
+
* @param easing 原缓动函数
|
|
1779
|
+
* @returns 镜像缓动函数
|
|
1780
|
+
*/
|
|
1781
|
+
static mirror(easing: (t: number) => number): (t: number) => number;
|
|
1782
|
+
/** 平滑进入(常用于UI动画) */
|
|
1783
|
+
static readonly smoothIn: typeof Easing.quadOut;
|
|
1784
|
+
/** 平滑退出(常用于UI动画) */
|
|
1785
|
+
static readonly smoothOut: typeof Easing.quadIn;
|
|
1786
|
+
/** 快速进入(常用于出现动画) */
|
|
1787
|
+
static readonly quickIn: typeof Easing.cubicOut;
|
|
1788
|
+
/** 快速退出(常用于消失动画) */
|
|
1789
|
+
static readonly quickOut: typeof Easing.cubicIn;
|
|
1790
|
+
/** 自然运动(模拟物理) */
|
|
1791
|
+
static readonly natural: typeof Easing.quartOut;
|
|
1792
|
+
/** 强调效果(吸引注意力) */
|
|
1793
|
+
static readonly emphasize: typeof Easing.backOut;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* 插值器类型定义
|
|
1798
|
+
*/
|
|
1799
|
+
type InterpolatorFunction<T> = (from: T, to: T, t: number) => T;
|
|
1800
|
+
/**
|
|
1801
|
+
* 关键帧数据结构
|
|
1802
|
+
*/
|
|
1803
|
+
interface Keyframe<T> {
|
|
1804
|
+
time: number;
|
|
1805
|
+
value: T;
|
|
1806
|
+
easing?: (t: number) => number;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* 带缓存的插值器类
|
|
1810
|
+
* 用于需要重复插值相同起始和目标值的情况
|
|
1811
|
+
*/
|
|
1812
|
+
declare class CachedInterpolator<T> {
|
|
1813
|
+
private from?;
|
|
1814
|
+
private to?;
|
|
1815
|
+
private interpolator;
|
|
1816
|
+
private cache;
|
|
1817
|
+
constructor(interpolator: InterpolatorFunction<T>);
|
|
1818
|
+
/**
|
|
1819
|
+
* 设置插值范围
|
|
1820
|
+
* @param from 起始值
|
|
1821
|
+
* @param to 目标值
|
|
1822
|
+
*/
|
|
1823
|
+
setRange(from: T, to: T): void;
|
|
1824
|
+
/**
|
|
1825
|
+
* 获取插值结果
|
|
1826
|
+
* @param t 插值参数
|
|
1827
|
+
* @returns 插值结果
|
|
1828
|
+
*/
|
|
1829
|
+
get(t: number): T;
|
|
1830
|
+
/**
|
|
1831
|
+
* 清空缓存
|
|
1832
|
+
*/
|
|
1833
|
+
clearCache(): void;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* 插值工具类
|
|
1837
|
+
*
|
|
1838
|
+
* 提供各种类型的插值功能,用于创建平滑的数值变化
|
|
1839
|
+
*/
|
|
1840
|
+
declare class Interpolation {
|
|
1841
|
+
/**
|
|
1842
|
+
* 数值线性插值
|
|
1843
|
+
* @param from 起始值
|
|
1844
|
+
* @param to 目标值
|
|
1845
|
+
* @param t 插值参数 (0-1)
|
|
1846
|
+
* @returns 插值结果
|
|
1847
|
+
*/
|
|
1848
|
+
static number(from: number, to: number, t: number): number;
|
|
1849
|
+
/**
|
|
1850
|
+
* 向量线性插值
|
|
1851
|
+
* @param from 起始向量
|
|
1852
|
+
* @param to 目标向量
|
|
1853
|
+
* @param t 插值参数 (0-1)
|
|
1854
|
+
* @returns 插值结果向量
|
|
1855
|
+
*/
|
|
1856
|
+
static vector2(from: Vector2, to: Vector2, t: number): Vector2;
|
|
1857
|
+
/**
|
|
1858
|
+
* 角度插值(处理角度环绕)
|
|
1859
|
+
* @param from 起始角度(弧度)
|
|
1860
|
+
* @param to 目标角度(弧度)
|
|
1861
|
+
* @param t 插值参数 (0-1)
|
|
1862
|
+
* @returns 插值结果角度
|
|
1863
|
+
*/
|
|
1864
|
+
static angle(from: number, to: number, t: number): number;
|
|
1865
|
+
/**
|
|
1866
|
+
* 颜色插值(RGB)
|
|
1867
|
+
* @param from 起始颜色 [r, g, b, a?]
|
|
1868
|
+
* @param to 目标颜色 [r, g, b, a?]
|
|
1869
|
+
* @param t 插值参数 (0-1)
|
|
1870
|
+
* @returns 插值结果颜色
|
|
1871
|
+
*/
|
|
1872
|
+
static color(from: number[], to: number[], t: number): number[];
|
|
1873
|
+
/**
|
|
1874
|
+
* 三次样条插值
|
|
1875
|
+
* @param p0 控制点0
|
|
1876
|
+
* @param p1 控制点1(起点)
|
|
1877
|
+
* @param p2 控制点2(终点)
|
|
1878
|
+
* @param p3 控制点3
|
|
1879
|
+
* @param t 插值参数 (0-1)
|
|
1880
|
+
* @returns 插值结果
|
|
1881
|
+
*/
|
|
1882
|
+
static cubicSpline(p0: number, p1: number, p2: number, p3: number, t: number): number;
|
|
1883
|
+
/**
|
|
1884
|
+
* Hermite插值
|
|
1885
|
+
* @param p0 起始点
|
|
1886
|
+
* @param m0 起始切线
|
|
1887
|
+
* @param p1 结束点
|
|
1888
|
+
* @param m1 结束切线
|
|
1889
|
+
* @param t 插值参数 (0-1)
|
|
1890
|
+
* @returns 插值结果
|
|
1891
|
+
*/
|
|
1892
|
+
static hermite(p0: number, m0: number, p1: number, m1: number, t: number): number;
|
|
1893
|
+
/**
|
|
1894
|
+
* 球面线性插值(适用于方向向量)
|
|
1895
|
+
* @param from 起始单位向量
|
|
1896
|
+
* @param to 目标单位向量
|
|
1897
|
+
* @param t 插值参数 (0-1)
|
|
1898
|
+
* @returns 插值结果向量
|
|
1899
|
+
*/
|
|
1900
|
+
static slerp(from: Vector2, to: Vector2, t: number): Vector2;
|
|
1901
|
+
/**
|
|
1902
|
+
* 创建带缓存的插值器
|
|
1903
|
+
* 用于需要重复插值相同起始和目标值的情况
|
|
1904
|
+
* @param interpolator 插值函数
|
|
1905
|
+
* @returns 缓存插值器实例
|
|
1906
|
+
*/
|
|
1907
|
+
static createCachedInterpolator<T>(interpolator: InterpolatorFunction<T>): CachedInterpolator<T>;
|
|
1908
|
+
/**
|
|
1909
|
+
* 样条曲线插值(通过多个控制点)
|
|
1910
|
+
* @param points 控制点数组
|
|
1911
|
+
* @param t 插值参数 (0-1)
|
|
1912
|
+
* @returns 插值结果
|
|
1913
|
+
*/
|
|
1914
|
+
static spline(points: number[], t: number): number;
|
|
1915
|
+
/**
|
|
1916
|
+
* 向量样条曲线插值
|
|
1917
|
+
* @param points 控制点数组
|
|
1918
|
+
* @param t 插值参数 (0-1)
|
|
1919
|
+
* @returns 插值结果向量
|
|
1920
|
+
*/
|
|
1921
|
+
static vectorSpline(points: Vector2[], t: number): Vector2;
|
|
1922
|
+
/**
|
|
1923
|
+
* 关键帧动画插值
|
|
1924
|
+
* @param keyframes 关键帧数组(按时间排序)
|
|
1925
|
+
* @param time 当前时间
|
|
1926
|
+
* @param interpolator 插值函数
|
|
1927
|
+
* @returns 插值结果
|
|
1928
|
+
*/
|
|
1929
|
+
static keyframe<T>(keyframes: Keyframe<T>[], time: number, interpolator: InterpolatorFunction<T>): T;
|
|
1930
|
+
/**
|
|
1931
|
+
* 路径插值(沿着由点组成的路径)
|
|
1932
|
+
* @param path 路径点数组
|
|
1933
|
+
* @param t 插值参数 (0-1)
|
|
1934
|
+
* @param closed 是否为闭合路径
|
|
1935
|
+
* @returns 路径上的点
|
|
1936
|
+
*/
|
|
1937
|
+
static pathInterpolation(path: Vector2[], t: number, closed?: boolean): Vector2;
|
|
1938
|
+
/**
|
|
1939
|
+
* 计算路径总长度
|
|
1940
|
+
* @param path 路径点数组
|
|
1941
|
+
* @param closed 是否为闭合路径
|
|
1942
|
+
* @returns 路径总长度
|
|
1943
|
+
*/
|
|
1944
|
+
static getPathLength(path: Vector2[], closed?: boolean): number;
|
|
1945
|
+
/**
|
|
1946
|
+
* 创建数值插值器
|
|
1947
|
+
* @param from 起始值
|
|
1948
|
+
* @param to 目标值
|
|
1949
|
+
* @returns 插值器函数
|
|
1950
|
+
*/
|
|
1951
|
+
static createNumberInterpolator(from: number, to: number): (t: number) => number;
|
|
1952
|
+
/**
|
|
1953
|
+
* 创建向量插值器
|
|
1954
|
+
* @param from 起始向量
|
|
1955
|
+
* @param to 目标向量
|
|
1956
|
+
* @returns 插值器函数
|
|
1957
|
+
*/
|
|
1958
|
+
static createVectorInterpolator(from: Vector2, to: Vector2): (t: number) => Vector2;
|
|
1959
|
+
/**
|
|
1960
|
+
* 创建组合插值器(插值多个值)
|
|
1961
|
+
* @param interpolators 插值器数组
|
|
1962
|
+
* @returns 组合插值器函数
|
|
1963
|
+
*/
|
|
1964
|
+
static createCompositeInterpolator<T>(interpolators: InterpolatorFunction<T>[]): (from: T[], to: T[], t: number) => T[];
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
export { CachedInterpolator, Circle, CollisionDetector, Easing, Interpolation, MathUtils, Matrix3, Rectangle, Vector2 };
|
|
1968
|
+
export type { CollisionInfo, InterpolatorFunction, Keyframe };
|