@woosh/meep-engine 2.33.4 → 2.33.9
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 +21 -1
- package/core/collection/RingBuffer.js +40 -10
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/array/typed/typed_array_copy.js +2 -2
- 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 +9 -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_compute_projected_area.js +6 -4
- package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
- package/core/geom/3d/aabb/aabb3_from_min_max.js +15 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -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/core/geom/3d/frustum/array_normalize_plane.js +25 -0
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +60 -0
- 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/undo/ActionProcessor.d.ts +2 -0
- package/core/process/undo/ActionProcessor.js +59 -1
- package/core/process/undo/ActionProcessor.spec.js +59 -0
- package/core/process/undo/Mark.js +2 -1
- package/engine/Engine.d.ts +2 -0
- package/engine/EngineHarness.js +4 -4
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +19 -0
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +7 -19
- 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/GraphicsEngine.js +9 -116
- 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/filter/FlipArrayInPlace.js +25 -0
- package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
- package/engine/graphics/filter/ImageFilter.js +20 -51
- 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/geometry/instancing/InstancedMeshGroup.js +25 -16
- package/engine/graphics/material/SplatMaterial.js +4 -97
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +2 -6
- 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/fill_patch_geometry_data.js +2 -0
- 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 +2 -2
- package/engine/graphics/micron/format/MicronGeometryPatch.js +17 -9
- package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
- 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/prototypeVirtualGeometry.js +1 -1
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +27 -23
- package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +3 -5
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +38 -49
- package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
- package/engine/graphics/micron/render/refinement/RefinementSpec.js +98 -0
- package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +21 -0
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +12 -9
- package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
- package/engine/graphics/render/buffer/buffers/ColorAndDepthFrameBuffer.js +5 -3
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
- package/engine/graphics/render/forward_plus/LightManager.js +5 -7
- package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
- package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
- package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
- package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +1 -1
- package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
- package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +440 -0
- package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
- package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
- package/engine/graphics/shadows/ShadowMapRenderer.js +12 -2
- package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
- package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
- package/engine/graphics/texture/cubemap/load_environment_map.js +163 -0
- package/engine/graphics/texture/sampler/Sampler2D.js +18 -62
- package/engine/graphics/texture/sampler/TextureBinaryBufferSerializer.js +1 -1
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +3 -2
- package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +3 -2
- package/engine/graphics/texture/sampler/differenceSampler.js +31 -0
- package/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js +25 -0
- package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -2
- package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
- package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
- package/engine/network/convertPathToURL.js +6 -0
- package/engine/plugin/EnginePluginManager.d.ts +9 -0
- package/engine/reference/v2/Reference.d.ts +7 -0
- package/package.json +1 -1
- package/view/minimap/gl/MinimapMarkersGL.js +2 -2
- package/engine/graphics/micron/build/clustering/cluster_mesh_vertices.js +0 -3
- package/engine/graphics/micron/render/RefinementSpec.js +0 -181
|
@@ -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() {
|
|
@@ -40,8 +40,8 @@ export class MicronGeometryBufferAttributeSpec {
|
|
|
40
40
|
equals(other) {
|
|
41
41
|
return this.type === other.type
|
|
42
42
|
&& this.itemSize === other.itemSize
|
|
43
|
-
&& this.name === other.name
|
|
44
43
|
&& this.normalized === other.normalized
|
|
44
|
+
&& this.name === other.name
|
|
45
45
|
;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -13,22 +13,36 @@ export class MicronGeometryPatch {
|
|
|
13
13
|
*/
|
|
14
14
|
this.id = 0;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Continuous memory region for various pieces of data to get better memory access patterns
|
|
18
|
+
* All pieces of data end up in a continuous piece of memory, resulting in better cache coherence
|
|
19
|
+
* @type {ArrayBuffer}
|
|
20
|
+
*/
|
|
21
|
+
const array_buffer = new ArrayBuffer((6 + 6 + 24) * 4);
|
|
22
|
+
|
|
16
23
|
/**
|
|
17
24
|
* Bounds are used to determine screen error and whether a patch should be subdivided or not for rendering
|
|
18
25
|
* @type {number[]}
|
|
19
26
|
*/
|
|
20
|
-
this.bounding_box = new Float32Array(6);
|
|
27
|
+
this.bounding_box = new Float32Array(array_buffer, 0, 6);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {vec4|number[]}
|
|
32
|
+
*/
|
|
33
|
+
this.bounding_sphere = vec4.create()
|
|
21
34
|
|
|
22
35
|
/**
|
|
23
36
|
*
|
|
24
37
|
* @type {number[]|Float32Array}
|
|
25
38
|
*/
|
|
26
|
-
this.group_bounding_box = new Float32Array(6);
|
|
39
|
+
this.group_bounding_box = new Float32Array(array_buffer, 6 * 4, 6);
|
|
40
|
+
|
|
27
41
|
/**
|
|
28
42
|
*
|
|
29
43
|
* @type {number[]|Float32Array}
|
|
30
44
|
*/
|
|
31
|
-
this.group_bounding_box_corners = new Float32Array(24);
|
|
45
|
+
this.group_bounding_box_corners = new Float32Array(array_buffer, 12 * 4, 24);
|
|
32
46
|
|
|
33
47
|
/**
|
|
34
48
|
*
|
|
@@ -42,12 +56,6 @@ export class MicronGeometryPatch {
|
|
|
42
56
|
*/
|
|
43
57
|
this.group_error = 0;
|
|
44
58
|
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @type {vec4}
|
|
48
|
-
*/
|
|
49
|
-
this.bounding_sphere = vec4.create()
|
|
50
|
-
|
|
51
59
|
/**
|
|
52
60
|
*
|
|
53
61
|
* @type {MicronGeometryPatch[]}
|
|
@@ -2,6 +2,8 @@ import { isArrayEqual } from "../../../../core/collection/ArrayUtils.js";
|
|
|
2
2
|
import { computeHashArray } from "../../../../core/math/MathUtils.js";
|
|
3
3
|
import { invokeObjectHash } from "../../../../core/model/object/invokeObjectHash.js";
|
|
4
4
|
|
|
5
|
+
const DEFAULT_HASH = 123456;
|
|
6
|
+
|
|
5
7
|
export class MicronVertexDataSpec {
|
|
6
8
|
constructor() {
|
|
7
9
|
/**
|
|
@@ -12,9 +14,21 @@ export class MicronVertexDataSpec {
|
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
*
|
|
15
|
-
* @type {
|
|
17
|
+
* @type {number}
|
|
18
|
+
* @private
|
|
16
19
|
*/
|
|
17
|
-
this.
|
|
20
|
+
this.__hash = DEFAULT_HASH;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {MicronGeometryBufferAttributeSpec[]} attributes
|
|
26
|
+
*/
|
|
27
|
+
setAttributes(attributes) {
|
|
28
|
+
this.attributes = attributes;
|
|
29
|
+
|
|
30
|
+
// reset hash to trigger hash update
|
|
31
|
+
this.__hash = DEFAULT_HASH;
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
/**
|
|
@@ -30,10 +44,18 @@ export class MicronVertexDataSpec {
|
|
|
30
44
|
return isArrayEqual(this.attributes, other.attributes);
|
|
31
45
|
}
|
|
32
46
|
|
|
33
|
-
|
|
47
|
+
computeHash() {
|
|
34
48
|
return computeHashArray(this.attributes, invokeObjectHash);
|
|
35
49
|
}
|
|
36
50
|
|
|
51
|
+
hash() {
|
|
52
|
+
if (this.__hash === DEFAULT_HASH) {
|
|
53
|
+
this.__hash = this.computeHash();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return this.__hash;
|
|
57
|
+
}
|
|
58
|
+
|
|
37
59
|
/**
|
|
38
60
|
*
|
|
39
61
|
* @param {string} name
|
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
|
+
}
|
|
@@ -2,19 +2,33 @@ import { Frustum, Matrix4 } from "three";
|
|
|
2
2
|
import { array_copy } from "../../../../core/collection/array/copyArray.js";
|
|
3
3
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
4
4
|
import { MicronGeometryPatchOccurrence } from "../format/MicronGeometryPatchOccurance.js";
|
|
5
|
-
import { RefinementSpec } from "./RefinementSpec.js";
|
|
5
|
+
import { RefinementSpec } from "./refinement/RefinementSpec.js";
|
|
6
6
|
import { ActivePatchList } from "./refinement/ActivePatchList.js";
|
|
7
7
|
import { ActivePatchFlags } from "./refinement/ActivePatchFlags.js";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @readonly
|
|
11
|
+
* @type {RefinementSpec}
|
|
12
|
+
*/
|
|
10
13
|
const refinement_spec = new RefinementSpec();
|
|
11
14
|
|
|
12
15
|
export class VirtualGeometryBuilder {
|
|
13
16
|
constructor() {
|
|
14
17
|
this.view_projection_matrix = new Matrix4();
|
|
15
|
-
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {Float32Array|number[]|mat4}
|
|
22
|
+
*/
|
|
23
|
+
this.matrix_projection = new Float32Array(16);
|
|
24
|
+
|
|
16
25
|
this.matrix_projection_inverse = new Matrix4();
|
|
17
|
-
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @type {Float32Array|number[]|mat4}
|
|
30
|
+
*/
|
|
31
|
+
this.matrix_world_inverse = new Float32Array(16);
|
|
18
32
|
|
|
19
33
|
/**
|
|
20
34
|
*
|
|
@@ -48,10 +62,10 @@ export class VirtualGeometryBuilder {
|
|
|
48
62
|
|
|
49
63
|
/**
|
|
50
64
|
*
|
|
51
|
-
* @type {
|
|
65
|
+
* @type {ActivePatchList}
|
|
52
66
|
* @private
|
|
53
67
|
*/
|
|
54
|
-
this.
|
|
68
|
+
this.__acl = new ActivePatchList();
|
|
55
69
|
|
|
56
70
|
/**
|
|
57
71
|
* How much error to accept when deciding to subdivide a cluster
|
|
@@ -76,12 +90,8 @@ export class VirtualGeometryBuilder {
|
|
|
76
90
|
this.__flags__enforce_dependency_splits = true;
|
|
77
91
|
}
|
|
78
92
|
|
|
79
|
-
/**
|
|
80
|
-
* Drop all cached data, forcing a complete rebuild next time
|
|
81
|
-
* Useful for testing and debugging
|
|
82
|
-
*/
|
|
83
93
|
dropCache() {
|
|
84
|
-
this.
|
|
94
|
+
this.__acl.clear();
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
/**
|
|
@@ -102,8 +112,10 @@ export class VirtualGeometryBuilder {
|
|
|
102
112
|
camera.updateMatrixWorld(true);
|
|
103
113
|
|
|
104
114
|
this.view_projection_matrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
105
|
-
|
|
106
|
-
this.
|
|
115
|
+
|
|
116
|
+
this.matrix_world_inverse.set(camera.matrixWorldInverse.elements);
|
|
117
|
+
this.matrix_projection.set(camera.projectionMatrix.elements);
|
|
118
|
+
|
|
107
119
|
this.matrix_projection_inverse.copy(camera.projectionMatrixInverse);
|
|
108
120
|
|
|
109
121
|
this.view_frustum.setFromProjectionMatrix(this.view_projection_matrix);
|
|
@@ -137,15 +149,7 @@ export class VirtualGeometryBuilder {
|
|
|
137
149
|
const micron_geometry = object.geometry;
|
|
138
150
|
if (micron_geometry !== undefined) {
|
|
139
151
|
// get acl
|
|
140
|
-
|
|
141
|
-
const acls = this.__acls;
|
|
142
|
-
|
|
143
|
-
let acl = acls.get(object);
|
|
144
|
-
|
|
145
|
-
if (acl === undefined) {
|
|
146
|
-
acl = new ActivePatchList();
|
|
147
|
-
acls.set(object, acl);
|
|
148
|
-
}
|
|
152
|
+
const acl = this.__acl;
|
|
149
153
|
|
|
150
154
|
acl.initializeFromGeometry(micron_geometry);
|
|
151
155
|
|
|
@@ -182,7 +186,7 @@ export class VirtualGeometryBuilder {
|
|
|
182
186
|
apl
|
|
183
187
|
) {
|
|
184
188
|
|
|
185
|
-
refinement_spec.build(transform, this.matrix_world_inverse, this.matrix_projection);
|
|
189
|
+
refinement_spec.build(transform.elements, this.matrix_world_inverse, this.matrix_projection);
|
|
186
190
|
|
|
187
191
|
const output = this.output;
|
|
188
192
|
|
|
@@ -2,14 +2,12 @@ import { assert } from "../../../../../core/assert.js";
|
|
|
2
2
|
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
|
-
import {
|
|
6
|
-
computeThreeTextureInternalFormatFromDataType,
|
|
7
|
-
computeThreeTextureTypeFromDataType
|
|
8
|
-
} from "../../../render/forward_plus/TextureBackedMemoryRegion.js";
|
|
9
5
|
import { DataTexture, NearestFilter } from "three";
|
|
10
|
-
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
11
6
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
12
7
|
import { compute_micron_buffer_array_constructor } from "../../build/compute_micron_buffer_array_constructor.js";
|
|
8
|
+
import { computeThreeTextureTypeFromDataType } from "../../../render/forward_plus/data/computeThreeTextureTypeFromDataType.js";
|
|
9
|
+
import { computeThreeTextureInternalFormatFromDataType } from "../../../render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js";
|
|
10
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
*
|