@woosh/meep-engine 2.34.20 → 2.34.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.
@@ -1,6 +1,7 @@
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";
4
5
 
5
6
  /**
6
7
  *
@@ -18,17 +19,6 @@ export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
18
19
  buffer.readFloat32Array(gbb, 0, 6);
19
20
  buffer.readFloat32Array(patch.group_bounding_sphere, 0, 4);
20
21
 
21
- // reconstruct corners
22
- aabb3_build_corners(
23
- patch.group_bounding_box_corners,
24
- 0,
25
- gbb[0],
26
- gbb[1],
27
- gbb[2],
28
- gbb[3],
29
- gbb[4],
30
- gbb[5]
31
- );
32
22
 
33
23
  patch.group_error = buffer.readFloat32();
34
24
  patch.lod = buffer.readUintVar();
@@ -101,4 +91,43 @@ export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
101
91
 
102
92
  patch.vertex_attribute_arrays[i] = array;
103
93
  }
94
+
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
+ // reconstruct corners
123
+ aabb3_build_corners(
124
+ patch.group_bounding_box_corners,
125
+ 0,
126
+ gbb[0],
127
+ gbb[1],
128
+ gbb[2],
129
+ gbb[3],
130
+ gbb[4],
131
+ gbb[5]
132
+ );
104
133
  }
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.20",
8
+ "version": "2.34.21",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",