@woosh/meep-engine 2.49.8 → 2.50.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 (197) hide show
  1. package/editor/actions/concrete/ArrayCopyAction.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BinaryBuffer.js +1 -1
  4. package/src/core/binary/BinaryBuffer.spec.js +128 -0
  5. package/src/core/binary/int32_to_binary_string.js +4 -1
  6. package/src/core/binary/int32_to_binary_string.spec.js +9 -0
  7. package/src/core/bvh2/BinaryNode.js +0 -30
  8. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
  9. package/src/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
  10. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
  11. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
  12. package/src/core/cache/Cache.js +31 -29
  13. package/src/core/cache/Cache.spec.js +4 -1
  14. package/src/core/collection/HashMap.js +1 -1
  15. package/src/core/collection/array/{copyArray.js → array_copy.js} +1 -24
  16. package/src/core/collection/array/array_copy_entire.js +21 -0
  17. package/src/core/collection/array/typed/typed_array_copy.js +1 -1
  18. package/src/core/collection/queue/Deque.d.ts +4 -0
  19. package/src/core/collection/queue/Deque.js +5 -7
  20. package/src/core/collection/queue/Deque.spec.js +107 -0
  21. package/src/core/collection/table/RowFirstTable.js +1 -1
  22. package/src/core/geom/2d/aabb/AABB2.d.ts +14 -0
  23. package/src/core/geom/2d/aabb/AABB2.js +9 -7
  24. package/src/core/geom/2d/aabb/AABB2.spec.js +100 -0
  25. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.spec.js +11 -0
  26. package/src/core/geom/2d/aabb/aabb2_compute_overlap.spec.js +56 -0
  27. package/src/core/geom/2d/aabb/aabb2_contains.spec.js +40 -0
  28. package/src/core/geom/2d/bvh/Node2.js +1 -1
  29. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +1 -1
  30. package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
  31. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +35 -0
  32. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +51 -0
  33. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +15 -0
  34. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +30 -0
  35. package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +29 -0
  36. package/src/core/geom/3d/aabb/AABB3.d.ts +4 -0
  37. package/src/core/geom/3d/aabb/AABB3.spec.js +30 -0
  38. package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
  39. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +1 -1
  40. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
  41. package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
  42. package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +1 -1
  43. package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
  44. package/src/core/geom/3d/topology/expandConnectivityByLocality.js +1 -1
  45. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1 -1
  46. package/src/core/geom/Quaternion.d.ts +11 -0
  47. package/src/core/geom/Quaternion.js +36 -27
  48. package/src/core/geom/Quaternion.spec.js +141 -0
  49. package/src/core/geom/Vector2.d.ts +5 -1
  50. package/src/core/geom/Vector2.js +24 -0
  51. package/src/core/geom/Vector3.d.ts +4 -0
  52. package/src/core/geom/Vector3.spec.js +60 -0
  53. package/src/core/graph/GraphUtils.js +4 -2
  54. package/src/core/graph/layout/CircleLayout.js +4 -2
  55. package/src/core/math/bessel_i0.spec.js +43 -0
  56. package/src/core/math/bessel_j0.js +30 -0
  57. package/src/core/math/hash/murmur3_32.spec.js +8 -0
  58. package/src/core/math/hash/squirrel3.spec.js +16 -0
  59. package/src/core/math/interval/NumericInterval.js +1 -0
  60. package/src/core/math/{bessel_i0.js → modified_bessel_i0.js} +5 -2
  61. package/src/core/math/noise/{create_noise_2d.js → create_simplex_noise_2d.js} +2 -2
  62. package/src/core/math/noise/create_simplex_noise_2d.spec.js +21 -0
  63. package/src/core/math/physics/irradiance/interpolate_irradiance_linear.spec.js +20 -0
  64. package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js +4 -4
  65. package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.spec.js +18 -0
  66. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +1 -1
  67. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.spec.js +20 -0
  68. package/src/core/math/random/seededRandomMersenneTwister.spec.js +10 -0
  69. package/src/core/math/spline/spline_bezier3.js +1 -1
  70. package/src/core/math/spline/spline_bezier3_bounds.js +2 -1
  71. package/src/core/math/spline/spline_bezier3_bounds.spec.js +37 -0
  72. package/src/core/math/statistics/computeSampleSize_Cochran.spec.js +12 -0
  73. package/src/core/math/statistics/computeStatisticalPartialMedian.js +4 -0
  74. package/src/core/math/statistics/computeStatisticalPartialMedian.spec.js +13 -0
  75. package/src/core/math/vector_nd_dot.js +16 -0
  76. package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
  77. package/src/core/math/vector_nd_normalize.spec.js +15 -0
  78. package/src/core/process/PromiseWatcher.spec.js +1 -1
  79. package/src/engine/achievements/Achievement.spec.js +21 -0
  80. package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
  81. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +2 -2
  82. package/src/engine/animation/curve/compression/{animation_curve_to_float_array.js → sample_animation_curve_to_float_array.js} +10 -3
  83. package/src/engine/animation/curve/compression/sample_animation_curve_to_float_array.spec.js +29 -0
  84. package/src/engine/animation/curve/draw/build_curve_editor.js +3 -3
  85. package/src/engine/development/performance/RingBufferMetric.js +1 -1
  86. package/src/engine/ecs/EntityManager.js +1 -205
  87. package/src/engine/ecs/animation/Animation.js +2 -180
  88. package/src/engine/ecs/animation/AnimationClip.js +132 -0
  89. package/src/engine/ecs/animation/AnimationClip.spec.js +5 -0
  90. package/src/engine/ecs/animation/AnimationClipFlag.js +7 -0
  91. package/src/engine/ecs/animation/AnimationFlags.js +8 -0
  92. package/src/engine/ecs/animation/AnimationSerializationAdapter.js +32 -0
  93. package/src/engine/ecs/fow/FogOfWar.js +1 -1
  94. package/src/engine/ecs/guid/GUID.js +1 -1
  95. package/src/engine/ecs/systems/AnimationSystem.js +3 -1
  96. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
  97. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
  98. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  99. package/src/engine/ecs/transform/Transform.d.ts +2 -0
  100. package/src/engine/ecs/transform/Transform.spec.js +63 -0
  101. package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
  102. package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
  103. package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
  104. package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
  105. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.js +2 -1
  106. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +1 -1
  107. package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
  108. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
  109. package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
  110. package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
  111. package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
  112. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  113. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
  114. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  115. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
  116. package/src/engine/graphics/load_and_set_cubemap_v0.js +1 -1
  117. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
  118. package/src/engine/graphics/render/Lines.js +1 -1
  119. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
  120. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
  121. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  122. package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
  123. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  124. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
  125. package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
  126. package/src/engine/graphics/render/view/CameraView.js +1 -1
  127. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  128. package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
  129. package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
  130. package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
  131. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
  132. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  133. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
  134. package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
  135. package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
  136. package/src/engine/graphics/texture/CanvasClone.js +5 -1
  137. package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
  138. package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
  139. package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
  140. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
  141. package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
  142. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
  143. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
  144. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
  145. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
  146. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
  147. package/src/engine/graphics/texture/sampler/filter/kaiser_1.js +8 -4
  148. package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +2 -0
  149. package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
  150. package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
  151. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
  152. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
  153. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
  154. package/src/engine/graphics/trail/TemporalPath.js +0 -36
  155. package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
  156. package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
  157. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
  158. package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
  159. package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
  160. package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
  161. package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
  162. package/src/engine/logging/VoidLoggerBackend.js +12 -0
  163. package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
  164. package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
  165. package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
  166. package/src/engine/save/GameStateLoader.js +1 -1
  167. package/src/engine/scene/Scene.d.ts +2 -0
  168. package/src/engine/scene/Scene.js +2 -2
  169. package/src/engine/scene/Scene.spec.js +20 -0
  170. package/src/engine/scene/SceneManager.d.ts +4 -0
  171. package/src/engine/scene/SceneManager.js +46 -23
  172. package/src/engine/scene/SceneManager.spec.js +107 -0
  173. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
  174. package/src/engine/ui/GUIEngine.js +1 -1
  175. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +11 -4
  176. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.spec.js +30 -0
  177. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +18 -2
  178. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.spec.js +17 -0
  179. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +2 -2
  180. package/src/generation/grid/GridData.js +0 -60
  181. package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
  182. package/src/generation/markers/MarkerNode.js +2 -2
  183. package/src/generation/theme/AreaMask.js +3 -1
  184. package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
  185. package/src/core/geom/2d/LineSegment2.js +0 -175
  186. package/src/core/geom/Matrix4.js +0 -275
  187. package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
  188. package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
  189. package/src/engine/physics/cannon/cannon.min.js +0 -27
  190. /package/src/engine/ecs/{animation → ik}/IKMath.js +0 -0
  191. /package/src/engine/ecs/{animation → ik}/IKProblem.js +0 -0
  192. /package/src/engine/ecs/{animation → ik}/IKSolver.js +0 -0
  193. /package/src/engine/ecs/{animation → ik}/InverseKinematics.js +0 -0
  194. /package/src/engine/ecs/{animation → ik}/InverseKinematicsSystem.js +0 -0
  195. /package/src/engine/ecs/{animation → ik}/OneBoneSurfaceAlignmentSolver.js +0 -0
  196. /package/src/engine/ecs/{animation → ik}/TwoBoneInverseKinematicsSolver.js +0 -0
  197. /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
