@woosh/meep-engine 2.43.0 → 2.43.3

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 (105) hide show
  1. package/core/bvh2/aabb3/aabb3_array_combine.js +2 -2
  2. package/core/collection/RingBuffer.js +4 -2
  3. package/core/collection/RingBuffer.spec.js +59 -0
  4. package/core/collection/array/ArrayIteratorRandom.js +1 -1
  5. package/core/collection/{ArrayUtils.spec.js → array/arrayPickBestElement.spec.js} +1 -1
  6. package/core/collection/array/arrayPickBestElements.js +51 -0
  7. package/core/collection/array/arrayPickMinElement.js +43 -0
  8. package/core/collection/array/arrayQuickSort.js +1 -1
  9. package/core/collection/array/arraySetSortingDiff.js +1 -1
  10. package/core/collection/array/arraySwapElements.js +12 -0
  11. package/core/collection/array/groupArrayBy.js +42 -0
  12. package/core/collection/array/isArrayEqual.js +50 -0
  13. package/core/collection/array/randomMultipleFromArray.js +34 -0
  14. package/core/collection/array/randomizeArrayElementOrder.js +23 -0
  15. package/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +1 -1
  16. package/core/geom/3d/aabb/aabb3_build_frustum.js +1 -1
  17. package/core/geom/3d/aabb/compute_aabb_from_points.js +1 -1
  18. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +3 -1
  19. package/core/geom/3d/morton/v3_morton_encode_transformed.spec.js +20 -0
  20. package/core/geom/3d/plane/orient3d_fast.js +8 -10
  21. package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +0 -23
  22. package/core/geom/3d/plane/plane_three_compute_convex3_plane_intersection.js +24 -0
  23. package/core/geom/3d/shape/UnionShape3D.js +1 -1
  24. package/core/geom/3d/tetrahedra/README.md +10 -1
  25. package/core/geom/3d/tetrahedra/{tetrahedra_collection.js → TetrahedralMesh.js} +236 -152
  26. package/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +156 -0
  27. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +2 -2
  28. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +4 -4
  29. package/core/geom/3d/tetrahedra/delaunay/Cavity.js +45 -7
  30. package/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +44 -9
  31. package/core/geom/3d/tetrahedra/delaunay/debug_validate_mesh.js +19 -0
  32. package/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +155 -0
  33. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity2.js +224 -0
  34. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_sub_determinant.js +77 -0
  35. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_sub_determinant.spec.js +30 -0
  36. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_insert_point.js +98 -0
  37. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_toward_cavity.js +13 -6
  38. package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +9 -9
  39. package/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +1 -1
  40. package/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +83 -0
  41. package/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.spec.js +24 -0
  42. package/core/geom/3d/tetrahedra/tetrahedron_contains_point.spec.js +66 -0
  43. package/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +119 -0
  44. package/core/geom/Bezier.js +0 -27
  45. package/core/geom/Plane.js +0 -4
  46. package/core/geom/packing/miniball/Subspan.js +2 -2
  47. package/core/geom/v3_lerp.js +6 -1
  48. package/core/math/isqrt.js +28 -0
  49. package/core/math/isqrt.spec.js +9 -0
  50. package/core/math/max.spec.js +25 -0
  51. package/core/math/min2.spec.js +25 -0
  52. package/core/model/node-graph/node/NodeInstance.js +3 -3
  53. package/core/primitives/strings/prefixTree/PrefixTreeLeaf.js +1 -1
  54. package/core/process/task/util/randomCountTask.js +1 -1
  55. package/editor/ecs/component/editors/primitive/ArrayEditor.js +1 -1
  56. package/editor/tools/v2/BlenderCameraOrientationGizmo.js +6 -0
  57. package/editor/view/ecs/components/common/AutoCanvasView.js +13 -25
  58. package/engine/asset/AssetManager.d.ts +7 -1
  59. package/engine/asset/AssetManager.js +50 -15
  60. package/engine/asset/AssetManager.spec.js +17 -11
  61. package/engine/asset/AssetRequest.js +57 -0
  62. package/engine/asset/loaders/ArrayBufferLoader.js +22 -0
  63. package/engine/asset/loaders/AssetLoader.js +1 -1
  64. package/engine/ecs/System.js +1 -1
  65. package/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -1
  66. package/engine/graphics/FrameRunner.js +5 -9
  67. package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +1 -1
  68. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +1 -1
  69. package/engine/graphics/ecs/camera/Camera.js +1 -10
  70. package/engine/graphics/ecs/camera/CameraSystem.js +8 -8
  71. package/engine/graphics/ecs/camera/ProjectionType.js +9 -0
  72. package/engine/graphics/ecs/camera/build_three_camera_object.js +3 -3
  73. package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +59 -4
  74. package/engine/graphics/geometry/VertexDataSpec.js +1 -1
  75. package/engine/graphics/impostors/octahedral/prototypeBaker.js +3 -3
  76. package/engine/graphics/micron/plugin/GLTFAssetTransformer.js +1 -1
  77. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +3 -1
  78. package/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.js +1 -1
  79. package/engine/graphics/render/forward_plus/LightManager.js +1 -1
  80. package/engine/graphics/render/forward_plus/LightManager.spec.js +4 -0
  81. package/engine/graphics/render/forward_plus/computeFrustumCorners.js +4 -2
  82. package/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
  83. package/engine/graphics/render/layers/RenderLayerUtils.js +2 -2
  84. package/engine/graphics/shaders/DenoiseShader.js +1 -1
  85. package/engine/graphics/texture/atlas/AtlasPatch.js +11 -3
  86. package/engine/graphics/texture/atlas/CachingTextureAtlas.js +2 -2
  87. package/engine/graphics/texture/atlas/TextureAtlas.js +7 -1
  88. package/engine/graphics/texture/atlas/TextureAtlas.spec.js +22 -0
  89. package/engine/graphics/texture/sampler/Sampler2D.js +0 -64
  90. package/engine/graphics/texture/sampler/Sampler2D.spec.js +2 -1
  91. package/engine/graphics/texture/sampler/sampler2d_combine.js +67 -0
  92. package/engine/intelligence/behavior/ecs/BehaviorSystem.spec.js +0 -3
  93. package/engine/network/PriorityFetch.js +192 -0
  94. package/engine/simulation/DormandPrince.js +1 -1
  95. package/engine/ui/DraggableAspect.js +0 -1
  96. package/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
  97. package/package.json +1 -1
  98. package/view/elements/CanvasView.js +7 -1
  99. package/view/elements/image/HTMLElementCacheKey.js +1 -1
  100. package/view/util/DomSizeObserver.js +3 -5
  101. package/core/collection/ArrayUtils.js +0 -263
  102. package/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +0 -73
  103. package/core/geom/3d/tetrahedra/hxt/a.js +0 -524
  104. package/core/geom/3d/tetrahedra/hxt/hxt.js +0 -140
  105. package/core/geom/3d/tetrahedra/hxt/hxt.wasm +0 -0
