@woosh/meep-engine 2.48.22 → 2.48.23

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 (101) hide show
  1. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +1 -1
  2. package/editor/ecs/component/editors/three/MeshEditor.js +1 -1
  3. package/editor/tools/SelectionTool.js +1 -1
  4. package/editor/view/library/MeshLibraryView.js +1 -1
  5. package/package.json +1 -1
  6. package/src/core/binary/32BitEncoder.js +1 -1
  7. package/src/core/bvh2/LeafNode.js +2 -2
  8. package/src/core/bvh2/Node.d.ts +1 -1
  9. package/src/core/bvh2/Node.js +1 -1
  10. package/src/core/bvh2/NodeValidator.js +1 -1
  11. package/src/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  12. package/src/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -2
  13. package/src/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  14. package/src/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -2
  15. package/src/core/cache/Cache.js +4 -2
  16. package/src/core/codegen/LineBuilder.js +3 -0
  17. package/src/core/collection/HashMap.js +6 -0
  18. package/src/core/collection/heap/Uint32Heap.js +1 -0
  19. package/src/core/events/signal/Signal.js +7 -5
  20. package/src/core/events/signal/SignalBinding.js +56 -54
  21. package/src/core/events/signal/SignalFlags.js +7 -0
  22. package/src/core/function/Functions.js +1 -1
  23. package/src/core/geom/{Rectangle.js → 2d/Rectangle.js} +5 -5
  24. package/src/core/geom/{AABB2.js → 2d/aabb/AABB2.js} +10 -78
  25. package/src/core/geom/{AABB2.spec.js → 2d/aabb/AABB2.spec.js} +1 -1
  26. package/src/core/geom/2d/aabb/aabb2_compute_overlap.js +42 -0
  27. package/src/core/geom/2d/aabb/aabb2_contains.js +23 -0
  28. package/src/core/geom/2d/aabb/aabb2_distance_sqr_to_point.js +25 -0
  29. package/src/core/geom/2d/aabb/aabb2_distance_to_point.js +17 -0
  30. package/src/core/geom/2d/aabb/aabb2_distance_to_point.spec.js +17 -0
  31. package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +18 -0
  32. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.js +45 -0
  33. package/src/core/geom/2d/aabb/aabb2_signed_distance_sqr_to_point.spec.js +40 -0
  34. package/src/core/geom/2d/aabb/aabb2_signed_distance_to_point.js +27 -0
  35. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +4 -0
  36. package/src/core/geom/2d/quad-tree/PointQuadTree.js +3 -0
  37. package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +1 -1
  38. package/src/core/geom/2d/quad-tree/QuadTreeNode.js +3 -3
  39. package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +6 -8
  40. package/src/core/geom/2d/quad-tree/qt_match_data_by_circle.js +3 -3
  41. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +3 -3
  42. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.d.ts +1 -1
  43. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.js +13 -13
  44. package/src/core/{bvh2/aabb3 → geom/3d/aabb}/AABB3.spec.js +1 -1
  45. package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +13 -9
  46. package/src/core/geom/packing/max-rect/MaxRectangles.js +1 -1
  47. package/src/core/geom/{GeometryMath.js → rayTriangleIntersection.js} +5 -1
  48. package/src/core/graph/GraphUtils.js +1 -1
  49. package/src/core/graph/build_face_graph_from_mesh.js +1 -3
  50. package/src/core/graph/layout/BoxLayouter.js +1 -1
  51. package/src/core/graph/layout/CircleLayout.js +2 -2
  52. package/src/core/model/node-graph/visual/NodeVisualData.js +1 -1
  53. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  54. package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +2 -2
  55. package/src/engine/asset/preloader/Preloader.js +3 -3
  56. package/src/engine/ecs/components/Renderable.d.ts +1 -1
  57. package/src/engine/ecs/components/Renderable.js +1 -1
  58. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +1 -1
  59. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  60. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -2
  61. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
  62. package/src/engine/graphics/camera/makeScreenScissorFrustum.d.ts +1 -1
  63. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  64. package/src/engine/graphics/ecs/mesh/Mesh.d.ts +1 -1
  65. package/src/engine/graphics/ecs/mesh/Mesh.js +1 -1
  66. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +1 -1
  67. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +1 -1
  68. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +1 -1
  69. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +1 -1
  70. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  71. package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +1 -1
  72. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1 -1
  73. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +1 -1
  74. package/src/engine/graphics/render/forward_plus/debug/createScreenGrid.js +1 -1
  75. package/src/engine/graphics/render/view/CameraView.js +1 -1
  76. package/src/engine/graphics/texture/atlas/AtlasPatch.js +2 -2
  77. package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +2 -2
  78. package/src/engine/graphics/util/makeMeshPreviewScene.js +1 -1
  79. package/src/engine/graphics/util/renderObjectToSampler2D.js +1 -1
  80. package/src/engine/ui/tiles2d/computeTileGridMove.js +3 -2
  81. package/src/engine/ui/tiles2d/computeTileGridMove.spec.js +1 -1
  82. package/src/generation/theme/AreaMask.js +1 -1
  83. package/src/view/View.js +1 -1
  84. package/src/view/elements/progress/RectangularPieProgressView.js +1 -1
  85. package/src/view/minimap/Minimap.js +1 -1
  86. package/src/view/minimap/gl/MinimapFogOfWar.js +1 -1
  87. package/src/view/tooltip/DomTooltipObserver.js +1 -1
  88. package/src/view/tooltip/TooltipManager.js +1 -1
  89. package/src/view/tooltip/TooltipView.js +1 -1
  90. package/src/view/util/DomSizeObserver.js +2 -2
  91. package/src/core/geom/2d/AABB2Math.js +0 -40
  92. package/src/core/geom/2d/AABB2Math.spec.js +0 -17
  93. /package/src/core/geom/{LineSegment2.js → 2d/LineSegment2.js} +0 -0
  94. /package/src/core/geom/{Rectangle.spec.js → 2d/Rectangle.spec.js} +0 -0
  95. /package/src/core/geom/{AABB2.d.ts → 2d/aabb/AABB2.d.ts} +0 -0
  96. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3.js +0 -0
  97. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Encoded_v0.js +0 -0
  98. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/deserializeAABB3Quantized16Uint.js +0 -0
  99. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3.js +0 -0
  100. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Encoded_v0.js +0 -0
  101. /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/serializeAABB3Quantized16Uint.js +0 -0
