@woosh/meep-engine 2.34.41 → 2.34.45

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 (58) hide show
  1. package/core/bvh2/BinaryNode.js +10 -8
  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/geom/3d/frustum/{array_setFromProjectionMatrix.js → frustum_from_projection_matrix_array.js} +1 -1
  34. package/core/geom/3d/topology/TopoMesh.js +0 -8
  35. package/core/geom/3d/topology/TopoVertex.js +7 -6
  36. package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +93 -5
  37. package/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +7 -4
  38. package/core/geom/3d/topology/simplify/quadratic/compute_edge_collapse_cost_quadratic.js +7 -1
  39. package/core/geom/3d/topology/simplify/simplifyTopoMesh.js +1 -14
  40. package/core/math/fabsf.js +8 -0
  41. package/engine/development/performance/MetricCollection.js +6 -0
  42. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +1 -1
  43. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
  44. package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +23 -8
  45. package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +2 -2
  46. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -0
  47. package/engine/graphics/micron/build/hierarchy/merge_patches.js +1 -1
  48. package/engine/graphics/micron/convert_three_object_to_micron.js +2 -0
  49. package/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +3 -2
  50. package/engine/graphics/micron/prototypeVirtualGeometry.js +12 -7
  51. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  52. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +16 -43
  53. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +5 -1
  54. package/engine/graphics/micron/render/refinement/ActivePatchList.js +4 -10
  55. package/engine/graphics/micron/render/refinement/RefinementSpec.js +16 -20
  56. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -2
  57. package/package.json +1 -1
  58. package/core/bvh2/aabb3/AABB3Math.js +0 -579
@@ -1,8 +1,8 @@
1
1
  import { EngineHarness } from "../../../../EngineHarness.js";
2
- import { ShadedGeometrySystem } from "../ShadedGeometrySystem.d.ts";
3
- import EntityBuilder from "../../../../ecs/EntityBuilder.d.ts";
4
- import { Transform } from "../../../../ecs/transform/Transform.d.ts";
5
- import { ShadedGeometry } from "../ShadedGeometry.d.ts";
2
+ import { ShadedGeometrySystem } from "../ShadedGeometrySystem.js";
3
+ import EntityBuilder from "../../../../ecs/EntityBuilder.js";
4
+ import { Transform } from "../../../../ecs/transform/Transform.js";
5
+ import { ShadedGeometry } from "../ShadedGeometry.js";
6
6
  import { BoxBufferGeometry, MeshBasicMaterial } from "three";
7
7
 
8
8
  const eh = new EngineHarness();
@@ -22,11 +22,26 @@ async function main(engine) {
22
22
 
23
23
  const ecd = em.dataset;
24
24
 
25
+ const material = new MeshBasicMaterial({
26
+ color: 0xFFFFFF
27
+ });
28
+
29
+ material.visible = false;
30
+
31
+ window.material = material;
32
+
33
+ const g = ShadedGeometry.from(new BoxBufferGeometry(), material);
34
+
35
+
25
36
  new EntityBuilder()
26
- .add(new Transform())
27
- .add(ShadedGeometry.from(new BoxBufferGeometry(), new MeshBasicMaterial({
28
- color: 0xFFFFFF
29
- })))
37
+ .add(Transform.fromJSON({
38
+ position: {
39
+ x: 10,
40
+ y: 1,
41
+ z: 10
42
+ }
43
+ }))
44
+ .add(g)
30
45
  .build(ecd);
31
46
  }
32
47
 
@@ -1,9 +1,9 @@
1
1
  import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
2
2
  import { NodeType } from "../../../../../core/bvh2/binary/NodeType.js";
3
- import { intersectRay } from "../../../../../core/bvh2/aabb3/AABB3Math.js";
4
3
  import Vector3 from "../../../../../core/geom/Vector3.js";
5
4
  import { computeTriangleRayIntersection } from "../../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
6
5
  import { GeometrySpatialAcceleratorVisitor } from "./GeometryVisitor.js";
6
+ import { aabb3_intersects_ray } from "../../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
7
7
 
