@woosh/meep-engine 2.34.43 → 2.34.47

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 (68) hide show
  1. package/core/bvh2/BinaryNode.js +62 -32
  2. package/core/bvh2/LeafNode.js +2 -1
  3. package/core/bvh2/aabb3/AABB3.js +879 -1059
  4. package/core/bvh2/aabb3/AABB3.spec.js +5 -7
  5. package/core/bvh2/aabb3/aabb3_array_intersects_ray.js +2 -2
  6. package/core/bvh2/aabb3/aabb3_box_surface_area_2.js +10 -0
  7. package/core/bvh2/aabb3/aabb3_compute_half_surface_area.js +16 -0
  8. package/core/bvh2/aabb3/aabb3_compute_surface_area.js +18 -0
  9. package/core/bvh2/aabb3/aabb3_expand_array.js +15 -0
  10. package/core/bvh2/aabb3/aabb3_intersect_aabb3.js +28 -0
  11. package/core/bvh2/aabb3/aabb3_intersect_ray_slab.js +73 -0
  12. package/core/bvh2/aabb3/{aabb3_intersects_frustum.js → aabb3_intersects_frustum_array.js} +16 -1
  13. package/core/bvh2/aabb3/aabb3_intersects_line_segment.js +79 -0
  14. package/core/bvh2/aabb3/aabb3_intersects_ray.js +92 -0
  15. package/core/bvh2/aabb3/{AABB3Math.spec.js → aabb3_intersects_ray.spec.js} +3 -3
  16. package/core/bvh2/aabb3/aabb3_intersects_ray_fast.js +176 -0
  17. package/core/bvh2/aabb3/aabb3_score_boxes_SAH.js +43 -0
  18. package/core/bvh2/aabb3/aabb_score_boxes_SAH_delta.js +37 -0
  19. package/core/bvh2/aabb3/deserializeAABB3.js +17 -0
  20. package/core/bvh2/aabb3/deserializeAABB3Encoded_v0.js +73 -0
  21. package/core/bvh2/aabb3/deserializeAABB3Quantized16Uint.js +36 -0
  22. package/core/bvh2/aabb3/serializeAABB3.js +13 -0
  23. package/core/bvh2/aabb3/serializeAABB3Quantized16Uint.js +33 -0
  24. package/core/bvh2/binary/2/BinaryUint32BVH.js +3 -3
  25. package/core/bvh2/binary/BinaryBVH.js +2 -2
  26. package/core/bvh2/binary/RayLeafIntersectionVisitor.js +2 -2
  27. package/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  28. package/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -1
  29. package/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  30. package/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -1
  31. package/core/bvh2/transform/BottomUpOptimizingRebuilder.js +6 -5
  32. package/core/bvh2/transform/tryRotateSingleNode.js +2 -1
  33. package/core/bvh2/traversal/bvh_traverse_pre_order_using_stack.js +43 -0
  34. package/core/bvh2/visual/convert_bvh_to_dot_format_string.js +50 -0
  35. package/core/geom/3d/frustum/{array_setFromProjectionMatrix.js → frustum_from_projection_matrix_array.js} +1 -1
  36. package/core/geom/3d/topology/TopoMesh.js +0 -8
  37. package/core/geom/3d/topology/TopoVertex.js +7 -6
  38. package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +93 -5
  39. package/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +7 -4
  40. package/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js +7 -1
  41. package/core/geom/3d/topology/simplify/simplifyTopoMesh.js +1 -14
  42. package/core/graph/convertGraphToDotString.js +4 -4
  43. package/core/graph/v2/Graph.js +4 -0
  44. package/core/math/fabsf.js +8 -0
  45. package/engine/development/performance/MetricCollection.js +6 -0
  46. package/engine/ecs/foliage/ecs/Foliage2System.js +7 -2
  47. package/engine/graphics/compute_geometry_polycount.js +21 -0
  48. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
  49. package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +66 -9
  50. package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +2 -2
  51. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -0
  52. package/engine/graphics/micron/build/hierarchy/merge_patches.js +1 -1
  53. package/engine/graphics/micron/convert_three_object_to_micron.js +2 -0
  54. package/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +3 -2
  55. package/engine/graphics/micron/plugin/GLTFAssetTransformer.js +176 -0
  56. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +1 -135
  57. package/engine/graphics/micron/prototypeVirtualGeometry.js +12 -7
  58. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  59. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +16 -43
  60. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +5 -1
  61. package/engine/graphics/micron/render/refinement/ActivePatchList.js +4 -10
  62. package/engine/graphics/micron/render/refinement/RefinementSpec.js +16 -20
  63. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +316 -11
  64. package/engine/graphics/render/layers/RenderLayer.js +22 -14
  65. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +18 -5
  66. package/engine/graphics/render/visibility/VisibilityComputer.js +11 -15
  67. package/package.json +1 -1
  68. package/core/bvh2/aabb3/AABB3Math.js +0 -579