@@ -13,9 +13,9 @@ import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/
13
13
  import { SGMesh } from "../../mesh-v2/aggregate/SGMesh.js";
14
14
  import { GameAssetType } from "../../../../asset/GameAssetType.js";
15
15
  import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
16
- import { TaskLoadingScreen } from "../../../../../view/task/TaskLoadingScreen.js";
17
16
  import '../../../../../../../../css/game.scss';
18
17
  import { countTask } from "../../../../../core/process/task/util/countTask.js";
18
+ import Vector2 from "../../../../../core/geom/Vector2.js";
19
19
 
20
20
  const decal_urls = `data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_13_t.png
21
21
  data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_01_t.png
@@ -207,6 +207,55 @@ function promise_time_out(t) {
207
207
  });
208
208
  }
209
209
 
210
+ /**
211
+ *
212
+ * @param ecd
213
+ * @param {number} x
214
+ * @param {number} y
215
+ * @param {number} size_x
216
+ * @param {number} size_y
217
+ * @param {number} spacing
218
+ * @param {string[]} textures
219
+ */
220
+ function grid(ecd, offset_x, offset_y,x, y, size_x, size_y, spacing, textures) {
221
+
222
+ const random = seededRandom();
223
+
224
+ for (let i = 0; i < x; i++) {
225
+ for (let j = 0; j < y; j++) {
226
+
227
+ const decal = new Decal();
228
+
229
+ decal.uri = randomFromArray(random, textures);
230
+
231
+ const entity = new EntityBuilder();
232
+
233
+ entity.clearFlag(EntityBuilderFlags.WatchDestruction);
234
+
235
+ const transform = new Transform();
236
+ transform.position.set(
237
+ i * (size_x + spacing) + offset_x,
238
+ 0,
239
+ j * (size_y + spacing) + offset_y,
240
+ );
241
+ // transform.rotation.alignToDirection(Vector3.down);
242
+ // transform.rotation.set(0,0,-0.7,0.7);
243
+ // transform.rotation.set(0,0.7,0,0.7);
244
+ transform.rotation.set(-0.7, 0, 0, 0.7);
245
+ // transform.rotation.random(random);
246
+ transform.scale.set(size_x, size_y,1 );
247
+ // transform.scale.setScalar(1);
248
+
249
+ entity
250
+ .add(transform)
251
+ .add(decal)
252
+ .build(ecd);
253
+
254
+ }
255
+ }
256
+
257
+ }
258
+
210
259
  /**
211
260
  *
212
261
  * @param {Engine} engine
@@ -216,7 +265,9 @@ async function main(engine) {
216
265
  await EngineHarness.buildBasics({
217
266
  engine,
218
267
  enableWater: false,
219
- cameraFarDistance: 300
268
+ cameraFarDistance: 300,
269
+ terrainResolution: 1,
270
+ terrainSize: new Vector2(1000, 1000)
220
271
  });
221
272
 
222
273
  new EntityBuilder()
@@ -265,7 +316,7 @@ async function main(engine) {
265
316
 
266
317
  const task = countTask(0, ENTITY_COUNT, makeOne);
267
318
 
268
- TaskLoadingScreen.instance.load(engine, task);
319
+ // TaskLoadingScreen.instance.load(engine, task);
269
320
 
270
321
  // console.profile('spawn');
271
322
 
@@ -273,8 +324,12 @@ async function main(engine) {
273
324
  // console.profileEnd('spawn');
274
325
  });
275
326
 
276
- engine.executor.run(task);
327
+ // engine.executor.run(task);
328
+
329
+
330
+ grid(engine.entityManager.dataset, 20,10,80, 25, .4, .6, .1, decal_urls.slice(105, 105+3));
277
331
 
332
+ grid(engine.entityManager.dataset, 20,30,80, 25, .4, .6, .1, decal_urls.slice(105, 105+3));
278
333
  // await promise_time_out(10);
279
334
 
280
335
 
@@ -1,6 +1,6 @@
1
- import { isArrayEqual } from "../../../core/collection/ArrayUtils.js";
2
1
  import { invokeObjectHash } from "../../../core/model/object/invokeObjectHash.js";
3
2
  import { computeHashArray } from "../../../core/collection/array/computeHashArray.js";
3
+ import { isArrayEqual } from "../../../core/collection/array/isArrayEqual.js";
4
4
 
5
5
  const DEFAULT_HASH = 123456;
6
6
 
@@ -51,10 +51,10 @@ async function main(engine) {
51
51
  // const path = 'data/models/road_bike/road_bike.gltf'; //large CAD-type model
52
52
  // const path = 'data/models/LowPolyTownshipSet/Barrel/model.gltf';
53
53
  // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
54
- const path = 'data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf';
54
+ // const path = 'data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf';
55
55
  // const path = 'data/models/MOBA and Tower Defense/Tree_01.gltf';
56
56
  // const path = 'data/models/samples/transform-hierarchy.glb';
57
- // const path = 'data/models/sponza-pbr/gltf/sponza.glb';
57
+ const path = 'data/models/sponza-pbr/gltf/sponza.glb';
58
58
  // const path = 'moicon/gnutti_not_optimized/model.gltf';
59
59
  // const path = 'moicon/isiflow_Oct_15_21/1/model.gltf';
60
60
  // const path = 'moicon/Kople/EVCharger1.gltf';
@@ -64,7 +64,7 @@ async function main(engine) {
64
64
  // console.profile('bake');
65
65
  const id = baker.bake({
66
66
  objects,
67
- frames: 8,
67
+ frames: 24,
68
68
  resolution: 1024,
69
69
  type: ImpostorCaptureType.Hemisphere
70
70
  });
@@ -174,7 +174,7 @@ export class GLTFAssetTransformer extends AssetTransformer {
174
174
  const micron_path = `${base}/${uri}`;
175
175
 
176
176
  try {
177
- micron_data = await this.__am.promise(micron_path, ASSET_TYPE_ARRAY_BUFFER);
177
+ micron_data = await this.__am.promise(micron_path, ASSET_TYPE_ARRAY_BUFFER, { skip_queue: true });
178
178
  } catch (e) {
179
179
  console.error(`Failed to load micron geometry '${micron_path}' referenced in GLTF (will skip): ${e}`);
180
180
  return;
@@ -149,7 +149,9 @@ export class MicronRenderPlugin extends EnginePlugin {
149
149
 
150
150
  // ensure that "arraybuffer" asset loader is present
151
151
  if (am.getLoaderByType(ASSET_TYPE_ARRAY_BUFFER) === undefined) {
152
- am.registerLoader(ASSET_TYPE_ARRAY_BUFFER, new ArrayBufferLoader());
152
+ am.registerLoader(ASSET_TYPE_ARRAY_BUFFER, new ArrayBufferLoader({
153
+ fetch_priority: "low" // hint to fetch data in background
154
+ }));
153
155
  }
154
156
 
155
157
  this.__asset_transformer.assetManager = am;
@@ -1,5 +1,5 @@
1
- import { isArrayEqual } from "../../../../../../core/collection/ArrayUtils.js";
2
1
  import { assert } from "../../../../../../core/assert.js";
2
+ import { isArrayEqual } from "../../../../../../core/collection/array/isArrayEqual.js";
3
3
 
4
4
  export class FunctionSignature {
5
5
  constructor() {
@@ -17,7 +17,6 @@ import Vector3 from "../../../../core/geom/Vector3.js";
17
17
  import { query_bvh_frustum_from_objects } from "./query/query_bvh_frustum_from_objects.js";
18
18
  import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
19
19
  import { computeFrustumCorners } from "./computeFrustumCorners.js";
20
- import { arraySwapElements } from "../../../../core/collection/ArrayUtils.js";
21
20
  import { compute_light_data_hash_0 } from "./cluster/compute_light_data_hash_0.js";
22
21
  import { read_plane_pair } from "./cluster/read_plane_pair.js";
23
22
  import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
@@ -47,6 +46,7 @@ import { array_copy } from "../../../../core/collection/array/copyArray.js";
47
46
  import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
48
47
  import { invokeObjectCompare } from "../../../../core/model/object/invokeObjectCompare.js";
49
48
  import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
49
+ import { arraySwapElements } from "../../../../core/collection/array/arraySwapElements.js";
50
50
 
51
51
  const LOOKUP_CACHE_SIZE = 1024; // must be power of two
52
52
 
@@ -35,6 +35,10 @@ test('correct cluster content (single small light)', () => {
35
35
 
36
36
  const camera = new PerspectiveCamera(45, 1, 1, 10);
37
37
  camera.lookAt(0, 0, 5);
38
+
39
+ camera.updateProjectionMatrix();
40
+ camera.updateMatrix();
41
+ camera.updateMatrixWorld(true);
38
42
 
39
43
  lm.setTileMapResolution(1, 1, 1);
40
44
 
@@ -1,7 +1,9 @@
1
- import { plane_three_computeConvex3PlaneIntersection } from "../../../../core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
1
+ import {
2
+ plane_three_computeConvex3PlaneIntersection
3
+ } from "../../../../core/geom/3d/plane/plane_three_compute_convex3_plane_intersection.js";
2
4
 
3
5
  /**
4
- *
6
+ * Get frustum corners from a set of planes
5
7
  * @param {Float32Array|number[]} result
6
8
  * @param {Plane[]} planes
7
9
  */
@@ -1561,10 +1561,10 @@ function draw_camera_view_planes() {
1561
1561
  // prepare_scene_2();
1562
1562
  // prepare_scene_decal_0();
1563
1563
  // prepare_scene_decal_1();
1564
- // prepare_scene_decal_2();
1564
+ prepare_scene_decal_2();
1565
1565
  // prepare_scene_9();
1566
1566
  // prepare_scene_2();
1567
- prepare_scene_0();
1567
+ // prepare_scene_0();
1568
1568
  animate();
1569
1569
 
1570
1570
  // draw_camera_view_planes();
@@ -1,7 +1,7 @@
1
+ import { v3_distance_above_plane } from "../../../../core/geom/v3_distance_above_plane.js";
1
2
  import {
2
3
  plane_three_computeConvex3PlaneIntersection
3
- } from "../../../../core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
4
- import { v3_distance_above_plane } from "../../../../core/geom/v3_distance_above_plane.js";
4
+ } from "../../../../core/geom/3d/plane/plane_three_compute_convex3_plane_intersection.js";
5
5
 
6
6
  /**
7
7
  *
@@ -60,7 +60,7 @@ void main(void) {
60
60
  `;
