@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const scratch_aabb = new Float32Array(4);
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* NOTE: tends to overestimate the area
|
|
6
|
+
* @param {number[]} aabb
|
|
7
|
+
* @param {number[]} matrix
|
|
8
|
+
* @return {number}
|
|
9
|
+
*/
|
|
10
|
+
export function aabb3_estimate_projected_area2(aabb, matrix) {
|
|
11
|
+
// extract translation from matrix
|
|
12
|
+
scratch_aabb[0] = scratch_aabb[2] = matrix[12];
|
|
13
|
+
scratch_aabb[1] = scratch_aabb[3] = matrix[13];
|
|
14
|
+
|
|
15
|
+
// apply 3x3 matrix transform
|
|
16
|
+
for (let i = 0; i < 2; i++) {
|
|
17
|
+
for (let j = 0; j < 3; j++) {
|
|
18
|
+
|
|
19
|
+
const m_a = i * 4 + j;
|
|
20
|
+
const m_v = matrix[m_a];
|
|
21
|
+
|
|
22
|
+
const a = m_v * aabb[j];
|
|
23
|
+
const b = m_v * aabb[j + 3];
|
|
24
|
+
|
|
25
|
+
if (a < b) {
|
|
26
|
+
scratch_aabb[i] += a;
|
|
27
|
+
scratch_aabb[i + 2] += b;
|
|
28
|
+
} else {
|
|
29
|
+
scratch_aabb[i] += b;
|
|
30
|
+
scratch_aabb[i + 2] += a;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const x1 = scratch_aabb[2];
|
|
37
|
+
const x0 = scratch_aabb[0];
|
|
38
|
+
|
|
39
|
+
const dx = x1 - x0;
|
|
40
|
+
|
|
41
|
+
const y1 = scratch_aabb[3];
|
|
42
|
+
const y0 = scratch_aabb[1];
|
|
43
|
+
|
|
44
|
+
const dy = y1 - y0;
|
|
45
|
+
const a = dx * dy;
|
|
46
|
+
|
|
47
|
+
const cx = (aabb[0] + aabb[3]) * 0.5;
|
|
48
|
+
const cy = (aabb[1] + aabb[4]) * 0.5;
|
|
49
|
+
const cz = (aabb[2] + aabb[5]) * 0.5;
|
|
50
|
+
|
|
51
|
+
/* compute W projection value, using conservative estimate
|
|
52
|
+
@see https://twitter.com/SebAaltonen/status/1332332808979832832
|
|
53
|
+
@see https://gist.github.com/slembcke/b2b2af4dede1d5702a635dc2d0e45d54
|
|
54
|
+
*/
|
|
55
|
+
const w = matrix[3] * cx + matrix[7] * cy + matrix[11] * cz + matrix[15];
|
|
56
|
+
const d = 0.5 / Math.abs(w);
|
|
57
|
+
|
|
58
|
+
return a * d * d;
|
|
59
|
+
}
|
|
@@ -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,33 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* NOTE: Based on Transforming Axis-Aligned Bounding Boxes by Jim Arvo from "Graphics Gems", Academic Press, 1990
|
|
4
|
+
* @param {number[]} result
|
|
5
|
+
* @param {number[]} aabb
|
|
6
|
+
* @param {number[]} matrix 4x4 matrix
|
|
7
|
+
*/
|
|
8
|
+
export function aabb3_matrix4_project(result, aabb, matrix) {
|
|
9
|
+
// extract translation from matrix
|
|
10
|
+
result[0] = result[3] = matrix[12];
|
|
11
|
+
result[1] = result[4] = matrix[13];
|
|
12
|
+
result[2] = result[5] = matrix[14];
|
|
13
|
+
|
|
14
|
+
// apply 3x3 matrix transform
|
|
15
|
+
for (let i = 0; i < 3; i++) {
|
|
16
|
+
for (let j = 0; j < 3; j++) {
|
|
17
|
+
|
|
18
|
+
const m_a = i * 4 + j;
|
|
19
|
+
const m_v = matrix[m_a];
|
|
20
|
+
|
|
21
|
+
const a = m_v * aabb[j];
|
|
22
|
+
const b = m_v * aabb[j + 3];
|
|
23
|
+
|
|
24
|
+
if (a < b) {
|
|
25
|
+
result[i] += a;
|
|
26
|
+
result[i + 3] += b;
|
|
27
|
+
} else {
|
|
28
|
+
result[i] += b;
|
|
29
|
+
result[i + 3] += a;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { aabb3_matrix4_project } from "./aabb3_matrix4_project.js";
|
|
2
|
+
|
|
3
|
+
test('identity', () => {
|
|
4
|
+
const r = [];
|
|
5
|
+
|
|
6
|
+
aabb3_matrix4_project(r, [1, 2, 3, 5, 7, 9], [
|
|
7
|
+
1, 0, 0, 0,
|
|
8
|
+
0, 1, 0, 0,
|
|
9
|
+
0, 0, 1, 0,
|
|
10
|
+
0, 0, 0, 1
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
expect(r).toEqual([1, 2, 3, 5, 7, 9]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('translation case', () => {
|
|
17
|
+
const r = [];
|
|
18
|
+
|
|
19
|
+
aabb3_matrix4_project(r, [1, 2, 3, 5, 7, 9], [
|
|
20
|
+
1, 0, 0, 0,
|
|
21
|
+
0, 1, 0, 0,
|
|
22
|
+
0, 0, 1, 0,
|
|
23
|
+
13, -17, 23, 1
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
expect(r).toEqual([14, -15, 26, 18, -10, 32]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
test('scale case', () => {
|
|
31
|
+
const r = [];
|
|
32
|
+
|
|
33
|
+
aabb3_matrix4_project(r, [1, 2, 3, 5, 7, 9], [
|
|
34
|
+
-1, 0, 0, 0,
|
|
35
|
+
0, 2, 0, 0,
|
|
36
|
+
0, 0, -3, 0,
|
|
37
|
+
0, 0, 0, 1
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
expect(r).toEqual([-5, 4, -27, -1, 14, -9]);
|
|
41
|
+
});
|
|
@@ -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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { v3_length } from "../../Vector3.d.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalize a plane in-place
|
|
5
|
+
* @param {number[]} source
|
|
6
|
+
* @param {number} source_offset
|
|
7
|
+
*/
|
|
8
|
+
function array_normalize_plane(source, source_offset) {
|
|
9
|
+
const _x = source[source_offset];
|
|
10
|
+
const _y = source[source_offset + 1];
|
|
11
|
+
const _z = source[source_offset + 2];
|
|
12
|
+
|
|
13
|
+
const length = v3_length(_x, _y, _z);
|
|
14
|
+
|
|
15
|
+
const inverseNormalLength = 1.0 / length;
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
By re-using values already in the registers instead of using *= we save a few extra READ ops
|
|
19
|
+
*/
|
|
20
|
+
source[source_offset] = _x * inverseNormalLength;
|
|
21
|
+
source[source_offset + 1] = _y * inverseNormalLength;
|
|
22
|
+
source[source_offset + 2] = _z * inverseNormalLength;
|
|
23
|
+
|
|
24
|
+
source[source_offset + 3] *= inverseNormalLength;
|
|
25
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { v3_length } from "../../Vector3.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} destination
|
|
6
|
+
* @param {number} destination_offset
|
|
7
|
+
* @param {number} x
|
|
8
|
+
* @param {number} y
|
|
9
|
+
* @param {number} z
|
|
10
|
+
* @param {number} w
|
|
11
|
+
*/
|
|
12
|
+
function array_set_plane_normalized(destination, destination_offset, x, y, z, w) {
|
|
13
|
+
const length = v3_length(x, y, z);
|
|
14
|
+
|
|
15
|
+
const inverseNormalLength = 1.0 / length;
|
|
16
|
+
|
|
17
|
+
destination[destination_offset] = x * inverseNormalLength;
|
|
18
|
+
destination[destination_offset + 1] = y * inverseNormalLength;
|
|
19
|
+
destination[destination_offset + 2] = z * inverseNormalLength;
|
|
20
|
+
destination[destination_offset + 3] = w * inverseNormalLength;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Set frustum from projection matrix
|
|
25
|
+
* @param {number[]|Float32Array} frustum_planes
|
|
26
|
+
* @param {number[]} me
|
|
27
|
+
*/
|
|
28
|
+
export function array_setFromProjectionMatrix(frustum_planes, me) {
|
|
29
|
+
|
|
30
|
+
const me0 = me[0];
|
|
31
|
+
const me3 = me[3];
|
|
32
|
+
|
|
33
|
+
const me4 = me[4];
|
|
34
|
+
const me7 = me[7];
|
|
35
|
+
|
|
36
|
+
const me8 = me[8];
|
|
37
|
+
const me11 = me[11];
|
|
38
|
+
|
|
39
|
+
const me12 = me[12];
|
|
40
|
+
const me15 = me[15];
|
|
41
|
+
|
|
42
|
+
array_set_plane_normalized(frustum_planes, 0, me3 - me0, me7 - me4, me11 - me8, me15 - me12);
|
|
43
|
+
array_set_plane_normalized(frustum_planes, 4, me3 + me0, me7 + me4, me11 + me8, me15 + me12);
|
|
44
|
+
|
|
45
|
+
const me1 = me[1];
|
|
46
|
+
const me5 = me[5];
|
|
47
|
+
const me9 = me[9];
|
|
48
|
+
const me13 = me[13];
|
|
49
|
+
|
|
50
|
+
array_set_plane_normalized(frustum_planes, 8, me3 + me1, me7 + me5, me11 + me9, me15 + me13);
|
|
51
|
+
array_set_plane_normalized(frustum_planes, 12, me3 - me1, me7 - me5, me11 - me9, me15 - me13);
|
|
52
|
+
|
|
53
|
+
const me2 = me[2];
|
|
54
|
+
const me6 = me[6];
|
|
55
|
+
const me10 = me[10];
|
|
56
|
+
const me14 = me[14];
|
|
57
|
+
|
|
58
|
+
array_set_plane_normalized(frustum_planes, 16, me3 - me2, me7 - me6, me11 - me10, me15 - me14);
|
|
59
|
+
array_set_plane_normalized(frustum_planes, 20, me3 + me2, me7 + me6, me11 + me10, me15 + me14);
|
|
60
|
+
}
|
|
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
|
|
@@ -202,6 +202,64 @@ export class ActionProcessor {
|
|
|
202
202
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Navigate to a specific mark back or forward
|
|
207
|
+
* @param {M} mark_descriptor specific mark description
|
|
208
|
+
* @returns {boolean} true on success, false otherwise (e.g. mark not found)
|
|
209
|
+
* @throws {Error} when mark is non-unique
|
|
210
|
+
*/
|
|
211
|
+
navigateTo(mark_descriptor) {
|
|
212
|
+
// find all matching marks
|
|
213
|
+
const matching_marks = this.marks.filter(m => m.description === mark_descriptor);
|
|
214
|
+
|
|
215
|
+
if (matching_marks.length === 0) {
|
|
216
|
+
// not found
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (matching_marks.length > 1) {
|
|
221
|
+
throw new Error(`Attempting to navigate to a non-unique mark descriptor '${mark_descriptor}'. Mark descriptor must be unique, instead ${matching_marks.length} matches were found`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const match = matching_marks[0];
|
|
225
|
+
|
|
226
|
+
const target = match.index;
|
|
227
|
+
|
|
228
|
+
let temp_cursor = this.cursor;
|
|
229
|
+
|
|
230
|
+
if (target > this.cursor) {
|
|
231
|
+
|
|
232
|
+
while (target > this.cursor) {
|
|
233
|
+
// navigate forward
|
|
234
|
+
this.redo();
|
|
235
|
+
|
|
236
|
+
if (temp_cursor === this.cursor) {
|
|
237
|
+
// no cursor change
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
temp_cursor = this.cursor;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
} else if (target < this.cursor) {
|
|
245
|
+
|
|
246
|
+
while (target < this.cursor) {
|
|
247
|
+
// navigate backwards
|
|
248
|
+
this.undo();
|
|
249
|
+
|
|
250
|
+
if (temp_cursor === this.cursor) {
|
|
251
|
+
// no cursor change
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
temp_cursor = this.cursor;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
|
|
205
263
|
undo() {
|
|
206
264
|
let markAddress = 0;
|
|
207
265
|
/**
|
|
@@ -226,7 +284,7 @@ export class ActionProcessor {
|
|
|
226
284
|
markAddress = 0;
|
|
227
285
|
}
|
|
228
286
|
|
|
229
|
-
//keep rewinding until we hit mark
|
|
287
|
+
//keep rewinding until we hit a mark
|
|
230
288
|
while (this.cursor > markAddress && this.cursor > 0) {
|
|
231
289
|
this.cursor--;
|
|
232
290
|
const action = this.history.get(this.cursor);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ActionProcessor } from "./ActionProcessor.js";
|
|
2
|
+
import { Action } from "./Action.js";
|
|
3
|
+
|
|
4
|
+
class DummyContext {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.value = 0;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class DummyAction extends Action {
|
|
11
|
+
apply(context) {
|
|
12
|
+
// do nothing
|
|
13
|
+
context.value++;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
revert(context) {
|
|
17
|
+
context.value--;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test('navigateTo backwards', () => {
|
|
22
|
+
const ctx = new DummyContext();
|
|
23
|
+
const ap = new ActionProcessor(ctx);
|
|
24
|
+
|
|
25
|
+
ap.mark('a');
|
|
26
|
+
ap.do(new DummyAction());
|
|
27
|
+
ap.mark('b');
|
|
28
|
+
ap.do(new DummyAction());
|
|
29
|
+
|
|
30
|
+
expect(ap.navigateTo('a')).toBe(true);
|
|
31
|
+
|
|
32
|
+
expect(ctx.value).toBe(0);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('navigateTo forward', () => {
|
|
36
|
+
const ctx = new DummyContext();
|
|
37
|
+
const ap = new ActionProcessor(ctx);
|
|
38
|
+
|
|
39
|
+
ap.mark('a');
|
|
40
|
+
ap.do(new DummyAction());
|
|
41
|
+
ap.mark('b');
|
|
42
|
+
ap.do(new DummyAction());
|
|
43
|
+
ap.mark('c');
|
|
44
|
+
|
|
45
|
+
ap.undo();
|
|
46
|
+
ap.undo();
|
|
47
|
+
ap.undo();
|
|
48
|
+
|
|
49
|
+
expect(ap.navigateTo('c')).toBe(true);
|
|
50
|
+
|
|
51
|
+
expect(ctx.value).toBe(2);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('navigateTo non-existent on empty', () => {
|
|
55
|
+
const ctx = new DummyContext();
|
|
56
|
+
const ap = new ActionProcessor(ctx);
|
|
57
|
+
|
|
58
|
+
expect(ap.navigateTo('a')).toBe(false);
|
|
59
|
+
});
|