@woosh/meep-engine 2.133.5 → 2.134.1
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/core/graph/coloring/colorizeGraphMCS.js +1 -1
- package/src/core/graph/convert_graph_to_dot_string.d.ts.map +1 -1
- package/src/core/graph/convert_graph_to_dot_string.js +2 -1
- package/src/core/graph/graph_compute_distance_matrix.d.ts +18 -1
- package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_distance_matrix.js +21 -2
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_laplacian_matrix.js +2 -1
- package/src/core/graph/graph_k_means_cluster.d.ts +10 -3
- package/src/core/graph/graph_k_means_cluster.d.ts.map +1 -1
- package/src/core/graph/graph_k_means_cluster.js +250 -123
- package/src/core/graph/layout/CircleLayout.js +6 -6
- package/src/core/graph/layout/Connection.js +1 -1
- package/src/core/graph/layout/box/aabb2_force_into_container.d.ts.map +1 -1
- package/src/core/graph/layout/box/aabb2_force_into_container.js +4 -2
- package/src/core/math/statistics/computeStatisticalMedian.js +1 -1
- 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
|
@@ -14,7 +14,7 @@ const INVALID_FLIP_COST = Number.MAX_VALUE;
|
|
|
14
14
|
* @param {TopoVertex} victim
|
|
15
15
|
* @param {TopoVertex} target
|
|
16
16
|
* @param {TopoEdge} victim_edge
|
|
17
|
-
* @param {Map<number,
|
|
17
|
+
* @param {Map<number, Quadric3>} vertex_quadratics
|
|
18
18
|
* @return {number}
|
|
19
19
|
*/
|
|
20
20
|
export function computeEdgeCollapseCost(victim, target, victim_edge, vertex_quadratics) {
|
|
@@ -14,19 +14,19 @@ export function edge_collapse_pick_target_vertex(edge: TopoEdge, restricted_vert
|
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @param {TopoEdge} edge
|
|
17
|
-
* @param {Map<number,
|
|
17
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
18
18
|
* @param {Set<number>} restricted_vertices
|
|
19
19
|
*/
|
|
20
|
-
export function compute_edge_collapse_cost(edge: TopoEdge, quadratics: Map<number,
|
|
20
|
+
export function compute_edge_collapse_cost(edge: TopoEdge, quadratics: Map<number, Quadric3>, restricted_vertices: Set<number>): number;
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param {TopoMesh} mesh
|
|
24
24
|
* @param {TopoEdge}edge
|
|
25
25
|
* @param {TopoVertex} target
|
|
26
|
-
* @param {Map<number,
|
|
26
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
27
27
|
* @param {Uint32Heap} heap
|
|
28
28
|
* @param {Set<number>} restricted_vertices
|
|
29
29
|
* @returns {boolean}
|
|
30
30
|
*/
|
|
31
|
-
export function decimate_edge_collapse_snap(mesh: TopoMesh, edge: TopoEdge, target: TopoVertex, quadratics: Map<number,
|
|
31
|
+
export function decimate_edge_collapse_snap(mesh: TopoMesh, edge: TopoEdge, target: TopoVertex, quadratics: Map<number, Quadric3>, heap: Uint32Heap, restricted_vertices: Set<number>): boolean;
|
|
32
32
|
//# sourceMappingURL=decimate_edge_collapse_snap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimate_edge_collapse_snap.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,kFASC;AAED;;;;;GAKG;AACH,sFAHW,IAAI,MAAM,CAAC,GACT,aAAW,SAAS,CA0ChC;AAqBD;;;;;GAKG;AACH,uEAHW,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"decimate_edge_collapse_snap.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,kFASC;AAED;;;;;GAKG;AACH,sFAHW,IAAI,MAAM,CAAC,GACT,aAAW,SAAS,CA0ChC;AAqBD;;;;;GAKG;AACH,uEAHW,IAAI,MAAM,WAAU,uBACpB,IAAI,MAAM,CAAC,UAsBrB;AAsBD;;;;;;;;;GASG;AACH,4GALW,IAAI,MAAM,WAAU,yCAEpB,IAAI,MAAM,CAAC,GACT,OAAO,CAmFnB"}
|
|
@@ -132,7 +132,7 @@ function build_edge_cost_squared_topology(edge) {
|
|
|
132
132
|
/**
|
|
133
133
|
*
|
|
134
134
|
* @param {TopoEdge} edge
|
|
135
|
-
* @param {Map<number,
|
|
135
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
136
136
|
* @param {Set<number>} restricted_vertices
|
|
137
137
|
*/
|
|
138
138
|
export function compute_edge_collapse_cost(edge, quadratics, restricted_vertices) {
|
|
@@ -160,7 +160,7 @@ export function compute_edge_collapse_cost(edge, quadratics, restricted_vertices
|
|
|
160
160
|
/**
|
|
161
161
|
*
|
|
162
162
|
* @param {TopoEdge} edge
|
|
163
|
-
* @param {Map<number,
|
|
163
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
164
164
|
* @param {Uint32Heap} heap
|
|
165
165
|
* @param {Set<number>} restricted_vertices
|
|
166
166
|
*/
|
|
@@ -182,7 +182,7 @@ function tm_build_cost(edge, quadratics, heap, restricted_vertices) {
|
|
|
182
182
|
* @param {TopoMesh} mesh
|
|
183
183
|
* @param {TopoEdge}edge
|
|
184
184
|
* @param {TopoVertex} target
|
|
185
|
-
* @param {Map<number,
|
|
185
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
186
186
|
* @param {Uint32Heap} heap
|
|
187
187
|
* @param {Set<number>} restricted_vertices
|
|
188
188
|
* @returns {boolean}
|
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Quadric Error Metric
|
|
3
|
-
*
|
|
3
|
+
* Upper-triangular portion of a symmetric 4x4 matrix encoding a quadric form.
|
|
4
|
+
*
|
|
5
|
+
* Layout (10 elements):
|
|
6
|
+
* [0]=a2 [1]=ab [2]=ac [3]=ad
|
|
7
|
+
* [4]=b2 [5]=bc [6]=bd
|
|
8
|
+
* [7]=c2 [8]=cd
|
|
9
|
+
* [9]=d2
|
|
4
10
|
*/
|
|
5
|
-
export class
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export class Quadric3 extends Float64Array {
|
|
12
|
+
constructor();
|
|
13
|
+
set a2(arg: any);
|
|
14
|
+
get a2(): any;
|
|
15
|
+
0: any;
|
|
16
|
+
set ab(arg: any);
|
|
17
|
+
get ab(): any;
|
|
18
|
+
1: any;
|
|
19
|
+
set ac(arg: any);
|
|
20
|
+
get ac(): any;
|
|
21
|
+
2: any;
|
|
22
|
+
set ad(arg: any);
|
|
23
|
+
get ad(): any;
|
|
24
|
+
3: any;
|
|
25
|
+
set b2(arg: any);
|
|
26
|
+
get b2(): any;
|
|
27
|
+
4: any;
|
|
28
|
+
set bc(arg: any);
|
|
29
|
+
get bc(): any;
|
|
30
|
+
5: any;
|
|
31
|
+
set bd(arg: any);
|
|
32
|
+
get bd(): any;
|
|
33
|
+
6: any;
|
|
34
|
+
set c2(arg: any);
|
|
35
|
+
get c2(): any;
|
|
36
|
+
7: any;
|
|
37
|
+
set cd(arg: any);
|
|
38
|
+
get cd(): any;
|
|
39
|
+
8: any;
|
|
40
|
+
set d2(arg: any);
|
|
41
|
+
get d2(): any;
|
|
42
|
+
9: any;
|
|
16
43
|
/**
|
|
17
44
|
*
|
|
18
45
|
* @param {ArrayLike<number>|number[]|Float32Array} result
|
|
@@ -39,12 +66,7 @@ export class Quadratic3 {
|
|
|
39
66
|
*/
|
|
40
67
|
setFromVector4(x: number, y: number, z: number, w: number): void;
|
|
41
68
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {TopoTriangle} face
|
|
44
|
-
*/
|
|
45
|
-
setFromFace(face: TopoTriangle): void;
|
|
46
|
-
/**
|
|
47
|
-
* Squared distance from the given point to plane encoded by the quadratic
|
|
69
|
+
* Squared distance from the given point to plane encoded by the quadric
|
|
48
70
|
* @param {number} x
|
|
49
71
|
* @param {number} y
|
|
50
72
|
* @param {number} z
|
|
@@ -52,19 +74,17 @@ export class Quadratic3 {
|
|
|
52
74
|
*/
|
|
53
75
|
evaluate(x: number, y: number, z: number): number;
|
|
54
76
|
/**
|
|
55
|
-
* Find optimal vertex position based on the
|
|
77
|
+
* Find the optimal vertex position based on the quadric
|
|
56
78
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @param {number[]} out
|
|
79
|
+
* @param {number[]} out vector3
|
|
60
80
|
* @returns {boolean}
|
|
61
81
|
*/
|
|
62
82
|
optimize(out: number[]): boolean;
|
|
63
83
|
/**
|
|
64
84
|
*
|
|
65
|
-
* @param {
|
|
85
|
+
* @param {Quadric3} Q
|
|
66
86
|
*/
|
|
67
|
-
add(Q:
|
|
87
|
+
add(Q: Quadric3): void;
|
|
68
88
|
/**
|
|
69
89
|
*
|
|
70
90
|
* @param {number} v
|
|
@@ -72,17 +92,23 @@ export class Quadratic3 {
|
|
|
72
92
|
multiplyScalar(v: number): void;
|
|
73
93
|
/**
|
|
74
94
|
*
|
|
75
|
-
* @returns {
|
|
95
|
+
* @returns {Quadric3}
|
|
76
96
|
*/
|
|
77
|
-
clone():
|
|
97
|
+
clone(): Quadric3;
|
|
78
98
|
/**
|
|
79
99
|
*
|
|
80
|
-
* @param {
|
|
100
|
+
* @param {Quadric3} other
|
|
81
101
|
*/
|
|
82
|
-
copy(other:
|
|
102
|
+
copy(other: Quadric3): void;
|
|
83
103
|
/**
|
|
84
104
|
* Set all matrix values to 0
|
|
85
105
|
*/
|
|
86
106
|
clear(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Useful for type checking
|
|
109
|
+
* @readonly
|
|
110
|
+
* @type {boolean}
|
|
111
|
+
*/
|
|
112
|
+
readonly isQuadric3: boolean;
|
|
87
113
|
}
|
|
88
|
-
//# sourceMappingURL=
|
|
114
|
+
//# sourceMappingURL=Quadric3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Quadric3.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/Quadric3.js"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH;IACI,cAEC;IAMD,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAOf,iBAEC;IAND,cAEC;IAGG,OAAW;IAGf;;;OAGG;IACH,kBAFW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAMjD;IAED;;;OAGG;IACH,eAFW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAkBjD;IAED;;;;;OAKG;IACH,sBAJW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,WACvC,MAAM,GACJ,OAAO,CAqCnB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;;;;;OAMG;IACH,YALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CASlB;IAED;;;;;OAKG;IACH,cAHW,MAAM,EAAE,GACN,OAAO,CAkBnB;IAED;;;OAGG;IACH,OAFW,QAAQ,QAalB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAahB;IAED;;;OAGG;IACH,SAFa,QAAQ,CAQpB;IAED;;;OAGG;IACH,YAFW,QAAQ,QAIlB;IAED;;OAEG;IACH,cAEC;IAGL;;;;OAIG;IACH,qBAFU,OAAO,CAEY;CAP5B"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { vec3 } from "gl-matrix";
|
|
2
|
+
import { EPSILON } from "../../../../../math/EPSILON.js";
|
|
3
|
+
import { fabsf } from "../../../../../math/fabsf.js";
|
|
4
|
+
|
|
5
|
+
const scratch_m3 = new Float32Array(9);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Quadric Error Metric
|
|
9
|
+
* Upper-triangular portion of a symmetric 4x4 matrix encoding a quadric form.
|
|
10
|
+
*
|
|
11
|
+
* Layout (10 elements):
|
|
12
|
+
* [0]=a2 [1]=ab [2]=ac [3]=ad
|
|
13
|
+
* [4]=b2 [5]=bc [6]=bd
|
|
14
|
+
* [7]=c2 [8]=cd
|
|
15
|
+
* [9]=d2
|
|
16
|
+
*/
|
|
17
|
+
export class Quadric3 extends Float64Array {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(10);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get a2() {
|
|
23
|
+
return this[0];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set a2(v) {
|
|
27
|
+
this[0] = v;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get ab() {
|
|
31
|
+
return this[1];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
set ab(v) {
|
|
35
|
+
this[1] = v;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get ac() {
|
|
39
|
+
return this[2];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
set ac(v) {
|
|
43
|
+
this[2] = v;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get ad() {
|
|
47
|
+
return this[3];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
set ad(v) {
|
|
51
|
+
this[3] = v;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get b2() {
|
|
55
|
+
return this[4];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set b2(v) {
|
|
59
|
+
this[4] = v;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get bc() {
|
|
63
|
+
return this[5];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
set bc(v) {
|
|
67
|
+
this[5] = v;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get bd() {
|
|
71
|
+
return this[6];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set bd(v) {
|
|
75
|
+
this[6] = v;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get c2() {
|
|
79
|
+
return this[7];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
set c2(v) {
|
|
83
|
+
this[7] = v;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get cd() {
|
|
87
|
+
return this[8];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
set cd(v) {
|
|
91
|
+
this[8] = v;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get d2() {
|
|
95
|
+
return this[9];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set d2(v) {
|
|
99
|
+
this[9] = v;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @param {ArrayLike<number>|number[]|Float32Array} result
|
|
105
|
+
*/
|
|
106
|
+
toVector3(result) {
|
|
107
|
+
result[0] = this[3];
|
|
108
|
+
result[1] = this[6];
|
|
109
|
+
result[2] = this[8];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {ArrayLike<number>|number[]|Float32Array} m3
|
|
115
|
+
*/
|
|
116
|
+
toTensorM3(m3) {
|
|
117
|
+
const ab = this[1];
|
|
118
|
+
const ac = this[2];
|
|
119
|
+
const bc = this[5];
|
|
120
|
+
|
|
121
|
+
m3[0] = this[0];
|
|
122
|
+
m3[1] = ab;
|
|
123
|
+
m3[2] = ac;
|
|
124
|
+
|
|
125
|
+
m3[3] = ab;
|
|
126
|
+
m3[4] = this[4];
|
|
127
|
+
m3[5] = bc;
|
|
128
|
+
|
|
129
|
+
m3[6] = ac;
|
|
130
|
+
m3[7] = bc;
|
|
131
|
+
m3[8] = this[7];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Equivalent to taking a tensor followed by matrix inversion
|
|
136
|
+
* @param {ArrayLike<number>|number[]|Float32Array} m3
|
|
137
|
+
* @param {number} epsilon
|
|
138
|
+
* @returns {boolean} whether operation was successful or not
|
|
139
|
+
*/
|
|
140
|
+
toTensorM3Inverse(m3, epsilon) {
|
|
141
|
+
const a2 = this[0];
|
|
142
|
+
const ab = this[1];
|
|
143
|
+
const ac = this[2];
|
|
144
|
+
const b2 = this[4];
|
|
145
|
+
const bc = this[5];
|
|
146
|
+
const c2 = this[7];
|
|
147
|
+
|
|
148
|
+
const det = a2 * (b2 * c2 - bc * bc) -
|
|
149
|
+
ab * (ab * c2 - ac * bc) +
|
|
150
|
+
ac * (ab * bc - ac * b2);
|
|
151
|
+
|
|
152
|
+
if (fabsf(det) > epsilon) {
|
|
153
|
+
// avoid division by zero
|
|
154
|
+
|
|
155
|
+
const invdet = 1.0 / det;
|
|
156
|
+
|
|
157
|
+
m3[0] = (b2 * c2 - bc * bc) * invdet;
|
|
158
|
+
m3[3] = (bc * ac - ab * c2) * invdet;
|
|
159
|
+
m3[6] = (ab * bc - b2 * ac) * invdet;
|
|
160
|
+
|
|
161
|
+
m3[1] = (ac * bc - ab * c2) * invdet;
|
|
162
|
+
m3[4] = (a2 * c2 - ac * ac) * invdet;
|
|
163
|
+
m3[7] = (ab * ac - a2 * bc) * invdet;
|
|
164
|
+
|
|
165
|
+
m3[2] = (ab * bc - ac * b2) * invdet;
|
|
166
|
+
m3[5] = (ac * ab - a2 * bc) * invdet;
|
|
167
|
+
m3[8] = (a2 * b2 - ab * ab) * invdet;
|
|
168
|
+
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// determinant is zero, matrix is singular, cannot invert
|
|
173
|
+
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Set from plane expressed as a 4 component vector
|
|
179
|
+
* @param {number} x plane normal
|
|
180
|
+
* @param {number} y plane normal
|
|
181
|
+
* @param {number} z plane normal
|
|
182
|
+
* @param {number} w plane offset
|
|
183
|
+
*/
|
|
184
|
+
setFromVector4(x, y, z, w) {
|
|
185
|
+
this[0] = x * x;
|
|
186
|
+
this[1] = x * y;
|
|
187
|
+
this[2] = x * z;
|
|
188
|
+
this[3] = x * w;
|
|
189
|
+
|
|
190
|
+
this[4] = y * y;
|
|
191
|
+
this[5] = y * z;
|
|
192
|
+
this[6] = y * w;
|
|
193
|
+
|
|
194
|
+
this[7] = z * z;
|
|
195
|
+
this[8] = z * w;
|
|
196
|
+
|
|
197
|
+
this[9] = w * w;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Squared distance from the given point to plane encoded by the quadric
|
|
202
|
+
* @param {number} x
|
|
203
|
+
* @param {number} y
|
|
204
|
+
* @param {number} z
|
|
205
|
+
* @returns {number}
|
|
206
|
+
*/
|
|
207
|
+
evaluate(x, y, z) {
|
|
208
|
+
// Evaluate vAv + 2bv + c
|
|
209
|
+
|
|
210
|
+
return (x * x * this[0]) + (2 * x * y * this[1]) + (2 * x * z * this[2]) + (2 * x * this[3]) // A
|
|
211
|
+
+ (y * y * this[4]) + (2 * y * z * this[5]) + (2 * y * this[6]) // B
|
|
212
|
+
+ (z * z * this[7]) + (2 * z * this[8]) // C
|
|
213
|
+
+ this[9]; // D
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Find the optimal vertex position based on the quadric
|
|
218
|
+
*
|
|
219
|
+
* @param {number[]} out vector3
|
|
220
|
+
* @returns {boolean}
|
|
221
|
+
*/
|
|
222
|
+
optimize(out) {
|
|
223
|
+
|
|
224
|
+
// Based on Blender's implementation: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/quadric.c
|
|
225
|
+
|
|
226
|
+
if (this.toTensorM3Inverse(scratch_m3, EPSILON)) {
|
|
227
|
+
|
|
228
|
+
this.toVector3(out);
|
|
229
|
+
|
|
230
|
+
vec3.transformMat3(out, out, scratch_m3);
|
|
231
|
+
vec3.negate(out, out);
|
|
232
|
+
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return false;
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
*
|
|
242
|
+
* @param {Quadric3} Q
|
|
243
|
+
*/
|
|
244
|
+
add(Q) {
|
|
245
|
+
this[0] += Q[0];
|
|
246
|
+
this[1] += Q[1];
|
|
247
|
+
this[2] += Q[2];
|
|
248
|
+
this[3] += Q[3];
|
|
249
|
+
this[4] += Q[4];
|
|
250
|
+
this[5] += Q[5];
|
|
251
|
+
this[6] += Q[6];
|
|
252
|
+
this[7] += Q[7];
|
|
253
|
+
this[8] += Q[8];
|
|
254
|
+
this[9] += Q[9];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
*
|
|
259
|
+
* @param {number} v
|
|
260
|
+
*/
|
|
261
|
+
multiplyScalar(v) {
|
|
262
|
+
this[0] *= v;
|
|
263
|
+
this[1] *= v;
|
|
264
|
+
this[2] *= v;
|
|
265
|
+
this[3] *= v;
|
|
266
|
+
this[4] *= v;
|
|
267
|
+
this[5] *= v;
|
|
268
|
+
this[6] *= v;
|
|
269
|
+
this[7] *= v;
|
|
270
|
+
this[8] *= v;
|
|
271
|
+
this[9] *= v;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @returns {Quadric3}
|
|
277
|
+
*/
|
|
278
|
+
clone() {
|
|
279
|
+
const r = new Quadric3();
|
|
280
|
+
|
|
281
|
+
r.copy(this);
|
|
282
|
+
|
|
283
|
+
return r;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @param {Quadric3} other
|
|
289
|
+
*/
|
|
290
|
+
copy(other) {
|
|
291
|
+
this.set(other);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Set all matrix values to 0
|
|
296
|
+
*/
|
|
297
|
+
clear() {
|
|
298
|
+
this.fill(0);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Useful for type checking
|
|
304
|
+
* @readonly
|
|
305
|
+
* @type {boolean}
|
|
306
|
+
*/
|
|
307
|
+
Quadric3.prototype.isQuadric3 = true;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
|
-
* @param {Map<number,
|
|
4
|
-
* @param {Map<number,
|
|
3
|
+
* @param {Map<number, Quadric3>} destination
|
|
4
|
+
* @param {Map<number, Quadric3>} source
|
|
5
5
|
* @param {TopoMesh} mesh
|
|
6
6
|
*/
|
|
7
|
-
export function deep_copy_vertex_quadratics(destination: Map<number,
|
|
7
|
+
export function deep_copy_vertex_quadratics(destination: Map<number, Quadric3>, source: Map<number, Quadric3>, mesh: TopoMesh): void;
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param {TopoMesh} mesh
|
|
11
11
|
* @param {TopoEdge[]} border_set
|
|
12
|
-
* @param {Map<number,
|
|
12
|
+
* @param {Map<number, Quadric3>} vertex_quadratics
|
|
13
13
|
* @param {number} [weight]
|
|
14
14
|
*/
|
|
15
|
-
export function apply_border_penalties_to_vertex_quadrics(mesh: TopoMesh, border_set: TopoEdge[], vertex_quadratics: Map<number,
|
|
15
|
+
export function apply_border_penalties_to_vertex_quadrics(mesh: TopoMesh, border_set: TopoEdge[], vertex_quadratics: Map<number, Quadric3>, weight?: number): void;
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
* @param {TopoMesh} mesh
|
|
19
|
-
* @param {Map<number,
|
|
19
|
+
* @param {Map<number, Quadric3>} quadratics VertexID -> Quadratic map
|
|
20
20
|
* @param {boolean} [use_triangle_area]
|
|
21
21
|
* @param {boolean} [use_border_constraints]
|
|
22
22
|
*/
|
|
23
23
|
export function build_vertex_quadratics({ mesh, quadratics, use_triangle_area, use_border_constraints }: TopoMesh): void;
|
|
24
|
-
import {
|
|
24
|
+
import { Quadric3 } from "./Quadric3.js";
|
|
25
25
|
//# sourceMappingURL=build_vertex_quadratics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_vertex_quadratics.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_vertex_quadratics.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,yDAJW,IAAI,MAAM,EAAE,QAAQ,CAAC,UACrB,IAAI,MAAM,EAAE,QAAQ,CAAC,wBAgB/B;AA8CD;;;;;;GAMG;AACH,sFAJW,UAAU,qBACV,IAAI,MAAM,EAAE,QAAQ,CAAC,WACrB,MAAM,QAQhB;AA2BD;;;;;;GAMG;AACH,yHAwDC;yBA1KwB,eAAe"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Quadratic3 } from "./Quadratic3.js";
|
|
2
|
-
import { tm_face_area } from "../../tm_face_area.js";
|
|
3
|
-
import { assert } from "../../../../../assert.js";
|
|
4
|
-
import { tm_face_normal } from "../../tm_face_normal.js";
|
|
5
1
|
import { vec3 } from "gl-matrix";
|
|
2
|
+
import { assert } from "../../../../../assert.js";
|
|
3
|
+
import { v3_dot } from "../../../../vec3/v3_dot.js";
|
|
6
4
|
import { query_edge_is_boundary } from "../../query/query_edge_is_boundary.js";
|
|
5
|
+
import { tm_face_area } from "../../tm_face_area.js";
|
|
6
|
+
import { tm_face_normal } from "../../tm_face_normal.js";
|
|
7
|
+
import { Quadric3 } from "./Quadric3.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
*
|
|
10
|
-
* @param {Map<number,
|
|
11
|
-
* @param {Map<number,
|
|
11
|
+
* @param {Map<number, Quadric3>} destination
|
|
12
|
+
* @param {Map<number, Quadric3>} source
|
|
12
13
|
* @param {TopoMesh} mesh
|
|
13
14
|
*/
|
|
14
15
|
export function deep_copy_vertex_quadratics(destination, source, mesh) {
|
|
@@ -31,7 +32,7 @@ export function deep_copy_vertex_quadratics(destination, source, mesh) {
|
|
|
31
32
|
* @see "Boundary and Texture Preserving Mesh Simplification Algorithm for Virtual Reality" by Kanchan Bahirat et.al. University of Texas/Dallas
|
|
32
33
|
* @param {TopoEdge} edge
|
|
33
34
|
* @param {number} weight
|
|
34
|
-
* @param {Map<number,
|
|
35
|
+
* @param {Map<number, Quadric3>} vertex_quadratics
|
|
35
36
|
*/
|
|
36
37
|
function apply_border_penalty_to_vertex_quadrics(edge, weight, vertex_quadratics) {
|
|
37
38
|
const v0 = edge.v0;
|
|
@@ -57,7 +58,7 @@ function apply_border_penalty_to_vertex_quadrics(edge, weight, vertex_quadratics
|
|
|
57
58
|
|
|
58
59
|
const d = -vec3.dot(abc, v0);
|
|
59
60
|
|
|
60
|
-
const constraint = new
|
|
61
|
+
const constraint = new Quadric3();
|
|
61
62
|
constraint.setFromVector4(abc[0], abc[1], abc[2], d);
|
|
62
63
|
constraint.multiplyScalar(vec3.length(edge_vector) * weight);
|
|
63
64
|
// constraint.multiplyScalar(weight);
|
|
@@ -74,7 +75,7 @@ function apply_border_penalty_to_vertex_quadrics(edge, weight, vertex_quadratics
|
|
|
74
75
|
*
|
|
75
76
|
* @param {TopoMesh} mesh
|
|
76
77
|
* @param {TopoEdge[]} border_set
|
|
77
|
-
* @param {Map<number,
|
|
78
|
+
* @param {Map<number, Quadric3>} vertex_quadratics
|
|
78
79
|
* @param {number} [weight]
|
|
79
80
|
*/
|
|
80
81
|
export function apply_border_penalties_to_vertex_quadrics(mesh, border_set, vertex_quadratics, weight = 10) {
|
|
@@ -85,10 +86,35 @@ export function apply_border_penalties_to_vertex_quadrics(mesh, border_set, vert
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {Quadric3} quadric
|
|
92
|
+
* @param {TopoTriangle} face
|
|
93
|
+
*/
|
|
94
|
+
function quadric_set_from_face(quadric, face){
|
|
95
|
+
const v0 = face.vertices[0];
|
|
96
|
+
|
|
97
|
+
// compute triangle's plane
|
|
98
|
+
face.computeNormal();
|
|
99
|
+
|
|
100
|
+
// compute plane offset
|
|
101
|
+
const normal_x = face.normal[0];
|
|
102
|
+
const normal_y = face.normal[1];
|
|
103
|
+
const normal_z = face.normal[2];
|
|
104
|
+
|
|
105
|
+
const plane_constant = -v3_dot(
|
|
106
|
+
normal_x, normal_y, normal_z,
|
|
107
|
+
|
|
108
|
+
v0.x, v0.y, v0.z
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
quadric.setFromVector4(normal_x, normal_y, normal_z, plane_constant);
|
|
112
|
+
}
|
|
113
|
+
|
|
88
114
|
/**
|
|
89
115
|
*
|
|
90
116
|
* @param {TopoMesh} mesh
|
|
91
|
-
* @param {Map<number,
|
|
117
|
+
* @param {Map<number, Quadric3>} quadratics VertexID -> Quadratic map
|
|
92
118
|
* @param {boolean} [use_triangle_area]
|
|
93
119
|
* @param {boolean} [use_border_constraints]
|
|
94
120
|
*/
|
|
@@ -108,19 +134,19 @@ export function build_vertex_quadratics({
|
|
|
108
134
|
for (i = 0; i < mesh_vertex_count; i++) {
|
|
109
135
|
const mesh_vertex = mesh_vertices[i];
|
|
110
136
|
|
|
111
|
-
const vertex_quadratic = new
|
|
137
|
+
const vertex_quadratic = new Quadric3();
|
|
112
138
|
|
|
113
139
|
quadratics.set(mesh_vertex.index, vertex_quadratic);
|
|
114
140
|
}
|
|
115
141
|
|
|
116
142
|
// compute values for quadratics
|
|
117
|
-
const q = new
|
|
143
|
+
const q = new Quadric3();
|
|
118
144
|
|
|
119
145
|
const faces = mesh.getFaces();
|
|
120
146
|
|
|
121
147
|
for (face of faces) {
|
|
122
148
|
|
|
123
|
-
q
|
|
149
|
+
quadric_set_from_face(q,face);
|
|
124
150
|
|
|
125
151
|
if (use_triangle_area) {
|
|
126
152
|
const triangle_area = tm_face_area(face);
|
package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @param {TopoVertex} v0
|
|
4
4
|
* @param {TopoVertex} v1
|
|
5
5
|
* @param {TopoVertex} target where to collapse v0 and v1 to
|
|
6
|
-
* @param {Map<number,
|
|
6
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
7
7
|
* @returns {number}
|
|
8
8
|
*/
|
|
9
|
-
export function compute_edge_collapse_cost_quadratic(v0: TopoVertex, v1: TopoVertex, target: TopoVertex, quadratics: Map<number,
|
|
9
|
+
export function compute_edge_collapse_cost_quadratic(v0: TopoVertex, v1: TopoVertex, target: TopoVertex, quadratics: Map<number, Quadric3>): number;
|
|
10
10
|
//# sourceMappingURL=compute_edge_collapse_cost_quadratic.d.ts.map
|
package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_edge_collapse_cost_quadratic.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qHAHW,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"compute_edge_collapse_cost_quadratic.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qHAHW,IAAI,MAAM,WAAU,GAClB,MAAM,CAqBlB"}
|
package/src/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param {TopoVertex} v0
|
|
4
4
|
* @param {TopoVertex} v1
|
|
5
5
|
* @param {TopoVertex} target where to collapse v0 and v1 to
|
|
6
|
-
* @param {Map<number,
|
|
6
|
+
* @param {Map<number,Quadric3>} quadratics
|
|
7
7
|
* @returns {number}
|
|
8
8
|
*/
|
|
9
9
|
export function compute_edge_collapse_cost_quadratic(
|