@woosh/meep-engine 2.37.8 → 2.37.11

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.
@@ -20,6 +20,8 @@ export class CachedAsyncMap extends AbstractAsyncMap {
20
20
  return volatile_value;
21
21
  }
22
22
 
23
+ // TODO re-insert into volatile if persisted has a hit
24
+
23
25
  return await this.__persisted.get(key);
24
26
  }
25
27
 
@@ -76,7 +76,15 @@ 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
+ }
80
88
 
81
89
  let entity_node = three_object_to_entity_composition(asset.create());
82
90
 
@@ -49,7 +49,7 @@ export class MicronRenderPlugin extends EnginePlugin {
49
49
 
50
50
  /**
51
51
  *
52
- * @type {AsyncRemoteHashMap}
52
+ * @type {AsyncRemoteHashMap<THREE.BufferGeometry, MicronGeometry>}
53
53
  * @private
54
54
  */
55
55
  this.__persisted_geometry = new AsyncRemoteHashMap({
@@ -60,6 +60,7 @@ export class MicronRenderPlugin extends EnginePlugin {
60
60
  storageKeyPrefix: STORAGE_KEY,
61
61
 
62
62
  });
63
+
63
64
  /**
64
65
  *
65
66
  * @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
@@ -109,7 +110,7 @@ export class MicronRenderPlugin extends EnginePlugin {
109
110
  const sg_system = system;
110
111
 
111
112
  sg_system.register_render_adapter(2, () => {
112
- const adapter = new MicronShadedGeometryRenderAdapter();
113
+ const adapter = new MicronShadedGeometryRenderAdapter(this.__cache);
113
114
 
114
115
  adapter.ctx = this.__vgtr.ctx;
115
116
 
@@ -1,6 +1,5 @@
1
1
  import { AbstractRenderAdapter } from "../../../ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js";
2
2
  import Vector2 from "../../../../../core/geom/Vector2.js";
3
- import { buildMicronGeometryFromBufferGeometry } from "../../build/buildMicronGeometryFromBufferGeometry.js";
4
3
  import { ShadedGeometryFlags } from "../../../ecs/mesh-v2/ShadedGeometryFlags.js";
5
4
  import { MaterialVertexSpec, MaterialVertexSpecFlags } from "../../render/v1/MaterialVertexSpec.js";
6
5
  import { compute_geometry_polycount } from "../../../geometry/compute_geometry_polycount.js";
@@ -26,7 +25,11 @@ const MICRON_POLYCOUNT_THRESHOLD_MAX = 10000;
26
25
 
27
26
  export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
28
27
 
29
- constructor() {
28
+ /**
29
+ *
30
+ * @param {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>} cache
31
+ */
32
+ constructor(cache) {
30
33
  super();
31
34
 
32
35
  /**
@@ -48,6 +51,13 @@ export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
48
51
  * @private
49
52
  */
50
53
  this.__geometry_building_promises = new Map();
54
+
55
+ /**
56
+ *
57
+ * @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
58
+ * @private
59
+ */
60
+ this.__cache = cache;
51
61
  }
52
62
 
53
63
  score(geometry, material, instance_count) {
@@ -72,9 +82,10 @@ export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
72
82
  return micron_geometry;
73
83
 
74
84
  } else {
85
+
75
86
  // no micron geometry
76
87
  if (!this.__geometry_building_promises.has(geometry_id)) {
77
- const p = buildMicronGeometryFromBufferGeometry(sg.geometry);
88
+ const p = this.__cache.get(sg.geometry);
78
89
 
79
90
  this.__geometry_building_promises.set(geometry_id, p);
80
91
 
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.8",
8
+ "version": "2.37.11",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",