@babylonjs/core 7.53.1 → 7.53.3
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/abstractSound.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +12 -12
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +15 -8
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +23 -11
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.js +8 -0
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/staticSoundInstance.d.ts +2 -0
- package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +4 -4
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +3 -3
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +23 -16
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +3 -3
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +13 -6
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +13 -8
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +18 -14
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +10 -6
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +7 -3
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +5 -5
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +9 -9
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +4 -4
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +4 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +14 -0
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/Culling/Helper/boundingInfoHelper.d.ts +2 -2
- package/Culling/Helper/boundingInfoHelper.js +2 -2
- package/Culling/Helper/boundingInfoHelper.js.map +1 -1
- package/Engines/abstractEngine.js +2 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/Lights/IES/iesLoader.d.ts +1 -1
- package/Lights/IES/iesLoader.js +1 -1
- package/Lights/IES/iesLoader.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +2 -2
- package/Lights/Shadows/shadowGenerator.js +2 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/spotLight.d.ts +1 -1
- package/Lights/spotLight.js +1 -1
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -2
- package/Materials/PBR/pbrBaseMaterial.js +2 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.d.ts +1 -0
- package/Materials/Textures/Loaders/basisTextureLoader.js +1 -0
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/exrTextureLoader.d.ts +5 -4
- package/Materials/Textures/Loaders/exrTextureLoader.js +5 -4
- package/Materials/Textures/Loaders/exrTextureLoader.js.map +1 -1
- package/Materials/Textures/internalTexture.js +2 -2
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/material.js +1 -1
- package/Materials/material.js.map +1 -1
- package/Maths/math.scalar.d.ts +1 -0
- package/Maths/math.scalar.functions.d.ts +9 -0
- package/Maths/math.scalar.functions.js +11 -0
- package/Maths/math.scalar.functions.js.map +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +96 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js +318 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -0
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/csg2.d.ts +3 -3
- package/Meshes/csg2.js +3 -3
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/lattice.d.ts +2 -2
- package/Meshes/lattice.js +5 -4
- package/Meshes/lattice.js.map +1 -1
- package/Meshes/lattice.material.d.ts +2 -2
- package/Meshes/lattice.material.js +2 -2
- package/Meshes/lattice.material.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -2
- package/Meshes/mesh.js +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.js +1 -1
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/fileTools.d.ts +1 -1
- package/Misc/fileTools.js +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Physics/v2/characterController.d.ts +3 -2
- package/Physics/v2/characterController.js +12 -0
- package/Physics/v2/characterController.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +4 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +11 -16
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +6 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +7 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +3 -0
- package/scene.js +5 -0
- package/scene.js.map +1 -1
|
@@ -149,10 +149,10 @@ export declare abstract class AbstractSound extends AbstractNamedAudioNode {
|
|
|
149
149
|
abstract stop(): void;
|
|
150
150
|
protected _beforePlay(instance: _AbstractSoundInstance): void;
|
|
151
151
|
protected _afterPlay(instance: _AbstractSoundInstance): void;
|
|
152
|
+
protected _getNewestInstance(): Nullable<_AbstractSoundInstance>;
|
|
152
153
|
protected _setState(state: SoundState): void;
|
|
153
154
|
protected abstract _createInstance(): _AbstractSoundInstance;
|
|
154
155
|
protected _stopExcessInstances(): void;
|
|
155
|
-
private _getNewestInstance;
|
|
156
156
|
private _onInstanceEnded;
|
|
157
157
|
private _onOutBusDisposed;
|
|
158
158
|
}
|
|
@@ -179,6 +179,18 @@ export class AbstractSound extends AbstractNamedAudioNode {
|
|
|
179
179
|
_afterPlay(instance) {
|
|
180
180
|
this._state = instance.state;
|
|
181
181
|
}
|
|
182
|
+
_getNewestInstance() {
|
|
183
|
+
if (this._instances.size === 0) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (!this._newestInstance) {
|
|
187
|
+
const it = this._instances.values();
|
|
188
|
+
for (let next = it.next(); !next.done; next = it.next()) {
|
|
189
|
+
this._newestInstance = next.value;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return this._newestInstance;
|
|
193
|
+
}
|
|
182
194
|
_setState(state) {
|
|
183
195
|
this._state = state;
|
|
184
196
|
}
|
|
@@ -192,17 +204,5 @@ export class AbstractSound extends AbstractNamedAudioNode {
|
|
|
192
204
|
}
|
|
193
205
|
}
|
|
194
206
|
}
|
|
195
|
-
_getNewestInstance() {
|
|
196
|
-
if (this._instances.size === 0) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
if (!this._newestInstance) {
|
|
200
|
-
const it = this._instances.values();
|
|
201
|
-
for (let next = it.next(); !next.done; next = it.next()) {
|
|
202
|
-
this._newestInstance = next.value;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return this._newestInstance;
|
|
206
|
-
}
|
|
207
207
|
}
|
|
208
208
|
//# sourceMappingURL=abstractSound.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractSound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAM5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAIhG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAiD/D;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,sBAAsB;IAgB9D,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC,CAAC,4BAA4B;QAhBnF,cAAS,GAA6B,IAAI,CAAC;QAC3C,oBAAe,GAAqC,IAAI,CAAC;QACzD,YAAO,GAA8B,IAAI,CAAC;QAC1C,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACtD,WAAM,8BAAkC;QAEtC,eAAU,GAAwC,IAAI,CAAC,iBAAiB,CAAC;QAInF;;WAEG;QACa,sBAAiB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAkP5D,qBAAgB,GAA+C,CAAC,QAAQ,EAAE,EAAE;YAChF,IAAI,IAAI,CAA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AAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;gBACjC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;IAEO,kBAAkB;QACtB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACpC,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC;YACtC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;CAkBJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport type { PrimaryAudioBus } from \"./audioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\nimport type { IAudioAnalyzerOptions } from \"./subProperties/abstractAudioAnalyzer\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\nimport { _AudioAnalyzer } from \"./subProperties/audioAnalyzer\";\n\n/** @internal */\nexport interface IAbstractSoundOptionsBase {\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n autoplay: boolean;\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n maxInstances: number;\n}\n\n/** @internal */\nexport interface IAbstractSoundPlayOptionsBase {\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n loop: boolean;\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n startOffset: number;\n}\n\n/**\n * Options for creating a sound.\n */\nexport interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, IAudioAnalyzerOptions, ISpatialAudioOptions, IStereoAudioOptions {\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: Nullable<PrimaryAudioBus>;\n}\n\n/**\n * Options for playing a sound.\n */\nexport interface IAbstractSoundPlayOptions extends IAbstractSoundPlayOptionsBase, IVolumeAudioOptions {}\n\n/**\n * Options stored in a sound.\n * @internal\n */\nexport interface IAbstractSoundStoredOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptionsBase {}\n\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport abstract class AbstractSound extends AbstractNamedAudioNode {\n private _analyzer: Nullable<_AudioAnalyzer> = null;\n private _newestInstance: Nullable<_AbstractSoundInstance> = null;\n private _outBus: Nullable<PrimaryAudioBus> = null;\n private _privateInstances = new Set<_AbstractSoundInstance>();\n private _state: SoundState = SoundState.Stopped;\n\n protected _instances: ReadonlySet<_AbstractSoundInstance> = this._privateInstances;\n protected abstract readonly _options: IAbstractSoundStoredOptions;\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n /**\n * Observable for when the sound stops playing.\n */\n public readonly onEndedObservable = new Observable<AbstractSound>();\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS); // Inputs are for instances.\n }\n\n /**\n * The analyzer features of the sound.\n */\n public get analyzer(): _AudioAnalyzer {\n return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));\n }\n\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n public get autoplay(): boolean {\n return this._options.autoplay;\n }\n\n /**\n * The current playback time of the sound, in seconds.\n */\n public get currentTime(): number {\n const instance = this._getNewestInstance();\n return instance ? instance.currentTime : 0;\n }\n\n public set currentTime(value: number) {\n this.startOffset = value;\n\n const instance = this._getNewestInstance();\n if (instance) {\n instance.currentTime = value;\n }\n }\n\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n public get loop(): boolean {\n return this._options.loop;\n }\n\n public set loop(value: boolean) {\n this._options.loop = value;\n }\n\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n public get maxInstances(): number {\n return this._options.maxInstances;\n }\n\n public set maxInstances(value: number) {\n this._options.maxInstances = value;\n }\n\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial features of the sound.\n */\n public abstract spatial: AbstractSpatialAudio;\n\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n public get startOffset(): number {\n return this._options.startOffset;\n }\n\n public set startOffset(value: number) {\n this._options.startOffset = value;\n }\n\n /**\n * The state of the sound.\n */\n public get state(): SoundState {\n return this._state;\n }\n\n /**\n * The stereo features of the sound.\n */\n public abstract stereo: AbstractStereoAudio;\n\n /**\n * The output volume of the sound.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._analyzer?.dispose();\n this._analyzer = null;\n\n this._newestInstance = null;\n this._outBus = null;\n\n this._privateInstances.clear();\n this.onEndedObservable.clear();\n }\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public abstract play(options?: Partial<IAbstractSoundPlayOptions>): void;\n\n /**\n * Pauses the sound.\n */\n public pause(): void {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.pause();\n }\n\n this._state = SoundState.Paused;\n }\n\n /**\n * Resumes the sound.\n */\n public resume(): void {\n if (this._state !== SoundState.Paused) {\n return;\n }\n\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.resume();\n }\n\n this._state = SoundState.Started;\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n */\n public abstract stop(): void;\n\n protected _beforePlay(instance: _AbstractSoundInstance): void {\n if (this.state === SoundState.Paused && this._instances.size > 0) {\n this.resume();\n return;\n }\n\n instance.onEndedObservable.addOnce(this._onInstanceEnded);\n this._privateInstances.add(instance);\n this._newestInstance = instance;\n }\n\n protected _afterPlay(instance: _AbstractSoundInstance): void {\n this._state = instance.state;\n }\n\n protected _setState(state: SoundState): void {\n this._state = state;\n }\n\n protected abstract _createInstance(): _AbstractSoundInstance;\n\n protected _stopExcessInstances(): void {\n if (this.maxInstances < Infinity) {\n const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === SoundState.Started).length - this.maxInstances;\n const it = this._instances.values();\n\n for (let i = 0; i < numberOfInstancesToStop; i++) {\n const instance = it.next().value;\n instance.stop();\n }\n }\n }\n\n private _getNewestInstance(): Nullable<_AbstractSoundInstance> {\n if (this._instances.size === 0) {\n return null;\n }\n\n if (!this._newestInstance) {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n this._newestInstance = next.value;\n }\n }\n\n return this._newestInstance;\n }\n\n private _onInstanceEnded: (instance: _AbstractSoundInstance) => void = (instance) => {\n if (this._newestInstance === instance) {\n this._newestInstance = null;\n }\n\n this._privateInstances.delete(instance);\n\n if (this._instances.size === 0) {\n this._state = SoundState.Stopped;\n this.onEndedObservable.notifyObservers(this);\n }\n };\n\n private _onOutBusDisposed = () => {\n this.outBus = null;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstractSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/abstractSound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAM5E,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAIhG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAiD/D;;GAEG;AACH,MAAM,OAAgB,aAAc,SAAQ,sBAAsB;IAgB9D,YAAsB,IAAY,EAAE,MAAqB;QACrD,KAAK,CAAC,IAAI,EAAE,MAAM,+CAAuC,CAAC,CAAC,4BAA4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AAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACpC,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC;YACtC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAES,SAAS,CAAC,KAAiB;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAIS,oBAAoB;QAC1B,IAAI,IAAI,CAAC,YAAY,GAAG,QAAQ,EAAE,CAAC;YAC/B,MAAM,uBAAuB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,+BAAuB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YACnJ,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;gBACjC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;CAkBJ","sourcesContent":["import { Observable } from \"../../Misc/observable\";\nimport type { Nullable } from \"../../types\";\nimport { SoundState } from \"../soundState\";\nimport { AbstractNamedAudioNode, AudioNodeType } from \"./abstractAudioNode\";\nimport type { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport type { PrimaryAudioBus } from \"./audioBus\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { _AbstractAudioSubGraph } from \"./subNodes/abstractAudioSubGraph\";\nimport type { IVolumeAudioOptions } from \"./subNodes/volumeAudioSubNode\";\nimport { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from \"./subNodes/volumeAudioSubNode\";\nimport type { IAudioAnalyzerOptions } from \"./subProperties/abstractAudioAnalyzer\";\nimport type { AbstractSpatialAudio, ISpatialAudioOptions } from \"./subProperties/abstractSpatialAudio\";\nimport type { AbstractStereoAudio, IStereoAudioOptions } from \"./subProperties/abstractStereoAudio\";\nimport { _AudioAnalyzer } from \"./subProperties/audioAnalyzer\";\n\n/** @internal */\nexport interface IAbstractSoundOptionsBase {\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n autoplay: boolean;\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n maxInstances: number;\n}\n\n/** @internal */\nexport interface IAbstractSoundPlayOptionsBase {\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n loop: boolean;\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n startOffset: number;\n}\n\n/**\n * Options for creating a sound.\n */\nexport interface IAbstractSoundOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptions, IAudioAnalyzerOptions, ISpatialAudioOptions, IStereoAudioOptions {\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n outBus: Nullable<PrimaryAudioBus>;\n}\n\n/**\n * Options for playing a sound.\n */\nexport interface IAbstractSoundPlayOptions extends IAbstractSoundPlayOptionsBase, IVolumeAudioOptions {}\n\n/**\n * Options stored in a sound.\n * @internal\n */\nexport interface IAbstractSoundStoredOptions extends IAbstractSoundOptionsBase, IAbstractSoundPlayOptionsBase {}\n\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport abstract class AbstractSound extends AbstractNamedAudioNode {\n private _analyzer: Nullable<_AudioAnalyzer> = null;\n private _newestInstance: Nullable<_AbstractSoundInstance> = null;\n private _outBus: Nullable<PrimaryAudioBus> = null;\n private _privateInstances = new Set<_AbstractSoundInstance>();\n private _state: SoundState = SoundState.Stopped;\n\n protected _instances: ReadonlySet<_AbstractSoundInstance> = this._privateInstances;\n protected abstract readonly _options: IAbstractSoundStoredOptions;\n protected abstract _subGraph: _AbstractAudioSubGraph;\n\n /**\n * Observable for when the sound stops playing.\n */\n public readonly onEndedObservable = new Observable<AbstractSound>();\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine, AudioNodeType.HAS_INPUTS_AND_OUTPUTS); // Inputs are for instances.\n }\n\n /**\n * The analyzer features of the sound.\n */\n public get analyzer(): _AudioAnalyzer {\n return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph));\n }\n\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n public get autoplay(): boolean {\n return this._options.autoplay;\n }\n\n /**\n * The current playback time of the sound, in seconds.\n */\n public get currentTime(): number {\n const instance = this._getNewestInstance();\n return instance ? instance.currentTime : 0;\n }\n\n public set currentTime(value: number) {\n this.startOffset = value;\n\n const instance = this._getNewestInstance();\n if (instance) {\n instance.currentTime = value;\n }\n }\n\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n public get loop(): boolean {\n return this._options.loop;\n }\n\n public set loop(value: boolean) {\n this._options.loop = value;\n }\n\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n public get maxInstances(): number {\n return this._options.maxInstances;\n }\n\n public set maxInstances(value: number) {\n this._options.maxInstances = value;\n }\n\n /**\n * The output bus for the sound. Defaults to `null`.\n * - If not set or `null`, the sound is automatically connected to the audio engine's default main bus.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n public get outBus(): Nullable<PrimaryAudioBus> {\n return this._outBus;\n }\n\n public set outBus(outBus: Nullable<PrimaryAudioBus>) {\n if (this._outBus === outBus) {\n return;\n }\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n\n this._outBus = outBus;\n\n if (this._outBus) {\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n\n /**\n * The spatial features of the sound.\n */\n public abstract spatial: AbstractSpatialAudio;\n\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n public get startOffset(): number {\n return this._options.startOffset;\n }\n\n public set startOffset(value: number) {\n this._options.startOffset = value;\n }\n\n /**\n * The state of the sound.\n */\n public get state(): SoundState {\n return this._state;\n }\n\n /**\n * The stereo features of the sound.\n */\n public abstract stereo: AbstractStereoAudio;\n\n /**\n * The output volume of the sound.\n */\n public get volume(): number {\n return _GetVolumeAudioProperty(this._subGraph, \"volume\");\n }\n\n public set volume(value: number) {\n // The volume subnode is created on initialization and should always exist.\n const node = _GetVolumeAudioSubNode(this._subGraph);\n if (!node) {\n throw new Error(\"No volume subnode\");\n }\n\n node.volume = value;\n }\n\n /**\n * Releases associated resources.\n */\n public override dispose(): void {\n super.dispose();\n\n this.stop();\n\n this._analyzer?.dispose();\n this._analyzer = null;\n\n this._newestInstance = null;\n this._outBus = null;\n\n this._privateInstances.clear();\n this.onEndedObservable.clear();\n }\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public abstract play(options?: Partial<IAbstractSoundPlayOptions>): void;\n\n /**\n * Pauses the sound.\n */\n public pause(): void {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.pause();\n }\n\n this._state = SoundState.Paused;\n }\n\n /**\n * Resumes the sound.\n */\n public resume(): void {\n if (this._state !== SoundState.Paused) {\n return;\n }\n\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.resume();\n }\n\n this._state = SoundState.Started;\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n */\n public abstract stop(): void;\n\n protected _beforePlay(instance: _AbstractSoundInstance): void {\n if (this.state === SoundState.Paused && this._instances.size > 0) {\n this.resume();\n return;\n }\n\n instance.onEndedObservable.addOnce(this._onInstanceEnded);\n this._privateInstances.add(instance);\n this._newestInstance = instance;\n }\n\n protected _afterPlay(instance: _AbstractSoundInstance): void {\n this._state = instance.state;\n }\n\n protected _getNewestInstance(): Nullable<_AbstractSoundInstance> {\n if (this._instances.size === 0) {\n return null;\n }\n\n if (!this._newestInstance) {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n this._newestInstance = next.value;\n }\n }\n\n return this._newestInstance;\n }\n\n protected _setState(state: SoundState): void {\n this._state = state;\n }\n\n protected abstract _createInstance(): _AbstractSoundInstance;\n\n protected _stopExcessInstances(): void {\n if (this.maxInstances < Infinity) {\n const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === SoundState.Started).length - this.maxInstances;\n const it = this._instances.values();\n\n for (let i = 0; i < numberOfInstancesToStop; i++) {\n const instance = it.next().value;\n instance.stop();\n }\n }\n }\n\n private _onInstanceEnded: (instance: _AbstractSoundInstance) => void = (instance) => {\n if (this._newestInstance === instance) {\n this._newestInstance = null;\n }\n\n this._privateInstances.delete(instance);\n\n if (this._instances.size === 0) {\n this._state = SoundState.Stopped;\n this.onEndedObservable.notifyObservers(this);\n }\n };\n\n private _onOutBusDisposed = () => {\n this.outBus = null;\n };\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Node } from "../../../node";
|
|
2
|
+
import type { Nullable } from "../../../types";
|
|
2
3
|
import { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
|
|
3
4
|
import type { _SpatialAudioSubNode } from "../subNodes/spatialAudioSubNode";
|
|
4
5
|
import type { _SpatialAudioListener } from "../subProperties/spatialAudioListener";
|
|
@@ -18,18 +19,22 @@ export declare class _SpatialAudioAttacherComponent {
|
|
|
18
19
|
/** @internal */
|
|
19
20
|
constructor(spatialAudioNode: _SpatialAudioSubNode | _SpatialAudioListener);
|
|
20
21
|
/**
|
|
21
|
-
* Returns `true` if
|
|
22
|
+
* Returns `true` if attached to a scene node; otherwise returns `false`.
|
|
22
23
|
*/
|
|
23
24
|
get isAttached(): boolean;
|
|
24
25
|
/**
|
|
25
|
-
* Attaches a scene
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Attaches to a scene node.
|
|
27
|
+
*
|
|
28
|
+
* Detaches automatically before attaching to the given scene node.
|
|
29
|
+
* If `sceneNode` is `null` it is the same as calling `detach()`.
|
|
30
|
+
*
|
|
31
|
+
* @param sceneNode The scene node to attach to, or `null` to detach.
|
|
32
|
+
* @param useBoundingBox Whether to use the scene node's bounding box for positioning. Defaults to `false`.
|
|
33
|
+
* @param attachmentType Whether to attach to the scene node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
29
34
|
*/
|
|
30
|
-
attach(sceneNode: Node
|
|
35
|
+
attach(sceneNode: Nullable<Node>, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void;
|
|
31
36
|
/**
|
|
32
|
-
* Detaches the attached
|
|
37
|
+
* Detaches from the scene node if attached.
|
|
33
38
|
*/
|
|
34
39
|
detach(): void;
|
|
35
40
|
/**
|
|
@@ -37,7 +42,9 @@ export declare class _SpatialAudioAttacherComponent {
|
|
|
37
42
|
*/
|
|
38
43
|
dispose: () => void;
|
|
39
44
|
/**
|
|
40
|
-
* Updates the audio
|
|
45
|
+
* Updates the position and rotation of the associated audio engine object in the audio rendering graph.
|
|
46
|
+
*
|
|
47
|
+
* This is called automatically by default and only needs to be called manually if automatic updates are disabled.
|
|
41
48
|
*/
|
|
42
49
|
update(): void;
|
|
43
50
|
}
|
|
@@ -22,33 +22,45 @@ export class _SpatialAudioAttacherComponent {
|
|
|
22
22
|
this._spatialAudioNode = spatialAudioNode;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Returns `true` if
|
|
25
|
+
* Returns `true` if attached to a scene node; otherwise returns `false`.
|
|
26
26
|
*/
|
|
27
27
|
get isAttached() {
|
|
28
28
|
return this._sceneNode !== null;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Attaches a scene
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* Attaches to a scene node.
|
|
32
|
+
*
|
|
33
|
+
* Detaches automatically before attaching to the given scene node.
|
|
34
|
+
* If `sceneNode` is `null` it is the same as calling `detach()`.
|
|
35
|
+
*
|
|
36
|
+
* @param sceneNode The scene node to attach to, or `null` to detach.
|
|
37
|
+
* @param useBoundingBox Whether to use the scene node's bounding box for positioning. Defaults to `false`.
|
|
38
|
+
* @param attachmentType Whether to attach to the scene node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
35
39
|
*/
|
|
36
40
|
attach(sceneNode, useBoundingBox, attachmentType) {
|
|
41
|
+
if (this._sceneNode === sceneNode) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
37
44
|
this.detach();
|
|
45
|
+
if (!sceneNode) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
38
48
|
this._attachmentType = attachmentType;
|
|
39
49
|
this._sceneNode = sceneNode;
|
|
40
50
|
this._sceneNode.onDisposeObservable.add(this.dispose);
|
|
41
51
|
this._useBoundingBox = useBoundingBox;
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
|
-
* Detaches the attached
|
|
54
|
+
* Detaches from the scene node if attached.
|
|
45
55
|
*/
|
|
46
56
|
detach() {
|
|
47
57
|
this._sceneNode?.onDisposeObservable.removeCallback(this.dispose);
|
|
48
58
|
this._sceneNode = null;
|
|
49
59
|
}
|
|
50
60
|
/**
|
|
51
|
-
* Updates the audio
|
|
61
|
+
* Updates the position and rotation of the associated audio engine object in the audio rendering graph.
|
|
62
|
+
*
|
|
63
|
+
* This is called automatically by default and only needs to be called manually if automatic updates are disabled.
|
|
52
64
|
*/
|
|
53
65
|
update() {
|
|
54
66
|
if (this._attachmentType & 1 /* SpatialAudioAttachmentType.Position */) {
|
|
@@ -56,15 +68,15 @@ export class _SpatialAudioAttacherComponent {
|
|
|
56
68
|
this._position.copyFrom(this._sceneNode.getBoundingInfo().boundingBox.centerWorld);
|
|
57
69
|
}
|
|
58
70
|
else {
|
|
59
|
-
this.
|
|
71
|
+
this._sceneNode?.getWorldMatrix().getTranslationToRef(this._position);
|
|
60
72
|
}
|
|
61
73
|
this._spatialAudioNode.position.copyFrom(this._position);
|
|
62
|
-
this._spatialAudioNode.
|
|
74
|
+
this._spatialAudioNode._updatePosition();
|
|
63
75
|
}
|
|
64
76
|
if (this._attachmentType & 2 /* SpatialAudioAttachmentType.Rotation */) {
|
|
65
|
-
this._sceneNode?.getWorldMatrix().decompose(undefined, this._rotationQuaternion
|
|
77
|
+
this._sceneNode?.getWorldMatrix().decompose(undefined, this._rotationQuaternion);
|
|
66
78
|
this._spatialAudioNode.rotationQuaternion.copyFrom(this._rotationQuaternion);
|
|
67
|
-
this._spatialAudioNode.
|
|
79
|
+
this._spatialAudioNode._updateRotation();
|
|
68
80
|
}
|
|
69
81
|
}
|
|
70
82
|
}
|
|
@@ -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;QAmDzC;;WAEG;QACI,YAAO,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC,CAAC;QApDE,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC;IACpC,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,MAAM,EAAE,CAAC;QAEd,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO;QACX,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtD,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;IASD;;;;OAIG;IACI,MAAM;QACT,IAAI,IAAI,CAAC,eAAe,8CAAsC,EAAE,CAAC;YAC7D,IAAI,IAAI,CAAC,eAAe,IAAK,IAAI,CAAC,UAA2B,CAAC,eAAe,EAAE,CAAC;gBAC5E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAE,IAAI,CAAC,UAA2B,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YACzG,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1E,CAAC;YAED,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzD,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAC;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,8CAAsC,EAAE,CAAC;YAC7D,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,mBAAmB,CAAC,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;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 * 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 if (this._attachmentType & SpatialAudioAttachmentType.Position) {\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}\n"]}
|
|
@@ -54,6 +54,10 @@ export class StaticSound extends AbstractSound {
|
|
|
54
54
|
}
|
|
55
55
|
set pitch(value) {
|
|
56
56
|
this._options.pitch = value;
|
|
57
|
+
const instance = this._getNewestInstance();
|
|
58
|
+
if (instance) {
|
|
59
|
+
instance.pitch = value;
|
|
60
|
+
}
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* The playback rate of the sound. Defaults to `1`.
|
|
@@ -64,6 +68,10 @@ export class StaticSound extends AbstractSound {
|
|
|
64
68
|
}
|
|
65
69
|
set playbackRate(value) {
|
|
66
70
|
this._options.playbackRate = value;
|
|
71
|
+
const instance = this._getNewestInstance();
|
|
72
|
+
if (instance) {
|
|
73
|
+
instance.playbackRate = value;
|
|
74
|
+
}
|
|
67
75
|
}
|
|
68
76
|
/**
|
|
69
77
|
* Plays the sound.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/staticSound.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EA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C,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,OAAO;QACX,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { SoundState } from \"../soundState\";\nimport type { IAbstractSoundOptions, IAbstractSoundPlayOptions, IAbstractSoundStoredOptions } from \"./abstractSound\";\nimport { AbstractSound } from \"./abstractSound\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { _StaticSoundInstance } from \"./staticSoundInstance\";\n\n/** @internal */\nexport interface IStaticSoundOptionsBase {\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n duration: number;\n /**\n * The end of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n * - Has no effect if {@link loop} is `false`.\n */\n loopEnd: number;\n /**\n * The start of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n * - Has no effect if {@link loop} is `false`.\n *\n */\n loopStart: number;\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Can be combined with {@link playbackRate}.\n */\n pitch: number;\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Can be combined with {@link pitch}.\n */\n playbackRate: number;\n}\n\n/** @internal */\nexport interface IStaticSoundPlayOptionsBase {\n /**\n * The time to wait before playing the sound, in seconds. Defaults to `0`.\n */\n waitTime: number;\n}\n\n/**\n * Options for creating a static sound.\n */\nexport interface IStaticSoundOptions extends IAbstractSoundOptions, IStaticSoundBufferOptions, IStaticSoundStoredOptions {}\n\n/**\n * Options for playing a static sound.\n */\nexport interface IStaticSoundPlayOptions extends IAbstractSoundPlayOptions, IStaticSoundOptionsBase, IStaticSoundPlayOptionsBase {}\n\n/**\n * Options for stopping a static sound.\n */\nexport interface IStaticSoundStopOptions {\n /**\n * The time to wait before stopping the sound, in seconds. Defaults to `0`.\n */\n waitTime: number;\n}\n\n/**\n * Options stored in a static sound.\n * @internal\n */\nexport interface IStaticSoundStoredOptions extends IAbstractSoundStoredOptions, IStaticSoundOptionsBase {}\n\n/**\n * Abstract class representing a static sound.\n *\n * A static sound has a sound buffer that is loaded into memory all at once. This allows it to have more capabilities\n * than a streaming sound, such as loop points and playback rate changes, but it also means that the sound must be\n * fully downloaded and decoded before it can be played, which may take a long time for sounds with long durations.\n *\n * To prevent downloading and decoding a sound multiple times, a sound's buffer can be shared with other sounds.\n * See {@link CreateSoundBufferAsync}, {@link StaticSoundBuffer} and {@link StaticSound.buffer} for more information.\n *\n * Static sounds are created by the {@link CreateSoundAsync} function.\n */\nexport abstract class StaticSound extends AbstractSound {\n protected override _instances: Set<_StaticSoundInstance>;\n protected abstract override readonly _options: IStaticSoundStoredOptions;\n\n /**\n * The sound buffer that the sound uses.\n *\n * This buffer can be shared with other static sounds.\n */\n public abstract readonly buffer: StaticSoundBuffer;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n public get duration(): number {\n return this._options.duration;\n }\n\n public set duration(value: number) {\n this._options.duration = value;\n }\n\n /**\n * The start of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n */\n public get loopStart(): number {\n return this._options.loopStart;\n }\n\n public set loopStart(value: number) {\n this._options.loopStart = value;\n }\n\n /**\n * The end of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n */\n public get loopEnd(): number {\n return this._options.loopEnd;\n }\n\n public set loopEnd(value: number) {\n this._options.loopEnd = value;\n }\n\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Gets combined with {@link playbackRate} to determine the final pitch.\n */\n public get pitch(): number {\n return this._options.pitch;\n }\n\n public set pitch(value: number) {\n this._options.pitch = value;\n }\n\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Gets combined with {@link pitch} to determine the final playback rate.\n */\n public get playbackRate(): number {\n return this._options.playbackRate;\n }\n\n public set playbackRate(value: number) {\n this._options.playbackRate = value;\n }\n\n protected abstract override _createInstance(): _StaticSoundInstance;\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this.state === SoundState.Paused) {\n this.resume();\n return;\n }\n\n options.duration ??= this.duration;\n options.loop ??= this.loop;\n options.loopStart ??= this.loopStart;\n options.loopEnd ??= this.loopEnd;\n options.pitch ??= this.pitch;\n options.playbackRate ??= this.playbackRate;\n options.startOffset ??= this.startOffset;\n options.volume ??= 1;\n options.waitTime ??= 0;\n\n const instance = this._createInstance();\n this._beforePlay(instance);\n instance.play(options);\n this._afterPlay(instance);\n\n this._stopExcessInstances();\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n * @param options - The options to use when stopping the sound.\n */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (options.waitTime && 0 < options.waitTime) {\n this._setState(SoundState.Stopping);\n } else {\n this._setState(SoundState.Stopped);\n }\n\n if (!this._instances) {\n return;\n }\n\n for (const instance of Array.from(this._instances)) {\n instance.stop(options);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"staticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/staticSound.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAuEhD;;;;;;;;;;;GAWG;AACH,MAAM,OAAgB,WAAY,SA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,IAAI,CAAC,UAA4C,EAAE;QACtD,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3C,IAAI,CAAC,SAAS,6BAAqB,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,SAAS,4BAAoB,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,OAAO;QACX,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { SoundState } from \"../soundState\";\nimport type { IAbstractSoundOptions, IAbstractSoundPlayOptions, IAbstractSoundStoredOptions } from \"./abstractSound\";\nimport { AbstractSound } from \"./abstractSound\";\nimport type { AudioEngineV2 } from \"./audioEngineV2\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { _StaticSoundInstance } from \"./staticSoundInstance\";\n\n/** @internal */\nexport interface IStaticSoundOptionsBase {\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n duration: number;\n /**\n * The end of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n * - Has no effect if {@link loop} is `false`.\n */\n loopEnd: number;\n /**\n * The start of the loop range in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n * - Has no effect if {@link loop} is `false`.\n *\n */\n loopStart: number;\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Can be combined with {@link playbackRate}.\n */\n pitch: number;\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Can be combined with {@link pitch}.\n */\n playbackRate: number;\n}\n\n/** @internal */\nexport interface IStaticSoundPlayOptionsBase {\n /**\n * The time to wait before playing the sound, in seconds. Defaults to `0`.\n */\n waitTime: number;\n}\n\n/**\n * Options for creating a static sound.\n */\nexport interface IStaticSoundOptions extends IAbstractSoundOptions, IStaticSoundBufferOptions, IStaticSoundStoredOptions {}\n\n/**\n * Options for playing a static sound.\n */\nexport interface IStaticSoundPlayOptions extends IAbstractSoundPlayOptions, IStaticSoundOptionsBase, IStaticSoundPlayOptionsBase {}\n\n/**\n * Options for stopping a static sound.\n */\nexport interface IStaticSoundStopOptions {\n /**\n * The time to wait before stopping the sound, in seconds. Defaults to `0`.\n */\n waitTime: number;\n}\n\n/**\n * Options stored in a static sound.\n * @internal\n */\nexport interface IStaticSoundStoredOptions extends IAbstractSoundStoredOptions, IStaticSoundOptionsBase {}\n\n/**\n * Abstract class representing a static sound.\n *\n * A static sound has a sound buffer that is loaded into memory all at once. This allows it to have more capabilities\n * than a streaming sound, such as loop points and playback rate changes, but it also means that the sound must be\n * fully downloaded and decoded before it can be played, which may take a long time for sounds with long durations.\n *\n * To prevent downloading and decoding a sound multiple times, a sound's buffer can be shared with other sounds.\n * See {@link CreateSoundBufferAsync}, {@link StaticSoundBuffer} and {@link StaticSound.buffer} for more information.\n *\n * Static sounds are created by the {@link CreateSoundAsync} function.\n */\nexport abstract class StaticSound extends AbstractSound {\n protected override _instances: Set<_StaticSoundInstance>;\n protected abstract override readonly _options: IStaticSoundStoredOptions;\n\n /**\n * The sound buffer that the sound uses.\n *\n * This buffer can be shared with other static sounds.\n */\n public abstract readonly buffer: StaticSoundBuffer;\n\n protected constructor(name: string, engine: AudioEngineV2) {\n super(name, engine);\n }\n\n /**\n * The amount of time to play the sound for, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the sound plays for its full duration.\n */\n public get duration(): number {\n return this._options.duration;\n }\n\n public set duration(value: number) {\n this._options.duration = value;\n }\n\n /**\n * The start of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop starts at the beginning of the sound.\n */\n public get loopStart(): number {\n return this._options.loopStart;\n }\n\n public set loopStart(value: number) {\n this._options.loopStart = value;\n }\n\n /**\n * The end of the loop range, in seconds. Defaults to `0`.\n * - If less than or equal to `0`, the loop plays for the sound's full duration.\n */\n public get loopEnd(): number {\n return this._options.loopEnd;\n }\n\n public set loopEnd(value: number) {\n this._options.loopEnd = value;\n }\n\n /**\n * The pitch of the sound, in cents. Defaults to `0`.\n * - Gets combined with {@link playbackRate} to determine the final pitch.\n */\n public get pitch(): number {\n return this._options.pitch;\n }\n\n public set pitch(value: number) {\n this._options.pitch = value;\n\n const instance = this._getNewestInstance() as _StaticSoundInstance;\n if (instance) {\n instance.pitch = value;\n }\n }\n\n /**\n * The playback rate of the sound. Defaults to `1`.\n * - Gets combined with {@link pitch} to determine the final playback rate.\n */\n public get playbackRate(): number {\n return this._options.playbackRate;\n }\n\n public set playbackRate(value: number) {\n this._options.playbackRate = value;\n\n const instance = this._getNewestInstance() as _StaticSoundInstance;\n if (instance) {\n instance.playbackRate = value;\n }\n }\n\n protected abstract override _createInstance(): _StaticSoundInstance;\n\n /**\n * Plays the sound.\n * - Triggers `onEndedObservable` if played for the full duration and the `loop` option is not set.\n * @param options The options to use when playing the sound. Options set here override the sound's options.\n */\n public play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this.state === SoundState.Paused) {\n this.resume();\n return;\n }\n\n options.duration ??= this.duration;\n options.loop ??= this.loop;\n options.loopStart ??= this.loopStart;\n options.loopEnd ??= this.loopEnd;\n options.pitch ??= this.pitch;\n options.playbackRate ??= this.playbackRate;\n options.startOffset ??= this.startOffset;\n options.volume ??= 1;\n options.waitTime ??= 0;\n\n const instance = this._createInstance();\n this._beforePlay(instance);\n instance.play(options);\n this._afterPlay(instance);\n\n this._stopExcessInstances();\n }\n\n /**\n * Stops the sound.\n * - Triggers `onEndedObservable` if the sound is playing.\n * @param options - The options to use when stopping the sound.\n */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (options.waitTime && 0 < options.waitTime) {\n this._setState(SoundState.Stopping);\n } else {\n this._setState(SoundState.Stopped);\n }\n\n if (!this._instances) {\n return;\n }\n\n for (const instance of Array.from(this._instances)) {\n instance.stop(options);\n }\n }\n}\n"]}
|
|
@@ -10,6 +10,8 @@ export interface IStaticSoundInstanceOptions extends IAbstractSoundInstanceOptio
|
|
|
10
10
|
/** @internal */
|
|
11
11
|
export declare abstract class _StaticSoundInstance extends _AbstractSoundInstance {
|
|
12
12
|
protected abstract readonly _options: IStaticSoundInstanceOptions;
|
|
13
|
+
abstract pitch: number;
|
|
14
|
+
abstract playbackRate: number;
|
|
13
15
|
abstract play(options: Partial<IStaticSoundPlayOptions>): void;
|
|
14
16
|
abstract stop(options?: Partial<IStaticSoundStopOptions>): void;
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticSoundInstance.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/staticSoundInstance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AASjE,gBAAgB;AAChB,MAAM,OAAgB,oBAAqB,SAAQ,sBAAsB;
|
|
1
|
+
{"version":3,"file":"staticSoundInstance.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/staticSoundInstance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AASjE,gBAAgB;AAChB,MAAM,OAAgB,oBAAqB,SAAQ,sBAAsB;CAQxE","sourcesContent":["import type { IAbstractSoundInstanceOptions } from \"./abstractSoundInstance\";\nimport { _AbstractSoundInstance } from \"./abstractSoundInstance\";\nimport type { IStaticSoundOptionsBase, IStaticSoundPlayOptions, IStaticSoundStopOptions } from \"./staticSound\";\n\n/**\n * Options for creating a static sound instance.\n * @internal\n */\nexport interface IStaticSoundInstanceOptions extends IAbstractSoundInstanceOptions, IStaticSoundOptionsBase {}\n\n/** @internal */\nexport abstract class _StaticSoundInstance extends _AbstractSoundInstance {\n protected abstract override readonly _options: IStaticSoundInstanceOptions;\n\n public abstract pitch: number;\n public abstract playbackRate: number;\n\n public abstract override play(options: Partial<IStaticSoundPlayOptions>): void;\n public abstract override stop(options?: Partial<IStaticSoundStopOptions>): void;\n}\n"]}
|
|
@@ -16,9 +16,9 @@ export declare abstract class _SpatialAudioSubNode extends _AbstractAudioSubNode
|
|
|
16
16
|
abstract coneOuterVolume: number;
|
|
17
17
|
abstract distanceModel: DistanceModelType;
|
|
18
18
|
abstract maxDistance: number;
|
|
19
|
+
abstract minDistance: number;
|
|
19
20
|
abstract panningModel: PanningModelType;
|
|
20
21
|
abstract position: Vector3;
|
|
21
|
-
abstract referenceDistance: number;
|
|
22
22
|
abstract rolloffFactor: number;
|
|
23
23
|
abstract rotation: Vector3;
|
|
24
24
|
abstract rotationQuaternion: Quaternion;
|
|
@@ -26,7 +26,7 @@ export declare abstract class _SpatialAudioSubNode extends _AbstractAudioSubNode
|
|
|
26
26
|
/** @internal */
|
|
27
27
|
get isAttached(): boolean;
|
|
28
28
|
/** @internal */
|
|
29
|
-
attach(sceneNode: Node
|
|
29
|
+
attach(sceneNode: Nullable<Node>, useBoundingBox: boolean, attachmentType: SpatialAudioAttachmentType): void;
|
|
30
30
|
/** @internal */
|
|
31
31
|
detach(): void;
|
|
32
32
|
/** @internal */
|
|
@@ -35,8 +35,8 @@ export declare abstract class _SpatialAudioSubNode extends _AbstractAudioSubNode
|
|
|
35
35
|
setOptions(options: Partial<ISpatialAudioOptions>): void;
|
|
36
36
|
/** @internal */
|
|
37
37
|
update(): void;
|
|
38
|
-
abstract
|
|
39
|
-
abstract
|
|
38
|
+
abstract _updatePosition(): void;
|
|
39
|
+
abstract _updateRotation(): void;
|
|
40
40
|
}
|
|
41
41
|
/** @internal */
|
|
42
42
|
export declare function _GetSpatialAudioSubNode(subGraph: _AbstractAudioSubGraph): Nullable<_SpatialAudioSubNode>;
|
|
@@ -36,8 +36,8 @@ export class _SpatialAudioSubNode extends _AbstractAudioSubNode {
|
|
|
36
36
|
this.coneOuterVolume = options.spatialConeOuterVolume ?? _SpatialAudioDefaults.coneOuterVolume;
|
|
37
37
|
this.distanceModel = options.spatialDistanceModel ?? _SpatialAudioDefaults.distanceModel;
|
|
38
38
|
this.maxDistance = options.spatialMaxDistance ?? _SpatialAudioDefaults.maxDistance;
|
|
39
|
+
this.minDistance = options.spatialMinDistance ?? _SpatialAudioDefaults.minDistance;
|
|
39
40
|
this.panningModel = options.spatialPanningModel ?? _SpatialAudioDefaults.panningModel;
|
|
40
|
-
this.referenceDistance = options.spatialReferenceDistance ?? _SpatialAudioDefaults.referenceDistance;
|
|
41
41
|
this.rolloffFactor = options.spatialRolloffFactor ?? _SpatialAudioDefaults.rolloffFactor;
|
|
42
42
|
if (options.spatialPosition) {
|
|
43
43
|
this.position = options.spatialPosition.clone();
|
|
@@ -59,8 +59,8 @@ export class _SpatialAudioSubNode extends _AbstractAudioSubNode {
|
|
|
59
59
|
this._attacherComponent?.update();
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
62
|
+
this._updatePosition();
|
|
63
|
+
this._updateRotation();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -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;AAE7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,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;IAeD,gBAAgB;IAChB,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,kBAAkB,KAAK,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC;IAClF,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,
|
|
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;AAE7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,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;IAeD,gBAAgB;IAChB,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,kBAAkB,KAAK,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC;IAClF,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,SAAyB,EAAE,cAAuB,EAAE,cAA0C;QACxG,IAAI,CAAC,MAAM,EAAE,CAAC;QAEd,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC3B,IAAI,CAAC,kBAAkB,GAAG,IAAI,8BAA8B,CAAC,IAAI,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAC9E,CAAC;IAED,gBAAgB;IACT,MAAM;QACT,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IACtC,CAAC;IAED,gBAAgB;IACA,OAAO;QACnB,KAAK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M,CAAC;YACJ,IAAI,CAAC,kBAAkB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAC/E,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;IAED,gBAAgB;IACT,MAAM;QACT,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QACtC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;IACL,CAAC;CAIJ;AAED,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAAC,QAAgC;IACpE,OAAO,QAAQ,CAAC,UAAU,sCAA4C,CAAC;AAC3E,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAA+C,QAAgC,EAAE,QAAW;IAChI,OAAO,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AAC5F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAA+C,QAAgC,EAAE,QAAW,EAAE,KAA8B;IAChK,QAAQ,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, Vector3 } from \"../../../Maths/math.vector\";\nimport type { Node } from \"../../../node\";\nimport type { Nullable } from \"../../../types\";\nimport type { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\nimport type { AudioEngineV2 } from \"../audioEngineV2\";\nimport { _SpatialAudioAttacherComponent } from \"../components/spatialAudioAttacherComponent\";\nimport type { ISpatialAudioOptions } from \"../subProperties/abstractSpatialAudio\";\nimport { _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 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 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.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 _GetSpatialAudioProperty<K extends keyof typeof _SpatialAudioDefaults>(subGraph: _AbstractAudioSubGraph, property: K): (typeof _SpatialAudioDefaults)[K] {\n return _GetSpatialAudioSubNode(subGraph)?.[property] ?? _SpatialAudioDefaults[property];\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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../../../Maths/math.vector";
|
|
2
2
|
import type { Node } from "../../../node";
|
|
3
|
+
import type { Nullable } from "../../../types";
|
|
3
4
|
import type { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
|
|
4
5
|
export declare const _SpatialAudioDefaults: {
|
|
5
6
|
readonly coneInnerAngle: number;
|
|
@@ -7,9 +8,9 @@ export declare const _SpatialAudioDefaults: {
|
|
|
7
8
|
readonly coneOuterVolume: number;
|
|
8
9
|
readonly distanceModel: DistanceModelType;
|
|
9
10
|
readonly maxDistance: number;
|
|
11
|
+
readonly minDistance: number;
|
|
10
12
|
readonly panningModel: PanningModelType;
|
|
11
13
|
readonly position: Vector3;
|
|
12
|
-
readonly referenceDistance: number;
|
|
13
14
|
readonly rolloffFactor: number;
|
|
14
15
|
readonly rotation: Vector3;
|
|
15
16
|
readonly rotationQuaternion: Quaternion;
|
|
@@ -46,7 +47,7 @@ export interface ISpatialAudioOptions {
|
|
|
46
47
|
* - `"exponential"`: The volume is reduced exponentially as the source moves away from the listener.
|
|
47
48
|
*
|
|
48
49
|
* @see {@link spatialMaxDistance}
|
|
49
|
-
* @see {@link
|
|
50
|
+
* @see {@link spatialMinDistance}
|
|
50
51
|
* @see {@link spatialRolloffFactor}
|
|
51
52
|
*/
|
|
52
53
|
spatialDistanceModel: "linear" | "inverse" | "exponential";
|
|
@@ -88,7 +89,7 @@ export interface ISpatialAudioOptions {
|
|
|
88
89
|
* - This value is used by all distance models.
|
|
89
90
|
* @see {@link spatialDistanceModel}
|
|
90
91
|
*/
|
|
91
|
-
|
|
92
|
+
spatialMinDistance: number;
|
|
92
93
|
/**
|
|
93
94
|
* How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.
|
|
94
95
|
* - This value is used by all distance models.
|
|
@@ -139,7 +140,7 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
139
140
|
* - `"exponential"`: The volume is reduced exponentially as the source moves away from the listener.
|
|
140
141
|
*
|
|
141
142
|
* @see {@link spatialMaxDistance}
|
|
142
|
-
* @see {@link
|
|
143
|
+
* @see {@link spatialMinDistance}
|
|
143
144
|
* @see {@link spatialRolloffFactor}
|
|
144
145
|
*/
|
|
145
146
|
abstract distanceModel: "linear" | "inverse" | "exponential";
|
|
@@ -153,6 +154,12 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
153
154
|
* @see {@link distanceModel}
|
|
154
155
|
*/
|
|
155
156
|
abstract maxDistance: number;
|
|
157
|
+
/**
|
|
158
|
+
* 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.
|
|
159
|
+
* - This value is used by all distance models.
|
|
160
|
+
* @see {@link distanceModel}
|
|
161
|
+
*/
|
|
162
|
+
abstract minDistance: number;
|
|
156
163
|
/**
|
|
157
164
|
* The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.
|
|
158
165
|
* - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
|
|
@@ -170,12 +177,6 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
170
177
|
* The spatial position. Defaults to (0, 0, 0).
|
|
171
178
|
*/
|
|
172
179
|
abstract position: Vector3;
|
|
173
|
-
/**
|
|
174
|
-
* 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.
|
|
175
|
-
* - This value is used by all distance models.
|
|
176
|
-
* @see {@link distanceModel}
|
|
177
|
-
*/
|
|
178
|
-
abstract referenceDistance: number;
|
|
179
180
|
/**
|
|
180
181
|
* How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.
|
|
181
182
|
* - This value is used by all distance models.
|
|
@@ -191,18 +192,24 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
191
192
|
*/
|
|
192
193
|
abstract rotationQuaternion: Quaternion;
|
|
193
194
|
/**
|
|
194
|
-
* Attaches
|
|
195
|
-
*
|
|
195
|
+
* Attaches to a scene node.
|
|
196
|
+
*
|
|
197
|
+
* Detaches automatically before attaching to the given scene node.
|
|
198
|
+
* If `sceneNode` is `null` it is the same as calling `detach()`.
|
|
199
|
+
*
|
|
200
|
+
* @param sceneNode The scene node to attach to, or `null` to detach.
|
|
196
201
|
* @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
|
|
197
|
-
* @param attachmentType
|
|
202
|
+
* @param attachmentType Whether to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
198
203
|
*/
|
|
199
|
-
abstract attach(sceneNode: Node
|
|
204
|
+
abstract attach(sceneNode: Nullable<Node>, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;
|
|
200
205
|
/**
|
|
201
|
-
* Detaches
|
|
206
|
+
* Detaches from the scene node if attached.
|
|
202
207
|
*/
|
|
203
208
|
abstract detach(): void;
|
|
204
209
|
/**
|
|
205
|
-
* Updates the position and rotation
|
|
210
|
+
* Updates the position and rotation of the associated audio engine object in the audio rendering graph.
|
|
211
|
+
*
|
|
212
|
+
* This is called automatically by default and only needs to be called manually if automatic updates are disabled.
|
|
206
213
|
*/
|
|
207
214
|
abstract update(): void;
|
|
208
215
|
}
|
|
@@ -3,11 +3,11 @@ export const _SpatialAudioDefaults = {
|
|
|
3
3
|
coneInnerAngle: 6.28318530718,
|
|
4
4
|
coneOuterAngle: 6.28318530718,
|
|
5
5
|
coneOuterVolume: 0,
|
|
6
|
-
distanceModel: "
|
|
6
|
+
distanceModel: "linear",
|
|
7
7
|
maxDistance: 10000,
|
|
8
|
+
minDistance: 1,
|
|
8
9
|
panningModel: "equalpower",
|
|
9
10
|
position: Vector3.Zero(),
|
|
10
|
-
referenceDistance: 1,
|
|
11
11
|
rolloffFactor: 1,
|
|
12
12
|
rotation: Vector3.Zero(),
|
|
13
13
|
rotationQuaternion: new Quaternion(),
|
|
@@ -24,10 +24,10 @@ export function _HasSpatialAudioOptions(options) {
|
|
|
24
24
|
options.spatialConeOuterVolume !== undefined ||
|
|
25
25
|
options.spatialDistanceModel !== undefined ||
|
|
26
26
|
options.spatialMaxDistance !== undefined ||
|
|
27
|
+
options.spatialMinDistance !== undefined ||
|
|
27
28
|
options.spatialMinUpdateTime !== undefined ||
|
|
28
29
|
options.spatialPanningModel !== undefined ||
|
|
29
30
|
options.spatialPosition !== undefined ||
|
|
30
|
-
options.spatialReferenceDistance !== undefined ||
|
|
31
31
|
options.spatialRolloffFactor !== undefined ||
|
|
32
32
|
options.spatialRotation !== undefined ||
|
|
33
33
|
options.spatialRotationQuaternion !== undefined);
|