@woosh/meep-engine 2.34.24 → 2.34.28

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.
@@ -0,0 +1,14 @@
1
+ import { v3_dot } from "../../v3_dot.js";
2
+
3
+ export function ray_distance_to_point(origin_x, origin_y, origin_z, direction_x, direction_y, direction_z,ref_x, ref_y, ref_z){
4
+ // find closest point
5
+ const sp0_x = ref_x - origin_x;
6
+ const sp0_y = ref_y - origin_y;
7
+ const sp0_z = ref_z - origin_z;
8
+
9
+ //
10
+ const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
11
+ const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
12
+
13
+ return d3 / d2;
14
+ }
@@ -10,6 +10,7 @@ import { vec4 } from "gl-matrix";
10
10
  import { computeTopoMeshBoundiningBox } from "../../../../core/geom/3d/topology/bounds/computeTopoMeshBoundiningBox.js";
11
11
  import { computeTopoMeshBoundingSphere } from "../../../../core/geom/3d/topology/bounds/computeTopoMeshBoundingSphere.js";
12
12
  import { meshopt_optimizeVertexCache } from "../../geometry/optimization/VertexCacheOptimizer.js";
13
+ import { array_copy } from "../../../../core/collection/array/copyArray.js";
13
14
 
14
15
  /**
15
16
  *
@@ -190,15 +191,11 @@ export class PatchRepresentation {
190
191
  return result;
191
192
  }
192
193
 
193
- computeBoundingBox() {
194
+ computeBounds() {
194
195
  computeTopoMeshBoundiningBox(this.bounding_box, this.topology_snapshot);
195
196
  computeTopoMeshBoundingSphere(this.bounding_sphere, this.topology_snapshot);
196
197
  }
197
198
 
198
- computeBounds() {
199
- this.computeBoundingBox();
200
- }
201
-
202
199
  /**
203
200
  * @returns {number}
204
201
  */
@@ -403,11 +400,11 @@ export class PatchRepresentation {
403
400
 
404
401
  this.group_aabb.getCorners(result.group_bounding_box_corners);
405
402
 
406
- vec4.copy(result.group_bounding_sphere, this.group_bounding_sphere);
403
+ array_copy(this.group_bounding_sphere, 0, result.group_bounding_sphere, 0, 4);
407
404
 
408
405
  result.group_error = this.group_error;
409
406
 
410
- vec4.copy(result.bounding_sphere, this.bounding_sphere);
407
+ array_copy(this.bounding_sphere, 0, result.bounding_sphere, 0, 4);
411
408
 
412
409
  result.normal_cone.copy(this.normal_cone);
413
410
 
@@ -134,7 +134,9 @@ async function assemble_graph(nodes) {
134
134
  }
135
135
 
136
136
  // return root
137
- return __nodes[0];
137
+ const root = __nodes[0];
138
+
139
+ return root;
138
140
  }
139
141
 
140
142
 