61
61
 
62
62
  /**
63
- *
63
+ * Normal Probability Distribution Function
64
64
  * @param {number} x
65
65
  * @param {number} sigma
66
66
  * @return {number}
@@ -31,7 +31,7 @@ export class AtlasPatch {
31
31
  this.id = -1;
32
32
 
33
33
  /**
34
- *
34
+ * Texture data of the patch, this is what will be stenciled into the atlas
35
35
  * @type {Sampler2D|null}
36
36
  */
37
37
  this.sampler = null;
@@ -43,8 +43,9 @@ export class AtlasPatch {
43
43
  this.uv = new Rectangle(0, 0, 0, 0);
44
44
 
45
45
  /**
46
- * Area in the atlas where patch along with the padding is packed into
47
- * Used for packing inside TextureAtlas. Do not modify manually
46
+ * Area in the atlas where patch along with the padding is packed into.
47
+ * Used for packing inside TextureAtlas.
48
+ * Do not modify manually
48
49
  * @readonly
49
50
  * @protected
50
51
  * @type {AABB2}
@@ -56,6 +57,13 @@ export class AtlasPatch {
56
57
  * @type {number|AtlasPatchFlag}
57
58
  */
58
59
  this.flags = 0;
60
+
61
+ /**
62
+ * Version of associated sampler that was last written.
63
+ * Used to track and signal when sampler needs to be re-painted.
64
+ * @type {number}
65
+ */
66
+ this.last_painted_version = -1;
59
67
  }
