@woosh/meep-engine 2.33.2 → 2.33.6

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.
Files changed (98) hide show
  1. package/core/bvh2/aabb3/AABB3.js +18 -0
  2. package/core/bvh2/aabb3/aabb3_intersects_frustum.js +38 -0
  3. package/core/collection/RingBuffer.js +40 -10
  4. package/core/collection/array/copyArray.js +2 -2
  5. package/core/collection/array/typed/typed_array_copy.js +2 -2
  6. package/core/collection/table/RowFirstTableSpec.js +8 -0
  7. package/core/geom/3d/aabb/aabb3_compute_projected_area.js +16 -14
  8. package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
  9. package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
  10. package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -0
  11. package/core/geom/3d/plane/plane3_lerp.js +2 -2
  12. package/core/geom/3d/topology/TopoTriangle.js +2 -2
  13. package/core/geom/AABB2.d.ts +2 -0
  14. package/core/geom/Matrix4.js +4 -4
  15. package/core/geom/Vector3.js +5 -5
  16. package/core/model/reactive/model/terminal/ReactiveReference.js +7 -1
  17. package/core/process/undo/ActionProcessor.d.ts +2 -0
  18. package/core/process/undo/ActionProcessor.js +59 -1
  19. package/core/process/undo/ActionProcessor.spec.js +59 -0
  20. package/core/process/undo/Mark.js +2 -1
  21. package/engine/asset/loaders/GLTFAssetLoader.js +3 -3
  22. package/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +11 -1
  23. package/engine/asset/loaders/material/TextureAttachment.js +12 -1
  24. package/engine/asset/loaders/material/bitmap2sampler_gl.js +19 -0
  25. package/engine/asset/loaders/material/computeImageBitmapEquality.js +7 -19
  26. package/engine/asset/loaders/material/computeTextureEquality.js +1 -1
  27. package/engine/asset/loaders/material/computeTextureHash.js +16 -14
  28. package/engine/asset/loaders/material/traverseMaterialTextures.js +2 -2
  29. package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +2 -2
  30. package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +4 -4
  31. package/engine/graphics/GraphicsEngine.d.ts +2 -2
  32. package/engine/graphics/GraphicsEngine.js +20 -62
  33. package/engine/graphics/filter/FlipArrayInPlace.js +25 -0
  34. package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
  35. package/engine/graphics/filter/ImageFilter.js +20 -51
  36. package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -2
  37. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +25 -16
  38. package/engine/graphics/material/SplatMaterial.js +4 -97
  39. package/engine/graphics/material/optimization/MaterialOptimizationContext.js +598 -0
  40. package/engine/graphics/micron/build/PatchRepresentation.js +4 -43
  41. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -75
  42. package/engine/graphics/micron/build/compute_buffer_geometry_byte_size.js +16 -0
  43. package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -0
  44. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
  45. package/engine/graphics/micron/format/MicronGeometryPatch.js +17 -5
  46. package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
  47. package/engine/graphics/micron/prototypeVirtualGeometry.js +19 -12
  48. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +34 -27
  49. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
  50. package/engine/graphics/micron/render/instanced/PatchDataTextures.js +1 -0
  51. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +1 -29
  52. package/engine/graphics/micron/render/refinement/ActivePatchList.js +43 -159
  53. package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
  54. package/engine/graphics/micron/render/refinement/RefinementSpec.js +98 -0
  55. package/engine/graphics/micron/render/refinement/array_normalize_plane.js +25 -0
  56. package/engine/graphics/micron/render/refinement/array_setFromProjectionMatrix.js +60 -0
  57. package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +43 -0
  58. package/engine/graphics/micron/render/refinement/is_patch_visible.js +37 -0
  59. package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +21 -0
  60. package/engine/graphics/micron/render/v1/VGThreeRenderer.js +12 -9
  61. package/engine/graphics/micron/util/unit_hemioct.spec.js +2 -2
  62. package/engine/graphics/render/buffer/buffers/ColorAndDepthFrameBuffer.js +5 -3
  63. package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +12 -2
  64. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
  65. package/engine/graphics/render/forward_plus/LightManager.js +5 -7
  66. package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
  67. package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
  68. package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
  69. package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
  70. package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
  71. package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
  72. package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
  73. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  74. package/engine/graphics/render/forward_plus/prototypeLightManager.js +1 -1
  75. package/engine/graphics/render/utils/ThreeBypassRenderer.js +1 -3
  76. package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
  77. package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
  78. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
  79. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +435 -0
  80. package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
  81. package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
  82. package/engine/graphics/shadows/ShadowMapRenderer.js +12 -2
  83. package/engine/graphics/texture/atlas/TextureAtlas.js +1 -1
  84. package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
  85. package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
  86. package/engine/graphics/texture/cubemap/load_environment_map.js +163 -0
  87. package/engine/graphics/texture/sampler/Sampler2D.js +18 -62
  88. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +8 -4
  89. package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +3 -2
  90. package/engine/graphics/texture/sampler/differenceSampler.js +31 -0
  91. package/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js +25 -0
  92. package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -2
  93. package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
  94. package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
  95. package/package.json +1 -1
  96. package/view/elements/progress/segmented/SegmentedResourceBarView.js +50 -15
  97. package/view/minimap/gl/MinimapMarkersGL.js +2 -2
  98. package/engine/graphics/micron/render/RefinementSpec.js +0 -110
