@woosh/meep-engine 2.34.40 → 2.34.44

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 (55) hide show
  1. package/core/bvh2/BinaryNode.js +10 -8
  2. package/core/bvh2/BinaryNode.spec.js +1 -0
  3. package/core/bvh2/LeafNode.js +2 -1
  4. package/core/bvh2/aabb3/AABB3.js +879 -1059
  5. package/core/bvh2/aabb3/AABB3.spec.js +5 -7
  6. package/core/bvh2/aabb3/aabb3_array_intersects_ray.js +2 -2
  7. package/core/bvh2/aabb3/aabb3_box_surface_area_2.js +10 -0
  8. package/core/bvh2/aabb3/aabb3_compute_half_surface_area.js +16 -0
  9. package/core/bvh2/aabb3/aabb3_compute_surface_area.js +18 -0
  10. package/core/bvh2/aabb3/aabb3_expand_array.js +15 -0
  11. package/core/bvh2/aabb3/aabb3_intersect_aabb3.js +28 -0
  12. package/core/bvh2/aabb3/aabb3_intersect_ray_slab.js +73 -0
  13. package/core/bvh2/aabb3/{aabb3_intersects_frustum.js → aabb3_intersects_frustum_array.js} +16 -1
  14. package/core/bvh2/aabb3/aabb3_intersects_line_segment.js +79 -0
  15. package/core/bvh2/aabb3/aabb3_intersects_ray.js +92 -0
  16. package/core/bvh2/aabb3/{AABB3Math.spec.js → aabb3_intersects_ray.spec.js} +3 -3
  17. package/core/bvh2/aabb3/aabb3_intersects_ray_fast.js +176 -0
  18. package/core/bvh2/aabb3/aabb3_score_boxes_SAH.js +43 -0
  19. package/core/bvh2/aabb3/aabb_score_boxes_SAH_delta.js +37 -0
  20. package/core/bvh2/aabb3/deserializeAABB3.js +17 -0
  21. package/core/bvh2/aabb3/deserializeAABB3Encoded_v0.js +73 -0
  22. package/core/bvh2/aabb3/deserializeAABB3Quantized16Uint.js +36 -0
  23. package/core/bvh2/aabb3/serializeAABB3.js +13 -0
  24. package/core/bvh2/aabb3/serializeAABB3Quantized16Uint.js +33 -0
  25. package/core/bvh2/binary/2/BinaryUint32BVH.js +3 -3
  26. package/core/bvh2/binary/BinaryBVH.js +2 -2
  27. package/core/bvh2/binary/RayLeafIntersectionVisitor.js +2 -2
  28. package/core/bvh2/serialization/deserializeBinaryNode.js +1 -1
  29. package/core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js +2 -1
  30. package/core/bvh2/serialization/serializeBinaryNode.js +1 -1
  31. package/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +2 -1
  32. package/core/bvh2/transform/BottomUpOptimizingRebuilder.js +6 -5
  33. package/core/bvh2/transform/tryRotateSingleNode.js +2 -1
  34. package/core/geom/3d/frustum/{array_setFromProjectionMatrix.js → frustum_from_projection_matrix_array.js} +1 -1
  35. package/core/math/fabsf.js +8 -0
  36. package/engine/development/performance/MetricCollection.js +6 -0
  37. package/engine/graphics/composit/CompositLayer.js +15 -1
  38. package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +7 -0
  39. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +1 -1
  40. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
  41. package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +23 -8
  42. package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +2 -2
  43. package/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +3 -2
  44. package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -2
  45. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  46. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +15 -41
  47. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +5 -1
  48. package/engine/graphics/micron/render/refinement/ActivePatchList.js +2 -2
  49. package/engine/graphics/micron/render/refinement/RefinementSpec.js +16 -20
  50. package/engine/graphics/render/buffer/simple-fx/DepthLimitedBlur.js +27 -4
  51. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +7 -2
  52. package/engine/graphics/render/buffer/simple-fx/ao/SAOShader.js +186 -187
  53. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +3 -3
  54. package/package.json +1 -1
  55. package/core/bvh2/aabb3/AABB3Math.js +0 -579