@@ -477,7 +477,8 @@ async function many_to_many_merge(
477
477
 
478
478
  rep.group_aabb.copy(group_aabb);
479
479
  rep.group_bounding_sphere.set(group_bounding_sphere);
480
- computeTopoMeshBoundiningBox(rep.bounding_box, piece_mesh);
480
+
481
+ rep.computeBounds();
481
482
 
482
483
  rep.group_error = group_per_pixel_error;
483
484
 
@@ -515,10 +516,6 @@ export async function merge_patches(
515
516
  // only 1 patch, no merge opportunity, forward it to output directly
516
517
  const node = nodes[0];
517
518
 
518
- //set group bounds to produce a valid root
519
- node.group_aabb.copy(node.bounding_box);
520
- node.group_bounding_sphere.set(node.bounding_sphere);
521
-
522
519
  output[output_offset.value++] = node;
523
520
  return 1;
524
521
  } else {
@@ -3,7 +3,6 @@ import { assert } from "../../../../core/assert.js";
3
3
  import { computeTriangleRayIntersection } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
4
4
  import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
5
5
  import { aabb3_array_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_array_intersects_ray.js";
6
- import { sphere_array_intersects_ray } from "../../../../core/geom/3d/sphere/sphere_array_intersects_ray.js";
7
6
 
8
7
  let id_counter = 0;
9
8
 
@@ -79,6 +78,8 @@ export class MicronGeometry {
79
78
  origin_x, origin_y, origin_z,
80
79
  direction_x, direction_y, direction_z
81
80
  ) {
81
+ let i;
82
+ let stack_cursor = 1;
82
83
 
83
84
  /**
84
85
  *
@@ -87,7 +88,6 @@ export class MicronGeometry {
87
88
  const hits = [];
88
89
 
89
90
  // initialize stack
90
- let stack_cursor = 1;
91
91
  const stack = scratch_traversal_stack;
92
92
  stack[0] = this.root;
93
93
 
@@ -108,12 +108,14 @@ export class MicronGeometry {
108
108
  // using group bounds because it's conservative, as we want to be able to hit LOD_0
109
109
 
110
110
  // sphere test
111
- if (!sphere_array_intersects_ray(patch.group_bounding_sphere,
112
- origin_x, origin_y, origin_z,
113
- direction_x, direction_y, direction_z
114
- )) {
115
- continue;
116
- }
111
+
112
+ // TODO check what's wrong with sphere tests and re-enable them
113
+ // if (!sphere_array_intersects_ray(patch.group_bounding_sphere,
114
+ // origin_x, origin_y, origin_z,
115
+ // direction_x, direction_y, direction_z
116
+ // )) {
117
+ // continue;
118
+ // }
117
119
 
118
120
 
119
121
  // box test (more expensive, different volume)
@@ -132,12 +134,14 @@ export class MicronGeometry {
132
134
  // cast against bounds
133
135
 
134
136
  // sphere test
135
- if (!sphere_array_intersects_ray(patch.bounding_sphere,
136
- origin_x, origin_y, origin_z,
137
- direction_x, direction_y, direction_z
138
- )) {
139
- continue;
140
- }
137
+
138
+ // TODO check what's wrong with sphere tests and re-enable them
139
+ // if (!sphere_array_intersects_ray(patch.bounding_sphere,
140
+ // origin_x, origin_y, origin_z,
141
+ // direction_x, direction_y, direction_z
142
+ // )) {
143
+ // continue;
144
+ // }
141
145
 
142
146
  // box test
143
147
  if (!aabb3_array_intersects_ray(
@@ -154,7 +158,7 @@ export class MicronGeometry {
154
158
 
155
159
  const vertices = patch.vertex_attribute_arrays[position_attribute_index];
156
160
 
157
- for (let i = 0; i < index_count;) {
161
+ for (i = 0; i < index_count;) {
158
162
  const a = indices[i++];
159
163
  const b = indices[i++];
160
164
  const c = indices[i++];
@@ -201,7 +205,7 @@ export class MicronGeometry {
201
205
 
202
206
  const child_count = children.length;
203
207
 
204
- for (let i = 0; i < child_count; i++) {
208
+ for (i = 0; i < child_count; i++) {
205
209
  const child = children[i];
206
210
 
207
211
  // push to stack
@@ -1,7 +1,6 @@
1
1
  import { aabb3_build_corners } from "../../../../../core/geom/3d/aabb/aabb3_build_corners.js";
2
2
  import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
3
3
  import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
4
- import { v3_distance } from "../../../../../core/geom/v3_distance.js";
5
4
 
6
5
  /**
7
6
  *
@@ -19,7 +18,6 @@ export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
19
18
  buffer.readFloat32Array(gbb, 0, 6);
20
19
  buffer.readFloat32Array(patch.group_bounding_sphere, 0, 4);
21
20
 
22
-
23
21
  patch.group_error = buffer.readFloat32();
24
22
  patch.lod = buffer.readUintVar();
25
23
  patch.polygon_count = buffer.readUintVar();
@@ -92,33 +90,6 @@ export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
92
90
  patch.vertex_attribute_arrays[i] = array;
93
91
  }
94
92
 
95
-
96
- // validate and fix group bounds as necessary
97
- if (
98
- patch.group_bounding_box[0] > patch.bounding_box[0] // x0
99
- || patch.group_bounding_box[1] > patch.bounding_box[1] // y0
100
- || patch.group_bounding_box[2] > patch.bounding_box[2] // x0
101
- || patch.group_bounding_box[3] < patch.bounding_box[3] // x1
102
- || patch.group_bounding_box[4] < patch.bounding_box[4] // y1
103
- || patch.group_bounding_box[5] < patch.bounding_box[5] // z1
104
- ) {
105
- // bounds are violated, fix
106
- patch.group_bounding_box.set(patch.bounding_box);
107
- }
108
-
109
- if (v3_distance(
110
- patch.group_bounding_sphere[0],
111
- patch.group_bounding_sphere[1],
112
- patch.group_bounding_sphere[2],
113
- patch.bounding_sphere[0],
114
- patch.bounding_sphere[1],
115
- patch.bounding_sphere[2]
116
- ) + patch.bounding_sphere[3] > patch.group_bounding_sphere[3]) {
117
- // group's sphere bounds are violated, fix
118
- patch.group_bounding_sphere.set(patch.bounding_sphere);
119
- }
120
-
121
-
122
93
  // reconstruct corners
123
94
  aabb3_build_corners(
124
95
  patch.group_bounding_box_corners,
@@ -455,7 +455,7 @@ function init() {
455
455
  }
456
456
 
457
457
  // sample_gltf_sponza();
458
- // sample_gltf_rts_factory();
458
+ gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
459
459
  // sample_lucy();
460
460
  // sample_gltf_hapro_2();
461
461
  // sample_gltf_hapro_1();
@@ -467,7 +467,7 @@ function init() {
467
467
  // gltf_sample('data/models/moicon/isiflow_Oct_15_21/0/model.gltf');
468
468
  // gltf_sample('moicon/29_Dec_2021_Nammo/1/model.gltf');
469
469
  // gltf_sample('moicon/29_Dec_2021_Nammo/1-onematerial/model.gltf');
470
- gltf_sample('moicon/29_Dec_2021_Nammo/2/model.gltf');
470
+ // gltf_sample('moicon/29_Dec_2021_Nammo/2/model.gltf');
471
471
 
472
472
  document.addEventListener("mousemove", onDocumentMouseMove);
473
473
 
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.34.24",
8
+ "version": "2.34.28",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",