@woosh/meep-engine 2.33.6 → 2.33.11
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/binary/BinaryBuffer.js +26 -2
- 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/collection/table/DataType2TypedArrayConstructorMapping.js +2 -0
- package/core/collection/table/DataTypeByteSizes.js +21 -0
- package/core/collection/table/RowFirstTable.js +1 -88
- package/core/collection/table/RowFirstTable.spec.js +3 -1
- package/core/collection/table/RowFirstTableSpec.js +1 -19
- package/core/collection/table/computeDataTypeByIndex.js +21 -0
- package/core/collection/table/deserializeRowFirstTable.js +48 -0
- package/core/collection/table/serializeRowFirstTable.js +27 -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/core/process/worker/WorkerBuilder.js +21 -6
- package/engine/Engine.d.ts +2 -0
- package/engine/EngineHarness.js +4 -4
- package/engine/ecs/foliage/InstancedFoliage.js +3 -5
- package/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +2 -1
- 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/format/MicronGeometry.js +12 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
- package/engine/graphics/micron/format/MicronGeometryPatch.js +6 -6
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +101 -0
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +25 -0
- package/engine/graphics/micron/format/serialization/deserialize_patch.js +104 -0
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +18 -0
- package/engine/graphics/micron/format/serialization/serialize_patch.js +84 -0
- package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.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/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +1 -1
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +11 -6
- package/engine/graphics/texture/sampler/TextureBinaryBufferSerializer.js +1 -1
- package/engine/network/convertPathToURL.js +7 -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
|
@@ -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
|
|
@@ -55,6 +55,18 @@ export class MicronGeometry {
|
|
|
55
55
|
this.__proxy = null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
get patches() {
|
|
59
|
+
return this.__patches;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {MicronGeometryPatch[]} v
|
|
65
|
+
*/
|
|
66
|
+
set patches(v) {
|
|
67
|
+
this.__patches = v;
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
/**
|
|
59
71
|
* @param {THREE.BufferGeometry} geometry
|
|
60
72
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
2
|
-
import { DataTypeByteSizes } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
3
2
|
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
3
|
+
import { DataTypeByteSizes } from "../../../../core/collection/table/DataTypeByteSizes.js";
|
|
4
4
|
|
|
5
5
|
export class MicronGeometryBufferAttributeSpec {
|
|
6
6
|
constructor() {
|
|
@@ -26,6 +26,12 @@ export class MicronGeometryPatch {
|
|
|
26
26
|
*/
|
|
27
27
|
this.bounding_box = new Float32Array(array_buffer, 0, 6);
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {vec4|number[]}
|
|
32
|
+
*/
|
|
33
|
+
this.bounding_sphere = vec4.create()
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
*
|
|
31
37
|
* @type {number[]|Float32Array}
|
|
@@ -50,12 +56,6 @@ export class MicronGeometryPatch {
|
|
|
50
56
|
*/
|
|
51
57
|
this.group_error = 0;
|
|
52
58
|
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @type {vec4}
|
|
56
|
-
*/
|
|
57
|
-
this.bounding_sphere = vec4.create()
|
|
58
|
-
|
|
59
59
|
/**
|
|
60
60
|
*
|
|
61
61
|
* @type {MicronGeometryPatch[]}
|
package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { MicronGeometry } from "../MicronGeometry.js";
|
|
3
|
+
import { MicronGeometryBufferAttributeSpec } from "../MicronGeometryBufferAttributeSpec.js";
|
|
4
|
+
import { MicronGeometryPatch } from "../MicronGeometryPatch.js";
|
|
5
|
+
import { serialize_patch } from "./serialize_patch.js";
|
|
6
|
+
import { deserialize_patch } from "./deserialize_patch.js";
|
|
7
|
+
import { serialize_attribute_spec } from "./serialize_attribute_spec.js";
|
|
8
|
+
import { deserialize_attribute_spec } from "./deserialize_attribute_spec.js";
|
|
9
|
+
|
|
10
|
+
export class MicronGeometryBinarySerializationAdapter extends BinaryClassSerializationAdapter {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.klass = MicronGeometry;
|
|
15
|
+
this.version = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {BinaryBuffer} buffer
|
|
21
|
+
* @param {MicronGeometry} value
|
|
22
|
+
*/
|
|
23
|
+
serialize(buffer, value) {
|
|
24
|
+
const spec = value.vertex_spec;
|
|
25
|
+
|
|
26
|
+
// serialize vertex spec
|
|
27
|
+
const attributes = spec.attributes;
|
|
28
|
+
const attribute_count = attributes.length;
|
|
29
|
+
buffer.writeUintVar(attribute_count);
|
|
30
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
31
|
+
const attribute = attributes[i];
|
|
32
|
+
|
|
33
|
+
serialize_attribute_spec(buffer, attribute);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// serialize patches
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @type {MicronGeometryPatch[]}
|
|
41
|
+
*/
|
|
42
|
+
const patches = value.patches;
|
|
43
|
+
const patch_count = patches.length;
|
|
44
|
+
|
|
45
|
+
const root_patch_index = patches.indexOf(value.root);
|
|
46
|
+
|
|
47
|
+
buffer.writeUintVar(root_patch_index);
|
|
48
|
+
|
|
49
|
+
buffer.writeUintVar(patch_count);
|
|
50
|
+
|
|
51
|
+
for (let i = 0; i < patch_count; i++) {
|
|
52
|
+
serialize_patch(buffer, patches[i], spec, patches);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {BinaryBuffer} buffer
|
|
59
|
+
* @param {MicronGeometry} value
|
|
60
|
+
*/
|
|
61
|
+
deserialize(buffer, value) {
|
|
62
|
+
// read spec
|
|
63
|
+
const attribute_count = buffer.readUintVar();
|
|
64
|
+
const attributes = [];
|
|
65
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
66
|
+
const spec = new MicronGeometryBufferAttributeSpec();
|
|
67
|
+
|
|
68
|
+
deserialize_attribute_spec(buffer, spec);
|
|
69
|
+
attributes[i] = spec;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const vertex_spec = value.vertex_spec;
|
|
73
|
+
vertex_spec.setAttributes(attributes);
|
|
74
|
+
|
|
75
|
+
// read patches
|
|
76
|
+
const root_patch_index = buffer.readUintVar();
|
|
77
|
+
|
|
78
|
+
const patch_count = buffer.readUintVar();
|
|
79
|
+
|
|
80
|
+
const patches = [];
|
|
81
|
+
|
|
82
|
+
// build initial patches
|
|
83
|
+
for (let i = 0; i < patch_count; i++) {
|
|
84
|
+
const patch = new MicronGeometryPatch();
|
|
85
|
+
|
|
86
|
+
patch.id = i;
|
|
87
|
+
|
|
88
|
+
patches[i] = patch;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//read patches
|
|
92
|
+
for (let i = 0; i < patch_count; i++) {
|
|
93
|
+
const patch = patches[i];
|
|
94
|
+
|
|
95
|
+
deserialize_patch(buffer, patch, vertex_spec, patches);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
value.patches = patches;
|
|
99
|
+
value.root = patches[root_patch_index];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computeDataTypeByIndex } from "../../../../../core/collection/table/computeDataTypeByIndex.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {MicronGeometryBufferAttributeSpec} spec
|
|
7
|
+
*/
|
|
8
|
+
export function deserialize_attribute_spec(buffer, spec) {
|
|
9
|
+
|
|
10
|
+
spec.name = buffer.readUTF8String();
|
|
11
|
+
spec.itemSize = buffer.readUintVar();
|
|
12
|
+
|
|
13
|
+
const type_index = buffer.readUint8();
|
|
14
|
+
const type = computeDataTypeByIndex(type_index);
|
|
15
|
+
|
|
16
|
+
if (type === undefined) {
|
|
17
|
+
throw new Error(`Unknown data type marker '${type_index}'`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
spec.type = type;
|
|
21
|
+
|
|
22
|
+
const flags = buffer.readUint8();
|
|
23
|
+
|
|
24
|
+
spec.normalized = (flags & 0x1) !== 0;
|
|
25
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { aabb3_build_corners } from "../../../../../core/geom/3d/aabb/aabb3_build_corners.js";
|
|
2
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
3
|
+
import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {BinaryBuffer} buffer
|
|
8
|
+
* @param {MicronGeometryPatch} patch
|
|
9
|
+
* @param {MicronVertexDataSpec} vertex_spec
|
|
10
|
+
* @param {MicronGeometryPatch[]} patch_array
|
|
11
|
+
*/
|
|
12
|
+
export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
|
|
13
|
+
// METADATA
|
|
14
|
+
buffer.readFloat32Array(patch.bounding_box, 0, 6);
|
|
15
|
+
buffer.readFloat32Array(patch.bounding_sphere, 0, 4);
|
|
16
|
+
|
|
17
|
+
const gbb = patch.group_bounding_box;
|
|
18
|
+
buffer.readFloat32Array(gbb, 0, 6);
|
|
19
|
+
buffer.readFloat32Array(patch.group_bounding_sphere, 0, 4);
|
|
20
|
+
|
|
21
|
+
// reconstruct corners
|
|
22
|
+
aabb3_build_corners(
|
|
23
|
+
patch.group_bounding_box_corners,
|
|
24
|
+
0,
|
|
25
|
+
gbb[0],
|
|
26
|
+
gbb[1],
|
|
27
|
+
gbb[2],
|
|
28
|
+
gbb[3],
|
|
29
|
+
gbb[4],
|
|
30
|
+
gbb[5]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
patch.group_error = buffer.readFloat32();
|
|
34
|
+
patch.lod = buffer.readUintVar();
|
|
35
|
+
patch.polygon_count = buffer.readUintVar();
|
|
36
|
+
patch.vertex_count = buffer.readUintVar();
|
|
37
|
+
|
|
38
|
+
// parents
|
|
39
|
+
const parents = [];
|
|
40
|
+
const parent_count = buffer.readUintVar();
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < parent_count; i++) {
|
|
43
|
+
const parent_index = buffer.readUintVar();
|
|
44
|
+
|
|
45
|
+
if (patch_array.length <= parent_index || parent_index < 0) {
|
|
46
|
+
throw new Error(`out of bounds parent index '${parent_index}'`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
parents[i] = patch_array[parent_index];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
patch.parents = parents;
|
|
53
|
+
|
|
54
|
+
// children
|
|
55
|
+
const children = [];
|
|
56
|
+
const child_count = buffer.readUintVar();
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < child_count; i++) {
|
|
59
|
+
const child_index = buffer.readUintVar();
|
|
60
|
+
|
|
61
|
+
if (patch_array.length <= child_index || child_index < 0) {
|
|
62
|
+
throw new Error(`out of bounds child index '${child_index}'`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
children[i] = patch_array[child_index];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
patch.children = children;
|
|
69
|
+
|
|
70
|
+
// INDICES
|
|
71
|
+
const index_count = patch.polygon_count * 3;
|
|
72
|
+
|
|
73
|
+
if (patch.vertex_count <= 256) {
|
|
74
|
+
patch.face_indices = new Uint8Array(index_count);
|
|
75
|
+
buffer.readUint8Array(patch.face_indices, 0, index_count);
|
|
76
|
+
} else if (patch.vertex_count <= 65536) {
|
|
77
|
+
patch.face_indices = new Uint16Array(index_count);
|
|
78
|
+
buffer.readUint16Array(patch.face_indices, 0, index_count);
|
|
79
|
+
} else {
|
|
80
|
+
throw new Error(`Unsupported vertex count '${patch.vertex_count}'`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// VERTICES
|
|
84
|
+
const attributes = vertex_spec.attributes;
|
|
85
|
+
const attribute_count = attributes.length;
|
|
86
|
+
|
|
87
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
88
|
+
const spec = attributes[i];
|
|
89
|
+
|
|
90
|
+
const data_type = spec.type;
|
|
91
|
+
const item_size = spec.itemSize;
|
|
92
|
+
|
|
93
|
+
const byte_size = DataTypeByteSizes[data_type];
|
|
94
|
+
|
|
95
|
+
const ArrayConstructor = DataType2TypedArrayConstructorMapping[data_type];
|
|
96
|
+
|
|
97
|
+
const elment_count = item_size * patch.vertex_count;
|
|
98
|
+
const array = new ArrayConstructor(elment_count);
|
|
99
|
+
|
|
100
|
+
buffer.readUint8Array(new Uint8Array(array.buffer), 0, byte_size * elment_count);
|
|
101
|
+
|
|
102
|
+
patch.vertex_attribute_arrays[i] = array;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataTypeIndices } from "../../../../../core/collection/table/DataTypeIndices.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {MicronGeometryBufferAttributeSpec} spec
|
|
7
|
+
*/
|
|
8
|
+
export function serialize_attribute_spec(buffer, spec) {
|
|
9
|
+
buffer.writeUTF8String(spec.name);
|
|
10
|
+
buffer.writeUintVar(spec.itemSize);
|
|
11
|
+
|
|
12
|
+
const dataTypeIndex = DataTypeIndices[spec.type];
|
|
13
|
+
buffer.writeUint8(dataTypeIndex);
|
|
14
|
+
|
|
15
|
+
const flags = spec.normalized ? 1 : 0;
|
|
16
|
+
|
|
17
|
+
buffer.writeUint8(flags);// flags
|
|
18
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {MicronGeometryPatch} patch
|
|
7
|
+
* @param {MicronVertexDataSpec} vertex_spec
|
|
8
|
+
* @param {MicronGeometryPatch[]} patch_array
|
|
9
|
+
*/
|
|
10
|
+
export function serialize_patch(buffer, patch, vertex_spec, patch_array) {
|
|
11
|
+
// METADATA
|
|
12
|
+
buffer.writeFloat32Array(patch.bounding_box, 0, 6);
|
|
13
|
+
buffer.writeFloat32Array(patch.bounding_sphere, 0, 4);
|
|
14
|
+
|
|
15
|
+
buffer.writeFloat32Array(patch.group_bounding_box, 0, 6);
|
|
16
|
+
buffer.writeFloat32Array(patch.group_bounding_sphere, 0, 4);
|
|
17
|
+
|
|
18
|
+
buffer.writeFloat32(patch.group_error);
|
|
19
|
+
buffer.writeUintVar(patch.lod);
|
|
20
|
+
buffer.writeUintVar(patch.polygon_count);
|
|
21
|
+
buffer.writeUintVar(patch.vertex_count);
|
|
22
|
+
|
|
23
|
+
// write parents
|
|
24
|
+
const parents = patch.parents;
|
|
25
|
+
const parent_count = parents.length;
|
|
26
|
+
|
|
27
|
+
buffer.writeUintVar(parent_count);
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < parent_count; i++) {
|
|
30
|
+
const parent = parents[i];
|
|
31
|
+
|
|
32
|
+
const parent_index = patch_array.indexOf(parent);
|
|
33
|
+
|
|
34
|
+
if (parent_index === -1) {
|
|
35
|
+
throw new Error(`Patch '${parent.id}' not found in the lookup table`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buffer.writeUintVar(parent_index);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// write children
|
|
42
|
+
const children = patch.children;
|
|
43
|
+
const child_count = children.length;
|
|
44
|
+
|
|
45
|
+
buffer.writeUintVar(child_count);
|
|
46
|
+
|
|
47
|
+
for (let i = 0; i < child_count; i++) {
|
|
48
|
+
const child = children[i];
|
|
49
|
+
|
|
50
|
+
const child_index = patch_array.indexOf(child);
|
|
51
|
+
|
|
52
|
+
if (child_index === -1) {
|
|
53
|
+
throw new Error(`Patch '${child.id}' not found in the lookup table`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
buffer.writeUintVar(child_index);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// INDICES
|
|
60
|
+
if (patch.vertex_count <= 256) {
|
|
61
|
+
buffer.writeUint8Array(patch.face_indices, 0, patch.polygon_count * 3);
|
|
62
|
+
} else if (patch.vertex_count <= 65536) {
|
|
63
|
+
buffer.writeUint16Array(patch.face_indices, 0, patch.polygon_count * 3);
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error(`Unsupported vertex count '${patch.vertex_count}'`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// VERTICES
|
|
69
|
+
const attributes = vertex_spec.attributes;
|
|
70
|
+
const attribute_count = attributes.length;
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
73
|
+
const spec = attributes[i];
|
|
74
|
+
|
|
75
|
+
const data_type = spec.type;
|
|
76
|
+
const item_size = spec.itemSize;
|
|
77
|
+
|
|
78
|
+
const byte_size = DataTypeByteSizes[data_type];
|
|
79
|
+
|
|
80
|
+
const attribute_values = patch.vertex_attribute_arrays[i];
|
|
81
|
+
|
|
82
|
+
buffer.writeUint8Array(new Uint8Array(attribute_values.buffer), 0, item_size * byte_size * patch.vertex_count);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -3,11 +3,11 @@ import { MICRON_PATCH_SIZE_MAX } from "../../build/MICRON_PATCH_SIZE_MAX.js";
|
|
|
3
3
|
import { typed_array_copy } from "../../../../../core/collection/array/typed/typed_array_copy.js";
|
|
4
4
|
import { channelCountToThreeTextureFormat } from "../../../texture/channelCountToThreeTextureFormat.js";
|
|
5
5
|
import { DataTexture, NearestFilter } from "three";
|
|
6
|
-
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
7
6
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
8
7
|
import { compute_micron_buffer_array_constructor } from "../../build/compute_micron_buffer_array_constructor.js";
|
|
9
8
|
import { computeThreeTextureTypeFromDataType } from "../../../render/forward_plus/data/computeThreeTextureTypeFromDataType.js";
|
|
10
9
|
import { computeThreeTextureInternalFormatFromDataType } from "../../../render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js";
|
|
10
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
@@ -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";
|
|
@@ -3,12 +3,12 @@ import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
|
3
3
|
import { assert } from "../../../../../core/assert.js";
|
|
4
4
|
import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
5
5
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
|
-
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
7
6
|
import { NumericType } from "./NumericType.js";
|
|
8
7
|
import { computeDataType } from "./computeDataType.js";
|
|
9
8
|
import { computeThreeTextureTypeFromDataType } from "./computeThreeTextureTypeFromDataType.js";
|
|
10
9
|
import { computeThreeTextureInternalFormatFromDataType } from "./computeThreeTextureInternalFormatFromDataType.js";
|
|
11
10
|
import { computeThreeTextureFormat } from "./computeThreeTextureFormat.js";
|
|
11
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* How wide a data texture is
|