@woosh/meep-engine 2.36.18 → 2.36.21

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.
@@ -28,6 +28,9 @@ const scratch_corners = [
28
28
  new ThreeVector3()
29
29
  ];
30
30
 
31
+ /**
32
+ @deprecated use {@link ShadedGeometry} instead
33
+ */
31
34
  class Renderable {
32
35
  constructor(object) {
33
36
  this.object = object;
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Created by Alex on 01/04/2014.
3
3
  */
4
- import {System} from '../System.js';
4
+ import { System } from '../System.js';
5
5
  import Renderable from '../components/Renderable.js';
6
- import {Transform} from '../transform/Transform.js';
7
- import {SignalBinding} from "../../../core/events/signal/SignalBinding.js";
8
- import {Box3} from "three";
9
- import {RenderableFlags} from "../components/RenderableFlags.js";
10
- import {rootObject3DFastMatrixUpdate} from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
11
- import {updateNodeByTransformAndBBB} from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
6
+ import { Transform } from '../transform/Transform.js';
7
+ import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
8
+ import { Box3 } from "three";
9
+ import { RenderableFlags } from "../components/RenderableFlags.js";
10
+ import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
11
+ import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
12
12
 
13
13
 
14
14
  /**
@@ -43,6 +43,9 @@ export function three_computeObjectBoundingBox(object, result) {
43
43
 
44
44
  }
45
45
 
46
+ /**
47
+ * @deprecated use {@link ShadedGeometry} instead
48
+ */
46
49
  class RenderSystem extends System {
47
50
  /**
48
51
  *
@@ -35,18 +35,49 @@ void main(){
35
35
  }
36
36
  `;
37
37
 
38
+ const material_id_vertex_shader_skinned = `
39
+ #include <common>
40
+ #include <uv_pars_vertex>
41
+ #include <displacementmap_pars_vertex>
42
+ #include <morphtarget_pars_vertex>
43
+ #include <skinning_pars_vertex>
44
+ #include <logdepthbuf_pars_vertex>
45
+ #include <clipping_planes_pars_vertex>
46
+
47
+ void main()
48
+ {
49
+ #include <uv_vertex>
50
+ #include <skinbase_vertex>
51
+ #ifdef USE_DISPLACEMENTMAP
52
+ #include <beginnormal_vertex>
53
+ #include <morphnormal_vertex>
54
+ #include <skinnormal_vertex>
55
+ #endif
56
+ #include <begin_vertex>
57
+ #include <morphtarget_vertex>
58
+ #include <skinning_vertex>
59
+ #include <displacementmap_vertex>
60
+ #include <project_vertex>
61
+ #include <logdepthbuf_vertex>
62
+ #include <clipping_planes_vertex>
63
+ }
64
+ `;
65
+
66
+
67
+ const material_id_vertex_shader_static = `
68
+ void main()
69
+ {
70
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
71
+ gl_Position = projectionMatrix * mvPosition;
72
+ }
73
+ `;
74
+
38
75
  function makeIdMaterialStatic() {
39
76
  return new ShaderMaterial({
40
77
  uniforms: {
41
78
  id: { value: 0 }
42
79
  },
43
- vertexShader: `
44
- void main()
45
- {
46
- vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
47
- gl_Position = projectionMatrix * mvPosition;
48
- }
49
- `,
80
+ vertexShader: material_id_vertex_shader_static,
50
81
  fragmentShader: material_id_fragment_shader
51
82
  });
52
83
  }
@@ -59,33 +90,7 @@ function makeIdMaterialSkinned() {
59
90
  uniforms: {
60
91
  id: { value: 0 }
61
92
  },
62
- vertexShader: `
63
- #include <common>
64
- #include <uv_pars_vertex>
65
- #include <displacementmap_pars_vertex>
66
- #include <morphtarget_pars_vertex>
67
- #include <skinning_pars_vertex>
68
- #include <logdepthbuf_pars_vertex>
69
- #include <clipping_planes_pars_vertex>
70
-
71
- void main()
72
- {
73
- #include <uv_vertex>
74
- #include <skinbase_vertex>
75
- #ifdef USE_DISPLACEMENTMAP
76
- #include <beginnormal_vertex>
77
- #include <morphnormal_vertex>
78
- #include <skinnormal_vertex>
79
- #endif
80
- #include <begin_vertex>
81
- #include <morphtarget_vertex>
82
- #include <skinning_vertex>
83
- #include <displacementmap_vertex>
84
- #include <project_vertex>
85
- #include <logdepthbuf_vertex>
86
- #include <clipping_planes_vertex>
87
- }
88
- `,
93
+ vertexShader: material_id_vertex_shader_skinned,
89
94
  fragmentShader: material_id_fragment_shader
90
95
  });
91
96
  }
@@ -3,7 +3,7 @@ import { HighlightRenderElementSource } from "../plugin/HighlightRenderElementSo
3
3
  import Highlight from "../Highlight.js";
4
4
  import { OutlineRenderPlugin } from "../plugin/OutlineRenderPlugin.js";
5
5
  import { ShadedGeometry } from "../../mesh-v2/ShadedGeometry.js";
6
- import { build_three_object } from "../../mesh-v2/build_three_object.js";
6
+ import { SGThreeObjectCache } from "../../mesh-v2/render/SGThreeObjectCache.js";
7
7
 
8
8
  class Supplier extends HighlightRenderElementSource {
9
9
  /**
@@ -35,10 +35,10 @@ class Supplier extends HighlightRenderElementSource {
35
35
 
36
36
  /**
37
37
  *
38
- * @type {WeakMap<ShadedGeometry, THREE.Object3D>}
38
+ * @type {SGThreeObjectCache}
39
39
  * @private
40
40
  */
41
- this.__object_cache = new WeakMap();
41
+ this.__object_cache = SGThreeObjectCache.INSTANCE;
42
42
  }
43
43
 
44
44
  collect(pool, group) {
@@ -85,11 +85,7 @@ class Supplier extends HighlightRenderElementSource {
85
85
  return;
86
86
  }
87
87
 
88
- let object = this.__object_cache.get(sg);
89
-
90
- if(object === undefined){
91
- object = build_three_object(sg);
92
- }
88
+ const object = this.__object_cache.get(sg);
93
89
 
94
90
  object.matrixWorld.elements = sg.transform;
95
91
 
@@ -0,0 +1,38 @@
1
+ import { build_three_object } from "../build_three_object.js";
2
+
3
+ export class SGThreeObjectCache {
4
+ constructor() {
5
+ /**
6
+ *
7
+ * @type {WeakMap<ShadedGeometry, THREE.Object3D>}
8
+ * @private
9
+ */
10
+ this.__object_cache = new WeakMap();
11
+ }
12
+
13
+ /**
14
+ *
15
+ * @param {ShadedGeometry} sg
16
+ * @returns {THREE.Object3D}
17
+ */
18
+ get(sg) {
19
+
20
+ const existing_object = this.__object_cache.get(sg);
21
+
22
+ if (existing_object !== undefined) {
23
+ return existing_object;
24
+ }
25
+
26
+ const new_object = build_three_object(sg);
27
+
28
+ this.__object_cache.set(sg, new_object);
29
+
30
+ return new_object;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * @readonly
36
+ * @type {SGThreeObjectCache}
37
+ */
38
+ SGThreeObjectCache.INSTANCE = new SGThreeObjectCache();
@@ -1,6 +1,6 @@
1
1
  import { AbstractRenderAdapter } from "./AbstractRenderAdapter.js";
2
2
  import { array_copy } from "../../../../../../core/collection/array/copyArray.js";
3
- import { build_three_object } from "../../build_three_object.js";
3
+ import { SGThreeObjectCache } from "../SGThreeObjectCache.js";
4
4
 
5
5
  export class GenericRendererAdapter extends AbstractRenderAdapter {
6
6
  constructor() {
@@ -8,10 +8,10 @@ export class GenericRendererAdapter extends AbstractRenderAdapter {
8
8
 
9
9
  /**
10
10
  *
11
- * @type {Cache<ShadedGeometry, THREE.Object3D>}
11
+ * @type {SGThreeObjectCache}
12
12
  * @private
13
13
  */
14
- this.__cache = new WeakMap();
14
+ this.__cache = SGThreeObjectCache.INSTANCE;
15
15
  }
16
16
 
17
17
 
@@ -29,21 +29,11 @@ export class GenericRendererAdapter extends AbstractRenderAdapter {
29
29
  }
30
30
 
31
31
  add(sg) {
32
- const cache = this.__cache;
33
-
34
32
  /**
35
33
  *
36
34
  * @type {THREE.Object3D}
37
35
  */
38
- let object = cache.get(sg);
39
-
40
- if (object === undefined) {
41
-
42
- object = build_three_object(sg);
43
-
44
- cache.set(sg, object);
45
-
46
- }
36
+ const object = this.__cache.get(sg);
47
37
 
48
38
  array_copy(sg.__transform, 0, object.matrixWorld.elements, 0, 16);
49
39
 
@@ -8,7 +8,9 @@ import { convert_three_object_to_micron } from "../convert_three_object_to_micro
8
8
  import { compute_geometry_polycount } from "../../geometry/compute_geometry_polycount.js";
9
9
  import { traverseThreeObject } from "../../ecs/highlight/renderer/traverseThreeObject.js";
10
10
  import { max2 } from "../../../../core/math/max2.js";
11
- import { deserialize_geometry_collection } from "../format/serialization/collection/geometry_collection_serialization.js";
11
+ import {
12
+ deserialize_geometry_collection
13
+ } from "../format/serialization/collection/geometry_collection_serialization.js";
12
14
  import { GLTF_MICRON_ID_FIELD } from "./GLTF_MICRON_ID_FIELD.js";
13
15
 
14
16
  export const ASSET_TYPE_ARRAY_BUFFER = "arraybuffer";
@@ -196,18 +198,21 @@ export class GLTFAssetTransformer extends AssetTransformer {
196
198
  */
197
199
  const root = source.create();
198
200
 
199
- const gltf_max_polycount = max_polycount(root);
200
201
 
201
- if (gltf_max_polycount < this.__threshold_polycount) {
202
- // no change, geometries are too small
203
- return source;
204
- }
202
+ await this.__load_mesh_micron_data(source.gltf,asset_description);
205
203
 
206
204
  // attempt to load existing micron geometries
207
205
  await async_traverse_three_object(root, this.__visitObjectToLoadMicron, this, {
208
206
  asset: asset_description
209
207
  });
210
208
 
209
+ const gltf_max_polycount = max_polycount(root);
210
+
211
+ if (gltf_max_polycount < this.__threshold_polycount) {
212
+ // no change, geometries are too small
213
+ return source;
214
+ }
215
+
211
216
  const micron_root = await convert_three_object_to_micron(root.clone(), this.__cache);
212
217
  micron_root.boundingSphere = root.boundingSphere;
213
218
 
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.18",
8
+ "version": "2.36.21",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",