@@ -2,8 +2,6 @@ import { EnginePlugin } from "../../../plugin/EnginePlugin.js";
2
2
  import { VGThreeRenderer } from "../render/v1/VGThreeRenderer.js";
3
3
  import { RenderLayer } from "../../render/layers/RenderLayer.js";
4
4
  import { RenderPassType } from "../../render/RenderPassType.js";
5
- import { AssetTransformer } from "../../../asset/AssetTransformer.js";
6
- import { convert_three_object_to_micron } from "../convert_three_object_to_micron.js";
7
5
  import { Cache } from "../../../../core/cache/Cache.js";
8
6
  import { computeGeometryHash } from "../../../asset/loaders/geometry/geometry/computeGeometryHash.js";
9
7
  import { computeGeometryEquality } from "../../../asset/loaders/geometry/geometry/computeGeometryEquality.js";
@@ -12,13 +10,9 @@ import { AsyncRemoteHashMap } from "../../../../core/collection/map/AsyncRemoteH
12
10
  import { BufferGeometrySerializationAdapter } from "./serialization/BufferGeometrySerializationAdapter.js";
13
11
  import { MicronGeometryBinarySerializationAdapter } from "../format/serialization/MicronGeometryBinarySerializationAdapter.js";
14
12
  import { AsyncMapWrapper } from "../../../../core/collection/map/AsyncMapWrapper.js";
15
- import { async_traverse_three_object } from "../../../asset/loaders/async_traverse_three_object.js";
16
- import { computePathDirectory } from "../../../../core/FilePath.js";
17
- import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
18
13
  import { MicronGeometry } from "../format/MicronGeometry.js";
19
14
  import { ArrayBufferLoader } from "../../../asset/loaders/ArrayBufferLoader.js";
20
- import { MICRON_URI_FIELD } from "../MICRON_URI_FIELD.js";
21
- import { MICRON_GEOMETRY_FIELD } from "../MICRON_GEOMETRY_FIELD.js";
15
+ import { ASSET_TYPE_ARRAY_BUFFER, GLTFAssetTransformer } from "./GLTFAssetTransformer.js";
22
16
 
23
17
  /**
24
18
  *
@@ -26,134 +20,6 @@ import { MICRON_GEOMETRY_FIELD } from "../MICRON_GEOMETRY_FIELD.js";
26
20
  */
27
21
  const STORAGE_KEY = '@plugin/virtual-geometry-micron/geometry-cache';
28
22
 