@@ -1,13 +1,9 @@
1
- import { BitSet } from "../../../../core/binary/BitSet.js";
2
1
  import { TopoMesh } from "../../../../core/geom/3d/topology/TopoMesh.js";
3
2
  import { PatchRepresentation } from "./PatchRepresentation.js";
4
- import { max3 } from "../../../../core/math/max3.js";
5
- import { min3 } from "../../../../core/math/min3.js";
6
3
  import { MicronGeometry } from "../format/MicronGeometry.js";
7
4
  import { buildAbstractPatchHierarchy } from "./hierarchy/buildAbstractPatchHierarchy.js";
8
5
  import { MicronGeometryBufferAttributeSpec } from "../format/MicronGeometryBufferAttributeSpec.js";
9
6
  import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
10
- import { RowFirstTableSpec } from "../../../../core/collection/table/RowFirstTableSpec.js";
11
7
  import { DataType } from "../../../../core/collection/table/DataType.js";
12
8
  import { MicronGeometryPatch } from "../format/MicronGeometryPatch.js";
13
9
  import { build_clustering_info } from "./debug/build_clustering_info.js";
@@ -15,6 +11,7 @@ import { build_graph_info } from "./debug/build_graph_info.js";
15
11
  import { expandConnectivityByLocality } from "../../../../core/geom/3d/topology/expandConnectivityByLocality.js";
16
12
  import { build_geometry_info } from "./build_geometry_info.js";
17
13
  import { build_leaf_patches_metis } from "./clustering/build_leaf_patches_metis.js";
14
+ import { compute_buffer_geometry_byte_size } from "./compute_buffer_geometry_byte_size.js";
18
15
 
19
16
 