@@ -2,7 +2,7 @@ import { TypeEditor } from "../../TypeEditor.js";
2
2
  import { Sampler2D } from "../../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
3
3
  import { renderObjectToSampler2D } from "../../../../../src/engine/graphics/util/renderObjectToSampler2D.js";
4
4
  import { Mesh, MeshPhongMaterial } from "three";
5
- import AABB2 from "../../../../../src/core/geom/AABB2.js";
5
+ import AABB2 from "../../../../../src/core/geom/2d/aabb/AABB2.js";
6
6
  import { CanvasView } from "../../../../../src/view/elements/CanvasView.js";
7
7
  import sampler2D2Canvas from "../../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
8
8
 
@@ -1,7 +1,7 @@
1
1
  import { TypeEditor } from "../../TypeEditor.js";
2
2
  import { Sampler2D } from "../../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
3
3
  import { renderObjectToSampler2D } from "../../../../../src/engine/graphics/util/renderObjectToSampler2D.js";
4
- import AABB2 from "../../../../../src/core/geom/AABB2.js";
4
+ import AABB2 from "../../../../../src/core/geom/2d/aabb/AABB2.js";
5
5
  import { CanvasView } from "../../../../../src/view/elements/CanvasView.js";
6
6
  import sampler2D2Canvas from "../../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
7
7
  import { threeUpdateTransform } from "../../../../../src/engine/graphics/util/threeUpdateTransform.js";
@@ -5,7 +5,7 @@
5
5
 
6
6
  import Tool from './engine/Tool.js';
7
7
  import Vector2 from '../../src/core/geom/Vector2.js';
8
- import AABB2 from '../../src/core/geom/AABB2.js';
8
+ import AABB2 from '../../src/core/geom/2d/aabb/AABB2.js';
9
9
  import { Camera } from '../../src/engine/graphics/ecs/camera/Camera.js';
10
10
  import View from '../../src/view/View.js';
11
11
 
@@ -4,7 +4,7 @@ import Vector2 from "../../../src/core/geom/Vector2.js";
4
4
  import domify from "../../../src/view/DOM.js";
5
5
  import LabelView from "../../../src/view/common/LabelView.js";
