@casual-simulation/aux-common 3.0.10 → 3.0.13-alpha.2430479070

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.
Files changed (47) hide show
  1. package/aux-format-2/AuxCausalTree2.js +40 -5
  2. package/aux-format-2/AuxCausalTree2.js.map +1 -1
  3. package/bots/Bot.d.ts +8 -0
  4. package/bots/Bot.js +10 -0
  5. package/bots/Bot.js.map +1 -1
  6. package/bots/BotCalculations.d.ts +47 -7
  7. package/bots/BotCalculations.js +172 -15
  8. package/bots/BotCalculations.js.map +1 -1
  9. package/bots/test/BotCalculationContextTests.js +58 -6
  10. package/bots/test/BotCalculationContextTests.js.map +1 -1
  11. package/bots/test/BotTestHelpers.d.ts +4 -0
  12. package/bots/test/BotTestHelpers.js +67 -0
  13. package/bots/test/BotTestHelpers.js.map +1 -1
  14. package/math/Quaternion.d.ts +94 -0
  15. package/math/Quaternion.js +128 -0
  16. package/math/Quaternion.js.map +1 -0
  17. package/math/Rotation.d.ts +274 -0
  18. package/math/Rotation.js +378 -0
  19. package/math/Rotation.js.map +1 -0
  20. package/math/Vector2.d.ts +251 -0
  21. package/math/Vector2.js +287 -0
  22. package/math/Vector2.js.map +1 -0
  23. package/math/Vector3.d.ts +318 -0
  24. package/math/Vector3.js +370 -0
  25. package/math/Vector3.js.map +1 -0
  26. package/math/index.d.ts +5 -0
  27. package/math/index.js +5 -0
  28. package/math/index.js.map +1 -0
  29. package/package.json +4 -4
  30. package/partitions/MemoryPartition.js +23 -4
  31. package/partitions/MemoryPartition.js.map +1 -1
  32. package/partitions/RemoteYjsPartition.d.ts +2 -0
  33. package/partitions/RemoteYjsPartition.js +11 -4
  34. package/partitions/RemoteYjsPartition.js.map +1 -1
  35. package/partitions/YjsPartition.js +8 -0
  36. package/partitions/YjsPartition.js.map +1 -1
  37. package/runtime/AuxLibrary.d.ts +17 -40
  38. package/runtime/AuxLibrary.js +183 -68
  39. package/runtime/AuxLibrary.js.map +1 -1
  40. package/runtime/AuxLibraryDefinitions.def +587 -10
  41. package/runtime/AuxRuntime.js +26 -1
  42. package/runtime/AuxRuntime.js.map +1 -1
  43. package/runtime/Utils.js +12 -4
  44. package/runtime/Utils.js.map +1 -1
  45. package/partitions/test/PartitionTests.d.ts +0 -8
  46. package/partitions/test/PartitionTests.js +0 -1548
  47. package/partitions/test/PartitionTests.js.map +0 -1
@@ -2941,6 +2941,33 @@ declare interface Point3D {
2941
2941
  z: number;
2942
2942
  }
2943
2943
 
2944
+ /**
2945
+ * Defines a 3D rotation as Euler angles or a Quaternion.
2946
+ */
2947
+ declare interface RawRotation {
2948
+ /**
2949
+ * The amount to rotate around the X axis in radians.
2950
+ */
2951
+ x: number;
2952
+
2953
+ /**
2954
+ * The amount to rotate around the Y axis in radians.
2955
+ */
2956
+ y: number;
2957
+
2958
+ /**
2959
+ * The amount to rotate around the Z axis in radians.
2960
+ */
2961
+ z: number;
2962
+
2963
+ /**
2964
+ * The real part of the quaternion.
2965
+ * If provided, then the value will be interpreted as a quaternion.
2966
+ * Otherwise, it will be interpreted as euler angles.
2967
+ */
2968
+ w?: number;
2969
+ }
2970
+
2944
2971
  /**
2945
2972
  * Defines an interface that contains performance statistics about a inst.
2946
2973
  */
@@ -6227,6 +6254,497 @@ declare type DateTimeClass = typeof DateTime;
6227
6254
  // End Luxon Types
6228
6255
 
6229
6256
 
