@woosh/meep-engine 2.62.0 → 2.64.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.
- package/build/meep.cjs +1061 -1058
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +1061 -1058
- package/package.json +1 -1
- package/src/core/binary/EncodingBinaryBuffer.js +7 -43
- package/src/core/binary/EncodingBinaryBuffer.spec.js +16 -0
- package/src/core/binary/UINT16_MAX.js +5 -0
- package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +4 -2
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +5 -5
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +8 -10
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +7 -7
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js +37 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +12 -4
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +29 -0
- package/src/core/cache/LoadingCache.js +4 -1
- package/src/core/collection/list/List.js +9 -3
- package/src/core/collection/map/BiMap.js +49 -0
- package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +11 -4
- package/src/core/geom/Vector2.js +6 -4
- package/src/engine/ecs/components/Tag.d.ts +2 -0
- package/src/engine/ecs/components/Tag.js +19 -28
- package/src/engine/ecs/components/Tag.spec.js +47 -0
- package/src/engine/ecs/fow/FogOfWar.js +4 -0
- package/src/engine/ecs/fow/FogOfWarEditor.js +3 -0
- package/src/engine/ecs/terrain/TerrainPreview.js +45 -44
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +22 -4
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +17 -12
- package/src/engine/graphics/ecs/mesh/Mesh.d.ts +0 -4
- package/src/engine/graphics/ecs/mesh/Mesh.js +0 -11
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +57 -67
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +49 -86
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +41 -72
- package/src/engine/graphics/particles/particular/engine/emitter/write_particle_patch_uv.js +28 -0
- package/src/engine/grid/ORTHOGONAL_NEIGHBOURHOOD_MASK.js +11 -0
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +17 -17
- package/src/core/binary/stringToByteArray.js +0 -24
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +0 -81
- package/src/engine/ecs/foliage/Foliage.js +0 -151
- package/src/engine/ecs/foliage/FoliageLoader.js +0 -39
- package/src/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +0 -27
- package/src/engine/ecs/foliage/ImpostorFoliage.js +0 -106
- package/src/engine/ecs/foliage/InstancedFoliage.js +0 -395
- package/src/engine/ecs/foliage/ViewState.js +0 -181
- package/src/engine/ecs/foliage/ecs/Foliage2System.js +0 -333
- package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +0 -70
- package/src/engine/ecs/foliage/ecs/InstancedMeshLayer.js +0 -138
- package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +0 -28
- package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +0 -64
- package/src/engine/ecs/foliage/ecs/optimizeIndividualMeshesEntitiesToInstances.js +0 -233
- package/src/engine/save/storage/GooglePlayStorage.js +0 -47
- package/src/engine/save/storage/JsonStringCodec.js +0 -24
- package/src/engine/save/storage/LocalStorage.js +0 -148
- package/src/engine/save/storage/MsgPackCodec.js +0 -22
- /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 { EBBVHLeafProxy } from "../../../../../../core/bvh2/bvh3/EBBVHLeafProxy.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 {
|
|
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);
|
|
@@ -175,12 +151,13 @@ export class ParticleEmitter {
|
|
|
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
|
-
|
|
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.
|
|
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,
|
|
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
|
-
|
|
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
|
|
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,
|
|
751
|
-
const nearPlane =
|
|
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
|
|
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
|
|
1221
|
-
|
|
1222
|
-
const frustum = new Frustum();
|
|
1185
|
+
const DEFAULT_POINT_MATERIAL = new PointsMaterial({ color: 0xFFFFFF });
|
|
1223
1186
|
|
|
1224
|
-
const
|
|
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 {
|
|
11
|
-
import {
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -8,21 +8,20 @@
|
|
|
8
8
|
import {
|
|
9
9
|
ExplicitBinaryBoundingVolumeHierarchy
|
|
10
10
|
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
} from "../../../../core/
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {IncrementalDeltaSet} from "../../../graphics/render/visibility/IncrementalDeltaSet.js";
|
|
11
|
+
import { bvh_query_user_data_generic } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_generic.js";
|
|
12
|
+
import { BVHQueryIntersectsSphere } from "../../../../core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js";
|
|
13
|
+
import { invokeObjectCompare } from "../../../../core/model/object/invokeObjectCompare.js";
|
|
14
|
+
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
15
|
+
import { SoundAssetLoader } from "../../../asset/loaders/SoundAssetLoader.js";
|
|
16
|
+
import { System } from '../../../ecs/System.js';
|
|
17
|
+
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
18
|
+
import { IncrementalDeltaSet } from "../../../graphics/render/visibility/IncrementalDeltaSet.js";
|
|
20
19
|
import SoundListener from "../SoundListener.js";
|
|
21
|
-
import {SoundEmitter} from './SoundEmitter.js';
|
|
22
|
-
import {SoundEmitterChannel} from "./SoundEmitterChannel.js";
|
|
23
|
-
import {SoundEmitterComponentContext} from "./SoundEmitterComponentContext.js";
|
|
24
|
-
import {SoundEmitterFlags} from "./SoundEmitterFlags.js";
|
|
25
|
-
import {SoundTrackFlags} from "./SoundTrackFlags.js";
|
|
20
|
+
import { SoundEmitter } from './SoundEmitter.js';
|
|
21
|
+
import { SoundEmitterChannel } from "./SoundEmitterChannel.js";
|
|
22
|
+
import { SoundEmitterComponentContext } from "./SoundEmitterComponentContext.js";
|
|
23
|
+
import { SoundEmitterFlags } from "./SoundEmitterFlags.js";
|
|
24
|
+
import { SoundTrackFlags } from "./SoundTrackFlags.js";
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* @readonly
|
|
@@ -272,9 +271,11 @@ export class SoundEmitterSystem extends System {
|
|
|
272
271
|
|
|
273
272
|
const listenerPosition = listenerTransform.position;
|
|
274
273
|
|
|
275
|
-
const
|
|
274
|
+
const query = BVHQueryIntersectsSphere.from([listenerPosition.x, listenerPosition.y, listenerPosition.z, 0]);
|
|
275
|
+
|
|
276
|
+
const matchCount = bvh_query_user_data_generic(
|
|
276
277
|
scratch_array, 0,
|
|
277
|
-
this.__bvh,
|
|
278
|
+
this.__bvh, this.__bvh.root, query
|
|
278
279
|
);
|
|
279
280
|
|
|
280
281
|
for (let i = 0; i < matchCount; i++) {
|
|
@@ -362,6 +363,5 @@ export class SoundEmitterSystem extends System {
|
|
|
362
363
|
}
|
|
363
364
|
|
|
364
365
|
|
|
365
|
-
|
|
366
366
|
}
|
|
367
367
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turns a string into an array of bytes; a "byte" being a JS number in the
|
|
3
|
-
* range 0-255.
|
|
4
|
-
* @param {string} str String value to arrify.
|
|
5
|
-
* @return {Uint8Array} Array of numbers corresponding to the
|
|
6
|
-
* UCS character codes of each character in str.
|
|
7
|
-
*/
|
|
8
|
-
export function stringToByteArray(str) {
|
|
9
|
-
const length = str.length;
|
|
10
|
-
|
|
11
|
-
const output = [];
|
|
12
|
-
let p = 0;
|
|
13
|
-
|
|
14
|
-
for (let i = 0; i < length; i++) {
|
|
15
|
-
let c = str.charCodeAt(i);
|
|
16
|
-
while (c > 0xff) {
|
|
17
|
-
output[p++] = c & 0xff;
|
|
18
|
-
c >>= 8;
|
|
19
|
-
}
|
|
20
|
-
output[p++] = c;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return new Uint8Array(output);
|
|
24
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {SCRATCH_UINT32_TRAVERSAL_STACK} from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
2
|
-
import {aabb3_array_intersects_sphere_array} from "../../../geom/3d/aabb/aabb3_array_intersects_sphere_array.js";
|
|
3
|
-
import {NULL_NODE} from "../ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
4
|
-
import {bvh_collect_user_data} from "./bvh_collect_user_data.js";
|
|
5
|
-
|
|
6
|
-
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
7
|
-
|
|
8
|
-
const scratch_aabb = new Float32Array(6);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {number[]} result
|
|
13
|
-
* @param {number} result_offset
|
|
14
|
-
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
15
|
-
* @param {number[]|Float32Array} sphere
|
|
16
|
-
*/
|
|
17
|
-
export function bvh_query_user_data_overlaps_sphere(
|
|
18
|
-
result,
|
|
19
|
-
result_offset,
|
|
20
|
-
bvh,
|
|
21
|
-
sphere
|
|
22
|
-
) {
|
|
23
|
-
const root = bvh.root;
|
|
24
|
-
|
|
25
|
-
if (root === NULL_NODE) {
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
|
-
const stack_top = stack.pointer++;
|
|
34
|
-
|
|
35
|
-
stack[stack_top] = root;
|
|
36
|
-
|
|
37
|
-
let result_cursor = result_offset;
|
|
38
|
-
|
|
39
|
-
while (stack.pointer > stack_top) {
|
|
40
|
-
stack.pointer--;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @type {number}
|
|
45
|
-
*/
|
|
46
|
-
const node = stack[stack.pointer];
|
|
47
|
-
|
|
48
|
-
// test node against the ray
|
|
49
|
-
bvh.node_get_aabb(node, scratch_aabb);
|
|
50
|
-
const intersection = aabb3_array_intersects_sphere_array(scratch_aabb, sphere);
|
|
51
|
-
|
|
52
|
-
if (intersection === 0) {
|
|
53
|
-
// fully outside
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const node_is_leaf = bvh.node_is_leaf(node);
|
|
58
|
-
|
|
59
|
-
if (node_is_leaf) {
|
|
60
|
-
// leaf node
|
|
61
|
-
result[result_cursor++] = bvh.node_get_user_data(node);
|
|
62
|
-
|
|
63
|
-
} else if (intersection === 2) {
|
|
64
|
-
// fully inside, fast collection path
|
|
65
|
-
result_cursor += bvh_collect_user_data(result, result_cursor, bvh, node);
|
|
66
|
-
} else {
|
|
67
|
-
// partially inside
|
|
68
|
-
// read in-order
|
|
69
|
-
const child1 = bvh.node_get_child1(node);
|
|
70
|
-
const child2 = bvh.node_get_child2(node);
|
|
71
|
-
|
|
72
|
-
// write to stack in reverse order, so that fist child ends up being visited first
|
|
73
|
-
stack[stack.pointer++] = child1;
|
|
74
|
-
stack[stack.pointer++] = child2;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// drop stack frame
|
|
79
|
-
|
|
80
|
-
return result_cursor - result_offset;
|
|
81
|
-
}
|