29
- const ASSET_TYPE_ARRAY_BUFFER = "arraybuffer";
30
-
31
- class GLTFAssetTransformer extends AssetTransformer {
32
- /**
33
- *
34
- * @param {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>} cache
35
- */
36
- constructor(cache) {
37
- super();
38
-
39
- /**
40
- *
41
- * @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
42
- * @private
43
- */
44
- this.__cache = cache;
45
-
46
- /**
47
- *
48
- * @type {AssetManager|null}
49
- * @private
50
- */
51
- this.__am = null;
52
-
53
- /**
54
- *
55
- * @type {MicronGeometryBinarySerializationAdapter}
56
- * @private
57
- */
58
- this.__serde = new MicronGeometryBinarySerializationAdapter();
59
- }
60
-
61
- /**
62
- *
63
- * @param {AssetManager|null} am
64
- */
65
- set assetManager(am) {
66
- this.__am = am;
67
- }
68
-
69
-
70
- /**
71
- * @param {THREE.Object3D} object
72
- * @param {{asset:AssetDescription}} ctx
73
- * @return {Promise<void>}
74
- * @private
75
- */
76
- async __visitObjectToLoadMicron(object, ctx) {
77
- if (!object.isMesh) {
78
- return;
79
- }
80
-
81
- /**
82
- * @type {THREE.BufferGeometry}
83
- */
84
- const geometry = object.geometry;
85
-
86
- const micron_uri = geometry.userData[MICRON_URI_FIELD];
87
-
88
- if (typeof micron_uri !== "string") {
89
- return;
90
- }
91
-
92
-
93
- /**
94
- * @type {AssetDescription}
95
- */
96
- const ad = ctx.asset;
97
-
98
- const base = computePathDirectory(ad.path);
99
-
100
- let micron_data;
101
-
102
- const micron_path = `${base}/${micron_uri}`;
103
-
104
- try {
105
- micron_data = await this.__am.promise(micron_path, ASSET_TYPE_ARRAY_BUFFER);
106
- } catch (e) {
107
- console.error(`Failed to load micron geometry '${micron_path}' referenced in GLTF (will skip): ${e}`);
108
- return;
109
- }
110
-
111
- // deserialize micron data
112
- const buffer = BinaryBuffer.fromArrayBuffer(micron_data.create());
113
- const micron_geometry = new MicronGeometry();
114
-
115
- this.__serde.deserialize(buffer, micron_geometry);
116
-
117
- // set proxy for raycasting
118
- micron_geometry.proxy = geometry;
119
-
120
- geometry[MICRON_GEOMETRY_FIELD] = micron_geometry;
121
- }
122
-
123
-
124
- /**
125
- *
126
- * @param {Asset} source
127
- * @param {AssetDescription} asset_description
128
- * @return {Promise<Asset>}
129
- */
130
- async transform(source, asset_description) {
131
- const animationClips = source.animations;
132
-
133
- if (animationClips !== undefined && animationClips.length > 0) {
134
- // animations might cause trouble
135
- console.warn(`model '${asset_description.path}' contains animations, these animations might not works as intended with micron.`);
136
- }
137
-
138
- /**
139
- * @type {THREE.Object3D}
140
- */
141
- const root = source.create();
142
-
143
- // attempt to load existing micron geometries
144
- await async_traverse_three_object(root, this.__visitObjectToLoadMicron, this, {
145
- asset: asset_description
146
- });
147
-
148
- const micron_root = await convert_three_object_to_micron(root.clone(), this.__cache);
149
- micron_root.boundingSphere = root.boundingSphere;
150
-
151
- source.override_mesh = micron_root;
152
-
153
- return source;
154
- }
155
- }
156
-
157
23
  export class MicronRenderPlugin extends EnginePlugin {
158
24
  constructor() {
159
25
  super();
@@ -48,7 +48,6 @@ import { CanvasView } from "../../../view/elements/CanvasView.js";
48
48
  import { Sampler2D } from "../texture/sampler/Sampler2D.js";
49
49
  import { downsampleSampler2D } from "../texture/sampler/downsampleSampler2D.js";
50
50
  import { ShadowMapRenderer } from "../shadows/ShadowMapRenderer.js";
51
- import { MouseEvents } from "../../input/devices/events/MouseEvents.js";
52
51
  import { mat4 } from "gl-matrix";
53
52
 
54
53
  const background = new TextureLoader().load('data/textures/utility/checkers_white_grey_256x256.png');
@@ -460,14 +459,15 @@ function init() {
460
459
 
461
460
  // sample_gltf_sponza();
462
461
  // gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
463
- // sample_lucy();
462
+ sample_lucy();
463
+ // sample_dragon();
464
464
  // sample_gltf_hapro_2();
465
465
  // sample_gltf_hapro_1();
466
466
  // sample_gltf_broken_isiflow();
467
467
  // gltf_grid('data/models/moicon/Kople/EVCharger1.gltf');
468
468
  // gltf_grid('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
469
- // gltf_sample('data/models/moicon/08-clickable-assets/model.gltf');
470
- // gltf_sample('data/models/moicon/05-ground-floor/model.gltf');
469
+ // gltf_sample('moicon/08-clickable-assets/model.gltf');
470
+ // gltf_sample('moicon/05-ground-floor/model.gltf');
471
471
  // gltf_sample('data/models/moicon/isiflow_Oct_15_21/0/model.gltf');
472
472
  // gltf_sample('moicon/29_Dec_2021_Nammo/1/model.gltf');
473
473
  // gltf_sample('moicon/29_Dec_2021_Nammo/1-onematerial/model.gltf');
@@ -478,7 +478,7 @@ function init() {
478
478
  // gltf_sample('moicon/03_Jan_22_Demo/4-area_1st_floor/model.gltf');
479
479
  // gltf_sample('moicon/03_Jan_22_Demo/8-assets/model.gltf');
480
480
  // gltf_sample('moicon/03_Jan_22_Demo/worker_test/model.gltf');
481
- gltf_sample('moicon/A4/A4/model.gltf');
481
+ // gltf_sample('moicon/A4/A4/model.gltf');
482
482
 
483
483
  document.addEventListener("mousemove", onDocumentMouseMove);
484
484
 
@@ -546,6 +546,7 @@ function onWindowResize() {
546
546
  * @param {number} scale
547
547
  */
548
548
  function createScene(geometry, m1, scale) {
549
+
549
550
  geometry.computeVertexNormals();
550
551
 
551
552
 
@@ -709,6 +710,8 @@ function print_perf_stats() {
709
710
  });
710
711
 
711
712
  console.log(values.join(", "));
713
+
714
+ metrics.clear();
712
715
  }
713
716
 
714
717
  setInterval(print_perf_stats, 2000);
@@ -796,7 +799,7 @@ function render() {
796
799
  // console.log(`patches:${active_patches.length}, polycount:${polycount}`);
797
800
  }
798
801
 
799
- window.document.body.addEventListener(MouseEvents.Move, ({ clientX, clientY }) => {
802
+ const raycast_handler = ({ clientX, clientY }) => {
800
803
  const direction = new Vector3();
801
804
 
802
805
  const viewport_size = new Vector2();
@@ -856,5 +859,7 @@ window.document.body.addEventListener(MouseEvents.Move, ({ clientX, clientY }) =
856
859
  if (hits.length > 0) {
857
860
  console.log(`HITS: ${hits.map(JSON.stringify).join(',')}`);
858
861
  }
859
- });
862
+ };
863
+
864
+ // window.document.body.addEventListener(MouseEvents.Move, raycast_handler);
860
865
 
@@ -69,7 +69,7 @@ export class PatchCacheKey {
69
69
  fromPatchOccurrence(o) {
70
70
  this.patch_id = o.patch.id;
71
71
  this.geometry_id = o.geometry_id;
72
- this.transform.set(o.transform.elements);
72
+ this.transform.set(o.transform);
73
73
  }
74
74
  }
75
75
 
@@ -1,10 +1,10 @@
1
- import { Frustum, Matrix4 } from "three";
2
1
  import { array_copy } from "../../../../core/collection/array/copyArray.js";
3
2
  import Vector2 from "../../../../core/geom/Vector2.js";
4
3
  import { MicronGeometryPatchOccurrence } from "../format/MicronGeometryPatchOccurance.js";
5
4
  import { RefinementSpec } from "./refinement/RefinementSpec.js";
6
5
  import { ActivePatchList } from "./refinement/ActivePatchList.js";
7
6
  import { ActivePatchFlags } from "./refinement/ActivePatchFlags.js";
7
+ import { mat4 } from "gl-matrix";
8
8
 
9
9
  /**
10
10
  * @readonly
@@ -14,27 +14,27 @@ const refinement_spec = new RefinementSpec();
14
14
 
15
15
  export class VirtualGeometryBuilder {
16
16
  constructor() {
17
- this.view_projection_matrix = new Matrix4();
17
+
18
+
19
+ const common_buffer = new ArrayBuffer(192);
20
+
18
21
 
19
22
  /**
20
- *
23
+ * Camera's world inverse matrix
21
24
  * @type {Float32Array|number[]|mat4}
22
25
  */
23
- this.matrix_projection = new Float32Array(16);
24
-
25
- this.matrix_projection_inverse = new Matrix4();
26
-
26
+ this.matrix_world_inverse = new Float32Array(common_buffer, 0, 16);
27
27
  /**
28
- *
28
+ * Camera's projection matrix
29
29
  * @type {Float32Array|number[]|mat4}
30
30
  */
31
- this.matrix_world_inverse = new Float32Array(16);
31
+ this.matrix_projection = new Float32Array(common_buffer, 64, 16);
32
32
 
33
33
  /**
34
34
  *
35
- * @type {Frustum}
35
+ * @type {Float32Array|number[]|mat4}
36
36
  */
37
- this.view_frustum = new Frustum();
37
+ this.view_projection_matrix = new Float32Array(common_buffer, 128, 16);
38
38
 
39
39
  /**
40
40
  * @private
@@ -74,20 +74,6 @@ export class VirtualGeometryBuilder {
74
74
  * @type {number}
75
75
  */
76
76
  this.error_bias = 2;
77
-
78
- /**
79
- *
80
- * @type {number}
81
- * @private
82
- */
83
- this.__info_enforced_node_splits = 0;
84
-
85
- /**
86
- *
87
- * @type {boolean}
88
- * @private
89
- */
90
- this.__flags__enforce_dependency_splits = true;
91
77
  }
92
78
 
93
79
  dropCache() {
@@ -111,27 +97,15 @@ export class VirtualGeometryBuilder {
111
97
  camera.updateMatrix();
112
98
  camera.updateMatrixWorld(true);
113
99
 
114
- this.view_projection_matrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
115
-
116
100
  this.matrix_world_inverse.set(camera.matrixWorldInverse.elements);
117
101
  this.matrix_projection.set(camera.projectionMatrix.elements);
118
102
 
119
- this.matrix_projection_inverse.copy(camera.projectionMatrixInverse);
120
-
121
- this.view_frustum.setFromProjectionMatrix(this.view_projection_matrix);
103
+ mat4.multiply(this.view_projection_matrix, this.matrix_projection, this.matrix_world_inverse);
122
104
 
123
105
  //
124
106
  refinement_spec.focal_length = camera.fov / 180;
125
107
  }
126
108
 
127
- /**
128
- *
129
- * @param {THREE.Matrix4} matrix
130
- */
131
- setProjectionMatrix(matrix) {
132
- this.view_projection_matrix.copy(matrix);
133
- }
134
-
135
109
  /**
136
110
  *
137
111
  * @param {THREE.Object3D|ThreeMicronMesh} object
@@ -151,12 +125,11 @@ export class VirtualGeometryBuilder {
151
125
  // get acl
152
126
  const acl = this.__acl;
153
127
 
154
- acl.initializeFromGeometry(micron_geometry);
155
128
 
156
129
  this.buildForMesh(
157
130
  object.instance_id,
158
131
  micron_geometry,
159
- object.matrixWorld,
132
+ object.matrixWorld.elements,
160
133
  acl
161
134
  );
162
135
  }
@@ -176,7 +149,7 @@ export class VirtualGeometryBuilder {
176
149
  *
177
150
  * @param {number} instance_id
178
151
  * @param {MicronGeometry} geometry
179
- * @param {THREE.Matrix4} transform
152
+ * @param {number[]} transform world transform matrix of the instance
180
153
  * @param {ActivePatchList} apl
181
154
  */
182
155
  buildForMesh(
@@ -185,8 +158,9 @@ export class VirtualGeometryBuilder {
185
158
  transform,
186
159
  apl
187
160
  ) {
161
+ apl.initializeFromGeometry(geometry);
188
162
 
189
- refinement_spec.build(transform.elements, this.matrix_world_inverse, this.matrix_projection);
163
+ refinement_spec.build(transform, this.view_projection_matrix);
190
164
 
191
165
  const output = this.output;
192
166
 
@@ -265,7 +239,6 @@ export class VirtualGeometryBuilder {
265
239
  // clear output
266
240
  this.output.clear();
267
241
 
268
- this.__info_enforced_node_splits = 0;
269
242
 
270
243
  const n = this.input_scene_length;
271
244
  const input_objects = this.input_scene;
@@ -141,6 +141,10 @@ export class ThreeInstancedAdapter {
141
141
  const geo = this.__buffer_geometry;
142
142
 
143
143
  const patch_transform_attribute = geo.getAttribute(ATTRIBUTE_NAME_TRANSFORM);
144
+ /**
145
+ *
146
+ * @type {Float32Array}
147
+ */
144
148
  const patch_transform_array = patch_transform_attribute.array;
145
149
 
146
150
  patch_transform_attribute.needsUpdate = true;
@@ -157,7 +161,7 @@ export class ThreeInstancedAdapter {
157
161
 
158
162
  const i16 = i * 16;
159
163
 
160
- occurrence.transform.toArray(patch_transform_array, i16);
164
+ patch_transform_array.set(occurrence.transform, i16);
161
165
 
162
166
  const patch_slot_id = patch_data.ensure(occurrence.patch);
163
167
 
@@ -2,7 +2,7 @@ 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
4
  import { BitSet } from "../../../../../core/binary/BitSet.js";
5
- import { aabb3_intersects_frustum } from "../../../../../core/bvh2/aabb3/aabb3_intersects_frustum.js";
5
+ import { aabb3_intersects_frustum_array } from "../../../../../core/bvh2/aabb3/aabb3_intersects_frustum_array.js";
6
6
 
7
7
  export class ActivePatchList {
8
8
  constructor() {
@@ -194,27 +194,20 @@ export class ActivePatchList {
194
194
 
195
195
  const node = record.patch;
196
196
 
197
- // check if record needs to be split
198
- const prev_is_visible = record.getFlag(ActivePatchFlags.Visible);
199
197
 
200
198
  /*
201
199
  check if node is in view frustum
202
200
  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
203
201
  */
204
- const in_view_frustum = aabb3_intersects_frustum(node.bounding_box, frustum_planes);
202
+ const in_view_frustum = aabb3_intersects_frustum_array(node.bounding_box, frustum_planes);
205
203
 
206
204
  if (!in_view_frustum) {
207
205
  // outside of view frustum, cull
208
- if (prev_is_visible) {
209
- record.clearFlag(ActivePatchFlags.Visible);
210
- }
211
206
  record = record.link_next;
212
207
  continue;
213
208
  }
214
209
 
215
- if (!prev_is_visible) {
216
- record.setFlag(ActivePatchFlags.Visible);
217
- }
210
+ record.setFlag(ActivePatchFlags.Visible);
218
211
 
219
212
  /*
220
213
  scale error to projection space:
@@ -224,6 +217,7 @@ export class ActivePatchList {
224
217
  */
225
218
 
226
219
 
220
+ // check if record needs to be split
227
221
  if (node.lod > 0) {
228
222
 
229
223
  // not the lowest level of LOD, see if subdivision might be necessary
@@ -1,6 +1,6 @@
1
1
  import Vector2 from "../../../../../core/geom/Vector2.js";
2
2
  import { mat4 } from "gl-matrix";
3
- import { array_setFromProjectionMatrix } from "../../../../../core/geom/3d/frustum/array_setFromProjectionMatrix.js";
3
+ import { frustum_from_projection_matrix_array } from "../../../../../core/geom/3d/frustum/frustum_from_projection_matrix_array.js";
4
4
 
5
5
  export class RefinementSpec {
6
6
  constructor() {
@@ -37,25 +37,20 @@ export class RefinementSpec {
37
37
  */
38
38
  const array_buffer = new ArrayBuffer(160);
39
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
40
 
48
41
  /**
49
42
  * Contains transformation from camera space to object space
50
43
  * @type {Float32Array|number[]|mat4}
51
44
  */
52
- this.projection_matrix = new Float32Array(array_buffer, 24 * 4, 16);
45
+ this.projection_matrix = new Float32Array(array_buffer, 0, 16);
53
46
 
54
47
  /**
55
- * Model world transform
56
- * @type {Float32Array|number[]|mat4}
48
+ * Object-space camera frustum
49
+ * Frustum planes in compact form
50
+ * @type {Float32Array}
57
51
  */
58
- // this.transform = new Float32Array(16);
52
+ this.frustum_f32 = new Float32Array(array_buffer, 64, 24);
53
+
59
54
 
60
55
  /**
61
56
  * Object-space camera position
@@ -68,6 +63,11 @@ export class RefinementSpec {
68
63
  throw new Error('deprecated, use .frustum_f32 instead');
69
64
  }
70
65
 
66
+ /**
67
+ *
68
+ * @param {number} x
69
+ * @param {number} y
70
+ */
71
71
  setResolution(x, y) {
72
72
  this.resolution.set(x, y);
73
73
 
@@ -79,20 +79,16 @@ export class RefinementSpec {
79
79
  /**
80
80
  *
81
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
82
+ * @param {number[]|mat4|Float32Array|ArrayLike<number>} view_projection_matrix camera's view projection matrix (projection* world_inverse)
84
83
  */
85
- build(transform, matrix_world_inverse, matrix_projection) {
86
- // const _transform = this.transform;
87
- // _transform.set(transform);
84
+ build(transform, view_projection_matrix) {
88
85
 
89
86
  // build projection matrix
90
87
  const projection_matrix = this.projection_matrix;
91
88
 
92
- mat4.multiply(projection_matrix, matrix_world_inverse, transform);
93
- mat4.multiply(projection_matrix, matrix_projection, projection_matrix);
89
+ mat4.multiply(projection_matrix, view_projection_matrix, transform);
94
90
 
95
91
  // compute view frustum in model-space
96
- array_setFromProjectionMatrix(this.frustum_f32, projection_matrix);
92
+ frustum_from_projection_matrix_array(this.frustum_f32, projection_matrix);
97
93
  }
98
94
  }