6
6
  import List from "../../../src/core/collection/list/List.js";
7
- import AABB2 from "../../../src/core/geom/AABB2.js";
7
+ import AABB2 from "../../../src/core/geom/2d/aabb/AABB2.js";
8
8
  import { DragEvents } from "../../../src/engine/input/devices/events/DragEvents.js";
9
9
  import { MouseEvents } from "../../../src/engine/input/devices/events/MouseEvents.js";
10
10
  import { TouchEvents } from "../../../src/engine/input/devices/events/TouchEvents.js";
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.48.22",
8
+ "version": "2.48.23",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -2,7 +2,7 @@ import { FunctionCompiler } from "../function/FunctionCompiler.js";
2
2
  import { assert } from "../assert.js";
3
3
 
4
4
  /**
5
- *
5
+ * Builds an encoder/decoder to simplify process of reading/writing various parts of a 32 bit field
6
6
  * @param {number[]} bitCounts
7
7
  * @returns {{encode: function(...number):number, decode: function(value:number, result:number[]):void}}
8
8
  */
@@ -2,8 +2,8 @@
2
2
  * Created by Alex on 17/11/2014.
3
3
  */
4
4
  import { Node } from "./Node.js";
5
- import { serializeAABB3 } from "./aabb3/serializeAABB3.js";
6
- import { deserializeAABB3 } from "./aabb3/deserializeAABB3.js";
5
+ import { serializeAABB3 } from "../geom/3d/aabb/serializeAABB3.js";
6
+ import { deserializeAABB3 } from "../geom/3d/aabb/deserializeAABB3.js";
7
7
 
8
8
 
9
9
  /**
@@ -1,4 +1,4 @@
1
- import {AABB3} from "./aabb3/AABB3";
1
+ import {AABB3} from "../geom/3d/aabb/AABB3";
2
2
  import {BinaryNode} from "./BinaryNode";
3
3
 
4
4
  export class Node<T> extends AABB3 {
@@ -2,7 +2,7 @@
2
2
  * Created by Alex on 17/11/2014.
3
3
  */
4
4
  import computeMortonCode from "../geom/3d/morton/Morton.js";
5
- import { AABB3 } from "./aabb3/AABB3.js";
5
+ import { AABB3 } from "../geom/3d/aabb/AABB3.js";
6
6
 
7
7
 
