@woosh/meep-engine 2.48.20 → 2.48.22
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/package.json +1 -1
- package/src/{engine/graphics/micron/build/clustering → core/geom/3d/topology/util}/compute_face_connection_weight.js +40 -35
- package/src/core/graph/build_face_graph_from_mesh.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +0 -3
- package/src/engine/graphics/micron/MICRON_GEOMETRY_FIELD.js +0 -1
- package/src/engine/graphics/micron/MICRON_URI_FIELD.js +0 -1
- package/src/engine/graphics/micron/build/MICRON_PATCH_SIZE_MAX.js +0 -5
- package/src/engine/graphics/micron/build/PatchRepresentation.js +0 -424
- package/src/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +0 -311
- package/src/engine/graphics/micron/build/build_geometry_info.js +0 -21
- package/src/engine/graphics/micron/build/clustering/assignInitialPatchNeighbours.js +0 -63
- package/src/engine/graphics/micron/build/clustering/assign_patch_neighbours_from_topology.js +0 -46
- package/src/engine/graphics/micron/build/clustering/build_clustering_2.js +0 -37
- package/src/engine/graphics/micron/build/clustering/build_leaf_patches.js +0 -326
- package/src/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +0 -76
- package/src/engine/graphics/micron/build/clustering/computeBorderLengthChange.js +0 -59
- package/src/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +0 -57
- package/src/engine/graphics/micron/build/clustering/computeOpenFaceFreedom.js +0 -35
- package/src/engine/graphics/micron/build/clustering/populateOpenFaceNeighboursForPatch.js +0 -56
- package/src/engine/graphics/micron/build/clustering/validate_leaf_patch_connectivity.js +0 -44
- package/src/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +0 -24
- package/src/engine/graphics/micron/build/compute_vertex_remap_cost.js +0 -29
- package/src/engine/graphics/micron/build/debug/build_clustering_info.js +0 -58
- package/src/engine/graphics/micron/build/debug/build_graph_info.js +0 -59
- package/src/engine/graphics/micron/build/fill_patch_geometry_data.js +0 -270
- package/src/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +0 -196
- package/src/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -162
- package/src/engine/graphics/micron/build/hierarchy/build_merge_graph.js +0 -89
- package/src/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +0 -146
- package/src/engine/graphics/micron/build/hierarchy/compute_patches_shared_vertex_count.js +0 -32
- package/src/engine/graphics/micron/build/hierarchy/compute_patches_shared_vertices.js +0 -34
- package/src/engine/graphics/micron/build/hierarchy/merge_patches.js +0 -581
- package/src/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +0 -53
- package/src/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +0 -515
- package/src/engine/graphics/micron/build/hierarchy/patch_combine.js +0 -180
- package/src/engine/graphics/micron/build/hierarchy/patch_fill_holes_by_uncollapse.js +0 -60
- package/src/engine/graphics/micron/build/hierarchy/patch_stitch_parent_border.js +0 -320
- package/src/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +0 -547
- package/src/engine/graphics/micron/build/hierarchy/qvdr_build_tree.js +0 -140
- package/src/engine/graphics/micron/buildPatchwork.js +0 -68
- package/src/engine/graphics/micron/convert_three_object_to_micron.js +0 -179
- package/src/engine/graphics/micron/debug/VirtualGeometryStats.js +0 -42
- package/src/engine/graphics/micron/format/MICRON_GEOMETRY_PROPERTY_NAME.js +0 -1
- package/src/engine/graphics/micron/format/MicronGeometry.d.ts +0 -21
- package/src/engine/graphics/micron/format/MicronGeometry.js +0 -334
- package/src/engine/graphics/micron/format/MicronGeometryPatch.d.ts +0 -3
- package/src/engine/graphics/micron/format/MicronGeometryPatch.js +0 -205
- package/src/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +0 -50
- package/src/engine/graphics/micron/format/ThreeMicronMesh.d.ts +0 -10
- package/src/engine/graphics/micron/format/ThreeMicronMesh.js +0 -45
- package/src/engine/graphics/micron/format/VirtualGeometry.js +0 -158
- package/src/engine/graphics/micron/format/micron_build_proxy_geometry.js +0 -205
- package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +0 -123
- package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.spec.js +0 -63
- package/src/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.js +0 -83
- package/src/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.spec.js +0 -51
- package/src/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +0 -25
- package/src/engine/graphics/micron/format/serialization/deserialize_patch.js +0 -106
- package/src/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +0 -18
- package/src/engine/graphics/micron/format/serialization/serialize_patch.js +0 -84
- package/src/engine/graphics/micron/format/validate_patch_bounds.js +0 -69
- package/src/engine/graphics/micron/plugin/GLTFAssetTransformer.js +0 -265
- package/src/engine/graphics/micron/plugin/GLTF_MICRON_ID_FIELD.js +0 -5
- package/src/engine/graphics/micron/plugin/MicronRenderPlugin.d.ts +0 -8
- package/src/engine/graphics/micron/plugin/MicronRenderPlugin.js +0 -150
- package/src/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +0 -176
- package/src/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +0 -216
- package/src/engine/graphics/micron/prototypeMicronProxyBuild.js +0 -227
- package/src/engine/graphics/micron/prototypeVirtualGeometry.js +0 -911
- package/src/engine/graphics/micron/render/PatchCacheKey.js +0 -79
- package/src/engine/graphics/micron/render/VIRTUAL_MESH_FLAG.d.ts +0 -1
- package/src/engine/graphics/micron/render/VIRTUAL_MESH_FLAG.js +0 -1
- package/src/engine/graphics/micron/render/VirtualGeometryBuilder.js +0 -207
- package/src/engine/graphics/micron/render/approximateTriangleArea.js +0 -25
- package/src/engine/graphics/micron/render/culling/PatchCullingSystem.js +0 -129
- package/src/engine/graphics/micron/render/instanced/PatchDataTextures.js +0 -329
- package/src/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -175
- package/src/engine/graphics/micron/render/instanced/shader/constants.js +0 -3
- package/src/engine/graphics/micron/render/instanced/shader/gen_micron_vertex_attribute_texture_name.js +0 -8
- package/src/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +0 -250
- package/src/engine/graphics/micron/render/makeThreeMeshFromVirtualGeometry.js +0 -37
- package/src/engine/graphics/micron/render/refinement/ActivePatchFlags.js +0 -8
- package/src/engine/graphics/micron/render/refinement/ActivePatchList.js +0 -241
- package/src/engine/graphics/micron/render/refinement/ActivePatchRecord.js +0 -154
- package/src/engine/graphics/micron/render/refinement/RefinementSpec.js +0 -84
- package/src/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +0 -133
- package/src/engine/graphics/micron/render/refinement/is_patch_facing_back.js +0 -43
- package/src/engine/graphics/micron/render/refinement/is_patch_visible.js +0 -37
- package/src/engine/graphics/micron/render/v1/MaterialContext.js +0 -150
- package/src/engine/graphics/micron/render/v1/MaterialVertexSpec.js +0 -115
- package/src/engine/graphics/micron/render/v1/MicronRenderContext.js +0 -145
- package/src/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +0 -255
- package/src/engine/graphics/micron/render/v1/VGThreeRenderer.js +0 -142
- package/src/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +0 -54
- package/src/engine/graphics/micron/simplifyGeometry.js +0 -26
- package/src/engine/graphics/micron/util/patchToBufferGeometry.js +0 -19
package/package.json
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {TopoTriangle} f0
|
|
7
|
-
* @param {TopoTriangle} f1
|
|
8
|
-
* @returns {number}
|
|
9
|
-
*/
|
|
10
|
-
export function compute_face_connection_weight(f0, f1) {
|
|
11
|
-
const vertices_0 = f0.vertices;
|
|
12
|
-
const vertices_1 = f1.vertices;
|
|
13
|
-
|
|
14
|
-
// compute center
|
|
15
|
-
const f0_center_x = (vertices_0[0].x + vertices_0[1].x + vertices_0[2].x) * 0.333;
|
|
16
|
-
const f0_center_y = (vertices_0[0].y + vertices_0[1].y + vertices_0[2].y) * 0.333;
|
|
17
|
-
const f0_center_z = (vertices_0[0].z + vertices_0[1].z + vertices_0[2].z) * 0.333;
|
|
18
|
-
|
|
19
|
-
const f1_center_x = (vertices_1[0].x + vertices_1[1].x + vertices_1[2].x) * 0.333;
|
|
20
|
-
const f1_center_y = (vertices_1[0].y + vertices_1[1].y + vertices_1[2].y) * 0.333;
|
|
21
|
-
const f1_center_z = (vertices_1[0].z + vertices_1[1].z + vertices_1[2].z) * 0.333;
|
|
22
|
-
|
|
23
|
-
const distance_sqr = v3_distance_sqr(
|
|
24
|
-
f0_center_x, f0_center_y, f0_center_z,
|
|
25
|
-
f1_center_x, f1_center_y, f1_center_z
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// compute normal dot
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { v3_distance_sqr } from "../../../v3_distance_sqr";
|
|
2
|
+
import { v3_dot } from "../../../v3_dot.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {TopoTriangle} f0
|
|
7
|
+
* @param {TopoTriangle} f1
|
|
8
|
+
* @returns {number}
|
|
9
|
+
*/
|
|
10
|
+
export function compute_face_connection_weight(f0, f1) {
|
|
11
|
+
const vertices_0 = f0.vertices;
|
|
12
|
+
const vertices_1 = f1.vertices;
|
|
13
|
+
|
|
14
|
+
// compute center
|
|
15
|
+
const f0_center_x = (vertices_0[0].x + vertices_0[1].x + vertices_0[2].x) * 0.333;
|
|
16
|
+
const f0_center_y = (vertices_0[0].y + vertices_0[1].y + vertices_0[2].y) * 0.333;
|
|
17
|
+
const f0_center_z = (vertices_0[0].z + vertices_0[1].z + vertices_0[2].z) * 0.333;
|
|
18
|
+
|
|
19
|
+
const f1_center_x = (vertices_1[0].x + vertices_1[1].x + vertices_1[2].x) * 0.333;
|
|
20
|
+
const f1_center_y = (vertices_1[0].y + vertices_1[1].y + vertices_1[2].y) * 0.333;
|
|
21
|
+
const f1_center_z = (vertices_1[0].z + vertices_1[1].z + vertices_1[2].z) * 0.333;
|
|
22
|
+
|
|
23
|
+
const distance_sqr = v3_distance_sqr(
|
|
24
|
+
f0_center_x, f0_center_y, f0_center_z,
|
|
25
|
+
f1_center_x, f1_center_y, f1_center_z
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// compute normal dot
|
|
29
|
+
const n0 = f0.normal;
|
|
30
|
+
const n1 = f1.normal;
|
|
31
|
+
|
|
32
|
+
const dot = v3_dot(
|
|
33
|
+
n0[0], n0[1], n0[2],
|
|
34
|
+
n1[0], n1[1], n1[2],
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const distance_weight = distance_sqr !== 0 ? 0.01 / distance_sqr : 10000;
|
|
38
|
+
|
|
39
|
+
return 2 + distance_weight + dot * 0.1;
|
|
40
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Graph } from "./v2/Graph.js";
|
|
|
2
2
|
import { MultiNode } from "./MultiNode.js";
|
|
3
3
|
import {
|
|
4
4
|
compute_face_connection_weight
|
|
5
|
-
} from "
|
|
5
|
+
} from "../geom/3d/topology/util/compute_face_connection_weight.js";
|
|
6
6
|
import { WeightedEdge } from "./WeightedEdge.js";
|
|
7
7
|
import { graph_compute_disconnected_clusters } from "./graph_compute_disconnected_clusters.js";
|
|
8
8
|
|
|
@@ -6,7 +6,6 @@ import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
|
6
6
|
import { three_object_to_entity_composition } from "../three_object_to_entity_composition.js";
|
|
7
7
|
import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/TransformAttachmentSystem.js";
|
|
8
8
|
import { Camera } from "../../camera/Camera.js";
|
|
9
|
-
import { MicronRenderPlugin } from "../../../micron/plugin/MicronRenderPlugin.js";
|
|
10
9
|
import { enableEditor } from "../../../../../../editor/enableEditor.js";
|
|
11
10
|
import { MeshSystem } from "../../mesh/MeshSystem.js";
|
|
12
11
|
|
|
@@ -31,8 +30,6 @@ async function init(harness) {
|
|
|
31
30
|
config.addLoader(GameAssetType.ModelGLTF_JSON, gltfAssetLoader);
|
|
32
31
|
config.addLoader(GameAssetType.ModelGLTF, gltfAssetLoader);
|
|
33
32
|
|
|
34
|
-
config.addPlugin(MicronRenderPlugin);
|
|
35
|
-
|
|
36
33
|
await config.apply(engine);
|
|
37
34
|
|
|
38
35
|
enableEditor(engine);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const MICRON_GEOMETRY_FIELD = '@micron_geometry';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const MICRON_URI_FIELD = '@micron_path';
|
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import { TopoMesh } from "../../../../core/geom/3d/topology/struct/TopoMesh.js";
|
|
2
|
-
import { MicronGeometryPatch } from "../format/MicronGeometryPatch.js";
|
|
3
|
-
import { fill_patch_geometry_data } from "./fill_patch_geometry_data.js";
|
|
4
|
-
import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
|
|
5
|
-
import { assert } from "../../../../core/assert.js";
|
|
6
|
-
import {
|
|
7
|
-
computeTriangleClusterNormalBoundingCone
|
|
8
|
-
} from "../../../../core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js";
|
|
9
|
-
import { noop } from "../../../../core/function/Functions.js";
|
|
10
|
-
import { ConicRay } from "../../../../core/geom/ConicRay.js";
|
|
11
|
-
import { vec4 } from "gl-matrix";
|
|
12
|
-
import { computeTopoMeshBoundiningBox } from "../../../../core/geom/3d/topology/bounds/computeTopoMeshBoundiningBox.js";
|
|
13
|
-
import {
|
|
14
|
-
computeTopoMeshBoundingSphere
|
|
15
|
-
} from "../../../../core/geom/3d/topology/bounds/computeTopoMeshBoundingSphere.js";
|
|
16
|
-
import { meshopt_optimizeVertexCache } from "../../geometry/optimization/VertexCacheOptimizer.js";
|
|
17
|
-
import { array_copy } from "../../../../core/collection/array/copyArray.js";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @type {PatchRepresentation[]}
|
|
22
|
-
*/
|
|
23
|
-
const parent_stack = [];
|
|
24
|
-
|
|
25
|
-
export class PatchRepresentation {
|
|
26
|
-
constructor() {
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @type {number}
|
|
30
|
-
*/
|
|
31
|
-
this.id = 0;
|
|
32
|
-
|
|
33
|
-
this.bounding_box = new AABB3(
|
|
34
|
-
Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY,
|
|
35
|
-
Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @type {AABB3}
|
|
41
|
-
*/
|
|
42
|
-
this.group_aabb = new AABB3(0, 0, 0, 0, 0, 0);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @type {vec4|Float32Array}
|
|
47
|
-
*/
|
|
48
|
-
this.group_bounding_sphere = new Float32Array(4);
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @type {number}
|
|
53
|
-
*/
|
|
54
|
-
this.group_error = 0;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @type {vec4}
|
|
59
|
-
*/
|
|
60
|
-
this.bounding_sphere = vec4.create()
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Bounding cone of face normals
|
|
64
|
-
* @type {ConicRay}
|
|
65
|
-
*/
|
|
66
|
-
this.normal_cone = new ConicRay();
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @type {TopoMesh|null}
|
|
71
|
-
*/
|
|
72
|
-
this.topology_snapshot = null;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated
|
|
76
|
-
* Vertices that are shared with neighbours
|
|
77
|
-
* @type {Set<number>}
|
|
78
|
-
*/
|
|
79
|
-
this.vertices_shared = new Set();
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
* @type {Set<number>}
|
|
84
|
-
*/
|
|
85
|
-
this.vertices_included = new Set();
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Runtime dependency patches, if this patch is refined at runtime - dependencies must be refined as well
|
|
89
|
-
* These dependencies allow for more aggressive simplification of topology
|
|
90
|
-
* @type {PatchRepresentation[]}
|
|
91
|
-
*/
|
|
92
|
-
this.dependencies = [];
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Patches that share 1 or more edges with this one
|
|
96
|
-
* This includes patches at all LOD levels
|
|
97
|
-
* @type {PatchRepresentation[]}
|
|
98
|
-
*/
|
|
99
|
-
this.neighbours = [];
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @type {PatchRepresentation[]}
|
|
104
|
-
*/
|
|
105
|
-
this.children = [];
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* @type {PatchRepresentation[]}
|
|
110
|
-
*/
|
|
111
|
-
this.parents = [];
|
|
112
|
-
|
|
113
|
-
this.lod = 0;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated
|
|
119
|
-
*/
|
|
120
|
-
set topology_mask(v) {
|
|
121
|
-
throw new Error('E');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @deprecated
|
|
127
|
-
*/
|
|
128
|
-
get topology_mask() {
|
|
129
|
-
throw new Error('E');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @deprecated
|
|
134
|
-
*/
|
|
135
|
-
get parent() {
|
|
136
|
-
throw new Error('Single parent is no longer supported, use .parents instead');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* @deprecated
|
|
141
|
-
*/
|
|
142
|
-
set parent(v) {
|
|
143
|
-
throw new Error('Single parent is no longer supported, use .parents instead');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
snapshotTopology() {
|
|
147
|
-
const mesh = new TopoMesh();
|
|
148
|
-
|
|
149
|
-
mesh.add(this.topology_mask);
|
|
150
|
-
|
|
151
|
-
this.topology_snapshot = mesh;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
*
|
|
156
|
-
* @param {function(string)} error_consumer
|
|
157
|
-
* @param {*} thisArg
|
|
158
|
-
* @returns {boolean}
|
|
159
|
-
*/
|
|
160
|
-
validate(error_consumer = noop, thisArg) {
|
|
161
|
-
let result = true;
|
|
162
|
-
// check neighbours
|
|
163
|
-
const neighbours = this.neighbours;
|
|
164
|
-
const neighbour_count = neighbours.length;
|
|
165
|
-
|
|
166
|
-
for (let i = 0; i < neighbour_count; i++) {
|
|
167
|
-
const neighbour = neighbours[i];
|
|
168
|
-
|
|
169
|
-
if (!neighbour.hasNeighbour(this)) {
|
|
170
|
-
result = false;
|
|
171
|
-
error_consumer.call(thisArg, `Neighbour[${i}] missing back link`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// check that parent contains all of the children's neighbours except for descendants
|
|
176
|
-
const children = this.children;
|
|
177
|
-
const child_count = children.length;
|
|
178
|
-
for (let i = 0; i < child_count; i++) {
|
|
179
|
-
const child = children[i];
|
|
180
|
-
|
|
181
|
-
const child_neighbours = child.neighbours;
|
|
182
|
-
const child_neighbour_count = child_neighbours.length;
|
|
183
|
-
|
|
184
|
-
for (let j = 0; j < child_neighbour_count; j++) {
|
|
185
|
-
const child_neighbour = child_neighbours[j];
|
|
186
|
-
|
|
187
|
-
if (child_neighbour.isDescendantOf(this)) {
|
|
188
|
-
// skip descendants
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (!this.hasNeighbour(child_neighbour)) {
|
|
193
|
-
result = false;
|
|
194
|
-
error_consumer.call(thisArg, `Missing inherited neighbour[${j}] of child[${i}]`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
computeBounds() {
|
|
203
|
-
computeTopoMeshBoundiningBox(this.bounding_box, this.topology_snapshot);
|
|
204
|
-
computeTopoMeshBoundingSphere(this.bounding_sphere, this.topology_snapshot);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* @returns {number}
|
|
209
|
-
*/
|
|
210
|
-
computePerimeterLength() {
|
|
211
|
-
let result = 0;
|
|
212
|
-
const edges = this.topology_snapshot.getEdges();
|
|
213
|
-
for (const edge of edges) {
|
|
214
|
-
if (edge.isTopologyBorder()) {
|
|
215
|
-
result += edge.length;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
*
|
|
224
|
-
* @param {function(PatchRepresentation):boolean} filter
|
|
225
|
-
* @returns {PatchRepresentation[]}
|
|
226
|
-
*/
|
|
227
|
-
collectNodes(filter) {
|
|
228
|
-
const result = [];
|
|
229
|
-
this.traverse(p => {
|
|
230
|
-
if (filter(p)) {
|
|
231
|
-
result.push(p);
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
*
|
|
240
|
-
* @param {function(path:PatchRepresentation):boolean?} callback
|
|
241
|
-
* @param {*} [thisArg]
|
|
242
|
-
*/
|
|
243
|
-
traverse(callback, thisArg) {
|
|
244
|
-
const stack = [this];
|
|
245
|
-
let stack_cursor = 1;
|
|
246
|
-
const seen_nodes = new Set();
|
|
247
|
-
seen_nodes.add(this);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
while (stack_cursor > 0) {
|
|
251
|
-
stack_cursor--;
|
|
252
|
-
|
|
253
|
-
const patch = stack[stack_cursor];
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const traverse_deeper = callback.call(thisArg, patch);
|
|
257
|
-
|
|
258
|
-
if (traverse_deeper === false) {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const children = patch.children;
|
|
263
|
-
const child_count = children.length;
|
|
264
|
-
|
|
265
|
-
for (let i = 0; i < child_count; i++) {
|
|
266
|
-
const child = children[i];
|
|
267
|
-
|
|
268
|
-
if (seen_nodes.has(child)) {
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
seen_nodes.add(child);
|
|
273
|
-
|
|
274
|
-
stack[stack_cursor++] = child;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
*
|
|
281
|
-
* @returns {number}
|
|
282
|
-
*/
|
|
283
|
-
countDescendants() {
|
|
284
|
-
let result = 0;
|
|
285
|
-
|
|
286
|
-
const children = this.children;
|
|
287
|
-
const child_count = children.length;
|
|
288
|
-
for (let i = 0; i < child_count; i++) {
|
|
289
|
-
result++;
|
|
290
|
-
|
|
291
|
-
const child = children[i];
|
|
292
|
-
|
|
293
|
-
result += child.countDescendants();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return result;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
*
|
|
301
|
-
* @param {PatchRepresentation} p
|
|
302
|
-
* @returns {boolean}
|
|
303
|
-
*/
|
|
304
|
-
isDescendantOf(p) {
|
|
305
|
-
|
|
306
|
-
let cursor = 1;
|
|
307
|
-
parent_stack[0] = this;
|
|
308
|
-
|
|
309
|
-
do {
|
|
310
|
-
cursor--;
|
|
311
|
-
|
|
312
|
-
const x = parent_stack[cursor];
|
|
313
|
-
|
|
314
|
-
if (x === p) {
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const parents = x.parents;
|
|
319
|
-
const parent_count = parents.length;
|
|
320
|
-
for (let i = 0; i < parent_count; i++) {
|
|
321
|
-
parent_stack[cursor++] = parents[i];
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
} while (cursor > 0);
|
|
325
|
-
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
*
|
|
331
|
-
* @param {PatchRepresentation} p
|
|
332
|
-
* @returns {boolean}
|
|
333
|
-
*/
|
|
334
|
-
hasDescendant(p) {
|
|
335
|
-
const children = this.children;
|
|
336
|
-
const child_count = children.length;
|
|
337
|
-
for (let i = 0; i < child_count; i++) {
|
|
338
|
-
const child = children[i];
|
|
339
|
-
|
|
340
|
-
if (child === p) {
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (child.hasDescendant(p)) {
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
*
|
|
354
|
-
* @param {PatchRepresentation} p
|
|
355
|
-
* @returns {boolean}
|
|
356
|
-
*/
|
|
357
|
-
hasChild(p) {
|
|
358
|
-
return this.children.indexOf(p) !== -1;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
*
|
|
363
|
-
* @param {PatchRepresentation} p
|
|
364
|
-
* @returns {boolean}
|
|
365
|
-
*/
|
|
366
|
-
hasNeighbour(p) {
|
|
367
|
-
return this.neighbours.indexOf(p) !== -1;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
*
|
|
372
|
-
* @param {PatchRepresentation} p
|
|
373
|
-
*/
|
|
374
|
-
addNeighbour(p) {
|
|
375
|
-
assert.notEqual(this, p, 'cannot add self as a neighbour');
|
|
376
|
-
assert.arrayHasNo(this.neighbours, p, 'already contained');
|
|
377
|
-
|
|
378
|
-
this.neighbours.push(p);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
computeNormalBoundingCone() {
|
|
382
|
-
computeTriangleClusterNormalBoundingCone(this.normal_cone, this.topology_snapshot.getFaces());
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
*
|
|
387
|
-
* @param {MicronGeometryPatch} result
|
|
388
|
-
* @param {THREE.BufferGeometry} source_geometry
|
|
389
|
-
* @param {VertexDataSpec} vertex_data_spec
|
|
390
|
-
*/
|
|
391
|
-
buildMicronGeometryPatch(result, source_geometry, vertex_data_spec) {
|
|
392
|
-
|
|
393
|
-
assert.defined(source_geometry, 'source_geometry');
|
|
394
|
-
assert.equal(source_geometry.isBufferGeometry, true, 'source_geometry.isBufferGeometry !== true');
|
|
395
|
-
assert.defined(vertex_data_spec, 'vertex_data_spec');
|
|
396
|
-
|
|
397
|
-
result.id = this.id;
|
|
398
|
-
result.lod = this.lod;
|
|
399
|
-
|
|
400
|
-
const topology = this.topology_snapshot;
|
|
401
|
-
|
|
402
|
-
result.polygon_count = topology.getFaces().size;
|
|
403
|
-
|
|
404
|
-
// copy bounding_box
|
|
405
|
-
this.bounding_box.writeToArray(result.bounding_box, 0);
|
|
406
|
-
|
|
407
|
-
this.group_aabb.writeToArray(result.group_bounding_box, 0);
|
|
408
|
-
|
|
409
|
-
this.group_aabb.getCorners(result.group_bounding_box_corners);
|
|
410
|
-
|
|
411
|
-
array_copy(this.group_bounding_sphere, 0, result.group_bounding_sphere, 0, 4);
|
|
412
|
-
|
|
413
|
-
result.group_error = this.group_error;
|
|
414
|
-
|
|
415
|
-
array_copy(this.bounding_sphere, 0, result.bounding_sphere, 0, 4);
|
|
416
|
-
|
|
417
|
-
result.normal_cone.copy(this.normal_cone);
|
|
418
|
-
|
|
419
|
-
fill_patch_geometry_data(result, source_geometry, this.topology_snapshot, vertex_data_spec);
|
|
420
|
-
|
|
421
|
-
// optimize index buffer for better caching
|
|
422
|
-
meshopt_optimizeVertexCache(result.face_indices, result.face_indices, result.face_indices.length, result.vertex_count);
|
|
423
|
-
}
|
|
424
|
-
}
|