@woosh/meep-engine 2.39.13 → 2.39.14

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,9 +28,10 @@ export function computeTopoMeshBoundingSphere(result, mesh) {
28
28
  const miniball = new Miniball(pointSet);
29
29
 
30
30
  const center = miniball.center();
31
+ const radius = miniball.radius();
31
32
 
32
33
  result[0] = center[0];
33
34
  result[1] = center[1];
34
35
  result[2] = center[2];
35
- result[3] = miniball.radius();
36
+ result[3] = radius;
36
37
  }
@@ -74,6 +74,7 @@ export function build_merge_graph(leaves) {
74
74
  const connection_weight = computePatchMergeScore(leaf, neighbour);
75
75
 
76
76
  assert.isNumber(connection_weight, 'connection_weight');
77
+ assert.notNaN(connection_weight, 'connection_weight');
77
78
  assert.isFiniteNumber(connection_weight, 'connection_weight');
78
79
 
79
80
  const edge = new WeightedEdge(node_leaf, node_neighbour);
@@ -1,9 +1,12 @@
1
1
  import { ConicRay } from "../../../../../core/geom/ConicRay.js";
2
2
  import { compute_bounding_cone_of_2_cones } from "../../../../../core/geom/3d/cone/compute_bounding_cone_of_2_cones.js";
3
3
  import { compute_patches_shared_vertex_count } from "./compute_patches_shared_vertex_count.js";
4
- import { compute_bounding_sphere_of_2_spheres } from "../../../../../core/geom/3d/compute_bounding_sphere_of_2_spheres.js";
4
+ import {
5
+ compute_bounding_sphere_of_2_spheres
6
+ } from "../../../../../core/geom/3d/compute_bounding_sphere_of_2_spheres.js";
5
7
  import { max2 } from "../../../../../core/math/max2.js";
6
8
  import { min2 } from "../../../../../core/math/min2.js";
9
+ import { assert } from "../../../../../core/assert.js";
7
10
 
8
11
 
9
12
  /**
@@ -74,6 +77,12 @@ function compute_sphere_volume(r) {
74
77
  * @return {number}
75
78
  */
76
79
  function normalized_difference(a, b) {
80
+ assert.isNumber(a, 'a');
81
+ assert.isNumber(b, 'a');
82
+
83
+ assert.notNaN(a,'a');
84
+ assert.notNaN(b,'b');
85
+
77
86
  return Math.abs(a - b) / (max2(a, b) + 0.0001);
78
87
  }
79
88
 
@@ -85,10 +94,13 @@ function normalized_difference(a, b) {
85
94
  */
86
95
  export function computePatchMergeScore(a, b) {
87
96
  // compute common neighbours
88
- const common_neighbours = array_compute_common_element_count(a.neighbours, b.neighbours);
97
+ const a_neighbours = a.neighbours;
98
+ const b_neighbours = b.neighbours;
99
+
100
+ const common_neighbours = array_compute_common_element_count(a_neighbours, b_neighbours);
89
101
 
90
102
  // normalize neighbour count
91
- const common_neighbour_score = common_neighbours / (min2(a.neighbours.length, b.neighbours.length) + 0.01);
103
+ const common_neighbour_score = common_neighbours / (min2(a_neighbours.length, b_neighbours.length) + 0.01);
92
104
 
93
105
  // prefer merging patches of similar LOD level, this creates a more flat hierarchy
94
106
  const lod_score = 1 - normalized_difference(a.lod, b.lod);
@@ -123,10 +135,12 @@ export function computePatchMergeScore(a, b) {
123
135
  */
124
136
  const shared_vertex_count = compute_patches_shared_vertex_count(a, b);
125
137
 
126
- return similar_volume_score * 0.01
138
+ const result = similar_volume_score * 0.01
127
139
  + shared_vertex_count
128
140
  + normal_score * 0.001
129
141
  + common_neighbour_score
130
142
  + lod_score * 0.1
131
143
  + volume_score;
144
+
145
+ return result;
132
146
  }
@@ -91,6 +91,14 @@ export class GLTFAssetTransformer extends AssetTransformer {
91
91
  * @private
92
92
  */
93
93
  this.__active_mesh_micron_cache = [];
94
+
95
+ /**
96
+ * @deprecated
97
+ * Whether override mesh will be created for the asset, this is generally outdated
98
+ * @type {boolean}
99
+ * @private
100
+ */
101
+ this.__settings_build_override_mesh = false;
94
102
  }
95
103
 
96
104
  /**
@@ -198,7 +206,7 @@ export class GLTFAssetTransformer extends AssetTransformer {
198
206
  */
199
207
  const root = source.create();
200
208
 
201
- await this.__load_mesh_micron_data(source.gltf,asset_description);
209
+ await this.__load_mesh_micron_data(source.gltf, asset_description);
202
210
 
203
211
  // attempt to load existing micron geometries
204
212
  await async_traverse_three_object(root, this.__visitObjectToLoadMicron, this, {
@@ -212,12 +220,14 @@ export class GLTFAssetTransformer extends AssetTransformer {
212
220
  return source;
213
221
  }
214
222
 
215
- const micron_root = await convert_three_object_to_micron(root.clone(), this.__cache);
216
- micron_root.boundingSphere = root.boundingSphere;
223
+ if (this.__settings_build_override_mesh) {
224
+ const micron_root = await convert_three_object_to_micron(root.clone(), this.__cache);
225
+ micron_root.boundingSphere = root.boundingSphere;
217
226
 
218
- source.override_mesh = micron_root;
227
+ source.override_mesh = micron_root;
219
228
 
220
- traverseThreeObject(micron_root, ensureProxy);
229
+ traverseThreeObject(micron_root, ensureProxy);
230
+ }
221
231
 
222
232
  return source;
223
233
  }
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.39.13",
8
+ "version": "2.39.14",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",