@woosh/meep-engine 2.33.3 → 2.33.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/bvh2/LeafNode.js +6 -1
- package/core/bvh2/aabb3/AABB3.js +21 -1
- package/core/bvh2/aabb3/aabb3_intersects_frustum.js +10 -2
- 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/RowFirstTableSpec.js +8 -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/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/MicronGeometryBufferAttributeSpec.js +1 -1
- package/engine/graphics/micron/format/MicronGeometryPatch.js +11 -3
- package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
- package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -4
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +28 -26
- package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +40 -80
- 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 +435 -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/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/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 -159
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import ThreeFactory from "../../three/ThreeFactory.js";
|
|
9
9
|
import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
|
|
10
10
|
import { composeCompile } from "../../material/composeCompile.js";
|
|
11
|
+
import { typed_array_copy } from "../../../../core/collection/array/typed/typed_array_copy.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
@@ -29,14 +30,14 @@ function InstancedMeshGroup() {
|
|
|
29
30
|
* Minimum spare capacity increase during growing
|
|
30
31
|
* @type {number}
|
|
31
32
|
*/
|
|
32
|
-
this.growConstant =
|
|
33
|
+
this.growConstant = 4;
|
|
33
34
|
|
|
34
|
-
this.shrinkFactor = 0.
|
|
35
|
+
this.shrinkFactor = 0.5;
|
|
35
36
|
/**
|
|
36
37
|
* Minimum capacity reduction for shrinkage to occur
|
|
37
38
|
* @type {number}
|
|
38
39
|
*/
|
|
39
|
-
this.shrinkConstant =
|
|
40
|
+
this.shrinkConstant = 64;
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
*
|
|
@@ -217,14 +218,30 @@ InstancedMeshGroup.prototype.setCapacity = function (size) {
|
|
|
217
218
|
* @param {number} size
|
|
218
219
|
*/
|
|
219
220
|
InstancedMeshGroup.prototype.ensureCapacity = function (size) {
|
|
221
|
+
|
|
220
222
|
const currentCapacity = this.capacity;
|
|
223
|
+
|
|
221
224
|
if (currentCapacity < size) {
|
|
222
|
-
|
|
225
|
+
// grow
|
|
226
|
+
|
|
227
|
+
const newCapacityRaw = Math.max(
|
|
228
|
+
size,
|
|
229
|
+
currentCapacity * this.growFactor,
|
|
230
|
+
currentCapacity + this.growConstant
|
|
231
|
+
);
|
|
232
|
+
|
|
223
233
|
const newCapacityInteger = Math.ceil(newCapacityRaw);
|
|
234
|
+
|
|
224
235
|
this.setCapacity(newCapacityInteger);
|
|
225
|
-
|
|
236
|
+
|
|
237
|
+
} else if (
|
|
238
|
+
currentCapacity * this.shrinkFactor > size
|
|
239
|
+
&& currentCapacity - this.shrinkConstant > size
|
|
240
|
+
) {
|
|
241
|
+
// shrink
|
|
226
242
|
this.setCapacity(size);
|
|
227
243
|
}
|
|
244
|
+
|
|
228
245
|
};
|
|
229
246
|
|
|
230
247
|
/**
|
|
@@ -375,14 +392,6 @@ InstancedMeshGroup.prototype.remove = function (reference) {
|
|
|
375
392
|
this.setCount(this.count - 1);
|
|
376
393
|
};
|
|
377
394
|
|
|
378
|
-
/**
|
|
379
|
-
* @param {Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array|Float32Array|Float64Array} source
|
|
380
|
-
* @param {Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array|Float32Array|Float64Array}target
|
|
381
|
-
*/
|
|
382
|
-
function copyArray(source, target) {
|
|
383
|
-
target.set(source.subarray(0, Math.min(target.length, source.length)), 0)
|
|
384
|
-
}
|
|
385
|
-
|
|
386
395
|
InstancedMeshGroup.prototype.build = function () {
|
|
387
396
|
if (this.__threeGeometry !== null) {
|
|
388
397
|
// dispose old geometry's GPU memory
|
|
@@ -415,16 +424,16 @@ InstancedMeshGroup.prototype.build = function () {
|
|
|
415
424
|
if (this.__attributePosition !== null) {
|
|
416
425
|
//copy old data
|
|
417
426
|
const oldPositionArray = this.__attributePosition.array;
|
|
418
|
-
|
|
427
|
+
typed_array_copy(oldPositionArray, newPositionArray);
|
|
419
428
|
}
|
|
420
429
|
if (this.__attributeRotation !== null) {
|
|
421
430
|
//copy old data
|
|
422
431
|
const oldRotationArray = this.__attributeRotation.array;
|
|
423
|
-
|
|
432
|
+
typed_array_copy(oldRotationArray, newRotationArray);
|
|
424
433
|
}
|
|
425
434
|
if (this.__attributeScale !== null) {
|
|
426
435
|
const oldScaleArray = this.__attributeScale.array;
|
|
427
|
-
|
|
436
|
+
typed_array_copy(oldScaleArray, newScaleArray);
|
|
428
437
|
|
|
429
438
|
if (newScaleArray.length > oldScaleArray.length) {
|
|
430
439
|
//fill the rest of the array with scale factor of 1 as a default
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import {
|
|
5
5
|
ClampToEdgeWrapping,
|
|
6
6
|
Color,
|
|
7
|
-
|
|
7
|
+
FrontSide,
|
|
8
8
|
GLSL3,
|
|
9
9
|
LinearFilter,
|
|
10
10
|
NormalBlending,
|
|
@@ -15,95 +15,10 @@ import {
|
|
|
15
15
|
Vector4 as ThreeVector4
|
|
16
16
|
} from 'three';
|
|
17
17
|
import TerrainShader from "../shaders/TerrainShader.js";
|
|
18
|
-
import Vector4 from "../../../core/geom/Vector4.js";
|
|
19
18
|
import { Sampler2D } from "../texture/sampler/Sampler2D.js";
|
|
20
19
|
import sampler2D2Texture from "../texture/sampler/Sampler2D2Texture.js";
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
* @param {Vector4} tex0
|
|
25
|
-
* @param {Vector4} tex1
|
|
26
|
-
* @param {Vector4} tex2
|
|
27
|
-
* @param {Vector4} tex3
|
|
28
|
-
* @param {Vector4} splat
|
|
29
|
-
* @param {Vector4} result
|
|
30
|
-
*/
|
|
31
|
-
export function blendSplatTextures(tex0, tex1, tex2, tex3, splat, result) {
|
|
32
|
-
const b0 = splat.x;
|
|
33
|
-
const b1 = splat.y;
|
|
34
|
-
const b2 = splat.z;
|
|
35
|
-
const b3 = splat.w;
|
|
36
|
-
|
|
37
|
-
const bT = b0 + b1 + b2 + b3;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
result.set(
|
|
41
|
-
(tex0.x * b0 + tex1.x * b1 + tex2.x * b2 + tex3.x * b3) / bT,
|
|
42
|
-
(tex0.y * b0 + tex1.y * b1 + tex2.y * b2 + tex3.y * b3) / bT,
|
|
43
|
-
(tex0.z * b0 + tex1.z * b1 + tex2.z * b2 + tex3.z * b3) / bT,
|
|
44
|
-
(tex0.w * b0 + tex1.w * b1 + tex2.w * b2 + tex3.w * b3) / bT
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {Sampler2D[]} diffuse
|
|
51
|
-
* @param {Vector2} diffuseRepeat
|
|
52
|
-
* @param {Sampler2D} splat
|
|
53
|
-
* @param {Vector2} gridSize
|
|
54
|
-
* @param {Vector2} resultTextureSize
|
|
55
|
-
* @returns {Sampler2D}
|
|
56
|
-
*/
|
|
57
|
-
export function buildTerrainTexture({ diffuse, diffuseRepeat, splat, gridSize, resultTextureSize }) {
|
|
58
|
-
const texture0 = diffuse[0];
|
|
59
|
-
const texture1 = diffuse[1];
|
|
60
|
-
const texture2 = diffuse[2];
|
|
61
|
-
const texture3 = diffuse[3];
|
|
62
|
-
|
|
63
|
-
const resultData = new Uint8Array(resultTextureSize.x * resultTextureSize.y * 4);
|
|
64
|
-
|
|
65
|
-
const result = new Sampler2D(resultData, 4, resultTextureSize.x, resultTextureSize.y);
|
|
66
|
-
|
|
67
|
-
//do the splatting
|
|
68
|
-
let x, y, u, v;
|
|
69
|
-
|
|
70
|
-
const tex0 = new Vector4(0, 0, 0, 0);
|
|
71
|
-
const tex1 = new Vector4(0, 0, 0, 0);
|
|
72
|
-
const tex2 = new Vector4(0, 0, 0, 0);
|
|
73
|
-
const tex3 = new Vector4(0, 0, 0, 0);
|
|
74
|
-
|
|
75
|
-
const vSplat = new Vector4(0, 0, 0, 0);
|
|
76
|
-
|
|
77
|
-
const vTemp = new Vector4(0, 0, 0, 0);
|
|
78
|
-
|
|
79
|
-
for (x = 0; x < resultTextureSize.x; x++) {
|
|
80
|
-
|
|
81
|
-
u = x / (resultTextureSize.x - 1);
|
|
82
|
-
|
|
83
|
-
for (y = 0; y < resultTextureSize.y; y++) {
|
|
84
|
-
|
|
85
|
-
v = y / (resultTextureSize.y - 1);
|
|
86
|
-
|
|
87
|
-
const dU = (u * diffuseRepeat.x) % 1;
|
|
88
|
-
const dV = (v * diffuseRepeat.y) % 1;
|
|
89
|
-
|
|
90
|
-
texture0.sample(dU, dV, tex0);
|
|
91
|
-
texture1.sample(dU, dV, tex1);
|
|
92
|
-
texture2.sample(dU, dV, tex2);
|
|
93
|
-
texture3.sample(dU, dV, tex3);
|
|
94
|
-
|
|
95
|
-
splat.sample(u, v, vSplat);
|
|
96
|
-
|
|
97
|
-
blendSplatTextures(tex0, tex1, tex2, tex3, vSplat, vTemp);
|
|
98
|
-
|
|
99
|
-
result.set(x, y, [vTemp.x, vTemp.y, vTemp.z, 255]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function whitePixelTexture() {
|
|
21
|
+
export function whitePixelTexture() {
|
|
107
22
|
const sampler = Sampler2D.uint8(4, 1, 1);
|
|
108
23
|
|
|
109
24
|
for (let i = 0; i < sampler.data.length; i++) {
|
|
@@ -205,17 +120,12 @@ export function SplatMaterial(
|
|
|
205
120
|
uniforms.gridResolution.value.set(gridResolution.x, gridResolution.y);
|
|
206
121
|
}
|
|
207
122
|
|
|
208
|
-
|
|
209
|
-
//this is for the water shader, so that back of the terrain reflects in the water, otherwise edges of shoreline look odd
|
|
210
|
-
//TODO check how this can be removed, it would speed water(and ordinary) rendering if back faces could be culled
|
|
211
|
-
const side = DoubleSide;
|
|
212
|
-
|
|
213
123
|
const sm = new ShaderMaterial({
|
|
214
124
|
|
|
215
125
|
uniforms: uniforms,
|
|
216
126
|
vertexShader: TerrainShader.vertexShader,
|
|
217
127
|
fragmentShader: TerrainShader.fragmentShader,
|
|
218
|
-
side:
|
|
128
|
+
side: FrontSide,
|
|
219
129
|
blending: NormalBlending,
|
|
220
130
|
depthTest: true,
|
|
221
131
|
depthWrite: true,
|
|
@@ -249,11 +159,8 @@ export function SplatMaterial(
|
|
|
249
159
|
sm.aoMap = true;
|
|
250
160
|
uniforms.aoMap.value = lightMap;
|
|
251
161
|
uniforms.aoMapIntensity.value = 0.7;
|
|
252
|
-
//
|
|
253
|
-
// sm.lightMap = true;
|
|
254
|
-
// uniforms.lightMap.value = options.lightMap;
|
|
255
|
-
// uniforms.lightMapIntensity.value = 1;
|
|
256
162
|
}
|
|
163
|
+
|
|
257
164
|
sm.extensions.derivatives = true; //needed for rendering grid
|
|
258
165
|
sm.needsUpdate = true;
|
|
259
166
|
|
|
@@ -4,7 +4,6 @@ import { MicronGeometry } from "../format/MicronGeometry.js";
|
|
|
4
4
|
import { buildAbstractPatchHierarchy } from "./hierarchy/buildAbstractPatchHierarchy.js";
|
|
5
5
|
import { MicronGeometryBufferAttributeSpec } from "../format/MicronGeometryBufferAttributeSpec.js";
|
|
6
6
|
import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
|
|
7
|
-
import { RowFirstTableSpec } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
8
7
|
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
9
8
|
import { MicronGeometryPatch } from "../format/MicronGeometryPatch.js";
|
|
10
9
|
import { build_clustering_info } from "./debug/build_clustering_info.js";
|
|
@@ -12,7 +11,7 @@ import { build_graph_info } from "./debug/build_graph_info.js";
|
|
|
12
11
|
import { expandConnectivityByLocality } from "../../../../core/geom/3d/topology/expandConnectivityByLocality.js";
|
|
13
12
|
import { build_geometry_info } from "./build_geometry_info.js";
|
|
14
13
|
import { build_leaf_patches_metis } from "./clustering/build_leaf_patches_metis.js";
|
|
15
|
-
import { compute_buffer_geometry_byte_size } from "
|
|
14
|
+
import { compute_buffer_geometry_byte_size } from "../../geometry/buffered/compute_buffer_geometry_byte_size.js";
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -202,11 +201,8 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
|
|
|
202
201
|
// console.time('build geometry');
|
|
203
202
|
|
|
204
203
|
const vertex_attributes = attributes_from_buffer_geometry(input);
|
|
205
|
-
const data_types = buildVertexDataTypeMap(vertex_attributes);
|
|
206
|
-
const vertex_data_spec = RowFirstTableSpec.get(data_types);
|
|
207
204
|
|
|
208
|
-
r.vertex_spec.
|
|
209
|
-
r.vertex_spec.attributes = vertex_attributes;
|
|
205
|
+
r.vertex_spec.setAttributes(vertex_attributes);
|
|
210
206
|
r.root = compilePatchGraph(root, input, r.vertex_spec);
|
|
211
207
|
|
|
212
208
|
r.initialize();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FastBinaryHeap from "../../../../navigation/grid/FastBinaryHeap.js";
|
|
2
|
-
import { mn_graph_collapse_weighted_edge } from "
|
|
3
|
-
import { build_face_graph_from_mesh } from "
|
|
2
|
+
import { mn_graph_collapse_weighted_edge } from "../../../../../core/graph/mn_graph_collapse_weighted_edge.js";
|
|
3
|
+
import { build_face_graph_from_mesh } from "../../../../../core/graph/build_face_graph_from_mesh.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cluster_mesh_metis } from "
|
|
1
|
+
import { cluster_mesh_metis } from "../../../../../core/graph/cluster_mesh_metis.js";
|
|
2
2
|
import { MICRON_PATCH_SIZE_MAX } from "../MICRON_PATCH_SIZE_MAX.js";
|
|
3
3
|
import { PatchRepresentation } from "../PatchRepresentation.js";
|
|
4
4
|
import { TopoMesh } from "../../../../../core/geom/3d/topology/TopoMesh.js";
|
|
@@ -198,6 +198,8 @@ export function fill_patch_geometry_data(result, buffer_geometry, topo, vertex_d
|
|
|
198
198
|
const micron_attributes = vertex_data_spec.attributes;
|
|
199
199
|
const attribute_count = micron_attributes.length;
|
|
200
200
|
|
|
201
|
+
//TODO create a single ArrayBuffer for all attributes to get better cache coherence for rendering
|
|
202
|
+
|
|
201
203
|
for (let i = 0; i < attribute_count; i++) {
|
|
202
204
|
const attribute_spec = micron_attributes[i];
|
|
203
205
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Graph } from "../../../../../core/graph/v2/Graph.js";
|
|
2
|
-
import { MultiNode } from "
|
|
2
|
+
import { MultiNode } from "../../../../../core/graph/MultiNode.js";
|
|
3
3
|
import { merge_patches } from "./merge_patches.js";
|
|
4
|
-
import { coarsen_graph } from "
|
|
4
|
+
import { coarsen_graph } from "../../../../../core/graph/coarsen_graph.js";
|
|
5
5
|
import { build_merge_graph } from "./build_merge_graph.js";
|
|
6
6
|
import { assign_patch_neighbours_from_topology } from "../clustering/assign_patch_neighbours_from_topology.js";
|
|
7
7
|
import { assert } from "../../../../../core/assert.js";
|
|
8
|
-
import { graph_create_off_mesh_links } from "
|
|
8
|
+
import { graph_create_off_mesh_links } from "../../../../../core/graph/build_face_graph_from_mesh.js";
|
|
9
9
|
import { build_vertex_quadratics } from "../../../../../core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -2,78 +2,6 @@ import { simplifyTopoMesh } from "../../../../../core/geom/3d/topology/simplify/
|
|
|
2
2
|
import { MICRON_PATCH_SIZE_MAX } from "../MICRON_PATCH_SIZE_MAX.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @template T
|
|
7
|
-
* @returns Set<T>
|
|
8
|
-
* @param {Set<T>} a
|
|
9
|
-
* @param {Set<T>} b
|
|
10
|
-
*/
|
|
11
|
-
export function compute_set_intersection(a, b) {
|
|
12
|
-
const result = new Set();
|
|
13
|
-
|
|
14
|
-
const a_array = Array.from(a);
|
|
15
|
-
|
|
16
|
-
const n = a_array.length;
|
|
17
|
-
for (let i = 0; i < n; i++) {
|
|
18
|
-
const t = a_array[i];
|
|
19
|
-
|
|
20
|
-
if (b.has(t)) {
|
|
21
|
-
result.add(t);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @template T
|
|
30
|
-
* @returns Set<T>
|
|
31
|
-
* @param {Set<T>} a
|
|
32
|
-
* @param {Set<T>} b
|
|
33
|
-
*/
|
|
34
|
-
export function compute_set_difference(a, b) {
|
|
35
|
-
const result = new Set();
|
|
36
|
-
|
|
37
|
-
const a_array = Array.from(a);
|
|
38
|
-
const a_count = a_array.length;
|
|
39
|
-
for (let i = 0; i < a_count; i++) {
|
|
40
|
-
const t = a_array[i];
|
|
41
|
-
|
|
42
|
-
if (!b.has(t)) {
|
|
43
|
-
result.add(t);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const b_array = Array.from(b);
|
|
48
|
-
const b_count = b_array.length;
|
|
49
|
-
for (let i = 0; i < b_count; i++) {
|
|
50
|
-
const t = b_array[i];
|
|
51
|
-
|
|
52
|
-
if (!a.has(t)) {
|
|
53
|
-
result.add(t);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @template T
|
|
63
|
-
* @param {Set<T>} a
|
|
64
|
-
* @param {Set<T>} b
|
|
65
|
-
*/
|
|
66
|
-
export function set_remove(a, b) {
|
|
67
|
-
const bs = Array.from(b);
|
|
68
|
-
|
|
69
|
-
const n = bs.length;
|
|
70
|
-
for (let i = 0; i < n; i++) {
|
|
71
|
-
const t = bs[i];
|
|
72
|
-
|
|
73
|
-
a.delete(t);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
5
|
/**
|
|
78
6
|
*
|
|
79
7
|
* @param {Set<number>} result
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Graph } from "../../../../../core/graph/v2/Graph.js";
|
|
2
|
-
import { MultiNode } from "
|
|
2
|
+
import { MultiNode } from "../../../../../core/graph/MultiNode.js";
|
|
3
3
|
import { computePatchMergeScore } from "./computePatchMergeScore.js";
|
|
4
|
-
import { WeightedEdge } from "
|
|
4
|
+
import { WeightedEdge } from "../../../../../core/graph/WeightedEdge.js";
|
|
5
5
|
import { assert } from "../../../../../core/assert.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConicRay } from "../../../../../core/geom/ConicRay.js";
|
|
2
|
-
import { compute_bounding_cone_of_2_cones } from "
|
|
2
|
+
import { compute_bounding_cone_of_2_cones } from "../../../../../core/geom/3d/compute_bounding_cone_of_2_cones.js";
|
|
3
3
|
import { compute_patches_shared_vertex_count } from "./compute_patches_shared_vertex_count.js";
|
|
4
|
-
import { compute_bounding_sphere_of_2_spheres } from "
|
|
4
|
+
import { compute_bounding_sphere_of_2_spheres } from "../../../../../core/geom/3d/compute_bounding_sphere_of_2_spheres.js";
|
|
5
5
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
6
|
import { min2 } from "../../../../../core/math/min2.js";
|
|
7
7
|
|
|
@@ -58,7 +58,7 @@ const pi_sqr = 9.86960440109;
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
*
|
|
61
|
-
* @param {number} r
|
|
61
|
+
* @param {number} r radius
|
|
62
62
|
* @return {number}
|
|
63
63
|
*/
|
|
64
64
|
function compute_sphere_volume(r) {
|
|
@@ -9,12 +9,15 @@ import { collapse_edges, extract_edge_cost } from "../../../../../core/geom/3d/t
|
|
|
9
9
|
import { build_edge_collapse_candidates } from "../../../../../core/geom/3d/topology/simplify/build_edge_collapse_candidates.js";
|
|
10
10
|
import { collapse_all_degenerate_edges } from "../../../../../core/geom/3d/topology/simplify/collapse_all_degenerate_edges.js";
|
|
11
11
|
import { deep_copy_vertex_quadratics } from "../../../../../core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js";
|
|
12
|
-
import { SquareMatrix } from "
|
|
12
|
+
import { SquareMatrix } from "../../../../../core/graph/SquareMatrix.js";
|
|
13
13
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
14
|
-
import { matrix_eigenvalues_in_place } from "
|
|
14
|
+
import { matrix_eigenvalues_in_place } from "../../../../../core/graph/eigen/eigen.js";
|
|
15
15
|
import { min2 } from "../../../../../core/math/min2.js";
|
|
16
16
|
import { PatchRepresentation } from "../PatchRepresentation.js";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
build_face_graph_from_mesh,
|
|
19
|
+
graph_create_off_mesh_links
|
|
20
|
+
} from "../../../../../core/graph/build_face_graph_from_mesh.js";
|
|
18
21
|
import { optimize_graph_partitioning_balance_detailed } from "./optimize_graph_partitioning_balance.js";
|
|
19
22
|
import { patch_build_parent } from "./patch_combine.js";
|
|
20
23
|
import { array_copy } from "../../../../../core/collection/array/copyArray.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { graph_k_means_cluster_detailed } from "
|
|
1
|
+
import { graph_k_means_cluster_detailed } from "../../../../../core/graph/graph_k_means_cluster.js";
|
|
2
2
|
import { array_remove_first } from "../../../../../core/collection/array/array_remove_first.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -4,8 +4,8 @@ import { array_copy_unique } from "../../../../../core/collection/array/array_co
|
|
|
4
4
|
import { array_remove_first } from "../../../../../core/collection/array/array_remove_first.js";
|
|
5
5
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
6
|
import { array_push_if_unique } from "../../../../../core/collection/array/array_push_if_unique.js";
|
|
7
|
-
import { compute_bounding_sphere_of_2_spheres } from "
|
|
8
|
-
import { compute_bounding_cone_of_2_cones } from "
|
|
7
|
+
import { compute_bounding_sphere_of_2_spheres } from "../../../../../core/geom/3d/compute_bounding_sphere_of_2_spheres.js";
|
|
8
|
+
import { compute_bounding_cone_of_2_cones } from "../../../../../core/geom/3d/compute_bounding_cone_of_2_cones.js";
|
|
9
9
|
import { ConicRay } from "../../../../../core/geom/ConicRay.js";
|
|
10
10
|
import { passThrough } from "../../../../../core/function/Functions.js";
|
|
11
11
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { array_push_if_unique } from "../../../../../core/collection/array/array_push_if_unique.js";
|
|
2
2
|
import FastBinaryHeap from "../../../../navigation/grid/FastBinaryHeap.js";
|
|
3
3
|
import { build_vertex_quadratics } from "../../../../../core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js";
|
|
4
|
-
import {
|
|
4
|
+
import { compute_set_of_border_vertex_indices } from "./build_intermediate_patch_topology.js";
|
|
5
5
|
import { compute_patches_shared_vertices } from "./compute_patches_shared_vertices.js";
|
|
6
6
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
7
7
|
import { MICRON_PATCH_SIZE_MAX } from "../MICRON_PATCH_SIZE_MAX.js";
|
|
8
8
|
import { collapse_edges, extract_edge_cost } from "../../../../../core/geom/3d/topology/simplify/simplifyTopoMesh.js";
|
|
9
9
|
import { build_edge_collapse_candidates } from "../../../../../core/geom/3d/topology/simplify/build_edge_collapse_candidates.js";
|
|
10
10
|
import { collapse_all_degenerate_edges } from "../../../../../core/geom/3d/topology/simplify/collapse_all_degenerate_edges.js";
|
|
11
|
+
import { compute_set_intersection } from "../../../../../core/collection/set/compute_set_intersection.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Cluster must share at least this many vertices for the vertex boundary constraint to be relaxed and allow them to be made dependent on each other
|
|
@@ -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,30 @@ 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);
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
*
|
|
24
31
|
* @type {number[]|Float32Array}
|
|
25
32
|
*/
|
|
26
|
-
this.group_bounding_box = new Float32Array(6);
|
|
33
|
+
this.group_bounding_box = new Float32Array(array_buffer, 6 * 4, 6);
|
|
34
|
+
|
|
27
35
|
/**
|
|
28
36
|
*
|
|
29
37
|
* @type {number[]|Float32Array}
|
|
30
38
|
*/
|
|
31
|
-
this.group_bounding_box_corners = new Float32Array(24);
|
|
39
|
+
this.group_bounding_box_corners = new Float32Array(array_buffer, 12 * 4, 24);
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
*
|
|
@@ -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
|
|
@@ -456,14 +456,14 @@ function init() {
|
|
|
456
456
|
|
|
457
457
|
// sample_gltf_sponza();
|
|
458
458
|
// sample_gltf_rts_factory();
|
|
459
|
-
|
|
459
|
+
sample_lucy();
|
|
460
460
|
// sample_gltf_hapro_2();
|
|
461
461
|
// sample_gltf_hapro_1();
|
|
462
462
|
// sample_gltf_broken_isiflow();
|
|
463
463
|
// gltf_grid('data/models/moicon/Kople/EVCharger1.gltf');
|
|
464
464
|
// gltf_grid('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
|
|
465
|
-
gltf_sample('data/models/moicon/08-clickable-assets/model.gltf');
|
|
466
|
-
gltf_sample('data/models/moicon/05-ground-floor/model.gltf');
|
|
465
|
+
// gltf_sample('data/models/moicon/08-clickable-assets/model.gltf');
|
|
466
|
+
// gltf_sample('data/models/moicon/05-ground-floor/model.gltf');
|
|
467
467
|
// gltf_sample('data/models/moicon/isiflow_Oct_15_21/0/model.gltf');
|
|
468
468
|
|
|
469
469
|
document.addEventListener("mousemove", onDocumentMouseMove);
|
|
@@ -535,7 +535,7 @@ function createScene(geometry, m1, scale) {
|
|
|
535
535
|
geometry.computeVertexNormals();
|
|
536
536
|
|
|
537
537
|
|
|
538
|
-
const grid_size =
|
|
538
|
+
const grid_size = 100;
|
|
539
539
|
const grid_spacing = 2000;
|
|
540
540
|
|
|
541
541
|
for (let i = 0; i < grid_size; i++) {
|