@woosh/meep-engine 2.63.0 → 2.65.0

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 (69) hide show
  1. package/build/meep.cjs +5357 -5350
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +5357 -5350
  4. package/package.json +1 -1
  5. package/src/core/binary/UINT16_MAX.js +5 -0
  6. package/src/core/bvh2/BinaryNode.js +14 -14
  7. package/src/core/bvh2/LeafNode.js +4 -4
  8. package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.d.ts → BVH.d.ts} +1 -1
  9. package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.js → BVH.js} +7 -7
  10. package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.spec.js → BVH.spec.js} +20 -20
  11. package/src/core/bvh2/bvh3/{EBBVHLeafProxy.js → BvhClient.js} +3 -3
  12. package/src/core/bvh2/bvh3/BvhClient.spec.js +51 -0
  13. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +2 -2
  14. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +4 -4
  15. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +3 -3
  16. package/src/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +2 -8
  17. package/src/core/bvh2/bvh3/query/BVHQuery.js +1 -1
  18. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +8 -10
  19. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +7 -7
  20. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js +37 -0
  21. package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +2 -2
  22. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -2
  23. package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +2 -2
  24. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +3 -8
  25. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +2 -2
  26. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +13 -5
  27. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +29 -0
  28. package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +3 -3
  29. package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.spec.js +3 -3
  30. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +3 -3
  31. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +4 -4
  32. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.spec.js +3 -3
  33. package/src/core/collection/list/List.js +9 -3
  34. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +11 -4
  35. package/src/core/geom/Vector2.js +6 -4
  36. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +22 -24
  37. package/src/engine/graphics/ecs/mesh/Mesh.js +8 -8
  38. package/src/engine/graphics/ecs/mesh/MeshSystem.js +3 -5
  39. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +6 -6
  40. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +3 -3
  41. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +16 -18
  42. package/src/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +5 -5
  43. package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +9 -11
  44. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +51 -88
  45. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +41 -72
  46. package/src/engine/graphics/particles/particular/engine/emitter/write_particle_patch_uv.js +28 -0
  47. package/src/engine/graphics/render/forward_plus/LightManager.js +30 -32
  48. package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +3 -3
  49. package/src/engine/graphics/sh3/LightProbeVolume.js +19 -19
  50. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +4 -6
  51. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +17 -19
  52. package/src/engine/sound/ecs/emitter/SoundEmitter.js +18 -16
  53. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +20 -22
  54. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +0 -81
  55. package/src/engine/ecs/foliage/Foliage.js +0 -151
  56. package/src/engine/ecs/foliage/FoliageLoader.js +0 -39
  57. package/src/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +0 -27
  58. package/src/engine/ecs/foliage/ImpostorFoliage.js +0 -106
  59. package/src/engine/ecs/foliage/InstancedFoliage.js +0 -395
  60. package/src/engine/ecs/foliage/ViewState.js +0 -181
  61. package/src/engine/ecs/foliage/ecs/Foliage2System.js +0 -333
  62. package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +0 -70
  63. package/src/engine/ecs/foliage/ecs/InstancedMeshLayer.js +0 -138
  64. package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +0 -28
  65. package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +0 -64
  66. package/src/engine/ecs/foliage/ecs/optimizeIndividualMeshesEntitiesToInstances.js +0 -233
  67. package/src/engine/save/storage/GooglePlayStorage.js +0 -47
  68. package/src/engine/save/storage/JsonStringCodec.js +0 -24
  69. /package/src/engine/sound/ecs/emitter/{SoundEmitter.spec.js → SoundEmitterSerializationAdapter.spec.js} +0 -0
@@ -1,23 +1,24 @@
1
- import {Box3, BufferGeometry, Frustum, Points, PointsMaterial} from 'three';
2
- import {assert} from "../../../../../../core/assert.js";
3
- import {EBBVHLeafProxy} from "../../../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
4
- import {computeHashIntegerArray} from "../../../../../../core/collection/array/computeHashIntegerArray.js";
1
+ import { Box3, BufferGeometry, Frustum, Points, PointsMaterial } from 'three';
2
+ import { assert } from "../../../../../../core/assert.js";
3
+ import { BvhClient } from "../../../../../../core/bvh2/bvh3/BvhClient.js";
4
+ import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
5
5
  import List from "../../../../../../core/collection/list/List.js";