20
17
  /**
@@ -38,55 +35,6 @@ function buildVertexDataTypeMap(attributes) {
38
35
  return data_types;
39
36
  }
40
37
 
41
-
42
- /**
43
- *
44
- * @param {FastBinaryHeap} candidates
45
- * @param {BitSet} open_set
46
- * @param {TopoMesh} mesh
47
- */
48
- function pickCandidateForNextPatch(candidates, open_set, mesh) {
49
-
50
- }
51
-
52
- /**
53
- *
54
- * @param {AABB3} bounds
55
- * @param {TopoTriangle} face
56
- */
57
- function expandBoundsByFace(bounds, face) {
58
- const vertices = face.vertices;
59
-
60
- const vA = vertices[0];
61
- const vB = vertices[1];
62
- const vC = vertices[2];
63
-
64
- bounds._expandToFitPoint(vA.x, vA.y, vA.z);
65
- bounds._expandToFitPoint(vB.x, vB.y, vB.z);
66
- bounds._expandToFitPoint(vC.x, vC.y, vC.z);
67
- }
68
-
69
- /**
70
- *
71
- * @param {AABB3} bounds
72
- * @param {TopoVertex} vA
73
- * @param {TopoVertex} vB
74
- * @param {TopoVertex} vC
75
- * @returns {number}
76
- */
77
- function computeBoundsTriangleInclusionCost(bounds, vA, vB, vC) {
78
- // compute AABB of triangle
79
- const x0 = min3(vA.x, vB.x, vC.x);
80
- const y0 = min3(vA.y, vB.y, vC.y);
81
- const z0 = min3(vA.z, vB.z, vC.z);
82
-
83
- const x1 = max3(vA.x, vB.x, vC.x);
84
- const y1 = max3(vA.y, vB.y, vC.y);
85
- const z1 = max3(vA.z, vB.z, vC.z);
86
-
87
- return bounds._costForInclusion(x0, y0, z0, x1, y1, z1);
88
- }
89
-
90
38
  /**
91
39
  *
92
40
  * @param {MicronGeometryBufferAttributeSpec} spec
@@ -120,6 +68,7 @@ function format_attribute(spec, source, name) {
120
68
 
121
69
  switch (name) {
122
70
  case 'uv':
71
+ case 'uv2':
123
72
  custom_attribute_format_uv(spec, source);
124
73
  break;
125
74
  case 'tangent':
@@ -157,23 +106,6 @@ function attributes_from_buffer_geometry(buffer_geometry) {
157
106
  return result;
158
107
  }
159
108
 
160
- /**
161
- *
162
- * @param {THREE.BufferGeometry} g
163
- * @returns {number}
164
- */
165
- export function compute_buffer_geometry_byte_size(g) {
166
- let result = 0;
167
-
168
- result += g.getIndex().array.buffer.byteLength;
169
-
170
- for (const attribute_name in g.attributes) {
171
- result += g.attributes[attribute_name].array.buffer.byteLength;
172
- }
173
-
174
- return result;
175
- }
176
-
177
109
  const PRINT_VERBOSE_STATS = false;
178
110
 
179
111
  /**
@@ -261,7 +193,7 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
261
193
  const r = new MicronGeometry();
262
194
 
263
195
  r.proxy = input; // TODO use r.buildProxy(1) instead
264
-
196
+
265
197
  r.source_triangle_count = index_attribute.count / 3;
266
198
  r.source_vertex_count = input.getAttribute('position').count;
267
199
  r.source_byte_size = compute_buffer_geometry_byte_size(input);
@@ -269,11 +201,8 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
269
201
  // console.time('build geometry');
270
202
 
271
203
  const vertex_attributes = attributes_from_buffer_geometry(input);
272
- const data_types = buildVertexDataTypeMap(vertex_attributes);
273
- const vertex_data_spec = RowFirstTableSpec.get(data_types);
274
204
 
275
- r.vertex_spec.data = vertex_data_spec;
276
- r.vertex_spec.attributes = vertex_attributes;
205
+ r.vertex_spec.setAttributes(vertex_attributes);
277
206
  r.root = compilePatchGraph(root, input, r.vertex_spec);
278
207
 
279
208
  r.initialize();
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Estimated GPU-side geometry size
3
+ * @param {THREE.BufferGeometry} g
4
+ * @returns {number}
5
+ */
6
+ export function compute_buffer_geometry_byte_size(g) {
7
+ let result = 0;
8
+
9
+ result += g.getIndex().array.buffer.byteLength;
10
+
11
+ for (const attribute_name in g.attributes) {
12
+ result += g.attributes[attribute_name].array.buffer.byteLength;
13
+ }
14
+
15
+ return result;
16
+ }
@@ -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
 