@@ -0,0 +1,17 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {AABB3} box
5
+ */
6
+ function deserializeAABB3(buffer, box) {
7
+ const x0 = buffer.readFloat64();
8
+ const y0 = buffer.readFloat64();
9
+ const z0 = buffer.readFloat64();
10
+ const x1 = buffer.readFloat64();
11
+ const y1 = buffer.readFloat64();
12
+ const z1 = buffer.readFloat64();
13
+
14
+ box.setBounds(x0, y0, z0, x1, y1, z1);
15
+ }
16
+
17
+ export { deserializeAABB3 };
@@ -0,0 +1,73 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {AABB3} box
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} z0
8
+ * @param {number} x1
9
+ * @param {number} y1
10
+ * @param {number} z1
11
+ */
12
+ export function deserializeAABB3Encoded_v0(buffer, box, x0, y0, z0, x1, y1, z1) {
13
+ const header = buffer.readUint8();
14
+
15
+ //compute value ranges
16
+ const xD = x1 - x0;
17
+ const yD = y1 - y0;
18
+ const zD = z1 - z0;
19
+
20
+
21
+ let qx0;
22
+ let qx1;
23
+
24
+ let qy0;
25
+ let qy1;
26
+
27
+ let qz0;
28
+ let qz1;
29
+
30
+ if ((header & 1) === 0) {
31
+ const _x0 = buffer.readUint16();
32
+ qx0 = (_x0 / 65535) * xD + x0;
33
+ } else {
34
+ qx0 = x0;
35
+ }
36
+
37
+ if ((header & 2) === 0) {
38
+ const _x1 = buffer.readUint16();
39
+ qx1 = (_x1 / 65535) * xD + x0;
40
+ } else {
41
+ qx1 = x1;
42
+ }
43
+
44
+ if ((header & 4) === 0) {
45
+ const _y0 = buffer.readUint16();
46
+ qy0 = (_y0 / 65535) * yD + y0;
47
+ } else {
48
+ qy0 = y0;
49
+ }
50
+
51
+ if ((header & 8) === 0) {
52
+ const _y1 = buffer.readUint16();
53
+ qy1 = (_y1 / 65535) * yD + y0;
54
+ } else {
55
+ qy1 = y1;
56
+ }
57
+
58
+ if ((header & 16) === 0) {
59
+ const _z0 = buffer.readUint16();
60
+ qz0 = (_z0 / 65535) * zD + z0;
61
+ } else {
62
+ qz0 = z0;
63
+ }
64
+
65
+ if ((header & 32) === 0) {
66
+ const _z1 = buffer.readUint16();
67
+ qz1 = (_z1 / 65535) * zD + z0;
68
+ } else {
69
+ qz1 = z1;
70
+ }
71
+
72
+ box.setBounds(qx0, qy0, qz0, qx1, qy1, qz1);
73
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {AABB3} box
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} z0
8
+ * @param {number} x1
9
+ * @param {number} y1
10
+ * @param {number} z1
11
+ */
12
+ export function deserializeAABB3Quantized16Uint(buffer, box, x0, y0, z0, x1, y1, z1) {
13
+ //compute value ranges
14
+ const xD = x1 - x0;
15
+ const yD = y1 - y0;
16
+ const zD = z1 - z0;
17
+
18
+ //read values
19
+ const _x0 = buffer.readUint16();
20
+ const _y0 = buffer.readUint16();
21
+ const _z0 = buffer.readUint16();
22
+ const _x1 = buffer.readUint16();
23
+ const _y1 = buffer.readUint16();
24
+ const _z1 = buffer.readUint16();
25
+
26
+ //quantize all values
27
+ const qx0 = (_x0 / 65535) * xD + x0;
28
+ const qy0 = (_y0 / 65535) * yD + y0;
29
+ const qz0 = (_z0 / 65535) * zD + z0;
30
+
31
+ const qx1 = (_x1 / 65535) * xD + x0;
32
+ const qy1 = (_y1 / 65535) * yD + y0;
33
+ const qz1 = (_z1 / 65535) * zD + z0;
34
+
35
+ box.setBounds(qx0, qy0, qz0, qx1, qy1, qz1);
36
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {AABB3} box
5
+ */
6
+ export function serializeAABB3(buffer, box) {
7
+ buffer.writeFloat64(box.x0);
8
+ buffer.writeFloat64(box.y0);
9
+ buffer.writeFloat64(box.z0);
10
+ buffer.writeFloat64(box.x1);
11
+ buffer.writeFloat64(box.y1);
12
+ buffer.writeFloat64(box.z1);
13
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {AABB3} box
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} z0
8
+ * @param {number} x1
9
+ * @param {number} y1
10
+ * @param {number} z1
11
+ */
12
+ export function serializeAABB3Quantized16Uint(buffer, box, x0, y0, z0, x1, y1, z1) {
13
+ //compute value ranges
14
+ const xD = x1 - x0;
15
+ const yD = y1 - y0;
16
+ const zD = z1 - z0;
17
+
18
+ //quantize all values
19
+ const _x0 = (((box.x0 - x0) / xD) * 65535) | 0;
20
+ const _y0 = (((box.y0 - y0) / yD) * 65535) | 0;
21
+ const _z0 = (((box.z0 - z0) / zD) * 65535) | 0;
22
+
23
+ const _x1 = (((box.x1 - x0) / xD) * 65535) | 0;
24
+ const _y1 = (((box.y1 - y0) / yD) * 65535) | 0;
25
+ const _z1 = (((box.z1 - z0) / zD) * 65535) | 0;
26
+
27
+ buffer.writeUint16(_x0);
28
+ buffer.writeUint16(_y0);
29
+ buffer.writeUint16(_z0);
30
+ buffer.writeUint16(_x1);
31
+ buffer.writeUint16(_y1);
32
+ buffer.writeUint16(_z1);
33
+ }
@@ -3,10 +3,10 @@ import { min2 } from "../../../math/min2.js";
3
3
  import { max2 } from "../../../math/max2.js";
4
4
  import { ceilPowerOfTwo } from "../../../binary/operations/ceilPowerOfTwo.js";
5
5
  import { array_swap } from "../../../collection/array/array_swap.js";
6
- import { _boxSurfaceArea2 } from "../../aabb3/AABB3Math.js";
7
6
  import { mortonEncode_magicbits } from "../../../geom/3d/morton/mortonEncode_magicbits.js";
8
7
  import { min3 } from "../../../math/min3.js";
9
8
  import { max3 } from "../../../math/max3.js";
9
+ import { aabb3_compute_half_surface_area } from "../../aabb3/aabb3_compute_half_surface_area.js";
10
10
 
11
11
  /**
12
12
  * @readonly
@@ -272,7 +272,7 @@ export class BinaryUint32BVH {
272
272
  }
273
273
 
274
274
  this.readBounds(address, box, 0);
275
- result += _boxSurfaceArea2(box[0], box[1], box[2], box[3], box[4], box[5]);
275
+ result += aabb3_compute_half_surface_area(box[0], box[1], box[2], box[3], box[4], box[5]);
276
276
  }
277
277
 
278
278
  return result;
@@ -299,7 +299,7 @@ export class BinaryUint32BVH {
299
299
  const y1 = max3(scratch_box_0[4], scratch_box_1[4], scratch_box_2[4]);
300
300
  const z1 = max3(scratch_box_0[5], scratch_box_1[5], scratch_box_2[5]);
301
301
 
302
- return _boxSurfaceArea2(x0, y0, z0, x1, y1, z1);
302
+ return aabb3_compute_half_surface_area(x0, y0, z0, x1, y1, z1);
303
303
  }
304
304
 
305
305
  /**
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import PrimitiveType from "../../binary/type/PrimitiveTypes.js";
5
5
  import BinaryStructure from "../../binary/type/Type.js";
6
- import { intersectRay } from "../aabb3/AABB3Math.js";
6
+ import { aabb3_intersects_ray } from "../aabb3/aabb3_intersects_ray.js";
7
7
 
8
8
  const NodeType = {
9
9
  LEAF: 0,
@@ -262,7 +262,7 @@ BinaryBVH.prototype.traverseRayLeafIntersections = function (startX, startY, sta
262
262
  const y1 = daNode.read_y1(dataView, address);
263
263
  const z1 = daNode.read_z1(dataView, address);
264
264
 
265
- let b = intersectRay(x0, y0, z0, x1, y1, z1, startX, startY, startZ, directionX, directionY, directionZ);
265
+ let b = aabb3_intersects_ray(x0, y0, z0, x1, y1, z1, startX, startY, startZ, directionX, directionY, directionZ);
266
266
 
267
267
  if (!b) {
268
268
  return false;
@@ -1,7 +1,7 @@
1
1
  import { noop } from "../../function/Functions.js";
2
- import { intersectRay } from "../aabb3/AABB3Math.js";
3
2
  import { IndexedBinaryBVHVisitor } from "./IndexedBinaryBVHVisitor.js";
4
3
  import { NodeType } from "./NodeType.js";
4
+ import { aabb3_intersects_ray } from "../aabb3/aabb3_intersects_ray.js";
5
5
 
6
6
  export class RayLeafIntersectionVisitor extends IndexedBinaryBVHVisitor {
7
7
  constructor() {
@@ -37,7 +37,7 @@ export class RayLeafIntersectionVisitor extends IndexedBinaryBVHVisitor {
37
37
  const y1 = data[address + 4];
38
38
  const z1 = data[address + 5];
39
39
 
40
- const intersectionFound = intersectRay(x0, y0, z0, x1, y1, z1,
40
+ const intersectionFound = aabb3_intersects_ray(x0, y0, z0, x1, y1, z1,
41
41
  this.originX, this.originY, this.originZ,
42
42
  this.directionX, this.directionY, this.directionZ
43
43
  );
@@ -1,6 +1,6 @@
1
- import { deserializeAABB3 } from "../aabb3/AABB3.js";
2
1
  import { BinaryNode } from "../BinaryNode.js";
3
2
  import { deserializeLeafNode, LeafNode } from "../LeafNode.js";
3
+ import { deserializeAABB3 } from "../aabb3/deserializeAABB3.js";
4
4
 
5
5
  /**
6
6
  *
@@ -1,6 +1,7 @@
1
- import { deserializeAABB3, deserializeAABB3Encoded_v0 } from "../aabb3/AABB3.js";
2
1
  import { BinaryNode } from "../BinaryNode.js";
3
2
  import { LeafNode } from "../LeafNode.js";
3
+ import { deserializeAABB3Encoded_v0 } from "../aabb3/deserializeAABB3Encoded_v0.js";
4
+ import { deserializeAABB3 } from "../aabb3/deserializeAABB3.js";
4
5
 
5
6
  /**
6
7
  *
@@ -1,5 +1,5 @@
1
- import { serializeAABB3 } from "../aabb3/AABB3.js";
2
1
  import { isLeaf, serializeLeafNode } from "../LeafNode.js";
2
+ import { serializeAABB3 } from "../aabb3/serializeAABB3.js";
3
3
 
4
4
  /**
5
5
  *
@@ -1,4 +1,5 @@
1
- import { serializeAABB3, serializeAABB3Encoded_v0 } from "../aabb3/AABB3.js";
1
+ import { serializeAABB3Encoded_v0 } from "../aabb3/AABB3.js";
2
+ import { serializeAABB3 } from "../aabb3/serializeAABB3.js";
2
3
 
3
4
  /**
4
5
  *
@@ -1,7 +1,8 @@
1
- import { boxSurfaceArea2, scoreBoxesSAH } from "../aabb3/AABB3Math.js";
2
1
  import { BinaryNode } from "../BinaryNode.js";
3
2
  import { isLeaf } from "../LeafNode.js";
4
3
  import { surfaceAreaHeuristic } from "../sah/surfaceAreaHeuristic.js";
4
+ import { aabb3_score_boxes_SAH } from "../aabb3/aabb3_score_boxes_SAH.js";
5
+ import { aabb3_box_surface_area_2 } from "../aabb3/aabb3_box_surface_area_2.js";
5
6
 
6
7
  function BottomUpOptimizingRebuilder() {
7
8
  this.root = null;
@@ -9,7 +10,7 @@ function BottomUpOptimizingRebuilder() {
9
10
  /**
10
11
  * @type {function(left:NodeDescription, right:NodeDescription):number} heuristic Cost function of pairing two nodes, lower value means better pairing
11
12
  */
12
- this.heuristic = scoreBoxesSAH;
13
+ this.heuristic = aabb3_score_boxes_SAH;
13
14
  }
