@woosh/meep-engine 2.60.1 → 2.62.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 +20244 -20262
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +20244 -20262
- package/package.json +1 -1
- package/src/core/binary/BitSet.js +1 -1
- package/src/core/bvh2/BinaryNode.js +16 -13
- package/src/core/bvh2/LeafNode.js +6 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +81 -0
- package/src/core/geom/3d/aabb/AABB3.js +24 -36
- package/src/core/geom/3d/aabb/aabb3_array_compute_from_sphere.js +22 -0
- package/src/core/geom/3d/aabb/aabb3_array_intersects_sphere.js +22 -0
- package/src/core/geom/3d/aabb/aabb3_array_intersects_sphere_array.js +11 -0
- package/src/core/geom/3d/aabb/aabb3_signed_distance_to_aabb3.js +28 -0
- package/src/core/geom/3d/aabb/serializeAABB3Quantized16Uint.js +19 -10
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +30 -182
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.spec.js +27 -1
- package/src/core/geom/3d/tetrahedra/delaunay/Cavity.js +3 -4
- package/src/core/geom/ConicRay.js +16 -21
- package/src/core/geom/ConicRay.spec.js +24 -0
- package/src/core/geom/packing/miniball/Miniball.js +68 -117
- package/src/core/geom/packing/miniball/Miniball.spec.js +3 -3
- package/src/core/geom/packing/miniball/Subspan.js +47 -34
- package/src/core/geom/packing/miniball/miniball_compute_quality.js +64 -0
- package/src/core/math/bessel_3.js +1 -0
- package/src/core/math/random/randomBytes.js +2 -2
- package/src/core/math/sqr.js +8 -0
- package/src/core/model/node-graph/Connection.js +21 -23
- package/src/core/model/node-graph/DataType.js +16 -17
- package/src/core/model/node-graph/NodeGraph.js +49 -50
- package/src/core/model/node-graph/node/NodeDescription.js +42 -44
- package/src/core/model/node-graph/node/NodeInstance.js +59 -60
- package/src/core/model/node-graph/node/NodeInstancePortReference.js +27 -29
- package/src/core/model/node-graph/node/NodeRegistry.js +16 -18
- package/src/core/model/node-graph/node/Port.js +35 -37
- package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +27 -13
- package/src/core/path/computePathDirectory.spec.js +8 -0
- package/src/core/process/BaseProcess.d.ts +5 -0
- package/src/core/process/WatchDog.js +76 -75
- package/src/core/process/action/AsynchronousAction.js +24 -22
- package/src/core/process/executor/profile/Profile.js +34 -24
- package/src/core/process/executor/profile/TraceEvent.js +75 -75
- package/src/core/process/worker/OnDemandWorkerManager.js +27 -30
- package/src/core/process/worker/WorkerBuilder.js +149 -149
- package/src/core/process/worker/WorkerProxy.js +25 -21
- package/src/core/process/worker/extractTransferables.js +2 -2
- package/src/engine/Engine.js +58 -53
- package/src/engine/EngineConfiguration.d.ts +4 -4
- package/src/engine/ecs/EntityManager.js +517 -614
- package/src/engine/ecs/System.js +2 -2
- package/src/engine/ecs/foliage/ecs/Foliage2System.js +3 -0
- package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +4 -1
- package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +64 -0
- package/src/engine/ecs/foliage/ecs/{InstancedMeshUtils.js → optimizeIndividualMeshesEntitiesToInstances.js} +11 -70
- package/src/engine/ecs/transform/Transform.d.ts +7 -5
- package/src/engine/ecs/transform/Transform.js +30 -16
- package/src/engine/ecs/validateSystem.js +89 -0
- package/src/engine/graphics/GraphicsEngine.js +433 -483
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +42 -46
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +2 -2
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +49 -52
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +52 -56
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +20 -22
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +43 -25
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +160 -180
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +37 -41
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +63 -67
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +46 -50
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +61 -65
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +48 -52
- package/src/engine/graphics/shadows/testShadowMapRendering.js +28 -32
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +22 -20
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.js +10 -13
- package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +1 -1
- package/src/engine/plugin/EnginePluginManager.d.ts +6 -1
- package/src/engine/sound/dB2Volume.js +8 -0
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +125 -99
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.js +4 -42
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +31 -121
- package/src/engine/sound/volume2dB.js +8 -0
- package/src/generation/theme/ThemeEngine.js +19 -53
- package/src/engine/ecs/components/ClingToHeightMap.js +0 -19
- package/src/engine/ecs/components/SynchronizePosition.js +0 -15
- package/src/engine/ecs/systems/ClingToHeightMapSystem.js +0 -170
- package/src/engine/ecs/systems/SynchronizePositionSystem.js +0 -43
- package/src/engine/graphics/geometry/bvh/buffered/BVHFromBufferGeometry.js +0 -133
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import Army from "../../../../../model/game/ecs/component/army/Army.js";
|
|
2
|
+
import {
|
|
3
|
+
initializeGameBinarySerializationRegistry
|
|
4
|
+
} from "../../../../../model/game/GameBinarySerializationRegistry.js";
|
|
5
|
+
import { enableEditor } from "../../../../editor/enableEditor.js";
|
|
6
|
+
import Vector2 from "../../../core/geom/Vector2.js";
|
|
7
|
+
import { ArrayBufferLoader } from "../../asset/loaders/ArrayBufferLoader.js";
|
|
8
|
+
import { AttachmentSystem } from "../../ecs/attachment/AttachmentSystem.js";
|
|
9
|
+
import { SerializationMetadata } from "../../ecs/components/SerializationMetadata.js";
|
|
10
|
+
import Entity from "../../ecs/Entity.js";
|
|
11
|
+
import GUIElement from "../../ecs/gui/GUIElement.js";
|
|
5
12
|
import GUIElementSystem from "../../ecs/gui/GUIElementSystem.js";
|
|
6
13
|
import HeadsUpDisplaySystem from "../../ecs/gui/hud/HeadsUpDisplaySystem.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { SoundEmitterSystem } from "../../sound/ecs/emitter/SoundEmitterSystem.js";
|
|
10
|
-
import SoundControllerSystem from "../../sound/ecs/SoundControllerSystem.js";
|
|
11
|
-
import SoundListenerSystem from "../../sound/ecs/SoundListenerSystem.js";
|
|
14
|
+
import ViewportPosition from "../../ecs/gui/position/ViewportPosition.js";
|
|
15
|
+
import ViewportPositionSystem from "../../ecs/gui/position/ViewportPositionSystem.js";
|
|
12
16
|
import AnimationSystem from "../../ecs/systems/AnimationSystem.js";
|
|
13
|
-
import
|
|
14
|
-
import { CameraSystem } from "../ecs/camera/CameraSystem.js";
|
|
17
|
+
import TagSystem from "../../ecs/systems/TagSystem.js";
|
|
15
18
|
import ClingToTerrainSystem from "../../ecs/terrain/ecs/cling/ClingToTerrainSystem.js";
|
|
16
19
|
import TerrainSystem from "../../ecs/terrain/ecs/TerrainSystem.js";
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import ViewportPositionSystem from "../../ecs/gui/position/ViewportPositionSystem.js";
|
|
20
|
-
import SynchronizePositionSystem from "../../ecs/systems/SynchronizePositionSystem.js";
|
|
20
|
+
import { EngineConfiguration } from "../../EngineConfiguration.js";
|
|
21
|
+
import { EngineHarness } from "../../EngineHarness.js";
|
|
21
22
|
import InputControllerSystem from "../../input/ecs/systems/InputControllerSystem.js";
|
|
22
23
|
import { InputSystem } from "../../input/ecs/systems/InputSystem.js";
|
|
24
|
+
import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
25
|
+
import { loadSerializedScene } from "../../scene/SerializedScene.js";
|
|
26
|
+
import { SoundEmitterSystem } from "../../sound/ecs/emitter/SoundEmitterSystem.js";
|
|
27
|
+
import SoundControllerSystem from "../../sound/ecs/SoundControllerSystem.js";
|
|
28
|
+
import SoundListenerSystem from "../../sound/ecs/SoundListenerSystem.js";
|
|
29
|
+
import { CameraSystem } from "../ecs/camera/CameraSystem.js";
|
|
30
|
+
import TopDownCameraControllerSystem from "../ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
23
31
|
import MeshHighlightSystem from "../ecs/highlight/system/MeshHighlightSystem.js";
|
|
24
32
|
import LightSystem from "../ecs/light/LightSystem.js";
|
|
25
|
-
import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
26
|
-
import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
|
|
27
|
-
import { ParticleEmitterSystem } from "../particles/ecs/ParticleEmitterSystem.js";
|
|
28
33
|
import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
29
|
-
import { ArrayBufferLoader } from "../../asset/loaders/ArrayBufferLoader.js";
|
|
30
|
-
import {
|
|
31
|
-
initializeGameBinarySerializationRegistry
|
|
32
|
-
} from "../../../../../model/game/GameBinarySerializationRegistry.js";
|
|
33
|
-
import WaterSystem from "../ecs/water/WaterSystem.js";
|
|
34
|
-
import Army from "../../../../../model/game/ecs/component/army/Army.js";
|
|
35
34
|
import Mesh from "../ecs/mesh/Mesh.js";
|
|
36
|
-
import
|
|
35
|
+
import { MeshSystem } from "../ecs/mesh/MeshSystem.js";
|
|
36
|
+
import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
|
|
37
|
+
import Trail2DSystem from "../ecs/trail2d/Trail2DSystem.js";
|
|
38
|
+
import WaterSystem from "../ecs/water/WaterSystem.js";
|
|
39
|
+
import { ParticleEmitterSystem } from "../particles/ecs/ParticleEmitterSystem.js";
|
|
37
40
|
import { buildCanvasViewFromTexture } from "../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
38
|
-
import ViewportPosition from "../../ecs/gui/position/ViewportPosition.js";
|
|
39
|
-
import Vector2 from "../../../core/geom/Vector2.js";
|
|
40
|
-
import GUIElement from "../../ecs/gui/GUIElement.js";
|
|
41
|
-
import { enableEditor } from "../../../../editor/enableEditor.js";
|
|
42
|
-
import { SerializationMetadata } from "../../ecs/components/SerializationMetadata.js";
|
|
43
41
|
|
|
44
42
|
const eh = new EngineHarness();
|
|
45
43
|
|
|
@@ -84,9 +82,7 @@ function makeConfig(engine) {
|
|
|
84
82
|
new ClingToTerrainSystem(),
|
|
85
83
|
new TerrainSystem(graphics, assetManager),
|
|
86
84
|
new Trail2DSystem(engine),
|
|
87
|
-
new Foliage2System(assetManager, graphics),
|
|
88
85
|
new ViewportPositionSystem(graphics.viewport.size),
|
|
89
|
-
new SynchronizePositionSystem(),
|
|
90
86
|
new InputControllerSystem(devices),
|
|
91
87
|
new InputSystem(devices),
|
|
92
88
|
new MeshHighlightSystem(engine),
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Sampler2D} from "../Sampler2D.js";
|
|
2
|
+
import {sampler2d_scale_down_lanczos} from "./sampler2d_scale_down_lanczos.js";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
describe.skip("currently broken", () => {
|
|
5
|
+
test("scale down 2x2 to 1x1 single channel", () => {
|
|
6
|
+
const input = new Sampler2D([1, 2, 3, 4], 1, 2, 2);
|
|
7
|
+
const output = new Sampler2D([7], 1, 1, 1);
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
sampler2d_scale_down_lanczos(input, output);
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
});
|
|
11
|
+
expect(output.readChannel(0, 0, 0)).toBeCloseTo(2.5);
|
|
12
|
+
});
|
|
12
13
|
|
|
13
|
-
test("scale down 3x1 to 1x1", () => {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
test("scale down 3x1 to 1x1", () => {
|
|
15
|
+
const input = new Sampler2D([1, 2, 3], 1, 3, 1);
|
|
16
|
+
const output = new Sampler2D([7], 1, 1, 1);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
sampler2d_scale_down_lanczos(input, output);
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
});
|
|
20
|
+
expect(output.readChannel(0, 0, 0)).toBeCloseTo(2);
|
|
21
|
+
});
|
|
21
22
|
|
|
22
|
-
test("scale down 1x3 to 1x1", () => {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
test("scale down 1x3 to 1x1", () => {
|
|
24
|
+
const input = new Sampler2D([1, 2, 3], 1, 1, 3);
|
|
25
|
+
const output = new Sampler2D([7], 1, 1, 1);
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
sampler2d_scale_down_lanczos(input, output);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
});
|
|
29
|
+
expect(output.readChannel(0, 0, 0)).toBeCloseTo(2);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {assert} from "../../../../../core/assert.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -37,38 +37,35 @@ export function sampler2d_scale_down_linear(input, output) {
|
|
|
37
37
|
const input_data = input.data;
|
|
38
38
|
const output_data = output.data;
|
|
39
39
|
|
|
40
|
-
let
|
|
41
|
-
let x, y;
|
|
42
|
-
|
|
43
|
-
for (y = 0; y < oH; y++) {
|
|
40
|
+
for (let y = 0; y < oH; y++) {
|
|
44
41
|
|
|
45
42
|
const sampleOffsetY = y * sH;
|
|
46
43
|
|
|
47
44
|
const row_address = y * oW * itemSize;
|
|
48
45
|
|
|
49
|
-
for (x = 0; x < oW; x++) {
|
|
46
|
+
for (let x = 0; x < oW; x++) {
|
|
50
47
|
|
|
51
48
|
const output_texel_address = row_address + x * itemSize;
|
|
52
49
|
|
|
53
50
|
const sampleOffsetX = x * sW;
|
|
54
51
|
|
|
55
52
|
// accumulate sample
|
|
56
|
-
for (j = 0; j < sH; j++) {
|
|
53
|
+
for (let j = 0; j < sH; j++) {
|
|
57
54
|
const row_index = (sampleOffsetY + j) * iW;
|
|
58
55
|
const texel_offset = row_index + sampleOffsetX;
|
|
56
|
+
let input_texel_address = texel_offset * itemSize;
|
|
59
57
|
|
|
60
|
-
for (i =
|
|
61
|
-
|
|
62
|
-
const iAddress = (texel_offset + i) * itemSize;
|
|
58
|
+
for (let i = sW; i > 0; i--) {
|
|
63
59
|
|
|
64
|
-
for (k = 0; k < itemSize; k++) {
|
|
65
|
-
sample[k] += input_data[k +
|
|
60
|
+
for (let k = 0; k < itemSize; k++) {
|
|
61
|
+
sample[k] += input_data[k + input_texel_address];
|
|
66
62
|
}
|
|
67
63
|
|
|
64
|
+
input_texel_address += itemSize;
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
|
|
71
|
-
for (i = 0; i < itemSize; i++) {
|
|
68
|
+
for (let i = 0; i < itemSize; i++) {
|
|
72
69
|
// dilute the sample
|
|
73
70
|
output_data[output_texel_address + i] = sample[i] * sampleSizeInv;
|
|
74
71
|
//reset sample
|
|
@@ -25,7 +25,7 @@ test("constructor doesn't throw", () => {
|
|
|
25
25
|
new VirtualTexture(assetManager)
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
test("init computes sizes correctly", () => {
|
|
28
|
+
test.skip("init computes sizes correctly", () => {
|
|
29
29
|
const assetManager = mockAssetManager();
|
|
30
30
|
|
|
31
31
|
const sut = new VirtualTexture(assetManager);
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import {BaseProcess} from "../../core/process/BaseProcess";
|
|
1
2
|
import {Reference} from "../reference/v2/Reference";
|
|
2
3
|
|
|
3
4
|
interface Type<T> extends Function {
|
|
4
5
|
new(...args: any[]): T;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export class EnginePluginManager {
|
|
8
|
+
export class EnginePluginManager extends BaseProcess {
|
|
8
9
|
acquire<T>(klass: Type<T>): Promise<Reference<T>>
|
|
9
10
|
|
|
10
11
|
getPlugin<T>(klass: Type<T>): T | undefined
|
|
12
|
+
|
|
13
|
+
startup(): Promise<void>
|
|
14
|
+
|
|
15
|
+
shutdown(): Promise<void>
|
|
11
16
|
}
|
|
@@ -3,43 +3,25 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
import {EBBVHLeafProxy} from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
|
|
7
|
+
import {computeHashIntegerArray} from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
6
8
|
import List from '../../../../core/collection/list/List.js';
|
|
9
|
+
import {aabb3_array_compute_from_sphere} from "../../../../core/geom/3d/aabb/aabb3_array_compute_from_sphere.js";
|
|
7
10
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
8
|
-
import {
|
|
9
|
-
import { SoundEmitterFlags } from "./SoundEmitterFlags.js";
|
|
10
|
-
import { SoundAttenuationFunction } from "./SoundAttenuationFunction.js";
|
|
11
|
-
import {
|
|
12
|
-
interpolate_irradiance_linear
|
|
13
|
-
} from "../../../../core/math/physics/irradiance/interpolate_irradiance_linear.js";
|
|
11
|
+
import {interpolate_irradiance_linear} from "../../../../core/math/physics/irradiance/interpolate_irradiance_linear.js";
|
|
14
12
|
import {
|
|
15
13
|
interpolate_irradiance_lograrithmic
|
|
16
14
|
} from "../../../../core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Convert decibel to percentage volume
|
|
28
|
-
* @param {number} dB
|
|
29
|
-
* @returns {number}
|
|
30
|
-
*/
|
|
31
|
-
function dB2Volume(dB) {
|
|
32
|
-
return Math.pow(10, 0.05 * dB);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Convert percentage volume to decibel
|
|
37
|
-
* @param {number} volume
|
|
38
|
-
* @returns {number}
|
|
39
|
-
*/
|
|
40
|
-
function volume2dB(volume) {
|
|
41
|
-
return 20 * Math.log10(volume);
|
|
42
|
-
}
|
|
15
|
+
import {interpolate_irradiance_smith} from "../../../../core/math/physics/irradiance/interpolate_irradiance_smith.js";
|
|
16
|
+
import {objectKeyByValue} from "../../../../core/model/object/objectKeyByValue.js";
|
|
17
|
+
import {computeHashFloat} from "../../../../core/primitives/numbers/computeHashFloat.js";
|
|
18
|
+
import {number_compare_ascending} from "../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
19
|
+
import {compareStrings} from "../../../../core/primitives/strings/compareStrings.js";
|
|
20
|
+
import {computeStringHash} from "../../../../core/primitives/strings/computeStringHash.js";
|
|
21
|
+
import {SoundAttenuationFunction} from "./SoundAttenuationFunction.js";
|
|
22
|
+
import {SoundEmitterFlags} from "./SoundEmitterFlags.js";
|
|
23
|
+
import {SoundPanningModelType} from "./SoundPanningModelType.js";
|
|
24
|
+
import {SoundTrack} from "./SoundTrack.js";
|
|
43
25
|
|
|
44
26
|
const DEFAULT_DISTANCE_MIN = 1;
|
|
45
27
|
const DEFAULT_DISTANCE_MAX = 10000;
|
|
@@ -50,92 +32,105 @@ const DEFAULT_CHANNEL = null;
|
|
|
50
32
|
* @class
|
|
51
33
|
*/
|
|
52
34
|
export class SoundEmitter {
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @readonly
|
|
39
|
+
* @type {List<SoundTrack>}
|
|
40
|
+
*/
|
|
41
|
+
tracks = new List();
|
|
42
|
+
|
|
53
43
|
/**
|
|
54
44
|
*
|
|
55
|
-
* @
|
|
45
|
+
* @type {String|SoundEmitterChannels|null}
|
|
56
46
|
*/
|
|
57
|
-
|
|
47
|
+
channel = DEFAULT_CHANNEL;
|
|
58
48
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @type {number}
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
__distanceMin = 1;
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @type {number}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
__distanceMax = 10000;
|
|
70
62
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
__distanceRolloff = 1;
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
/**
|
|
71
|
+
* TODO add to binary serialization
|
|
72
|
+
* @type {SoundPanningModelType}
|
|
73
|
+
*/
|
|
74
|
+
panningModel = SoundPanningModelType.HRTF;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Type of attenuation used for sound fall-off, this is only used if Attenuation flag is set
|
|
78
|
+
* @type {SoundAttenuationFunction|number}
|
|
79
|
+
*/
|
|
80
|
+
attenuation = SoundAttenuationFunction.Smith;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @type {number|SoundEmitterFlags}
|
|
85
|
+
*/
|
|
86
|
+
flags = 0;
|
|
84
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @readonly
|
|
90
|
+
*/
|
|
91
|
+
nodes = {
|
|
85
92
|
/**
|
|
86
|
-
* @
|
|
87
|
-
* @type {number}
|
|
88
|
-
* @private
|
|
93
|
+
* @type {GainNode}
|
|
89
94
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
volume: null,
|
|
92
96
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @type {SoundPanningModelType}
|
|
97
|
+
* @type {PannerNode}
|
|
95
98
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
panner: null,
|
|
98
100
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @type {SoundAttenuationFunction|number}
|
|
101
|
+
* @type {GainNode}
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
attenuation: null,
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @type {
|
|
105
|
+
* One of the other nodes, depending on the configuration
|
|
106
|
+
* @type {AudioNode}
|
|
107
107
|
*/
|
|
108
|
-
|
|
108
|
+
endpoint: null
|
|
109
|
+
};
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @type {PannerNode}
|
|
117
|
-
*/
|
|
118
|
-
panner: null,
|
|
119
|
-
/**
|
|
120
|
-
* @type {GainNode}
|
|
121
|
-
*/
|
|
122
|
-
attenuation: null,
|
|
123
|
-
/**
|
|
124
|
-
* One of the other nodes, depending on the configuration
|
|
125
|
-
* @type {AudioNode}
|
|
126
|
-
*/
|
|
127
|
-
endpoint: null
|
|
128
|
-
};
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @type {Vector1}
|
|
114
|
+
*/
|
|
115
|
+
volume = new Vector1(1);
|
|
129
116
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
/**
|
|
118
|
+
* @readonly
|
|
119
|
+
* @type {EBBVHLeafProxy}
|
|
120
|
+
*/
|
|
121
|
+
bvh = new EBBVHLeafProxy();
|
|
135
122
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @constructor
|
|
126
|
+
*/
|
|
127
|
+
constructor() {
|
|
128
|
+
|
|
129
|
+
this.volume.onChanged.add((value) => {
|
|
130
|
+
const volume_node = this.nodes.volume;
|
|
131
|
+
|
|
132
|
+
if (volume_node !== null) {
|
|
133
|
+
volume_node.gain.setValueAtTime(value, 0);
|
|
139
134
|
}
|
|
140
135
|
});
|
|
141
136
|
|
|
@@ -437,6 +432,37 @@ export class SoundEmitter {
|
|
|
437
432
|
}
|
|
438
433
|
}
|
|
439
434
|
|
|
435
|
+
/**
|
|
436
|
+
*
|
|
437
|
+
* @param {number} x
|
|
438
|
+
* @param {number} y
|
|
439
|
+
* @param {number} z
|
|
440
|
+
*/
|
|
441
|
+
updatePosition(x, y, z) {
|
|
442
|
+
if (this.getFlag(SoundEmitterFlags.Spatialization)) {
|
|
443
|
+
//update position of the panner node
|
|
444
|
+
const nodes = this.nodes;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
*
|
|
448
|
+
* @type {PannerNode}
|
|
449
|
+
*/
|
|
450
|
+
const panner = nodes.panner;
|
|
451
|
+
|
|
452
|
+
if (panner !== null) {
|
|
453
|
+
panner.setPosition(x, y, z);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const distanceMax = this.distanceMax;
|
|
458
|
+
|
|
459
|
+
const bounds = this.bvh.bounds;
|
|
460
|
+
|
|
461
|
+
aabb3_array_compute_from_sphere(bounds, 0, x, y, z, distanceMax);
|
|
462
|
+
|
|
463
|
+
this.bvh.write_bounds();
|
|
464
|
+
}
|
|
465
|
+
|
|
440
466
|
/**
|
|
441
467
|
*
|
|
442
468
|
* @param {number} [duration] fade duration in seconds
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SoundTrackFlags } from "./SoundTrackFlags.js";
|
|
5
|
-
import { loadSoundTrackAsset } from "./loadSoundTrackAsset.js";
|
|
1
|
+
import {loadSoundTrackAsset} from "./loadSoundTrackAsset.js";
|
|
2
|
+
import {SoundTrackFlags} from "./SoundTrackFlags.js";
|
|
3
|
+
import {SoundTrackNodes} from "./SoundTrackNodes.js";
|
|
6
4
|
|
|
7
5
|
export class SoundEmitterComponentContext {
|
|
8
6
|
constructor() {
|
|
@@ -31,12 +29,6 @@ export class SoundEmitterComponentContext {
|
|
|
31
29
|
*/
|
|
32
30
|
this.targetNode = null;
|
|
33
31
|
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @type {LeafNode}
|
|
37
|
-
*/
|
|
38
|
-
this.leaf = new LeafNode(this, 0, 0, 0, 0, 0, 0);
|
|
39
|
-
|
|
40
32
|
/**
|
|
41
33
|
*
|
|
42
34
|
* @type {boolean}
|
|
@@ -67,37 +59,7 @@ export class SoundEmitterComponentContext {
|
|
|
67
59
|
const y = position.y;
|
|
68
60
|
const z = position.z;
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
//update position of the panner node
|
|
72
|
-
const nodes = emitter.nodes;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @type {PannerNode}
|
|
77
|
-
*/
|
|
78
|
-
const panner = nodes.panner;
|
|
79
|
-
|
|
80
|
-
if (panner !== null) {
|
|
81
|
-
panner.setPosition(x, y, z);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @type {LeafNode}
|
|
88
|
-
*/
|
|
89
|
-
const bvhLeaf = this.leaf;
|
|
90
|
-
|
|
91
|
-
const distanceMax = emitter.distanceMax;
|
|
92
|
-
|
|
93
|
-
bvhLeaf.resize(
|
|
94
|
-
x - distanceMax,
|
|
95
|
-
y - distanceMax,
|
|
96
|
-
z - distanceMax,
|
|
97
|
-
x + distanceMax,
|
|
98
|
-
y + distanceMax,
|
|
99
|
-
z + distanceMax
|
|
100
|
-
);
|
|
62
|
+
emitter.updatePosition(x, y, z);
|
|
101
63
|
}
|
|
102
64
|
|
|
103
65
|
/**
|