@specter-automation/test 1.0.149 → 1.0.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/locators/actor-locator.d.ts +67 -4
- package/dist/core/locators/actor-locator.js +128 -9
- package/dist/core/locators/ai-controller-locator.d.ts +7 -1
- package/dist/core/locators/ai-controller-locator.js +10 -1
- package/dist/core/locators/specter-locator.js +18 -1
- package/dist/core/specter-client.d.ts +26 -49
- package/dist/core/specter-client.js +59 -44
- package/dist/core/specter-debug.d.ts +145 -0
- package/dist/core/specter-debug.js +35 -0
- package/dist/core/specter-matcher-report.d.ts +1 -1
- package/dist/core/specter-matcher-report.js +1 -1
- package/dist/core/specter-math.d.ts +417 -0
- package/dist/core/specter-math.js +522 -0
- package/dist/core/specter-preview.js +2 -1
- package/dist/core/specter-reporter.js +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -1
- package/dist/matchers/actor-matchers.d.ts +51 -30
- package/dist/matchers/actor-matchers.js +93 -10
- package/dist/matchers/gas-matchers.d.ts +2 -0
- package/dist/matchers/gas-matchers.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RotatorUtils = exports.VectorUtils = void 0;
|
|
4
|
+
exports.resolveVector3 = resolveVector3;
|
|
5
|
+
exports.resolveRotator = resolveRotator;
|
|
6
|
+
exports.normalizeAxis = normalizeAxis;
|
|
7
|
+
exports.findLookAtRotation = findLookAtRotation;
|
|
8
|
+
exports.getRotationBetween = getRotationBetween;
|
|
9
|
+
exports.calculateDistance = calculateDistance;
|
|
10
|
+
exports.calculateDistance2D = calculateDistance2D;
|
|
11
|
+
exports.normalizeRotator = normalizeRotator;
|
|
12
|
+
exports.deltaRotator = deltaRotator;
|
|
13
|
+
const DEG_TO_RAD = Math.PI / 180.0;
|
|
14
|
+
const RAD_TO_DEG = 180.0 / Math.PI;
|
|
15
|
+
const EPSILON = 1e-7;
|
|
16
|
+
function cleanFloat(val) {
|
|
17
|
+
return Math.abs(val) < EPSILON ? 0 : val;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a partial or complete Vector3, defaulting undefined components (x, y, z) to 0.
|
|
21
|
+
*/
|
|
22
|
+
function resolveVector3(v) {
|
|
23
|
+
return {
|
|
24
|
+
x: v?.x ?? 0,
|
|
25
|
+
y: v?.y ?? 0,
|
|
26
|
+
z: v?.z ?? 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolves a partial or complete Rotator, defaulting undefined components (pitch, yaw, roll) to 0.
|
|
31
|
+
*/
|
|
32
|
+
function resolveRotator(r) {
|
|
33
|
+
return {
|
|
34
|
+
pitch: r?.pitch ?? 0,
|
|
35
|
+
yaw: r?.yaw ?? 0,
|
|
36
|
+
roll: r?.roll ?? 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalizes an angle in degrees to the [-180, 180) range, matching Unreal's FRotator::NormalizeAxis.
|
|
41
|
+
*/
|
|
42
|
+
function normalizeAxis(angleDeg) {
|
|
43
|
+
let a = angleDeg % 360;
|
|
44
|
+
if (a > 180)
|
|
45
|
+
a -= 360;
|
|
46
|
+
if (a <= -180)
|
|
47
|
+
a += 360;
|
|
48
|
+
return cleanFloat(a);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Utilities for 3D vectors matching Unreal Engine coordinate math.
|
|
52
|
+
*/
|
|
53
|
+
exports.VectorUtils = {
|
|
54
|
+
/**
|
|
55
|
+
* Creates a Vector3 at (0, 0, 0).
|
|
56
|
+
*/
|
|
57
|
+
zero: () => ({ x: 0, y: 0, z: 0 }),
|
|
58
|
+
/**
|
|
59
|
+
* Resolves a partial or complete Vector3, defaulting undefined components to 0.
|
|
60
|
+
*/
|
|
61
|
+
resolve: resolveVector3,
|
|
62
|
+
/**
|
|
63
|
+
* Adds an offset in a given direction vector: location + (direction * offset).
|
|
64
|
+
* Undefined x, y, z components default to 0.
|
|
65
|
+
*/
|
|
66
|
+
addOffset: (location, direction, offset) => {
|
|
67
|
+
const loc = resolveVector3(location);
|
|
68
|
+
const dir = resolveVector3(direction);
|
|
69
|
+
return {
|
|
70
|
+
x: loc.x + (dir.x * offset),
|
|
71
|
+
y: loc.y + (dir.y * offset),
|
|
72
|
+
z: loc.z + (dir.z * offset)
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Adds two vectors (A + B). Undefined components default to 0.
|
|
77
|
+
*/
|
|
78
|
+
add: (a, b) => {
|
|
79
|
+
const va = resolveVector3(a);
|
|
80
|
+
const vb = resolveVector3(b);
|
|
81
|
+
return {
|
|
82
|
+
x: va.x + vb.x,
|
|
83
|
+
y: va.y + vb.y,
|
|
84
|
+
z: va.z + vb.z
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* Subtracts vector B from vector A (A - B). Undefined components default to 0.
|
|
89
|
+
*/
|
|
90
|
+
subtract: (a, b) => {
|
|
91
|
+
const va = resolveVector3(a);
|
|
92
|
+
const vb = resolveVector3(b);
|
|
93
|
+
return {
|
|
94
|
+
x: va.x - vb.x,
|
|
95
|
+
y: va.y - vb.y,
|
|
96
|
+
z: va.z - vb.z
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
/** `a - b`: alias for subtract */
|
|
100
|
+
sub: (a, b) => {
|
|
101
|
+
const va = resolveVector3(a);
|
|
102
|
+
const vb = resolveVector3(b);
|
|
103
|
+
return {
|
|
104
|
+
x: va.x - vb.x,
|
|
105
|
+
y: va.y - vb.y,
|
|
106
|
+
z: va.z - vb.z
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Multiplies a vector by a scalar. Undefined components default to 0.
|
|
111
|
+
*/
|
|
112
|
+
multiply: (v, scalar) => {
|
|
113
|
+
const res = resolveVector3(v);
|
|
114
|
+
return {
|
|
115
|
+
x: res.x * scalar,
|
|
116
|
+
y: res.y * scalar,
|
|
117
|
+
z: res.z * scalar
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
/** `v * scalar`: alias for multiply */
|
|
121
|
+
scale: (v, scalar) => {
|
|
122
|
+
const res = resolveVector3(v);
|
|
123
|
+
return {
|
|
124
|
+
x: res.x * scalar,
|
|
125
|
+
y: res.y * scalar,
|
|
126
|
+
z: res.z * scalar
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Divides a vector by a scalar. Returns (0, 0, 0) if scalar is 0.
|
|
131
|
+
*/
|
|
132
|
+
divide: (v, scalar) => {
|
|
133
|
+
if (scalar === 0)
|
|
134
|
+
return { x: 0, y: 0, z: 0 };
|
|
135
|
+
const res = resolveVector3(v);
|
|
136
|
+
return {
|
|
137
|
+
x: res.x / scalar,
|
|
138
|
+
y: res.y / scalar,
|
|
139
|
+
z: res.z / scalar
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Calculates the Euclidean distance between two 3D vectors. Undefined components default to 0.
|
|
144
|
+
*/
|
|
145
|
+
distance: (a, b) => {
|
|
146
|
+
const va = resolveVector3(a);
|
|
147
|
+
const vb = resolveVector3(b);
|
|
148
|
+
const dx = vb.x - va.x;
|
|
149
|
+
const dy = vb.y - va.y;
|
|
150
|
+
const dz = vb.z - va.z;
|
|
151
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Calculates the 2D Euclidean distance on the ground plane (XY only). Undefined components default to 0.
|
|
155
|
+
*/
|
|
156
|
+
distance2D: (a, b) => {
|
|
157
|
+
const va = resolveVector3(a);
|
|
158
|
+
const vb = resolveVector3(b);
|
|
159
|
+
const dx = vb.x - va.x;
|
|
160
|
+
const dy = vb.y - va.y;
|
|
161
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* Returns the magnitude / length of a 3D vector. Undefined components default to 0.
|
|
165
|
+
*/
|
|
166
|
+
length: (v) => {
|
|
167
|
+
const res = resolveVector3(v);
|
|
168
|
+
return Math.sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* Returns the 2D magnitude on the XY plane. Undefined components default to 0.
|
|
172
|
+
*/
|
|
173
|
+
length2D: (v) => {
|
|
174
|
+
const res = resolveVector3(v);
|
|
175
|
+
return Math.sqrt(res.x * res.x + res.y * res.y);
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Returns the squared length of a 3D vector. Undefined components default to 0.
|
|
179
|
+
*/
|
|
180
|
+
lengthSquared: (v) => {
|
|
181
|
+
const res = resolveVector3(v);
|
|
182
|
+
return res.x * res.x + res.y * res.y + res.z * res.z;
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* Returns a normalized unit vector (length = 1). Returns (0, 0, 0) if length is 0.
|
|
186
|
+
*/
|
|
187
|
+
normalize: (v) => {
|
|
188
|
+
const res = resolveVector3(v);
|
|
189
|
+
const len = Math.sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
|
|
190
|
+
if (len === 0)
|
|
191
|
+
return { x: 0, y: 0, z: 0 };
|
|
192
|
+
return {
|
|
193
|
+
x: res.x / len,
|
|
194
|
+
y: res.y / len,
|
|
195
|
+
z: res.z / len
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
/**
|
|
199
|
+
* Returns the normalized direction vector from point `from` to point `to`.
|
|
200
|
+
* Undefined components default to 0.
|
|
201
|
+
*/
|
|
202
|
+
direction: (from, to) => {
|
|
203
|
+
const vf = resolveVector3(from);
|
|
204
|
+
const vt = resolveVector3(to);
|
|
205
|
+
const dx = vt.x - vf.x;
|
|
206
|
+
const dy = vt.y - vf.y;
|
|
207
|
+
const dz = vt.z - vf.z;
|
|
208
|
+
const len = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
209
|
+
if (len === 0)
|
|
210
|
+
return { x: 0, y: 0, z: 0 };
|
|
211
|
+
return { x: dx / len, y: dy / len, z: dz / len };
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Computes the dot product of two vectors (A · B). Undefined components default to 0.
|
|
215
|
+
*/
|
|
216
|
+
dot: (a, b) => {
|
|
217
|
+
const va = resolveVector3(a);
|
|
218
|
+
const vb = resolveVector3(b);
|
|
219
|
+
return va.x * vb.x + va.y * vb.y + va.z * vb.z;
|
|
220
|
+
},
|
|
221
|
+
/**
|
|
222
|
+
* Computes the cross product of two vectors (A × B) in Unreal's left-handed coordinate system.
|
|
223
|
+
* Undefined components default to 0.
|
|
224
|
+
*/
|
|
225
|
+
cross: (a, b) => {
|
|
226
|
+
const va = resolveVector3(a);
|
|
227
|
+
const vb = resolveVector3(b);
|
|
228
|
+
return {
|
|
229
|
+
x: va.y * vb.z - va.z * vb.y,
|
|
230
|
+
y: va.z * vb.x - va.x * vb.z,
|
|
231
|
+
z: va.x * vb.y - va.y * vb.x
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
/**
|
|
235
|
+
* Linearly interpolates between vector A and B by alpha. Undefined components default to 0.
|
|
236
|
+
*/
|
|
237
|
+
lerp: (a, b, alpha) => {
|
|
238
|
+
const va = resolveVector3(a);
|
|
239
|
+
const vb = resolveVector3(b);
|
|
240
|
+
return {
|
|
241
|
+
x: va.x + (vb.x - va.x) * alpha,
|
|
242
|
+
y: va.y + (vb.y - va.y) * alpha,
|
|
243
|
+
z: va.z + (vb.z - va.z) * alpha
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
/**
|
|
247
|
+
* Checks if two vectors are approximately equal within a tolerance distance.
|
|
248
|
+
* Undefined components default to 0.
|
|
249
|
+
*/
|
|
250
|
+
isNearlyEqual: (a, b, tolerance = 0.01) => {
|
|
251
|
+
return exports.VectorUtils.distance(a, b) <= tolerance;
|
|
252
|
+
},
|
|
253
|
+
/**
|
|
254
|
+
* Converts a direction vector into an Unreal Engine FRotator (Roll = 0).
|
|
255
|
+
* Matches Unreal's `FVector::Rotation()` / `FRotationMatrix::MakeFromX()`.
|
|
256
|
+
*/
|
|
257
|
+
toRotator: (direction) => {
|
|
258
|
+
return exports.RotatorUtils.fromDirection(direction);
|
|
259
|
+
},
|
|
260
|
+
/**
|
|
261
|
+
* Calculates the FRotator required to face from point `from` towards point `to`.
|
|
262
|
+
* Identical to Unreal Engine's `UKismetMathLibrary::FindLookAtRotation`.
|
|
263
|
+
* Undefined components default to 0.
|
|
264
|
+
*/
|
|
265
|
+
findLookAtRotation: (from, to) => {
|
|
266
|
+
return exports.RotatorUtils.fromVectors(from, to);
|
|
267
|
+
},
|
|
268
|
+
/**
|
|
269
|
+
* Rotates a 3D vector by an Unreal FRotator.
|
|
270
|
+
* Matches Unreal Engine's `FRotator::RotateVector`.
|
|
271
|
+
* Undefined components default to 0.
|
|
272
|
+
*/
|
|
273
|
+
rotate: (v, rot) => {
|
|
274
|
+
const { fwd, right, up } = exports.RotatorUtils.getAxes(rot);
|
|
275
|
+
const res = resolveVector3(v);
|
|
276
|
+
return {
|
|
277
|
+
x: cleanFloat(fwd.x * res.x + right.x * res.y + up.x * res.z),
|
|
278
|
+
y: cleanFloat(fwd.y * res.x + right.y * res.y + up.y * res.z),
|
|
279
|
+
z: cleanFloat(fwd.z * res.x + right.z * res.y + up.z * res.z)
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Utilities for Euler rotations (Pitch, Yaw, Roll in degrees) matching Unreal Engine's FRotator.
|
|
285
|
+
*/
|
|
286
|
+
exports.RotatorUtils = {
|
|
287
|
+
/**
|
|
288
|
+
* Creates a Rotator at (pitch: 0, yaw: 0, roll: 0).
|
|
289
|
+
*/
|
|
290
|
+
zero: () => ({ pitch: 0, yaw: 0, roll: 0 }),
|
|
291
|
+
/**
|
|
292
|
+
* Resolves a partial or complete Rotator, defaulting undefined components (pitch, yaw, roll) to 0.
|
|
293
|
+
*/
|
|
294
|
+
resolve: resolveRotator,
|
|
295
|
+
/**
|
|
296
|
+
* Constructs a Rotator from pitch, yaw, and optional roll. Defaults omitted parameters to 0.
|
|
297
|
+
*/
|
|
298
|
+
make: (pitch = 0, yaw = 0, roll = 0) => ({
|
|
299
|
+
pitch: normalizeAxis(pitch),
|
|
300
|
+
yaw: normalizeAxis(yaw),
|
|
301
|
+
roll: normalizeAxis(roll)
|
|
302
|
+
}),
|
|
303
|
+
/**
|
|
304
|
+
* Constructs a flat yaw-only Rotator (pitch: 0, roll: 0).
|
|
305
|
+
*/
|
|
306
|
+
fromYaw: (yaw = 0) => ({
|
|
307
|
+
pitch: 0,
|
|
308
|
+
yaw: normalizeAxis(yaw),
|
|
309
|
+
roll: 0
|
|
310
|
+
}),
|
|
311
|
+
/**
|
|
312
|
+
* Calculates the look-at rotation from a direction vector.
|
|
313
|
+
* Matches Unreal's `FVector::Rotation()`. Undefined components default to 0.
|
|
314
|
+
*/
|
|
315
|
+
fromDirection: (dir) => {
|
|
316
|
+
const d = resolveVector3(dir);
|
|
317
|
+
const dist2D = Math.sqrt(d.x * d.x + d.y * d.y);
|
|
318
|
+
if (dist2D === 0 && d.z === 0) {
|
|
319
|
+
return { pitch: 0, yaw: 0, roll: 0 };
|
|
320
|
+
}
|
|
321
|
+
const yaw = Math.atan2(d.y, d.x) * RAD_TO_DEG;
|
|
322
|
+
const pitch = Math.atan2(d.z, dist2D) * RAD_TO_DEG;
|
|
323
|
+
return {
|
|
324
|
+
pitch: normalizeAxis(pitch),
|
|
325
|
+
yaw: normalizeAxis(yaw),
|
|
326
|
+
roll: 0
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Calculates the rotation required to look from `from` towards `to`.
|
|
331
|
+
* Identical to Unreal Engine's `UKismetMathLibrary::FindLookAtRotation(Start, Target)`.
|
|
332
|
+
* Undefined components default to 0.
|
|
333
|
+
*/
|
|
334
|
+
fromVectors: (from, to) => {
|
|
335
|
+
const vf = resolveVector3(from);
|
|
336
|
+
const vt = resolveVector3(to);
|
|
337
|
+
return exports.RotatorUtils.fromDirection({
|
|
338
|
+
x: vt.x - vf.x,
|
|
339
|
+
y: vt.y - vf.y,
|
|
340
|
+
z: vt.z - vf.z
|
|
341
|
+
});
|
|
342
|
+
},
|
|
343
|
+
/**
|
|
344
|
+
* Alias for `fromVectors`: finds the look-at rotation from `start` to `target`.
|
|
345
|
+
*/
|
|
346
|
+
findLookAtRotation: (start, target) => {
|
|
347
|
+
return exports.RotatorUtils.fromVectors(start, target);
|
|
348
|
+
},
|
|
349
|
+
/**
|
|
350
|
+
* Computes the three unit axis vectors (Forward, Right, Up) for a given Rotator.
|
|
351
|
+
* Matches Unreal Engine's `FRotationMatrix(Rotator)`.
|
|
352
|
+
* Undefined components default to 0.
|
|
353
|
+
*/
|
|
354
|
+
getAxes: (rot) => {
|
|
355
|
+
const r = resolveRotator(rot);
|
|
356
|
+
const p = r.pitch * DEG_TO_RAD;
|
|
357
|
+
const y = r.yaw * DEG_TO_RAD;
|
|
358
|
+
const roll = r.roll * DEG_TO_RAD;
|
|
359
|
+
const sp = Math.sin(p), cp = Math.cos(p);
|
|
360
|
+
const sy = Math.sin(y), cy = Math.cos(y);
|
|
361
|
+
const sr = Math.sin(roll), cr = Math.cos(roll);
|
|
362
|
+
const fwd = {
|
|
363
|
+
x: cleanFloat(cp * cy),
|
|
364
|
+
y: cleanFloat(cp * sy),
|
|
365
|
+
z: cleanFloat(sp)
|
|
366
|
+
};
|
|
367
|
+
const right = {
|
|
368
|
+
x: cleanFloat(sr * sp * cy - cr * sy),
|
|
369
|
+
y: cleanFloat(sr * sp * sy + cr * cy),
|
|
370
|
+
z: cleanFloat(-sr * cp)
|
|
371
|
+
};
|
|
372
|
+
const up = {
|
|
373
|
+
x: cleanFloat(-(cr * sp * cy + sr * sy)),
|
|
374
|
+
y: cleanFloat(-(cr * sp * sy - sr * cy)),
|
|
375
|
+
z: cleanFloat(cr * cp)
|
|
376
|
+
};
|
|
377
|
+
return { fwd, right, up };
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Returns the unit forward vector (+X) for this rotation.
|
|
381
|
+
* Matches Unreal Engine's `FRotator::Vector()`.
|
|
382
|
+
* Undefined components default to 0.
|
|
383
|
+
*/
|
|
384
|
+
getForwardVector: (rot) => {
|
|
385
|
+
const r = resolveRotator(rot);
|
|
386
|
+
const p = r.pitch * DEG_TO_RAD;
|
|
387
|
+
const y = r.yaw * DEG_TO_RAD;
|
|
388
|
+
const cp = Math.cos(p);
|
|
389
|
+
return {
|
|
390
|
+
x: cleanFloat(cp * Math.cos(y)),
|
|
391
|
+
y: cleanFloat(cp * Math.sin(y)),
|
|
392
|
+
z: cleanFloat(Math.sin(p))
|
|
393
|
+
};
|
|
394
|
+
},
|
|
395
|
+
/**
|
|
396
|
+
* Returns the unit right vector (+Y) for this rotation.
|
|
397
|
+
*/
|
|
398
|
+
getRightVector: (rot) => {
|
|
399
|
+
return exports.RotatorUtils.getAxes(rot).right;
|
|
400
|
+
},
|
|
401
|
+
/**
|
|
402
|
+
* Returns the unit up vector (+Z) for this rotation.
|
|
403
|
+
*/
|
|
404
|
+
getUpVector: (rot) => {
|
|
405
|
+
return exports.RotatorUtils.getAxes(rot).up;
|
|
406
|
+
},
|
|
407
|
+
/**
|
|
408
|
+
* Normalizes all components (Pitch, Yaw, Roll) to [-180, 180) degrees.
|
|
409
|
+
* Matches Unreal's `FRotator::GetNormalized()`. Undefined components default to 0.
|
|
410
|
+
*/
|
|
411
|
+
normalize: (rot) => {
|
|
412
|
+
const r = resolveRotator(rot);
|
|
413
|
+
return {
|
|
414
|
+
pitch: normalizeAxis(r.pitch),
|
|
415
|
+
yaw: normalizeAxis(r.yaw),
|
|
416
|
+
roll: normalizeAxis(r.roll)
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
/**
|
|
420
|
+
* Calculates the angular difference (to - from) with all components normalized to [-180, 180).
|
|
421
|
+
* Undefined components default to 0.
|
|
422
|
+
*/
|
|
423
|
+
delta: (from, to) => {
|
|
424
|
+
const rf = resolveRotator(from);
|
|
425
|
+
const rt = resolveRotator(to);
|
|
426
|
+
return {
|
|
427
|
+
pitch: normalizeAxis(rt.pitch - rf.pitch),
|
|
428
|
+
yaw: normalizeAxis(rt.yaw - rf.yaw),
|
|
429
|
+
roll: normalizeAxis(rt.roll - rf.roll)
|
|
430
|
+
};
|
|
431
|
+
},
|
|
432
|
+
/**
|
|
433
|
+
* Calculates the absolute angular distance in degrees between two 3D orientations (0° to 180°).
|
|
434
|
+
* Undefined components default to 0.
|
|
435
|
+
*/
|
|
436
|
+
angularDistance: (a, b) => {
|
|
437
|
+
const fwdA = exports.RotatorUtils.getForwardVector(a);
|
|
438
|
+
const fwdB = exports.RotatorUtils.getForwardVector(b);
|
|
439
|
+
const dot = Math.max(-1, Math.min(1, fwdA.x * fwdB.x + fwdA.y * fwdB.y + fwdA.z * fwdB.z));
|
|
440
|
+
return cleanFloat(Math.acos(dot) * RAD_TO_DEG);
|
|
441
|
+
},
|
|
442
|
+
/**
|
|
443
|
+
* Calculates the absolute difference between two yaw angles in degrees (0° to 180°).
|
|
444
|
+
* Undefined components default to 0.
|
|
445
|
+
*/
|
|
446
|
+
yawDifference: (a, b) => {
|
|
447
|
+
const yawA = typeof a === 'number' ? a : (a?.yaw ?? 0);
|
|
448
|
+
const yawB = typeof b === 'number' ? b : (b?.yaw ?? 0);
|
|
449
|
+
return Math.abs(normalizeAxis(yawA - yawB));
|
|
450
|
+
},
|
|
451
|
+
/**
|
|
452
|
+
* Checks if two Rotators are approximately equal within a tolerance in degrees.
|
|
453
|
+
* Handles 360-degree wrapping (e.g. 179° and -179° are within 2° of each other).
|
|
454
|
+
* Undefined components default to 0.
|
|
455
|
+
*/
|
|
456
|
+
isNearlyEqual: (a, b, toleranceDegrees = 0.5) => {
|
|
457
|
+
const ra = resolveRotator(a);
|
|
458
|
+
const rb = resolveRotator(b);
|
|
459
|
+
return Math.abs(normalizeAxis(ra.pitch - rb.pitch)) <= toleranceDegrees &&
|
|
460
|
+
Math.abs(normalizeAxis(ra.yaw - rb.yaw)) <= toleranceDegrees &&
|
|
461
|
+
Math.abs(normalizeAxis(ra.roll - rb.roll)) <= toleranceDegrees;
|
|
462
|
+
},
|
|
463
|
+
/**
|
|
464
|
+
* Interpolates smoothly from Rotator A to B taking the shortest angular path.
|
|
465
|
+
* Undefined components default to 0.
|
|
466
|
+
*/
|
|
467
|
+
lerp: (from, to, alpha) => {
|
|
468
|
+
const rf = resolveRotator(from);
|
|
469
|
+
const d = exports.RotatorUtils.delta(from, to);
|
|
470
|
+
return {
|
|
471
|
+
pitch: normalizeAxis(rf.pitch + d.pitch * alpha),
|
|
472
|
+
yaw: normalizeAxis(rf.yaw + d.yaw * alpha),
|
|
473
|
+
roll: normalizeAxis(rf.roll + d.roll * alpha)
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
// ==========================================
|
|
478
|
+
// TOP-LEVEL CONVENIENCE HELPERS
|
|
479
|
+
// ==========================================
|
|
480
|
+
/**
|
|
481
|
+
* Calculates the FRotator required to face from point `from` towards point `to`.
|
|
482
|
+
* Identical to Unreal Engine's `UKismetMathLibrary::FindLookAtRotation`.
|
|
483
|
+
* Undefined components default to 0.
|
|
484
|
+
*/
|
|
485
|
+
function findLookAtRotation(from, to) {
|
|
486
|
+
return exports.RotatorUtils.fromVectors(from, to);
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Alias for `findLookAtRotation`: calculates the rotation between two 3D positions.
|
|
490
|
+
* Undefined components default to 0.
|
|
491
|
+
*/
|
|
492
|
+
function getRotationBetween(from, to) {
|
|
493
|
+
return exports.RotatorUtils.fromVectors(from, to);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Calculates the Euclidean distance between two 3D points.
|
|
497
|
+
* Undefined components default to 0.
|
|
498
|
+
*/
|
|
499
|
+
function calculateDistance(a, b) {
|
|
500
|
+
return exports.VectorUtils.distance(a, b);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Calculates the 2D Euclidean distance on the ground plane (XY only).
|
|
504
|
+
* Undefined components default to 0.
|
|
505
|
+
*/
|
|
506
|
+
function calculateDistance2D(a, b) {
|
|
507
|
+
return exports.VectorUtils.distance2D(a, b);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Normalizes all components of a Rotator to [-180, 180) degrees.
|
|
511
|
+
* Undefined components default to 0.
|
|
512
|
+
*/
|
|
513
|
+
function normalizeRotator(rot) {
|
|
514
|
+
return exports.RotatorUtils.normalize(rot);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Calculates the angular delta between two Rotators (to - from), wrapping shortest-path to [-180, 180).
|
|
518
|
+
* Undefined components default to 0.
|
|
519
|
+
*/
|
|
520
|
+
function deltaRotator(from, to) {
|
|
521
|
+
return exports.RotatorUtils.delta(from, to);
|
|
522
|
+
}
|
|
@@ -45,7 +45,8 @@ class SpecterPreview {
|
|
|
45
45
|
* Shows a fixed place: a sphere of `radius` (default 1500) around `location`, from above at an angle.
|
|
46
46
|
*/
|
|
47
47
|
async at(location, options) {
|
|
48
|
-
|
|
48
|
+
const loc = { x: location.x ?? 0, y: location.y ?? 0, z: location.z ?? 0 };
|
|
49
|
+
return this.send({ mode: 'at', location: loc, radius: options?.radius ?? 0 }, `at (${Math.round(loc.x)}, ${Math.round(loc.y)}, ${Math.round(loc.z)})`);
|
|
49
50
|
}
|
|
50
51
|
/** Shows the player's view, as the game draws it. */
|
|
51
52
|
async player() {
|
|
@@ -270,7 +270,8 @@ class SpecterReporter {
|
|
|
270
270
|
recordedEvents = new Map();
|
|
271
271
|
send(payload) {
|
|
272
272
|
const msg = JSON.stringify(payload);
|
|
273
|
-
|
|
273
|
+
if (process.env.SPECTER_REPORTER_DEBUG)
|
|
274
|
+
console.log(`[REPORTER WEBSOCKET SEND]: ${msg}`);
|
|
274
275
|
const testName = payload.payload?.testName;
|
|
275
276
|
if (testName) {
|
|
276
277
|
let events = this.recordedEvents.get(testName);
|
|
@@ -367,7 +368,8 @@ class SpecterReporter {
|
|
|
367
368
|
return ''; // Return empty string if no valid parent is found (makes it a Root node)
|
|
368
369
|
}
|
|
369
370
|
onStepBegin(test, result, step) {
|
|
370
|
-
|
|
371
|
+
if (process.env.SPECTER_REPORTER_DEBUG)
|
|
372
|
+
console.log(`[REPORTER DEBUG] Step Begin: "${step.title}" | Category: "${step.category}" | Parent: "${step.parent ? step.parent.title : 'None'}" ("${step.parent ? step.parent.category : ''}")`);
|
|
371
373
|
// 1. Playwright's outer expect step for a Specter matcher: announced by its wrapper step below,
|
|
372
374
|
// which carries the locator in its title.
|
|
373
375
|
if (step.category === 'expect' && (0, specter_matcher_report_1.parseSpecterExpectTitle)(step.title)) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { test, expect, type SpecterTestOptions } from './core/test-wrapper';
|
|
2
|
-
export { SpecterTransport, SpecterWorld, VectorUtils } from './core/specter-client';
|
|
2
|
+
export { SpecterTransport, SpecterWorld, VectorUtils, RotatorUtils, resolveVector3, resolveRotator, normalizeAxis, findLookAtRotation, getRotationBetween, calculateDistance, calculateDistance2D, normalizeRotator, deltaRotator } from './core/specter-client';
|
|
3
3
|
export type { SpecterPayload, SpawnOptions, Vector3, Rotator, Transform, HitResult, LinearColor, Color, Vector2D, SpecterRegistry, SpecterFunctionRegistry, LoadMapOptions, SpecterGrantedAbility, SpecterActiveEffect, SpecterActorSnapshot, RegisteredGameplayTags } from './core/specter-client';
|
|
4
4
|
export { SpecterLocator, WidgetLocator, ActorLocator, AiControllerLocator, type WidgetGeometry, type WidgetFilterOptions } from './core/locators';
|
|
5
5
|
export { default as SpecterReporter } from './core/specter-reporter';
|
|
@@ -9,6 +9,7 @@ export type { SpecterMatcherReport } from './core/specter-matcher-report';
|
|
|
9
9
|
export { SPECTER_PERF_ATTACHMENT, describeHitch, describeHitches, summarizeCapture } from './core/specter-perf';
|
|
10
10
|
export type { PerformanceCapture, PerformanceHitch, PerformanceStat, MeasurePerformanceOptions } from './core/specter-perf';
|
|
11
11
|
export { describeBehaviorTrail, describeNodePath } from './core/specter-ai-trail';
|
|
12
|
+
export { formatDebugDiagnostics, type CollisionDescription, type CollisionResponse, type TraceResult, type PerceptionResult, type NavPathResult, type OverlapResult, type EngineLog, type EngineLogEntry, type StateHistory, type StateSample, type ActorStateSample, type StuckAI } from './core/specter-debug';
|
|
12
13
|
export type { BehaviorTrail, BehaviorTrailEvent, DescribeBehaviorTrailOptions } from './core/specter-ai-trail';
|
|
13
14
|
export type { UnrealKey } from './core/specter-keys';
|
|
14
15
|
export type { SpecterActorEvents, SpecterWidgetEvents, SpecterWorldEvents, CustomActorEvents, CustomWidgetEvents, CustomWorldEvents, ActorEventMap, WidgetEventMap, WorldEventMap, EventPredicate, WaitForEventOptions } from './core/events';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.visualExpect = exports.performanceExpect = exports.aiExpect = exports.materialExpect = exports.runConditionalInputLoop = exports.evaluateCondition = exports.SpecterPreview = exports.SpecterNetwork = exports.SpecterInputSequence = exports.describeNodePath = exports.describeBehaviorTrail = exports.summarizeCapture = exports.describeHitches = exports.describeHitch = exports.SPECTER_PERF_ATTACHMENT = exports.SPECTER_MATCHER_ATTACHMENT = exports.expectAll = exports.SpecterReporter = exports.AiControllerLocator = exports.ActorLocator = exports.WidgetLocator = exports.SpecterLocator = exports.VectorUtils = exports.SpecterWorld = exports.SpecterTransport = exports.expect = exports.test = void 0;
|
|
6
|
+
exports.visualExpect = exports.performanceExpect = exports.aiExpect = exports.materialExpect = exports.runConditionalInputLoop = exports.evaluateCondition = exports.SpecterPreview = exports.SpecterNetwork = exports.SpecterInputSequence = exports.formatDebugDiagnostics = exports.describeNodePath = exports.describeBehaviorTrail = exports.summarizeCapture = exports.describeHitches = exports.describeHitch = exports.SPECTER_PERF_ATTACHMENT = exports.SPECTER_MATCHER_ATTACHMENT = exports.expectAll = exports.SpecterReporter = exports.AiControllerLocator = exports.ActorLocator = exports.WidgetLocator = exports.SpecterLocator = exports.deltaRotator = exports.normalizeRotator = exports.calculateDistance2D = exports.calculateDistance = exports.getRotationBetween = exports.findLookAtRotation = exports.normalizeAxis = exports.resolveRotator = exports.resolveVector3 = exports.RotatorUtils = exports.VectorUtils = exports.SpecterWorld = exports.SpecterTransport = exports.expect = exports.test = void 0;
|
|
7
7
|
var test_wrapper_1 = require("./core/test-wrapper");
|
|
8
8
|
Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_wrapper_1.test; } });
|
|
9
9
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_wrapper_1.expect; } });
|
|
@@ -11,6 +11,16 @@ var specter_client_1 = require("./core/specter-client");
|
|
|
11
11
|
Object.defineProperty(exports, "SpecterTransport", { enumerable: true, get: function () { return specter_client_1.SpecterTransport; } });
|
|
12
12
|
Object.defineProperty(exports, "SpecterWorld", { enumerable: true, get: function () { return specter_client_1.SpecterWorld; } });
|
|
13
13
|
Object.defineProperty(exports, "VectorUtils", { enumerable: true, get: function () { return specter_client_1.VectorUtils; } });
|
|
14
|
+
Object.defineProperty(exports, "RotatorUtils", { enumerable: true, get: function () { return specter_client_1.RotatorUtils; } });
|
|
15
|
+
Object.defineProperty(exports, "resolveVector3", { enumerable: true, get: function () { return specter_client_1.resolveVector3; } });
|
|
16
|
+
Object.defineProperty(exports, "resolveRotator", { enumerable: true, get: function () { return specter_client_1.resolveRotator; } });
|
|
17
|
+
Object.defineProperty(exports, "normalizeAxis", { enumerable: true, get: function () { return specter_client_1.normalizeAxis; } });
|
|
18
|
+
Object.defineProperty(exports, "findLookAtRotation", { enumerable: true, get: function () { return specter_client_1.findLookAtRotation; } });
|
|
19
|
+
Object.defineProperty(exports, "getRotationBetween", { enumerable: true, get: function () { return specter_client_1.getRotationBetween; } });
|
|
20
|
+
Object.defineProperty(exports, "calculateDistance", { enumerable: true, get: function () { return specter_client_1.calculateDistance; } });
|
|
21
|
+
Object.defineProperty(exports, "calculateDistance2D", { enumerable: true, get: function () { return specter_client_1.calculateDistance2D; } });
|
|
22
|
+
Object.defineProperty(exports, "normalizeRotator", { enumerable: true, get: function () { return specter_client_1.normalizeRotator; } });
|
|
23
|
+
Object.defineProperty(exports, "deltaRotator", { enumerable: true, get: function () { return specter_client_1.deltaRotator; } });
|
|
14
24
|
var locators_1 = require("./core/locators");
|
|
15
25
|
Object.defineProperty(exports, "SpecterLocator", { enumerable: true, get: function () { return locators_1.SpecterLocator; } });
|
|
16
26
|
Object.defineProperty(exports, "WidgetLocator", { enumerable: true, get: function () { return locators_1.WidgetLocator; } });
|
|
@@ -30,6 +40,8 @@ Object.defineProperty(exports, "summarizeCapture", { enumerable: true, get: func
|
|
|
30
40
|
var specter_ai_trail_1 = require("./core/specter-ai-trail");
|
|
31
41
|
Object.defineProperty(exports, "describeBehaviorTrail", { enumerable: true, get: function () { return specter_ai_trail_1.describeBehaviorTrail; } });
|
|
32
42
|
Object.defineProperty(exports, "describeNodePath", { enumerable: true, get: function () { return specter_ai_trail_1.describeNodePath; } });
|
|
43
|
+
var specter_debug_1 = require("./core/specter-debug");
|
|
44
|
+
Object.defineProperty(exports, "formatDebugDiagnostics", { enumerable: true, get: function () { return specter_debug_1.formatDebugDiagnostics; } });
|
|
33
45
|
var specter_input_sequence_1 = require("./core/specter-input-sequence");
|
|
34
46
|
Object.defineProperty(exports, "SpecterInputSequence", { enumerable: true, get: function () { return specter_input_sequence_1.SpecterInputSequence; } });
|
|
35
47
|
var specter_network_1 = require("./core/specter-network");
|