8
8
  export class Node extends AABB3 {
@@ -4,7 +4,7 @@ import { buildShortStringPath } from "./Node.js";
4
4
 
5
5
  /**
6
6
  *
7
- * @param {NodeDescription} node
7
+ * @param {Node} node
8
8
  * @param {ViolationType} type
9
9
  * @param {String} message
10
10
  * @constructor
@@ -1,6 +1,6 @@
1
1
  import { BinaryNode } from "../BinaryNode.js";
2
2
  import { deserializeLeafNode, LeafNode } from "../LeafNode.js";
3
- import { deserializeAABB3 } from "../aabb3/deserializeAABB3.js";
3
+ import { deserializeAABB3 } from "../../geom/3d/aabb/deserializeAABB3.js";
4
4
 
5
5
  /**
6
6
  *
@@ -1,7 +1,7 @@
1
1
  import { BinaryNode } from "../BinaryNode.js";
2
2
  import { LeafNode } from "../LeafNode.js";
3
- import { deserializeAABB3Encoded_v0 } from "../aabb3/deserializeAABB3Encoded_v0.js";
4
- import { deserializeAABB3 } from "../aabb3/deserializeAABB3.js";
3
+ import { deserializeAABB3Encoded_v0 } from "../../geom/3d/aabb/deserializeAABB3Encoded_v0.js";
4
+ import { deserializeAABB3 } from "../../geom/3d/aabb/deserializeAABB3.js";
5
5
 
6
6
  /**
7
7
  *
@@ -1,5 +1,5 @@
1
1
  import { isLeaf, serializeLeafNode } from "../LeafNode.js";
2
- import { serializeAABB3 } from "../aabb3/serializeAABB3.js";
2
+ import { serializeAABB3 } from "../../geom/3d/aabb/serializeAABB3.js";
3
3
 
4
4
  /**
5
5
  *
@@ -1,5 +1,5 @@
1
- import { serializeAABB3 } from "../aabb3/serializeAABB3.js";
2
- import { serializeAABB3Encoded_v0 } from "../aabb3/serializeAABB3Encoded_v0.js";
1
+ import { serializeAABB3 } from "../../geom/3d/aabb/serializeAABB3.js";
2
+ import { serializeAABB3Encoded_v0 } from "../../geom/3d/aabb/serializeAABB3Encoded_v0.js";
3
3
 
4
4
  /**
5
5
  *
@@ -6,6 +6,7 @@ import { CacheElement } from "./CacheElement.js";
6
6
  import { collectIteratorValueToArray } from "../collection/IteratorUtils.js";
7
7
 
8
8
  /**
9
+ * Hash-based cache, uses LRU (least-recently-used) eviction policy
9
10
  * TODO validate hashes of held elements to keep them up to date. Keys are assumed to be immutable, but this assumption may be broken by users
10
11
  * @template Key, Value
11
12
  * @extends Map<Key,Value>
@@ -108,7 +109,8 @@ export class Cache {
108
109
  }
109
110
 
110
111
  /**
111
- *
112
+ * Marks element as recently used
113
+ * Moves element to the end of the eviction queue
112
114
  * @param {CacheElement<Key,Value>} element
113
115
  * @private
114
116
  */
@@ -426,7 +428,7 @@ export class Cache {
426
428
  */
427
429
  const keys = [];
428
430
 
429
- collectIteratorValueToArray(keys,this.data.keys());
431
+ collectIteratorValueToArray(keys, this.data.keys());
430
432
 
431
433
  const n = keys.length;
432
434
  for (let i = 0; i < n; i++) {
@@ -16,6 +16,9 @@ class Line {
16
16
  }
17
17
  }
18
18
 
19
+ /**
20
+ * Useful for creating formatted snippets of code
21
+ */
19
22
  class LineBuilder {
20
23
 
21
24
  /**
@@ -81,22 +81,28 @@ export class HashMap {
81
81
  assert.isNonNegativeInteger(capacity, 'capacity');
82
82
 
83
83
  assert.isNumber(loadFactor, 'loadFactor');
84
+ assert.notNaN(loadFactor, 'loadFactor');
84
85
  assert.greaterThan(loadFactor, 0, 'loadFactor must be > 0');
85
86
 
86
87
  /**
87
88
  *
88
89
  * @type {function(K): number}
90
+ * @readonly
91
+ * @private
89
92
  */
90
93
  this.keyHashFunction = keyHashFunction;
91
94
  /**
92
95
  *
93
96
  * @type {function(K, K): boolean}
97
+ * @readonly
98
+ * @private
94
99
  */
95
100
  this.keyEqualityFunction = keyEqualityFunction;
96
101
 
97
102
  /**
98
103
  * Sparse array of map entries
99
104
  * @type {MapEntry[][]}
105
+ * @private
100
106
  */
101
107
  this.records = [];
102
108
 
@@ -49,6 +49,7 @@ function HEAP_RIGHT(i) {
49
49
 
50
50
  /**
51
51
  * Binary Heap implementation that stores uin32 ID along with a floating point score value
52
+ * Very fast and compact
52
53
  * Inspired by Blender's heap implementation found here: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/BLI_heap.c
53
54
  */
54
55
  export class Uint32Heap {
@@ -41,6 +41,7 @@ export class Signal {
41
41
  * @returns {boolean}
42
42
  */
43
43
  get dispatching() {
44
+ console.warn('deprecated, use .isDispatching instead');
44
45
  return this.getFlag(SignalFlags.Dispatching);
45
46
  }
46
47
 
@@ -49,6 +50,7 @@ export class Signal {
49
50
  * @param {boolean} v
50
51
  */
51
52
  set dispatching(v) {
53
+ console.warn('deprecated, flag should not be written to from outside of the signal');
52
54
  this.writeFlag(SignalFlags.Dispatching, v);
53
55
  }
54
56
 
@@ -147,7 +149,7 @@ export class Signal {
147
149
  * @param {*} [context]
148
150
  */
149
151
  addOne(h, context) {
150
- assert.isFunction( h, "handler");
152
+ assert.isFunction(h, "handler");
151
153
 
152
154
  const handler = new SignalHandler(h, context);
153
155
 
@@ -209,12 +211,12 @@ export class Signal {
209
211
  }
210
212
 
211
213
  //mark dispatch process
212
- this.dispatching = true;
214
+ this.setFlag(SignalFlags.Dispatching);
213
215
 
214
216
  dispatchViaProxy(this.handlers, args);
215
217
 
216
218
  //mark end of dispatch process
217
- this.dispatching = false;
219
+ this.clearFlag(SignalFlags.Dispatching);
218
220
  }
219
221
 
220
222
  /**
@@ -588,11 +590,11 @@ export class Signal {
588
590
  }
589
591
 
590
592
  /**
591
- *
593
+ * @deprecated do not use
592
594
  * @returns {boolean}
593
595
  */
594
596
  isDispatching() {
595
- return this.dispatching;
597
+ return this.getFlag(SignalFlags.Dispatching);
596
598
  }
597
599
 
598
600
  /**
@@ -4,73 +4,75 @@
4
4
  */
5
5
 
6
6
 
7
- /**
8
- *
9
- * @param {Signal} signal
10
- * @param {function} handler
11
- * @param {*} [context]
12
- * @constructor
13
- */
14
- function SignalBinding(signal, handler, context) {
15
- if (typeof handler !== "function") {
16
- throw new TypeError(`handler must be a function, instead was ${handler}`);
17
- }
7
+ export class SignalBinding {
8
+ /**
9
+ *
10
+ * @param {Signal} signal
11
+ * @param {function} handler
12
+ * @param {*} [context]
13
+ * @constructor
14
+ */
15
+ constructor(signal, handler, context) {
16
+ if (typeof handler !== "function") {
17
+ throw new TypeError(`handler must be a function, instead was ${handler}`);
18
+ }
18
19
 
19
- if (typeof signal !== "object") {
20
- throw new TypeError(`signal must be of an object, instead was ${signal}`)
21
- }
20
+ if (typeof signal !== "object") {
21
+ throw new TypeError(`signal must be of an object, instead was ${signal}`)
22
+ }
22
23
 
23
- if (typeof signal.add !== "function") {
24
- throw new TypeError(`signal.add must be a function, instead was ${signal.add}`);
25
- }
24
+ if (typeof signal.add !== "function") {
25
+ throw new TypeError(`signal.add must be a function, instead was ${signal.add}`);
26
+ }
26
27
 
27
- /**
28
- * Binding signal
29
- * @type {Signal}
30
- */
31
- this.signal = signal;
28
+ /**
29
+ * Binding signal
30
+ * @type {Signal}
31
+ */
32
+ this.signal = signal;
32
33
 
33
- /**
34
- * Signal handler to be attached to the signal
35
- * @type {Function}
36
- */
37
- this.handler = handler;
34
+ /**
35
+ * Signal handler to be attached to the signal
36
+ * @type {Function}
37
+ */
38
+ this.handler = handler;
38
39
 
39
- /**
40
- *
41
- * @type {*}
42
- */
43
- this.context = context;
40
+ /**
41
+ *
42
+ * @type {*}
43
+ */
44
+ this.context = context;
45
+
46
+ /**
47
+ * State flag
48
+ * @type {boolean}
49
+ */
50
+ this.linked = false;
51
+ }
44
52
 
45
53
  /**
46
- * State flag
47
- * @type {boolean}
54
+ * Attaches handler to the signal
55
+ * Idempotent
48
56
  */
49
- this.linked = false;
50
- }
57
+ link() {
58
+ if (this.linked) {
59
+ return;
60
+ }
51
61
 
52
- /**
53
- * Attaches handler to the signal
54
- * Idempotent
55
- */
56
- SignalBinding.prototype.link = function () {
57
- if (!this.linked) {
58
62
  this.linked = true;
59
63
  this.signal.add(this.handler, this.context);
60
64
  }
61
- };
62
65
 
63
- /**
64
- * Detaches handler from the signal
65
- * Idempotent
66
- */
67
- SignalBinding.prototype.unlink = function () {
68
- if (this.linked) {
66
+ /**
67
+ * Detaches handler from the signal
68
+ * Idempotent
69
+ */
70
+ unlink() {
71
+ if (!this.linked) {
72
+ return;
73
+ }
74
+
69
75
  this.linked = false;
70
76
  this.signal.remove(this.handler, this.context);
71
77
  }
72
- };
73
-
74
- export {
75
- SignalBinding
76
- };
78
+ }
@@ -1,4 +1,11 @@
1
1
  export const SignalFlags = {
2
+ /**
3
+ * If set - signal will not invoke handlers when dispatched
4
+ */
2
5
  Silent: 1,
6
+ /**
7
+ * Is set at the start of the dispatch and cleared at the end
8
+ * @deprecated
9
+ */
3
10
  Dispatching: 2
4
11
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  /**
8
8
  * No-operation function. Does nothing. Useful when a callback is required to avoid checks for a missing function.
9
- * @param {*..} arguments
9
+ * @param {*} arguments
10
10
  */
11
11
  export function noop() {
12
12
  }
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Created by Alex on 14/03/2016.
3
3
  */
4
- import { max2 } from "../math/max2.js";
5
- import { min2 } from "../math/min2.js";
6
- import Vector2 from "./Vector2.js";
7
- import { intersects1D } from "../math/interval/intersects1D.js";
8
- import { overlap1D } from "../math/interval/overlap1D.js";
4
+ import { max2 } from "../../math/max2.js";
5
+ import { min2 } from "../../math/min2.js";
6
+ import Vector2 from "../Vector2.js";
7
+ import { intersects1D } from "../../math/interval/intersects1D.js";
8
+ import { overlap1D } from "../../math/interval/overlap1D.js";
9
9
 
10
10
 
11
11
  class Rectangle {
@@ -4,13 +4,14 @@
4
4
  */
5
5
 
6
6
 
7
- import { assert } from "../assert.js";
8
- import { clamp } from "../math/clamp.js";
9
- import { max2 } from "../math/max2.js";
10
- import { min2 } from "../math/min2.js";
11
- import LineSegment2 from "./LineSegment2.js";
12
- import Vector2 from "./Vector2.js";
13
- import { overlap1D } from "../math/interval/overlap1D.js";
7
+ import { assert } from "../../../assert.js";
8
+ import { clamp } from "../../../math/clamp.js";
9
+ import { max2 } from "../../../math/max2.js";
10
+ import { min2 } from "../../../math/min2.js";
11
+ import LineSegment2 from "../LineSegment2.js";
12
+ import Vector2 from "../../Vector2.js";
13
+ import { aabb2_compute_overlap } from "./aabb2_compute_overlap.js";
14
+ import { aabb2_overlap_exists } from "./aabb2_overlap_exists.js";
14
15
 
15
16
  /**
16
17
  *
@@ -137,7 +138,7 @@ class AABB2 {
137
138
  const bx1 = other.x1;
138
139
  const by1 = other.y1;
139
140
 
140
- return computeOverlap(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1, result);
141
+ return aabb2_compute_overlap(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1, result);
141
142
  }
142
143
 
143
144
  /**
@@ -156,7 +157,7 @@ class AABB2 {
156
157
  const bx1 = other.x1;
157
158
  const by1 = other.y1;
158
159
 
159
- return aabb2_overlapExists(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1);
160
+ return aabb2_overlap_exists(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1);
160
161
  }
161
162
 
162
163
  /**
@@ -583,74 +584,5 @@ AABB2.zero = Object.freeze(new AABB2(0, 0, 0, 0));
583
584
  */
584
585
  AABB2.unit = Object.freeze(new AABB2(0, 0, 1, 1));
585
586
 
586
- /**
587
- *
588
- * @param {number} ax0
589
- * @param {number} ay0
590
- * @param {number} ax1
591
- * @param {number} ay1
592
- * @param {number} bx0
593
- * @param {number} by0
594
- * @param {number} bx1
595
- * @param {number} by1
596
- * @returns {boolean} true if overlap exists, false if no overlap
597
- */
598
- export function aabb2_overlapExists(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1) {
599
- return overlap1D(ax0, ax1, bx0, bx1)
600
- && overlap1D(ay0, ay1, by0, by1);
601
- }
602
-
603
- /**
604
- *
605
- * @param {number} bounds_x0
606
- * @param {number} bounds_y0
607
- * @param {number} bounds_x1
608
- * @param {number} bounds_y1
609
- * @param {number} x0
610
- * @param {number} y0
611
- * @param {number} x1
612
- * @param {number} y1
613
- * @return {boolean}
614
- */
615
- export function aabb2_contains(bounds_x0, bounds_y0, bounds_x1, bounds_y1, x0, y0, x1, y1) {
616
-
617
- return x0 >= bounds_x0 && x1 <= bounds_x1 && y0 >= bounds_y0 && y1 <= bounds_y1;
618
- }
619
-
620
- /**
621
- *
622
- * @param {number} ax0
623
- * @param {number} ay0
624
- * @param {number} ax1
625
- * @param {number} ay1
626
- * @param {number} bx0
627
- * @param {number} by0
628
- * @param {number} bx1
629
- * @param {number} by1
630
- * @param {AABB2} result
631
- * @returns {boolean} true if overlap exists, false if no overlap
632
- */
633
- function computeOverlap(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1, result) {
634
- const x0 = max2(ax0, bx0);
635
- const x1 = min2(ax1, bx1);
636
-
637
- if (x0 >= x1) {
638
- //no overlap
639
- return false;
640
- }
641
-
642
- const y0 = max2(ay0, by0);
643
- const y1 = min2(ay1, by1);
644
-
645
- if (y0 >= y1) {
646
- //no overlap
647
- return false;
648
- }
649
-
650
- result.set(x0, y0, x1, y1);
651
-
652
- return true;
653
- }
654
-
655
587
 
656
588
  export default AABB2;
@@ -1,4 +1,4 @@
1
- import AABB2 from "./AABB2.js";
1
+ import AABB2 from "./AABB2.d.ts";
2
2
 
3
3
  test('copy', () => {
4
4
  const a = new AABB2(1, 2, 5, 11);
@@ -0,0 +1,42 @@
1
+ import { max2 } from "../../../math/max2.js";
2
+ import { min2 } from "../../../math/min2.js";
3
+
4
+ /**
5
+ *
6
+ * @param {number} ax0
7
+ * @param {number} ay0
8
+ * @param {number} ax1
9
+ * @param {number} ay1
10
+ * @param {number} bx0
11
+ * @param {number} by0
12
+ * @param {number} bx1
13
+ * @param {number} by1
14
+ * @param {AABB2} result
15
+ * @returns {boolean} true if overlap exists, false if no overlap
16
+ */
17
+ export function aabb2_compute_overlap(
18
+ ax0, ay0, ax1, ay1,
19
+ bx0, by0, bx1, by1,
20
+ result
21
+ ) {
22
+
23
+ const x0 = max2(ax0, bx0);
24
+ const x1 = min2(ax1, bx1);
25
+
26
+ if (x0 >= x1) {
27
+ //no overlap
28
+ return false;
29
+ }
30
+
31
+ const y0 = max2(ay0, by0);
32
+ const y1 = min2(ay1, by1);
33
+
34
+ if (y0 >= y1) {
35
+ //no overlap
36
+ return false;
37
+ }
38
+
39
+ result.set(x0, y0, x1, y1);
40
+
41
+ return true;
42
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ *
3
+ * @param {number} bounds_x0
4
+ * @param {number} bounds_y0
5
+ * @param {number} bounds_x1
6
+ * @param {number} bounds_y1
7
+ * @param {number} x0
8
+ * @param {number} y0
9
+ * @param {number} x1
10
+ * @param {number} y1
11
+ * @return {boolean}
12
+ */
13
+ export function aabb2_contains(
14
+ bounds_x0, bounds_y0, bounds_x1, bounds_y1,
15
+ x0, y0, x1, y1
16
+ ) {
17
+
18
+ return x0 >= bounds_x0
19
+ && x1 <= bounds_x1
20
+ && y0 >= bounds_y0
21
+ && y1 <= bounds_y1
22
+ ;
23
+ }
@@ -0,0 +1,25 @@
1
+ import { max3 } from "../../../math/max3.js";
2
+
3
+ /**
4
+ * NOTE: The result is not a signed distance, any degree of penetration will produce 0 distance as a result
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} x1
8
+ * @param {number} y1
9
+ * @param {number} px
10
+ * @param {number} py
11
+ * @returns {number}
12
+ */
13
+ export function aabb2_distance_sqr_to_point(x0, y0, x1, y1, px, py) {
14
+
15
+ const dx0 = x0 - px;
16
+ const dx1 = px - x1;
17
+
18
+ const dy0 = y0 - py;
19
+ const dy1 = py - y1;
20
+
21
+ const dx = max3(0, dx0, dx1);
22
+ const dy = max3(0, dy0, dy1);
23
+
24
+ return dx * dx + dy * dy;
25
+ }