@woosh/meep-engine 2.102.0 → 2.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/build/meep.cjs +42 -35
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +42 -35
  4. package/package.json +1 -1
  5. package/src/core/geom/2d/circle/Circle.d.ts +0 -8
  6. package/src/core/geom/2d/circle/Circle.d.ts.map +1 -1
  7. package/src/core/geom/2d/circle/Circle.js +85 -85
  8. package/src/core/geom/ConicRay.d.ts +3 -1
  9. package/src/core/geom/ConicRay.d.ts.map +1 -1
  10. package/src/core/geom/ConicRay.js +7 -5
  11. package/src/core/geom/Vector1.d.ts.map +1 -1
  12. package/src/core/geom/Vector1.js +3 -0
  13. package/src/core/geom/Vector2.d.ts.map +1 -1
  14. package/src/core/geom/Vector2.js +6 -3
  15. package/src/core/geom/Vector3.js +1 -1
  16. package/src/core/geom/vec3/v3_angle_cos_between.spec.d.ts +2 -0
  17. package/src/core/geom/vec3/v3_angle_cos_between.spec.d.ts.map +1 -0
  18. package/src/core/geom/vec3/v3_angle_cos_between.spec.js +124 -0
  19. package/src/core/geom/vec3/v3_distance_above_plane.d.ts +13 -4
  20. package/src/core/geom/vec3/v3_distance_sqr.d.ts +12 -1
  21. package/src/core/geom/vec3/v3_length.d.ts +9 -1
  22. package/src/core/lang/reactive/compileReactiveExpression.d.ts.map +1 -1
  23. package/src/core/lang/reactive/compileReactiveExpression.js +1 -3
  24. package/src/core/lang/reactive/pegjs/ReactivePegCompiler.d.ts.map +1 -1
  25. package/src/core/lang/reactive/pegjs/ReactivePegCompiler.js +11 -5
  26. package/src/core/math/PI_RECIPROCAL.d.ts +6 -0
  27. package/src/core/math/PI_RECIPROCAL.d.ts.map +1 -0
  28. package/src/core/math/PI_RECIPROCAL.js +5 -0
  29. package/src/core/math/newton_solver_1d.d.ts +4 -3
  30. package/src/core/math/newton_solver_1d.d.ts.map +1 -1
  31. package/src/core/math/newton_solver_1d.js +4 -3
  32. package/src/core/math/physics/brdf/D_GGX.d.ts.map +1 -1
  33. package/src/core/math/physics/brdf/D_GGX.js +4 -1
  34. package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
  35. package/src/core/math/physics/brdf/brdf_burley.js +5 -1
  36. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.d.ts.map +1 -1
  37. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +3 -3
  38. package/src/core/primitives/strings/insert_after.spec.d.ts +2 -0
  39. package/src/core/primitives/strings/insert_after.spec.d.ts.map +1 -0
  40. package/src/core/primitives/strings/insert_after.spec.js +16 -0
  41. package/src/core/primitives/strings/insert_before.spec.d.ts +2 -0
  42. package/src/core/primitives/strings/insert_before.spec.d.ts.map +1 -0
  43. package/src/core/primitives/strings/insert_before.spec.js +16 -0
  44. package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  45. package/src/core/process/executor/ConcurrentExecutor.js +10 -4
  46. package/src/core/time/current_time_in_seconds.d.ts.map +1 -1
  47. package/src/core/time/current_time_in_seconds.js +1 -1
  48. package/src/engine/animation/curve/compute_curve_aabb.d.ts.map +1 -1
  49. package/src/engine/animation/curve/compute_curve_aabb.js +19 -16
  50. package/src/engine/ecs/fow/FogOfWar.d.ts.map +1 -1
  51. package/src/engine/ecs/fow/FogOfWar.js +10 -10
  52. package/src/engine/ecs/fow/FogOfWar.spec.js +5 -6
  53. package/src/engine/google/loadGTAG.d.ts +7 -0
  54. package/src/engine/google/loadGTAG.d.ts.map +1 -0
  55. package/src/engine/google/loadGTAG.js +32 -0
  56. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.d.ts.map +1 -1
  57. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +6 -1
  58. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.d.ts.map +1 -1
  59. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +17 -1
  60. package/src/engine/metrics/GoogleAnalyticsMetrics.d.ts +2 -1
  61. package/src/engine/metrics/GoogleAnalyticsMetrics.d.ts.map +1 -1
  62. package/src/engine/metrics/GoogleAnalyticsMetrics.js +4 -39
  63. package/src/engine/notify/NotificationLog.d.ts +1 -2
  64. package/src/engine/notify/NotificationLog.d.ts.map +1 -1
  65. package/src/engine/notify/NotificationLog.js +33 -32
  66. package/src/core/lang/reactive/nearley/Reactive.ne +0 -87
  67. package/src/engine/compression/CompressionService.d.ts +0 -19
  68. package/src/engine/compression/CompressionService.d.ts.map +0 -1
  69. package/src/engine/compression/CompressionService.js +0 -144
