@woosh/meep-engine 2.33.6 → 2.33.8
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/core/bvh2/LeafNode.js +6 -1
- package/core/bvh2/aabb3/AABB3.js +17 -0
- package/core/collection/set/compute_set_difference.js +32 -0
- package/core/collection/set/compute_set_intersection.js +22 -0
- package/core/collection/set/set_remove.js +15 -0
- package/core/color/Color.js +1 -0
- package/core/color/ColorUtils.js +12 -3
- package/core/geom/3d/aabb/aabb3_from_min_max.js +15 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +96 -0
- package/{engine/graphics/micron/render/v1 → core/geom/3d}/apply_mat4_transform_to_v3_array.js +0 -0
- package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.js +3 -3
- package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.spec.js +1 -1
- package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_sphere_of_2_spheres.js +3 -3
- package/{engine/graphics/micron/util → core/geom/3d}/encode_unit3_hemioct.js +0 -0
- package/{engine/graphics/micron/render/refinement → core/geom/3d/frustum}/array_normalize_plane.js +1 -1
- package/{engine/graphics/micron/render/refinement → core/geom/3d/frustum}/array_setFromProjectionMatrix.js +2 -2
- package/{engine/graphics/micron/util → core/geom/3d}/unit_hemioct.spec.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/MultiNode.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/SquareMatrix.js +2 -2
- package/{engine/graphics/micron/build → core}/graph/SquareMatrix.spec.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/WeightedEdge.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/build_face_graph_from_mesh.js +2 -2
- package/{engine/graphics/micron/build/clustering → core/graph}/cluster_mesh_metis.js +2 -6
- package/{engine/graphics/micron/build → core}/graph/coarsen_graph.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/coarsen_graph.spec.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/eigen/eigen.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/eigen/eigen.spec.js +1 -1
- package/{engine/graphics/micron/build/hierarchy → core/graph/eigen}/eigen_values_find_spectral_gap.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_adjacency_matrix.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_compute_disconnected_clusters.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_degree_matrix.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_k_means_cluster.js +5 -5
- package/{engine/graphics/micron/build → core}/graph/graph_laplacian_matrix.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/metis/metis.js +2 -2
- package/{engine/graphics/micron/build → core}/graph/metis/metis_options.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/mn_graph_collapse_weighted_edge.js +0 -0
- package/engine/Engine.d.ts +2 -0
- package/engine/EngineHarness.js +4 -4
- package/engine/ecs/transform/Transform.js +2 -1
- package/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +22 -37
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +155 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +68 -0
- package/engine/graphics/ecs/mesh-v2/prototypeShadedGeometry.js +31 -0
- package/engine/graphics/{micron → geometry}/aabb3_to_buffer_geometry.js +0 -0
- package/engine/graphics/{micron/build → geometry/buffered}/compute_buffer_geometry_byte_size.js +0 -0
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +1 -1
- package/engine/graphics/micron/build/clustering/build_clustering_2.js +2 -2
- package/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +1 -1
- package/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +3 -3
- package/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -72
- package/engine/graphics/micron/build/hierarchy/build_merge_graph.js +2 -2
- package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +3 -3
- package/engine/graphics/micron/build/hierarchy/merge_patches.js +6 -3
- package/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +1 -1
- package/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +1 -1
- package/engine/graphics/micron/build/hierarchy/patch_combine.js +2 -2
- package/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +2 -1
- package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
- package/engine/graphics/micron/render/refinement/RefinementSpec.js +1 -1
- package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
- package/engine/plugin/EnginePluginManager.d.ts +9 -0
- package/engine/reference/v2/Reference.d.ts +7 -0
- package/package.json +1 -1
- package/engine/graphics/micron/build/clustering/cluster_mesh_vertices.js +0 -3
package/core/bvh2/LeafNode.js
CHANGED
|
@@ -83,10 +83,15 @@ LeafNode.prototype.move = function (dx, dy, dz) {
|
|
|
83
83
|
LeafNode.prototype.resize = function (x0, y0, z0, x1, y1, z1) {
|
|
84
84
|
this.setBounds(x0, y0, z0, x1, y1, z1);
|
|
85
85
|
|
|
86
|
+
this.bubbleRefit();
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
LeafNode.prototype.bubbleRefit = function (){
|
|
90
|
+
|
|
86
91
|
if (this.parentNode !== null) {
|
|
87
92
|
this.parentNode.bubbleRefit();
|
|
88
93
|
}
|
|
89
|
-
}
|
|
94
|
+
}
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
97
|
*
|
package/core/bvh2/aabb3/AABB3.js
CHANGED
|
@@ -736,6 +736,23 @@ AABB3.prototype.writeToArray = function (result, offset) {
|
|
|
736
736
|
result[offset + 5] = this.z1;
|
|
737
737
|
};
|
|
738
738
|
|
|
739
|
+
/**
|
|
740
|
+
*
|
|
741
|
+
* @param {number[]|Float32Array|Float64Array} source
|
|
742
|
+
* @param {number} offset
|
|
743
|
+
*/
|
|
744
|
+
AABB3.prototype.readFromArray = function (source, offset) {
|
|
745
|
+
assert.isNonNegativeInteger(offset, 'offset');
|
|
746
|
+
|
|
747
|
+
this.x0 = source[offset];
|
|
748
|
+
this.y0 = source[offset + 1];
|
|
749
|
+
this.z0 = source[offset + 2];
|
|
750
|
+
|
|
751
|
+
this.x1 = source[offset + 3];
|
|
752
|
+
this.y1 = source[offset + 4];
|
|
753
|
+
this.z1 = source[offset + 5];
|
|
754
|
+
};
|
|
755
|
+
|
|
739
756
|
/**
|
|
740
757
|
* @param {THREE.Plane} plane
|
|
741
758
|
* @returns {int} 2,0,or -2; 2: above, -2 : below, 0 : intersects plane
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @returns Set<T>
|
|
4
|
+
* @param {Set<T>} a
|
|
5
|
+
* @param {Set<T>} b
|
|
6
|
+
*/
|
|
7
|
+
export function compute_set_difference(a, b) {
|
|
8
|
+
const result = new Set();
|
|
9
|
+
|
|
10
|
+
const a_array = Array.from(a);
|
|
11
|
+
const a_count = a_array.length;
|
|
12
|
+
for (let i = 0; i < a_count; i++) {
|
|
13
|
+
const t = a_array[i];
|
|
14
|
+
|
|
15
|
+
if (!b.has(t)) {
|
|
16
|
+
result.add(t);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const b_array = Array.from(b);
|
|
21
|
+
const b_count = b_array.length;
|
|
22
|
+
for (let i = 0; i < b_count; i++) {
|
|
23
|
+
const t = b_array[i];
|
|
24
|
+
|
|
25
|
+
if (!a.has(t)) {
|
|
26
|
+
result.add(t);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @returns Set<T>
|
|
4
|
+
* @param {Set<T>} a
|
|
5
|
+
* @param {Set<T>} b
|
|
6
|
+
*/
|
|
7
|
+
export function compute_set_intersection(a, b) {
|
|
8
|
+
const result = new Set();
|
|
9
|
+
|
|
10
|
+
const a_array = Array.from(a);
|
|
11
|
+
|
|
12
|
+
const n = a_array.length;
|
|
13
|
+
for (let i = 0; i < n; i++) {
|
|
14
|
+
const t = a_array[i];
|
|
15
|
+
|
|
16
|
+
if (b.has(t)) {
|
|
17
|
+
result.add(t);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
}
|
package/core/color/Color.js
CHANGED
package/core/color/ColorUtils.js
CHANGED
|
@@ -146,18 +146,21 @@ function int2rgb(value) {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
const rgbRegEx = /rgb\(([0-9]+),\s*([0-9]+),\s*([0-9]+)\)/;
|
|
150
|
+
const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\)/;
|
|
151
|
+
|
|
149
152
|
/**
|
|
150
153
|
*
|
|
151
154
|
* @param {string|number} c
|
|
152
155
|
* @returns {number[]} Numeric array, values are in Uint range
|
|
153
156
|
*/
|
|
154
157
|
export function parseColor(c) {
|
|
155
|
-
const rgbRegEx = /rgb\(([0-9]+),\s*([0-9]+),\s*([0-9]+)\)/;
|
|
156
|
-
const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\)/;
|
|
157
158
|
|
|
158
159
|
const result = [];
|
|
159
160
|
|
|
160
|
-
|
|
161
|
+
const type_of_code = typeof c;
|
|
162
|
+
|
|
163
|
+
if (type_of_code === "string") {
|
|
161
164
|
const cL = c.toLowerCase();
|
|
162
165
|
|
|
163
166
|
let match;
|
|
@@ -191,6 +194,12 @@ export function parseColor(c) {
|
|
|
191
194
|
} else {
|
|
192
195
|
throw new Error(`Failed to decode color string '${c}' `);
|
|
193
196
|
}
|
|
197
|
+
} else if(type_of_code === 'number'){
|
|
198
|
+
|
|
199
|
+
result[0] = c >> 16;
|
|
200
|
+
result[1] = (c >> 8) & 0xFF;
|
|
201
|
+
result[2] = (c) & 0xFF;
|
|
202
|
+
|
|
194
203
|
} else {
|
|
195
204
|
throw new Error(`Failed to decode color '${c}'`);
|
|
196
205
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]|Float32Array|Float64Array} result
|
|
4
|
+
* @param {{x:number,y:number,z:number}} min
|
|
5
|
+
* @param {{x:number,y:number,z:number}} max
|
|
6
|
+
*/
|
|
7
|
+
export function aabb3_from_min_max(result, min, max) {
|
|
8
|
+
result[0] = min.x;
|
|
9
|
+
result[1] = min.y;
|
|
10
|
+
result[2] = min.z;
|
|
11
|
+
|
|
12
|
+
result[3] = max.x;
|
|
13
|
+
result[4] = max.y;
|
|
14
|
+
result[5] = max.z;
|
|
15
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]|Float32Array} result
|
|
6
|
+
* @param {number[]|Float32Array|Float64Array} aabb_corners
|
|
7
|
+
* @param {number[]|Float32Array} projection_matrix
|
|
8
|
+
*/
|
|
9
|
+
export function aabb3_matrix4_project_by_corners(result, aabb_corners, projection_matrix) {
|
|
10
|
+
assert.greaterThanOrEqual(result.length, 6, 'result.length must >= 6');
|
|
11
|
+
assert.greaterThanOrEqual(aabb_corners.length, 24, 'aabb_corners.length must >= 24');
|
|
12
|
+
assert.greaterThanOrEqual(projection_matrix.length, 16, 'projection_matrix.length must >= 16');
|
|
13
|
+
|
|
14
|
+
// read matrix into local variables for speed
|
|
15
|
+
const a0 = projection_matrix[0];
|
|
16
|
+
const a1 = projection_matrix[1];
|
|
17
|
+
const a2 = projection_matrix[2];
|
|
18
|
+
const a3 = projection_matrix[3];
|
|
19
|
+
|
|
20
|
+
const b0 = projection_matrix[4];
|
|
21
|
+
const b1 = projection_matrix[5];
|
|
22
|
+
const b2 = projection_matrix[6];
|
|
23
|
+
const b3 = projection_matrix[7];
|
|
24
|
+
|
|
25
|
+
const c0 = projection_matrix[8];
|
|
26
|
+
const c1 = projection_matrix[9];
|
|
27
|
+
const c2 = projection_matrix[10];
|
|
28
|
+
const c3 = projection_matrix[11];
|
|
29
|
+
|
|
30
|
+
const d0 = projection_matrix[12];
|
|
31
|
+
const d1 = projection_matrix[13];
|
|
32
|
+
const d2 = projection_matrix[14];
|
|
33
|
+
const d3 = projection_matrix[15];
|
|
34
|
+
|
|
35
|
+
// initialize bounds
|
|
36
|
+
let x0 = Number.POSITIVE_INFINITY;
|
|
37
|
+
let y0 = Number.POSITIVE_INFINITY;
|
|
38
|
+
let z0 = Number.POSITIVE_INFINITY;
|
|
39
|
+
|
|
40
|
+
let x1 = Number.NEGATIVE_INFINITY;
|
|
41
|
+
let y1 = Number.NEGATIVE_INFINITY;
|
|
42
|
+
let z1 = Number.NEGATIVE_INFINITY;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < 24; i += 3) {
|
|
46
|
+
|
|
47
|
+
// read corner
|
|
48
|
+
const _x = aabb_corners[i];
|
|
49
|
+
const _y = aabb_corners[i + 1];
|
|
50
|
+
const _z = aabb_corners[i + 2];
|
|
51
|
+
|
|
52
|
+
// apply transform
|
|
53
|
+
const t_x = a0 * _x + b0 * _y + c0 * _z + d0;
|
|
54
|
+
const t_y = a1 * _x + b1 * _y + c1 * _z + d1;
|
|
55
|
+
const t_z = a2 * _x + b2 * _y + c2 * _z + d2;
|
|
56
|
+
const t_w = a3 * _x + b3 * _y + c3 * _z + d3;
|
|
57
|
+
|
|
58
|
+
// perspective divide and normalization (-1,1 space projected to -0.5,0.5)
|
|
59
|
+
const d = 1 / t_w;
|
|
60
|
+
|
|
61
|
+
// finally compute screen-space coordinates of the corner
|
|
62
|
+
const x = t_x * d;
|
|
63
|
+
const y = t_y * d;
|
|
64
|
+
const z = t_z * d;
|
|
65
|
+
|
|
66
|
+
if (x0 > x) {
|
|
67
|
+
x0 = x;
|
|
68
|
+
}
|
|
69
|
+
if (x1 < x) {
|
|
70
|
+
x1 = x;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (y0 > y) {
|
|
74
|
+
y0 = y;
|
|
75
|
+
}
|
|
76
|
+
if (y1 < y) {
|
|
77
|
+
y1 = y;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (z0 > z) {
|
|
81
|
+
z0 = z;
|
|
82
|
+
}
|
|
83
|
+
if (z1 < z) {
|
|
84
|
+
z1 = z;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
result[0] = x0;
|
|
90
|
+
result[1] = y0;
|
|
91
|
+
result[2] = z0;
|
|
92
|
+
|
|
93
|
+
result[3] = x1;
|
|
94
|
+
result[4] = y1;
|
|
95
|
+
result[5] = z1;
|
|
96
|
+
}
|
package/{engine/graphics/micron/render/v1 → core/geom/3d}/apply_mat4_transform_to_v3_array.js
RENAMED
|
File without changes
|
package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.js
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import Vector3 from "
|
|
5
|
-
import Quaternion, { quat3_createFromAxisAngle } from "
|
|
6
|
-
import { max2 } from "
|
|
4
|
+
import Vector3 from "../Vector3.js";
|
|
5
|
+
import Quaternion, { quat3_createFromAxisAngle } from "../Quaternion.js";
|
|
6
|
+
import { max2 } from "../../math/max2.js";
|
|
7
7
|
|
|
8
8
|
const tangent = new Vector3();
|
|
9
9
|
|
package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_sphere_of_2_spheres.js
RENAMED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { vec3 } from "gl-matrix";
|
|
5
|
-
import { Miniball } from "
|
|
6
|
-
import { PointSet } from "
|
|
7
|
-
import { max2 } from "
|
|
5
|
+
import { Miniball } from "../packing/miniball/Miniball.js";
|
|
6
|
+
import { PointSet } from "../packing/miniball/PointSet.js";
|
|
7
|
+
import { max2 } from "../../math/max2.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v3_length } from "
|
|
1
|
+
import { v3_length } from "../../Vector3.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -21,7 +21,7 @@ function array_set_plane_normalized(destination, destination_offset, x, y, z, w)
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Set frustum from projection matrix
|
|
25
25
|
* @param {number[]|Float32Array} frustum_planes
|
|
26
26
|
* @param {number[]} me
|
|
27
27
|
*/
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataType2TypedArrayConstructorMapping } from "
|
|
2
|
-
import { assert } from "
|
|
1
|
+
import { DataType2TypedArrayConstructorMapping } from "../collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
2
|
+
import { assert } from "../assert.js";
|
|
3
3
|
|
|
4
4
|
export class SquareMatrix {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SquareMatrix } from "./SquareMatrix.js";
|
|
2
|
-
import { DataType } from "
|
|
2
|
+
import { DataType } from "../collection/table/DataType.js";
|
|
3
3
|
|
|
4
4
|
test('set/get cell', () => {
|
|
5
5
|
const m = new SquareMatrix(2, DataType.Uint8);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Graph } from "
|
|
1
|
+
import { Graph } from "./v2/Graph.js";
|
|
2
2
|
import { MultiNode } from "./MultiNode.js";
|
|
3
|
-
import { compute_face_connection_weight } from "
|
|
3
|
+
import { compute_face_connection_weight } from "../../engine/graphics/micron/build/clustering/compute_face_connection_weight.js";
|
|
4
4
|
import { WeightedEdge } from "./WeightedEdge.js";
|
|
5
5
|
import { graph_compute_disconnected_clusters } from "./graph_compute_disconnected_clusters.js";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Metis } from "
|
|
2
|
-
import { metis_options } from "
|
|
1
|
+
import { Metis } from "./metis/metis.js";
|
|
2
|
+
import { metis_options } from "./metis/metis_options.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* How many times to retry partitioning before giving up
|
|
@@ -7,10 +7,6 @@ import { metis_options } from "../graph/metis/metis_options.js";
|
|
|
7
7
|
*/
|
|
8
8
|
const MAX_STEPS = 50;
|
|
9
9
|
|
|
10
|
-
function cluster_mesh_metis_detailed(mesh, patch_size) {
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
*
|
|
16
12
|
* @param {Uint32Array} result
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import FastBinaryHeap from "
|
|
1
|
+
import FastBinaryHeap from "../../engine/navigation/grid/FastBinaryHeap.js";
|
|
2
2
|
import { mn_graph_collapse_weighted_edge } from "./mn_graph_collapse_weighted_edge.js";
|
|
3
3
|
import { WeightedEdge } from "./WeightedEdge.js";
|
|
4
4
|
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SquareMatrix } from "../SquareMatrix.js";
|
|
2
|
-
import { DataType } from "
|
|
2
|
+
import { DataType } from "../../collection/table/DataType.js";
|
|
3
3
|
import { matrix_eigenvalues_in_place } from "./eigen.js";
|
|
4
4
|
|
|
5
5
|
function roughly_equal_array_vectors(actual, expected) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//
|
|
2
|
-
import { seededRandom } from "
|
|
3
|
-
import { randomIntegerBetween } from "
|
|
2
|
+
import { seededRandom } from "../math/random/seededRandom.js";
|
|
3
|
+
import { randomIntegerBetween } from "../math/MathUtils.js";
|
|
4
4
|
import { SquareMatrix } from "./SquareMatrix.js";
|
|
5
|
-
import { DataType } from "
|
|
6
|
-
import { BitSet } from "
|
|
7
|
-
import FastBinaryHeap from "
|
|
5
|
+
import { DataType } from "../collection/table/DataType.js";
|
|
6
|
+
import { BitSet } from "../binary/BitSet.js";
|
|
7
|
+
import FastBinaryHeap from "../../engine/navigation/grid/FastBinaryHeap.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @template N
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { graph_degree_matrix } from "./graph_degree_matrix.js";
|
|
2
2
|
import { SquareMatrix } from "./SquareMatrix.js";
|
|
3
|
-
import { DataType } from "
|
|
3
|
+
import { DataType } from "../collection/table/DataType.js";
|
|
4
4
|
import { graph_adjacency_matrix } from "./graph_adjacency_matrix.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import WorkerBuilder from "
|
|
2
|
-
import { OnDemandWorkerManager } from "
|
|
1
|
+
import WorkerBuilder from "../../process/worker/WorkerBuilder.js";
|
|
2
|
+
import { OnDemandWorkerManager } from "../../process/worker/OnDemandWorkerManager.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export class Metis {
|
|
File without changes
|
|
File without changes
|
package/engine/Engine.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {AssetManager} from "./asset/AssetManager";
|
|
|
8
8
|
import {EntityManager} from "./ecs/EntityManager";
|
|
9
9
|
import View from "../view/View";
|
|
10
10
|
import Ticker from "./simulation/Ticker";
|
|
11
|
+
import {EnginePluginManager} from "./plugin/EnginePluginManager";
|
|
11
12
|
|
|
12
13
|
export interface IEngineInitializationOptions {
|
|
13
14
|
entityManager?: EntityManager
|
|
@@ -25,6 +26,7 @@ export default class Engine {
|
|
|
25
26
|
public readonly devices: { keyboard: KeyboardDevice, pointer: PointerDevice }
|
|
26
27
|
public readonly assetManager: AssetManager
|
|
27
28
|
public readonly ticker: Ticker
|
|
29
|
+
public readonly plugins: EnginePluginManager
|
|
28
30
|
|
|
29
31
|
public start(): Promise<any>
|
|
30
32
|
|
package/engine/EngineHarness.js
CHANGED
|
@@ -203,10 +203,10 @@ export class EngineHarness {
|
|
|
203
203
|
*
|
|
204
204
|
* @param {Engine} engine
|
|
205
205
|
* @param {Vector3} [focus]
|
|
206
|
-
* @param heightMap
|
|
207
|
-
* @param heightRange
|
|
208
|
-
* @param pitch
|
|
209
|
-
* @param yaw
|
|
206
|
+
* @param [heightMap]
|
|
207
|
+
* @param [heightRange]
|
|
208
|
+
* @param [pitch]
|
|
209
|
+
* @param [yaw]
|
|
210
210
|
* @param {number} [distance]
|
|
211
211
|
* @param {Vector2} [terrainSize]
|
|
212
212
|
* @param {number} [terrainResolution]
|
|
@@ -6,6 +6,7 @@ import Vector3 from "../../../core/geom/Vector3.js";
|
|
|
6
6
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
7
7
|
import { Matrix4 } from "../../../core/geom/Matrix4.js";
|
|
8
8
|
import { Quaternion as ThreeQuaternion } from "three";
|
|
9
|
+
import { composeMatrix4 } from "../../graphics/util/composeMatrix4.js";
|
|
9
10
|
|
|
10
11
|
const delta = new Vector3();
|
|
11
12
|
|
|
@@ -175,7 +176,7 @@ export class Transform {
|
|
|
175
176
|
* @param {Matrix4} matrix
|
|
176
177
|
*/
|
|
177
178
|
toThreeMatrix(matrix) {
|
|
178
|
-
matrix
|
|
179
|
+
composeMatrix4(matrix, this.position, this.rotation, this.scale);
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
2
|
-
import { min2 } from "../../../../core/math/min2.js";
|
|
3
|
-
import { composeMatrix4 } from "../../util/composeMatrix4.js";
|
|
4
1
|
import { Matrix4 as ThreeMatrix4 } from "three";
|
|
2
|
+
import { aabb3_matrix4_project_by_corners } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js";
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
const matrix4 = new ThreeMatrix4();
|
|
@@ -13,6 +11,12 @@ const matrix4 = new ThreeMatrix4();
|
|
|
13
11
|
*/
|
|
14
12
|
const corners = new Float64Array(24);
|
|
15
13
|
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {Float32Array}
|
|
17
|
+
*/
|
|
18
|
+
const scratch_aabb = new Float32Array(6);
|
|
19
|
+
|
|
16
20
|
/**
|
|
17
21
|
*
|
|
18
22
|
* @param {LeafNode} bvh
|
|
@@ -20,20 +24,7 @@ const corners = new Float64Array(24);
|
|
|
20
24
|
* @param {Transform} transform
|
|
21
25
|
*/
|
|
22
26
|
export function updateNodeByTransformAndBBB(bvh, boundingBox, transform) {
|
|
23
|
-
|
|
24
|
-
const scale = transform.scale;
|
|
25
|
-
const rotation = transform.rotation;
|
|
26
|
-
|
|
27
|
-
composeMatrix4(matrix4, position, rotation, scale);
|
|
28
|
-
|
|
29
|
-
let x0 = Infinity,
|
|
30
|
-
y0 = Infinity,
|
|
31
|
-
z0 = Infinity,
|
|
32
|
-
x1 = -Infinity,
|
|
33
|
-
y1 = -Infinity,
|
|
34
|
-
z1 = -Infinity;
|
|
35
|
-
|
|
36
|
-
boundingBox.getCorners(corners);
|
|
27
|
+
transform.toThreeMatrix(matrix4);
|
|
37
28
|
|
|
38
29
|
/**
|
|
39
30
|
* Shortcut elements for faster access
|
|
@@ -41,29 +32,23 @@ export function updateNodeByTransformAndBBB(bvh, boundingBox, transform) {
|
|
|
41
32
|
*/
|
|
42
33
|
const e = matrix4.elements;
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const y = corners[j + 1];
|
|
47
|
-
const z = corners[j + 2];
|
|
48
|
-
|
|
49
|
-
// perform matrix transform on corners
|
|
50
|
-
|
|
51
|
-
const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
|
|
35
|
+
updateNodeByMatrix4AndBBB(bvh, boundingBox, e);
|
|
36
|
+
}
|
|
52
37
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {LeafNode} bvh
|
|
41
|
+
* @param {AABB3} boundingBox
|
|
42
|
+
* @param {number[]} matrix4
|
|
43
|
+
*/
|
|
44
|
+
export function updateNodeByMatrix4AndBBB(bvh, boundingBox, matrix4) {
|
|
45
|
+
boundingBox.getCorners(corners);
|
|
56
46
|
|
|
57
|
-
// update AABB bounds
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
y0 = min2(y0, _y);
|
|
61
|
-
z0 = min2(z0, _z);
|
|
48
|
+
aabb3_matrix4_project_by_corners(scratch_aabb, corners, matrix4);
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
y1 = max2(y1, _y);
|
|
65
|
-
z1 = max2(z1, _z);
|
|
66
|
-
}
|
|
50
|
+
bvh.readFromArray(scratch_aabb, 0);
|
|
67
51
|
|
|
68
|
-
bvh.
|
|
52
|
+
bvh.bubbleRefit();
|
|
69
53
|
}
|
|
54
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Mesh, Quaternion } from "three";
|
|
2
|
+
import { updateNodeByMatrix4AndBBB } from "../mesh/updateNodeByTransformAndBBB.js";
|
|
3
|
+
import { LeafNode } from "../../../../core/bvh2/LeafNode.js";
|
|
4
|
+
import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
|
|
5
|
+
|
|
6
|
+
const _q = new Quaternion();
|
|
7
|
+
const _aabb3 = new AABB3();
|
|
8
|
+
|
|
9
|
+
export class ShadedGeometry {
|
|
10
|
+
constructor() {
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @type {THREE.BufferGeometry|null}
|
|
14
|
+
*/
|
|
15
|
+
this.geometry = null;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @type {THREE.Material|null}
|
|
19
|
+
*/
|
|
20
|
+
this.material = null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {THREE.Object3D|null}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
this.__cached_object = null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {LeafNode<ShadedGeometry>}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this.__bvh_leaf = new LeafNode(this, 0, 0, 0, 0, 0, 0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get bvh() {
|
|
38
|
+
return this.__bvh_leaf;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {THREE.BufferGeometry} geometry
|
|
44
|
+
* @param {THREE.Material} material
|
|
45
|
+
*/
|
|
46
|
+
from(geometry, material) {
|
|
47
|
+
this.geometry = geometry;
|
|
48
|
+
this.material = material;
|
|
49
|
+
|
|
50
|
+
// ensure that geometry has a bounding box
|
|
51
|
+
if (geometry.boundingBox === null) {
|
|
52
|
+
geometry.computeBoundingBox();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.__cached_object === null) {
|
|
56
|
+
this.__cached_object = new Mesh(geometry, material);
|
|
57
|
+
} else {
|
|
58
|
+
this.__cached_object.material = material;
|
|
59
|
+
this.__cached_object.geometry = geometry;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param geometry
|
|
66
|
+
* @param material
|
|
67
|
+
* @return {ShadedGeometry}
|
|
68
|
+
*/
|
|
69
|
+
static from(geometry, material) {
|
|
70
|
+
const r = new ShadedGeometry();
|
|
71
|
+
|
|
72
|
+
r.from(geometry, material);
|
|
73
|
+
|
|
74
|
+
return r;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
updateTransform() {
|
|
78
|
+
// update matrix
|
|
79
|
+
this.__cached_object.updateMatrix();
|
|
80
|
+
|
|
81
|
+
// update bounds
|
|
82
|
+
|
|
83
|
+
const gbb = this.geometry.boundingBox;
|
|
84
|
+
|
|
85
|
+
_aabb3.setBounds(
|
|
86
|
+
gbb.min.x,
|
|
87
|
+
gbb.min.y,
|
|
88
|
+
gbb.min.z,
|
|
89
|
+
gbb.max.x,
|
|
90
|
+
gbb.max.y,
|
|
91
|
+
gbb.max.z
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
updateNodeByMatrix4AndBBB(this.__bvh_leaf, _aabb3, this.__cached_object.matrix.elements);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {number} x
|
|
100
|
+
* @param {number} y
|
|
101
|
+
* @param {number} z
|
|
102
|
+
*/
|
|
103
|
+
setPositionByComponents(x, y, z) {
|
|
104
|
+
|
|
105
|
+
this.__cached_object.position.set(x, y, z);
|
|
106
|
+
|
|
107
|
+
this.updateTransform();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param {number} x
|
|
113
|
+
* @param {number} y
|
|
114
|
+
* @param {number} z
|
|
115
|
+
* @param {number} w
|
|
116
|
+
*/
|
|
117
|
+
setRotationByComponents(x, y, z, w) {
|
|
118
|
+
|
|
119
|
+
_q.set(x, y, z, w);
|
|
120
|
+
|
|
121
|
+
this.__cached_object.rotation.setFromQuaternion(_q);
|
|
122
|
+
|
|
123
|
+
this.updateTransform();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @param {number} x
|
|
129
|
+
* @param {number} y
|
|
130
|
+
* @param {number} z
|
|
131
|
+
*/
|
|
132
|
+
setScaleByComponents(x, y, z) {
|
|
133
|
+
this.__cached_object.scale.set(x, y, z);
|
|
134
|
+
|
|
135
|
+
this.updateTransform();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @param {Transform} t
|
|
141
|
+
*/
|
|
142
|
+
applyTransform(t) {
|
|
143
|
+
// TODO this can be optimized quite a lot
|
|
144
|
+
const position = t.position;
|
|
145
|
+
this.setPositionByComponents(position.x, position.y, position.z);
|
|
146
|
+
|
|
147
|
+
const rotation = t.rotation;
|
|
148
|
+
this.setRotationByComponents(rotation.x, rotation.y, rotation.z, rotation.w);
|
|
149
|
+
|
|
150
|
+
const scale = t.scale;
|
|
151
|
+
this.setScaleByComponents(scale.x, scale.y, scale.z);
|
|
152
|
+
|
|
153
|
+
this.updateTransform();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ShadedGeometry } from "./ShadedGeometry.js";
|
|
2
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
3
|
+
import { System } from "../../../ecs/System.js";
|
|
4
|
+
|
|
5
|
+
export class ShadedGeometrySystem extends System {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {Engine} engine
|
|
9
|
+
*/
|
|
10
|
+
constructor(engine) {
|
|
11
|
+
super();
|
|
12
|
+
this.dependencies = [ShadedGeometry, Transform];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*s
|
|
16
|
+
* @type {Engine}
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
this.__engine = engine;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @type {RenderLayer|null}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
this.__render_layer = null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async startup(entityManager, readyCallback, errorCallback) {
|
|
30
|
+
|
|
31
|
+
const engine = this.__engine;
|
|
32
|
+
|
|
33
|
+
this.__render_layer = engine.graphics.layers.create('shaded-geometry');
|
|
34
|
+
this.__render_layer.extractRenderable = (sg) => sg.__cached_object;
|
|
35
|
+
|
|
36
|
+
readyCallback();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {ShadedGeometry} sg
|
|
42
|
+
* @param {Transform} t
|
|
43
|
+
* @param {number} entity
|
|
44
|
+
*/
|
|
45
|
+
link(sg, t, entity) {
|
|
46
|
+
t.position.onChanged.add(sg.setPositionByComponents, sg);
|
|
47
|
+
t.rotation.onChanged.add(sg.setRotationByComponents, sg);
|
|
48
|
+
t.scale.onChanged.add(sg.setScaleByComponents, sg);
|
|
49
|
+
|
|
50
|
+
sg.applyTransform(t);
|
|
51
|
+
|
|
52
|
+
this.__render_layer.bvh.insertNode(sg.bvh);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {ShadedGeometry} sg
|
|
58
|
+
* @param {Transform} t
|
|
59
|
+
* @param {number} entity
|
|
60
|
+
*/
|
|
61
|
+
unlink(sg, t, entity) {
|
|
62
|
+
t.position.onChanged.remove(sg.setPositionByComponents, sg);
|
|
63
|
+
t.rotation.onChanged.remove(sg.setRotationByComponents, sg);
|
|
64
|
+
t.scale.onChanged.remove(sg.setScaleByComponents, sg);
|
|
65
|
+
|
|
66
|
+
sg.bvh.disconnect();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EngineHarness } from "../../../EngineHarness.js";
|
|
2
|
+
import { ShadedGeometrySystem } from "./ShadedGeometrySystem.js";
|
|
3
|
+
import EntityBuilder from "../../../ecs/EntityBuilder.js";
|
|
4
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
5
|
+
import { ShadedGeometry } from "./ShadedGeometry.js";
|
|
6
|
+
import { BoxBufferGeometry, MeshBasicMaterial } from "three";
|
|
7
|
+
|
|
8
|
+
const eh = new EngineHarness();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {Engine} engine
|
|
13
|
+
*/
|
|
14
|
+
async function main(engine) {
|
|
15
|
+
|
|
16
|
+
await engine.entityManager.addSystem(new ShadedGeometrySystem(engine));
|
|
17
|
+
|
|
18
|
+
EngineHarness.buildBasics({ engine })
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const ecd = engine.entityManager.dataset;
|
|
22
|
+
|
|
23
|
+
new EntityBuilder()
|
|
24
|
+
.add(new Transform())
|
|
25
|
+
.add(ShadedGeometry.from(new BoxBufferGeometry(), new MeshBasicMaterial({
|
|
26
|
+
color: 0xFFFFFF
|
|
27
|
+
})))
|
|
28
|
+
.build(ecd);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
eh.initialize().then(main);
|
|
File without changes
|
package/engine/graphics/{micron/build → geometry/buffered}/compute_buffer_geometry_byte_size.js
RENAMED
|
File without changes
|
|
@@ -11,7 +11,7 @@ import { build_graph_info } from "./debug/build_graph_info.js";
|
|
|
11
11
|
import { expandConnectivityByLocality } from "../../../../core/geom/3d/topology/expandConnectivityByLocality.js";
|
|
12
12
|
import { build_geometry_info } from "./build_geometry_info.js";
|
|
13
13
|
import { build_leaf_patches_metis } from "./clustering/build_leaf_patches_metis.js";
|
|
14
|
-
import { compute_buffer_geometry_byte_size } from "
|
|
14
|
+
import { compute_buffer_geometry_byte_size } from "../../geometry/buffered/compute_buffer_geometry_byte_size.js";
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FastBinaryHeap from "../../../../navigation/grid/FastBinaryHeap.js";
|
|
2
|
-
import { mn_graph_collapse_weighted_edge } from "
|
|
3
|
-
import { build_face_graph_from_mesh } from "
|
|
2
|
+
import { mn_graph_collapse_weighted_edge } from "../../../../../core/graph/mn_graph_collapse_weighted_edge.js";
|
|
3
|
+
import { build_face_graph_from_mesh } from "../../../../../core/graph/build_face_graph_from_mesh.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cluster_mesh_metis } from "
|
|
1
|
+
import { cluster_mesh_metis } from "../../../../../core/graph/cluster_mesh_metis.js";
|
|
2
2
|
import { MICRON_PATCH_SIZE_MAX } from "../MICRON_PATCH_SIZE_MAX.js";
|
|
3
3
|
import { PatchRepresentation } from "../PatchRepresentation.js";
|
|
4
4
|
import { TopoMesh } from "../../../../../core/geom/3d/topology/TopoMesh.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Graph } from "../../../../../core/graph/v2/Graph.js";
|
|
2
|
-
import { MultiNode } from "
|
|
2
|
+
import { MultiNode } from "../../../../../core/graph/MultiNode.js";
|
|
3
3
|
import { merge_patches } from "./merge_patches.js";
|
|
4
|
-
import { coarsen_graph } from "
|
|
4
|
+
import { coarsen_graph } from "../../../../../core/graph/coarsen_graph.js";
|
|
5
5
|
import { build_merge_graph } from "./build_merge_graph.js";
|
|
6
6
|
import { assign_patch_neighbours_from_topology } from "../clustering/assign_patch_neighbours_from_topology.js";
|
|
7
7
|
import { assert } from "../../../../../core/assert.js";
|
|
8
|
-
import { graph_create_off_mesh_links } from "
|
|
8
|
+
import { graph_create_off_mesh_links } from "../../../../../core/graph/build_face_graph_from_mesh.js";
|
|
9
9
|
import { build_vertex_quadratics } from "../../../../../core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -2,78 +2,6 @@ import { simplifyTopoMesh } from "../../../../../core/geom/3d/topology/simplify/
|
|
|
2
2
|
import { MICRON_PATCH_SIZE_MAX } from "../MICRON_PATCH_SIZE_MAX.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @template T
|
|
7
|
-
* @returns Set<T>
|
|
8
|
-
* @param {Set<T>} a
|
|
9
|
-
* @param {Set<T>} b
|
|
10
|
-
*/
|
|
11
|
-
export function compute_set_intersection(a, b) {
|
|
12
|
-
const result = new Set();
|
|
13
|
-
|
|
14
|
-
const a_array = Array.from(a);
|
|
15
|
-
|
|
16
|
-
const n = a_array.length;
|
|
17
|
-
for (let i = 0; i < n; i++) {
|
|
18
|
-
const t = a_array[i];
|
|
19
|
-
|
|
20
|
-
if (b.has(t)) {
|
|
21
|
-
result.add(t);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @template T
|
|
30
|
-
* @returns Set<T>
|
|
31
|
-
* @param {Set<T>} a
|
|
32
|
-
* @param {Set<T>} b
|
|
33
|
-
*/
|
|
34
|
-
export function compute_set_difference(a, b) {
|
|
35
|
-
const result = new Set();
|
|
36
|
-
|
|
37
|
-
const a_array = Array.from(a);
|
|
38
|
-
const a_count = a_array.length;
|
|
39
|
-
for (let i = 0; i < a_count; i++) {
|
|
40
|
-
const t = a_array[i];
|
|
41
|
-
|
|
42
|
-
if (!b.has(t)) {
|
|
43
|
-
result.add(t);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const b_array = Array.from(b);
|
|
48
|
-
const b_count = b_array.length;
|
|
49
|
-
for (let i = 0; i < b_count; i++) {
|
|
50
|
-
const t = b_array[i];
|
|
51
|
-
|
|
52
|
-
if (!a.has(t)) {
|
|
53
|
-
result.add(t);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @template T
|
|
63
|
-
* @param {Set<T>} a
|
|
64
|
-
* @param {Set<T>} b
|
|
65
|
-
*/
|
|
66
|
-
export function set_remove(a, b) {
|
|
67
|
-
const bs = Array.from(b);
|
|
68
|
-
|
|
69
|
-
const n = bs.length;
|
|
70
|
-
for (let i = 0; i < n; i++) {
|
|
71
|
-
const t = bs[i];
|
|
72
|
-
|
|
73
|
-
a.delete(t);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
5
|
/**
|
|
78
6
|
*
|
|
79
7
|
* @param {Set<number>} result
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Graph } from "../../../../../core/graph/v2/Graph.js";
|
|
2
|
-
import { MultiNode } from "
|
|
2
|
+
import { MultiNode } from "../../../../../core/graph/MultiNode.js";
|
|
3
3
|
import { computePatchMergeScore } from "./computePatchMergeScore.js";
|
|
4
|
-
import { WeightedEdge } from "
|
|
4
|
+
import { WeightedEdge } from "../../../../../core/graph/WeightedEdge.js";
|
|
5
5
|
import { assert } from "../../../../../core/assert.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConicRay } from "../../../../../core/geom/ConicRay.js";
|
|
2
|
-
import { compute_bounding_cone_of_2_cones } from "
|
|
2
|
+
import { compute_bounding_cone_of_2_cones } from "../../../../../core/geom/3d/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 "
|
|
4
|
+
import { compute_bounding_sphere_of_2_spheres } from "../../../../../core/geom/3d/compute_bounding_sphere_of_2_spheres.js";
|
|
5
5
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
6
|
import { min2 } from "../../../../../core/math/min2.js";
|
|
7
7
|
|
|
@@ -58,7 +58,7 @@ const pi_sqr = 9.86960440109;
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
*
|
|
61
|
-
* @param {number} r
|
|
61
|
+
* @param {number} r radius
|
|
62
62
|
* @return {number}
|
|
63
63
|
*/
|
|
64
64
|
function compute_sphere_volume(r) {
|
|
@@ -9,12 +9,15 @@ import { collapse_edges, extract_edge_cost } from "../../../../../core/geom/3d/t
|
|
|
9
9
|
import { build_edge_collapse_candidates } from "../../../../../core/geom/3d/topology/simplify/build_edge_collapse_candidates.js";
|
|
10
10
|
import { collapse_all_degenerate_edges } from "../../../../../core/geom/3d/topology/simplify/collapse_all_degenerate_edges.js";
|
|
11
11
|
import { deep_copy_vertex_quadratics } from "../../../../../core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js";
|
|
12
|
-
import { SquareMatrix } from "
|
|
12
|
+
import { SquareMatrix } from "../../../../../core/graph/SquareMatrix.js";
|
|
13
13
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
14
|
-
import { matrix_eigenvalues_in_place } from "
|
|
14
|
+
import { matrix_eigenvalues_in_place } from "../../../../../core/graph/eigen/eigen.js";
|
|
15
15
|
import { min2 } from "../../../../../core/math/min2.js";
|
|
16
16
|
import { PatchRepresentation } from "../PatchRepresentation.js";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
build_face_graph_from_mesh,
|
|
19
|
+
graph_create_off_mesh_links
|
|
20
|
+
} from "../../../../../core/graph/build_face_graph_from_mesh.js";
|
|
18
21
|
import { optimize_graph_partitioning_balance_detailed } from "./optimize_graph_partitioning_balance.js";
|
|
19
22
|
import { patch_build_parent } from "./patch_combine.js";
|
|
20
23
|
import { array_copy } from "../../../../../core/collection/array/copyArray.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { graph_k_means_cluster_detailed } from "
|
|
1
|
+
import { graph_k_means_cluster_detailed } from "../../../../../core/graph/graph_k_means_cluster.js";
|
|
2
2
|
import { array_remove_first } from "../../../../../core/collection/array/array_remove_first.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -4,8 +4,8 @@ import { array_copy_unique } from "../../../../../core/collection/array/array_co
|
|
|
4
4
|
import { array_remove_first } from "../../../../../core/collection/array/array_remove_first.js";
|
|
5
5
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
6
|
import { array_push_if_unique } from "../../../../../core/collection/array/array_push_if_unique.js";
|
|
7
|
-
import { compute_bounding_sphere_of_2_spheres } from "
|
|
8
|
-
import { compute_bounding_cone_of_2_cones } from "
|
|
7
|
+
import { compute_bounding_sphere_of_2_spheres } from "../../../../../core/geom/3d/compute_bounding_sphere_of_2_spheres.js";
|
|
8
|
+
import { compute_bounding_cone_of_2_cones } from "../../../../../core/geom/3d/compute_bounding_cone_of_2_cones.js";
|
|
9
9
|
import { ConicRay } from "../../../../../core/geom/ConicRay.js";
|
|
10
10
|
import { passThrough } from "../../../../../core/function/Functions.js";
|
|
11
11
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { array_push_if_unique } from "../../../../../core/collection/array/array_push_if_unique.js";
|
|
2
2
|
import FastBinaryHeap from "../../../../navigation/grid/FastBinaryHeap.js";
|
|
3
3
|
import { build_vertex_quadratics } from "../../../../../core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js";
|
|
4
|
-
import {
|
|
4
|
+
import { compute_set_of_border_vertex_indices } from "./build_intermediate_patch_topology.js";
|
|
5
5
|
import { compute_patches_shared_vertices } from "./compute_patches_shared_vertices.js";
|
|
6
6
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
7
7
|
import { MICRON_PATCH_SIZE_MAX } from "../MICRON_PATCH_SIZE_MAX.js";
|
|
8
8
|
import { collapse_edges, extract_edge_cost } from "../../../../../core/geom/3d/topology/simplify/simplifyTopoMesh.js";
|
|
9
9
|
import { build_edge_collapse_candidates } from "../../../../../core/geom/3d/topology/simplify/build_edge_collapse_candidates.js";
|
|
10
10
|
import { collapse_all_degenerate_edges } from "../../../../../core/geom/3d/topology/simplify/collapse_all_degenerate_edges.js";
|
|
11
|
+
import { compute_set_intersection } from "../../../../../core/collection/set/compute_set_intersection.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Cluster must share at least this many vertices for the vertex boundary constraint to be relaxed and allow them to be made dependent on each other
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
2
2
|
import { mat4 } from "gl-matrix";
|
|
3
|
-
import { array_setFromProjectionMatrix } from "
|
|
3
|
+
import { array_setFromProjectionMatrix } from "../../../../../core/geom/3d/frustum/array_setFromProjectionMatrix.js";
|
|
4
4
|
|
|
5
5
|
export class RefinementSpec {
|
|
6
6
|
constructor() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PatchCacheKey } from "../PatchCacheKey.js";
|
|
2
|
-
import { apply_mat4_transform_to_v3_array } from "
|
|
2
|
+
import { apply_mat4_transform_to_v3_array } from "../../../../../core/geom/3d/apply_mat4_transform_to_v3_array.js";
|
|
3
3
|
import { Cache } from "../../../../../core/cache/Cache.js";
|
|
4
4
|
import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
|
|
5
5
|
import { invokeObjectEquals } from "../../../../../core/model/object/invokeObjectEquals.js";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"productName": "Meep",
|
|
5
5
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
6
6
|
"author": "Alexander Goldring",
|
|
7
|
-
"version": "2.33.
|
|
7
|
+
"version": "2.33.8",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"fast-levenshtein": "2.0.6",
|
|
10
10
|
"opentype.js": "1.3.3",
|