@woosh/meep-engine 2.37.10 → 2.37.13

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.
@@ -117,8 +117,6 @@ export class Transform {
117
117
 
118
118
  updateMatrix() {
119
119
  compose_matrix4_array(this.matrix, this.position, this.rotation, this.scale);
120
-
121
- this.clearFlag(TransformFlags.MatrixNeedsUpdate);
122
120
  }
123
121
 
124
122
  /**
@@ -158,8 +156,6 @@ export class Transform {
158
156
  } else {
159
157
  this.scale.copy(Vector3.one);
160
158
  }
161
-
162
- this.setFlag(TransformFlags.MatrixNeedsUpdate);
163
159
  }
164
160
 
165
161
  toJSON() {
@@ -236,14 +232,6 @@ export class Transform {
236
232
  * @param {Transform} b
237
233
  */
238
234
  multiplyTransforms(a, b) {
239
- if (a.getFlag(TransformFlags.MatrixNeedsUpdate)) {
240
- a.updateMatrix();
241
- }
242
-
243
- if (b.getFlag(TransformFlags.MatrixNeedsUpdate)) {
244
- b.updateMatrix();
245
- }
246
-
247
235
  mat4.multiply(m4_0, a.matrix, b.matrix);
248
236
 
249
237
  this.fromMatrix4(m4_0);
@@ -278,8 +266,6 @@ export class Transform {
278
266
 
279
267
  decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
280
268
 
281
- this.clearFlag(TransformFlags.MatrixNeedsUpdate);
282
-
283
269
  this.writeFlag(TransformFlags.AutomaticChangeDetection, ad);
284
270
  }
285
271
 
@@ -3,6 +3,9 @@
3
3
  * @enum {number}
4
4
  */
5
5
  export const TransformFlags = {
6
+ /**
7
+ * @deprecated
8
+ */
6
9
  MatrixNeedsUpdate: 1,
7
10
  AutomaticChangeDetection: 2
8
11
  };
@@ -3,8 +3,6 @@ import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
3
3
  import { DrawMode } from "./DrawMode.js";
4
4
  import { ShadedGeometryFlags } from "./ShadedGeometryFlags.js";
5
5
  import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
6
- import { allocate_transform_m4 } from "./allocate_transform_m4.js";
7
- import { TransformFlags } from "../../../ecs/transform/TransformFlags.js";
8
6
 
9
7
  /**
10
8
  * @readonly
@@ -230,14 +228,6 @@ export class ShadedGeometry {
230
228
  }
231
229
 
232
230
  updateTransform() {
233
- const t = this.__c_transform;
234
-
235
- if (t.getFlag(TransformFlags.MatrixNeedsUpdate)) {
236
- t.updateMatrix();
237
- }
238
-
239
- //this.__transform.set(t.matrix);
240
-
241
231
  this.update_bounds();
242
232
 
243
233
  this.__bvh_tree.node_move_aabb(this.__bvh_leaf_id, this.__bvh_aabb);
@@ -22,7 +22,6 @@ import TaskState from "../../../../core/process/task/TaskState.js";
22
22
  import {
23
23
  bvh_query_user_data_overlaps_frustum
24
24
  } from "../../../../core/bvh2/bvh3/bvh_query_user_data_overlaps_frustum.js";
25
- import { TransformFlags } from "../../../ecs/transform/TransformFlags.js";
26
25
 
27
26
 
28
27
  /**
@@ -37,6 +36,10 @@ const scratch_point = new SurfacePoint3();
37
36
  */
38
37
  const scratch_m4 = new Float32Array(16);
39
38
 
39
+ /**
40
+ * @readonly
41
+ * @type {Float32Array}
42
+ */
40
43
  const scratch_ray_0 = new Float32Array(6);
41
44
 
42
45
  export class ShadedGeometrySystem extends System {
@@ -251,23 +254,21 @@ export class ShadedGeometrySystem extends System {
251
254
  t.rotation.onChanged.add(sg.updateTransform, sg);
252
255
  t.scale.onChanged.add(sg.updateTransform, sg);
253
256
 
254
- if (t.getFlag(TransformFlags.MatrixNeedsUpdate)) {
255
- t.updateMatrix();
256
- }
257
-
258
- // sg.__transform.set(t.matrix);
259
257
  sg.update_bounds();
260
258
 
261
259
  // remember entity for lookups
262
260
  sg.__entity = entity;
263
261
 
264
262
  // insert BVH entry
265
- const bvh_node_id = this.__bvh_binary.allocate_node();
266
- this.__bvh_binary.node_set_aabb(bvh_node_id, sg.__bvh_aabb);
267
- this.__bvh_binary.node_set_user_data(bvh_node_id, entity);
268
- this.__bvh_binary.insert_leaf(bvh_node_id);
263
+ const bvh = this.__bvh_binary;
264
+
265
+ const bvh_node_id = bvh.allocate_node();
266
+
267
+ bvh.node_set_aabb(bvh_node_id, sg.__bvh_aabb);
268
+ bvh.node_set_user_data(bvh_node_id, entity);
269
+ bvh.insert_leaf(bvh_node_id);
269
270
 
270
- sg.__bvh_tree = this.__bvh_binary;
271
+ sg.__bvh_tree = bvh;
271
272
  sg.__bvh_leaf_id = bvh_node_id;
272
273
 
273
274
 
@@ -8,5 +8,7 @@ export class SGMesh {
8
8
 
9
9
  getBoundingBox(out: AABB3): boolean
10
10
 
11
+ getUntransformedBoundingBox(out: AABB3): void
12
+
11
13
  static fromURL(url: string): SGMesh
12
14
  }
@@ -1,4 +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
3
 
3
4
  export const SGMeshFlags = {
4
5
  CastShadow: 1,
@@ -20,6 +21,13 @@ export class SGMesh {
20
21
  */
21
22
  this.__node = null;
22
23
 
24
+ /**
25
+ *
26
+ * @type {AABB3}
27
+ * @private
28
+ */
29
+ this.__initial_bounds = new AABB3();
30
+
23
31
  /**
24
32
  *
25
33
  * @type {number}
@@ -63,6 +71,14 @@ export class SGMesh {
63
71
  return true;
64
72
  }
65
73
 
74
+ /**
75
+ *
76
+ * @param {AABB3} destination
77
+ */
78
+ getUntransformedBoundingBox(destination) {
79
+ destination.copy(this.__initial_bounds);
80
+ }
81
+
66
82
  /**
67
83
  *
68
84
  * @param {number|SGMeshFlags} flag
@@ -76,7 +76,21 @@ export class SGMeshSystem extends System {
76
76
  return;
77
77
  }
78
78
 
79
- // TODO check that entity still exists, as we get to this point asynchronously
79
+ if (!ecd.entityExists(entity)) {
80
+ // entity no longer exists
81
+ return;
82
+ }
83
+
84
+ if (ecd.getComponent(entity, SGMesh) !== mesh) {
85
+ // mesh has changed
86
+ return;
87
+ }
88
+
89
+ if (asset.boundingBox !== undefined) {
90
+ mesh.__initial_bounds.copy(asset.boundingBox);
91
+ } else {
92
+ console.error(`No bounds for asset: ${asset.description}`);
93
+ }
80
94
 
81
95
  let entity_node = three_object_to_entity_composition(asset.create());
82
96
 
@@ -145,6 +159,14 @@ export class SGMeshSystem extends System {
145
159
  * @param {number} entity
146
160
  */
147
161
  link(mesh, transform, entity) {
162
+ const p = transform.position;
163
+
164
+ // set initial bounds to single point
165
+ mesh.__initial_bounds.setBounds(
166
+ p.x, p.y, p.z,
167
+ p.x, p.y, p.z,
168
+ );
169
+
148
170
  if (mesh.url === null) {
149
171
  this.__wait_queue.push(entity);
150
172
  return;
@@ -1,5 +1,4 @@
1
1
  import { AbstractRenderAdapter } from "./AbstractRenderAdapter.js";
2
- import { array_copy } from "../../../../../../core/collection/array/copyArray.js";
3
2
  import { SGThreeObjectCache } from "../SGThreeObjectCache.js";
4
3
 
5
4
  export class GenericRendererAdapter extends AbstractRenderAdapter {
@@ -30,7 +29,13 @@ export class GenericRendererAdapter extends AbstractRenderAdapter {
30
29
  */
31
30
  const object = this.__cache.get(sg);
32
31
 
33
- array_copy(sg.transform, 0, object.matrixWorld.elements, 0, 16);
32
+ const source = sg.transform;
33
+ const destination = object.matrixWorld.elements;
34
+
35
+ // copy transform matrix
36
+ for (let i = 0; i < 16; i++) {
37
+ destination[i] = source[i];
38
+ }
34
39
 
35
40
  this.__objects[this.__object_count++] = object;
36
41
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.37.10",
8
+ "version": "2.37.13",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",