@@ -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
 
@@ -1,4 +1,3 @@
1
- import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
2
1
  import { squirrel3 } from "../../../../core/math/hash/squirrel3.js";
3
2
  import { ConicRay } from "../../../../core/geom/ConicRay.js";
4
3
  import { vec4 } from "gl-matrix";
@@ -14,17 +13,30 @@ export class MicronGeometryPatch {
14
13
  */
15
14
  this.id = 0;
16
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
+
17
23
  /**
18
24
  * Bounds are used to determine screen error and whether a patch should be subdivided or not for rendering
19
- * @type {AABB3}
25
+ * @type {number[]}
26
+ */
27
+ this.bounding_box = new Float32Array(array_buffer, 0, 6);
28
+
29
+ /**
30
+ *
31
+ * @type {number[]|Float32Array}
20
32
  */
21
- this.bounding_box = new AABB3(0, 0, 0, 0, 0, 0);
33
+ this.group_bounding_box = new Float32Array(array_buffer, 6 * 4, 6);
22
34
 
23
35
  /**
24
36
  *
25
- * @type {AABB3}
37
+ * @type {number[]|Float32Array}
26
38
  */
27
- this.group_bounding_box = new AABB3(0, 0, 0, 0, 0, 0);
39
+ this.group_bounding_box_corners = new Float32Array(array_buffer, 12 * 4, 24);
28
40
 
29
41
  /**
30
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 {RowFirstTableSpec|null}
17
+ * @type {number}
18
+ * @private
16
19
  */
17
- this.data = null;
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
- hash() {
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
@@ -53,7 +53,7 @@ background.wrapS = RepeatWrapping;
53
53
  background.wrapT = RepeatWrapping;
54
54
 
55
55
  const metrics = new MetricCollection();
56
- const METRIC_BUFFER_SIZE = 100;
56
+ const METRIC_BUFFER_SIZE = 1000;
57
57
  metrics.create({
58
58
  name: 'vg_build', buffer_size: METRIC_BUFFER_SIZE
59
59
  });
@@ -153,17 +153,21 @@ async function micron_add_object(object) {
153
153
  if (t.isMesh && material !== null) {
154
154
 
155
155
  const attachments = TextureAttachmentsByMaterialType[material.type];
156
- const n = attachments.length;
157
156
 
158
- for (let i = 0; i < n; i++) {
159
- const a = attachments[i];
160
- const texture = a.read(material);
157
+ if (attachments !== undefined) {
161
158
 
162
- if (texture !== undefined && texture !== null) {
163
- texture.anisotropy = 8;
159
+ const n = attachments.length;
160
+
161
+ for (let i = 0; i < n; i++) {
162
+ const a = attachments[i];
163
+ const texture = a.read(material);
164
+
165
+ if (texture !== undefined && texture !== null) {
166
+ texture.anisotropy = 8;
167
+ }
164
168
  }
165
- }
166
169
 
170
+ }
167
171
 
168
172
  }
169
173
  });
@@ -228,7 +232,7 @@ function init() {
228
232
  pointLight.add(mesh);
229
233
 
230
234
  // add directional light
231
- directionalLight = new DirectionalLight(0xFFAAAA, 0.7);
235
+ directionalLight = new DirectionalLight(0xFFAAAA, 0.8);
232
236
  directionalLight.position.set(-500, 1000, 300);
233
237
  directionalLight.castShadow = true;
234
238
  const shadow_camera = directionalLight.shadow.camera;
@@ -452,12 +456,15 @@ function init() {
452
456
 
453
457
  // sample_gltf_sponza();
454
458
  // sample_gltf_rts_factory();
455
- // sample_lucy();
459
+ sample_lucy();
456
460
  // sample_gltf_hapro_2();
457
461
  // sample_gltf_hapro_1();
458
462
  // sample_gltf_broken_isiflow();
459
- gltf_grid('data/models/moicon/Kople/EVCharger1.gltf');
463
+ // gltf_grid('data/models/moicon/Kople/EVCharger1.gltf');
460
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');
467
+ // gltf_sample('data/models/moicon/isiflow_Oct_15_21/0/model.gltf');
461
468
 
462
469
  document.addEventListener("mousemove", onDocumentMouseMove);
463
470
 
@@ -528,7 +535,7 @@ function createScene(geometry, m1, scale) {
528
535
  geometry.computeVertexNormals();
529
536
 
530
537
 
531
- const grid_size = 10;
538
+ const grid_size = 100;
532
539
  const grid_spacing = 2000;
533
540
 
534
541
  for (let i = 0; i < grid_size; i++) {
@@ -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
- this.matrix_projection = new Matrix4();
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
- this.matrix_world_inverse = new Matrix4();
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 {WeakMap<ThreeMicronMesh, ActivePatchList>}
65
+ * @type {ActivePatchList}
52
66
  * @private
53
67
  */
54
- this.__acls = new WeakMap();
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.__acls = new WeakMap();
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
- this.matrix_world_inverse.copy(camera.matrixWorldInverse);
106
- this.matrix_projection.copy(camera.projectionMatrix);
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);
@@ -129,8 +141,6 @@ export class VirtualGeometryBuilder {
129
141
  return;
130
142
  }
131
143
 
132
- const children = object.children;
133
-
134
144
  if (object.isMicronMesh) {
135
145
  /**
136
146
  *
@@ -139,14 +149,7 @@ export class VirtualGeometryBuilder {
139
149
  const micron_geometry = object.geometry;
140
150
  if (micron_geometry !== undefined) {
141
151
  // get acl
142
-
143
- let acl = this.__acls.get(object);
144
-
145
-
146
- if (acl === undefined) {
147
- acl = new ActivePatchList();
148
- this.__acls.set(object, acl);
149
- }
152
+ const acl = this.__acl;
150
153
 
151
154
  acl.initializeFromGeometry(micron_geometry);
152
155
 
@@ -159,7 +162,9 @@ export class VirtualGeometryBuilder {
159
162
  }
160
163
  }
161
164
 
165
+ const children = object.children;
162
166
  const children_count = children.length;
167
+
163
168
  for (let i = 0; i < children_count; i++) {
164
169
  const child = children[i];
165
170
 
@@ -181,7 +186,7 @@ export class VirtualGeometryBuilder {
181
186
  apl
182
187
  ) {
183
188
 
184
- refinement_spec.build(transform, this.matrix_world_inverse, this.matrix_projection);
189
+ refinement_spec.build(transform.elements, this.matrix_world_inverse, this.matrix_projection);
185
190
 
186
191
  const output = this.output;
187
192
 
@@ -252,9 +257,10 @@ export class VirtualGeometryBuilder {
252
257
 
253
258
  // update refinement spec
254
259
  refinement_spec.error_threshold = this.error_bias;
255
- refinement_spec.resolution.copy(this.resolution);
256
260
 
257
- refinement_spec.viewport_area = this.resolution.x * this.resolution.y;
261
+ const resolution = this.resolution;
262
+
263
+ refinement_spec.setResolution(resolution.x, resolution.y);
258
264
 
259
265
  // clear output
260
266
  this.output.clear();
@@ -262,9 +268,10 @@ export class VirtualGeometryBuilder {
262
268
  this.__info_enforced_node_splits = 0;
263
269
 
264
270
  const n = this.input_scene_length;
271
+ const input_objects = this.input_scene;
265
272
 
266
273
  for (let i = 0; i < n; i++) {
267
- const object3D = this.input_scene[i];
274
+ const object3D = input_objects[i];
268
275
 
269
276
  this.buildForObject(object3D);
270
277
  }
@@ -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
  *
@@ -253,6 +253,7 @@ export class PatchDataTextures {
253
253
  capacity + 1
254
254
  );
255
255
 
256
+ // Clamp to maximum texture size
256
257
  next_capacity = min2(next_capacity, MAX_TEXTURE_SIZE * this.__column_count);
257
258
 
258
259
  if (next_capacity < capacity) {
@@ -8,7 +8,7 @@ import {
8
8
  } from "three";
9
9
  import { MICRON_PATCH_SIZE_MAX } from "../../build/MICRON_PATCH_SIZE_MAX.js";
10
10
  import Signal from "../../../../../core/events/signal/Signal.js";
11
- import { ATTRIBUTE_INSTANCE_ID, ATTRIBUTE_NAME_ADDRESS, ATTRIBUTE_NAME_TRANSFORM } from "./shader/constants.js";
11
+ import { ATTRIBUTE_NAME_ADDRESS, ATTRIBUTE_NAME_TRANSFORM } from "./shader/constants.js";
12
12
  import { shader_rewrite_standard } from "./shader/shader_rewrite_standard.js";
13
13
 
14
14
 
@@ -98,20 +98,8 @@ export class ThreeInstancedAdapter {
98
98
  const ia_patch_ref = new InstancedBufferAttribute(new Uint16Array(capacity), 1, false);
99
99
  ia_patch_ref.setUsage(StreamDrawUsage);
100
100
 
101
-
102
- /**
103
- * This is a workaround for bug in WebGLBindingStates
104
- * @see https://github.com/mrdoob/three.js/issues/22843
105
- * @type {number}
106
- */
107
- ia_patch_ref.data = 0;
108
-
109
101
  geo.setAttribute(ATTRIBUTE_NAME_ADDRESS, ia_patch_ref);
110
102
 
111
- const ia_instance_id = new InstancedBufferAttribute(new Uint16Array(capacity), 1, false);
112
- ia_instance_id.setUsage(StreamDrawUsage);
113
- geo.setAttribute(ATTRIBUTE_INSTANCE_ID, ia_instance_id);
114
-
115
103
  // signal
116
104
  this.onRebuild.send0();
117
105
  }
@@ -151,7 +139,6 @@ export class ThreeInstancedAdapter {
151
139
  */
152
140
  build(patches, patch_count) {
153
141
  this.__prepare_capacity(patch_count);
154
- // this.__build_geometry();
155
142
 
156
143
  const geo = this.__buffer_geometry;
157
144
 
@@ -163,21 +150,8 @@ export class ThreeInstancedAdapter {
163
150
  const patch_address_attribute = geo.getAttribute(ATTRIBUTE_NAME_ADDRESS);
164
151
  const patch_address_array = patch_address_attribute.array;
165
152
 
166
- /**
167
- * This is a workaround for bug in WebGLBindingStates
168
- * @see https://github.com/mrdoob/three.js/issues/22843
169
- * @type {number}
170
- */
171
- patch_address_attribute.data++;
172
-
173
153
  patch_address_attribute.needsUpdate = true;
174
154
 
175
-
176
- const patch_instance_id_attribute = geo.getAttribute(ATTRIBUTE_INSTANCE_ID);
177
- const patch_instance_id_array = patch_instance_id_attribute.array;
178
-
179
- patch_instance_id_attribute.needsUpdate = true;
180
-
181
155
  const patch_data = this.__patch_data;
182
156
 
183
157
  for (let i = 0; i < patch_count; i++) {
@@ -190,8 +164,6 @@ export class ThreeInstancedAdapter {
190
164
  const patch_slot_id = patch_data.ensure(occurrence.patch);
191
165
 
192
166
  patch_address_array[i] = patch_slot_id;
193
-
194
- patch_instance_id_array[i] = occurrence.instance_id;
195
167
  }
196
168
  }
197
169
  }