@woosh/meep-engine 2.48.23 → 2.49.1

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 (147) hide show
  1. package/editor/tools/GridPaintTool.js +1 -1
  2. package/editor/tools/paint/TerrainPaintTool.js +1 -1
  3. package/editor/view/GridPickCoordinateView.js +1 -1
  4. package/package.json +1 -1
  5. package/src/core/UUID.js +2 -0
  6. package/src/core/assert.js +4 -1
  7. package/src/core/binary/ctz32.js +1 -1
  8. package/src/core/binary/operations/bitCount.spec.js +19 -0
  9. package/src/core/binary/uint82float.spec.js +7 -0
  10. package/src/core/bvh2/binary/IndexedBinaryBVH.spec.js +7 -0
  11. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +3 -0
  12. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +5 -4
  13. package/src/core/bvh2/transform/RotationOptimizer.spec.js +161 -155
  14. package/src/core/codegen/LineBuilder.js +12 -3
  15. package/src/core/codegen/LineBuilder.spec.js +7 -0
  16. package/src/core/collection/CuckooFilter.js +12 -12
  17. package/src/core/collection/HashMap.js +486 -237
  18. package/src/core/collection/HashMap.spec.js +110 -1
  19. package/src/core/collection/array/{typedArrayToDataType.js → typed/typedArrayToDataType.js} +1 -1
  20. package/src/core/collection/array/weightedRandomFromArray.spec.js +20 -0
  21. package/src/core/debug/matchers/AnyOf.js +1 -2
  22. package/src/core/geom/2d/aabb/AABB2.spec.js +1 -1
  23. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +19 -0
  24. package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +3 -3
  25. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +7 -9
  26. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +17 -15
  27. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.spec.js +25 -0
  28. package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
  29. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +3 -0
  30. package/src/core/geom/3d/aabb/aabb3_from_v3_array.spec.js +32 -0
  31. package/src/core/geom/3d/aabb/aabb3_intersects_aabb3.spec.js +115 -0
  32. package/src/core/geom/3d/aabb/aabb3_raycast.js +6 -1
  33. package/src/core/geom/3d/aabb/serializeAABB3Encoded_v0.js +6 -6
  34. package/src/core/geom/3d/{CircleMath.js → compute_circle_bounding_box.js} +1 -1
  35. package/src/core/geom/3d/decompose_matrix_4_array.js +18 -19
  36. package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  37. package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/matrix}/allocate_transform_m4.js +1 -1
  38. package/src/core/geom/3d/normal/hemioct/decode_hemioct_to_unit.js +26 -0
  39. package/src/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +0 -26
  40. package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +2 -1
  41. package/src/core/geom/3d/plane/computePlaneLineIntersection.js +51 -0
  42. package/src/core/geom/3d/plane/computePlanePlaneIntersection.js +77 -0
  43. package/src/core/geom/3d/plane/computePlaneRayIntersection.js +55 -0
  44. package/src/core/geom/3d/plane/plane3_computeLineSegmentIntersection.js +50 -0
  45. package/src/core/geom/3d/plane/planeRayIntersection.js +14 -0
  46. package/src/core/geom/3d/{tetrahedra/in_sphere_fast.js → sphere/in_sphere3d_fast.js} +1 -1
  47. package/src/core/geom/3d/{tetrahedra/in_sphere_robust.js → sphere/in_sphere3d_robust.js} +1 -1
  48. package/src/core/geom/3d/sphere/sphere_array_intersects_point.js +2 -2
  49. package/src/core/geom/3d/sphere/{sphereIntersectsPoint.js → sphere_intersects_point.js} +7 -4
  50. package/src/core/geom/3d/sphere/sphere_intersects_point.spec.js +134 -0
  51. package/src/core/geom/3d/sphere/sphere_intersects_ray.spec.js +49 -0
  52. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +11 -7
  53. package/src/core/geom/3d/tetrahedra/delaunay/{debug_validate_mesh.js → debug/debug_validate_mesh.js} +1 -1
  54. package/src/core/geom/3d/tetrahedra/delaunay/{push_boundary_with_validation.js → debug/push_boundary_with_validation.js} +1 -1
  55. package/src/core/geom/3d/tetrahedra/delaunay/{validate_cavity_boundary.js → debug/validate_cavity_boundary.js} +2 -2
  56. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +2 -2
  57. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +0 -164
  58. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +87 -0
  59. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +81 -0
  60. package/src/core/geom/{rayTriangleIntersection.js → 3d/triangle/rayTriangleIntersection.js} +2 -2
  61. package/src/core/geom/ConicRay.js +160 -152
  62. package/src/core/geom/Matrix4.js +2 -0
  63. package/src/core/geom/Quaternion.js +19 -1
  64. package/src/core/geom/packing/max-rect/MaxRectangles.js +4 -214
  65. package/src/core/geom/packing/max-rect/cost/costByBestShortSide.js +11 -0
  66. package/src/core/geom/packing/max-rect/cost/costByRemainingArea.js +14 -0
  67. package/src/core/geom/packing/max-rect/cutArea.js +79 -0
  68. package/src/core/geom/packing/max-rect/findBestContainer.js +58 -0
  69. package/src/core/geom/packing/max-rect/packOneBox.js +49 -0
  70. package/src/core/geom/packing/miniball/Miniball.js +12 -12
  71. package/src/core/geom/packing/miniball/Quality.js +2 -2
  72. package/src/core/geom/packing/miniball/Subspan.js +13 -13
  73. package/src/core/geom/v3_dot.js +1 -1
  74. package/src/core/graph/layout/CircleLayout.js +1 -1
  75. package/src/core/graph/layout/{BoxLayouter.js → box/BoxLayouter.js} +6 -50
  76. package/src/core/graph/layout/box/applyCentralGravityAABB2.js +29 -0
  77. package/src/core/json/resolvePath.spec.js +14 -0
  78. package/src/core/land/reactive/{compiler/ReactiveCompiler.spec.js → compileReactiveExpression.spec.js} +17 -17
  79. package/src/core/math/random/MersenneTwister.spec.js +19 -0
  80. package/src/core/math/random/randomGaussian.spec.js +9 -0
  81. package/src/core/math/statistics/computeStatisticalMean.js +2 -2
  82. package/src/core/model/reactive/model/arithmetic/ReactiveAdd.js +1 -1
  83. package/src/core/model/reactive/model/arithmetic/ReactiveDivide.js +3 -1
  84. package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.js +1 -1
  85. package/src/core/model/reactive/model/arithmetic/ReactiveNegate.js +3 -1
  86. package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.js +1 -1
  87. package/src/core/model/reactive/model/comparative/ReactiveEquals.js +1 -1
  88. package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.js +3 -1
  89. package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js +3 -1
  90. package/src/core/model/reactive/model/comparative/ReactiveLessThan.js +3 -1
  91. package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.js +3 -1
  92. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.js +1 -1
  93. package/src/core/model/reactive/model/logic/ReactiveAnd.js +1 -1
  94. package/src/core/model/reactive/model/logic/ReactiveNot.js +3 -1
  95. package/src/core/model/reactive/model/logic/ReactiveOr.js +1 -1
  96. package/src/core/primitives/numbers/computeHashFloat.spec.js +7 -0
  97. package/src/core/process/task/util/iteratorTask.js +3 -1
  98. package/src/engine/animation/curve/AnimationCurve.js +34 -5
  99. package/src/engine/animation/curve/AnimationCurve.spec.js +100 -0
  100. package/src/engine/asset/AssetTransformer.js +1 -0
  101. package/src/engine/computeStridedIntegerArrayHash.js +4 -2
  102. package/src/engine/ecs/components/Renderable.d.ts +1 -1
  103. package/src/{ecs → engine/ecs}/grid/pick.js +4 -4
  104. package/src/engine/ecs/parent/entity_node_compute_bounding_box.js +1 -1
  105. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -18
  106. package/src/engine/ecs/systems/MotionSystem.js +7 -1
  107. package/src/engine/ecs/systems/SynchronizePositionSystem.js +8 -2
  108. package/src/engine/ecs/transform/Transform.js +1 -1
  109. package/src/engine/graphics/camera/makeScreenScissorFrustum.js +3 -3
  110. package/src/engine/graphics/camera/testClippingPlaneComputation.js +13 -13
  111. package/src/engine/graphics/ecs/camera/Camera.js +1 -1
  112. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +1 -1
  113. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +9 -0
  114. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +1 -1
  115. package/src/engine/graphics/geometry/MikkT/STSpace.js +1 -1
  116. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  117. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  118. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +1 -1
  119. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +1 -0
  120. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
  121. package/src/engine/graphics/postprocess/threejs/postprocessing/TexturePass.js +2 -2
  122. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -2
  123. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  124. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +1 -1
  125. package/src/engine/intelligence/behavior/Behavior.spec.js +15 -0
  126. package/src/engine/intelligence/mcts/MoveEdge.js +1 -1
  127. package/src/engine/reference/v1/ReferenceManager.js +3 -0
  128. package/src/engine/reference/v2/Reference.js +33 -37
  129. package/src/engine/sound/sopra/README.md +6 -0
  130. package/src/generation/automata/CaveGeneratorCellularAutomata.js +10 -7
  131. package/src/generation/automata/CaveGeneratorCellularAutomata.spec.js +12 -0
  132. package/src/generation/automata/CellularAutomata.js +5 -4
  133. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +25 -9
  134. package/src/view/minimap/dom/MinimapCameraView.js +1 -1
  135. package/src/core/geom/Plane.js +0 -250
  136. package/src/core/land/reactive/ReactiveLexer.js +0 -158
  137. package/src/core/land/reactive/ReactiveLexer.ts +0 -181
  138. package/src/core/land/reactive/ReactiveListener.ts +0 -323
  139. package/src/core/land/reactive/ReactiveParser.js +0 -1573
  140. package/src/core/land/reactive/ReactiveParser.ts +0 -1776
  141. package/src/core/land/reactive/ReactiveVisitor.js +0 -1
  142. package/src/core/land/reactive/ReactiveVisitor.ts +0 -218
  143. package/src/core/land/reactive/compiler/ReactiveCompiler.js +0 -350
  144. package/src/core/land/reactive/compiler/ReactiveNearlyCompiler.js +0 -166
  145. package/src/core/land/reactive/compiler/ReactiveParser.js +0 -34
  146. package/src/core/land/reactive/nearley/ReactiveNearley.js +0 -187
  147. /package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/vector}/allocate_v3.js +0 -0