@@ -2476,7 +2476,7 @@ let Vector3$1 = class Vector3 {
2476
2476
  }
2477
2477
 
2478
2478
  /**
2479
- * @param {number} [squaredError=0.01]
2479
+ * @param {number} [squaredError]
2480
2480
  * @return {boolean}
2481
2481
  */
2482
2482
  isNormalized(squaredError = 0.01) {
@@ -47472,10 +47472,8 @@ function v2_dot(x0, y0, x1, y1) {
47472
47472
  class Vector2 {
47473
47473
  /**
47474
47474
  *
47475
- * @param {number} [x=0
47475
+ * @param {number} [x=0]
47476
47476
  * @param {number} [y=0]
47477
- * @property {number} x
47478
- * @property {number} y
47479
47477
  * @constructor
47480
47478
  */
47481
47479
  constructor(x = 0, y = 0) {
@@ -50396,6 +50394,7 @@ class Vector1 extends Number {
50396
50394
  * @param {number} x
50397
50395
  */
50398
50396
  setSilent(x) {
50397
+
50399
50398
  this.x = x;
50400
50399
  }
50401
50400
 
@@ -83404,7 +83403,7 @@ class ModuleRegistry {
83404
83403
  * @param {TaskGroup|Task} t
83405
83404
  * @returns {boolean}
83406
83405
  */
83407
- function isGroup(t) {
83406
+ function isGroupTask(t) {
83408
83407
  return t.children instanceof Array;
83409
83408
  }
83410
83409
 
@@ -83412,7 +83411,12 @@ function isGroup(t) {
83412
83411
  * @class
83413
83412
  */
83414
83413
  class ConcurrentExecutor {
83414
+ /**
83415
+ * How many time-slice cycles have been executed this far. This is a monotonically increasing counter
83416
+ * @type {number}
83417
+ */
83415
83418
  #cycle_count = 0;
83419
+
83416
83420
  /**
83417
83421
  * Handle of the last scheduled `setTimeout`
83418
83422
  * @type {number}
@@ -83524,7 +83528,7 @@ class ConcurrentExecutor {
83524
83528
  const child = children[i];
83525
83529
  child.on.completed.add(subTaskCompleted);
83526
83530
  child.on.failed.add(subTaskFailed);
83527
- if (isGroup(child)) {
83531
+ if (isGroupTask(child)) {
83528
83532
  this.runGroup(child);
83529
83533
  } else {
83530
83534
  this.run(child);
@@ -83547,7 +83551,7 @@ class ConcurrentExecutor {
83547
83551
  for (let i = 0; i < n; i++) {
83548
83552
  const child = children[i];
83549
83553
 
83550
- if (isGroup(child)) {
83554
+ if (isGroupTask(child)) {
83551
83555
  this.removeGroup(child);
83552
83556
  } else {
83553
83557
  this.removeTask(child);
@@ -83644,7 +83648,7 @@ class ConcurrentExecutor {
83644
83648
  }
83645
83649
 
83646
83650
  /**
83647
- * Go through unresolved queue and move tasks who's dependencies have been completed to ready queue or fail them
83651
+ * Go through unresolved queue and move tasks whose dependencies have been completed to ready queue or fail them
83648
83652
  */
83649
83653
  resolveTasks() {
83650
83654
  const queueUnresolved = this.queueUnresolved;
@@ -83681,6 +83685,7 @@ class ConcurrentExecutor {
83681
83685
  /**
83682
83686
  *
83683
83687
  * @param {Task} task
83688
+ * @returns {boolean}
83684
83689
  */
83685
83690
  contains(task) {
83686
83691
  if (this.queueUnresolved.indexOf(task) !== -1) {
@@ -96211,6 +96216,7 @@ const source = typeof performance === "undefined" ? Date : performance;
96211
96216
  * @returns {number}
96212
96217
  */
96213
96218
  function current_time_in_seconds() {
96219
+ // time source produces value in milliseconds, we need to scale to seconds
96214
96220
  return source.now() * 1e-3;
96215
96221
  }
96216
96222
 
@@ -102715,50 +102721,51 @@ Notification.prototype.isNotification = true;
102715
102721
  */
102716
102722
 
102717
102723
 
102718
- function NotificationLog() {
102724
+ class NotificationLog {
102719
102725
  /**
102720
102726
  * @readonly
102721
102727
  * @type {List<Notification>}
102722
102728
  */
102723
- this.elements = new List();
102729
+ elements = new List();
102724
102730
 
102725
102731
  /**
102726
102732
  * Once number of entries in the log reaches this amount, the earliest entries will be removed to make space for new ones
102727
102733
  * @type {number}
102728
102734
  */
102729
- this.maxLength = 1000;
102730
- }
102735
+ maxLength = 1000;
102731
102736
 
102732
- /**
102733
- *
102734
- * @param {{}} options See Notification.constructor for details
102735
- * @returns {Notification}
102736
- */
102737
- NotificationLog.prototype.add = function (options) {
102738
- const notification = new Notification(options);
102737
+ /**
102738
+ *
102739
+ * @param {{}} options See {@link Notification.constructor} for details
102740
+ * @returns {Notification}
102741
+ */
102742
+ add(options) {
102743
+ const notification = new Notification(options);
102739
102744
 
102740
- this.addNotification(notification);
102745
+ this.addNotification(notification);
102741
102746
 
102742
- return notification;
102743
- };
102747
+ return notification;
102748
+ }
102744
102749
 
102745
- /**
102746
- *
102747
- * @param {Notification} notification
102748
- */
102749
- NotificationLog.prototype.addNotification = function (notification) {
102750
+ /**
102751
+ *
102752
+ * @param {Notification} notification
102753
+ */
102754
+ addNotification(notification) {
102750
102755
 
102751
- // Crop notification log to size
102752
- const length = this.elements.length;
102756
+ // Crop notification log to size
102757
+ const length = this.elements.length;
102753
102758
 
102754
- const target = this.maxLength - 1;
102759
+ const target = this.maxLength - 1;
102755
102760
 
102756
- if (length > target) {
102757
- this.elements.crop(length - target, length);
102758
- }
102761
+ if (length > target) {
102762
+ // too many elements, drop some
102763
+ this.elements.crop(length - target, length);
102764
+ }
102759
102765
 
102760
- this.elements.add(notification);
102761
- };
102766
+ this.elements.add(notification);
102767
+ }
102768
+ }
102762
102769
 
102763
102770
  class LogDisplay {
102764
102771
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.102.0",
8
+ "version": "2.103.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,12 +1,4 @@
1
1
  export default Circle;
2
- /**
3
- * A circle or a 2-dimensional sphere. Represented as a position (x,y) and radius (r)
4
- * @param {Number} [x=0]
5
- * @param {Number} [y=0]
6
- * @param {Number} [r=0]
7
- * @constructor
8
- */
9
- declare function Circle(x?: number, y?: number, r?: number): void;
10
2
  declare class Circle {
11
3
  /**
12
4
  * A circle or a 2-dimensional sphere. Represented as a position (x,y) and radius (r)
@@ -1 +1 @@
1
- {"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/circle/Circle.js"],"names":[],"mappings":";AAEA;;;;;;GAMG;AACH,kEAkBC;;IAzBD;;;;;;OAMG;IACH,gDAkBC;IAjBG;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,UAAU;IAGd;;;OAGG;IACH,oCAEC;IAED;;;;OAIG;IACH,2CAGC;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,KACN,MAAM,QAOhB;IAED;;;OAGG;IACH,YAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,SAFa,MAAM,CAMlB"}
1
+ {"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/circle/Circle.js"],"names":[],"mappings":";AAEA;IACI;;;;;;OAMG;IACH,gDAkBC;IAjBG;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,UAAU;IAGd;;;OAGG;IACH,oCAEC;IAED;;;;OAIG;IACH,2CAGC;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,KACN,MAAM,QAOhB;IAED;;;OAGG;IACH,YAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;CACJ"}
@@ -1,105 +1,105 @@
1
1
  import { circle_intersects_circle } from "./circle_intersects_circle.js";
2
2
 
3
- /**
4
- * A circle or a 2-dimensional sphere. Represented as a position (x,y) and radius (r)
5
- * @param {Number} [x=0]
6
- * @param {Number} [y=0]
7
- * @param {Number} [r=0]
8
- * @constructor
9
- */
10
- function Circle(x = 0, y = 0, r = 0) {
3
+ class Circle {
11
4
  /**
12
- * Position along X axis
13
- * @type {Number}
5
+ * A circle or a 2-dimensional sphere. Represented as a position (x,y) and radius (r)
6
+ * @param {Number} [x=0]
7
+ * @param {Number} [y=0]
8
+ * @param {Number} [r=0]
9
+ * @constructor
14
10
  */
15
- this.x = x;
11
+ constructor(x = 0, y = 0, r = 0) {
12
+ /**
13
+ * Position along X axis
14
+ * @type {Number}
15
+ */
16
+ this.x = x;
17
+
18
+ /**
19
+ * Position along Y axis
20
+ * @type {Number}
21
+ */
22
+ this.y = y;
23
+
24
+ /**
25
+ * Radius
26
+ * @type {Number}
27
+ */
28
+ this.r = r;
29
+ }
16
30
 
17
31
  /**
18
- * Position along Y axis
19
- * @type {Number}
32
+ *
33
+ * @param {Vector2} target
20
34
  */
21
- this.y = y;
35
+ readPosition(target) {
36
+ target.set(this.x, this.y);
37
+ }
22
38
 
23
39
  /**
24
- * Radius
25
- * @type {Number}
40
+ *
41
+ * @param {Number} deltaX
42
+ * @param {Number} deltaY
26
43
  */
27
- this.r = r;
28
- }
29
-
30
- /**
31
- *
32
- * @param {Vector2} target
33
- */
34
- Circle.prototype.readPosition = function (target) {
35
- target.set(this.x, this.y);
36
- };
37
-
38
- /**
39
- *
40
- * @param {Number} deltaX
41
- * @param {Number} deltaY
42
- */
43
- Circle.prototype.move = function (deltaX, deltaY) {
44
- this.x += deltaX;
45
- this.y += deltaY;
46
- };
44
+ move(deltaX, deltaY) {
45
+ this.x += deltaX;
46
+ this.y += deltaY;
47
+ }
47
48
 
48
- /**
49
- *
50
- * @param {Circle} other
51
- * @returns {boolean}
52
- */
53
- Circle.prototype.overlaps = function (other) {
54
- const x0 = this.x;
55
- const y0 = this.y;
56
- const r0 = this.r;
57
-
58
- const x1 = other.x;
59
- const y1 = other.y;
60
- const r1 = other.r;
49
+ /**
50
+ *
51
+ * @param {Circle} other
52
+ * @returns {boolean}
53
+ */
54
+ overlaps(other) {
55
+ const x0 = this.x;
56
+ const y0 = this.y;
57
+ const r0 = this.r;
61
58
 
62
- return circle_intersects_circle(x0, y0, r0, x1, y1, r1);
63
- };
59
+ const x1 = other.x;
60
+ const y1 = other.y;
61
+ const r1 = other.r;
64
62
 
65
- /**
66
- *
67
- * @param {Circle} other
68
- * @returns {boolean}
69
- */
70
- Circle.prototype.equals = function (other) {
71
- return this.x === other.x && this.y === other.y && this.r === other.r;
72
- };
63
+ return circle_intersects_circle(x0, y0, r0, x1, y1, r1);
64
+ }
73
65
 
74
- /**
75
- *
76
- * @param {number} x
77
- * @param {number} y
78
- * @param {number} r
79
- */
80
- Circle.prototype.set = function (x, y, r) {
81
- this.x = x;
82
- this.y = y;
66
+ /**
67
+ *
68
+ * @param {Circle} other
69
+ * @returns {boolean}
70
+ */
71
+ equals(other) {
72
+ return this.x === other.x && this.y === other.y && this.r === other.r;
73
+ }
83
74
 
84
- this.r = r;
85
- };
75
+ /**
76
+ *
77
+ * @param {number} x
78
+ * @param {number} y
79
+ * @param {number} r
80
+ */
81
+ set(x, y, r) {
82
+ this.x = x;
83
+ this.y = y;
86
84
 
87
- /**
88
- *
89
- * @param {Circle} other
90
- */
91
- Circle.prototype.copy = function (other) {
92
- this.set(other.x, other.y, other.r);
93
- };
85
+ this.r = r;
86
+ }
94
87
 
95
- /**
96
- *
97
- * @returns {Circle}
98
- */
99
- Circle.prototype.clone = function () {
100
- const result = new Circle(this.x, this.y, this.r);
88
+ /**
89
+ *
90
+ * @param {Circle} other
91
+ */
92
+ copy(other) {
93
+ this.set(other.x, other.y, other.r);
94
+ }
101
95
 
102
- return result;
103
- };
96
+ /**
97
+ *
98
+ * @returns {Circle}
99
+ */
100
+ clone() {
101
+ return new Circle(this.x, this.y, this.r);
102
+ }
103
+ }
104
104
 
105
105
  export default Circle;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Represents a direction vector+angle
3
3
  * Mainly used inside particle systems for pick a motion direction at spawn
4
+ * @copyright "Company Named Limited"
4
5
  */
5
6
  export class ConicRay {
6
7
  /**
@@ -14,9 +15,10 @@ export class ConicRay {
14
15
  static fromScalars(x: number, y: number, z: number, angle: number): ConicRay;
15
16
  /**
16
17
  * Must be normalized
18
+ * @readonly
17
19
  * @type {Vector3}
18
20
  */
19
- direction: Vector3;
21
+ readonly direction: Vector3;
20
22
  /**
21
23
  * Half-angle of the cone, that is the angle between the center axis and the edge of the cone
22
24
  * In radians
@@ -1 +1 @@
1
- {"version":3,"file":"ConicRay.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/ConicRay.js"],"names":[],"mappings":"AAQA;;;GAGG;AACH;IA2KI;;;;;;;OAOG;IACH,sBANW,MAAM,KACN,MAAM,KACN,MAAM,SACN,MAAM,GACJ,QAAQ,CAWpB;IA1LD;;;OAGG;IACH,WAFU,OAAO,CAEgB;IAEjC;;;;OAIG;IACH,OAFU,MAAM,CAEN;IAEV;;;MAKC;IAED,0BAGC;IAED;;;OAGG;IACH,2CAGC;IAED;;;OAGG;IACH,6CAMC;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;;;OAKG;IACH,qBAJW,QAAQ,cACR,MAAM,GACJ,OAAO,CAKnB;IAED,eAKC;IAED;;;OAGG;IACH,YAFW,QAAQ,QAKlB;IAED;;;;OAIG;IACH,4BAHW,OAAO,GACL,OAAO,CAMnB;IAED;;;;;OAKG;IACH,gDAFW,OAAO,QAsEjB;CAoBJ;oBApMmB,cAAc"}
1
+ {"version":3,"file":"ConicRay.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/ConicRay.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH;IA4KI;;;;;;;OAOG;IACH,sBANW,MAAM,KACN,MAAM,KACN,MAAM,SACN,MAAM,GACJ,QAAQ,CAWpB;IA3LD;;;;OAIG;IACH,oBAFU,OAAO,CAEgB;IAEjC;;;;OAIG;IACH,OAFU,MAAM,CAEN;IAEV;;;MAKC;IAED,0BAGC;IAED;;;OAGG;IACH,2CAGC;IAED;;;OAGG;IACH,6CAMC;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;;;OAKG;IACH,qBAJW,QAAQ,cACR,MAAM,GACJ,OAAO,CAKnB;IAED,eAKC;IAED;;;OAGG;IACH,YAFW,QAAQ,QAKlB;IAED;;;;OAIG;IACH,4BAHW,OAAO,GACL,OAAO,CAMnB;IAED;;;;;OAKG;IACH,gDAFW,OAAO,QAsEjB;CAoBJ;oBAtMmB,cAAc"}
@@ -1,19 +1,21 @@
1
- import {assert} from "../assert.js";
2
- import {computeHashIntegerArray} from "../collection/array/computeHashIntegerArray.js";
3
- import {EPSILON} from "../math/EPSILON.js";
4
- import {epsilonEquals} from "../math/epsilonEquals.js";
5
- import {computeHashFloat} from "../primitives/numbers/computeHashFloat.js";
1
+ import { assert } from "../assert.js";
2
+ import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
3
+ import { EPSILON } from "../math/EPSILON.js";
4
+ import { epsilonEquals } from "../math/epsilonEquals.js";
5
+ import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
6
6
  import Vector3 from "./Vector3.js";
7
7
 
8
8
 
9
9
  /**
10
10
  * Represents a direction vector+angle
11
11
  * Mainly used inside particle systems for pick a motion direction at spawn
12
+ * @copyright "Company Named Limited"
12
13
  */
13
14
  export class ConicRay {
14
15
 
15
16
  /**
16
17
  * Must be normalized
18
+ * @readonly
17
19
  * @type {Vector3}
18
20
  */
19
21
  direction = new Vector3(0, 1, 0);
@@ -1 +1 @@
1
- {"version":3,"file":"Vector1.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector1.js"],"names":[],"mappings":";AAWA;IAwPI;;;;;OAKG;IACH,kBAJW,OAAO,KACP,OAAO,GACN,MAAM,CAIjB;IA/PD;;;;;;OAMG;IACH,gBALW,MAAM,EAchB;IAHG,UAAU;IAEV,0DAA6B;IAWjC;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,OAHW,MAAM,GACJ,OAAO,CAgBnB;IAED;;;OAGG;IACH,aAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,UAFY,OAAO,CAIlB;IAED,kBAEC;IAED,kBAEC;IAED;;;;OAIG;IACH,iBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,WAFW,OAAO,8BAAwB,WAIzC;IAED;;;;OAIG;IACH,iBAFY,OAAO,CAIlB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;OAIG;IACH,gBAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,WAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,OAAO,8BAAwB,QAIzC;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAInB;IAED;;OAEG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,4BAGC;IAED,iBAEC;IAED,yBAEC;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,EAAE,WACR,MAAM,QAIhB;IAED,oBAEC;IAED;;;OAGG;IACH,2CAEC;IAED;;;OAGG;IACH,6CAIC;IAgBD,mBAEC;IAND,gBAEC;IAaL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IAXvB,sDAIC;CACJ;;;cAYS,OAAO;aAMP,OAAO;;mBAtSE,4BAA4B"}
1
+ {"version":3,"file":"Vector1.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector1.js"],"names":[],"mappings":";AAWA;IA2PI;;;;;OAKG;IACH,kBAJW,OAAO,KACP,OAAO,GACN,MAAM,CAIjB;IAlQD;;;;;;OAMG;IACH,gBALW,MAAM,EAchB;IAHG,UAAU;IAEV,0DAA6B;IAWjC;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,OAHW,MAAM,GACJ,OAAO,CAgBnB;IAED;;;OAGG;IACH,aAFW,MAAM,QAOhB;IAED;;;OAGG;IACH,UAFY,OAAO,CAIlB;IAED,kBAEC;IAED,kBAEC;IAED;;;;OAIG;IACH,iBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,WAFW,OAAO,8BAAwB,WAIzC;IAED;;;;OAIG;IACH,iBAFY,OAAO,CAIlB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;OAIG;IACH,gBAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,WAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,OAAO,8BAAwB,QAIzC;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAInB;IAED;;OAEG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,4BAGC;IAED,iBAEC;IAED,yBAEC;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,EAAE,WACR,MAAM,QAIhB;IAED,oBAEC;IAED;;;OAGG;IACH,2CAEC;IAED;;;OAGG;IACH,6CAIC;IAgBD,mBAEC;IAND,gBAEC;IAaL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IAXvB,sDAIC;CACJ;;;cAYS,OAAO;aAMP,OAAO;;mBAzSE,4BAA4B"}
@@ -87,6 +87,9 @@ class Vector1 extends Number {
87
87
  * @param {number} x
88
88
  */
89
89
  setSilent(x) {
90
+ assert.isNumber( x,'x');
91
+ assert.notNaN(x, 'x');
92
+
90
93
  this.x = x;
91
94
  }
92
95
 
@@ -1 +1 @@
1
- {"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector2.js"],"names":[],"mappings":";AAmBA;IACI;;;;;;;OAOG;IACH,gBANW,MAAM,cA0BhB;IAbG;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV,0DAA6B;IAGjC;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAOhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,EAAE,WACR,MAAM,QAKhB;IAED,iBAMC;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAqBnB;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAOhB;IAED;;;;OAIG;IACH,QAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,QAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;OAKG;IACH,QAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,OAAO,KACP,OAAO,QAIjB;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,OAAO,CAInB;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,OAFa,OAAO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N,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,eAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,2BAHW,OAAO,GACL,MAAM,CAOlB;IAED;;OAEG;IACH,UAFa,MAAM,CAIlB;IAED;;OAEG;IACH,kBAWC;IAGD;;;OAGG;IACH,QAFa,MAAM,CAOlB;IAED;;;OAGG;IACH,cAFW,MAAM,QAahB;IAED;;;;;OAKG;IACH,6CAFa,OAAO,CAQnB;IAED,mBAEC;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,qBAJW,OAAO,cACP,MAAM,GACL,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,cACN,MAAM,GACL,OAAO,CAKlB;IAUD,mBAEC;IAVD,gBAEC;IAUD,mBAEC;IAVD,gBAEC;IAsDL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IA/CvB,sDAKC;CACJ;;mBAIS,OAAO;qBAMP,OAAO;qBAMP,OAAO;sBAMP,OAAO;qBAMP,OAAO;oBAKP,OAAO;;;mBA/pBE,4BAA4B;4BAQnB,uBAAuB"}
1
+ {"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector2.js"],"names":[],"mappings":";AAmBA;IACI;;;;;OAKG;IACH,gBAJW,MAAM,MACN,MAAM,EAuBhB;IAbG;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV,0DAA6B;IAGjC;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAOhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,EAAE,WACR,MAAM,QAKhB;IAED,iBAMC;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAqBnB;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAYhB;IAED;;;;OAIG;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DAKC;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;;;;OAMG;IACH,uEAIC;IAED;;;;OAIG;IACH,8CAIC;IAED;;;;OAIG;IACH,iDAIC;IAED;;;;OAIG;IACH,qBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;;OAKG;IACH,eAJW,OAAO,KACP,OAAO,YACP,MAAM,QAOhB;IAED;;;OAGG;IACH,sBAFW,MAAM,EAAE,QAUlB;IAED;;;;OAIG;IACH,kBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;;OAKG;IACH,kBAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,eAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,2BAHW,OAAO,GACL,MAAM,CAOlB;IAED;;OAEG;IACH,UAFa,MAAM,CAIlB;IAED;;OAEG;IACH,kBAWC;IAGD;;;OAGG;IACH,QAFa,MAAM,CAOlB;IAED;;;OAGG;IACH,cAFW,MAAM,QAahB;IAED;;;;;OAKG;IACH,6CAFa,OAAO,CAQnB;IAED,mBAEC;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,qBAJW,OAAO,cACP,MAAM,GACL,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,cACN,MAAM,GACL,OAAO,CAKlB;IAUD,mBAEC;IAVD,gBAEC;IAUD,mBAEC;IAVD,gBAEC;IAsDL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IA/CvB,sDAKC;CACJ;;mBAIS,OAAO;qBAMP,OAAO;qBAMP,OAAO;sBAMP,OAAO;qBAMP,OAAO;oBAKP,OAAO;;;mBAlqBE,4BAA4B;4BAQnB,uBAAuB"}
@@ -20,10 +20,8 @@ import { v2_magnitude } from "./vec2/v2_magnitude.js";
20
20
  class Vector2 {
21
21
  /**
22
22
  *
23
- * @param {number} [x=0
23
+ * @param {number} [x=0]
24
24
  * @param {number} [y=0]
25
- * @property {number} x
26
- * @property {number} y
27
25
  * @constructor
28
26
  */
29
27
  constructor(x = 0, y = 0) {
@@ -111,6 +109,11 @@ class Vector2 {
111
109
  * @param {number} y
112
110
  */
113
111
  setSilent(x, y) {
112
+ assert.isNumber(x, 'x');
113
+ assert.isNumber(y, 'y');
114
+
115
+ assert.notNaN(x, 'x');
116
+ assert.notNaN(y, 'y');
114
117
 
115
118
  this.x = x;
116
119
  this.y = y;
@@ -407,7 +407,7 @@ class Vector3 {
407
407
  }
408
408
 
409
409
  /**
410
- * @param {number} [squaredError=0.01]
410
+ * @param {number} [squaredError]
411
411
  * @return {boolean}
412
412
  */
413
413
  isNormalized(squaredError = 0.01) {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=v3_angle_cos_between.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_angle_cos_between.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_angle_cos_between.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,124 @@
1
+ import { v3_angle_cos_between } from "./v3_angle_cos_between.js";
2
+
3
+ function validate_result(value) {
4
+ expect(typeof value).toBe("number");
5
+ expect(value).not.toBeNaN();
6
+ expect(value).toBeGreaterThanOrEqual(-1);
7
+ expect(value).toBeLessThanOrEqual(1);
8
+ }
9
+
10
+ test("zero-length vectors produce valid results", () => {
11
+
12
+ validate_result(v3_angle_cos_between(
13
+ 0, 0, 0,
14
+ 0, 0, 0
15
+ ));
16
+
17
+ validate_result(v3_angle_cos_between(
18
+ 1, 0, 0,
19
+ 0, 0, 0
20
+ ));
21
+
22
+ validate_result(v3_angle_cos_between(
23
+ 0, 1, 0,
24
+ 0, 0, 0
25
+ ));
26
+
27
+ validate_result(v3_angle_cos_between(
28
+ 0, 0, 1,
29
+ 0, 0, 0
30
+ ));
31
+
32
+ validate_result(v3_angle_cos_between(
33
+ 0, 0, 0,
34
+ 1, 0, 0
35
+ ));
36
+
37
+ validate_result(v3_angle_cos_between(
38
+ 0, 0, 0,
39
+ 0, 1, 0
40
+ ));
41
+
42
+ validate_result(v3_angle_cos_between(
43
+ 0, 0, 0,
44
+ 0, 0, 1
45
+ ));
46
+
47
+ });
48
+ test("Right angles", () => {
49
+
50
+ expect(v3_angle_cos_between(
51
+ 1, 0, 0,
52
+ 0, 1, 0
53
+ )).toBeCloseTo(0);
54
+
55
+ expect(v3_angle_cos_between(
56
+ 1, 0, 0,
57
+ 0, 0, 1
58
+ )).toBeCloseTo(0);
59
+
60
+ expect(v3_angle_cos_between(
61
+ -1, 0, 0,
62
+ 0, 1, 0
63
+ )).toBeCloseTo(0);
64
+
65
+ expect(v3_angle_cos_between(
66
+ -1, 0, 0,
67
+ 0, 0, 1
68
+ )).toBeCloseTo(0);
69
+
70
+ expect(v3_angle_cos_between(
71
+ 0, 1, 0,
72
+ 1, 0, 0
73
+ )).toBeCloseTo(0);
74
+
75
+ expect(v3_angle_cos_between(
76
+ 0, 1, 0,
77
+ 0, 0, 1
78
+ )).toBeCloseTo(0);
79
+
80
+ expect(v3_angle_cos_between(
81
+ 0, -1, 0,
82
+ 1, 0, 0
83
+ )).toBeCloseTo(0);
84
+
85
+ expect(v3_angle_cos_between(
86
+ 0, -1, 0,
87
+ 0, 0, 1
88
+ )).toBeCloseTo(0);
89
+
90
+ expect(v3_angle_cos_between(
91
+ 0, 0, 1,
92
+ 1, 0, 0
93
+ )).toBeCloseTo(0);
94
+
95
+ expect(v3_angle_cos_between(
96
+ 0, 0, 1,
97
+ 0, 1, 0
98
+ )).toBeCloseTo(0);
99
+
100
+ expect(v3_angle_cos_between(
101
+ 0, 0, -1,
102
+ 1, 0, 0
103
+ )).toBeCloseTo(0);
104
+
105
+ expect(v3_angle_cos_between(
106
+ 0, 0, -1,
107
+ 0, 1, 0
108
+ )).toBeCloseTo(0);
109
+
110
+ });
111
+
112
+ test("non-uniform vectors", () => {
113
+
114
+ expect(v3_angle_cos_between(
115
+ 3, 0, 0,
116
+ 0, 7, 0
117
+ )).toBeCloseTo(0);
118
+
119
+ expect(v3_angle_cos_between(
120
+ -3, 0, 0,
121
+ 0, 7, 0
122
+ )).toBeCloseTo(0);
123
+
124
+ });
@@ -1,4 +1,13 @@
1
- export declare function v3_distance_above_plane(
2
- x: number, y: number, z: number,
3
- normalX: number, normalY: number, normalZ: number, planeConstant: number
4
- ): number
1
+ /**
2
+ * Orthogonal distance of a point to a plane, the distance is positive when the point lies above the plane and negative when the point is below
3
+ * @param {number} x
4
+ * @param {number} y
5
+ * @param {number} z
6
+ * @param {number} normalX
7
+ * @param {number} normalY
8
+ * @param {number} normalZ
9
+ * @param {number} planeConstant
10
+ * @returns {number}
11
+ */
12
+ export function v3_distance_above_plane(x: number, y: number, z: number, normalX: number, normalY: number, normalZ: number, planeConstant: number): number;
13
+ //# sourceMappingURL=v3_distance_above_plane.d.ts.map
@@ -1 +1,12 @@
1
- export function v3_distance_sqr(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): number
1
+ /**
2
+ *
3
+ * @param {number} x0
4
+ * @param {number} y0
5
+ * @param {number} z0
6
+ * @param {number} x1
7
+ * @param {number} y1
8
+ * @param {number} z1
9
+ * @returns {number}
10
+ */
11
+ export function v3_distance_sqr(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): number;
12
+ //# sourceMappingURL=v3_distance_sqr.d.ts.map