14
15
 
15
16
  /**
@@ -128,13 +129,13 @@ function leaves(node) {
128
129
  }
129
130
 
130
131
  function sah(left, right) {
131
- const leftArea = boxSurfaceArea2(left);
132
- const rightArea = boxSurfaceArea2(right);
132
+ const leftArea = aabb3_box_surface_area_2(left);
133
+ const rightArea = aabb3_box_surface_area_2(right);
133
134
 
134
135
  const leftLeaves = leaves(left);
135
136
  const rightLeaves = leaves(right);
136
137
 
137
- const commonArea = scoreBoxesSAH(left, right);
138
+ const commonArea = aabb3_score_boxes_SAH(left, right);
138
139
 
139
140
  return surfaceAreaHeuristic(commonArea, leftArea, rightArea, leftLeaves, rightLeaves);
140
141
  }
@@ -1,6 +1,7 @@
1
- import { boxSurfaceArea2 as computeArea, scoreBoxesSAH as computeAreaFor2 } from "../aabb3/AABB3Math.js";
2
1
  import { surfaceAreaHeuristic as sah } from "../sah/surfaceAreaHeuristic.js";
3
2
  import { isLeaf } from "../LeafNode.js";
3
+ import { aabb3_score_boxes_SAH as computeAreaFor2 } from "../aabb3/aabb3_score_boxes_SAH.js";
4
+ import { aabb3_box_surface_area_2 as computeArea } from "../aabb3/aabb3_box_surface_area_2.js";
4
5
 
5
6
  /**
6
7
  *
@@ -25,7 +25,7 @@ function array_set_plane_normalized(destination, destination_offset, x, y, z, w)
25
25
  * @param {number[]|Float32Array} frustum_planes
26
26
  * @param {number[]} me
27
27
  */
