@woosh/meep-engine 2.36.23 → 2.36.24

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.
@@ -84,6 +84,39 @@ function makeIdMaterialStatic() {
84
84
 
85
85
  const material_id_unskinned = makeIdMaterialStatic();
86
86
 
87
+ /**
88
+ *
89
+ * @type {WeakMap<Object3D, Object3D>}
90
+ */
91
+ const object_id_cache = new WeakMap();
92
+
93
+ /**
94
+ *
95
+ * @param {Mesh|SkinnedMesh} object
96
+ */
97
+ function obtain_id_mesh(object) {
98
+ const existing = object_id_cache.get(object);
99
+
100
+ if (existing !== undefined) {
101
+ return existing;
102
+ }
103
+
104
+ let material, mesh;
105
+ if (object.isSkinnedMesh) {
106
+ material = makeIdMaterialSkinned();
107
+ mesh = new SkinnedMesh(object.geometry, material);
108
+ mesh.bindMatrix.copy(object.bindMatrix);
109
+ mesh.bindMatrixInverse.copy(object.bindMatrixInverse);
110
+ mesh.skeleton = object.skeleton;
111
+ } else {
112
+ material = makeIdMaterialStatic();
113
+ mesh = new Mesh(object.geometry, material);
114
+ }
115
+
116
+ object_id_cache.set(object, mesh);
117
+
118
+ return mesh;
119
+ }
87
120
 
88
121
  function makeIdMaterialSkinned() {
89
122
  return new ShaderMaterial({
@@ -99,8 +132,6 @@ const material_id_skinned = makeIdMaterialSkinned();
99
132
  material_id_skinned.skinning = true;
100
133
 
101
134
 
102
- const PARAMETER_COUNT = 5;
103
- const PARAMETER_PER_OBJECT_SLOTS = 4;
104
135
  const OBJECT_MAX_COUNT = 256;
105
136
 
106
137
 
@@ -373,22 +404,10 @@ export class OutlineRenderer {
373
404
  __append_to_id_scene(object) {
374
405
  if (object.isMesh) {
375
406
 
376
- let material;
377
- let mesh;
378
-
379
- if (object.isSkinnedMesh) {
380
- material = makeIdMaterialSkinned();
381
- mesh = new SkinnedMesh(object.geometry, material);
382
- mesh.bindMatrix.copy(object.bindMatrix);
383
- mesh.bindMatrixInverse.copy(object.bindMatrixInverse);
384
- mesh.skeleton = object.skeleton;
385
- } else {
386
- material = makeIdMaterialStatic();
387
- mesh = new Mesh(object.geometry, material);
388
- }
407
+ const mesh = obtain_id_mesh(object);
389
408
 
390
409
  const parameter_set_id = this.__definition_dictionary.get(this.__active_definition);
391
- material.uniforms.id.value = parameter_set_id;
410
+ mesh.material.uniforms.id.value = parameter_set_id;
392
411
 
393
412
  mesh.matrixAutoUpdate = false;
394
413
  mesh.matrixWorldNeedsUpdate = false;
@@ -399,6 +418,7 @@ export class OutlineRenderer {
399
418
  mesh.modelViewMatrix.copy(object.modelViewMatrix);
400
419
 
401
420
  this.__id_scene.children.push(mesh);
421
+
402
422
  }
403
423
  }
404
424
 
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.36.23",
8
+ "version": "2.36.24",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",