@specter-automation/test 1.0.148 → 1.0.149

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.
@@ -151,7 +151,33 @@ export interface Vector2D {
151
151
  X?: number;
152
152
  Y?: number;
153
153
  }
154
+ /**
155
+ * Vector maths for the plain `{ x, y, z }` objects Specter returns (TypeScript has no operator overloading,
156
+ * so `a + b` on two vectors won't work). Every function returns a new vector and leaves its inputs alone.
157
+ *
158
+ * @example
159
+ * const { add, distance2D } = VectorUtils;
160
+ * await boss.setLocation(add(home, { x: 2100, y: 0, z: 0 }));
161
+ * expect(distance2D(await hero.getLocation(), start)).toBeLessThan(40);
162
+ */
154
163
  export declare const VectorUtils: {
164
+ /** `a + b` */
165
+ add: (a: Vector3, b: Vector3) => Vector3;
166
+ /** `a - b`: the vector from `b` to `a` */
167
+ sub: (a: Vector3, b: Vector3) => Vector3;
168
+ /** `v * scalar` */
169
+ scale: (v: Vector3, scalar: number) => Vector3;
170
+ /** Length of `v` */
171
+ length: (v: Vector3) => number;
172
+ /** `v` scaled to length 1; a zero vector stays zero */
173
+ normalize: (v: Vector3) => Vector3;
174
+ /** Dot product of `a` and `b` */
175
+ dot: (a: Vector3, b: Vector3) => number;
176
+ /** Distance between `a` and `b` */
177
+ distance: (a: Vector3, b: Vector3) => number;
178
+ /** Distance between `a` and `b` on the ground (x and y only), so height doesn't count */
179
+ distance2D: (a: Vector3, b: Vector3) => number;
180
+ /** `location + direction * offset`: a point `offset` units along `direction` from `location` */
155
181
  addOffset: (location: Vector3, direction: Vector3, offset: number) => Vector3;
156
182
  };
157
183
  export interface Rotator {
@@ -23,7 +23,36 @@ var SpecterEventType;
23
23
  /** An AI's logic moved, a blackboard key changed, or its tree started or finished (the AI trail) */
24
24
  SpecterEventType["AIState"] = "AIState";
25
25
  })(SpecterEventType || (exports.SpecterEventType = SpecterEventType = {}));
26
+ /**
27
+ * Vector maths for the plain `{ x, y, z }` objects Specter returns (TypeScript has no operator overloading,
28
+ * so `a + b` on two vectors won't work). Every function returns a new vector and leaves its inputs alone.
29
+ *
30
+ * @example
31
+ * const { add, distance2D } = VectorUtils;
32
+ * await boss.setLocation(add(home, { x: 2100, y: 0, z: 0 }));
33
+ * expect(distance2D(await hero.getLocation(), start)).toBeLessThan(40);
34
+ */
26
35
  exports.VectorUtils = {
36
+ /** `a + b` */
37
+ add: (a, b) => ({ x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }),
38
+ /** `a - b`: the vector from `b` to `a` */
39
+ sub: (a, b) => ({ x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }),
40
+ /** `v * scalar` */
41
+ scale: (v, scalar) => ({ x: v.x * scalar, y: v.y * scalar, z: v.z * scalar }),
42
+ /** Length of `v` */
43
+ length: (v) => Math.hypot(v.x, v.y, v.z),
44
+ /** `v` scaled to length 1; a zero vector stays zero */
45
+ normalize: (v) => {
46
+ const len = Math.hypot(v.x, v.y, v.z);
47
+ return len === 0 ? { x: 0, y: 0, z: 0 } : { x: v.x / len, y: v.y / len, z: v.z / len };
48
+ },
49
+ /** Dot product of `a` and `b` */
50
+ dot: (a, b) => a.x * b.x + a.y * b.y + a.z * b.z,
51
+ /** Distance between `a` and `b` */
52
+ distance: (a, b) => Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z),
53
+ /** Distance between `a` and `b` on the ground (x and y only), so height doesn't count */
54
+ distance2D: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
55
+ /** `location + direction * offset`: a point `offset` units along `direction` from `location` */
27
56
  addOffset: (location, direction, offset) => {
28
57
  return {
29
58
  x: location.x + (direction.x * offset),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specter-automation/test",
3
- "version": "1.0.148",
3
+ "version": "1.0.149",
4
4
  "description": "Playwright integration for Unreal Engine automation via Specter",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",