@@ -14,7 +14,9 @@ import { GameAssetType } from "../../../asset/GameAssetType.js";
14
14
  export default function loadSampler2D(url, assetManager) {
15
15
  return new Promise(function (resolve, reject) {
16
16
  assetManager.get({
17
- path: url, type: GameAssetType.Image, callback: (asset) => {
17
+ path: url,
18
+ type: GameAssetType.Image,
19
+ callback: (asset) => {
18
20
  const imageData = asset.create();
19
21
 
20
22
  const width = imageData.width;
@@ -32,7 +34,8 @@ export default function loadSampler2D(url, assetManager) {
32
34
  }
33
35
  const sampler2D = new Sampler2D(buffer, 1, width, height);
34
36
  resolve(sampler2D);
35
- }, failure: reject
37
+ },
38
+ failure: reject
36
39
  });
37
40
  });
38
41
  };
@@ -44,12 +44,15 @@ export function sampler2d_downsample_mipmap(source, destination) {
44
44
  const m0_sx = (current_mip.width + 1) / (current_mip.width);
45
45
  const m0_sy = (current_mip.height + 1) / (current_mip.height);
46
46
 
47
+ const destination_v_scale = dest_height > 1 ? 1 / (dest_height - 1) : 0;
48
+ const destination_u_scale = dest_width > 1 ? 1 / (dest_width - 1) : 0;
49
+
47
50
  for (let y = 0; y < dest_height; y++) {
48
- const v = y / (dest_height - 1);
51
+ const v = y * destination_v_scale;
49
52
 
50
53
  for (let x = 0; x < dest_width; x++) {
51
54
 
52
- const u = x / (dest_width - 1);
55
+ const u = x * destination_u_scale;
53
56
 
54
57
  for (let i = 0; i < itemSize; i++) {
55
58
 
@@ -58,7 +61,9 @@ export function sampler2d_downsample_mipmap(source, destination) {
58
61
 
59
62
  const c_out = lerp(c0, c1, mip_mix);
60
63
 
61
- destination.data[(y * dest_width + x) * itemSize + i] = c_out;
64
+ const destination_address = (y * dest_width + x) * itemSize + i;
65
+
66
+ destination.data[destination_address] = c_out;
62
67
  }
63
68
  }
64
69
  }
@@ -0,0 +1,13 @@
1
+ import { Sampler2D } from "../Sampler2D.js";
2
+ import { sampler2d_downsample_mipmap } from "./sampler2d_downsample_mipmap.js";
3
+
4
+ test("downsample solid fill from 2x2 to 1x1", () => {
5
+ const input = Sampler2D.uint8(1, 2, 2);
6
+
7
+ input.data.fill(7);
8
+
9
+ const result = Sampler2D.uint8(1, 1, 1);
10
+ sampler2d_downsample_mipmap(input, result);
11
+
12
+ expect(result.readChannel(0, 0, 0)).toBeCloseTo(7)
13
+ });
@@ -0,0 +1,58 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]|Float32Array|Uint8Array|Uint32Array} result
6
+ * @param {number} result_offset
7
+ * @param {Sampler2D} sampler
8
+ * @param {number} [channel]
9
+ * @return {number}
10
+ */
11
+ export function sampler2d_channel_compute_min_indices(
12
+ result, result_offset,
13
+ sampler, channel = 0
14
+ ) {
15
+ assert.defined(sampler, 'sampler');
16
+ assert.isNonNegativeInteger(result_offset, 'result_offset');
17
+
18
+ const itemSize = sampler.itemSize;
19
+
20
+ assert.isNumber(channel, "channel");
21
+ assert.isNonNegativeInteger(channel, 'channel');
22
+ assert.ok(channel >= 0, `channel must be >= 0, was ${channel}`);
23
+ assert.ok(channel < itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
24
+
25
+ assert.isArrayLike(result, "result");
26
+
27
+ const data = this.data;
28
+
29
+ const l = data.length;
30
+
31
+ if (l === 0) {
32
+ //no data
33
+ return 0;
34
+ }
35
+
36
+ let bestValue = data[channel];
37
+
38
+ let result_count = 0;
39
+
40
+ for (let i = channel + itemSize; i < l; i += itemSize) {
41
+ const value = data[i];
42
+
43
+ if (bestValue > value) {
44
+ bestValue = value;
45
+ //drop result
46
+ result_count = 1;
47
+
48
+ result[result_offset] = i;
49
+ } else if (value === bestValue) {
50
+ result[result_offset + result_count] = i;
51
+
52
+ result_count++;
53
+ }
54
+
55
+ }
56
+
57
+ return result_count;
58
+ }
@@ -59,33 +59,6 @@ TemporalPath.prototype.update = function (timeDelta) {
59
59
  this.updateSequence();
60
60
  };
61
61
 
62
-
63
- /**
64
- *
65
- * @param {number} t value between 0..1, falls between points p1 and p2
66
- * @param {number[]} p0
67
- * @param {number[]} p1
68
- * @param {number[]} p2
69
- * @param {number[]} p3
70
- * @param {number[]} result
71
- */
72
- function catmullRomSample(t, p0, p1, p2, p3, result) {
73
-
74
- for (let j = 0; j < 4; j++) {
75
- const v0 = p0[j];
76
- const v1 = p1[j];
77
- const v2 = p2[j];
78
- const v3 = p3[j];
79
-
80
- const t2 = t * t;
81
- const t3 = t2 * t;
82
-
83
- const qT = 0.5 * (2 * v1 + (v2 - v0) * t + (2 * v0 - 5 * v1 + 4 * v2 - v3) * t2 + (3 * v1 - v0 - 3 * v2 + v3) * t3);
84
-
85
- result[j] = qT;
86
- }
87
- }
88
-
89
62
  /**
90
63
  * @returns {number}
91
64
  */
@@ -133,15 +106,6 @@ TemporalPath.prototype.computeLength = function () {
133
106
  return result;
134
107
  };
135
108
 
136
- /**
137
- *
138
- * @param {number} sampleCount
139
- * @param {Float32Array} result
140
- */
141
- TemporalPath.prototype.sampleSmoothPath = function (sampleCount, result) {
142
-
143
- };
144
-
145
109
  /**
146
110
  *
147
111
  * @param {number} x
@@ -21,7 +21,7 @@ test("1 succeeding child", () => {
21
21
 
22
22
  p.initialize();
23
23
 
24
- expect(p.tick()).toBe(BehaviorStatus.Succeeded);
24
+ expect(p.tick(1)).toBe(BehaviorStatus.Succeeded);
25
25
 
26
26
  p.finalize();
27
27
 
@@ -43,8 +43,8 @@ test("1 succeeding child, 1 tick delay", () => {
43
43
 
44
44
  p.initialize();
45
45
 
46
- expect(p.tick()).toBe(BehaviorStatus.Running);
47
- expect(p.tick()).toBe(BehaviorStatus.Succeeded);
46
+ expect(p.tick(1)).toBe(BehaviorStatus.Running);
47
+ expect(p.tick(1)).toBe(BehaviorStatus.Succeeded);
48
48
 
49
49
  p.finalize();
50
50
 
@@ -66,7 +66,7 @@ test("1 failing child", () => {
66
66
 
67
67
  p.initialize();
68
68
 
69
- expect(p.tick()).toBe(BehaviorStatus.Failed);
69
+ expect(p.tick(1)).toBe(BehaviorStatus.Failed);
70
70
 
71
71
  p.finalize();
72
72
 
@@ -88,8 +88,8 @@ test("1 failing child, 1 tick delay", () => {
88
88
 
89
89
  p.initialize();
90
90
 
91
- expect(p.tick()).toBe(BehaviorStatus.Running);
92
- expect(p.tick()).toBe(BehaviorStatus.Failed);
91
+ expect(p.tick(1)).toBe(BehaviorStatus.Running);
92
+ expect(p.tick(1)).toBe(BehaviorStatus.Failed);
93
93
 
94
94
  p.finalize();
95
95
 
@@ -111,7 +111,7 @@ test("policy success-One, failure-One. Succeeding", () => {
111
111
 
112
112
  p.initialize();
113
113
 
114
- expect(p.tick()).toBe(BehaviorStatus.Succeeded);
114
+ expect(p.tick(1)).toBe(BehaviorStatus.Succeeded);
115
115
  });
116
116
 
117
117
  test("policy success-All, failure-One. Succeeding", () => {
@@ -127,8 +127,8 @@ test("policy success-All, failure-One. Succeeding", () => {
127
127
 
128
128
  p.initialize();
129
129
 
130
- expect(p.tick()).toBe(BehaviorStatus.Running);
131
- expect(p.tick()).toBe(BehaviorStatus.Succeeded);
130
+ expect(p.tick(1)).toBe(BehaviorStatus.Running);
131
+ expect(p.tick(1)).toBe(BehaviorStatus.Succeeded);
132
132
  });
133
133
 
134
134
  test("policy success-One, failure-One. Failing", () => {
@@ -144,7 +144,7 @@ test("policy success-One, failure-One. Failing", () => {
144
144
 
145
145
  p.initialize();
146
146
 
147
- expect(p.tick()).toBe(BehaviorStatus.Failed);
147
+ expect(p.tick(1)).toBe(BehaviorStatus.Failed);
148
148
  });
149
149
 
150
150
  test("policy success-One, failure-All. Failing", () => {
@@ -160,6 +160,6 @@ test("policy success-One, failure-All. Failing", () => {
160
160
 
161
161
  p.initialize();
162
162
 
163
- expect(p.tick()).toBe(BehaviorStatus.Running);
164
- expect(p.tick()).toBe(BehaviorStatus.Failed);
163
+ expect(p.tick(1)).toBe(BehaviorStatus.Running);
164
+ expect(p.tick(1)).toBe(BehaviorStatus.Failed);
165
165
  });
@@ -0,0 +1,17 @@
1
+ import { SequenceBehavior } from "./SequenceBehavior.js";
2
+ import { SucceedingBehavior } from "../primitive/SucceedingBehavior.js";
3
+ import { BehaviorStatus } from "../BehaviorStatus.js";
4
+
5
+ test("constructor does not throw", () => {
6
+ expect(() => new SequenceBehavior()).not.toThrow();
7
+ });
8
+
9
+ test("succeed in 1 tick with 1 succeeding child", () => {
10
+
11
+ const b = SequenceBehavior.from([new SucceedingBehavior()]);
12
+
13
+ b.initialize();
14
+
15
+ expect(b.tick(1)).toEqual(BehaviorStatus.Succeeded);
16
+
17
+ });
@@ -36,6 +36,8 @@ export class SucceedingBehavior extends Behavior {
36
36
  return BehaviorStatus.Running;
37
37
  }
38
38
  }
39
+
40
+ static INSTANCE = new SucceedingBehavior();
39
41
  }
40
42
 
41
43
  SucceedingBehavior.typeName = "SucceedingBehavior";
@@ -1,3 +1,9 @@
1
- export class StaticKnowledgeDataTable {
1
+ export class StaticKnowledgeDataTable<T> {
2
+ reset(): void
2
3
 
4
+ size(): number
5
+
6
+ get(id: string): T | null
7
+
8
+ add(item: T): boolean
3
9
  }
@@ -3,3 +3,24 @@ import { StaticKnowledgeDataTable } from "./StaticKnowledgeDataTable.js";
3
3
  test("constructor does not throw", () => {
4
4
  expect(() => new StaticKnowledgeDataTable()).not.toThrow();
5
5
  });
6
+
7
+ test("resetting empty works as expected", () => {
8
+ const table = new StaticKnowledgeDataTable();
9
+
10
+ table.reset();
11
+
12
+ expect(table.size()).toEqual(0);
13
+ });
14
+
15
+ test("getter", () => {
16
+
17
+ const table = new StaticKnowledgeDataTable();
18
+
19
+ expect(table.get("x")).toEqual(null);
20
+
21
+ const item = { id: "x" };
22
+
23
+ table.add(item);
24
+
25
+ expect(table.get('x')).toBe(item);
26
+ });
@@ -1,7 +1,7 @@
1
1
  import {StaticKnowledgeDataTable} from "./StaticKnowledgeDataTable";
2
2
 
3
- export class StaticKnowledgeDataTableDescriptor {
4
- public table: StaticKnowledgeDataTable
3
+ export class StaticKnowledgeDataTableDescriptor<T> {
4
+ public table: StaticKnowledgeDataTable<T>
5
5
  public id: string
6
6
  public source: string
7
7
  }
@@ -3,6 +3,10 @@ import { LogLevel } from "./LogLevel.js";
3
3
 
4
4
  let instance;
5
5
 
6
+ /**
7
+ * Directs output into system console
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/console
9
+ */
6
10
  export class ConsoleLoggerBackend extends LoggerBackend {
7
11
  log(level, message) {
8
12
  switch (level) {
@@ -0,0 +1,12 @@
1
+ import { LoggerBackend } from "./LoggerBackend.js";
2
+
3
+ /**
4
+ * Non-logging backend, used for testing or when log collection is unwanted
5
+ */
6
+ export class VoidLoggerBackend extends LoggerBackend {
7
+ log(level, message) {
8
+ // do nothing
9
+ }
10
+
11
+ static INSTANCE = new VoidLoggerBackend()
12
+ }
@@ -1,6 +1,6 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
  import { clamp } from "../../../../core/math/clamp.js";
3
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
3
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
4
4
  import { computeNonuniformCatmullRomSplineSample } from "./computeNonuniformCatmullRomSplineSample.js";
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { clamp } from "../../../../core/math/clamp.js";
2
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
2
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
3
3
  import { computeNonuniformCatmullRomSplineSample } from "./computeNonuniformCatmullRomSplineSample.js";
4
4
  import { assert } from "../../../../core/assert.js";
5
5
 
@@ -5,7 +5,7 @@ import { System } from '../../engine/ecs/System';
5
5
  import Transform from '../../engine/ecs/components/Transform';
6
6
  import PhysicalBody from '../../engine/ecs/components/PhysicalBody';
7
7
  import Vector3 from '../../core/geom/Vector3';
8
- import Cannon from './cannon.min.js';
8
+ import Cannon from './cannon.min.js'; //TODO replace with package import
9
9
 
10
10
 
11
11
  class CannonPhysicsSystem extends System {
@@ -26,7 +26,7 @@ class GameStateLoader extends EnginePlugin {
26
26
  save(name, resolve, reject, progress) {
27
27
  const engine = this.engine;
28
28
 
29
- const currentScene = engine.sceneManager.currentScene;
29
+ const currentScene = engine.sceneManager.current_scene;
30
30
 
31
31
 
32
32
  /**
@@ -1,5 +1,7 @@
1
1
  import {EntityComponentDataset} from "../ecs/EntityComponentDataset";
2
2
 
3
3
  export default class Scene {
4
+ constructor(name?: string)
5
+
4
6
  public dataset: EntityComponentDataset
5
7
  }
@@ -11,10 +11,10 @@ import { promiseTask } from "../../core/process/task/util/promiseTask.js";
11
11
  class Scene {
12
12
  /**
13
13
  *
14
- * @param {string} name
14
+ * @param {string} [name]
15
15
  * @constructor
16
16
  */
17
- constructor(name) {
17
+ constructor(name = "Unnamed") {
18
18
  /**
19
19
  *
20
20
  * @type {string}
@@ -0,0 +1,20 @@
1
+ import Scene from "./Scene.js";
2
+ import { EntityComponentDataset } from "../ecs/EntityComponentDataset.js";
3
+
4
+ test("constructor should not throw", () => {
5
+ expect(() => new Scene()).not.toThrow();
6
+ });
7
+
8
+ test("new scene has it's own dataset", () => {
9
+ const scene = new Scene();
10
+
11
+ expect(scene.dataset).not.toBeNull();
12
+ expect(scene.dataset).toBeDefined();
13
+ expect(scene.dataset).toBeInstanceOf(EntityComponentDataset);
14
+ });
15
+
16
+ test("name properly through constructor", () => {
17
+ const scene = new Scene("x");
18
+
19
+ expect(scene.name).toBe("x");
20
+ });
@@ -1,6 +1,10 @@
1
1
  import Scene from "./Scene";
2
+ import {EntityManager} from "../ecs/EntityManager";
2
3
 
3
4
  export default class SceneManager {
5
+ readonly current_scene:Scene|null
6
+ readonly entity_manager: EntityManager
7
+
4
8
  create(name: string): Scene
5
9
 
6
10
  add(scene: Scene): void
@@ -7,6 +7,34 @@ import List from "../../core/collection/list/List.js";
7
7
 
8
8
 
9
9
  class SceneManager {
10
+ /**
11
+ *
12
+ * @type {Scene|null}
13
+ */
14
+ #current_scene = null
15
+
16
+ /**
17
+ *
18
+ * @return {Scene|null}
19
+ */
20
+ get current_scene() {
21
+ return this.#current_scene;
22
+ }
23
+
24
+ /**
25
+ *
26
+ * @type {EntityManager|null}
27
+ */
28
+ #entity_manager = null;
29
+
30
+ /**
31
+ *
32
+ * @return {EntityManager|null}
33
+ */
34
+ get entity_manager(){
35
+ return this.#entity_manager;
36
+ }
37
+
10
38
  /**
11
39
  *
12
40
  * @param {EntityManager} entityManager
@@ -14,20 +42,17 @@ class SceneManager {
14
42
  * @constructor
15
43
  */
16
44
  constructor(entityManager, clock) {
17
- /**
18
- *
19
- * @type {Scene|null}
20
- */
21
- this.currentScene = null;
45
+
22
46
  /**
23
47
  * @type {List<Scene>}
24
48
  */
25
49
  this.scenes = new List();
50
+
26
51
  /**
27
52
  *
28
53
  * @type {EntityManager}
29
54
  */
30
- this.entityManager = entityManager;
55
+ this.#entity_manager = entityManager;
31
56
 
32
57
  /**
33
58
  *
@@ -113,10 +138,10 @@ class SceneManager {
113
138
  const scene = this.scenes.get(sceneIndex);
114
139
 
115
140
 
116
- if (this.currentScene === scene) {
141
+ if (this.#current_scene === scene) {
117
142
  this.deactivateCurrentScene();
118
143
 
119
- this.currentScene = null;
144
+ this.#current_scene = null;
120
145
  }
121
146
 
122
147
  this.scenes.remove(sceneIndex);
@@ -130,11 +155,11 @@ class SceneManager {
130
155
  */
131
156
  clear() {
132
157
 
133
- if (this.currentScene !== null) {
134
- this.currentScene.active.set(false);
135
- this.entityManager.detachDataSet();
158
+ if (this.#current_scene !== null) {
159
+ this.#current_scene.active.set(false);
160
+ this.#entity_manager.detachDataSet();
136
161
 
137
- this.currentScene = null;
162
+ this.#current_scene = null;
138
163
  }
139
164
 
140
165
  return this;
@@ -146,9 +171,7 @@ class SceneManager {
146
171
  * @returns {boolean}
147
172
  */
148
173
  exists(name) {
149
- return this.scenes.some(function (scene) {
150
- return scene.name === name;
151
- });
174
+ return this.getByName(name) !== undefined;
152
175
  }
153
176
 
154
177
  /**
@@ -170,8 +193,8 @@ class SceneManager {
170
193
 
171
194
  scene.active.set(false);
172
195
 
173
- if (this.entityManager.dataset === scene.dataset) {
174
- this.entityManager.detachDataSet();
196
+ if (this.#entity_manager.dataset === scene.dataset) {
197
+ this.#entity_manager.detachDataSet();
175
198
  }
176
199
 
177
200
  //remove speed modifiers
@@ -200,7 +223,7 @@ class SceneManager {
200
223
  console.error(`Exception in pre-activation routine of scene '${scene.id}'`, e);
201
224
  }
202
225
 
203
- const em = this.entityManager;
226
+ const em = this.#entity_manager;
204
227
 
205
228
  em.attachDataSet(scene.dataset);
206
229
 
@@ -218,7 +241,7 @@ class SceneManager {
218
241
  console.error(`Exception in post-activation routine of scene '${scene.id}'`, e);
219
242
  }
220
243
 
221
- this.currentScene = scene;
244
+ this.#current_scene = scene;
222
245
  }
223
246
 
224
247
  /**
@@ -226,7 +249,7 @@ class SceneManager {
226
249
  */
227
250
  deactivateCurrentScene() {
228
251
 
229
- const currentScene = this.currentScene;
252
+ const currentScene = this.#current_scene;
230
253
 
231
254
  if (currentScene !== null) {
232
255
  this.deactivateScene(currentScene);
@@ -261,12 +284,12 @@ class SceneManager {
261
284
  throw new Error(`Scene named '${name}' doesn't exist, valid options are: [${this.scenes.map(s => s.name).join(', ')}]`);
262
285
  }
263
286
 
264
- if (this.currentScene === scene) {
287
+ if (this.#current_scene === scene) {
265
288
  //already at that scene
266
289
  return;
267
290
  }
268
291
 
269
- const em = this.entityManager;
292
+ const em = this.#entity_manager;
270
293
 
271
294
  // Ensure that all system components are registered
272
295
  scene.dataset.registerManyComponentTypes(em.getComponentTypeMap());
@@ -281,7 +304,7 @@ class SceneManager {
281
304
  */
282
305
  stackPush(id) {
283
306
  //take current scene and put it onto the stack
284
- this.stack.push(this.currentScene.name);
307
+ this.stack.push(this.#current_scene.name);
285
308
 
286
309
  this.set(id);
287
310
  }