@babylonjs/core 9.9.1 → 9.9.2
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/AudioV2/abstractAudio/audioEngineV2.d.ts +34 -1
- package/AudioV2/abstractAudio/audioEngineV2.js +54 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +12 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +18 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
- package/AudioV2/abstractAudio/index.d.ts +1 -0
- package/AudioV2/abstractAudio/index.js +1 -0
- package/AudioV2/abstractAudio/index.js.map +1 -1
- package/AudioV2/abstractAudio/pure.d.ts +1 -0
- package/AudioV2/abstractAudio/pure.js +1 -0
- package/AudioV2/abstractAudio/pure.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +7 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +12 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +14 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +4 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +6 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +12 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +2 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +4 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +2 -1
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js +16 -1
- package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js.map +1 -1
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.d.ts +2 -1
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.js +5 -2
- package/FrameGraph/Tasks/Layers/selectionOutlineTask.js.map +1 -1
- package/Gizmos/index.d.ts +1 -0
- package/Gizmos/index.js +1 -0
- package/Gizmos/index.js.map +1 -1
- package/Gizmos/pure.d.ts +1 -0
- package/Gizmos/pure.js +1 -0
- package/Gizmos/pure.js.map +1 -1
- package/Gizmos/spatialAudioGizmo.d.ts +55 -0
- package/Gizmos/spatialAudioGizmo.js +151 -0
- package/Gizmos/spatialAudioGizmo.js.map +1 -0
- package/Layers/selectionOutlineLayer.pure.d.ts +9 -2
- package/Layers/selectionOutlineLayer.pure.js +29 -6
- package/Layers/selectionOutlineLayer.pure.js.map +1 -1
- package/Layers/thinEffectLayer.d.ts +1 -0
- package/Layers/thinEffectLayer.js +7 -4
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.d.ts +17 -3
- package/Layers/thinSelectionOutlineLayer.js +82 -17
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +5 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +54 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.d.ts +13 -0
- package/Materials/PBR/openpbrMaterial.pure.js +17 -0
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.pure.d.ts +2 -1
- package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.pure.js +3 -2
- package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +32 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +180 -22
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +54 -10
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +130 -13
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.d.ts +5 -1
- package/Meshes/abstractMesh.pure.js +92 -2
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.pure.js +143 -2
- package/Meshes/thinInstanceMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.types.d.ts +2 -1
- package/Meshes/thinInstanceMesh.types.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +12 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +8 -0
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.js +4 -2
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +54 -5
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +14 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingVoxel.vertex.js +1 -0
- package/Shaders/gaussianSplattingVoxel.vertex.js.map +1 -1
- package/Shaders/selectionOutline.fragment.js +16 -4
- package/Shaders/selectionOutline.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +56 -5
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +2 -3
- package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +14 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingVoxel.vertex.js +1 -0
- package/ShadersWGSL/gaussianSplattingVoxel.vertex.js.map +1 -1
- package/ShadersWGSL/selectionOutline.fragment.js +14 -2
- package/ShadersWGSL/selectionOutline.fragment.js.map +1 -1
- package/XR/features/WebXRBodyTracking.pure.d.ts +16 -0
- package/XR/features/WebXRBodyTracking.pure.js +167 -30
- package/XR/features/WebXRBodyTracking.pure.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type IDisposable } from "../../scene.js";
|
|
1
2
|
import { type Nullable } from "../../types.js";
|
|
3
|
+
import { type IReadonlyObservable, Observable } from "../../Misc/observable.js";
|
|
2
4
|
import { type IAudioParameterRampOptions } from "../audioParameter.js";
|
|
3
5
|
import { type AbstractAudioNode, type AbstractNamedAudioNode } from "./abstractAudioNode.js";
|
|
4
6
|
import { type AbstractSound } from "./abstractSound.js";
|
|
@@ -9,6 +11,12 @@ import { type IStaticSoundOptions, type StaticSound } from "./staticSound.js";
|
|
|
9
11
|
import { type IStaticSoundBufferOptions, type StaticSoundBuffer } from "./staticSoundBuffer.js";
|
|
10
12
|
import { type IStreamingSoundOptions, type StreamingSound } from "./streamingSound.js";
|
|
11
13
|
import { type AbstractSpatialAudioListener, type ISpatialAudioListenerOptions } from "./subProperties/abstractSpatialAudioListener.js";
|
|
14
|
+
/**
|
|
15
|
+
* Observable that notifies when a new v2 audio engine instance has been created.
|
|
16
|
+
* - Fires after the engine has been fully constructed and initialized (e.g. from {@link CreateAudioEngineAsync}),
|
|
17
|
+
* so subclass state (audio context, listener, etc.) is guaranteed to be available to observers.
|
|
18
|
+
*/
|
|
19
|
+
export declare const OnAudioEngineV2CreatedObservable: Observable<AudioEngineV2>;
|
|
12
20
|
/**
|
|
13
21
|
* Gets the most recently created v2 audio engine.
|
|
14
22
|
* @returns The most recently created v2 audio engine.
|
|
@@ -37,7 +45,12 @@ export type AudioEngineV2State = "closed" | "interrupted" | "running" | "suspend
|
|
|
37
45
|
*
|
|
38
46
|
* A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.
|
|
39
47
|
*/
|
|
40
|
-
export declare abstract class AudioEngineV2 {
|
|
48
|
+
export declare abstract class AudioEngineV2 implements IDisposable {
|
|
49
|
+
/**
|
|
50
|
+
* The list of v2 audio engines that have been created and not yet disposed.
|
|
51
|
+
* - Engines are added on construction and removed on {@link AudioEngineV2.dispose}.
|
|
52
|
+
*/
|
|
53
|
+
static get Instances(): ReadonlyArray<AudioEngineV2>;
|
|
41
54
|
/** Not owned, but all items should be in `_nodes` container, too, which is owned. */
|
|
42
55
|
private readonly _mainBuses;
|
|
43
56
|
private readonly _sounds;
|
|
@@ -46,6 +59,22 @@ export declare abstract class AudioEngineV2 {
|
|
|
46
59
|
private readonly _nodes;
|
|
47
60
|
private _defaultMainBus;
|
|
48
61
|
private _parameterRampDuration;
|
|
62
|
+
private readonly _onNodeAddedObservable;
|
|
63
|
+
private readonly _onNodeRemovedObservable;
|
|
64
|
+
private readonly _onDisposeObservable;
|
|
65
|
+
/**
|
|
66
|
+
* Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is added to this engine.
|
|
67
|
+
*/
|
|
68
|
+
get onNodeAddedObservable(): IReadonlyObservable<AbstractNamedAudioNode>;
|
|
69
|
+
/**
|
|
70
|
+
* Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is removed from this engine.
|
|
71
|
+
*/
|
|
72
|
+
get onNodeRemovedObservable(): IReadonlyObservable<AbstractNamedAudioNode>;
|
|
73
|
+
/**
|
|
74
|
+
* Observable that notifies when this engine is disposed.
|
|
75
|
+
* - Fires from {@link AudioEngineV2.dispose} after the engine has been removed from {@link AudioEngineV2.Instances}.
|
|
76
|
+
*/
|
|
77
|
+
get onDisposeObservable(): IReadonlyObservable<AudioEngineV2>;
|
|
49
78
|
protected constructor(options: Partial<IAudioEngineV2Options>);
|
|
50
79
|
/**
|
|
51
80
|
* The elapsed time since the audio engine was started, in seconds.
|
|
@@ -90,6 +119,10 @@ export declare abstract class AudioEngineV2 {
|
|
|
90
119
|
* The list of static and streaming sounds created by the audio engine.
|
|
91
120
|
*/
|
|
92
121
|
get sounds(): ReadonlyArray<AbstractSound>;
|
|
122
|
+
/**
|
|
123
|
+
* The list of top-level audio nodes (sounds, sound sources, buses, main buses) owned by the audio engine.
|
|
124
|
+
*/
|
|
125
|
+
get nodes(): ReadonlySet<AbstractNamedAudioNode>;
|
|
93
126
|
/**
|
|
94
127
|
* Creates a new audio bus.
|
|
95
128
|
* @param name - The name of the audio bus.
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { Observable } from "../../Misc/observable.js";
|
|
1
2
|
const Instances = [];
|
|
3
|
+
/**
|
|
4
|
+
* Observable that notifies when a new v2 audio engine instance has been created.
|
|
5
|
+
* - Fires after the engine has been fully constructed and initialized (e.g. from {@link CreateAudioEngineAsync}),
|
|
6
|
+
* so subclass state (audio context, listener, etc.) is guaranteed to be available to observers.
|
|
7
|
+
*/
|
|
8
|
+
export const OnAudioEngineV2CreatedObservable = new Observable();
|
|
2
9
|
/**
|
|
3
10
|
* Gets the most recently created v2 audio engine.
|
|
4
11
|
* @returns The most recently created v2 audio engine.
|
|
@@ -15,6 +22,32 @@ export function LastCreatedAudioEngine() {
|
|
|
15
22
|
* A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.
|
|
16
23
|
*/
|
|
17
24
|
export class AudioEngineV2 {
|
|
25
|
+
/**
|
|
26
|
+
* The list of v2 audio engines that have been created and not yet disposed.
|
|
27
|
+
* - Engines are added on construction and removed on {@link AudioEngineV2.dispose}.
|
|
28
|
+
*/
|
|
29
|
+
static get Instances() {
|
|
30
|
+
return Instances;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is added to this engine.
|
|
34
|
+
*/
|
|
35
|
+
get onNodeAddedObservable() {
|
|
36
|
+
return this._onNodeAddedObservable;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is removed from this engine.
|
|
40
|
+
*/
|
|
41
|
+
get onNodeRemovedObservable() {
|
|
42
|
+
return this._onNodeRemovedObservable;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Observable that notifies when this engine is disposed.
|
|
46
|
+
* - Fires from {@link AudioEngineV2.dispose} after the engine has been removed from {@link AudioEngineV2.Instances}.
|
|
47
|
+
*/
|
|
48
|
+
get onDisposeObservable() {
|
|
49
|
+
return this._onDisposeObservable;
|
|
50
|
+
}
|
|
18
51
|
constructor(options) {
|
|
19
52
|
/** Not owned, but all items should be in `_nodes` container, too, which is owned. */
|
|
20
53
|
this._mainBuses = new Set();
|
|
@@ -24,10 +57,19 @@ export class AudioEngineV2 {
|
|
|
24
57
|
this._nodes = new Set();
|
|
25
58
|
this._defaultMainBus = null;
|
|
26
59
|
this._parameterRampDuration = 0.01;
|
|
60
|
+
this._onNodeAddedObservable = new Observable();
|
|
61
|
+
this._onNodeRemovedObservable = new Observable();
|
|
62
|
+
this._onDisposeObservable = new Observable();
|
|
27
63
|
Instances.push(this);
|
|
28
64
|
if (typeof options.parameterRampDuration === "number") {
|
|
29
65
|
this.parameterRampDuration = options.parameterRampDuration;
|
|
30
66
|
}
|
|
67
|
+
// Intentionally do NOT notify {@link OnAudioEngineV2CreatedObservable} here:
|
|
68
|
+
// - This base constructor runs before subclass fields (audio context, listener, ...) are initialized
|
|
69
|
+
// and before any async {@link CreateAudioEngineAsync}-style setup completes, so observers would
|
|
70
|
+
// see a partially constructed engine.
|
|
71
|
+
// - Engine factory functions (e.g. {@link CreateAudioEngineAsync}) call `notifyObservers` themselves
|
|
72
|
+
// once the engine is fully constructed and initialized.
|
|
31
73
|
}
|
|
32
74
|
/**
|
|
33
75
|
* The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.
|
|
@@ -61,6 +103,12 @@ export class AudioEngineV2 {
|
|
|
61
103
|
}
|
|
62
104
|
return this._soundsArray;
|
|
63
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The list of top-level audio nodes (sounds, sound sources, buses, main buses) owned by the audio engine.
|
|
108
|
+
*/
|
|
109
|
+
get nodes() {
|
|
110
|
+
return this._nodes;
|
|
111
|
+
}
|
|
64
112
|
/**
|
|
65
113
|
* Releases associated resources.
|
|
66
114
|
*/
|
|
@@ -77,6 +125,10 @@ export class AudioEngineV2 {
|
|
|
77
125
|
this._sounds.clear();
|
|
78
126
|
this._disposeSoundsArray();
|
|
79
127
|
this._defaultMainBus = null;
|
|
128
|
+
this._onDisposeObservable.notifyObservers(this);
|
|
129
|
+
this._onDisposeObservable.clear();
|
|
130
|
+
this._onNodeAddedObservable.clear();
|
|
131
|
+
this._onNodeRemovedObservable.clear();
|
|
80
132
|
}
|
|
81
133
|
/**
|
|
82
134
|
* Unlocks the audio engine if it is locked.
|
|
@@ -98,9 +150,11 @@ export class AudioEngineV2 {
|
|
|
98
150
|
}
|
|
99
151
|
_addNode(node) {
|
|
100
152
|
this._nodes.add(node);
|
|
153
|
+
this._onNodeAddedObservable.notifyObservers(node);
|
|
101
154
|
}
|
|
102
155
|
_removeNode(node) {
|
|
103
156
|
this._nodes.delete(node);
|
|
157
|
+
this._onNodeRemovedObservable.notifyObservers(node);
|
|
104
158
|
}
|
|
105
159
|
_addSound(sound) {
|
|
106
160
|
this._disposeSoundsArray();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAClC,IAAY,EACZ,MAAiB,EACjB,UAAwC,EAAE,EAC1C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,yBAAyB,CACrC,IAAY,EACZ,MAA4C,EAC5C,UAA2C,EAAE,EAC7C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { type Nullable } from \"../../types\";\nimport { type IAudioParameterRampOptions } from \"../audioParameter\";\nimport { type AbstractAudioNode, type AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport { type AbstractSound } from \"./abstractSound\";\nimport { type AbstractSoundSource, type ISoundSourceOptions } from \"./abstractSoundSource\";\nimport { type AudioBus, type IAudioBusOptions } from \"./audioBus\";\nimport { type IMainAudioBusOptions, type MainAudioBus } from \"./mainAudioBus\";\nimport { type IStaticSoundOptions, type StaticSound } from \"./staticSound\";\nimport { type IStaticSoundBufferOptions, type StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport { type IStreamingSoundOptions, type StreamingSound } from \"./streamingSound\";\nimport { type AbstractSpatialAudioListener, type ISpatialAudioListenerOptions } from \"./subProperties/abstractSpatialAudioListener\";\n\nconst Instances: AudioEngineV2[] = [];\n\n/**\n * Gets the most recently created v2 audio engine.\n * @returns The most recently created v2 audio engine.\n */\nexport function LastCreatedAudioEngine(): Nullable<AudioEngineV2> {\n if (Instances.length === 0) {\n return null;\n }\n\n return Instances[Instances.length - 1];\n}\n\n/**\n * Options for creating a v2 audio engine.\n */\nexport interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n parameterRampDuration: number;\n /**\n * The initial output volume of the audio engine. Defaults to `1`.\n */\n volume: number;\n}\n\n/**\n * The state of a v2 audio engine.\n * @see {@link AudioEngineV2.state}\n */\nexport type AudioEngineV2State = \"closed\" | \"interrupted\" | \"running\" | \"suspended\";\n\n/**\n * Abstract base class for v2 audio engines.\n *\n * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.\n */\nexport abstract class AudioEngineV2 {\n /** Not owned, but all items should be in `_nodes` container, too, which is owned. */\n private readonly _mainBuses = new Set<MainAudioBus>();\n private readonly _sounds = new Set<AbstractSound>();\n private _soundsArray: Nullable<Array<AbstractSound>> = null;\n\n /** Owned top-level sound and bus nodes. */\n private readonly _nodes = new Set<AbstractNamedAudioNode>();\n\n private _defaultMainBus: Nullable<MainAudioBus> = null;\n\n private _parameterRampDuration: number = 0.01;\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.parameterRampDuration === \"number\") {\n this.parameterRampDuration = options.parameterRampDuration;\n }\n }\n\n /**\n * The elapsed time since the audio engine was started, in seconds.\n */\n public abstract readonly currentTime: number;\n\n /**\n * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.\n * @see {@link IAudioBusOptions.outBus}\n * @see {@link IAbstractSoundOptions.outBus}\n */\n public get defaultMainBus(): Nullable<MainAudioBus> {\n if (this._mainBuses.size === 0) {\n return null;\n }\n\n if (!this._defaultMainBus) {\n this._defaultMainBus = Array.from(this._mainBuses)[0];\n }\n\n return this._defaultMainBus;\n }\n\n /**\n * The spatial audio listener properties for the audio engine.\n * - Each audio engine has exactly one listener.\n */\n public abstract readonly listener: AbstractSpatialAudioListener;\n\n /**\n * The main output node.\n * - This is the last node in the audio graph before the audio is sent to the speakers.\n */\n public abstract readonly mainOut: AbstractAudioNode;\n\n /**\n * The current state of the audio engine.\n *\n * Possible values are:\n * - `\"closed\"`: The audio engine has been closed.\n * - `\"interrupted\"`: The audio engine has been interrupted and is not running.\n * - `\"running\"`: The audio engine is running normally.\n * - `\"suspended\"`: The audio engine is suspended and is not running.\n */\n public abstract readonly state: AudioEngineV2State;\n\n /**\n * The output volume of the audio engine.\n */\n public abstract volume: number;\n\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n public get parameterRampDuration(): number {\n return this._parameterRampDuration;\n }\n\n public set parameterRampDuration(value: number) {\n this._parameterRampDuration = Math.max(0, value);\n }\n\n /**\n * The list of static and streaming sounds created by the audio engine.\n */\n public get sounds(): ReadonlyArray<AbstractSound> {\n if (!this._soundsArray) {\n this._soundsArray = Array.from(this._sounds);\n }\n return this._soundsArray;\n }\n\n /**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @returns A promise that resolves with the created audio bus.\n */\n public abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;\n\n /**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @returns A promise that resolves with the created main audio bus.\n */\n public abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;\n\n /**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createMicrophoneSoundSourceAsync(name: string, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @returns A promise that resolves to the created static sound.\n */\n public abstract createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundOptions>\n ): Promise<StaticSound>;\n\n /**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @returns A promise that resolves to the created static sound buffer.\n */\n public abstract createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundBufferOptions>\n ): Promise<StaticSoundBuffer>;\n\n /**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createSoundSourceAsync(name: string, source: AudioNode, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @returns A promise that resolves to the created streaming sound.\n */\n public abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;\n\n /**\n * Releases associated resources.\n */\n public dispose(): void {\n if (Instances.includes(this)) {\n Instances.splice(Instances.indexOf(this), 1);\n }\n\n const nodeIt = this._nodes.values();\n for (let next = nodeIt.next(); !next.done; next = nodeIt.next()) {\n next.value.dispose();\n }\n\n this._mainBuses.clear();\n this._nodes.clear();\n this._sounds.clear();\n\n this._disposeSoundsArray();\n\n this._defaultMainBus = null;\n }\n\n /**\n * Checks if the specified format is valid.\n * @param format The format to check as an audio file extension like \"mp3\" or \"wav\".\n * @returns `true` if the format is valid; otherwise `false`.\n */\n public abstract isFormatValid(format: string): boolean;\n\n /**\n * Pauses the audio engine if it is running.\n * @returns A promise that resolves when the audio engine is paused.\n */\n public abstract pauseAsync(): Promise<void>;\n\n /**\n * Resumes the audio engine if it is not running.\n * @returns A promise that resolves when the audio engine is running.\n */\n public abstract resumeAsync(): Promise<void>;\n\n /**\n * Sets the audio output volume with optional ramping.\n * If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape.\n * If a ramp is already in progress then the volume is not set and an error is thrown.\n * @param value The value to set the volume to.\n * @param options The options to use for ramping the volume change.\n */\n public abstract setVolume(value: number, options?: Partial<IAudioParameterRampOptions>): void;\n\n /**\n * Unlocks the audio engine if it is locked.\n * - Note that the returned promise may already be resolved if the audio engine is already unlocked.\n * @returns A promise that is resolved when the audio engine is unlocked.\n */\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\n public unlockAsync(): Promise<void> {\n return this.resumeAsync();\n }\n\n protected _addMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.add(mainBus);\n\n this._addNode(mainBus);\n }\n\n protected _removeMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.delete(mainBus);\n this._defaultMainBus = null;\n\n this._removeNode(mainBus);\n }\n\n protected _addNode(node: AbstractNamedAudioNode): void {\n this._nodes.add(node);\n }\n\n protected _removeNode(node: AbstractNamedAudioNode): void {\n this._nodes.delete(node);\n }\n\n protected _addSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.add(sound);\n this._addNode(sound);\n }\n\n protected _removeSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.delete(sound);\n this._removeNode(sound);\n }\n\n /**\n * Called when any sound's playback state changes (started, stopped, paused, resumed).\n * Override in platform-specific implementations to react to sound playback state changes.\n * @internal\n */\n public _onSoundPlaybackStateChanged(): void {\n // No-op base implementation.\n }\n\n private _disposeSoundsArray(): void {\n if (this._soundsArray) {\n this._soundsArray.length = 0;\n this._soundsArray = null;\n }\n }\n}\n\n/**\n * @internal\n * @param engine - The given audio engine. If `null` then the last created audio engine is used.\n * @returns the given audio engine or the last created audio engine.\n * @throws An error if the resulting engine is `null`.\n */\nexport function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2 {\n if (!engine) {\n engine = LastCreatedAudioEngine();\n }\n\n if (engine) {\n return engine;\n }\n\n throw new Error(\"No audio engine.\");\n}\n\n/**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateAudioBusAsync(name: string, options: Partial<IAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createBusAsync(name, options);\n}\n\n/**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created main audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMainAudioBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<MainAudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createMainBusAsync(name, options);\n}\n\n/**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMicrophoneSoundSourceAsync(name: string, options: Partial<ISoundSourceOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createMicrophoneSoundSourceAsync(name, options);\n}\n\n/**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSound> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundAsync(name, source, options);\n}\n\n/**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\nexport async function CreateSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundBufferOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSoundBuffer> {\n engine = _GetAudioEngine(engine);\n return await engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundSourceAsync(\n name: string,\n source: AudioNode,\n options: Partial<ISoundSourceOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundSourceAsync(name, source, options);\n}\n\n/**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created streaming sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateStreamingSoundAsync(\n name: string,\n source: HTMLMediaElement | string | string[],\n options: Partial<IStreamingSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StreamingSound> {\n engine = _GetAudioEngine(engine);\n return engine.createStreamingSoundAsync(name, source, options);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audioEngineV2.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,UAAU,EAAE,MAAM,uBAAu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MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,yBAAyB,CACrC,IAAY,EACZ,MAA4C,EAC5C,UAA2C,EAAE,EAC7C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { type IDisposable } from \"../../scene\";\nimport { type Nullable } from \"../../types\";\nimport { type IReadonlyObservable, Observable } from \"../../Misc/observable\";\nimport { type IAudioParameterRampOptions } from \"../audioParameter\";\nimport { type AbstractAudioNode, type AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport { type AbstractSound } from \"./abstractSound\";\nimport { type AbstractSoundSource, type ISoundSourceOptions } from \"./abstractSoundSource\";\nimport { type AudioBus, type IAudioBusOptions } from \"./audioBus\";\nimport { type IMainAudioBusOptions, type MainAudioBus } from \"./mainAudioBus\";\nimport { type IStaticSoundOptions, type StaticSound } from \"./staticSound\";\nimport { type IStaticSoundBufferOptions, type StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport { type IStreamingSoundOptions, type StreamingSound } from \"./streamingSound\";\nimport { type AbstractSpatialAudioListener, type ISpatialAudioListenerOptions } from \"./subProperties/abstractSpatialAudioListener\";\n\nconst Instances: AudioEngineV2[] = [];\n\n/**\n * Observable that notifies when a new v2 audio engine instance has been created.\n * - Fires after the engine has been fully constructed and initialized (e.g. from {@link CreateAudioEngineAsync}),\n * so subclass state (audio context, listener, etc.) is guaranteed to be available to observers.\n */\nexport const OnAudioEngineV2CreatedObservable = new Observable<AudioEngineV2>();\n\n/**\n * Gets the most recently created v2 audio engine.\n * @returns The most recently created v2 audio engine.\n */\nexport function LastCreatedAudioEngine(): Nullable<AudioEngineV2> {\n if (Instances.length === 0) {\n return null;\n }\n\n return Instances[Instances.length - 1];\n}\n\n/**\n * Options for creating a v2 audio engine.\n */\nexport interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n parameterRampDuration: number;\n /**\n * The initial output volume of the audio engine. Defaults to `1`.\n */\n volume: number;\n}\n\n/**\n * The state of a v2 audio engine.\n * @see {@link AudioEngineV2.state}\n */\nexport type AudioEngineV2State = \"closed\" | \"interrupted\" | \"running\" | \"suspended\";\n\n/**\n * Abstract base class for v2 audio engines.\n *\n * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.\n */\nexport abstract class AudioEngineV2 implements IDisposable {\n /**\n * The list of v2 audio engines that have been created and not yet disposed.\n * - Engines are added on construction and removed on {@link AudioEngineV2.dispose}.\n */\n public static get Instances(): ReadonlyArray<AudioEngineV2> {\n return Instances;\n }\n\n /** Not owned, but all items should be in `_nodes` container, too, which is owned. */\n private readonly _mainBuses = new Set<MainAudioBus>();\n private readonly _sounds = new Set<AbstractSound>();\n private _soundsArray: Nullable<Array<AbstractSound>> = null;\n\n /** Owned top-level sound and bus nodes. */\n private readonly _nodes = new Set<AbstractNamedAudioNode>();\n\n private _defaultMainBus: Nullable<MainAudioBus> = null;\n\n private _parameterRampDuration: number = 0.01;\n\n private readonly _onNodeAddedObservable = new Observable<AbstractNamedAudioNode>();\n private readonly _onNodeRemovedObservable = new Observable<AbstractNamedAudioNode>();\n private readonly _onDisposeObservable = new Observable<AudioEngineV2>();\n\n /**\n * Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is added to this engine.\n */\n public get onNodeAddedObservable(): IReadonlyObservable<AbstractNamedAudioNode> {\n return this._onNodeAddedObservable;\n }\n\n /**\n * Observable that notifies when a top-level audio node (sound, sound source, bus, or main bus) is removed from this engine.\n */\n public get onNodeRemovedObservable(): IReadonlyObservable<AbstractNamedAudioNode> {\n return this._onNodeRemovedObservable;\n }\n\n /**\n * Observable that notifies when this engine is disposed.\n * - Fires from {@link AudioEngineV2.dispose} after the engine has been removed from {@link AudioEngineV2.Instances}.\n */\n public get onDisposeObservable(): IReadonlyObservable<AudioEngineV2> {\n return this._onDisposeObservable;\n }\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.parameterRampDuration === \"number\") {\n this.parameterRampDuration = options.parameterRampDuration;\n }\n\n // Intentionally do NOT notify {@link OnAudioEngineV2CreatedObservable} here:\n // - This base constructor runs before subclass fields (audio context, listener, ...) are initialized\n // and before any async {@link CreateAudioEngineAsync}-style setup completes, so observers would\n // see a partially constructed engine.\n // - Engine factory functions (e.g. {@link CreateAudioEngineAsync}) call `notifyObservers` themselves\n // once the engine is fully constructed and initialized.\n }\n\n /**\n * The elapsed time since the audio engine was started, in seconds.\n */\n public abstract readonly currentTime: number;\n\n /**\n * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.\n * @see {@link IAudioBusOptions.outBus}\n * @see {@link IAbstractSoundOptions.outBus}\n */\n public get defaultMainBus(): Nullable<MainAudioBus> {\n if (this._mainBuses.size === 0) {\n return null;\n }\n\n if (!this._defaultMainBus) {\n this._defaultMainBus = Array.from(this._mainBuses)[0];\n }\n\n return this._defaultMainBus;\n }\n\n /**\n * The spatial audio listener properties for the audio engine.\n * - Each audio engine has exactly one listener.\n */\n public abstract readonly listener: AbstractSpatialAudioListener;\n\n /**\n * The main output node.\n * - This is the last node in the audio graph before the audio is sent to the speakers.\n */\n public abstract readonly mainOut: AbstractAudioNode;\n\n /**\n * The current state of the audio engine.\n *\n * Possible values are:\n * - `\"closed\"`: The audio engine has been closed.\n * - `\"interrupted\"`: The audio engine has been interrupted and is not running.\n * - `\"running\"`: The audio engine is running normally.\n * - `\"suspended\"`: The audio engine is suspended and is not running.\n */\n public abstract readonly state: AudioEngineV2State;\n\n /**\n * The output volume of the audio engine.\n */\n public abstract volume: number;\n\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n public get parameterRampDuration(): number {\n return this._parameterRampDuration;\n }\n\n public set parameterRampDuration(value: number) {\n this._parameterRampDuration = Math.max(0, value);\n }\n\n /**\n * The list of static and streaming sounds created by the audio engine.\n */\n public get sounds(): ReadonlyArray<AbstractSound> {\n if (!this._soundsArray) {\n this._soundsArray = Array.from(this._sounds);\n }\n return this._soundsArray;\n }\n\n /**\n * The list of top-level audio nodes (sounds, sound sources, buses, main buses) owned by the audio engine.\n */\n public get nodes(): ReadonlySet<AbstractNamedAudioNode> {\n return this._nodes;\n }\n\n /**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @returns A promise that resolves with the created audio bus.\n */\n public abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;\n\n /**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @returns A promise that resolves with the created main audio bus.\n */\n public abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;\n\n /**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createMicrophoneSoundSourceAsync(name: string, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @returns A promise that resolves to the created static sound.\n */\n public abstract createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundOptions>\n ): Promise<StaticSound>;\n\n /**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @returns A promise that resolves to the created static sound buffer.\n */\n public abstract createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundBufferOptions>\n ): Promise<StaticSoundBuffer>;\n\n /**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createSoundSourceAsync(name: string, source: AudioNode, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @returns A promise that resolves to the created streaming sound.\n */\n public abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;\n\n /**\n * Releases associated resources.\n */\n public dispose(): void {\n if (Instances.includes(this)) {\n Instances.splice(Instances.indexOf(this), 1);\n }\n\n const nodeIt = this._nodes.values();\n for (let next = nodeIt.next(); !next.done; next = nodeIt.next()) {\n next.value.dispose();\n }\n\n this._mainBuses.clear();\n this._nodes.clear();\n this._sounds.clear();\n\n this._disposeSoundsArray();\n\n this._defaultMainBus = null;\n\n this._onDisposeObservable.notifyObservers(this);\n this._onDisposeObservable.clear();\n this._onNodeAddedObservable.clear();\n this._onNodeRemovedObservable.clear();\n }\n\n /**\n * Checks if the specified format is valid.\n * @param format The format to check as an audio file extension like \"mp3\" or \"wav\".\n * @returns `true` if the format is valid; otherwise `false`.\n */\n public abstract isFormatValid(format: string): boolean;\n\n /**\n * Pauses the audio engine if it is running.\n * @returns A promise that resolves when the audio engine is paused.\n */\n public abstract pauseAsync(): Promise<void>;\n\n /**\n * Resumes the audio engine if it is not running.\n * @returns A promise that resolves when the audio engine is running.\n */\n public abstract resumeAsync(): Promise<void>;\n\n /**\n * Sets the audio output volume with optional ramping.\n * If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape.\n * If a ramp is already in progress then the volume is not set and an error is thrown.\n * @param value The value to set the volume to.\n * @param options The options to use for ramping the volume change.\n */\n public abstract setVolume(value: number, options?: Partial<IAudioParameterRampOptions>): void;\n\n /**\n * Unlocks the audio engine if it is locked.\n * - Note that the returned promise may already be resolved if the audio engine is already unlocked.\n * @returns A promise that is resolved when the audio engine is unlocked.\n */\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\n public unlockAsync(): Promise<void> {\n return this.resumeAsync();\n }\n\n protected _addMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.add(mainBus);\n\n this._addNode(mainBus);\n }\n\n protected _removeMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.delete(mainBus);\n this._defaultMainBus = null;\n\n this._removeNode(mainBus);\n }\n\n protected _addNode(node: AbstractNamedAudioNode): void {\n this._nodes.add(node);\n this._onNodeAddedObservable.notifyObservers(node);\n }\n\n protected _removeNode(node: AbstractNamedAudioNode): void {\n this._nodes.delete(node);\n this._onNodeRemovedObservable.notifyObservers(node);\n }\n\n protected _addSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.add(sound);\n this._addNode(sound);\n }\n\n protected _removeSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.delete(sound);\n this._removeNode(sound);\n }\n\n /**\n * Called when any sound's playback state changes (started, stopped, paused, resumed).\n * Override in platform-specific implementations to react to sound playback state changes.\n * @internal\n */\n public _onSoundPlaybackStateChanged(): void {\n // No-op base implementation.\n }\n\n private _disposeSoundsArray(): void {\n if (this._soundsArray) {\n this._soundsArray.length = 0;\n this._soundsArray = null;\n }\n }\n}\n\n/**\n * @internal\n * @param engine - The given audio engine. If `null` then the last created audio engine is used.\n * @returns the given audio engine or the last created audio engine.\n * @throws An error if the resulting engine is `null`.\n */\nexport function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2 {\n if (!engine) {\n engine = LastCreatedAudioEngine();\n }\n\n if (engine) {\n return engine;\n }\n\n throw new Error(\"No audio engine.\");\n}\n\n/**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateAudioBusAsync(name: string, options: Partial<IAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createBusAsync(name, options);\n}\n\n/**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created main audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMainAudioBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<MainAudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createMainBusAsync(name, options);\n}\n\n/**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMicrophoneSoundSourceAsync(name: string, options: Partial<ISoundSourceOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createMicrophoneSoundSourceAsync(name, options);\n}\n\n/**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSound> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundAsync(name, source, options);\n}\n\n/**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\nexport async function CreateSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundBufferOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSoundBuffer> {\n engine = _GetAudioEngine(engine);\n return await engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundSourceAsync(\n name: string,\n source: AudioNode,\n options: Partial<ISoundSourceOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundSourceAsync(name, source, options);\n}\n\n/**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created streaming sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateStreamingSoundAsync(\n name: string,\n source: HTMLMediaElement | string | string[],\n options: Partial<IStreamingSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StreamingSound> {\n engine = _GetAudioEngine(engine);\n return engine.createStreamingSoundAsync(name, source, options);\n}\n"]}
|
|
@@ -22,6 +22,18 @@ export declare class _SpatialAudioAttacherComponent {
|
|
|
22
22
|
* Returns `true` if attached to a scene node; otherwise returns `false`.
|
|
23
23
|
*/
|
|
24
24
|
get isAttached(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The scene node this attacher is currently attached to, or `null` if not attached.
|
|
27
|
+
*/
|
|
28
|
+
get sceneNode(): Nullable<Node>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the attacher is using the scene node's bounding box for positioning.
|
|
31
|
+
*/
|
|
32
|
+
get useBoundingBox(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Which components (position, rotation, or both) of the scene node's world transform drive the spatial audio.
|
|
35
|
+
*/
|
|
36
|
+
get attachmentType(): SpatialAudioAttachmentType;
|
|
25
37
|
/**
|
|
26
38
|
* Attaches to a scene node.
|
|
27
39
|
*
|
|
@@ -27,6 +27,24 @@ export class _SpatialAudioAttacherComponent {
|
|
|
27
27
|
get isAttached() {
|
|
28
28
|
return this._sceneNode !== null;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The scene node this attacher is currently attached to, or `null` if not attached.
|
|
32
|
+
*/
|
|
33
|
+
get sceneNode() {
|
|
34
|
+
return this._sceneNode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether the attacher is using the scene node's bounding box for positioning.
|
|
38
|
+
*/
|
|
39
|
+
get useBoundingBox() {
|
|
40
|
+
return this._useBoundingBox;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Which components (position, rotation, or both) of the scene node's world transform drive the spatial audio.
|
|
44
|
+
*/
|
|
45
|
+
get attachmentType() {
|
|
46
|
+
return this._attachmentType;
|
|
47
|
+
}
|
|
30
48
|
/**
|
|
31
49
|
* Attaches to a scene node.
|
|
32
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialAudioAttacherComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAQjE;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IASvC,gBAAgB;IAChB,YAAmB,gBAA8D;QATjF,gBAAgB;QACR,oBAAe,0DAA8E;QACpF,cAAS,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,wBAAmB,GAAG,IAAI,UAAU,EAAE,CAAC;QAChD,eAAU,GAAmB,IAAI,CAAC;QAElC,oBAAe,GAAY,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"spatialAudioAttacherComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAQjE;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IASvC,gBAAgB;IAChB,YAAmB,gBAA8D;QATjF,gBAAgB;QACR,oBAAe,0DAA8E;QACpF,cAAS,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,wBAAmB,GAAG,IAAI,UAAU,EAAE,CAAC;QAChD,eAAU,GAAmB,IAAI,CAAC;QAElC,oBAAe,GAAY,KAAK,CAAC;QAwEzC;;WAEG;QACI,YAAO,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC,CAAC;QAzEE,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,SAAyB,EAAE,cAAuB,EAAE,cAA0C;QACxG,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,M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C,CAAC;YAEjF,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAC7E,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,eAAe,IAAI,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,CAAC;YAC3G,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAC;QAC7C,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport { type AbstractMesh } from \"../../../Meshes/abstractMesh\";\nimport { type Node } from \"../../../node\";\nimport { type Nullable } from \"../../../types\";\nimport { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\nimport { type _SpatialAudioSubNode } from \"../subNodes/spatialAudioSubNode\";\nimport { type _SpatialAudioListener } from \"../subProperties/spatialAudioListener\";\n\n/**\n * Provides a common interface for attaching an audio listener or source to a specific entity, ensuring only one entity\n * is attached at a time.\n * @internal\n */\nexport class _SpatialAudioAttacherComponent {\n /** @internal */\n private _attachmentType: SpatialAudioAttachmentType = SpatialAudioAttachmentType.PositionAndRotation;\n private readonly _position = new Vector3();\n private readonly _rotationQuaternion = new Quaternion();\n private _sceneNode: Nullable<Node> = null;\n private readonly _spatialAudioNode: _SpatialAudioSubNode | _SpatialAudioListener;\n private _useBoundingBox: boolean = false;\n\n /** @internal */\n public constructor(spatialAudioNode: _SpatialAudioSubNode | _SpatialAudioListener) {\n this._spatialAudioNode = spatialAudioNode;\n }\n\n /**\n * Returns `true` if attached to a scene node; otherwise returns `false`.\n */\n public get isAttached(): boolean {\n return this._sceneNode !== null;\n }\n\n /**\n * The scene node this attacher is currently attached to, or `null` if not attached.\n */\n public get sceneNode(): Nullable<Node> {\n return this._sceneNode;\n }\n\n /**\n * Whether the attacher is using the scene node's bounding box for positioning.\n */\n public get useBoundingBox(): boolean {\n return this._useBoundingBox;\n }\n\n /**\n * Which components (position, rotation, or both) of the scene node's world transform drive the spatial audio.\n */\n public get attachmentType(): SpatialAudioAttachmentType {\n return this._attachmentType;\n }\n\n /**\n * Attaches to a scene node.\n *\n * Detaches automatically before attaching to the given scene node.\n * If `sceneNode` is `null` it is the same as calling `detach()`.\n *\n * @param sceneNode The scene node to attach to, or `null` to detach.\n * @param useBoundingBox Whether to use the scene node's bounding box for positioning. Defaults to `false`.\n * @param attachmentType Whether to attach to the scene node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public attach(sceneNode: Nullable<Node>, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void {\n if (this._sceneNode === sceneNode) {\n return;\n }\n\n this.detach();\n\n if (!sceneNode) {\n return;\n }\n\n this._attachmentType = attachmentType;\n\n this._sceneNode = sceneNode;\n this._sceneNode.onDisposeObservable.add(this.dispose);\n\n this._useBoundingBox = useBoundingBox;\n }\n\n /**\n * Detaches from the scene node if attached.\n */\n public detach() {\n this._sceneNode?.onDisposeObservable.removeCallback(this.dispose);\n this._sceneNode = null;\n }\n\n /**\n * Releases associated resources.\n */\n public dispose = () => {\n this.detach();\n };\n\n /**\n * Updates the position and rotation of the associated audio engine object in the audio rendering graph.\n *\n * This is called automatically by default and only needs to be called manually if automatic updates are disabled.\n */\n public update() {\n const updatesPosition = !!(this._attachmentType & SpatialAudioAttachmentType.Position);\n\n if (updatesPosition) {\n if (this._useBoundingBox && (this._sceneNode as AbstractMesh).getBoundingInfo) {\n this._position.copyFrom((this._sceneNode as AbstractMesh).getBoundingInfo().boundingBox.centerWorld);\n } else {\n this._sceneNode?.getWorldMatrix().getTranslationToRef(this._position);\n }\n\n this._spatialAudioNode.position.copyFrom(this._position);\n this._spatialAudioNode._updatePosition();\n }\n\n if (this._attachmentType & SpatialAudioAttachmentType.Rotation) {\n this._sceneNode?.getWorldMatrix().decompose(undefined, this._rotationQuaternion);\n\n this._spatialAudioNode.rotationQuaternion.copyFrom(this._rotationQuaternion);\n this._spatialAudioNode._updateRotation();\n }\n\n if (!updatesPosition && \"panningEnabled\" in this._spatialAudioNode && !this._spatialAudioNode.panningEnabled) {\n this._spatialAudioNode._updatePosition();\n }\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ export * from "./abstractAudioBus.js";
|
|
|
2
2
|
export * from "./abstractAudioNode.js";
|
|
3
3
|
export * from "./abstractAudioOutNode.js";
|
|
4
4
|
export * from "./abstractSound.js";
|
|
5
|
+
export * from "./abstractSoundSource.js";
|
|
5
6
|
export * from "./audioBus.js";
|
|
6
7
|
export * from "./audioEngineV2.js";
|
|
7
8
|
export * from "./mainAudioBus.js";
|
|
@@ -3,6 +3,7 @@ export * from "./abstractAudioBus.js";
|
|
|
3
3
|
export * from "./abstractAudioNode.js";
|
|
4
4
|
export * from "./abstractAudioOutNode.js";
|
|
5
5
|
export * from "./abstractSound.js";
|
|
6
|
+
export * from "./abstractSoundSource.js";
|
|
6
7
|
export * from "./audioBus.js";
|
|
7
8
|
export * from "./audioEngineV2.js";
|
|
8
9
|
export * from "./mainAudioBus.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./abstractAudioBus\";\nexport * from \"./abstractAudioNode\";\nexport * from \"./abstractAudioOutNode\";\nexport * from \"./abstractSound\";\nexport * from \"./audioBus\";\nexport * from \"./audioEngineV2\";\nexport * from \"./mainAudioBus\";\nexport * from \"./staticSound\";\nexport * from \"./staticSoundBuffer\";\nexport * from \"./streamingSound\";\nexport * from \"./subProperties/index\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./abstractAudioBus\";\nexport * from \"./abstractAudioNode\";\nexport * from \"./abstractAudioOutNode\";\nexport * from \"./abstractSound\";\nexport * from \"./abstractSoundSource\";\nexport * from \"./audioBus\";\nexport * from \"./audioEngineV2\";\nexport * from \"./mainAudioBus\";\nexport * from \"./staticSound\";\nexport * from \"./staticSoundBuffer\";\nexport * from \"./streamingSound\";\nexport * from \"./subProperties/index\";\n"]}
|
|
@@ -3,6 +3,7 @@ export * from "./abstractAudioBus.js";
|
|
|
3
3
|
export * from "./abstractAudioNode.js";
|
|
4
4
|
export * from "./abstractAudioOutNode.js";
|
|
5
5
|
export * from "./abstractSound.js";
|
|
6
|
+
export * from "./abstractSoundSource.js";
|
|
6
7
|
export * from "./audioBus.js";
|
|
7
8
|
export * from "./audioEngineV2.js";
|
|
8
9
|
export * from "./mainAudioBus.js";
|
|
@@ -4,6 +4,7 @@ export * from "./abstractAudioBus.js";
|
|
|
4
4
|
export * from "./abstractAudioNode.js";
|
|
5
5
|
export * from "./abstractAudioOutNode.js";
|
|
6
6
|
export * from "./abstractSound.js";
|
|
7
|
+
export * from "./abstractSoundSource.js";
|
|
7
8
|
export * from "./audioBus.js";
|
|
8
9
|
export * from "./audioEngineV2.js";
|
|
9
10
|
export * from "./mainAudioBus.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\n/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./abstractAudioBus\";\nexport * from \"./abstractAudioNode\";\nexport * from \"./abstractAudioOutNode\";\nexport * from \"./abstractSound\";\nexport * from \"./audioBus\";\nexport * from \"./audioEngineV2\";\nexport * from \"./mainAudioBus\";\nexport * from \"./staticSound\";\nexport * from \"./staticSoundBuffer\";\nexport * from \"./streamingSound\";\nexport * from \"./subProperties/pure\";\n"]}
|
|
1
|
+
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\n/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./abstractAudioBus\";\nexport * from \"./abstractAudioNode\";\nexport * from \"./abstractAudioOutNode\";\nexport * from \"./abstractSound\";\nexport * from \"./abstractSoundSource\";\nexport * from \"./audioBus\";\nexport * from \"./audioEngineV2\";\nexport * from \"./mainAudioBus\";\nexport * from \"./staticSound\";\nexport * from \"./staticSoundBuffer\";\nexport * from \"./streamingSound\";\nexport * from \"./subProperties/pure\";\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Quaternion, type Vector3 } from "../../../Maths/math.vector.js";
|
|
2
2
|
import { type Node } from "../../../node.js";
|
|
3
3
|
import { type Nullable } from "../../../types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType.js";
|
|
5
5
|
import { type AudioEngineV2 } from "../audioEngineV2.js";
|
|
6
6
|
import { type ISpatialAudioOptions, _SpatialAudioDefaults } from "../subProperties/abstractSpatialAudio.js";
|
|
7
7
|
import { type _AbstractAudioSubGraph } from "./abstractAudioSubGraph.js";
|
|
@@ -27,6 +27,12 @@ export declare abstract class _SpatialAudioSubNode extends _AbstractAudioSubNode
|
|
|
27
27
|
/** @internal */
|
|
28
28
|
get isAttached(): boolean;
|
|
29
29
|
/** @internal */
|
|
30
|
+
get attachedNode(): Nullable<Node>;
|
|
31
|
+
/** @internal */
|
|
32
|
+
get useBoundingBox(): boolean;
|
|
33
|
+
/** @internal */
|
|
34
|
+
get attachmentType(): SpatialAudioAttachmentType;
|
|
35
|
+
/** @internal */
|
|
30
36
|
attach(sceneNode: Nullable<Node>, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void;
|
|
31
37
|
/** @internal */
|
|
32
38
|
detach(): void;
|
|
@@ -12,6 +12,18 @@ export class _SpatialAudioSubNode extends _AbstractAudioSubNode {
|
|
|
12
12
|
return this._attacherComponent !== null && this._attacherComponent.isAttached;
|
|
13
13
|
}
|
|
14
14
|
/** @internal */
|
|
15
|
+
get attachedNode() {
|
|
16
|
+
return this._attacherComponent?.sceneNode ?? null;
|
|
17
|
+
}
|
|
18
|
+
/** @internal */
|
|
19
|
+
get useBoundingBox() {
|
|
20
|
+
return this._attacherComponent?.useBoundingBox ?? false;
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
get attachmentType() {
|
|
24
|
+
return this._attacherComponent?.attachmentType ?? 3 /* SpatialAudioAttachmentType.PositionAndRotation */;
|
|
25
|
+
}
|
|
26
|
+
/** @internal */
|
|
15
27
|
attach(sceneNode, useBoundingBox, attachmentType) {
|
|
16
28
|
this.detach();
|
|
17
29
|
if (!this._attacherComponent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAA6B,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAEzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,gBAAgB;AAChB,MAAM,OAAgB,oBAAqB,SAAQ,qBAAqB;IAGpE,YAAsB,MAAqB;QACvC,KAAK,uCAAuB,MAAM,CAAC,CAAC;QAHhC,uBAAkB,GAA6C,IAAI,CAAC;IAI5E,CAAC;IAiBD,gBAAgB;IAChB,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,kBAAkB,KAAK,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU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Q,CAAC,aAAa,uCAA6C,CAAC,IAAI,EAAE,EAAE;QACxE,IAAI,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAC3B,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { type Quaternion, type Vector3 } from \"../../../Maths/math.vector\";\nimport { type Node } from \"../../../node\";\nimport { type Nullable } from \"../../../types\";\nimport {
|
|
1
|
+
{"version":3,"file":"spatialAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAA6B,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAEzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,gBAAgB;AAChB,MAAM,OAAgB,oBAAqB,SAAQ,qBAAqB;IAGpE,YAAsB,MAAqB;QACvC,KAAK,uCAAuB,MAAM,CAAC,CAAC;QAHhC,uBAAkB,GAA6C,IAAI,CAAC;IAI5E,CAAC;IAiBD,gBAAgB;IAChB,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,kBAAkB,KAAK,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC;IAClF,CAAC;IAED,gBAAgB;IAChB,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,kBAAkB,EAAE,SAAS,IAAI,IAAI,CAAC;IACtD,CAAC;IAED,gBAAgB;IAChB,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,kBAAkB,EAAE,cAAc,IAAI,KAAK,CAAC;IAC5D,CAAC;IAED,gBAAgB;IAChB,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,kBAAkB,EAAE,cAAc,0DAAkD,CAAC;IACrG,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,SAAyB,EAAE,cAAuB,EAAE,cAA0C;QACxG,IAAI,CAAC,MAAM,EAAE,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AC,CAAC;AACP,CAAC","sourcesContent":["import { type Quaternion, type Vector3 } from \"../../../Maths/math.vector\";\nimport { type Node } from \"../../../node\";\nimport { type Nullable } from \"../../../types\";\nimport { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\nimport { type AudioEngineV2 } from \"../audioEngineV2\";\nimport { _SpatialAudioAttacherComponent } from \"../components/spatialAudioAttacherComponent\";\nimport { type ISpatialAudioOptions, _SpatialAudioDefaults } from \"../subProperties/abstractSpatialAudio\";\nimport { type _AbstractAudioSubGraph } from \"./abstractAudioSubGraph\";\nimport { _AbstractAudioSubNode } from \"./abstractAudioSubNode\";\nimport { AudioSubNode } from \"./audioSubNode\";\n\n/** @internal */\nexport abstract class _SpatialAudioSubNode extends _AbstractAudioSubNode {\n private _attacherComponent: Nullable<_SpatialAudioAttacherComponent> = null;\n\n protected constructor(engine: AudioEngineV2) {\n super(AudioSubNode.SPATIAL, engine);\n }\n\n public abstract coneInnerAngle: number;\n public abstract coneOuterAngle: number;\n public abstract coneOuterVolume: number;\n public abstract distanceModel: DistanceModelType;\n public abstract maxDistance: number;\n public abstract minDistance: number;\n public abstract orientation: Vector3;\n public abstract panningEnabled: boolean;\n public abstract panningModel: PanningModelType;\n public abstract position: Vector3;\n public abstract rolloffFactor: number;\n public abstract rotation: Vector3;\n public abstract rotationQuaternion: Quaternion;\n public abstract _inNode: AudioNode;\n\n /** @internal */\n public get isAttached(): boolean {\n return this._attacherComponent !== null && this._attacherComponent.isAttached;\n }\n\n /** @internal */\n public get attachedNode(): Nullable<Node> {\n return this._attacherComponent?.sceneNode ?? null;\n }\n\n /** @internal */\n public get useBoundingBox(): boolean {\n return this._attacherComponent?.useBoundingBox ?? false;\n }\n\n /** @internal */\n public get attachmentType(): SpatialAudioAttachmentType {\n return this._attacherComponent?.attachmentType ?? SpatialAudioAttachmentType.PositionAndRotation;\n }\n\n /** @internal */\n public attach(sceneNode: Nullable<Node>, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void {\n this.detach();\n\n if (!this._attacherComponent) {\n this._attacherComponent = new _SpatialAudioAttacherComponent(this);\n }\n\n this._attacherComponent.attach(sceneNode, useBoundingBox, attachmentType);\n }\n\n /** @internal */\n public detach(): void {\n this._attacherComponent?.detach();\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._attacherComponent?.dispose();\n this._attacherComponent = null;\n }\n\n /** @internal */\n public setOptions(options: Partial<ISpatialAudioOptions>): void {\n this.coneInnerAngle = options.spatialConeInnerAngle ?? _SpatialAudioDefaults.coneInnerAngle;\n this.coneOuterAngle = options.spatialConeOuterAngle ?? _SpatialAudioDefaults.coneOuterAngle;\n this.coneOuterVolume = options.spatialConeOuterVolume ?? _SpatialAudioDefaults.coneOuterVolume;\n this.distanceModel = options.spatialDistanceModel ?? _SpatialAudioDefaults.distanceModel;\n this.maxDistance = options.spatialMaxDistance ?? _SpatialAudioDefaults.maxDistance;\n this.minDistance = options.spatialMinDistance ?? _SpatialAudioDefaults.minDistance;\n this.orientation = options.spatialOrientation ?? _SpatialAudioDefaults.orientation;\n this.panningEnabled = options.spatialPanningEnabled ?? _SpatialAudioDefaults.panningEnabled;\n this.panningModel = options.spatialPanningModel ?? _SpatialAudioDefaults.panningModel;\n this.rolloffFactor = options.spatialRolloffFactor ?? _SpatialAudioDefaults.rolloffFactor;\n\n if (options.spatialPosition) {\n this.position = options.spatialPosition.clone();\n }\n\n if (options.spatialRotationQuaternion) {\n this.rotationQuaternion = options.spatialRotationQuaternion.clone();\n } else if (options.spatialRotation) {\n this.rotation = options.spatialRotation.clone();\n } else {\n this.rotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\n }\n\n this.update();\n }\n\n /** @internal */\n public update(): void {\n if (this.isAttached) {\n this._attacherComponent?.update();\n } else {\n this._updatePosition();\n this._updateRotation();\n }\n }\n\n public abstract _updatePosition(): void;\n public abstract _updateRotation(): void;\n}\n\n/** @internal */\nexport function _GetSpatialAudioSubNode(subGraph: _AbstractAudioSubGraph): Nullable<_SpatialAudioSubNode> {\n return subGraph.getSubNode<_SpatialAudioSubNode>(AudioSubNode.SPATIAL);\n}\n\n/** @internal */\nexport function _SetSpatialAudioProperty<K extends keyof typeof _SpatialAudioDefaults>(subGraph: _AbstractAudioSubGraph, property: K, value: _SpatialAudioSubNode[K]): void {\n subGraph.callOnSubNode<_SpatialAudioSubNode>(AudioSubNode.SPATIAL, (node) => {\n node[property] = value;\n });\n}\n"]}
|
|
@@ -161,6 +161,20 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
161
161
|
* Whether the audio source is attached to a mesh or transform node.
|
|
162
162
|
*/
|
|
163
163
|
abstract isAttached: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The scene node this spatial audio is currently attached to, or `null` if not attached.
|
|
166
|
+
*/
|
|
167
|
+
abstract attachedNode: Nullable<Node>;
|
|
168
|
+
/**
|
|
169
|
+
* Whether the spatial audio is positioned using the attached scene node's bounding box (when the node is a mesh) instead of its world transform.
|
|
170
|
+
* - Only meaningful while {@link isAttached} is `true`.
|
|
171
|
+
*/
|
|
172
|
+
abstract useBoundingBox: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Which components (position, rotation, or both) of the attached scene node's world transform drive the spatial audio.
|
|
175
|
+
* - Only meaningful while {@link isAttached} is `true`.
|
|
176
|
+
*/
|
|
177
|
+
abstract attachmentType: SpatialAudioAttachmentType;
|
|
164
178
|
/**
|
|
165
179
|
* The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.
|
|
166
180
|
* - This value is used only when the {@link distanceModel} is set to `"linear"`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractSpatialAudio.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKjE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,cAAc,EAAE,aAAuB;IACvC,cAAc,EAAE,aAAuB;IACvC,eAAe,EAAE,CAAW;IAC5B,aAAa,EAAE,QAA6B;IAC5C,WAAW,EAAE,KAAe;IAC5B,WAAW,EAAE,CAAW;IACxB,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE;IAC5B,cAAc,EAAE,IAAe;IAC/B,YAAY,EAAE,YAAgC;IAC9C,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,aAAa,EAAE,CAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,kBAAkB,EAAE,IAAI,UAAU,EAAE;CAC9B,CAAC;AAwGX;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAsC;IAC1E,OAAO,CACH,OAAO,CAAC,cAAc;QACtB,OAAO,CAAC,iBAAiB,KAAK,SAAS;QACvC,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,sBAAsB,KAAK,SAAS;QAC5C,OAAO,CAAC,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,kBAAkB,KAAK,SAAS;QACxC,OAAO,CAAC,kBAAkB,KAAK,SAAS;QACxC,OAAO,CAAC,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,kBAAkB,KAAK,SAAS;QACxC,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,mBAAmB,KAAK,SAAS;QACzC,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,yBAAyB,KAAK,SAAS,CAClD,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAgB,oBAAoB;CAkIzC","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport { type Node } from \"../../../node\";\nimport { type Nullable } from \"../../../types\";\nimport { type SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\n\nexport const _SpatialAudioDefaults = {\n coneInnerAngle: 6.28318530718 as number,\n coneOuterAngle: 6.28318530718 as number,\n coneOuterVolume: 0 as number,\n distanceModel: \"linear\" as DistanceModelType,\n maxDistance: 10000 as number,\n minDistance: 1 as number,\n orientation: Vector3.Right(),\n panningEnabled: true as boolean,\n panningModel: \"equalpower\" as PanningModelType,\n position: Vector3.Zero(),\n rolloffFactor: 1 as number,\n rotation: Vector3.Zero(),\n rotationQuaternion: new Quaternion(),\n} as const;\n\n/**\n * Options for spatial audio.\n */\nexport interface ISpatialAudioOptions {\n /**\n * Whether to automatically update the spatial properties of the audio node. Defaults to `true`.\n */\n spatialAutoUpdate: boolean;\n /**\n * The spatial cone inner angle, in radians. Defaults to 2π.\n * - When the listener is inside the cone inner angle, the volume is at its maximum.\n */\n spatialConeInnerAngle: number;\n /**\n * The spatial cone outer angle, in radians. Defaults to 2π.\n * - When the listener is between the the cone inner and outer angles, the volume fades to its minimum as the listener approaches the outer angle.\n * - When the listener is outside the cone outer angle, the volume is at its minimum.\n */\n spatialConeOuterAngle: number;\n /**\n * The amount of volume reduction outside the {@link spatialConeOuterAngle}. Defaults to 0.\n */\n spatialConeOuterVolume: number;\n /**\n * The algorithm to use to reduce the volume of the audio source as it moves away from the listener. Defaults to \"inverse\".\n *\n * Possible values are:\n * - `\"linear\"`: The volume is reduced linearly as the source moves away from the listener.\n * - `\"inverse\"`: The volume is reduced inversely as the source moves away from the listener.\n * - `\"exponential\"`: The volume is reduced exponentially as the source moves away from the listener.\n *\n * @see {@link spatialMaxDistance}\n * @see {@link spatialMinDistance}\n * @see {@link spatialRolloffFactor}\n */\n spatialDistanceModel: \"linear\" | \"inverse\" | \"exponential\";\n /**\n * Enable spatial audio. Defaults to false.\n *\n * When set to `true`, the audio node's spatial properties will be initialized on creation and there will be no\n * delay when setting the first spatial value.\n *\n * When not specified, or set to `false`, the audio node's spatial properties will not be initialized on creation\n * and there will be a small delay when setting the first spatial value.\n *\n * - This option is ignored if any other spatial options are set.\n */\n spatialEnabled: boolean;\n /**\n * The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.\n * - This value is used only when the {@link spatialDistanceModel} is set to `\"linear\"`.\n * @see {@link spatialDistanceModel}\n */\n spatialMaxDistance: number;\n /**\n * The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.\n * - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.\n */\n spatialMinUpdateTime: number;\n /**\n * The spatial orientation used to determine the direction of the audio source. Defaults to (0, 0, -1).\n */\n spatialOrientation: Vector3;\n /**\n * Whether to spatially pan the audio source. Defaults to `true`.\n *\n * When set to `false`, the source keeps distance attenuation but does not pan between the left and right channels.\n * Sound cone attenuation is not applied while panning is disabled.\n */\n spatialPanningEnabled: boolean;\n /**\n * Possible values are:\n * - `\"equalpower\"`: Represents the equal-power panning algorithm, generally regarded as simple and efficient.\n * - `\"HRTF\"`: Renders a stereo output of higher quality than `\"equalpower\"` — it uses a convolution with measured impulse responses from human subjects.\n */\n spatialPanningModel: \"equalpower\" | \"HRTF\";\n /**\n * The spatial position. Defaults to (0, 0, 0).\n */\n spatialPosition: Vector3;\n /**\n * The distance for reducing volume as the audio source moves away from the listener – i.e. the distance the volume reduction starts at. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link spatialDistanceModel}\n */\n spatialMinDistance: number;\n /**\n * How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link spatialDistanceModel}\n */\n spatialRolloffFactor: number;\n /**\n * The spatial rotation, as Euler angles. Defaults to (0, 0, 0).\n */\n spatialRotation: Vector3;\n /**\n * The spatial rotation, as a quaternion. Defaults to (0, 0, 0, 1).\n */\n spatialRotationQuaternion: Quaternion;\n}\n\n/**\n * @param options The spatial audio options to check.\n * @returns `true` if spatial audio options are defined, otherwise `false`.\n */\nexport function _HasSpatialAudioOptions(options: Partial<ISpatialAudioOptions>): boolean {\n return (\n options.spatialEnabled ||\n options.spatialAutoUpdate !== undefined ||\n options.spatialConeInnerAngle !== undefined ||\n options.spatialConeOuterAngle !== undefined ||\n options.spatialConeOuterVolume !== undefined ||\n options.spatialDistanceModel !== undefined ||\n options.spatialMaxDistance !== undefined ||\n options.spatialMinDistance !== undefined ||\n options.spatialMinUpdateTime !== undefined ||\n options.spatialOrientation !== undefined ||\n options.spatialPanningEnabled !== undefined ||\n options.spatialPanningModel !== undefined ||\n options.spatialPosition !== undefined ||\n options.spatialRolloffFactor !== undefined ||\n options.spatialRotation !== undefined ||\n options.spatialRotationQuaternion !== undefined\n );\n}\n\n/**\n * Abstract class representing the `spatial` audio property on a sound or audio bus.\n *\n * @see {@link AudioEngineV2.listener}\n */\nexport abstract class AbstractSpatialAudio {\n /**\n * The spatial cone inner angle, in radians. Defaults to 2π.\n * - When the listener is inside the cone inner angle, the volume is at its maximum.\n */\n public abstract coneInnerAngle: number;\n\n /**\n * The spatial cone outer angle, in radians. Defaults to 2π.\n * - When the listener is between the the cone inner and outer angles, the volume fades to its minimum as the listener approaches the outer angle.\n * - When the listener is outside the cone outer angle, the volume is at its minimum.\n */\n public abstract coneOuterAngle: number;\n\n /**\n * The amount of volume reduction outside the {@link coneOuterAngle}. Defaults to 0.\n */\n public abstract coneOuterVolume: number;\n\n /**\n * The algorithm to use to reduce the volume of the audio source as it moves away from the listener. Defaults to \"inverse\".\n *\n * Possible values are:\n * - `\"linear\"`: The volume is reduced linearly as the source moves away from the listener.\n * - `\"inverse\"`: The volume is reduced inversely as the source moves away from the listener.\n * - `\"exponential\"`: The volume is reduced exponentially as the source moves away from the listener.\n *\n * @see {@link spatialMaxDistance}\n * @see {@link spatialMinDistance}\n * @see {@link spatialRolloffFactor}\n */\n public abstract distanceModel: \"linear\" | \"inverse\" | \"exponential\";\n\n /**\n * Whether the audio source is attached to a mesh or transform node.\n */\n public abstract isAttached: boolean;\n\n /**\n * The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.\n * - This value is used only when the {@link distanceModel} is set to `\"linear\"`.\n * @see {@link distanceModel}\n */\n public abstract maxDistance: number;\n\n /**\n * The distance for reducing volume as the audio source moves away from the listener – i.e. the distance the volume reduction starts at. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link distanceModel}\n */\n public abstract minDistance: number;\n\n /**\n * The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.\n * - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.\n */\n public abstract minUpdateTime: number;\n\n /**\n * The spatial orientation used to determine the direction of the audio source. Defaults to (0, 0, -1).\n */\n public abstract orientation: Vector3;\n\n /**\n * Whether to spatially pan the audio source. Defaults to `true`.\n *\n * When set to `false`, the source keeps distance attenuation but does not pan between the left and right channels.\n * Sound cone attenuation is not applied while panning is disabled.\n */\n public abstract panningEnabled: boolean;\n\n /**\n * The spatial panning model. Defaults to \"equalpower\".\n *\n * Possible values are:\n * - `\"equalpower\"`: Represents the equal-power panning algorithm, generally regarded as simple and efficient.\n * - `\"HRTF\"`:Renders a stereo output of higher quality than `\"equalpower\"` — it uses a convolution with measured impulse responses from human subjects.\n */\n public abstract panningModel: \"equalpower\" | \"HRTF\";\n\n /**\n * The spatial position. Defaults to (0, 0, 0).\n */\n public abstract position: Vector3;\n\n /**\n * How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link distanceModel}\n */\n public abstract rolloffFactor: number;\n\n /**\n * The spatial rotation used to determine the direction of the audio source. Defaults to (0, 0, 0).\n */\n public abstract rotation: Vector3;\n\n /**\n * The spatial rotation quaternion used to determine the direction of the audio source. Defaults to (0, 0, 0, 1).\n */\n public abstract rotationQuaternion: Quaternion;\n\n /**\n * Attaches to a scene node.\n *\n * Detaches automatically before attaching to the given scene node.\n * If `sceneNode` is `null` it is the same as calling `detach()`.\n *\n * @param sceneNode The scene node to attach to, or `null` to detach.\n * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.\n * @param attachmentType Whether to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public abstract attach(sceneNode: Nullable<Node>, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;\n\n /**\n * Detaches from the scene node if attached.\n */\n public abstract detach(): void;\n\n /**\n * Updates the position and rotation of the associated audio engine object in the audio rendering graph.\n *\n * This is called automatically by default and only needs to be called manually if automatic updates are disabled.\n */\n public abstract update(): void;\n\n /**\n * Releases associated resources.\n */\n public abstract dispose(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstractSpatialAudio.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKjE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,cAAc,EAAE,aAAuB;IACvC,cAAc,EAAE,aAAuB;IACvC,eAAe,EAAE,CAAW;IAC5B,aAAa,EAAE,QAA6B;IAC5C,WAAW,EAAE,KAAe;IAC5B,WAAW,EAAE,CAAW;IACxB,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE;IAC5B,cAAc,EAAE,IAAe;IAC/B,YAAY,EAAE,YAAgC;IAC9C,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,aAAa,EAAE,CAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,kBAAkB,EAAE,IAAI,UAAU,EAAE;CAC9B,CAAC;AAwGX;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAsC;IAC1E,OAAO,CACH,OAAO,CAAC,cAAc;QACtB,OAAO,CAAC,iBAAiB,KAAK,SAAS;QACvC,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,sBAAsB,KAAK,SAAS;QAC5C,OAAO,CAAC,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,kBAAkB,KAAK,SAAS;QACxC,OAAO,CAAC,kBAAkB,KAAK,SAAS;QACxC,OAAO,CAAC,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,kBAAkB,KAAK,SAAS;QACxC,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,mBAAmB,KAAK,SAAS;QACzC,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,yBAAyB,KAAK,SAAS,CAClD,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAgB,oBAAoB;CAmJzC","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport { type Node } from \"../../../node\";\nimport { type Nullable } from \"../../../types\";\nimport { type SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\n\nexport const _SpatialAudioDefaults = {\n coneInnerAngle: 6.28318530718 as number,\n coneOuterAngle: 6.28318530718 as number,\n coneOuterVolume: 0 as number,\n distanceModel: \"linear\" as DistanceModelType,\n maxDistance: 10000 as number,\n minDistance: 1 as number,\n orientation: Vector3.Right(),\n panningEnabled: true as boolean,\n panningModel: \"equalpower\" as PanningModelType,\n position: Vector3.Zero(),\n rolloffFactor: 1 as number,\n rotation: Vector3.Zero(),\n rotationQuaternion: new Quaternion(),\n} as const;\n\n/**\n * Options for spatial audio.\n */\nexport interface ISpatialAudioOptions {\n /**\n * Whether to automatically update the spatial properties of the audio node. Defaults to `true`.\n */\n spatialAutoUpdate: boolean;\n /**\n * The spatial cone inner angle, in radians. Defaults to 2π.\n * - When the listener is inside the cone inner angle, the volume is at its maximum.\n */\n spatialConeInnerAngle: number;\n /**\n * The spatial cone outer angle, in radians. Defaults to 2π.\n * - When the listener is between the the cone inner and outer angles, the volume fades to its minimum as the listener approaches the outer angle.\n * - When the listener is outside the cone outer angle, the volume is at its minimum.\n */\n spatialConeOuterAngle: number;\n /**\n * The amount of volume reduction outside the {@link spatialConeOuterAngle}. Defaults to 0.\n */\n spatialConeOuterVolume: number;\n /**\n * The algorithm to use to reduce the volume of the audio source as it moves away from the listener. Defaults to \"inverse\".\n *\n * Possible values are:\n * - `\"linear\"`: The volume is reduced linearly as the source moves away from the listener.\n * - `\"inverse\"`: The volume is reduced inversely as the source moves away from the listener.\n * - `\"exponential\"`: The volume is reduced exponentially as the source moves away from the listener.\n *\n * @see {@link spatialMaxDistance}\n * @see {@link spatialMinDistance}\n * @see {@link spatialRolloffFactor}\n */\n spatialDistanceModel: \"linear\" | \"inverse\" | \"exponential\";\n /**\n * Enable spatial audio. Defaults to false.\n *\n * When set to `true`, the audio node's spatial properties will be initialized on creation and there will be no\n * delay when setting the first spatial value.\n *\n * When not specified, or set to `false`, the audio node's spatial properties will not be initialized on creation\n * and there will be a small delay when setting the first spatial value.\n *\n * - This option is ignored if any other spatial options are set.\n */\n spatialEnabled: boolean;\n /**\n * The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.\n * - This value is used only when the {@link spatialDistanceModel} is set to `\"linear\"`.\n * @see {@link spatialDistanceModel}\n */\n spatialMaxDistance: number;\n /**\n * The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.\n * - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.\n */\n spatialMinUpdateTime: number;\n /**\n * The spatial orientation used to determine the direction of the audio source. Defaults to (0, 0, -1).\n */\n spatialOrientation: Vector3;\n /**\n * Whether to spatially pan the audio source. Defaults to `true`.\n *\n * When set to `false`, the source keeps distance attenuation but does not pan between the left and right channels.\n * Sound cone attenuation is not applied while panning is disabled.\n */\n spatialPanningEnabled: boolean;\n /**\n * Possible values are:\n * - `\"equalpower\"`: Represents the equal-power panning algorithm, generally regarded as simple and efficient.\n * - `\"HRTF\"`: Renders a stereo output of higher quality than `\"equalpower\"` — it uses a convolution with measured impulse responses from human subjects.\n */\n spatialPanningModel: \"equalpower\" | \"HRTF\";\n /**\n * The spatial position. Defaults to (0, 0, 0).\n */\n spatialPosition: Vector3;\n /**\n * The distance for reducing volume as the audio source moves away from the listener – i.e. the distance the volume reduction starts at. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link spatialDistanceModel}\n */\n spatialMinDistance: number;\n /**\n * How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link spatialDistanceModel}\n */\n spatialRolloffFactor: number;\n /**\n * The spatial rotation, as Euler angles. Defaults to (0, 0, 0).\n */\n spatialRotation: Vector3;\n /**\n * The spatial rotation, as a quaternion. Defaults to (0, 0, 0, 1).\n */\n spatialRotationQuaternion: Quaternion;\n}\n\n/**\n * @param options The spatial audio options to check.\n * @returns `true` if spatial audio options are defined, otherwise `false`.\n */\nexport function _HasSpatialAudioOptions(options: Partial<ISpatialAudioOptions>): boolean {\n return (\n options.spatialEnabled ||\n options.spatialAutoUpdate !== undefined ||\n options.spatialConeInnerAngle !== undefined ||\n options.spatialConeOuterAngle !== undefined ||\n options.spatialConeOuterVolume !== undefined ||\n options.spatialDistanceModel !== undefined ||\n options.spatialMaxDistance !== undefined ||\n options.spatialMinDistance !== undefined ||\n options.spatialMinUpdateTime !== undefined ||\n options.spatialOrientation !== undefined ||\n options.spatialPanningEnabled !== undefined ||\n options.spatialPanningModel !== undefined ||\n options.spatialPosition !== undefined ||\n options.spatialRolloffFactor !== undefined ||\n options.spatialRotation !== undefined ||\n options.spatialRotationQuaternion !== undefined\n );\n}\n\n/**\n * Abstract class representing the `spatial` audio property on a sound or audio bus.\n *\n * @see {@link AudioEngineV2.listener}\n */\nexport abstract class AbstractSpatialAudio {\n /**\n * The spatial cone inner angle, in radians. Defaults to 2π.\n * - When the listener is inside the cone inner angle, the volume is at its maximum.\n */\n public abstract coneInnerAngle: number;\n\n /**\n * The spatial cone outer angle, in radians. Defaults to 2π.\n * - When the listener is between the the cone inner and outer angles, the volume fades to its minimum as the listener approaches the outer angle.\n * - When the listener is outside the cone outer angle, the volume is at its minimum.\n */\n public abstract coneOuterAngle: number;\n\n /**\n * The amount of volume reduction outside the {@link coneOuterAngle}. Defaults to 0.\n */\n public abstract coneOuterVolume: number;\n\n /**\n * The algorithm to use to reduce the volume of the audio source as it moves away from the listener. Defaults to \"inverse\".\n *\n * Possible values are:\n * - `\"linear\"`: The volume is reduced linearly as the source moves away from the listener.\n * - `\"inverse\"`: The volume is reduced inversely as the source moves away from the listener.\n * - `\"exponential\"`: The volume is reduced exponentially as the source moves away from the listener.\n *\n * @see {@link spatialMaxDistance}\n * @see {@link spatialMinDistance}\n * @see {@link spatialRolloffFactor}\n */\n public abstract distanceModel: \"linear\" | \"inverse\" | \"exponential\";\n\n /**\n * Whether the audio source is attached to a mesh or transform node.\n */\n public abstract isAttached: boolean;\n\n /**\n * The scene node this spatial audio is currently attached to, or `null` if not attached.\n */\n public abstract attachedNode: Nullable<Node>;\n\n /**\n * Whether the spatial audio is positioned using the attached scene node's bounding box (when the node is a mesh) instead of its world transform.\n * - Only meaningful while {@link isAttached} is `true`.\n */\n public abstract useBoundingBox: boolean;\n\n /**\n * Which components (position, rotation, or both) of the attached scene node's world transform drive the spatial audio.\n * - Only meaningful while {@link isAttached} is `true`.\n */\n public abstract attachmentType: SpatialAudioAttachmentType;\n\n /**\n * The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.\n * - This value is used only when the {@link distanceModel} is set to `\"linear\"`.\n * @see {@link distanceModel}\n */\n public abstract maxDistance: number;\n\n /**\n * The distance for reducing volume as the audio source moves away from the listener – i.e. the distance the volume reduction starts at. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link distanceModel}\n */\n public abstract minDistance: number;\n\n /**\n * The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.\n * - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.\n */\n public abstract minUpdateTime: number;\n\n /**\n * The spatial orientation used to determine the direction of the audio source. Defaults to (0, 0, -1).\n */\n public abstract orientation: Vector3;\n\n /**\n * Whether to spatially pan the audio source. Defaults to `true`.\n *\n * When set to `false`, the source keeps distance attenuation but does not pan between the left and right channels.\n * Sound cone attenuation is not applied while panning is disabled.\n */\n public abstract panningEnabled: boolean;\n\n /**\n * The spatial panning model. Defaults to \"equalpower\".\n *\n * Possible values are:\n * - `\"equalpower\"`: Represents the equal-power panning algorithm, generally regarded as simple and efficient.\n * - `\"HRTF\"`:Renders a stereo output of higher quality than `\"equalpower\"` — it uses a convolution with measured impulse responses from human subjects.\n */\n public abstract panningModel: \"equalpower\" | \"HRTF\";\n\n /**\n * The spatial position. Defaults to (0, 0, 0).\n */\n public abstract position: Vector3;\n\n /**\n * How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.\n * - This value is used by all distance models.\n * @see {@link distanceModel}\n */\n public abstract rolloffFactor: number;\n\n /**\n * The spatial rotation used to determine the direction of the audio source. Defaults to (0, 0, 0).\n */\n public abstract rotation: Vector3;\n\n /**\n * The spatial rotation quaternion used to determine the direction of the audio source. Defaults to (0, 0, 0, 1).\n */\n public abstract rotationQuaternion: Quaternion;\n\n /**\n * Attaches to a scene node.\n *\n * Detaches automatically before attaching to the given scene node.\n * If `sceneNode` is `null` it is the same as calling `detach()`.\n *\n * @param sceneNode The scene node to attach to, or `null` to detach.\n * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.\n * @param attachmentType Whether to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public abstract attach(sceneNode: Nullable<Node>, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;\n\n /**\n * Detaches from the scene node if attached.\n */\n public abstract detach(): void;\n\n /**\n * Updates the position and rotation of the associated audio engine object in the audio rendering graph.\n *\n * This is called automatically by default and only needs to be called manually if automatic updates are disabled.\n */\n public abstract update(): void;\n\n /**\n * Releases associated resources.\n */\n public abstract dispose(): void;\n}\n"]}
|
|
@@ -52,6 +52,10 @@ export declare abstract class AbstractSpatialAudioListener {
|
|
|
52
52
|
* Whether the listener is attached to a camera, mesh or transform node.
|
|
53
53
|
*/
|
|
54
54
|
abstract isAttached: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The scene node this listener is currently attached to, or `null` if not attached.
|
|
57
|
+
*/
|
|
58
|
+
abstract attachedNode: Nullable<Node>;
|
|
55
59
|
/**
|
|
56
60
|
* The minimum update time in seconds of the listener if it is attached to a mesh, scene or transform node. Defaults to `0`.
|
|
57
61
|
* - The listener's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
|