8
8
  export class RaycastNearestHitComputingVisitor extends GeometrySpatialAcceleratorVisitor {
9
9
  constructor() {
@@ -158,7 +158,7 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
158
158
  const y1 = data[address + 4];
159
159
  const z1 = data[address + 5];
160
160
 
161
- return intersectRay(
161
+ return aabb3_intersects_ray(
162
162
  x0, y0, z0,
163
163
  x1, y1, z1,
164
164
 
@@ -15,6 +15,7 @@ import { compute_buffer_geometry_byte_size } from "../../geometry/buffered/compu
15
15
  import { deinterleaveBufferGeometry } from "../../geometry/buffered/deinterleaveBufferGeometry.js";
16
16
  import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
17
17
  import { aabb3_from_v3_array } from "../../../../core/bvh2/aabb3/aabb3_from_v3_array.js";
18
+ import { update_topo_face_normals } from "../../../../core/geom/3d/topology/update_topo_face_normals.js";
18
19
 
19
20
  /**
20
21
  * Returns current time in milliseconds
@@ -142,6 +143,9 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
142
143
 
143
144
  expandConnectivityByLocality(topoMesh, geometry_aabb);
144
145
 
146
+ // ensure faces have normals for mesh simplification
147
+ update_topo_face_normals(Array.from(topoMesh.getFaces()), topoMesh.getFaces().size);
148
+
145
149
  /**
146
150
  * Used to generate neighbourhood assignment
147
151
  * @type {Map<number, PatchRepresentation>}
@@ -399,7 +399,6 @@ async function many_to_many_merge(
399
399
  collapse_edges(
400
400
  num_desired_faces_to_remove,
401
401
  open_set,
402
- [],
403
402
  merged_mesh,
404
403
  edge_to_collapse_map,
405
404
  vertex_quadratics,
@@ -462,6 +461,7 @@ async function many_to_many_merge(
462
461
  // );
463
462
 
464
463
  const group_per_pixel_error = group_inverse_polycount;
464
+ // const group_per_pixel_error = Math.sqrt(largest_squared_error);
465
465
 
466
466
  // split topology into desired number of pieces
467
467
  const pieces = recursive_split_mesh_partition(merged_mesh, actual_up_count, MICRON_PATCH_SIZE_MAX);
@@ -76,6 +76,8 @@ export async function convert_three_object_to_micron(object, micron_cache = defa
76
76
 
77
77
  await micron_cache.set(g, micron_geometry);
78
78
 
79
+ // console.log(micron_geometry);
80
+
79
81
  return micron_geometry;
80
82
  }
81
83
 
@@ -1,4 +1,5 @@
1
1
  import { squirrel3 } from "../../../../core/math/hash/squirrel3.js";
2
+ import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
2
3
 
3
4
  export class MicronGeometryPatchOccurrence {
4
5
  constructor() {
@@ -21,7 +22,7 @@ export class MicronGeometryPatchOccurrence {
21
22
  this.patch = null;
22
23
  /**
23
24
  *
24
- * @type {THREE.Matrix4|null}
25
+ * @type {number[]|Float32Array|null}
25
26
  */
26
27
  this.transform = null;
27
28
  }
@@ -41,7 +42,7 @@ export class MicronGeometryPatchOccurrence {
41
42
  return this.geometry_id === other.geometry_id
42
43
  && this.instance_id === other.instance_id
43
44
  && this.patch.id === other.patch.id
44
- && this.transform.equals(other.transform)
45
+ && isArrayEqualStrict(this.transform, other.transform)
45
46
  ;
46
47
  }
47
48
 
@@ -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
  }
@@ -303,8 +303,8 @@ async function sample_scene_0(engine) {
303
303
  }
304
304
 
305
305
  // load_model('moicon/06_04_hapro/00-environment/model.gltf', -0.1);
306
- load_model_s('moicon/06_04_hapro/05-ground-floor/model.gltf');
307
- load_model_s('C:/git/moh/app/moicon/06_04_hapro/08-clickable-assets-new/model.gltf');
306
+ // load_model_s('moicon/06_04_hapro/05-ground-floor/model.gltf');
307
+ // load_model_s('C:/git/moh/app/moicon/06_04_hapro/08-clickable-assets-new/model.gltf');
308
308
  // load_model('moicon/06_04_hapro/02-bearers/model.gltf');
309
309
  // load_model('moicon/06_04_hapro/04-1st-floor/model.gltf');
310
310
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.34.41",
8
+ "version": "2.34.45",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",