@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
|
@@ -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
|
|
|
@@ -256,9 +260,7 @@ export class VirtualGeometryBuilder {
|
|
|
256
260
|
|
|
257
261
|
const resolution = this.resolution;
|
|
258
262
|
|
|
259
|
-
refinement_spec.resolution.
|
|
260
|
-
|
|
261
|
-
refinement_spec.viewport_area = resolution.x * resolution.y;
|
|
263
|
+
refinement_spec.setResolution(resolution.x, resolution.y);
|
|
262
264
|
|
|
263
265
|
// clear output
|
|
264
266
|
this.output.clear();
|
|
@@ -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
6
|
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
11
7
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
12
8
|
import { compute_micron_buffer_array_constructor } from "../../build/compute_micron_buffer_array_constructor.js";
|
|
9
|
+
import { computeThreeTextureTypeFromDataType } from "../../../render/forward_plus/data/computeThreeTextureTypeFromDataType.js";
|
|
10
|
+
import { computeThreeTextureInternalFormatFromDataType } from "../../../render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
*
|
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
import { ActivePatchRecord } from "./ActivePatchRecord.js";
|
|
2
2
|
import { ActivePatchFlags } from "./ActivePatchFlags.js";
|
|
3
3
|
import { aabb3_project_to_2d } from "../../../../../core/geom/3d/aabb/aabb3_compute_projected_area.js";
|
|
4
|
-
import { approximateTriangleArea } from "../approximateTriangleArea.js";
|
|
5
4
|
import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
6
5
|
import { aabb3_intersects_frustum } from "../../../../../core/bvh2/aabb3/aabb3_intersects_frustum.js";
|
|
7
6
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {number[]|Float32Array} bounding_box_corners
|
|
11
|
-
* @param {RefinementSpec} spec
|
|
12
|
-
* @returns {number}
|
|
13
|
-
*/
|
|
14
|
-
function compute_projected_area(bounding_box_corners, spec) {
|
|
15
|
-
// Cull by screen area
|
|
16
|
-
const normalized_screen_area = aabb3_project_to_2d(bounding_box_corners, spec.projection_matrix);
|
|
17
|
-
|
|
18
|
-
const patch_screen_area = normalized_screen_area * spec.viewport_area;
|
|
19
|
-
|
|
20
|
-
return patch_screen_area;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
7
|
export class ActivePatchList {
|
|
24
8
|
constructor() {
|
|
25
9
|
/**
|
|
@@ -39,6 +23,19 @@ export class ActivePatchList {
|
|
|
39
23
|
* @type {BitSet}
|
|
40
24
|
*/
|
|
41
25
|
this.unfolded = new BitSet();
|
|
26
|
+
|
|
27
|
+
// prevent re-allocation related thrashing
|
|
28
|
+
this.unfolded.preventShrink();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
clear() {
|
|
32
|
+
const unfolded = this.unfolded;
|
|
33
|
+
|
|
34
|
+
unfolded.reset();
|
|
35
|
+
|
|
36
|
+
ActivePatchRecord.pool_release_all(this.records);
|
|
37
|
+
|
|
38
|
+
this.records = null;
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
/**
|
|
@@ -46,14 +43,15 @@ export class ActivePatchList {
|
|
|
46
43
|
* @param {MicronGeometry} geometry
|
|
47
44
|
*/
|
|
48
45
|
initializeFromGeometry(geometry) {
|
|
49
|
-
|
|
46
|
+
this.clear();
|
|
47
|
+
|
|
48
|
+
const record = ActivePatchRecord.pool_get();
|
|
50
49
|
|
|
50
|
+
record.patch = geometry.root;
|
|
51
51
|
record.link_next = null;
|
|
52
52
|
record.link_previous = null;
|
|
53
53
|
|
|
54
54
|
const unfolded = this.unfolded;
|
|
55
|
-
|
|
56
|
-
unfolded.reset();
|
|
57
55
|
unfolded.set(record.patch.id, true);
|
|
58
56
|
|
|
59
57
|
this.records = record;
|
|
@@ -62,6 +60,7 @@ export class ActivePatchList {
|
|
|
62
60
|
/**
|
|
63
61
|
*
|
|
64
62
|
* @param {ActivePatchRecord} record
|
|
63
|
+
* @returns {ActivePatchRecord}
|
|
65
64
|
*/
|
|
66
65
|
node_split(record) {
|
|
67
66
|
|
|
@@ -74,19 +73,24 @@ export class ActivePatchList {
|
|
|
74
73
|
|
|
75
74
|
const child_id = child.id;
|
|
76
75
|
|
|
77
|
-
if (unfolded.
|
|
76
|
+
if (unfolded.getAndSet(child_id)) {
|
|
78
77
|
// already unfolded, skip
|
|
79
78
|
continue;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
const child_record = ActivePatchRecord.
|
|
81
|
+
const child_record = ActivePatchRecord.pool_get();
|
|
82
|
+
child_record.patch = child;
|
|
83
83
|
|
|
84
84
|
this.record_insert_after(record, child_record);
|
|
85
|
-
|
|
86
|
-
unfolded.set(child_id, true);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
this.record_remove(record);
|
|
88
|
+
|
|
89
|
+
const next = record.link_next;
|
|
90
|
+
|
|
91
|
+
ActivePatchRecord.pool_release(record);
|
|
92
|
+
|
|
93
|
+
return next;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
/**
|
|
@@ -150,36 +154,6 @@ export class ActivePatchList {
|
|
|
150
154
|
this.record_remove(b);
|
|
151
155
|
}
|
|
152
156
|
|
|
153
|
-
/**
|
|
154
|
-
*
|
|
155
|
-
* @param {ActivePatchRecord} record
|
|
156
|
-
* @param {RefinementSpec} spec
|
|
157
|
-
*/
|
|
158
|
-
node_try_merge(record, spec) {
|
|
159
|
-
const next = record.link_next;
|
|
160
|
-
if (next === null) {
|
|
161
|
-
// no next record
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return;
|
|
166
|
-
|
|
167
|
-
const parent = record.patch.parent;
|
|
168
|
-
|
|
169
|
-
if (parent !== next.patch.parent) {
|
|
170
|
-
// not a sibling
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const patch_screen_area = compute_projected_area(parent.bounding_box, spec);
|
|
175
|
-
|
|
176
|
-
const approximate_triangle_area = patch_screen_area * approximateTriangleArea(parent);
|
|
177
|
-
|
|
178
|
-
if (approximate_triangle_area <= spec.error_threshold) {
|
|
179
|
-
this.node_merge(record, next);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
}
|
|
183
157
|
|
|
184
158
|
/**
|
|
185
159
|
* Populate with LOD-X of a given geometry
|
|
@@ -210,7 +184,13 @@ export class ActivePatchList {
|
|
|
210
184
|
*/
|
|
211
185
|
refine(spec) {
|
|
212
186
|
|
|
213
|
-
|
|
187
|
+
const frustum_planes = spec.frustum_f32;
|
|
188
|
+
const projection_matrix = spec.projection_matrix;
|
|
189
|
+
const error_threshold = spec.error_threshold_normalized;
|
|
190
|
+
|
|
191
|
+
let record = this.records
|
|
192
|
+
|
|
193
|
+
for (; record !== null;) {
|
|
214
194
|
|
|
215
195
|
const node = record.patch;
|
|
216
196
|
|
|
@@ -221,32 +201,17 @@ export class ActivePatchList {
|
|
|
221
201
|
check if node is in view frustum
|
|
222
202
|
NOTE: following suggestion in "FastMesh: Efficient View-dependent Meshing" by Renato Pajarola et al, we can do a more coarse frustum test approximating frustum as a cone initially
|
|
223
203
|
*/
|
|
224
|
-
const
|
|
225
|
-
const in_view_frustum = aabb3_intersects_frustum(bounding_box, spec.frustum_f32);
|
|
204
|
+
const in_view_frustum = aabb3_intersects_frustum(node.bounding_box, frustum_planes);
|
|
226
205
|
|
|
227
206
|
if (!in_view_frustum) {
|
|
228
207
|
// outside of view frustum, cull
|
|
229
208
|
if (prev_is_visible) {
|
|
230
209
|
record.clearFlag(ActivePatchFlags.Visible);
|
|
231
210
|
}
|
|
211
|
+
record = record.link_next;
|
|
232
212
|
continue;
|
|
233
213
|
}
|
|
234
214
|
|
|
235
|
-
// compute projected bounds of the patch
|
|
236
|
-
// const patch_screen_area = compute_projected_area(bounding_box, spec);
|
|
237
|
-
|
|
238
|
-
// const patch_is_too_small_to_be_seen = patch_screen_area < spec.error_threshold;
|
|
239
|
-
//
|
|
240
|
-
// if (patch_is_too_small_to_be_seen) {
|
|
241
|
-
// // the whole patch is too small, cull
|
|
242
|
-
// if (prev_is_visible) {
|
|
243
|
-
// record.clearFlag(ActivePatchFlags.Visible);
|
|
244
|
-
// }
|
|
245
|
-
//
|
|
246
|
-
// // try to merge with sibling
|
|
247
|
-
// continue;
|
|
248
|
-
// }
|
|
249
|
-
|
|
250
215
|
if (!prev_is_visible) {
|
|
251
216
|
record.setFlag(ActivePatchFlags.Visible);
|
|
252
217
|
}
|
|
@@ -264,22 +229,17 @@ export class ActivePatchList {
|
|
|
264
229
|
// not the lowest level of LOD, see if subdivision might be necessary
|
|
265
230
|
|
|
266
231
|
// compute average triangle area
|
|
267
|
-
const group_screen_area =
|
|
232
|
+
const group_screen_area = aabb3_project_to_2d(node.group_bounding_box_corners, projection_matrix);
|
|
268
233
|
const screen_space_error = node.group_error * group_screen_area;
|
|
269
234
|
|
|
270
|
-
|
|
271
|
-
if (screen_space_error > spec.error_threshold) {
|
|
235
|
+
if (screen_space_error > error_threshold) {
|
|
272
236
|
// error too large, needs to be split
|
|
273
|
-
this.node_split(record);
|
|
237
|
+
record = this.node_split(record);
|
|
274
238
|
continue;
|
|
275
239
|
}
|
|
276
240
|
}
|
|
277
241
|
|
|
278
|
-
|
|
279
|
-
// check if record and its sibling can be merged
|
|
280
|
-
// if (approximate_triangle_area < spec.error_threshold) {
|
|
281
|
-
// this.node_try_merge(record, spec);
|
|
282
|
-
// }
|
|
242
|
+
record = record.link_next;
|
|
283
243
|
}
|
|
284
244
|
}
|
|
285
245
|
}
|
|
@@ -60,8 +60,6 @@ export class ActivePatchRecord {
|
|
|
60
60
|
patch_pool_size--;
|
|
61
61
|
|
|
62
62
|
// reset record
|
|
63
|
-
r.link_next = null;
|
|
64
|
-
|
|
65
63
|
r.flags = 0;
|
|
66
64
|
|
|
67
65
|
return r;
|
|
@@ -91,6 +89,10 @@ export class ActivePatchRecord {
|
|
|
91
89
|
* @param {ActivePatchRecord} r
|
|
92
90
|
*/
|
|
93
91
|
static pool_release_all(r) {
|
|
92
|
+
if (r === null) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
94
96
|
let p = r;
|
|
95
97
|
|
|
96
98
|
for (; patch_pool_size < patch_limit;) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
2
|
+
import { mat4 } from "gl-matrix";
|
|
3
|
+
import { array_setFromProjectionMatrix } from "../../../../../core/geom/3d/frustum/array_setFromProjectionMatrix.js";
|
|
4
|
+
|
|
5
|
+
export class RefinementSpec {
|
|
6
|
+
constructor() {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Viewport resolution
|
|
10
|
+
* @type {Vector2}
|
|
11
|
+
*/
|
|
12
|
+
this.resolution = new Vector2();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Number of pixels in the viewport
|
|
16
|
+
* @type {number}
|
|
17
|
+
*/
|
|
18
|
+
this.viewport_area = 0;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* How much error to accept when deciding to subdivide a cluster
|
|
22
|
+
* Measured in pixels
|
|
23
|
+
* Higher value will result in better performance but more visible artifacts
|
|
24
|
+
* @type {number}
|
|
25
|
+
*/
|
|
26
|
+
this.error_threshold = 1;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Error threshold as a fraction of the screen area instead of pixels, derived internally from pixel value
|
|
30
|
+
* @type {number}
|
|
31
|
+
*/
|
|
32
|
+
this.error_threshold_normalized = 1;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Continuous memory region for faster access
|
|
36
|
+
* @type {ArrayBuffer}
|
|
37
|
+
*/
|
|
38
|
+
const array_buffer = new ArrayBuffer(160);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Object-space camera frustum
|
|
42
|
+
* Frustum planes in compact form
|
|
43
|
+
* @type {Float32Array}
|
|
44
|
+
*/
|
|
45
|
+
this.frustum_f32 = new Float32Array(array_buffer, 0, 24);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Contains transformation from camera space to object space
|
|
50
|
+
* @type {Float32Array|number[]|mat4}
|
|
51
|
+
*/
|
|
52
|
+
this.projection_matrix = new Float32Array(array_buffer, 24 * 4, 16);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Model world transform
|
|
56
|
+
* @type {Float32Array|number[]|mat4}
|
|
57
|
+
*/
|
|
58
|
+
// this.transform = new Float32Array(16);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Object-space camera position
|
|
62
|
+
* @type {Float32Array}
|
|
63
|
+
*/
|
|
64
|
+
this.view_position = new Float32Array(3);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get frustum() {
|
|
68
|
+
throw new Error('deprecated, use .frustum_f32 instead');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setResolution(x, y) {
|
|
72
|
+
this.resolution.set(x, y);
|
|
73
|
+
|
|
74
|
+
this.viewport_area = x * y;
|
|
75
|
+
|
|
76
|
+
this.error_threshold_normalized = this.error_threshold / this.viewport_area;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {number[]|mat4|Float32Array|ArrayLike<number>} transform world-space object transform
|
|
82
|
+
* @param {number[]|mat4|Float32Array|ArrayLike<number>} matrix_world_inverse camera's world inverse matrix
|
|
83
|
+
* @param {number[]|mat4|Float32Array|ArrayLike<number>} matrix_projection camera's projection matrix
|
|
84
|
+
*/
|
|
85
|
+
build(transform, matrix_world_inverse, matrix_projection) {
|
|
86
|
+
// const _transform = this.transform;
|
|
87
|
+
// _transform.set(transform);
|
|
88
|
+
|
|
89
|
+
// build projection matrix
|
|
90
|
+
const projection_matrix = this.projection_matrix;
|
|
91
|
+
|
|
92
|
+
mat4.multiply(projection_matrix, matrix_world_inverse, transform);
|
|
93
|
+
mat4.multiply(projection_matrix, matrix_projection, projection_matrix);
|
|
94
|
+
|
|
95
|
+
// compute view frustum in model-space
|
|
96
|
+
array_setFromProjectionMatrix(this.frustum_f32, projection_matrix);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -12,6 +12,27 @@ export class MaterialVertexSpec {
|
|
|
12
12
|
this.material = null;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {MaterialVertexSpec} other
|
|
18
|
+
*/
|
|
19
|
+
copy(other) {
|
|
20
|
+
this.spec = other.spec;
|
|
21
|
+
this.material = other.material;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @return {MaterialVertexSpec}
|
|
27
|
+
*/
|
|
28
|
+
clone() {
|
|
29
|
+
const r = new MaterialVertexSpec();
|
|
30
|
+
|
|
31
|
+
r.copy(this);
|
|
32
|
+
|
|
33
|
+
return r;
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
/**
|
|
16
37
|
* @param {MicronVertexDataSpec} spec
|
|
17
38
|
* @param {Material} material
|
|
@@ -7,6 +7,12 @@ import { HashMap } from "../../../../../core/collection/HashMap.js";
|
|
|
7
7
|
import Signal from "../../../../../core/events/signal/Signal.js";
|
|
8
8
|
import { array_copy } from "../../../../../core/collection/array/copyArray.js";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {MaterialVertexSpec}
|
|
13
|
+
*/
|
|
14
|
+
const scratch_mvc = new MaterialVertexSpec();
|
|
15
|
+
|
|
10
16
|
export class VGThreeRenderer {
|
|
11
17
|
constructor() {
|
|
12
18
|
this.geometry = new VirtualGeometry();
|
|
@@ -32,13 +38,6 @@ export class VGThreeRenderer {
|
|
|
32
38
|
*/
|
|
33
39
|
this.__contexts_array = [];
|
|
34
40
|
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @type {Scene|null}
|
|
38
|
-
* @private
|
|
39
|
-
*/
|
|
40
|
-
this.__scene = null;
|
|
41
|
-
|
|
42
41
|
/**
|
|
43
42
|
*
|
|
44
43
|
* @type {Object3D[]}
|
|
@@ -75,14 +74,18 @@ export class VGThreeRenderer {
|
|
|
75
74
|
* @private
|
|
76
75
|
*/
|
|
77
76
|
__obtain_material(spec, m) {
|
|
78
|
-
|
|
77
|
+
scratch_mvc.material = m;
|
|
78
|
+
scratch_mvc.spec = spec;
|
|
79
79
|
|
|
80
|
-
const existing = this.material_contexts.get(
|
|
80
|
+
const existing = this.material_contexts.get(scratch_mvc);
|
|
81
81
|
|
|
82
82
|
if (existing !== undefined) {
|
|
83
83
|
return existing;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
// create a separate instance to be stored alongside the context
|
|
87
|
+
const key = scratch_mvc.clone();
|
|
88
|
+
|
|
86
89
|
const ctx = new MaterialContext(spec, m);
|
|
87
90
|
|
|
88
91
|
ctx.init(this.__gl_context);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PatchCacheKey } from "../PatchCacheKey.js";
|
|
2
|
-
import { apply_mat4_transform_to_v3_array } from "
|
|
2
|
+
import { apply_mat4_transform_to_v3_array } from "../../../../../core/geom/3d/apply_mat4_transform_to_v3_array.js";
|
|
3
3
|
import { Cache } from "../../../../../core/cache/Cache.js";
|
|
4
4
|
import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
|
|
5
5
|
import { invokeObjectEquals } from "../../../../../core/model/object/invokeObjectEquals.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FrameBuffer } from "../FrameBuffer.js";
|
|
2
2
|
import {
|
|
3
|
+
DepthFormat,
|
|
3
4
|
DepthTexture,
|
|
4
5
|
FloatType,
|
|
5
6
|
NearestFilter,
|
|
6
|
-
|
|
7
|
+
RGBFormat,
|
|
7
8
|
sRGBEncoding,
|
|
8
9
|
Vector2,
|
|
9
10
|
WebGLMultisampleRenderTarget
|
|
@@ -39,9 +40,9 @@ export class ColorAndDepthFrameBuffer extends FrameBuffer {
|
|
|
39
40
|
|
|
40
41
|
renderer.getSize(size);
|
|
41
42
|
|
|
42
|
-
const target = new WebGLMultisampleRenderTarget(size.x, size.y);
|
|
43
|
+
const target = new WebGLMultisampleRenderTarget(size.x, size.y,{ignoreDepth: false});
|
|
43
44
|
|
|
44
|
-
target.texture.format =
|
|
45
|
+
target.texture.format = RGBFormat; // note, three.js required RGBA render texture, even though RGB would do here
|
|
45
46
|
target.texture.minFilter = NearestFilter;
|
|
46
47
|
target.texture.magFilter = NearestFilter;
|
|
47
48
|
target.texture.generateMipmaps = false;
|
|
@@ -51,6 +52,7 @@ export class ColorAndDepthFrameBuffer extends FrameBuffer {
|
|
|
51
52
|
target.depthBuffer = true;
|
|
52
53
|
|
|
53
54
|
target.depthTexture = new DepthTexture();
|
|
55
|
+
target.depthTexture.format = DepthFormat;
|
|
54
56
|
target.depthTexture.type = FloatType;
|
|
55
57
|
target.depthTexture.generateMipmaps = false;
|
|
56
58
|
target.depthTexture.internalFormat = 'DEPTH_COMPONENT32F';
|
|
@@ -50,8 +50,6 @@ import { enableEditor } from "../../../../../editor/enableEditor.js";
|
|
|
50
50
|
import EntityBuilder from "../../../../ecs/EntityBuilder.js";
|
|
51
51
|
import { Transform } from "../../../../ecs/transform/Transform.js";
|
|
52
52
|
import Mesh from "../../../ecs/mesh/Mesh.js";
|
|
53
|
-
import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
|
|
54
|
-
import GUIElement from "../../../../ecs/gui/GUIElement.js";
|
|
55
53
|
import { CopyShader } from "three/examples/jsm/shaders/CopyShader.js";
|
|
56
54
|
import {
|
|
57
55
|
DoubleSide,
|
|
@@ -64,11 +62,11 @@ import {
|
|
|
64
62
|
UniformsUtils,
|
|
65
63
|
WebGLRenderTarget
|
|
66
64
|
} from "three";
|
|
67
|
-
import { buildCubeURLs } from "../../../GraphicsEngine.js";
|
|
68
65
|
import { AmbientOcclusionPostProcessEffect } from "../simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
69
66
|
import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
|
|
70
67
|
import { MicronRenderPlugin } from "../../../micron/plugin/MicronRenderPlugin.js";
|
|
71
68
|
import { StandardFrameBuffers } from "../../../StandardFrameBuffers.js";
|
|
69
|
+
import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
|
|
72
70
|
|
|
73
71
|
const engineHarness = new EngineHarness();
|
|
74
72
|
|
|
@@ -386,13 +384,13 @@ function main(engine) {
|
|
|
386
384
|
// .build(ecd);
|
|
387
385
|
|
|
388
386
|
// const canvasView = makeCameraClippingDebug(engine);
|
|
389
|
-
|
|
390
|
-
new EntityBuilder()
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
387
|
+
//
|
|
388
|
+
// new EntityBuilder()
|
|
389
|
+
// .add(ViewportPosition.fromJSON({
|
|
390
|
+
// offset: new Vector2(10, 10)
|
|
391
|
+
// }))
|
|
392
|
+
// .add(GUIElement.fromView(canvasView))
|
|
393
|
+
// .build(ecd);
|
|
396
394
|
|
|
397
395
|
|
|
398
396
|
}
|
|
@@ -11,15 +11,13 @@ import { compute_light_data_hash_0 } from "./cluster/compute_light_data_hash_0.j
|
|
|
11
11
|
import { read_plane_pair } from "./cluster/read_plane_pair.js";
|
|
12
12
|
import { read_frustum_planes_to_array } from "./cluster/read_frustum_planes_to_array.js";
|
|
13
13
|
import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
|
|
14
|
-
import {
|
|
15
|
-
computeDataType,
|
|
16
|
-
computeThreeTextureInternalFormatFromDataType,
|
|
17
|
-
computeThreeTextureTypeFromDataType,
|
|
18
|
-
NumericType,
|
|
19
|
-
TextureBackedMemoryRegion
|
|
20
|
-
} from "./TextureBackedMemoryRegion.js";
|
|
14
|
+
import { TextureBackedMemoryRegion } from "./data/TextureBackedMemoryRegion.js";
|
|
21
15
|
import { assert } from "../../../../core/assert.js";
|
|
22
16
|
import { DataType2TypedArrayConstructorMapping } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
17
|
+
import { NumericType } from "./data/NumericType.js";
|
|
18
|
+
import { computeDataType } from "./data/computeDataType.js";
|
|
19
|
+
import { computeThreeTextureTypeFromDataType } from "./data/computeThreeTextureTypeFromDataType.js";
|
|
20
|
+
import { computeThreeTextureInternalFormatFromDataType } from "./data/computeThreeTextureInternalFormatFromDataType.js";
|
|
23
21
|
|
|
24
22
|
const LOOKUP_CACHE_SIZE = 16384; // must be power of two
|
|
25
23
|
/**
|