6257
+ // Begin Math Types
6258
+ type Vector2Class = typeof Vector2;
6259
+ type Vector3Class = typeof Vector3;
6260
+ type QuaternionClass = typeof Quaternion;
6261
+ type RotationClass = typeof Rotation;
6262
+ /**
6263
+ * Defines a class that represents a 2D point in space.
6264
+ */
6265
+ declare class Vector2 {
6266
+ /**
6267
+ * The X value of this vector.
6268
+ */
6269
+ x: number;
6270
+ /**
6271
+ * The Y value of this vector.
6272
+ */
6273
+ y: number;
6274
+ /**
6275
+ * Constructs a new 2D vector with the given X and Y values.
6276
+ * @param x The X value of the vector.
6277
+ * @param y The Y value of the vector.
6278
+ */
6279
+ constructor(x?: number, y?: number);
6280
+ /**
6281
+ * Creates a 2D vector with the given X and Y values that is normalized immediately upon creation.
6282
+ * @param x The X value of the vector.
6283
+ * @param y The Y value of the vector.
6284
+ */
6285
+ static createNormalized(x: number, y: number): Vector2;
6286
+ /**
6287
+ * Calculates the angle between the two given vectors and returns the result in radians.
6288
+ * @param first The first vector.
6289
+ * @param second The second vector.
6290
+ */
6291
+ static angleBetween(first: Vector2, second: Vector2): number;
6292
+ /**
6293
+ * Calculates the distance between the two given vectors and returns the result.
6294
+ * @param first The first vector.
6295
+ * @param second The second vector.
6296
+ */
6297
+ static distanceBetween(first: Vector2, second: Vector2): number;
6298
+ /**
6299
+ * Constructs a new vector that is the linear interpolation between the given start and end positions.
6300
+ * The degree that the result is interpolated is determined by the given amount parameter.
6301
+ * @param start The start position.
6302
+ * @param finish The end position.
6303
+ * @param amount The amount that the resulting position should be interpolated between the start and end positions. Values near 0 indicate rotations close to the first and values near 1 indicate rotations close to the second.
6304
+ */
6305
+ static interpolatePosition(start: Vector2, finish: Vector2, amount: number): Vector2;
6306
+ /**
6307
+ * Constructs a new vector that is the directional linear interpolation between the given start and end positions.
6308
+ * The degree that the result is interpolated is determined by the given amount parameter.
6309
+ *
6310
+ * This function works similarly to interpolatePosition(), except the result is always a normalized vector.
6311
+ *
6312
+ * @param start The start position.
6313
+ * @param finish The end position.
6314
+ * @param amount The amount that the resulting position should be interpolated between the start and end positions. Values near 0 indicate rotations close to the first and values near 1 indicate rotations close to the second.
6315
+ */
6316
+ static interpolateDirection(start: Vector2, finish: Vector2, amount: number): Vector2;
6317
+ /**
6318
+ * Adds this vector with the other vector and returns the result.
6319
+ * @param other The other vector to add with this vector.
6320
+ */
6321
+ add(other: Vector2): Vector2;
6322
+ /**
6323
+ * Subtracts the other vector from this vector and returns the result.
6324
+ * @param other The other vector that should be subtracted from this vector.
6325
+ */
6326
+ subtract(other: Vector2): Vector2;
6327
+ /**
6328
+ * Multiplies each component of this vector by the given value and returns the result.
6329
+ * @param scale The scale that should be applied to this vector.
6330
+ */
6331
+ multiplyScalar(scale: number): Vector2;
6332
+ /**
6333
+ * Multiplies this vector by the given other vector and returns the result.
6334
+ * @param other The other vector to multiply with this vector.
6335
+ */
6336
+ multiply(other: Vector2): Vector2;
6337
+ /**
6338
+ * Calculates the dot product of this vector compared to the given other vector.
6339
+ * Returns a number that is positive if the vectors point in the same direction,
6340
+ * negative if they point in opposite directions, and zero if they are perpendicular.
6341
+ * For normalized vectors, this value is clamped to 1 and -1.
6342
+ * @param other The other vector to calculate the dot product with.
6343
+ */
6344
+ dot(other: Vector2): number;
6345
+ /**
6346
+ * Calculates the length of this vector and returns the result.
6347
+ */
6348
+ length(): number;
6349
+ /**
6350
+ * Calculates the square length of this vector and returns the result.
6351
+ * This is equivalent to length^2, but it is faster to calculate than length because it doesn't require
6352
+ * calculating a square root.
6353
+ */
6354
+ squareLength(): number;
6355
+ /**
6356
+ * Calculates the normalized version of this vector and returns it.
6357
+ * A normalized vector is a vector whose length equals 1.
6358
+ *
6359
+ * Normalizing a vector preserves its directionality while making the length (i.e. scale) of it 1.
6360
+ */
6361
+ normalize(): Vector2;
6362
+ toString(): string;
6363
+ /**
6364
+ * Determines if this vector equals the other vector.
6365
+ * @param other The other vector.
6366
+ */
6367
+ equals(other: Vector2): boolean;
6368
+ }
6369
+ /**
6370
+ * Defines a class that represents a 3D point in space.
6371
+ */
6372
+ declare class Vector3 {
6373
+ /**
6374
+ * The X value of this vector.
6375
+ */
6376
+ x: number;
6377
+ /**
6378
+ * The Y value of this vector.
6379
+ */
6380
+ y: number;
6381
+ /**
6382
+ * The Z value of this vector.
6383
+ */
6384
+ z: number;
6385
+ /**
6386
+ * Constructs a new 3D vector with the given X and Y values.
6387
+ * @param x The X value of the vector.
6388
+ * @param y The Y value of the vector.
6389
+ * @param z The Z value of the vector.
6390
+ */
6391
+ constructor(x?: number, y?: number, z?: number);
6392
+ /**
6393
+ * Creates a 3D vector with the given X and Y values that is normalized immediately upon creation.
6394
+ * @param x The X value of the vector.
6395
+ * @param y The Y value of the vector.
6396
+ * @param z The Z value of the vector.
6397
+ */
6398
+ static createNormalized(x: number, y: number, z: number): Vector3;
6399
+ /**
6400
+ * Calculates the angle between the two given vectors and returns the result in radians.
6401
+ * @param first The first vector.
6402
+ * @param second The second vector.
6403
+ */
6404
+ static angleBetween(first: Vector3, second: Vector3): number;
6405
+ /**
6406
+ * Calculates the distance between the two given vectors and returns the result.
6407
+ * @param first The first vector.
6408
+ * @param second The second vector.
6409
+ */
6410
+ static distanceBetween(first: Vector3, second: Vector3): number;
6411
+ /**
6412
+ * Constructs a new vector that is the linear interpolation between the given start and end positions.
6413
+ * The degree that the result is interpolated is determined by the given amount parameter.
6414
+ * @param start The start position.
6415
+ * @param finish The end position.
6416
+ * @param amount The amount that the resulting position should be interpolated between the start and end positions. Values near 0 indicate rotations close to the first and values near 1 indicate rotations close to the second.
6417
+ */
6418
+ static interpolatePosition(start: Vector3, finish: Vector3, amount: number): Vector3;
6419
+ /**
6420
+ * Constructs a new vector that is the directional linear interpolation between the given start and end positions.
6421
+ * The degree that the result is interpolated is determined by the given amount parameter.
6422
+ *
6423
+ * This function works similarly to interpolatePosition(), except the result is always a normalized vector.
6424
+ *
6425
+ * @param start The start position.
6426
+ * @param finish The end position.
6427
+ * @param amount The amount that the resulting position should be interpolated between the start and end positions. Values near 0 indicate rotations close to the first and values near 1 indicate rotations close to the second.
6428
+ */
6429
+ static interpolateDirection(start: Vector3, finish: Vector3, amount: number): Vector3;
6430
+ /**
6431
+ * Adds this vector with the other vector and returns the result.
6432
+ * @param other The other vector to add with this vector.
6433
+ */
6434
+ add(other: Vector3): Vector3;
6435
+ /**
6436
+ * Subtracts the other vector from this vector and returns the result.
6437
+ * @param other The other vector that should be subtracted from this vector.
6438
+ */
6439
+ subtract(other: Vector3): Vector3;
6440
+ /**
6441
+ * Multiplies each component of this vector by the given value and returns the result.
6442
+ * @param scale The scale that should be applied to this vector.
6443
+ */
6444
+ multiplyScalar(scale: number): Vector3;
6445
+ /**
6446
+ * Multiplies this vector by the given other vector and returns the result.
6447
+ * @param other The other vector to multiply with this vector.
6448
+ */
6449
+ multiply(other: Vector3): Vector3;
6450
+ /**
6451
+ * Calculates the dot product of this vector compared to the given other vector.
6452
+ * Returns a number that is positive if the vectors point in the same direction,
6453
+ * negative if they point in opposite directions, and zero if they are perpendicular.
6454
+ * For normalized vectors, this value is clamped to 1 and -1.
6455
+ * @param other The other vector to calculate the dot product with.
6456
+ */
6457
+ dot(other: Vector3): number;
6458
+ /**
6459
+ * Calculates the cross product of this vector with the given other vector.
6460
+ * Returns a new vector that is perpendicular to both vectors.
6461
+ * Note that the order of the vectors greatly matters. For example, (1, 0, 0).cross(0, 1, 0) === (0, 0, 1) but (0, 1, 0).cross(1, 0, 0) === (0, 0, -1).
6462
+ * @param other The other vector to calculate the cross product with.
6463
+ */
6464
+ cross(other: Vector3): Vector3;
6465
+ /**
6466
+ * Calculates the length of this vector and returns the result.
6467
+ */
6468
+ length(): number;
6469
+ /**
6470
+ * Calculates the square length of this vector and returns the result.
6471
+ * This is equivalent to length^2, but it is faster to calculate than length because it doesn't require
6472
+ * calculating a square root.
6473
+ */
6474
+ squareLength(): number;
6475
+ /**
6476
+ * Calculates the normalized version of this vector and returns it.
6477
+ * A normalized vector is a vector whose length equals 1.
6478
+ */
6479
+ normalize(): Vector3;
6480
+ toString(): string;
6481
+ /**
6482
+ * Determines if this vector equals the other vector.
6483
+ */
6484
+ equals(other: Vector3): boolean;
6485
+ }
6486
+ /**
6487
+ * Defines a class that represents a Quaternion. That is, a representation of a 3D rotation.
6488
+ *
6489
+ * Quaternions are a mathematical representation of 3D transformations and are commonly used to calculate and apply rotations to 3D points.
6490
+ * They work by defining a quaterion such that q = w + x*i + y*j + z*k, where w, x, y, and z are real numbers and i, j, and k are imaginary numbers.
6491
+ * The basics of this is that x, y, and z define a vector that represents the rotation axis, and w defines an angle around which the rotation occurs.
6492
+ * However, because i, j, and k are included we can keep x, y, and z from incorrectly interacting with each other and so avoid common pitfalls like Gimbal lock.
6493
+ *
6494
+ * One little known feature of quaternions is that they can also represent reflections and also scale.
6495
+ * This is because there are two different ways to apply a quaternion to a 3D point:
6496
+ *
6497
+ * - quaterion * point * inverse(quaterion)
6498
+ *
6499
+ * This formula rotates and scales the point quaternion. The rotation occurs around the axis specified by the quaternion X, Y, and Z values.
6500
+ * Additionally, the point will be scaled by the length of the quaternion. (i.e. sqrt( x^2 + y^2 + z^2 + w^2 ))
6501
+ * This is why quaternions that are used to represent only rotations must be normalized.
6502
+ *
6503
+ * - quaternion * point * quaternion
6504
+ *
6505
+ * This formula reflects scales the point by the quaternion. The reflection occurs across the axis specified by the quaternion X, Y, and Z values.
6506
+ * Additionally, the point will be scaled by the length of the quaternion. (i.e. sqrt( x^2 + y^2 + z^2 + w^2 ))
6507
+ */
6508
+ declare class Quaternion {
6509
+ /**
6510
+ * The X value of the quaternion.
6511
+ */
6512
+ x: number;
6513
+ /**
6514
+ * The Y value of the quaternion.
6515
+ */
6516
+ y: number;
6517
+ /**
6518
+ * The Z value of the quaternion.
6519
+ */
6520
+ z: number;
6521
+ /**
6522
+ * The W value of the quaternion.
6523
+ */
6524
+ w: number;
6525
+ /**
6526
+ * Creates a new Quaternion with the given values.
6527
+ * @param x The X value.
6528
+ * @param y The Y value.
6529
+ * @param z The Z value.
6530
+ * @param w The W value.
6531
+ */
6532
+ constructor(x?: number, y?: number, z?: number, w?: number);
6533
+ /**
6534
+ * Multiplies this quaternion by the other quaternion and returns the result.
6535
+ * In quaternion math, multiplication can be used to combine quaternions together,
6536
+ * however unlike regular multiplication quaternion multiplication is order dependent.
6537
+ *
6538
+ * Which frame of reference you want to use depends on which order you use.
6539
+ * For example, q2.multiply(q1) starts with the identity, applies q1 to it, and then applies q2 to that.
6540
+ * Whereas, q1.multiply(q2) starts with the identity, applies q2 to it, and then applies q1 to that.
6541
+ *
6542
+ * @param other The other quaternion.
6543
+ */
6544
+ multiply(other: Quaternion): Quaternion;
6545
+ /**
6546
+ * Calculates the conjugate of this quaternion and returns the result.
6547
+ * The conjugate (or inverse) of a quaternion is similar to negating a number.
6548
+ * When you multiply a quaternion by its conjugate, the result is the identity quaternion.
6549
+ */
6550
+ invert(): Quaternion;
6551
+ /**
6552
+ * Gets the length of this vector. That is, the pathagorean theorem applied to X, Y, Z, and W.
6553
+ */
6554
+ length(): number;
6555
+ /**
6556
+ * Calculates the square length of this quaternion and returns the result.
6557
+ * This is equivalent to length^2, but it is faster to calculate than length because it doesn't require
6558
+ * calculating a square root.
6559
+ */
6560
+ squareLength(): number;
6561
+ /**
6562
+ * Calculates the normalized version of this quaternion and returns it.
6563
+ * A normalized quaternion is a quaternion whose length equals 1.
6564
+ *
6565
+ * Normalizing a quaternion preserves its rotation/reflection while making the length (i.e. scale) of it 1.
6566
+ */
6567
+ normalize(): Quaternion;
6568
+ toString(): string;
6569
+ /**
6570
+ * Determines if this quaternion equals the other quaternion.
6571
+ * @param other The other quaternion to apply.
6572
+ */
6573
+ equals(other: Quaternion): boolean;
6574
+ }
6575
+ /**
6576
+ * Defines a class that can represent geometric rotations.
6577
+ */
6578
+ declare class Rotation {
6579
+ private _q;
6580
+ /**
6581
+ * The quaternion that this rotation uses.
6582
+ */
6583
+ get quaternion(): Quaternion;
6584
+ /**
6585
+ * Creates a new rotation using the given parameters.
6586
+ * @param rotation The information that should be used to construct the rotation.
6587
+ */
6588
+ constructor(rotation?: FromToRotation | AxisAndAngle | QuaternionRotation | Quaternion | SequenceRotation | EulerAnglesRotation | LookRotation);
6589
+ /**
6590
+ * Constructs a new Quaternion from the given axis and angle.
6591
+ * @param axisAndAngle The object that contains the axis and angle values.
6592
+ */
6593
+ static quaternionFromAxisAndAngle(axisAndAngle: AxisAndAngle): Quaternion;
6594
+ /**
6595
+ * Constructs a new Quaternion from the given from/to rotation.
6596
+ * This is equivalent to calculating the cross product and angle between the two vectors and constructing an axis/angle quaternion.
6597
+ * @param fromToRotation The object that contains the from and to values.
6598
+ */
6599
+ static quaternionFromTo(fromToRotation: FromToRotation): Quaternion;
6600
+ /**
6601
+ * Constructs a new Quaternion from the given look rotation.
6602
+ * @param look The object that contains the look rotation values.
6603
+ */
6604
+ static quaternionLook(look: LookRotation): Quaternion;
6605
+ /**
6606
+ * Determines the angle between the two given quaternions and returns the result in radians.
6607
+ * @param first The first quaternion. Must be a quaterion that represents a rotation
6608
+ * @param second The second quaternion.
6609
+ */
6610
+ static angleBetween(first: Rotation, second: Rotation): number;
6611
+ /**
6612
+ * Constructs a new rotation that is the spherical linear interpolation between the given first and second rotations.
6613
+ * The degree that the result is interpolated is determined by the given amount parameter.
6614
+ * @param first The first rotation.
6615
+ * @param second The second rotation.
6616
+ * @param amount The amount that the resulting rotation should be interpolated between the first and second rotations. Values near 0 indicate rotations close to the first and values near 1 indicate rotations close to the second.
6617
+ */
6618
+ static interpolate(first: Rotation, second: Rotation, amount: number): Rotation;
6619
+ /**
6620
+ * Rotates the given Vector3 by this quaternion and returns a new vector containing the result.
6621
+ * @param vector The 3D vector that should be rotated.
6622
+ */
6623
+ rotateVector3(vector: Vector3): Vector3;
6624
+ /**
6625
+ * Rotates the given Vector2 by this quaternion and returns a new vector containing the result.
6626
+ * Note that rotations around any other axis than (0, 0, 1) or (0, 0, -1) can produce results that contain a Z component.
6627
+ * @param vector The 2D vector that should be rotated.
6628
+ */
6629
+ rotateVector2(vector: Vector2): Vector3;
6630
+ /**
6631
+ * Combines this rotation with the other rotation and returns a new rotation that represents the combination of the two.
6632
+ * @param other The other rotation.
6633
+ */
6634
+ combineWith(other: Rotation): Rotation;
6635
+ /**
6636
+ * Calculates the inverse rotation of this rotation and returns a new rotation with the result.
6637
+ */
6638
+ invert(): Rotation;
6639
+ /**
6640
+ * Gets the axis and angle that this rotation rotates around.
6641
+ */
6642
+ axisAndAngle(): AxisAndAngle;
6643
+ /**
6644
+ * Determines if this rotation equals the other rotation.
6645
+ * @param other The rotation to check.
6646
+ */
6647
+ equals(other: Rotation): boolean;
6648
+ toString(): string;
6649
+ }
6650
+ /**
6651
+ * Defines an interface that represents a from/to rotation.
6652
+ * That is, a rotation that is able to rotate a vector from the given vector direction to the given vector direction.
6653
+ */
6654
+ export interface FromToRotation {
6655
+ /**
6656
+ * The direction that the rotation should rotate from.
6657
+ */
6658
+ from: Vector3;
6659
+ /**
6660
+ * The direction that the rotation should rotate to.
6661
+ */
6662
+ to: Vector3;
6663
+ }
6664
+ /**
6665
+ * Defines an interface that represents an Axis and Angle pair.
6666
+ */
6667
+ export interface AxisAndAngle {
6668
+ /**
6669
+ * The axis about which the angle should rotate around.
6670
+ */
6671
+ axis: Vector3;
6672
+ /**
6673
+ * The number of radians that should be rotated around the axis.
6674
+ */
6675
+ angle: number;
6676
+ }
6677
+ /**
6678
+ * Defines an interface that represents an Euler Angles rotation.
6679
+ */
6680
+ export interface EulerAnglesRotation {
6681
+ euler: {
6682
+ /**
6683
+ * The amount to rotate around the X axis.
6684
+ */
6685
+ x: number;
6686
+ /**
6687
+ * The amount to rotate around the Y axis.
6688
+ */
6689
+ y: number;
6690
+ /**
6691
+ * The amount to rotate around the Z axis.
6692
+ */
6693
+ z: number;
6694
+ /**
6695
+ * The order that the rotations should be applied in.
6696
+ */
6697
+ order?: string;
6698
+ };
6699
+ }
6700
+ /**
6701
+ * Defines an interface that represents a sequence of rotations.
6702
+ */
6703
+ export interface SequenceRotation {
6704
+ /**
6705
+ * The sequence of successive rotations.
6706
+ */
6707
+ sequence: Rotation[];
6708
+ }
6709
+ export interface QuaternionRotation {
6710
+ quaternion: { x: number, y: number, z: number, w: number };
6711
+ }
6712
+
6713
+ /**
6714
+ * Defines an interface that represents a rotation transforms (0, 1, 0) and (0, 0, 1) to look along the given direction and upwards axes.
6715
+ */
6716
+ export interface LookRotation {
6717
+ /**
6718
+ * The direction that (0, 1, 0) should be pointing along after the rotation is applied.
6719
+ */
6720
+ direction: Vector3;
6721
+
6722
+ /**
6723
+ * The direction that the upward axis should be pointing along after the rotation is applied.
6724
+ * If the direction and upwards vectors are not perpendicular, then the direction will be prioritized and the angle between
6725
+ * upwards and the resulting upwards vector will be minimized.
6726
+ *
6727
+ * If direction and upwards are perpendicular, then applying the rotation to (0, 0, 1) will give the upwards vector.
6728
+ */
6729
+ upwards: Vector3;
6730
+
6731
+ /**
6732
+ * How errors with the direction and upwards vectors should be handled.
6733
+ * If the direction and upwards vectors are parallel or perpendicular, then it is not possible to create a rotation
6734
+ * that looks along the direction and uses the upwards vector. The upwards vector is essentially useless in this scenario
6735
+ * and as a result there are an infinite number of possible valid rotations that look along direction vector.
6736
+ *
6737
+ * This parameter provides two ways to handle this situation:
6738
+ *
6739
+ * - "error" indicates that an error should be thrown when this situation arises.
6740
+ * - "nudge" indicates that the direction vector should be nudged by a miniscule amount in an arbitrary direction.
6741
+ * This causes the upwards and direction vectors to no longer be parallel, but it can also cause rotation bugs when the direction and upwards are the same.
6742
+ */
6743
+ errorHandling: 'error' | 'nudge';
6744
+ }
6745
+
6746
+ // End Math Types
6747
+
6230
6748
  declare global {
6231
6749
 
6232
6750
  /**
@@ -6303,6 +6821,45 @@ declare global {
6303
6821
  */
6304
6822
  const DateTime: DateTimeClass;
6305
6823
 
6824
+ /**
6825
+ * Defines a class that represents a 2D point in space.
6826
+ */
6827
+ const Vector2: Vector2Class;
6828
+
6829
+ /**
6830
+ * Defines a class that represents a 3D point in space.
6831
+ */
6832
+ const Vector3: Vector3Class;
6833
+
6834
+ /**
6835
+ * Defines a class that represents a Quaternion. That is, a representation of a 3D rotation.
6836
+ *
6837
+ * Quaternions are a mathematical representation of 3D transformations and are commonly used to calculate and apply rotations to 3D points.
6838
+ * They work by defining a quaterion such that q = w + x*i + y*j + z*k, where w, x, y, and z are real numbers and i, j, and k are imaginary numbers.
6839
+ * The basics of this is that x, y, and z define a vector that represents the rotation axis, and w defines an angle around which the rotation occurs.
6840
+ * However, because i, j, and k are included we can keep x, y, and z from incorrectly interacting with each other and so avoid common pitfalls like Gimbal lock.
6841
+ *
6842
+ * One little known feature of quaternions is that they can also represent reflections and also scale.
6843
+ * This is because there are two different ways to apply a quaternion to a 3D point:
6844
+ *
6845
+ * - quaterion * point * inverse(quaterion)
6846
+ *
6847
+ * This formula rotates and scales the point quaternion. The rotation occurs around the axis specified by the quaternion X, Y, and Z values.
6848
+ * Additionally, the point will be scaled by the length of the quaternion. (i.e. sqrt( x^2 + y^2 + z^2 + w^2 ))
6849
+ * This is why quaternions that are used to represent only rotations must be normalized.
6850
+ *
6851
+ * - quaternion * point * quaternion
6852
+ *
6853
+ * This formula reflects scales the point by the quaternion. The reflection occurs across the axis specified by the quaternion X, Y, and Z values.
6854
+ * Additionally, the point will be scaled by the length of the quaternion. (i.e. sqrt( x^2 + y^2 + z^2 + w^2 ))
6855
+ */
6856
+ const Quaternion: QuaternionClass;
6857
+
6858
+ /**
6859
+ * Defines a class that can represent geometric rotations.
6860
+ */
6861
+ const Rotation: RotationClass;
6862
+
6306
6863
  /**
6307
6864
  * Creates a new bot and returns it.
6308
6865
  * @param parent The bot that should be the parent of the new bot.
@@ -6512,7 +7069,7 @@ declare global {
6512
7069
  bot: (Bot | string)[] | Bot | string,
6513
7070
  eventName: string,
6514
7071
  arg?: any
6515
- ): any;
7072
+ ): any[];
6516
7073
 
6517
7074
  /**
6518
7075
  * Shouts the given event to every bot in every loaded simulation.
@@ -7001,7 +7558,17 @@ declare global {
7001
7558
  function getBotPosition(
7002
7559
  bot: Bot | string,
7003
7560
  dimension: string
7004
- ): Point3D;
7561
+ ): Vector3;
7562
+
7563
+ /**
7564
+ * Gets the rotation that the given bot is at in the given dimension.
7565
+ * @param bot The bot or bot ID.
7566
+ * @param dimension The dimension that the bot's rotation should be retrieved for.
7567
+ */
7568
+ function getBotRotation(
7569
+ bot: Bot | string,
7570
+ dimension: string
7571
+ ): Rotation;
7005
7572
 
7006
7573
  /**
7007
7574
  * Applies the given diff to the given bot.
@@ -7767,7 +8334,17 @@ interface Debugger {
7767
8334
  getBotPosition(
7768
8335
  bot: Bot | string,
7769
8336
  dimension: string
7770
- ): Point3D;
8337
+ ): Vector3;
8338
+
8339
+ /**
8340
+ * Gets the rotation that the given bot is at in the given dimension.
8341
+ * @param bot The bot or bot ID.
8342
+ * @param dimension The dimension that the bot's rotation should be retrieved for.
8343
+ */
8344
+ getBotRotation(
8345
+ bot: Bot | string,
8346
+ dimension: string
8347
+ ): Rotation;
7771
8348
 
7772
8349
  /**
7773
8350
  * Applies the given diff to the given bot.
@@ -7982,7 +8559,7 @@ interface Os {
7982
8559
  * Gets the 3D position of the player's camera.
7983
8560
  * @param portal The portal that the camera position should be retrieved for.
7984
8561
  */
7985
- getCameraPosition(portal?: 'grid' | 'miniGrid'): Point3D;
8562
+ getCameraPosition(portal?: 'grid' | 'miniGrid'): Vector3;
7986
8563
 
7987
8564
  /**
7988
8565
  * Gets the 3D rotation of the player's camera.
@@ -7994,13 +8571,13 @@ interface Os {
7994
8571
  * Gets the 3D point that the player's camera is focusing on.
7995
8572
  * @param portal The portal that the camera focus point should be retrieved for.
7996
8573
  */
7997
- getFocusPoint(portal?: 'grid' | 'miniGrid'): Point3D;
8574
+ getFocusPoint(portal?: 'grid' | 'miniGrid'): Vector3;
7998
8575
 
7999
8576
  /**
8000
8577
  * Gets the 3D position of the player's pointer.
8001
8578
  * @param pointer The position of the pointer to retrieve.
8002
8579
  */
8003
- getPointerPosition(pointer?: 'mouse' | 'left' | 'right'): Point3D;
8580
+ getPointerPosition(pointer?: 'mouse' | 'left' | 'right'): Vector3;
8004
8581
 
8005
8582
  /**
8006
8583
  * Gets the 3D rotation of the player's pointer.
@@ -8012,7 +8589,7 @@ interface Os {
8012
8589
  * Gets the 3D direction that the given pointer is pointing in.
8013
8590
  * @param pointer The pointer to get the direction of.
8014
8591
  */
8015
- getPointerDirection(pointer?: 'mouse' | 'left' | 'right'): Point3D;
8592
+ getPointerDirection(pointer?: 'mouse' | 'left' | 'right'): Vector3;
8016
8593
 
8017
8594
  /**
8018
8595
  * Gets the input state of the given button on the mouse.
@@ -9460,7 +10037,7 @@ interface Math {
9460
10037
  * Gets the forward direction for the given rotation.
9461
10038
  * @param pointerRotation The rotation that the pointer has represented in radians.
9462
10039
  */
9463
- getForwardDirection(pointerRotation: Point3D): Point3D;
10040
+ getForwardDirection(pointerRotation: RawRotation | Rotation): Vector3;
9464
10041
 
9465
10042
  /**
9466
10043
  * Finds the point at which the the given ray and ground plane intersect.
@@ -9468,14 +10045,14 @@ interface Math {
9468
10045
  * @param origin The origin of the ray.
9469
10046
  * @param direction The direction that the ray is pointing.
9470
10047
  */
9471
- intersectPlane(origin: Point3D, direction: Point3D): Point3D;
10048
+ intersectPlane(origin: Point3D, direction: Point3D): Vector3;
9472
10049
 
9473
10050
  /**
9474
10051
  * Gets the position offset for the given bot anchor point.
9475
10052
  * This is useful for doing custom math using anchor points.
9476
10053
  * @param anchorPoint The anchor point to get the offset for.
9477
10054
  */
9478
- getAnchorPointOffset(anchorPoint: BotAnchorPoint): Point3D;
10055
+ getAnchorPointOffset(anchorPoint: BotAnchorPoint): Vector3;
9479
10056
 
9480
10057
  /**
9481
10058
  * Adds the given vectors together and returns the result.