6
- import {AABB3} from "../../../../../../core/geom/3d/aabb/AABB3.js";
7
- import {aabb3_array_combine} from "../../../../../../core/geom/3d/aabb/aabb3_array_combine.js";
8
- import {compose_matrix4_array} from "../../../../../../core/geom/3d/compose_matrix4_array.js";
6
+ import { AABB3 } from "../../../../../../core/geom/3d/aabb/AABB3.js";
7
+ import { aabb3_array_combine } from "../../../../../../core/geom/3d/aabb/aabb3_array_combine.js";
8
+ import { aabb3_expand_array } from "../../../../../../core/geom/3d/aabb/aabb3_expand_array.js";
9
+ import { compose_matrix4_array } from "../../../../../../core/geom/3d/compose_matrix4_array.js";
9
10
  import Quaternion from "../../../../../../core/geom/Quaternion.js";
10
- import {v3_dot_array_array} from "../../../../../../core/geom/vec3/v3_dot_array_array.js";
11
+ import { v3_dot_array_array } from "../../../../../../core/geom/vec3/v3_dot_array_array.js";
11
12
  import Vector3 from "../../../../../../core/geom/Vector3.js";
12
- import {lerp} from "../../../../../../core/math/lerp.js";
13
- import {max2} from "../../../../../../core/math/max2.js";
14
- import {min2} from "../../../../../../core/math/min2.js";
15
- import {frustum_from_camera} from "../../../../ecs/camera/frustum_from_camera.js";
16
- import {BlendingType} from "../../../../texture/sampler/BlendingType.js";
17
- import {ParameterSet} from "../parameter/ParameterSet.js";
18
- import {ParticleParameter} from "../parameter/ParticleParameter.js";
19
- import {update_parameters} from "../simulator/update_parameters.js";
20
- import {computeEmissionFunction} from "./computeEmissionFunction.js";
13
+ import { lerp } from "../../../../../../core/math/lerp.js";
14
+ import { max2 } from "../../../../../../core/math/max2.js";
15
+ import { min2 } from "../../../../../../core/math/min2.js";
16
+ import { frustum_from_camera } from "../../../../ecs/camera/frustum_from_camera.js";
17
+ import { BlendingType } from "../../../../texture/sampler/BlendingType.js";
18
+ import { ParameterSet } from "../parameter/ParameterSet.js";
19
+ import { ParticleParameter } from "../parameter/ParticleParameter.js";
20
+ import { update_parameters } from "../simulator/update_parameters.js";
21
+ import { computeEmissionFunction } from "./computeEmissionFunction.js";
21
22
  import {
22
23
  PARTICLE_ATTRIBUTE_AGE,
23
24
  PARTICLE_ATTRIBUTE_BLEND,
@@ -31,11 +32,12 @@ import {
31
32
  PARTICLE_ATTRIBUTE_UV,
32
33
  PARTICLE_ATTRIBUTE_VELOCITY
33
34
  } from "./PARTICLE_ATTRIBUTES.js";
34
- import {ParticleEmitterFlag} from "./ParticleEmitterFlag.js";
35
- import {ParticleLayer} from "./ParticleLayer.js";
36
- import {ParticleParameters} from "./ParticleParameters.js";
37
- import {ParticlePool} from "./ParticlePool.js";
38
- import {PARTICULAR_PARTICLE_SPECIFICATION} from "./PARTICULAR_PARTICLE_SPECIFICATION.js";
35
+ import { ParticleEmitterFlag } from "./ParticleEmitterFlag.js";
36
+ import { ParticleLayer } from "./ParticleLayer.js";
37
+ import { ParticleParameters } from "./ParticleParameters.js";
38
+ import { ParticlePool } from "./ParticlePool.js";
39
+ import { PARTICULAR_PARTICLE_SPECIFICATION } from "./PARTICULAR_PARTICLE_SPECIFICATION.js";
40
+ import { write_particle_patch_uv } from "./write_particle_patch_uv.js";
39
41
 
40
42
  const EMPTY_GEOMETRY = new BufferGeometry();
41
43
 
@@ -84,34 +86,6 @@ function generateStandardParameterSet(parameters) {
84
86
  }
85
87
 
86
88
 
87
- const UINT16_MAX = 65535; // = 2^16 - 1
88
-
89
- /**
90
- *
91
- * @param {AtlasPatch} patch
92
- * @param {ParticlePool} particles
93
- * @param {number} ref
94
- */
95
- function write_particle_patch_uv(patch, particles, ref) {
96
- const uv = patch.uv;
97
-
98
- const uv_position = uv.position;
99
-
100
- const u0 = uv_position.x;
101
- const v0 = uv_position.y;
102
-
103
- const uv_size = uv.size;
104
-
105
- const u1 = uv_size.x;
106
- const v1 = uv_size.y;
107
-
108
- particles.writeAttributeVector4(
109
- ref,
110
- PARTICLE_ATTRIBUTE_UV,
111
- u0 * UINT16_MAX, v0 * UINT16_MAX, u1 * UINT16_MAX, v1 * UINT16_MAX
112
- );
113
- }
114
-
115
89
  let id_counter = 0;
116
90
 
117
91
  export class ParticleEmitter {
@@ -122,6 +96,7 @@ export class ParticleEmitter {
122
96
 
123
97
  /**
124
98
  * @private
99
+ * @readonly
125
100
  * @type {List<ParticleLayer>}
126
101
  */
127
102
  layers = new List();
@@ -137,6 +112,7 @@ export class ParticleEmitter {
137
112
  /**
138
113
  *
139
114
  * @type {Vector3}
115
+ * @readonly
140
116
  * @private
141
117
  */
142
118
  __lastSpawnPosition = new Vector3(0, 0, 0);
@@ -168,19 +144,20 @@ export class ParticleEmitter {
168
144
 
169
145
  /**
170
146
  * @readonly
171
- * @type {EBBVHLeafProxy}
147
+ * @type {BvhClient}
172
148
  */
173
- bvh_leaf = new EBBVHLeafProxy();
149
+ bvh_leaf = new BvhClient();
174
150
 
175
151
 
176
152
  /**
177
153
  * Upper-bound of bounds for an individual particle
154
+ * @readonly
178
155
  * @type {AABB3}
179
156
  */
180
157
  particleBounds = new AABB3(Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity);
181
158
 
182
159
  /**
183
- *
160
+ * @readonly
184
161
  * @type {AABB3}
185
162
  */
186
163
  emissionBounds = new AABB3(0, 0, 0, 0, 0, 0);
@@ -199,11 +176,14 @@ export class ParticleEmitter {
199
176
  */
200
177
  __hash = 0;
201
178
 
179
+
180
+ /**
181
+ * @readonly
182
+ * @type {ParameterSet}
183
+ */
184
+ parameters = new ParameterSet();
185
+
202
186
  constructor() {
203
- /**
204
- * @type {ParameterSet}
205
- */
206
- this.parameters = new ParameterSet();
207
187
  generateStandardParameterSet(this.parameters);
208
188
 
209
189
 
@@ -506,29 +486,15 @@ export class ParticleEmitter {
506
486
 
507
487
  particles.computeAttributeVector3AxisAlignedBoundingBox(PARTICLE_ATTRIBUTE_POSITION, scratch_array);
508
488
 
509
- let bounds_x0 = scratch_array[0];
510
- let bounds_y0 = scratch_array[1];
511
- let bounds_z0 = scratch_array[2];
512
-
513
- let bounds_x1 = scratch_array[3];
514
- let bounds_y1 = scratch_array[4];
515
- let bounds_z1 = scratch_array[5];
516
-
517
489
  //expand bounds by maximum sprite size
518
490
  const extents = this.computeSpriteMaxHalfSize();
519
491
 
520
- bounds_x0 -= extents;
521
- bounds_y0 -= extents;
522
- bounds_z0 -= extents;
523
-
524
- bounds_x1 += extents;
525
- bounds_y1 += extents;
526
- bounds_z1 += extents;
492
+ aabb3_expand_array(scratch_array, scratch_array, extents);
527
493
 
528
494
  //write updated bonds
529
495
  const bb = this.particleBounds;
530
496
 
531
- bb.setBounds(bounds_x0, bounds_y0, bounds_z0, bounds_x1, bounds_y1, bounds_z1);
497
+ bb.readFromArray(scratch_array);
532
498
 
533
499
  this.updateGeometryBounds();
534
500
 
@@ -620,7 +586,7 @@ export class ParticleEmitter {
620
586
 
621
587
  this.particles.build();
622
588
 
623
- const points = new Points(EMPTY_GEOMETRY, defaultPointsMaterial);
589
+ const points = new Points(EMPTY_GEOMETRY, DEFAULT_POINT_MATERIAL);
624
590
  points.frustumCulled = false;
625
591
  points.matrixAutoUpdate = false;
626
592
 
@@ -683,7 +649,10 @@ export class ParticleEmitter {
683
649
  this.setFlag(ParticleEmitterFlag.Initialized);
684
650
  }
685
651
 
686
- computeHash() {
652
+ /**
653
+ * @returns {number}
654
+ */
655
+ #computeHash() {
687
656
  const parameters_hash = this.parameters.hash();
688
657
  const layers_hash = this.layers.hash();
689
658
 
@@ -703,7 +672,7 @@ export class ParticleEmitter {
703
672
 
704
673
  hash() {
705
674
  if (this.getFlag(ParticleEmitterFlag.HashNeedUpdate)) {
706
- this.__hash = this.computeHash();
675
+ this.__hash = this.#computeHash();
707
676
  this.clearFlag(ParticleEmitterFlag.HashNeedUpdate);
708
677
  }
709
678
 
@@ -747,8 +716,8 @@ export class ParticleEmitter {
747
716
  //assert.notOk(this.particles.hasHoles(), 'Broken pre-condition: particle pool must not have holes. Make sure to call "compact" before sorting');
748
717
 
749
718
  //get font plane of camera
750
- frustum_from_camera(camera, frustum);
751
- const nearPlane = frustum.planes[0];
719
+ frustum_from_camera(camera, scratch_frustum);
720
+ const nearPlane = scratch_frustum.planes[0];
752
721
  const nearPlaneNormal = nearPlane.normal;
753
722
  nearPlaneNormal.toArray(scratch_near_plane_normal);
754
723
 
@@ -824,7 +793,7 @@ export class ParticleEmitter {
824
793
 
825
794
  //check if sprites need updating
826
795
  if (this.getFlag(ParticleEmitterFlag.SpritesNeedUpdate)) {
827
- this.updateSprites();
796
+ this.#updateSprites();
828
797
  }
829
798
  }
830
799
 
@@ -860,7 +829,7 @@ export class ParticleEmitter {
860
829
  /**
861
830
  * Write sprite UVs
862
831
  */
863
- updateSprites() {
832
+ #updateSprites() {
864
833
  const particles = this.particles;
865
834
 
866
835
  const occupancy = particles.occupancy;
@@ -894,8 +863,6 @@ export class ParticleEmitter {
894
863
  * @param {number} timeDelta period over which particles are being spawned, this will ensure that spawned particles have different initial age
895
864
  */
896
865
  spawnLayerParticlesContinuous(layerIndex, timeDelta) {
897
- assert.ok(layerIndex < this.layers.length && layerIndex >= 0, `layerIndex(=${layerIndex}) is out of bounds`);
898
-
899
866
  const layer = this.layers.get(layerIndex);
900
867
 
901
868
  const random = Math.random;
@@ -1020,8 +987,6 @@ export class ParticleEmitter {
1020
987
 
1021
988
  const layers = this.layers;
1022
989
 
1023
- assert.ok(layerIndex < layers.length && layerIndex >= 0, `layerIndex[=${layerIndex}] is out of bounds`);
1024
-
1025
990
  const layer = layers.get(layerIndex);
1026
991
 
1027
992
  const random = Math.random;
@@ -1217,11 +1182,9 @@ ParticleEmitter.SERIALIZABLE_FLAGS = SERIALIZABLE_FLAGS;
1217
1182
 
1218
1183
  const matrix4 = new Float32Array(16);
1219
1184
 
1220
- const defaultPointsMaterial = new PointsMaterial({color: 0xFFFFFF});
1221
-
1222
- const frustum = new Frustum();
1185
+ const DEFAULT_POINT_MATERIAL = new PointsMaterial({ color: 0xFFFFFF });
1223
1186
 
1224
- const position = [];
1187
+ const scratch_frustum = new Frustum();
1225
1188
 
1226
1189
  const v3position = new Vector3();
1227
1190
  const v3velocity = new Vector3();
@@ -1,19 +1,53 @@
1
- import { BitSet } from "../../../../../../core/binary/BitSet.js";
2
- import { max3 } from "../../../../../../core/math/max3.js";
3
1
  import { BufferAttribute, BufferGeometry, StreamDrawUsage } from 'three';
4
- import ObservedValue from "../../../../../../core/model/ObservedValue.js";
5
- import { typed_array_copy } from "../../../../../../core/collection/array/typed/typed_array_copy.js";
6
2
  import { assert } from "../../../../../../core/assert.js";
3
+ import { BitSet } from "../../../../../../core/binary/BitSet.js";
7
4
  import {
8
5
  compute_typed_array_constructor_from_data_type
9
6
  } from "../../../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
10
- import { min2 } from "../../../../../../core/math/min2.js";
11
- import { max2 } from "../../../../../../core/math/max2.js";
7
+ import { typed_array_copy } from "../../../../../../core/collection/array/typed/typed_array_copy.js";
8
+ import { aabb3_from_v3_array } from "../../../../../../core/geom/3d/aabb/aabb3_from_v3_array.js";
9
+ import { max3 } from "../../../../../../core/math/max3.js";
10
+ import ObservedValue from "../../../../../../core/model/ObservedValue.js";
12
11
 
13
12
  const SHRINK_THRESHOLD = 64;
14
13
  const GROW_MIN_STEP = 32;
15
14
 
16
15
  export class ParticlePool {
16
+ /**
17
+ *
18
+ * @type {BitSet}
19
+ */
20
+ occupancy = new BitSet();
21
+
22
+ /**
23
+ *
24
+ * @type {BufferAttribute[]}
25
+ */
26
+ attributes = [];
27
+
28
+ /**
29
+ * @type {ObservedValue.<BufferGeometry>}
30
+ */
31
+ geometry = new ObservedValue(null);
32
+
33
+ /**
34
+ *
35
+ * @type {number}
36
+ */
37
+ growFactor = 1.3;
38
+
39
+ /**
40
+ *
41
+ * @type {number}
42
+ */
43
+ shrinkFactor = 0.5;
44
+
45
+ /**
46
+ *
47
+ * @type {number}
48
+ */
49
+ capacity = 16;
50
+
17
51
  /**
18
52
  *
19
53
  * @param {VertexDataSpec} spec
@@ -28,40 +62,6 @@ export class ParticlePool {
28
62
  */
29
63
  this.spec = spec;
30
64
 
31
- /**
32
- *
33
- * @type {BitSet}
34
- */
35
- this.occupancy = new BitSet();
36
-
37
- /**
38
- *
39
- * @type {BufferAttribute[]}
40
- */
41
- this.attributes = [];
42
-
43
- /**
44
- * @type {ObservedValue.<BufferGeometry>}
45
- */
46
- this.geometry = new ObservedValue(null);
47
-
48
- /**
49
- *
50
- * @type {number}
51
- */
52
- this.growFactor = 1.3;
53
-
54
- /**
55
- *
56
- * @type {number}
57
- */
58
- this.shrinkFactor = 0.5;
59
-
60
- /**
61
- *
62
- * @type {number}
63
- */
64
- this.capacity = 16;
65
65
 
66
66
  this.build();
67
67
  }
@@ -521,42 +521,11 @@ export class ParticlePool {
521
521
  throw new Error(`Attribute item_size is expected to be 3, instead was '${item_size}'`);
522
522
  }
523
523
 
524
- let bounds_x0 = Infinity;
525
- let bounds_y0 = Infinity;
526
- let bounds_z0 = Infinity;
527
-
528
- let bounds_x1 = -Infinity;
529
- let bounds_y1 = -Infinity;
530
- let bounds_z1 = -Infinity;
531
-
532
524
  const particle_count = this.size();
533
525
 
534
526
  const data = attribute.array;
535
527
 
536
- for (let i = 0; i < particle_count; i++) {
537
- const particle_address = i * 3;
538
-
539
- const x = data[particle_address];
540
- const y = data[particle_address + 1];
541
- const z = data[particle_address + 2];
542
-
543
- bounds_x0 = min2(bounds_x0, x);
544
- bounds_y0 = min2(bounds_y0, y);
545
- bounds_z0 = min2(bounds_z0, z);
546
-
547
- bounds_x1 = max2(bounds_x1, x);
548
- bounds_y1 = max2(bounds_y1, y);
549
- bounds_z1 = max2(bounds_z1, z);
550
- }
551
-
552
- // read out
553
- result[0] = bounds_x0;
554
- result[1] = bounds_y0;
555
- result[2] = bounds_z0;
556
-
557
- result[3] = bounds_x1;
558
- result[4] = bounds_y1;
559
- result[5] = bounds_z1;
528
+ aabb3_from_v3_array(result,data,particle_count*3);
560
529
 
561
530
  }
562
531
 
@@ -0,0 +1,28 @@
1
+ import { UINT16_MAX } from "../../../../../../core/binary/UINT16_MAX.js";
2
+ import { PARTICLE_ATTRIBUTE_UV } from "./PARTICLE_ATTRIBUTES.js";
3
+
4
+ /**
5
+ *
6
+ * @param {AtlasPatch} patch
7
+ * @param {ParticlePool} particles
8
+ * @param {number} ref
9
+ */
10
+ export function write_particle_patch_uv(patch, particles, ref) {
11
+ const uv = patch.uv;
12
+
13
+ const uv_position = uv.position;
14
+
15
+ const u0 = uv_position.x;
16
+ const v0 = uv_position.y;
17
+
18
+ const uv_size = uv.size;
19
+
20
+ const u1 = uv_size.x;
21
+ const v1 = uv_size.y;
22
+
23
+ particles.writeAttributeVector4(
24
+ ref,
25
+ PARTICLE_ATTRIBUTE_UV,
26
+ u0 * UINT16_MAX, v0 * UINT16_MAX, u1 * UINT16_MAX, v1 * UINT16_MAX
27
+ );
28
+ }
@@ -1,4 +1,4 @@
1
- import { LightRenderMetadata } from "./LightRenderMetadata.js";
1
+ import { mat4 } from "gl-matrix";
2
2
  import {
3
3
  ClampToEdgeWrapping,
4
4
  DataTexture,
@@ -12,45 +12,43 @@ import {
12
12
  UnsignedByteType,
13
13
  UnsignedShortType
14
14
  } from "three";
15
- import Vector3 from "../../../../core/geom/Vector3.js";
16
- import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
17
- import { computeFrustumCorners } from "./computeFrustumCorners.js";
18
- import { read_plane_pair } from "./cluster/read_plane_pair.js";
19
- import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
20
- import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
21
- import { TextureBackedMemoryRegion } from "../../texture/TextureBackedMemoryRegion.js";
22
15
  import { assert } from "../../../../core/assert.js";
16
+ import { computeBinaryDataTypeByPrecision } from "../../../../core/binary/type/computeBinaryDataTypeByPrecision.js";
23
17
  import {
24
18
  DataType2TypedArrayConstructorMapping
25
19
  } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
26
- import { NumericType } from "../../../../core/math/NumericType.js";
27
- import { computeBinaryDataTypeByPrecision } from "../../../../core/binary/type/computeBinaryDataTypeByPrecision.js";
28
- import { computeThreeTextureTypeFromDataType } from "../../texture/computeThreeTextureTypeFromDataType.js";
29
- import {
30
- computeThreeTextureInternalFormatFromDataType
31
- } from "../../texture/computeThreeTextureInternalFormatFromDataType.js";
32
20
  import { BinaryUint32BVH } from "../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
33
- import { mat4 } from "gl-matrix";
34
- import { TextureAtlas } from "../../texture/atlas/TextureAtlas.js";
35
- import { CachingTextureAtlas } from "../../texture/atlas/CachingTextureAtlas.js";
36
- import { writeSample2DDataToDataTexture } from "../../texture/sampler/writeSampler2DDataToDataTexture.js";
37
- import { Decal } from "./model/Decal.js";
38
- import { ReferencedTextureAtlas } from "../../texture/atlas/ReferencedTextureAtlas.js";
39
- import { v3_morton_encode_transformed } from "../../../../core/geom/3d/morton/v3_morton_encode_transformed.js";
40
- import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
21
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
22
+ import {
23
+ bvh_query_user_data_overlaps_frustum
24
+ } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
41
25
  import { array_copy } from "../../../../core/collection/array/array_copy.js";
42
26
  import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
43
- import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
44
27
  import { arraySwapElements } from "../../../../core/collection/array/arraySwapElements.js";
45
- import { slice_frustum_linear_to_points } from "../../../../core/geom/3d/frustum/slice_frustum_linear_to_points.js";
46
28
  import { read_cluster_frustum_corners } from "../../../../core/geom/3d/frustum/read_cluster_frustum_corners.js";
47
- import { assign_cluster, LOOKUP_CACHE, scratch_corners, scratch_frustum_planes } from "./assign_cluster.js";
48
- import {
49
- ExplicitBinaryBoundingVolumeHierarchy
50
- } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
29
+ import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
30
+ import { slice_frustum_linear_to_points } from "../../../../core/geom/3d/frustum/slice_frustum_linear_to_points.js";
31
+ import { v3_morton_encode_transformed } from "../../../../core/geom/3d/morton/v3_morton_encode_transformed.js";
32
+ import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
33
+ import Vector3 from "../../../../core/geom/Vector3.js";
34
+ import { NumericType } from "../../../../core/math/NumericType.js";
35
+ import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
36
+ import { CachingTextureAtlas } from "../../texture/atlas/CachingTextureAtlas.js";
37
+ import { ReferencedTextureAtlas } from "../../texture/atlas/ReferencedTextureAtlas.js";
38
+ import { TextureAtlas } from "../../texture/atlas/TextureAtlas.js";
51
39
  import {
52
- bvh_query_user_data_overlaps_frustum
53
- } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
40
+ computeThreeTextureInternalFormatFromDataType
41
+ } from "../../texture/computeThreeTextureInternalFormatFromDataType.js";
42
+ import { computeThreeTextureTypeFromDataType } from "../../texture/computeThreeTextureTypeFromDataType.js";
43
+ import { writeSample2DDataToDataTexture } from "../../texture/sampler/writeSampler2DDataToDataTexture.js";
44
+ import { TextureBackedMemoryRegion } from "../../texture/TextureBackedMemoryRegion.js";
45
+ import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
46
+ import { assign_cluster, LOOKUP_CACHE, scratch_corners, scratch_frustum_planes } from "./assign_cluster.js";
47
+ import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
48
+ import { read_plane_pair } from "./cluster/read_plane_pair.js";
49
+ import { computeFrustumCorners } from "./computeFrustumCorners.js";
50
+ import { LightRenderMetadata } from "./LightRenderMetadata.js";
51
+ import { Decal } from "./model/Decal.js";
54
52
  import { point_light_inside_volume } from "./query/point_light_inside_volume.js";
55
53
 
56
54
 
@@ -137,9 +135,9 @@ export class LightManager {
137
135
 
138
136
  /**
139
137
  * @readonly
140
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
138
+ * @type {BVH}
141
139
  */
142
- #light_data_bvh = new ExplicitBinaryBoundingVolumeHierarchy();
140
+ #light_data_bvh = new BVH();
143
141
 
144
142
  /**
145
143
  * Mapping from a light/decal object ID internal metadata
@@ -1,4 +1,4 @@
1
- import { EBBVHLeafProxy } from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
1
+ import { BvhClient } from "../../../../core/bvh2/bvh3/BvhClient.js";
2
2
 
3
3
  export class LightRenderMetadata {
4
4
 
@@ -20,7 +20,7 @@ export class LightRenderMetadata {
20
20
  */
21
21
  this.address = 0;
22
22
 
23
- this.bvh_leaf = new EBBVHLeafProxy();
23
+ this.bvh_leaf = new BvhClient();
24
24
  }
25
25
 
26
26
  /**
@@ -42,7 +42,7 @@ export class LightRenderMetadata {
42
42
 
43
43
  /**
44
44
  *
45
- * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
45
+ * @param {BVH} bvh
46
46
  */
47
47
  link(bvh) {
48
48
  this.bvh_leaf.link(bvh, this.light.id);
@@ -1,13 +1,3 @@
1
- import { TetrahedralMesh } from "../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
2
- import {
3
- compute_delaunay_tetrahedral_mesh
4
- } from "../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
5
- import { visualise_probe } from "./visualise_probe.js";
6
- import {
7
- build_tetrahedral_mesh_buffer_geometry
8
- } from "../../../core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js";
9
- import Entity from "../../ecs/Entity.js";
10
- import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
11
1
  import {
12
2
  CubeCamera,
13
3
  LinearEncoding,
@@ -17,19 +7,29 @@ import {
17
7
  Scene,
18
8
  WebGLCubeRenderTarget
19
9
  } from "three";
20
- import { DrawMode } from "../ecs/mesh-v2/DrawMode.js";
21
- import { Transform } from "../../ecs/transform/Transform.js";
22
10
  import { array_copy } from "../../../core/collection/array/array_copy.js";
11
+ import { sh3_basis_at } from "../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
12
+ import { sh3_dering_optimize_positive } from "../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
23
13
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
24
- import { Light } from "../ecs/light/Light.js";
14
+ import {
15
+ build_tetrahedral_mesh_buffer_geometry
16
+ } from "../../../core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js";
17
+ import {
18
+ compute_delaunay_tetrahedral_mesh
19
+ } from "../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
20
+ import { TetrahedralMesh } from "../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
21
+ import { v3_length_sqr } from "../../../core/geom/vec3/v3_length_sqr.js";
22
+ import Entity from "../../ecs/Entity.js";
23
+ import { Transform } from "../../ecs/transform/Transform.js";
25
24
  import { threeMakeLight } from "../ecs/light/binding/three/threeMakeLight.js";
25
+ import { Light } from "../ecs/light/Light.js";
26
26
  import { ThreeLightCache } from "../ecs/light/three/ThreeLightCache.js";
27
- import { applyTransformToThreeObject } from "../ecs/mesh/applyTransformToThreeObject.js";
28
27
  import { build_three_object } from "../ecs/mesh-v2/build_three_object.js";
28
+ import { DrawMode } from "../ecs/mesh-v2/DrawMode.js";
29
+ import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
29
30
  import { ShadedGeometryFlags } from "../ecs/mesh-v2/ShadedGeometryFlags.js";
30
- import { v3_length_sqr } from "../../../core/geom/vec3/v3_length_sqr.js";
31
- import { sh3_dering_optimize_positive } from "../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
32
- import { sh3_basis_at } from "../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
31
+ import { applyTransformToThreeObject } from "../ecs/mesh/applyTransformToThreeObject.js";
32
+ import { visualise_probe } from "./visualise_probe.js";
33
33
 
34
34
  const TEMP_CONTACT = new SurfacePoint3();
35
35
 
@@ -333,7 +333,7 @@ class Baker {
333
333
 
334
334
  /**
335
335
  *
336
- * @type {ExplicitBinaryBoundingVolumeHierarchy|null}
336
+ * @type {BVH|null}
337
337
  * @private
338
338
  */
339
339
  this.__bvh = null;
@@ -345,7 +345,7 @@ class Baker {
345
345
  }
346
346
 
347
347
  /**
348
- * @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
348
+ * @param {BVH} bvh
349
349
  */
350
350
  set_bvh(bvh) {
351
351
  this.__bvh = bvh;
@@ -1,11 +1,9 @@
1
- import {
2
- ExplicitBinaryBoundingVolumeHierarchy
3
- } from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
1
+ import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
2
+ import { ebvh_build_for_geometry_morton } from "../../../../core/bvh2/bvh3/ebvh_build_for_geometry_morton.js";
4
3
  import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
5
4
  import {
6
5
  aabb3_signed_distance_sqr_to_point
7
6
  } from "../../../../core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js";
8
- import { ebvh_build_for_geometry_morton } from "../../../../core/bvh2/bvh3/ebvh_build_for_geometry_morton.js";
9
7
  import {
10
8
  computeTriangleRayIntersectionBarycentric
11
9
  } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js";
@@ -28,10 +26,10 @@ export class GeometryBVHBatched {
28
26
  constructor() {
29
27
  /**
30
28
  *
31
- * @type {ExplicitBinaryBoundingVolumeHierarchy}
29
+ * @type {BVH}
32
30
  * @private
33
31
  */
34
- this.__bvh = new ExplicitBinaryBoundingVolumeHierarchy();
32
+ this.__bvh = new BVH();
35
33
 
36
34
  /**
37
35
  *