@woosh/meep-engine 2.133.5 → 2.134.0
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.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BinaryBuffer.d.ts +20 -0
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +50 -0
- package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.d.ts +4 -4
- package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.js +2 -2
- package/src/core/geom/3d/topology/simplify/build_edge_collapse_candidates.d.ts +2 -2
- package/src/core/geom/3d/topology/simplify/build_edge_collapse_candidates.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/build_edge_collapse_candidates.js +1 -1
- package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.d.ts +2 -2
- package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.js +1 -1
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts +4 -4
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +3 -3
- package/src/core/geom/3d/topology/simplify/quadratic/{Quadratic3.d.ts → Quadric3.d.ts} +55 -29
- package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -0
- package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +307 -0
- package/src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.d.ts +7 -7
- package/src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +39 -13
- package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.d.ts +2 -2
- package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js +1 -1
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts +2 -2
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +2 -2
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh2.d.ts +4 -4
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh2.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/simplifyTopoMesh2.js +5 -5
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.d.ts +8 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_face_normals.js +56 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.d.ts +14 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compute_vertex_quadratics.js +95 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts +17 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +352 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.d.ts +21 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_collapse.js +52 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +16 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +90 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.d.ts +19 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.js +83 -0
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vert_fuse_duplicate_edges.js +148 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_get_incenter.js +4 -4
- package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.d.ts +15 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_faces_shared_loop.js +48 -0
- package/src/engine/navigation/mesh/NavigationMesh.d.ts +6 -4
- package/src/engine/navigation/mesh/NavigationMesh.d.ts.map +1 -1
- package/src/engine/navigation/mesh/NavigationMesh.js +212 -190
- package/src/engine/navigation/mesh/build/navmesh_build_topology.d.ts.map +1 -1
- package/src/engine/navigation/mesh/build/navmesh_build_topology.js +20 -7
- package/src/engine/navigation/mesh/bvh_query_nearest_face.d.ts +15 -0
- package/src/engine/navigation/mesh/bvh_query_nearest_face.d.ts.map +1 -0
- package/src/engine/navigation/mesh/bvh_query_nearest_face.js +131 -0
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.d.ts.map +0 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +0 -302
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { vec3 } from "gl-matrix";
|
|
2
|
-
import { EPSILON } from "../../../../../math/EPSILON.js";
|
|
3
|
-
import { fabsf } from "../../../../../math/fabsf.js";
|
|
4
|
-
import { v3_dot } from "../../../../vec3/v3_dot.js";
|
|
5
|
-
import { compute_triangle_normal } from "../../../triangle/compute_triangle_normal.js";
|
|
6
|
-
|
|
7
|
-
const scratch_v3 = new Float32Array(3);
|
|
8
|
-
const scratch_m3 = new Float32Array(9);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Quadric Error Metric
|
|
12
|
-
* Triangular 4x4 matrix, see https://en.wikipedia.org/wiki/Triangular_matrix
|
|
13
|
-
*/
|
|
14
|
-
export class Quadratic3 {
|
|
15
|
-
|
|
16
|
-
// Row 0
|
|
17
|
-
a2 = 0;
|
|
18
|
-
ab = 0;
|
|
19
|
-
ac = 0;
|
|
20
|
-
ad = 0;
|
|
21
|
-
|
|
22
|
-
// Row 1
|
|
23
|
-
b2 = 0;
|
|
24
|
-
bc = 0;
|
|
25
|
-
bd = 0;
|
|
26
|
-
|
|
27
|
-
// Row 2
|
|
28
|
-
c2 = 0;
|
|
29
|
-
cd = 0;
|
|
30
|
-
|
|
31
|
-
// Row 3
|
|
32
|
-
d2 = 0;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {ArrayLike<number>|number[]|Float32Array} result
|
|
38
|
-
*/
|
|
39
|
-
toVector3(result) {
|
|
40
|
-
result[0] = this.ad;
|
|
41
|
-
result[1] = this.bd;
|
|
42
|
-
result[2] = this.cd;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {ArrayLike<number>|number[]|Float32Array} m3
|
|
48
|
-
*/
|
|
49
|
-
toTensorM3(m3) {
|
|
50
|
-
m3[0] = this.a2;
|
|
51
|
-
m3[1] = this.ab;
|
|
52
|
-
m3[2] = this.ac;
|
|
53
|
-
|
|
54
|
-
m3[3] = this.ab;
|
|
55
|
-
m3[4] = this.b2;
|
|
56
|
-
m3[5] = this.bc;
|
|
57
|
-
|
|
58
|
-
m3[6] = this.ac;
|
|
59
|
-
m3[7] = this.bc;
|
|
60
|
-
m3[8] = this.c2;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Equivalent to taking a tensor followed by matrix inversion
|
|
65
|
-
* @param {ArrayLike<number>|number[]|Float32Array} m3
|
|
66
|
-
* @param {number} epsilon
|
|
67
|
-
* @returns {boolean} whether operation was successful or not
|
|
68
|
-
*/
|
|
69
|
-
toTensorM3Inverse(m3, epsilon) {
|
|
70
|
-
const a2 = this.a2;
|
|
71
|
-
const b2 = this.b2;
|
|
72
|
-
const c2 = this.c2;
|
|
73
|
-
const bc = this.bc;
|
|
74
|
-
const ab = this.ab;
|
|
75
|
-
const ac = this.ac;
|
|
76
|
-
|
|
77
|
-
const det = a2 * (b2 * c2 - bc * bc) -
|
|
78
|
-
ab * (ab * c2 - ac * bc) +
|
|
79
|
-
ac * (ab * bc - ac * b2);
|
|
80
|
-
|
|
81
|
-
if (fabsf(det) > epsilon) {
|
|
82
|
-
|
|
83
|
-
const invdet = 1.0 / det;
|
|
84
|
-
|
|
85
|
-
m3[0] = (b2 * c2 - bc * bc) * invdet;
|
|
86
|
-
m3[3] = (bc * ac - ab * c2) * invdet;
|
|
87
|
-
m3[6] = (ab * bc - b2 * ac) * invdet;
|
|
88
|
-
|
|
89
|
-
m3[1] = (ac * bc - ab * c2) * invdet;
|
|
90
|
-
m3[4] = (a2 * c2 - ac * ac) * invdet;
|
|
91
|
-
m3[7] = (ab * ac - a2 * bc) * invdet;
|
|
92
|
-
|
|
93
|
-
m3[2] = (ab * bc - ac * b2) * invdet;
|
|
94
|
-
m3[5] = (ac * ab - a2 * bc) * invdet;
|
|
95
|
-
m3[8] = (a2 * b2 - ab * ab) * invdet;
|
|
96
|
-
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Set from plane expressed as a 4 component vector
|
|
105
|
-
* @param {number} x plane normal
|
|
106
|
-
* @param {number} y plane normal
|
|
107
|
-
* @param {number} z plane normal
|
|
108
|
-
* @param {number} w plane offset
|
|
109
|
-
*/
|
|
110
|
-
setFromVector4(x, y, z, w) {
|
|
111
|
-
this.a2 = x * x;
|
|
112
|
-
this.ab = x * y;
|
|
113
|
-
this.ac = x * z;
|
|
114
|
-
this.ad = x * w;
|
|
115
|
-
|
|
116
|
-
this.b2 = y * y;
|
|
117
|
-
this.bc = y * z;
|
|
118
|
-
this.bd = y * w;
|
|
119
|
-
|
|
120
|
-
this.c2 = z * z;
|
|
121
|
-
this.cd = z * w;
|
|
122
|
-
|
|
123
|
-
this.d2 = w * w;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
*
|
|
128
|
-
* @param {TopoTriangle} face
|
|
129
|
-
*/
|
|
130
|
-
setFromFace(face) {
|
|
131
|
-
const v0 = face.vertices[0];
|
|
132
|
-
|
|
133
|
-
// compute triangle's plane
|
|
134
|
-
compute_triangle_normal(scratch_v3, v0, face.vertices[1], face.vertices[2]);
|
|
135
|
-
|
|
136
|
-
// compute plane offset
|
|
137
|
-
|
|
138
|
-
const normal_x = scratch_v3[0];
|
|
139
|
-
const normal_y = scratch_v3[1];
|
|
140
|
-
const normal_z = scratch_v3[2];
|
|
141
|
-
|
|
142
|
-
const plane_constant = -v3_dot(
|
|
143
|
-
normal_x, normal_y, normal_z,
|
|
144
|
-
|
|
145
|
-
v0.x, v0.y, v0.z
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
this.setFromVector4(normal_x, normal_y, normal_z, plane_constant);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Squared distance from the given point to plane encoded by the quadratic
|
|
153
|
-
* @param {number} x
|
|
154
|
-
* @param {number} y
|
|
155
|
-
* @param {number} z
|
|
156
|
-
* @returns {number}
|
|
157
|
-
*/
|
|
158
|
-
evaluate(x, y, z) {
|
|
159
|
-
// Evaluate vAv + 2bv + c
|
|
160
|
-
|
|
161
|
-
return (x * x * this.a2) + (2 * x * y * this.ab) + (2 * x * z * this.ac) + (2 * x * this.ad) // A
|
|
162
|
-
+ (y * y * this.b2) + (2 * y * z * this.bc) + (2 * y * this.bd) // B
|
|
163
|
-
+ (z * z * this.c2) + (2 * z * this.cd) // C
|
|
164
|
-
+ this.d2; // D
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Find optimal vertex position based on the quadratic
|
|
169
|
-
*
|
|
170
|
-
* Based on Blender's implementation: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/quadric.c
|
|
171
|
-
*
|
|
172
|
-
* @param {number[]} out
|
|
173
|
-
* @returns {boolean}
|
|
174
|
-
*/
|
|
175
|
-
optimize(out) {
|
|
176
|
-
|
|
177
|
-
if (this.toTensorM3Inverse(scratch_m3, EPSILON)) {
|
|
178
|
-
|
|
179
|
-
this.toVector3(out);
|
|
180
|
-
|
|
181
|
-
vec3.transformMat3(out, out, scratch_m3);
|
|
182
|
-
vec3.negate(out, out);
|
|
183
|
-
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return false;
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
* @param {Quadratic3} Q
|
|
194
|
-
*/
|
|
195
|
-
add(Q) {
|
|
196
|
-
|
|
197
|
-
// Accumulate coefficients
|
|
198
|
-
|
|
199
|
-
// R0
|
|
200
|
-
this.a2 += Q.a2;
|
|
201
|
-
this.ab += Q.ab;
|
|
202
|
-
this.ac += Q.ac;
|
|
203
|
-
this.ad += Q.ad;
|
|
204
|
-
|
|
205
|
-
// R1
|
|
206
|
-
this.b2 += Q.b2;
|
|
207
|
-
this.bc += Q.bc;
|
|
208
|
-
this.bd += Q.bd;
|
|
209
|
-
|
|
210
|
-
// R2
|
|
211
|
-
this.c2 += Q.c2;
|
|
212
|
-
this.cd += Q.cd;
|
|
213
|
-
|
|
214
|
-
// R3
|
|
215
|
-
this.d2 += Q.d2;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
*
|
|
220
|
-
* @param {number} v
|
|
221
|
-
*/
|
|
222
|
-
multiplyScalar(v) {
|
|
223
|
-
// R0
|
|
224
|
-
this.a2 *= v;
|
|
225
|
-
this.ab *= v;
|
|
226
|
-
this.ac *= v;
|
|
227
|
-
this.ad *= v;
|
|
228
|
-
|
|
229
|
-
// R1
|
|
230
|
-
this.b2 *= v;
|
|
231
|
-
this.bc *= v;
|
|
232
|
-
this.bd *= v;
|
|
233
|
-
|
|
234
|
-
// R2
|
|
235
|
-
this.c2 *= v;
|
|
236
|
-
this.cd *= v;
|
|
237
|
-
|
|
238
|
-
// R3
|
|
239
|
-
this.d2 *= v;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
*
|
|
244
|
-
* @returns {Quadratic3}
|
|
245
|
-
*/
|
|
246
|
-
clone() {
|
|
247
|
-
const r = new Quadratic3();
|
|
248
|
-
|
|
249
|
-
r.copy(this);
|
|
250
|
-
|
|
251
|
-
return r;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
*
|
|
256
|
-
* @param {Quadratic3} other
|
|
257
|
-
*/
|
|
258
|
-
copy(other) {
|
|
259
|
-
|
|
260
|
-
// R0
|
|
261
|
-
this.a2 = other.a2;
|
|
262
|
-
this.ab = other.ab;
|
|
263
|
-
this.ac = other.ac;
|
|
264
|
-
this.ad = other.ad;
|
|
265
|
-
|
|
266
|
-
// R1
|
|
267
|
-
this.b2 = other.b2;
|
|
268
|
-
this.bc = other.bc;
|
|
269
|
-
this.bd = other.bd;
|
|
270
|
-
|
|
271
|
-
// R2
|
|
272
|
-
this.c2 = other.c2;
|
|
273
|
-
this.cd = other.cd;
|
|
274
|
-
|
|
275
|
-
// R3
|
|
276
|
-
this.d2 = other.d2;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Set all matrix values to 0
|
|
281
|
-
*/
|
|
282
|
-
clear() {
|
|
283
|
-
// Row 0
|
|
284
|
-
this.a2 = 0;
|
|
285
|
-
this.ab = 0;
|
|
286
|
-
this.ac = 0;
|
|
287
|
-
this.ad = 0;
|
|
288
|
-
|
|
289
|
-
// Row 1
|
|
290
|
-
this.b2 = 0;
|
|
291
|
-
this.bc = 0;
|
|
292
|
-
this.bd = 0;
|
|
293
|
-
|
|
294
|
-
// Row 2
|
|
295
|
-
this.c2 = 0;
|
|
296
|
-
this.cd = 0;
|
|
297
|
-
|
|
298
|
-
// Row 3
|
|
299
|
-
this.d2 = 0;
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
}
|