@@ -25,7 +25,7 @@ export class ReactiveEquals extends ReactiveBinaryExpression {
25
25
  }
26
26
 
27
27
  equals(other) {
28
- return other.isReactiveEquals && super.equals(other);
28
+ return (other.isReactiveEquals === true) && super.equals(other);
29
29
  }
30
30
 
31
31
  toCode() {
@@ -23,9 +23,11 @@ export class ReactiveGreaterThan extends ReactiveBinaryExpression {
23
23
 
24
24
  return r;
25
25
  }
26
+
26
27
  equals(other) {
27
- return other.isReactiveGreaterThan && super.equals(other);
28
+ return (other.isReactiveGreaterThan === true) && super.equals(other);
28
29
  }
30
+
29
31
  toCode() {
30
32
  return `( ${this.left.toCode()} > ${this.right.toCode()} )`
31
33
  }
@@ -23,9 +23,11 @@ export class ReactiveGreaterThanOrEqual extends ReactiveBinaryExpression {
23
23
 
24
24
  return r;
25
25
  }
26
+
26
27
  equals(other) {
27
- return other.isReactiveGreaterThanOrEqual && super.equals(other);
28
+ return (other.isReactiveGreaterThanOrEqual === true) && super.equals(other);
28
29
  }
30
+
29
31
  toCode() {
30
32
  return `( ${this.left.toCode()} >= ${this.right.toCode()} )`
31
33
  }
@@ -23,9 +23,11 @@ export class ReactiveLessThan extends ReactiveBinaryExpression {
23
23
 
24
24
  return r;
25
25
  }
26
+
26
27
  equals(other) {
27
- return other.isReactiveLessThan && super.equals(other);
28
+ return (other.isReactiveLessThan === true) && super.equals(other);
28
29
  }
30
+
29
31
  toCode() {
30
32
  return `( ${this.left.toCode()} < ${this.right.toCode()} )`
31
33
  }
@@ -23,9 +23,11 @@ export class ReactiveLessThanOrEqual extends ReactiveBinaryExpression {
23
23
 
24
24
  return r;
25
25
  }
26
+
26
27
  equals(other) {
27
- return other.isReactiveLessThanOrEqual && super.equals(other);
28
+ return (other.isReactiveLessThanOrEqual === true) && super.equals(other);
28
29
  }
30
+
29
31
  toCode() {
30
32
  return `( ${this.left.toCode()} <= ${this.right.toCode()} )`
31
33
  }
@@ -25,7 +25,7 @@ export class ReactiveNotEquals extends ReactiveBinaryExpression {
25
25
  }
26
26
 
27
27
  equals(other) {
28
- return other.isReactiveNotEquals && super.equals(other);
28
+ return (other.isReactiveNotEquals === true) && super.equals(other);
29
29
  }
30
30
 
31
31
  toCode() {
@@ -35,7 +35,7 @@ export class ReactiveAnd extends ReactiveBinaryExpression {
35
35
  }
36
36
 
37
37
  equals(other) {
38
- return other.isReactiveAnd && super.equals(other);
38
+ return (other.isReactiveAnd === true) && super.equals(other);
39
39
  }
40
40
 
41
41
  toCode() {
@@ -22,9 +22,11 @@ export class ReactiveNot extends ReactiveUnaryExpression {
22
22
 
23
23
  return r;
24
24
  }
25
+
25
26
  equals(other) {
26
- return other.isReactiveNot && super.equals(other);
27
+ return (other.isReactiveNot === true) && super.equals(other);
27
28
  }
29
+
28
30
  toCode() {
29
31
  return `!${this.source.toCode()}`
30
32
  }
@@ -35,7 +35,7 @@ export class ReactiveOr extends ReactiveBinaryExpression {
35
35
  }
36
36
 
37
37
  equals(other) {
38
- return other.isReactiveOr && super.equals(other);
38
+ return (other.isReactiveOr === true) && super.equals(other);
39
39
  }
40
40
 
41
41
  toCode() {
@@ -5,3 +5,10 @@ test("computeHashFloat", () => {
5
5
 
6
6
  expect(computeHashFloat(500)).not.toEqual(computeHashFloat(400))
7
7
  });
8
+
9
+ test("hash is an integer", () => {
10
+ const hash = computeHashFloat(1.237);
11
+
12
+ expect(typeof hash).toBe("number");
13
+ expect(Number.isInteger(hash)).toBe(true);
14
+ });
@@ -1,18 +1,20 @@
1
1
  import Task from "../Task.js";
2
2
  import { TaskSignal } from "../TaskSignal.js";
3
3
  import { assert } from "../../../assert.js";
4
+ import { anyOf, equalTo } from "../../../debug/matchers/matchers.js";
4
5
 
5
6
  /**
6
7
  *
7
8
  * @param {string} name
8
9
  * @param {Iterator} iterator
9
- * @param {TaskSignal.Continue|TaskSignal.Yield} [cycle_signal] what to signal at the end of each iteration, Continue will provide better throughput, whereas Yield will produce very low load on the CPU
10
+ * @param {(TaskSignal.Continue)|(TaskSignal.Yield)} [cycle_signal] what to signal at the end of each iteration, Continue will provide better throughput, whereas Yield will produce very low load on the CPU
10
11
  * @returns {Task}
11
12
  */
12
13
  export function iteratorTask(name, iterator, cycle_signal = TaskSignal.Continue) {
13
14
  assert.defined(iterator, 'iterator');
14
15
  assert.notNull(iterator, 'iterator');
15
16
  assert.isFunction(iterator.next, 'iterator.next');
17
+ assert.that(cycle_signal, 'cycle_signal', anyOf(equalTo(TaskSignal.Continue), equalTo(TaskSignal.Yield)));
16
18
 
17
19
  return new Task({
18
20
  name,
@@ -2,6 +2,7 @@ import { inverseLerp } from "../../../core/math/inverseLerp.js";
2
2
  import { lerp } from "../../../core/math/lerp.js";
3
3
  import { invokeObjectToJSON } from "../../../core/model/object/invokeObjectToJSON.js";
4
4
  import { Keyframe } from "./Keyframe.js";
5
+ import { binarySearchHighIndex } from "../../../core/collection/array/binarySearchHighIndex.js";
5
6
 
6
7
  /**
7
8
  *
@@ -28,6 +29,16 @@ function evaluate(t, keyframe0, keyframe1) {
28
29
  return a * keyframe0.value + b * m0 + c * m1 + d * keyframe1.value;
29
30
  }
30
31
 
32
+ /**
33
+ *
34
+ * @param {number} time
35
+ * @param {Keyframe} keyframe
36
+ * @return {number}
37
+ */
38
+ function compareKeyframeToTime(time, keyframe) {
39
+ return time - keyframe.time;
40
+ }
41
+
31
42
  /**
32
43
  * Modelled on unity's AnimationCurve
33
44
  * @see https://github.com/nothke/ThreadableCurve/blob/master/ThreadableCurve.cs
@@ -46,8 +57,26 @@ export class AnimationCurve {
46
57
  * @param {Keyframe} key
47
58
  */
48
59
  add(key) {
49
- // TODO figure out the right place to insert the key
50
- this.keys.push(key);
60
+ const keys = this.keys;
61
+
62
+ const last_key_index = keys.length - 1;
63
+
64
+ if (
65
+ last_key_index < 0
66
+ || keys[last_key_index].time <= key.time
67
+ ) {
68
+
69
+ // inserted key goes at the end
70
+ keys.push(key);
71
+
72
+ } else {
73
+
74
+ // figure out the right place to insert the key
75
+ const i = binarySearchHighIndex(keys, key.time, compareKeyframeToTime, 0, last_key_index);
76
+
77
+ // insert key at the right place
78
+ keys.splice(i, 0, key);
79
+ }
51
80
  }
52
81
 
53
82
  /**
@@ -144,7 +173,7 @@ export class AnimationCurve {
144
173
  /**
145
174
  *
146
175
  * @param {number} index
147
- * @param {number} weight
176
+ * @param {number} weight value between 0 and 1
148
177
  */
149
178
  smoothTangents(index, weight) {
150
179
  const keys = this.keys;
@@ -173,10 +202,10 @@ export class AnimationCurve {
173
202
 
174
203
  }
175
204
 
176
- smoothAllTangents(){
205
+ smoothAllTangents() {
177
206
  const n = this.length;
178
207
  for (let i = 0; i < n; i++) {
179
- this.smoothTangents(i,0);
208
+ this.smoothTangents(i, 0);
180
209
  }
181
210
  }
182
211
 
@@ -0,0 +1,100 @@
1
+ import { AnimationCurve } from "./AnimationCurve.js";
2
+ import { Keyframe } from "./Keyframe.js";
3
+
4
+ test("constructor does not throw", () => {
5
+ expect(() => new AnimationCurve()).not.toThrow();
6
+ });
7
+
8
+ test("adding key increases length", () => {
9
+ const curve = new AnimationCurve();
10
+
11
+ curve.add(Keyframe.from(1, 7));
12
+
13
+ expect(curve.length).toBe(1);
14
+ });
15
+
16
+ test("removing non-existent key", () => {
17
+ const curve = new AnimationCurve();
18
+
19
+ expect(curve.remove(Keyframe.from(1, 7))).toBe(false);
20
+
21
+ expect(curve.length).toBe(0);
22
+
23
+ });
24
+
25
+ test("clear removes all keys", () => {
26
+
27
+ const curve = new AnimationCurve();
28
+
29
+ curve.add(Keyframe.from(0, 0));
30
+ curve.add(Keyframe.from(0, 0));
31
+
32
+ curve.clear();
33
+
34
+ expect(curve.length).toBe(0);
35
+ });
36
+
37
+ test("removing exising key", () => {
38
+ const curve = new AnimationCurve();
39
+
40
+ const key = Keyframe.from(1, 7);
41
+
42
+ curve.add(key);
43
+
44
+ expect(curve.remove(key)).toBe(true);
45
+
46
+ expect(curve.length).toBe(0);
47
+ });
48
+
49
+
50
+ test("sample linear curve with 2 points", () => {
51
+ const curve = new AnimationCurve();
52
+ curve.add(Keyframe.from(0, -3, 6, 6));
53
+ curve.add(Keyframe.from(1, 3, 6, 6));
54
+
55
+ expect(curve.evaluate(0)).toBeCloseTo(-3);
56
+ expect(curve.evaluate(1)).toBeCloseTo(3);
57
+ expect(curve.evaluate(0.5)).toBeCloseTo(0);
58
+ });
59
+
60
+ test("insert key out of order, should end up ordered", () => {
61
+
62
+ const curve = new AnimationCurve();
63
+
64
+ curve.add(Keyframe.from(0, 3));
65
+ curve.add(Keyframe.from(5, 7));
66
+
67
+ const out_of_order_key = Keyframe.from(1, 11);
68
+ curve.add(out_of_order_key);
69
+
70
+ expect(curve.keys[1]).toBe(out_of_order_key);
71
+
72
+ });
73
+
74
+ test("smooth tangents with a single keyframe does not throw", () => {
75
+ const curve = new AnimationCurve();
76
+
77
+ curve.add(Keyframe.from(0, 7));
78
+
79
+ expect(() => curve.smoothTangents(0, 1)).not.toThrow()
80
+ });
81
+
82
+ test("to/from JSON consistency", () => {
83
+
84
+ const curve = new AnimationCurve();
85
+
86
+ curve.add(Keyframe.from(3, -7, 13, -17));
87
+
88
+ const c2 = new AnimationCurve();
89
+
90
+ c2.fromJSON(curve.toJSON());
91
+
92
+ expect(c2.length).toBe(1);
93
+
94
+ const first_key = c2.keys[0];
95
+
96
+ expect(first_key.time).toBe(3);
97
+ expect(first_key.value).toBe(-7);
98
+ expect(first_key.inTangent).toBe(13);
99
+ expect(first_key.outTangent).toBe(-17);
100
+ });
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Applies a transformation to an asset. Such as performing mesh simplification for example.
3
3
  * Transformation is executed by the {@link AssetManager}
4
+ * Useful for modifying/extending post-processing done on various asset types
4
5
  * @template {Asset<T>} A
5
6
  * @template T
6
7
  */
@@ -1,12 +1,14 @@
1
1
  /**
2
- *
2
+ * Useful for computing hashes of large arrays, can pick a relevant stride and skip large chunks of memory while still capturing good amount of unique information from evenly-spaced areas of the array
3
3
  * @param {number[]|Uint32Array|Uint16Array|Uint8Array} array
4
4
  * @param {number} offset
5
5
  * @param {number} length
6
6
  * @param {number} stride
7
7
  * @return {number}
8
8
  */
9
- export function computeStridedIntegerArrayHash(array, offset, length, stride) {
9
+ export function computeStridedIntegerArrayHash(
10
+ array, offset, length, stride
11
+ ) {
10
12
  let result = length;
11
13
 
12
14
  for (let i = offset; i < length; i += stride) {
@@ -8,7 +8,7 @@ export default class Renderable {
8
8
  matrixAutoUpdate: boolean
9
9
  boundingBoxNeedsUpdate: boolean
10
10
 
11
- bvh: LeafNode
11
+ bvh: LeafNode<Object3D>
12
12
 
13
13
  constructor(object: Object3D)
14
14
  }
@@ -1,7 +1,7 @@
1
- import { assert } from "../../core/assert.js";
2
- import Vector3 from "../../core/geom/Vector3.js";
3
- import { SurfacePoint3 } from "../../core/geom/3d/SurfacePoint3.js";
4
- import Vector2 from "../../core/geom/Vector2.js";
1
+ import { assert } from "../../../core/assert.js";
2
+ import Vector3 from "../../../core/geom/Vector3.js";
3
+ import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
4
+ import Vector2 from "../../../core/geom/Vector2.js";
5
5
 
6
6
  /**
7
7
  *
@@ -1,5 +1,5 @@
1
1
  import { ShadedGeometry } from "../../graphics/ecs/mesh-v2/ShadedGeometry.js";
2
- import { AABB3 } from "../../../core/bvh2/aabb3/AABB3.js";
2
+ import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
3
3
 
4
4
  const scratch_aabb3 = new AABB3();
5
5
 
@@ -3,14 +3,6 @@ import { BinaryCollectionHeaderCodec, BinaryCollectionHeaderLayout } from "./Bin
3
3
  import { HashMap } from "../../../../../core/collection/HashMap.js";
4
4
  import { returnEmptyArray } from "../../../../../core/function/Functions.js";
5
5
 
6
- /**
7
- *
8
- * @returns {Array}
9
- */
10
- function makeEmptyArray() {
11
- return [];
12
- }
13
-
14
6
  export class BinaryCollectionSerializer {
15
7
  constructor() {
16
8
 
@@ -70,16 +62,7 @@ export class BinaryCollectionSerializer {
70
62
  * @type {Map<any, number>}
71
63
  */
72
64
  this.dictionary = new HashMap({
73
- keyHashFunction(key) {
74
- return key.hash();
75
- },
76
- keyEqualityFunction(k0, k1) {
77
- if (k0 === k1) {
78
- return true;
79
- } else {
80
- return k0.equals(k1);
81
- }
82
- }
65
+ capacity: 1024, //pre-allocate larger size to avoid rehashing
83
66
  });
84
67
  }
85
68
 
@@ -17,7 +17,13 @@ class MotionSystem extends System {
17
17
 
18
18
  update(timeDelta) {
19
19
  const entityManager = this.entityManager;
20
- entityManager.traverseEntities([Motion, Transform], function (motion, transform) {
20
+ const ecd = entityManager.dataset;
21
+
22
+ if (ecd === null) {
23
+ return;
24
+ }
25
+
26
+ ecd.traverseEntities([Motion, Transform], function (motion, transform) {
21
27
  const positionDelta = motion.velocity.clone().multiplyScalar(timeDelta);
22
28
  transform.position.add(positionDelta);
23
29
  });
@@ -17,9 +17,15 @@ class SynchronizePositionSystem extends System {
17
17
 
18
18
  update(timeDelta) {
19
19
  const em = this.entityManager;
20
- em.traverseEntities([SynchronizePosition, Transform], function (sync, transform) {
20
+ const ecd = em.dataset;
21
+
22
+ if (ecd === null) {
23
+ return;
24
+ }
25
+
26
+ ecd.traverseEntities([SynchronizePosition, Transform], function (sync, transform) {
21
27
  const targetEntity = sync.targetEntity;
22
- const targetTransform = em.getComponent(targetEntity, Transform);
28
+ const targetTransform = ecd.getComponent(targetEntity, Transform);
23
29
  if (sync.x) {
24
30
  transform.position.x = targetTransform.position.x;
25
31
  }
@@ -7,7 +7,7 @@ import Quaternion from "../../../core/geom/Quaternion.js";
7
7
  import { decompose_matrix_4_array } from "../../../core/geom/3d/decompose_matrix_4_array.js";
8
8
  import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
9
9
  import { TransformFlags } from "./TransformFlags.js";
10
- import { allocate_transform_m4 } from "../../graphics/ecs/mesh-v2/allocate_transform_m4.js";
10
+ import { allocate_transform_m4 } from "../../../core/geom/3d/matrix/allocate_transform_m4.js";
11
11
  import { assert } from "../../../core/assert.js";
12
12
  import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
13
13
  import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
@@ -14,11 +14,11 @@ const nearBR = new ThreeVector3();
14
14
 
15
15
  /**
16
16
  *
17
- * @param {Frustum} frustum
17
+ * @param {Frustum} output
18
18
  * @param {AABB2} box screen-space 2d box in NDC (-1,+1)
19
19
  * @param {THREE.Camera} camera
20
20
  */
21
- export function makeScreenScissorFrustum(frustum, box, camera) {
21
+ export function makeScreenScissorFrustum(output, box, camera) {
22
22
 
23
23
  camera.updateProjectionMatrix();
24
24
  camera.updateMatrixWorld();
@@ -46,7 +46,7 @@ export function makeScreenScissorFrustum(frustum, box, camera) {
46
46
  nearBR.unproject(camera);
47
47
 
48
48
  //create frustum planes
49
- const planes = frustum.planes;
49
+ const planes = output.planes;
50
50
 
51
51
  //set planes
52
52
  planes[0].setFromCoplanarPoints(nearTL, farTL, farTR);
@@ -39,7 +39,7 @@ import { FogOfWarRevealerSystem } from "../../ecs/fow/FogOfWarRevealerSystem.js"
39
39
  import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
40
40
  import { SerializationMetadataSystem } from "../../ecs/systems/SerializationMetadataSystem.js";
41
41
  import { InverseKinematicsSystem } from "../../ecs/animation/InverseKinematicsSystem.js";
42
- import { PathDisplaySystem } from "../../../../model/engine/visual/path/PathDisplaySystem.js";
42
+ import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
43
43
  import RenderSystem from "../../ecs/systems/RenderSystem.js";
44
44
  import { makeEngineOptionsModel } from "../../../../../model/game/options/makeEngineOptionsModel.js";
45
45
  import { enableEditor } from "../../../../editor/enableEditor.js";
@@ -79,7 +79,7 @@ function makeConfig(engine) {
79
79
  const guiSystem = new GUIElementSystem(engine.gui.view, engine);
80
80
  const headsUpDisplaySystem = new HeadsUpDisplaySystem(graphics);
81
81
 
82
- config.systems.push(
82
+ config.addManySystems(
83
83
  new ScriptSystem(),
84
84
  new FacingDirectionSystem(),
85
85
  new PathFollowingSystem(),
@@ -286,16 +286,16 @@ function makeCameraClippingDebug(engine) {
286
286
  const special_hits_1 = [];
287
287
  const special_hits_2 = [];
288
288
 
289
- ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_0.add((x, y, z) => {
290
- special_hits_0.push(new Vector3(x, y, z));
291
- });
292
-
293
- ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_1.add((x, y, z) => {
294
- special_hits_1.push(new Vector3(x, y, z));
295
- });
296
- ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_2.add((x, y, z) => {
297
- special_hits_2.push(new Vector3(x, y, z));
298
- });
289
+ // ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_0.add((x, y, z) => {
290
+ // special_hits_0.push(new Vector3(x, y, z));
291
+ // });
292
+ //
293
+ // ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_1.add((x, y, z) => {
294
+ // special_hits_1.push(new Vector3(x, y, z));
295
+ // });
296
+ // ThreeClippingPlaneComputingBVHVisitor.DEBUG_POINTS_2.add((x, y, z) => {
297
+ // special_hits_2.push(new Vector3(x, y, z));
298
+ // });
299
299
 
300
300
  const buffer = new RingBuffer(100);
301
301
 
@@ -381,7 +381,7 @@ function main(engine) {
381
381
  enableTerrain: true,
382
382
  terrainSize: new Vector2(100, 100),
383
383
  focus: new Vector3(102, 0, 61),
384
- pitch: -0.5,
384
+ pitch: 0.5,
385
385
  yaw: 2.2,
386
386
  distance: 3
387
387
  // pitch: -0.12,
@@ -14,7 +14,7 @@ import { frustum_from_camera } from "./frustum_from_camera.js";
14
14
  import { invertQuaternionOrientation } from "./InvertQuaternionOrientation.js";
15
15
  import { v3_distance_above_plane } from "../../../../core/geom/v3_distance_above_plane.js";
16
16
  import { ProjectionType } from "./ProjectionType.js";
17
- import { computePlaneRayIntersection } from "../../../../core/geom/Plane.js";
17
+ import { computePlaneRayIntersection } from "../../../../core/geom/3d/plane/computePlaneRayIntersection.js";
18
18
 
19
19
  /**
20
20
  * @class
@@ -1,5 +1,5 @@
1
1
  import { entity_node_compute_bounding_box } from "../../../../ecs/parent/entity_node_compute_bounding_box.js";
2
- import { AABB3 } from "../../../../../core/bvh2/aabb3/AABB3.js";
2
+ import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
3
3
 
4
4
  export const SGMeshFlags = {
5
5
  CastShadow: 1,
@@ -10,6 +10,9 @@ import { ParentEntity } from "../../../../ecs/parent/ParentEntity.js";
10
10
  import { EntityNode } from "../../../../ecs/parent/EntityNode.js";
11
11
  import { min2 } from "../../../../../core/math/min2.js";
12
12
  import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/TransformAttachmentSystem.js";
13
+ import { ResourceAccessSpecification } from "../../../../../core/model/ResourceAccessSpecification.js";
14
+ import { ResourceAccessKind } from "../../../../../core/model/ResourceAccessKind.js";
15
+ import { TransformAttachment } from "../../../../ecs/transform-attachment/TransformAttachment.js";
13
16
 
14
17
 
15
18
  /**
@@ -48,6 +51,12 @@ export class SGMeshSystem extends System {
48
51
  this.__assetManager = engine.assetManager;
49
52
 
50
53
  this.dependencies = [SGMesh, Transform];
54
+ this.components_used = [
55
+ ResourceAccessSpecification.from(SGMesh, ResourceAccessKind.Read | ResourceAccessKind.Write),
56
+ ResourceAccessSpecification.from(Transform, ResourceAccessKind.Read),
57
+ ResourceAccessSpecification.from(ShadedGeometry, ResourceAccessKind.Create),
58
+ ResourceAccessSpecification.from(TransformAttachment, ResourceAccessKind.Create),
59
+ ];
51
60
 
52
61
  /**
53
62
  *
@@ -8,7 +8,7 @@ import { InitTriInfo } from "./InitTriInfo.js";
8
8
  import { GenerateTSpaces } from "./GenerateTSpaces.js";
9
9
  import { DegenEpilogue } from "./DegenEpilogue.js";
10
10
  import { Build4RuleGroups } from "./Build4RuleGroups.js";
11
- import { allocate_v3 } from "../../ecs/mesh-v2/allocate_v3.js";
11
+ import { allocate_v3 } from "../../../../core/geom/3d/vector/allocate_v3.js";
12
12
  import { m_getNumFaces } from "./m_getNumFaces.js";
13
13
  import { GenerateInitialVerticesIndexList } from "./GenerateInitialVerticesIndexList.js";
14
14
  import { DegenPrologue } from "./DegenPrologue.js";
@@ -1,5 +1,5 @@
1
1
  import { vec3 } from "gl-matrix";
2
- import { allocate_v3 } from "../../ecs/mesh-v2/allocate_v3.js";
2
+ import { allocate_v3 } from "../../../../core/geom/3d/vector/allocate_v3.js";
3
3
 
4
4
  export class STSpace {
5
5
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import Vector3 from "../../../../../core/geom/Vector3.js";
2
2
 
3
3
  import { Vector3 as ThreeVector3 } from 'three';
4
- import { rayTriangleIntersection } from "../../../../../core/geom/rayTriangleIntersection.js";
4
+ import { rayTriangleIntersection } from "../../../../../core/geom/3d/triangle/rayTriangleIntersection.js";
5
5
  import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
6
6
  import { assert } from "../../../../../core/assert.js";
7
7
  import { v3_length } from "../../../../../core/geom/v3_length.js";
@@ -22,7 +22,7 @@ import { BUFFER_GEOMETRY_UVS } from "./BUFFER_GEOMETRY_UVS.js";
22
22
  import { is_compliant_mesh } from "./is_compliant_mesh.js";
23
23
  import { MaterialDescriptor } from "./MaterialDescriptor.js";
24
24
  import { computeThreeTextureTypeFromDataType } from "../../texture/computeThreeTextureTypeFromDataType.js";
25
- import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
25
+ import { typedArrayToDataType } from "../../../../core/collection/array/typed/typedArrayToDataType.js";
26
26
  import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
27
27
  import {
28
28
  compute_typed_array_constructor_from_data_type
@@ -1,4 +1,4 @@
1
- import { AABB3 } from "../../../../../core/bvh2/aabb3/AABB3.js";
1
+ import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
2
2
  import { RowFirstTable } from "../../../../../core/collection/table/RowFirstTable.js";
3
3
  import Vector3 from "../../../../../core/geom/Vector3.js";
4
4
  import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
@@ -125,6 +125,7 @@ export class ParameterLookupTable {
125
125
  */
126
126
  sample(position, result) {
127
127
  assert.isNumber(position, 'position');
128
+ assert.notNaN(position, 'position');
128
129
  // assert.greaterThanOrEqual(position, 0, 'position');
129
130
  // assert.ok(position >= 0 && position <= 1, `position must be between 0 and 1, instead was ${position}`);
130
131
 
@@ -77,7 +77,7 @@ import TopDownCameraController from "../../../../../ecs/camera/topdown/TopDownCa
77
77
  import { randomFloatBetween } from "../../../../../../../core/math/random/randomFloatBetween.js";
78
78
  import { MicronRenderPlugin } from "../../../../../micron/plugin/MicronRenderPlugin.js";
79
79
  import { obtainTerrain } from "../../../../../../ecs/terrain/util/obtainTerrain.js";
80
- import { pick } from "../../../../../../../ecs/grid/pick.js";
80
+ import { pick } from "../../../../../../ecs/grid/pick.js";
81
81
  import { clamp01 } from "../../../../../../../core/math/clamp01.js";
82
82
  import { randomFromArray } from "../../../../../../../core/math/random/randomFromArray.js";
83
83
  import { SamplingFunctionKind } from "./SamplingFunctionKind.js";