60
68
 
61
69
  /**
@@ -171,7 +171,7 @@ export class CachingTextureAtlas extends AbstractTextureAtlas {
171
171
 
172
172
  const target = this.__find_replacement_target(width, height);
173
173
 
174
- if (target) {
174
+ if (target !== -1) {
175
175
  // evicted just one element
176
176
  this.__evict(target);
177
177
  return true;
@@ -228,7 +228,7 @@ export class CachingTextureAtlas extends AbstractTextureAtlas {
228
228
  }
229
229
 
230
230
  reset() {
231
- this.__cached_patches.splice(i, this.__cached_patches.length);
231
+ this.__cached_patches.splice(0, this.__cached_patches.length);
232
232
  this.__atals.reset();
233
233
  }
234
234
 
@@ -210,6 +210,7 @@ export class TextureAtlas extends AbstractTextureAtlas {
210
210
  );
211
211
 
212
212
  patch.setFlag(AtlasPatchFlag.Painted);
213
+ patch.last_painted_version = source.version; // record version
213
214
 
214
215
  // console.timeEnd('TextureAtlas.paintPatch');
215
216
  }
@@ -462,10 +463,15 @@ export class TextureAtlas extends AbstractTextureAtlas {
462
463
  for (let i = 0; i < l; i++) {
463
464
  const patch = patches[i];
464
465
 
465
- if (!patch.getFlag(AtlasPatchFlag.Painted)) {
466
+ if (
467
+ !patch.getFlag(AtlasPatchFlag.Painted)
468
+ || patch.last_painted_version !== patch.sampler.version
469
+ ) {
470
+
466
471
  this.paintPatch(patch);
467
472
 
468
473
  paintCount++;
474
+
469
475
  }
470
476
  }
471
477
 
@@ -249,3 +249,25 @@ test("add 7 patches an update each time", () => {
249
249
  }
250
250
 
251
251
  });
252
+
253
+ test("modified sampler get repainted during 'paint'", () => {
254
+ const atlas = new TextureAtlas();
255
+
256
+ const sampler = Sampler2D.uint8(4, 1, 1);
257
+
258
+ sampler.data.fill(7);
259
+
260
+ const patch = atlas.add(sampler);
261
+
262
+ atlas.update();
263
+
264
+ // modify sampler
265
+ sampler.data.fill(3);
266
+ sampler.version++;
267
+
268
+ atlas.paint(); //repaint
269
+
270
+ const v0 = atlas.sampler.readChannel(patch.position.x, patch.position.y, 0)
271
+
272
+ expect(v0).toBe(3);
273
+ });
@@ -1646,70 +1646,6 @@ export class Sampler2D {
1646
1646
  return sampler;
1647
1647
  }
1648
1648
 
1649
- /**
1650
- *
1651
- * @param {Sampler2D} input0
1652
- * @param {Sampler2D} input1
1653
- * @param {Sampler2D} result
1654
- * @param {function( value0 : number[], value1 : number[], result : number[], index : number) : void} operation
1655
- */
1656
- static combine(input0, input1, result, operation) {
1657
- assert.notEqual(input0, undefined, "input0 is undefined");
1658
- assert.notEqual(input1, undefined, "input1 is undefined");
1659
- assert.notEqual(result, undefined, "result is undefined");
1660
-
1661
- assert.typeOf(operation, "function", "operation");
1662
-
1663
- assert.equal(input0.width, input1.width, `input0.width(=${input0.width}) is not equal to input1.width(=${input1.width})`);
1664
- assert.equal(input0.height, input1.height, `input0.height(=${input0.height}) is not equal to input1.height(=${input1.height})`);
1665
-
1666
- assert.equal(input0.width, result.width, `input width(=${input0.width}) is not equal to result.width(=${result.width})`);
1667
- assert.equal(input0.height, result.height, `input height(=${input0.height}) is not equal to result.height(=${result.height})`);
1668
-
1669
- const width = input0.width;
1670
- const height = input0.height;
1671
-
1672
- const length = width * height;
1673
-
1674
- const arg0 = [];
1675
- const arg1 = [];
1676
- const res = [];
1677
-
1678
- const itemSize0 = input0.itemSize;
1679
- const itemSize1 = input1.itemSize;
1680
- const itemSizeR = result.itemSize;
1681
-
1682
- const data0 = input0.data;
1683
- const data1 = input1.data;
1684
- const dataR = result.data;
1685
-
1686
-
1687
- let i, j;
1688
-
1689
- for (i = 0; i < length; i++) {
1690
-
1691
- // read input 0
1692
- for (j = 0; j < itemSize0; j++) {
1693
- arg0[j] = data0[j + i * itemSize0];
1694
- }
1695
-
1696
- // read input 1
1697
- for (j = 0; j < itemSize0; j++) {
1698
- arg1[j] = data1[j + i * itemSize1];
1699
- }
1700
-
1701
- //perform operation
1702
- operation(arg0, arg1, res, i);
1703
-
1704
- //write result
1705
- for (j = 0; j < itemSizeR; j++) {
1706
- dataR[j + i * itemSizeR] = res[j];
1707
- }
1708
-
1709
- }
1710
-
1711
- result.version++;
1712
- }
1713
1649
  }