28
- export function array_setFromProjectionMatrix(frustum_planes, me) {
28
+ export function frustum_from_projection_matrix_array(frustum_planes, me) {
29
29
 
30
30
  const me0 = me[0];
31
31
  const me3 = me[3];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Float ABS, from standard C lib
3
+ * @param {Number} val
4
+ * @returns {number}
5
+ */
6
+ export function fabsf(val) {
7
+ return val >= 0 ? val : -val;
8
+ }
@@ -10,6 +10,12 @@ export class MetricCollection {
10
10
  this.data = new Map();
11
11
  }
12
12
 
13
+ clear() {
14
+ this.data.forEach((value, key) => {
15
+ value.clear();
16
+ });
17
+ }
18
+
13
19
  /**
14
20
  *
15
21
  * @returns {string[]}
@@ -58,7 +58,7 @@ export class CompositLayer {
58
58
  *
59
59
  * @type {BlendingType}
60
60
  */
61
- this.blending = blending;
61
+ this.__blending = blending;
62
62
  /**
63
63
  *
64
64
  * @type {WebGLRenderTarget}
@@ -98,6 +98,20 @@ export class CompositLayer {
98
98
  };
99
99
  }
100
100
 
101
+ get blending() {
102
+ return this.__blending;
103
+ }
104
+
105
+ set blending(v) {
106
+ if (v === this.__blending) {
107
+ return;
108
+ }
109
+
110
+ this.__blending = v;
111
+
112
+ assignMaterialBlending(this.object.material, v);
113
+ }
114
+
101
115
  /**
102
116
  *
103
117
  * @param {number} v
@@ -8,6 +8,7 @@ import { ObjectPoolFactory } from "../../../../../core/model/object/ObjectPoolFa
8
8
  import { HighlightRenderElement } from "../renderer/HighlightRenderElement.js";
9
9
  import { noop } from "../../../../../core/function/Functions.js";
10
10
  import { CompositingStages } from "../../../composit/CompositingStages.js";
11
+ import { ProcessState } from "../../../../../core/process/ProcessState.js";
11
12
 
12
13
  export class OutlineRenderPlugin extends EnginePlugin {
13
14
  constructor() {
@@ -137,6 +138,12 @@ export class OutlineRenderPlugin extends EnginePlugin {
137
138
  }
138
139
 
139
140
  async startup() {
141
+
142
+ if (this.getState().getValue() === ProcessState.Running) {
143
+ //already running
144
+ return;
145
+ }
146
+
140
147
  const graphics = this.engine.graphics;
141
148
  const viewport_size = graphics.viewport.size;
142
149
 
@@ -58,7 +58,7 @@ function scene_object_filter(object3D) {
58
58
  /**
59
59
  * @type {THREE.Material|null|undefined}
60
60
  */
61
- const material = (object3D.customDepthMaterial !== null ? object3D.customDepthMaterial : object3D.material);
61
+ const material = (object3D.customDepthMaterial ? object3D.customDepthMaterial : object3D.material);
62
62
 
63
63
  if (material && material.visible === false) {
64
64
  //material's main
@@ -1,12 +1,12 @@
1
1
  import { ShadedGeometry } from "./ShadedGeometry.js";
2
2
  import { Transform } from "../../../ecs/transform/Transform.js";
3
3
  import { System } from "../../../ecs/System.js";
4
- import { intersectRay } from "../../../../core/bvh2/aabb3/AABB3Math.js";
5
4
  import { GeometrySpatialQueryAccelerator } from "../../geometry/buffered/query/GeometrySpatialQueryAccelerator.js";
6
5
  import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
7
6
  import { v3_distance_sqr } from "../../../../core/geom/v3_distance_sqr.js";
8
7
  import { mat4 } from "gl-matrix";
9
8
  import { returnTrue } from "../../../../core/function/Functions.js";
9
+ import { aabb3_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
10
10
 
11
11
  /**
12
12
  *
@@ -142,7 +142,7 @@ export class ShadedGeometrySystem extends System {
142
142
  const node = traversal_stack[traversal_cursor];
143
143
 
144
144
  // test node against the ray
145
- const intersects = intersectRay(
145
+ const intersects = aabb3_intersects_ray(
146
146
  node.x0, node.y0, node.z0,
147
147
  node.x1, node.y1, node.z1,
148
148
  origin_x, origin_y, origin_z,
@@ -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
 
@@ -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
 
@@ -460,7 +460,7 @@ function init() {
460
460
 
461
461
  // sample_gltf_sponza();
462
462
  // gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
463
- // sample_lucy();
463
+ sample_lucy();
464
464
  // sample_gltf_hapro_2();
465
465
  // sample_gltf_hapro_1();
466
466
  // sample_gltf_broken_isiflow();
@@ -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
 
@@ -709,6 +709,8 @@ function print_perf_stats() {
709
709
  });
710
710
 
711
711
  console.log(values.join(", "));
712
+
713
+ metrics.clear();
712
714
  }
713
715
 
714
716
  setInterval(print_perf_stats, 2000);
@@ -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