1714
1650
 
1715
1651
 
@@ -1,4 +1,5 @@
1
1
  import { Sampler2D } from "./Sampler2D.js";
2
+ import { sampler2d_combine } from "./sampler2d_combine.js";
2
3
 
3
4
  test("constructor arguments", () => {
4
5
  const uint8Array = new Uint8Array(24);
@@ -217,7 +218,7 @@ test('Sampler2.combine ADD', () => {
217
218
 
218
219
  const ut = new Sampler2D(new Array(8), 2, 2, 2);
219
220
 
220
- Sampler2D.combine(s0, s1, ut, function (arg0, arg1, res, index) {
221
+ sampler2d_combine(s0, s1, ut, function (arg0, arg1, res, index) {
221
222
  res[0] = arg0[0] + arg1[0];
222
223
  res[1] = arg0[1] + arg1[1];
223
224
  });
@@ -0,0 +1,67 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+
4
+ /**
5
+ * Execute a binary operation with 2 input samplers and an output
6
+ * @param {Sampler2D} input0
7
+ * @param {Sampler2D} input1
8
+ * @param {Sampler2D} result
9
+ * @param {function( value0 : number[], value1 : number[], result : number[], index : number) : void} operation
10
+ */
11
+ export function sampler2d_combine(input0, input1, result, operation) {
12
+ assert.notEqual(input0, undefined, "input0 is undefined");
13
+ assert.notEqual(input1, undefined, "input1 is undefined");
14
+ assert.notEqual(result, undefined, "result is undefined");
15
+
16
+ assert.typeOf(operation, "function", "operation");
17
+
18
+ assert.equal(input0.width, input1.width, `input0.width(=${input0.width}) is not equal to input1.width(=${input1.width})`);
19
+ assert.equal(input0.height, input1.height, `input0.height(=${input0.height}) is not equal to input1.height(=${input1.height})`);
20
+
21
+ assert.equal(input0.width, result.width, `input width(=${input0.width}) is not equal to result.width(=${result.width})`);
22
+ assert.equal(input0.height, result.height, `input height(=${input0.height}) is not equal to result.height(=${result.height})`);
23
+
24
+ const width = input0.width;
25
+ const height = input0.height;
26
+
27
+ const length = width * height;
28
+
29
+ const arg0 = [];
30
+ const arg1 = [];
31
+ const res = [];
32
+
33
+ const itemSize0 = input0.itemSize;
34
+ const itemSize1 = input1.itemSize;
35
+ const itemSizeR = result.itemSize;
36
+
37
+ const data0 = input0.data;
38
+ const data1 = input1.data;
39
+ const dataR = result.data;
40
+
41
+
42
+ let i, j;
43
+
44
+ for (i = 0; i < length; i++) {
45
+
46
+ // read input 0
47
+ for (j = 0; j < itemSize0; j++) {
48
+ arg0[j] = data0[j + i * itemSize0];
49
+ }
50
+
51
+ // read input 1
52
+ for (j = 0; j < itemSize0; j++) {
53
+ arg1[j] = data1[j + i * itemSize1];
54
+ }
55
+
56
+ //perform operation
57
+ operation(arg0, arg1, res, i);
58
+
59
+ //write result
60
+ for (j = 0; j < itemSizeR; j++) {
61
+ dataR[j + i * itemSizeR] = res[j];
62
+ }
63
+
64
+ }
65
+
66
+ result.version++;
67
+ }
@@ -1,7 +1,6 @@
1
1
  import { BehaviorSystem } from "./BehaviorSystem.js";
2
2
  import { BehaviorComponent } from "./BehaviorComponent.js";
3
3
  import { Behavior } from "../Behavior.js";
4
- import { BehaviorStatus } from "../BehaviorStatus.js";
5
4
  import { EntityComponentDataset } from "../../../ecs/EntityComponentDataset.js";
6
5
  import { EntityManager } from "../../../ecs/EntityManager.js";
7
6
  import { noop } from "../../../../core/function/Functions.js";
@@ -44,7 +43,6 @@ test("unlinking finalizes behavior if it is running", () => {
44
43
 
45
44
  const behavior = new Behavior();
46
45
  behavior.finalize = jest.fn();
47
- behavior.setStatus(BehaviorStatus.Running);
48
46
 
49
47
  s.unlink(BehaviorComponent.fromOne(behavior), 0);
50
48
 
@@ -56,7 +54,6 @@ test("update ticks behavior with the time delta", () => {
56
54
 
57
55
  const behavior = new Behavior();
58
56
  behavior.tick = jest.fn();
59
- behavior.setStatus(BehaviorStatus.Running);
60
57
 
61
58
  const behaviorComponent = BehaviorComponent.fromOne(behavior);
62
59