@babylonjs/core 7.52.0 → 7.52.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/abstractSound.d.ts +1 -2
- package/AudioV2/abstractAudio/abstractSound.js +1 -5
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioBus.d.ts +1 -2
- package/AudioV2/abstractAudio/audioBus.js +1 -5
- package/AudioV2/abstractAudio/audioBus.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +1 -2
- package/AudioV2/abstractAudio/audioEngineV2.js +1 -5
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +43 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +71 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -0
- package/AudioV2/abstractAudio/staticSound.d.ts +1 -1
- package/AudioV2/abstractAudio/staticSound.js +2 -2
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
- package/AudioV2/abstractAudio/streamingSound.js +2 -2
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +15 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +38 -3
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +29 -8
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +28 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +5 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +16 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +48 -14
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +21 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +39 -4
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/index.d.ts +1 -0
- package/AudioV2/index.js +1 -0
- package/AudioV2/index.js.map +1 -1
- package/AudioV2/spatialAudioAttachmentType.d.ts +5 -0
- package/AudioV2/spatialAudioAttachmentType.js +7 -0
- package/AudioV2/spatialAudioAttachmentType.js.map +1 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.d.ts +13 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js +38 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js.map +1 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +13 -14
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +39 -39
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudio.d.ts +6 -2
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js +13 -15
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.d.ts +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +41 -56
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioBus.d.ts +3 -0
- package/AudioV2/webAudio/webAudioBus.js +23 -2
- package/AudioV2/webAudio/webAudioBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +3 -1
- package/AudioV2/webAudio/webAudioEngine.js +11 -3
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +23 -2
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -0
- package/AudioV2/webAudio/webAudioStreamingSound.js +23 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -1
- package/Engines/abstractEngine.js +6 -5
- package/Engines/abstractEngine.js.map +1 -1
- package/Meshes/geometry.js +14 -7
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +1 -1
- package/Meshes/mesh.vertexData.js +2 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/fileTools.d.ts +3 -1
- package/Misc/fileTools.js +2 -2
- package/Misc/fileTools.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,33 @@
|
|
|
1
|
+
import { _SpatialAudioAttacherComponent } from "../components/spatialAudioAttacherComponent.js";
|
|
1
2
|
import { _SpatialAudioDefaults } from "../subProperties/abstractSpatialAudio.js";
|
|
2
3
|
import { _AbstractAudioSubNode } from "./abstractAudioSubNode.js";
|
|
3
4
|
/** @internal */
|
|
4
5
|
export class _SpatialAudioSubNode extends _AbstractAudioSubNode {
|
|
5
6
|
constructor(engine) {
|
|
6
7
|
super("Spatial" /* AudioSubNode.SPATIAL */, engine);
|
|
8
|
+
this._attacherComponent = null;
|
|
9
|
+
}
|
|
10
|
+
/** @internal */
|
|
11
|
+
get isAttached() {
|
|
12
|
+
return this._attacherComponent !== null && this._attacherComponent.isAttached;
|
|
13
|
+
}
|
|
14
|
+
/** @internal */
|
|
15
|
+
attach(sceneNode, useBoundingBox, attachmentType) {
|
|
16
|
+
this.detach();
|
|
17
|
+
if (!this._attacherComponent) {
|
|
18
|
+
this._attacherComponent = new _SpatialAudioAttacherComponent(this);
|
|
19
|
+
}
|
|
20
|
+
this._attacherComponent.attach(sceneNode, useBoundingBox, attachmentType);
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
23
|
+
detach() {
|
|
24
|
+
this._attacherComponent?.detach();
|
|
25
|
+
}
|
|
26
|
+
/** @internal */
|
|
27
|
+
dispose() {
|
|
28
|
+
super.dispose();
|
|
29
|
+
this._attacherComponent?.dispose();
|
|
30
|
+
this._attacherComponent = null;
|
|
7
31
|
}
|
|
8
32
|
/** @internal */
|
|
9
33
|
setOptions(options) {
|
|
@@ -15,18 +39,29 @@ export class _SpatialAudioSubNode extends _AbstractAudioSubNode {
|
|
|
15
39
|
this.panningModel = options.spatialPanningModel ?? _SpatialAudioDefaults.panningModel;
|
|
16
40
|
this.referenceDistance = options.spatialReferenceDistance ?? _SpatialAudioDefaults.referenceDistance;
|
|
17
41
|
this.rolloffFactor = options.spatialRolloffFactor ?? _SpatialAudioDefaults.rolloffFactor;
|
|
18
|
-
if (options.spatialPosition
|
|
42
|
+
if (options.spatialPosition) {
|
|
19
43
|
this.position = options.spatialPosition.clone();
|
|
20
44
|
}
|
|
21
|
-
if (options.spatialRotationQuaternion
|
|
45
|
+
if (options.spatialRotationQuaternion) {
|
|
22
46
|
this.rotationQuaternion = options.spatialRotationQuaternion.clone();
|
|
23
47
|
}
|
|
24
|
-
else if (options.spatialRotation
|
|
48
|
+
else if (options.spatialRotation) {
|
|
25
49
|
this.rotation = options.spatialRotation.clone();
|
|
26
50
|
}
|
|
27
51
|
else {
|
|
28
52
|
this.rotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();
|
|
29
53
|
}
|
|
54
|
+
this.update();
|
|
55
|
+
}
|
|
56
|
+
/** @internal */
|
|
57
|
+
update() {
|
|
58
|
+
if (this.isAttached) {
|
|
59
|
+
this._attacherComponent?.update();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.updatePosition();
|
|
63
|
+
this.updateRotation();
|
|
64
|
+
}
|
|
30
65
|
}
|
|
31
66
|
}
|
|
32
67
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.ts"],"names":[],"mappings":"
|
|
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,SAAe,EAAE,cAAuB,EAAE,cAA0C;QAC9F,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,CAAC,OAAO,EAAE,C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AAI,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,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1B,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 panningModel: PanningModelType;\n public abstract position: Vector3;\n public abstract referenceDistance: number;\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: 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.panningModel = options.spatialPanningModel ?? _SpatialAudioDefaults.panningModel;\n this.referenceDistance = options.spatialReferenceDistance ?? _SpatialAudioDefaults.referenceDistance;\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,4 +1,6 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../../../Maths/math.vector";
|
|
2
|
+
import type { Node } from "../../../node";
|
|
3
|
+
import type { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
|
|
2
4
|
export declare const _SpatialAudioDefaults: {
|
|
3
5
|
readonly coneInnerAngle: number;
|
|
4
6
|
readonly coneOuterAngle: number;
|
|
@@ -67,13 +69,14 @@ export interface ISpatialAudioOptions {
|
|
|
67
69
|
*/
|
|
68
70
|
spatialMaxDistance: number;
|
|
69
71
|
/**
|
|
70
|
-
* The
|
|
71
|
-
* -
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
* The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.
|
|
73
|
+
* - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
|
|
74
|
+
*/
|
|
75
|
+
spatialMinUpdateTime: number;
|
|
76
|
+
/**
|
|
74
77
|
* Possible values are:
|
|
75
78
|
* - `"equalpower"`: Represents the equal-power panning algorithm, generally regarded as simple and efficient.
|
|
76
|
-
* - `"HRTF"`:Renders a stereo output of higher quality than `"equalpower"` — it uses a convolution with measured impulse responses from human subjects.
|
|
79
|
+
* - `"HRTF"`: Renders a stereo output of higher quality than `"equalpower"` — it uses a convolution with measured impulse responses from human subjects.
|
|
77
80
|
*/
|
|
78
81
|
spatialPanningModel: "equalpower" | "HRTF";
|
|
79
82
|
/**
|
|
@@ -140,16 +143,23 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
140
143
|
* @see {@link spatialRolloffFactor}
|
|
141
144
|
*/
|
|
142
145
|
abstract distanceModel: "linear" | "inverse" | "exponential";
|
|
146
|
+
/**
|
|
147
|
+
* Whether the audio source is attached to a mesh or transform node.
|
|
148
|
+
*/
|
|
149
|
+
abstract isAttached: boolean;
|
|
143
150
|
/**
|
|
144
151
|
* The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.
|
|
145
152
|
* - This value is used only when the {@link distanceModel} is set to `"linear"`.
|
|
146
153
|
* @see {@link distanceModel}
|
|
147
154
|
*/
|
|
148
155
|
abstract maxDistance: number;
|
|
156
|
+
/**
|
|
157
|
+
* The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to `0`.
|
|
158
|
+
* - The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
|
|
159
|
+
*/
|
|
160
|
+
abstract minUpdateTime: number;
|
|
149
161
|
/**
|
|
150
162
|
* The spatial panning model. Defaults to "equalpower".
|
|
151
|
-
* - "equalpower" requires less CPU than "HRTF" but is less realistic for listeners with headphones or speakers close to the ears.
|
|
152
|
-
* - "HRTF" requires more CPU but is more realistic for listeners with headphones or speakers close to the ears.
|
|
153
163
|
*
|
|
154
164
|
* Possible values are:
|
|
155
165
|
* - `"equalpower"`: Represents the equal-power panning algorithm, generally regarded as simple and efficient.
|
|
@@ -181,7 +191,18 @@ export declare abstract class AbstractSpatialAudio {
|
|
|
181
191
|
*/
|
|
182
192
|
abstract rotationQuaternion: Quaternion;
|
|
183
193
|
/**
|
|
184
|
-
*
|
|
194
|
+
* Attaches the audio source to a scene object.
|
|
195
|
+
* @param sceneNode The scene node to attach the audio source to.
|
|
196
|
+
* @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
|
|
197
|
+
* @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
198
|
+
*/
|
|
199
|
+
abstract attach(sceneNode: Node, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;
|
|
200
|
+
/**
|
|
201
|
+
* Detaches the audio source from the currently attached graphics node.
|
|
202
|
+
*/
|
|
203
|
+
abstract detach(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Updates the position and rotation in the audio engine to the current values.
|
|
185
206
|
*/
|
|
186
207
|
abstract update(): void;
|
|
187
208
|
}
|
|
@@ -24,6 +24,7 @@ export function _HasSpatialAudioOptions(options) {
|
|
|
24
24
|
options.spatialConeOuterVolume !== undefined ||
|
|
25
25
|
options.spatialDistanceModel !== undefined ||
|
|
26
26
|
options.spatialMaxDistance !== undefined ||
|
|
27
|
+
options.spatialMinUpdateTime !== undefined ||
|
|
27
28
|
options.spatialPanningModel !== undefined ||
|
|
28
29
|
options.spatialPosition !== undefined ||
|
|
29
30
|
options.spatialReferenceDistance !== undefined ||
|
|
@@ -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;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,cAAc,EAAE,aAAuB;IACvC,cAAc,EAAE,aAAuB;IACvC,eAAe,EAAE,CAAW;IAC5B,aAAa,EAAE,SAA8B;IAC7C,WAAW,EAAE,KAAe;IAC5B,YAAY,EAAE,YAAgC;IAC9C,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,iBAAiB,EAAE,CAAW;IAC9B,aAAa,EAAE,CAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,kBAAkB,EAAE,IAAI,UAAU,EAAE;CAC9B,CAAC;AA4FX;;;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,mBAAmB,KAAK,SAAS;QACzC,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,wBAAwB,KAAK,SAAS;QAC9C,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;CAoFzC","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\n\nexport const _SpatialAudioDefaults = {\n coneInnerAngle: 6.28318530718 as number,\n coneOuterAngle: 6.28318530718 as number,\n coneOuterVolume: 0 as number,\n distanceModel: \"inverse\" as DistanceModelType,\n maxDistance: 10000 as number,\n panningModel: \"equalpower\" as PanningModelType,\n position: Vector3.Zero(),\n referenceDistance: 1 as number,\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 spatialReferenceDistance}\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 spatial panning model. Defaults to \"equalpower\".\n * - \"equalpower\" requires less CPU than \"HRTF\" but is less realistic for listeners with headphones or speakers close to the ears.\n * - \"HRTF\" requires more CPU but is more realistic for listeners with headphones or speakers close to the ears.\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 spatialReferenceDistance: 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.spatialPanningModel !== undefined ||\n options.spatialPosition !== undefined ||\n options.spatialReferenceDistance !== 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 spatialReferenceDistance}\n * @see {@link spatialRolloffFactor}\n */\n public abstract distanceModel: \"linear\" | \"inverse\" | \"exponential\";\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 spatial panning model. Defaults to \"equalpower\".\n * - \"equalpower\" requires less CPU than \"HRTF\" but is less realistic for listeners with headphones or speakers close to the ears.\n * - \"HRTF\" requires more CPU but is more realistic for listeners with headphones or speakers close to the ears.\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 * 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 referenceDistance: number;\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. Defaults to (0, 0, 0).\n */\n public abstract rotation: Vector3;\n\n /**\n * The spatial rotation quaternion. Defaults to (0, 0, 0, 1).\n */\n public abstract rotationQuaternion: Quaternion;\n\n /**\n * Updates the position and rotation properties.\n */\n public abstract update(): 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;AAIjE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,cAAc,EAAE,aAAuB;IACvC,cAAc,EAAE,aAAuB;IACvC,eAAe,EAAE,CAAW;IAC5B,aAAa,EAAE,SAA8B;IAC7C,WAAW,EAAE,KAAe;IAC5B,YAAY,EAAE,YAAgC;IAC9C,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,iBAAiB,EAAE,CAAW;IAC9B,aAAa,EAAE,CAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,kBAAkB,EAAE,IAAI,UAAU,EAAE;CAC9B,CAAC;AA6FX;;;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,oBAAoB,KAAK,SAAS;QAC1C,OAAO,CAAC,mBAAmB,KAAK,SAAS;QACzC,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,wBAAwB,KAAK,SAAS;QAC9C,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;CAyGzC","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport type { Node } from \"../../../node\";\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: \"inverse\" as DistanceModelType,\n maxDistance: 10000 as number,\n panningModel: \"equalpower\" as PanningModelType,\n position: Vector3.Zero(),\n referenceDistance: 1 as number,\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 spatialReferenceDistance}\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 * 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 spatialReferenceDistance: 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.spatialMinUpdateTime !== undefined ||\n options.spatialPanningModel !== undefined ||\n options.spatialPosition !== undefined ||\n options.spatialReferenceDistance !== 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 spatialReferenceDistance}\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 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 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 * 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 referenceDistance: number;\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. Defaults to (0, 0, 0).\n */\n public abstract rotation: Vector3;\n\n /**\n * The spatial rotation quaternion. Defaults to (0, 0, 0, 1).\n */\n public abstract rotationQuaternion: Quaternion;\n\n /**\n * Attaches the audio source to a scene object.\n * @param sceneNode The scene node to attach the audio source to.\n * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.\n * @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public abstract attach(sceneNode: Node, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;\n\n /**\n * Detaches the audio source from the currently attached graphics node.\n */\n public abstract detach(): void;\n /**\n * Updates the position and rotation in the audio engine to the current values.\n */\n public abstract update(): void;\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../../../Maths/math.vector";
|
|
2
|
+
import type { Node } from "../../../node";
|
|
3
|
+
import type { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
|
|
2
4
|
export declare const _SpatialAudioListenerDefaults: {
|
|
3
5
|
readonly position: Vector3;
|
|
4
6
|
readonly rotation: Vector3;
|
|
@@ -16,6 +18,11 @@ export interface ISpatialAudioListenerOptions {
|
|
|
16
18
|
* Set to `true` to enable the listener. Defaults to `false`.
|
|
17
19
|
*/
|
|
18
20
|
listenerEnabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The minimum update time in seconds of the listener if it is attached to a mesh, scene or transform node. Defaults to `0`.
|
|
23
|
+
* - The listener's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
|
|
24
|
+
*/
|
|
25
|
+
listenerMinUpdateTime: number;
|
|
19
26
|
/**
|
|
20
27
|
* The listener position. Defaults to (0, 0, 0).
|
|
21
28
|
*/
|
|
@@ -40,6 +47,15 @@ export declare function _HasSpatialAudioListenerOptions(options: Partial<ISpatia
|
|
|
40
47
|
* @see {@link AudioEngineV2.listener}
|
|
41
48
|
*/
|
|
42
49
|
export declare abstract class AbstractSpatialAudioListener {
|
|
50
|
+
/**
|
|
51
|
+
* Whether the listener is attached to a camera, mesh or transform node.
|
|
52
|
+
*/
|
|
53
|
+
abstract isAttached: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The minimum update time in seconds of the listener if it is attached to a mesh, scene or transform node. Defaults to `0`.
|
|
56
|
+
* - The listener's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
|
|
57
|
+
*/
|
|
58
|
+
abstract minUpdateTime: number;
|
|
43
59
|
/**
|
|
44
60
|
* The listener position. Defaults to (0, 0, 0).
|
|
45
61
|
*/
|
|
@@ -53,7 +69,18 @@ export declare abstract class AbstractSpatialAudioListener {
|
|
|
53
69
|
*/
|
|
54
70
|
abstract rotationQuaternion: Quaternion;
|
|
55
71
|
/**
|
|
56
|
-
*
|
|
72
|
+
* Attaches the audio source to a scene object.
|
|
73
|
+
* @param sceneNode The scene node to attach the audio source to.
|
|
74
|
+
* @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
|
|
75
|
+
* @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
76
|
+
*/
|
|
77
|
+
abstract attach(sceneNode: Node, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;
|
|
78
|
+
/**
|
|
79
|
+
* Detaches the audio source from the currently attached graphics node.
|
|
80
|
+
*/
|
|
81
|
+
abstract detach(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Updates the position and rotation in the audio engine to the current values.
|
|
57
84
|
*/
|
|
58
85
|
abstract update(): void;
|
|
59
86
|
}
|
|
@@ -9,7 +9,11 @@ export const _SpatialAudioListenerDefaults = {
|
|
|
9
9
|
* @returns `true` if spatial audio listener options are defined, otherwise `false`.
|
|
10
10
|
*/
|
|
11
11
|
export function _HasSpatialAudioListenerOptions(options) {
|
|
12
|
-
return options.
|
|
12
|
+
return (options.listenerEnabled ||
|
|
13
|
+
options.listenerMinUpdateTime !== undefined ||
|
|
14
|
+
options.listenerPosition !== undefined ||
|
|
15
|
+
options.listenerRotation !== undefined ||
|
|
16
|
+
options.listenerRotationQuaternion !== undefined);
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* Abstract class representing the spatial audio `listener` property on an audio engine.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractSpatialAudioListener.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"abstractSpatialAudioListener.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAIjE,MAAM,CAAC,MAAM,6BAA6B,GAAG;IACzC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE;IACxB,kBAAkB,EAAE,IAAI,UAAU,EAAE;CAC9B,CAAC;AAiCX;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAAC,OAA8C;IAC1F,OAAO,CACH,OAAO,CAAC,eAAe;QACvB,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAC3C,OAAO,CAAC,gBAAgB,KAAK,SAAS;QACtC,OAAO,CAAC,gBAAgB,KAAK,SAAS;QACtC,OAAO,CAAC,0BAA0B,KAAK,SAAS,CACnD,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAgB,4BAA4B;CA4CjD","sourcesContent":["import { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport type { Node } from \"../../../node\";\nimport type { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\n\nexport const _SpatialAudioListenerDefaults = {\n position: Vector3.Zero(),\n rotation: Vector3.Zero(),\n rotationQuaternion: new Quaternion(),\n} as const;\n\n/**\n * Options for spatial audio.\n */\nexport interface ISpatialAudioListenerOptions {\n /**\n * Whether to automatically update the position and rotation of the listener. Defaults to `true`.\n */\n listenerAutoUpdate: boolean;\n /**\n * Set to `true` to enable the listener. Defaults to `false`.\n */\n listenerEnabled: boolean;\n /**\n * The minimum update time in seconds of the listener if it is attached to a mesh, scene or transform node. Defaults to `0`.\n * - The listener's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.\n */\n listenerMinUpdateTime: number;\n /**\n * The listener position. Defaults to (0, 0, 0).\n */\n listenerPosition: Vector3;\n /**\n * The listener rotation, as Euler angles. Defaults to (0, 0, 0).\n */\n listenerRotation: Vector3;\n /**\n * The listener rotation, as a quaternion. Defaults to (0, 0, 0, 1).\n */\n listenerRotationQuaternion: Quaternion;\n}\n\n/**\n * @param options The spatial audio listener options to check.\n * @returns `true` if spatial audio listener options are defined, otherwise `false`.\n */\nexport function _HasSpatialAudioListenerOptions(options: Partial<ISpatialAudioListenerOptions>): boolean {\n return (\n options.listenerEnabled ||\n options.listenerMinUpdateTime !== undefined ||\n options.listenerPosition !== undefined ||\n options.listenerRotation !== undefined ||\n options.listenerRotationQuaternion !== undefined\n );\n}\n\n/**\n * Abstract class representing the spatial audio `listener` property on an audio engine.\n *\n * @see {@link AudioEngineV2.listener}\n */\nexport abstract class AbstractSpatialAudioListener {\n /**\n * Whether the listener is attached to a camera, mesh or transform node.\n */\n public abstract isAttached: boolean;\n\n /**\n * The minimum update time in seconds of the listener if it is attached to a mesh, scene or transform node. Defaults to `0`.\n * - The listener'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 listener position. Defaults to (0, 0, 0).\n */\n public abstract position: Vector3;\n\n /**\n * The listener rotation, as Euler angles. Defaults to (0, 0, 0).\n */\n public abstract rotation: Vector3;\n\n /**\n * The listener rotation, as a quaternion. Defaults to (0, 0, 0, 1).\n */\n public abstract rotationQuaternion: Quaternion;\n\n /**\n * Attaches the audio source to a scene object.\n * @param sceneNode The scene node to attach the audio source to.\n * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.\n * @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public abstract attach(sceneNode: Node, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;\n\n /**\n * Detaches the audio source from the currently attached graphics node.\n */\n public abstract detach(): void;\n\n /**\n * Updates the position and rotation in the audio engine to the current values.\n */\n public abstract update(): void;\n}\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Quaternion, Vector3 } from "../../../Maths/math.vector";
|
|
2
|
+
import type { Node } from "../../../node";
|
|
3
|
+
import { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
|
|
2
4
|
import type { _AbstractAudioSubGraph } from "../subNodes/abstractAudioSubGraph";
|
|
3
5
|
import { AbstractSpatialAudio } from "./abstractSpatialAudio";
|
|
4
6
|
/** @internal */
|
|
5
|
-
export declare class _SpatialAudio extends AbstractSpatialAudio {
|
|
7
|
+
export declare abstract class _SpatialAudio extends AbstractSpatialAudio {
|
|
6
8
|
private _position;
|
|
7
9
|
private _rotation;
|
|
8
10
|
private _rotationQuaternion;
|
|
@@ -22,6 +24,8 @@ export declare class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
22
24
|
get distanceModel(): DistanceModelType;
|
|
23
25
|
set distanceModel(value: DistanceModelType);
|
|
24
26
|
/** @internal */
|
|
27
|
+
get isAttached(): boolean;
|
|
28
|
+
/** @internal */
|
|
25
29
|
get maxDistance(): number;
|
|
26
30
|
set maxDistance(value: number);
|
|
27
31
|
/** @internal */
|
|
@@ -42,6 +46,17 @@ export declare class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
42
46
|
/** @internal */
|
|
43
47
|
get rotationQuaternion(): Quaternion;
|
|
44
48
|
set rotationQuaternion(value: Quaternion);
|
|
49
|
+
/**
|
|
50
|
+
* Attaches the audio source to a scene object.
|
|
51
|
+
* @param sceneNode The scene node to attach the audio source to.
|
|
52
|
+
* @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
|
|
53
|
+
* @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
54
|
+
*/
|
|
55
|
+
attach(sceneNode: Node, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;
|
|
56
|
+
/**
|
|
57
|
+
* Detaches the audio source from the currently attached graphics node.
|
|
58
|
+
*/
|
|
59
|
+
detach(): void;
|
|
45
60
|
/** @internal */
|
|
46
61
|
update(): void;
|
|
47
62
|
private _updatePosition;
|
|
@@ -5,9 +5,13 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
5
5
|
/** @internal */
|
|
6
6
|
constructor(subGraph) {
|
|
7
7
|
super();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const subNode = _GetSpatialAudioSubNode(subGraph);
|
|
9
|
+
if (!subNode) {
|
|
10
|
+
throw new Error("Sub node not found");
|
|
11
|
+
}
|
|
12
|
+
this._position = subNode.position.clone();
|
|
13
|
+
this._rotation = subNode.rotation.clone();
|
|
14
|
+
this._rotationQuaternion = subNode.rotationQuaternion.clone();
|
|
11
15
|
this._subGraph = subGraph;
|
|
12
16
|
}
|
|
13
17
|
/** @internal */
|
|
@@ -19,26 +23,30 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
19
23
|
}
|
|
20
24
|
/** @internal */
|
|
21
25
|
get coneOuterAngle() {
|
|
22
|
-
return _GetSpatialAudioProperty(this._subGraph, "coneOuterAngle")
|
|
26
|
+
return _GetSpatialAudioProperty(this._subGraph, "coneOuterAngle");
|
|
23
27
|
}
|
|
24
28
|
set coneOuterAngle(value) {
|
|
25
29
|
_SetSpatialAudioProperty(this._subGraph, "coneOuterAngle", value);
|
|
26
30
|
}
|
|
27
31
|
/** @internal */
|
|
28
32
|
get coneOuterVolume() {
|
|
29
|
-
return _GetSpatialAudioProperty(this._subGraph, "coneOuterVolume")
|
|
33
|
+
return _GetSpatialAudioProperty(this._subGraph, "coneOuterVolume");
|
|
30
34
|
}
|
|
31
35
|
set coneOuterVolume(value) {
|
|
32
36
|
_SetSpatialAudioProperty(this._subGraph, "coneOuterVolume", value);
|
|
33
37
|
}
|
|
34
38
|
/** @internal */
|
|
35
39
|
get distanceModel() {
|
|
36
|
-
return _GetSpatialAudioProperty(this._subGraph, "distanceModel")
|
|
40
|
+
return _GetSpatialAudioProperty(this._subGraph, "distanceModel");
|
|
37
41
|
}
|
|
38
42
|
set distanceModel(value) {
|
|
39
43
|
_SetSpatialAudioProperty(this._subGraph, "distanceModel", value);
|
|
40
44
|
}
|
|
41
45
|
/** @internal */
|
|
46
|
+
get isAttached() {
|
|
47
|
+
return this._subGraph.getSubNode("Spatial" /* AudioSubNode.SPATIAL */)?.isAttached ?? false;
|
|
48
|
+
}
|
|
49
|
+
/** @internal */
|
|
42
50
|
get maxDistance() {
|
|
43
51
|
return _GetSpatialAudioProperty(this._subGraph, "maxDistance") ?? _SpatialAudioDefaults.maxDistance;
|
|
44
52
|
}
|
|
@@ -50,7 +58,7 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
50
58
|
}
|
|
51
59
|
/** @internal */
|
|
52
60
|
get panningModel() {
|
|
53
|
-
return _GetSpatialAudioProperty(this._subGraph, "panningModel")
|
|
61
|
+
return _GetSpatialAudioProperty(this._subGraph, "panningModel");
|
|
54
62
|
}
|
|
55
63
|
set panningModel(value) {
|
|
56
64
|
_SetSpatialAudioProperty(this._subGraph, "panningModel", value);
|
|
@@ -65,14 +73,14 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
65
73
|
}
|
|
66
74
|
/** @internal */
|
|
67
75
|
get referenceDistance() {
|
|
68
|
-
return _GetSpatialAudioProperty(this._subGraph, "referenceDistance")
|
|
76
|
+
return _GetSpatialAudioProperty(this._subGraph, "referenceDistance");
|
|
69
77
|
}
|
|
70
78
|
set referenceDistance(value) {
|
|
71
79
|
_SetSpatialAudioProperty(this._subGraph, "referenceDistance", value);
|
|
72
80
|
}
|
|
73
81
|
/** @internal */
|
|
74
82
|
get rolloffFactor() {
|
|
75
|
-
return _GetSpatialAudioProperty(this._subGraph, "rolloffFactor")
|
|
83
|
+
return _GetSpatialAudioProperty(this._subGraph, "rolloffFactor");
|
|
76
84
|
}
|
|
77
85
|
set rolloffFactor(value) {
|
|
78
86
|
_SetSpatialAudioProperty(this._subGraph, "rolloffFactor", value);
|
|
@@ -93,11 +101,34 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
93
101
|
this._rotationQuaternion = value;
|
|
94
102
|
this._updateRotation();
|
|
95
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Attaches the audio source to a scene object.
|
|
106
|
+
* @param sceneNode The scene node to attach the audio source to.
|
|
107
|
+
* @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
|
|
108
|
+
* @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
109
|
+
*/
|
|
110
|
+
attach(sceneNode, useBoundingBox = false, attachmentType = 3 /* SpatialAudioAttachmentType.PositionAndRotation */) {
|
|
111
|
+
_GetSpatialAudioSubNode(this._subGraph)?.attach(sceneNode, useBoundingBox, attachmentType);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Detaches the audio source from the currently attached graphics node.
|
|
115
|
+
*/
|
|
116
|
+
detach() {
|
|
117
|
+
_GetSpatialAudioSubNode(this._subGraph)?.detach();
|
|
118
|
+
}
|
|
96
119
|
/** @internal */
|
|
97
120
|
update() {
|
|
98
121
|
const subNode = _GetSpatialAudioSubNode(this._subGraph);
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
if (!subNode) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (subNode.isAttached) {
|
|
126
|
+
subNode.update();
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this._updatePosition(subNode);
|
|
130
|
+
this._updateRotation(subNode);
|
|
131
|
+
}
|
|
101
132
|
}
|
|
102
133
|
_updatePosition(subNode = null) {
|
|
103
134
|
if (!subNode) {
|
|
@@ -108,7 +139,8 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
108
139
|
}
|
|
109
140
|
const position = subNode.position;
|
|
110
141
|
if (!position.equalsWithEpsilon(this._position)) {
|
|
111
|
-
subNode.position
|
|
142
|
+
subNode.position.copyFrom(this._position);
|
|
143
|
+
subNode.updatePosition();
|
|
112
144
|
}
|
|
113
145
|
}
|
|
114
146
|
_updateRotation(subNode = null) {
|
|
@@ -119,10 +151,12 @@ export class _SpatialAudio extends AbstractSpatialAudio {
|
|
|
119
151
|
}
|
|
120
152
|
}
|
|
121
153
|
if (!subNode.rotationQuaternion.equalsWithEpsilon(this._rotationQuaternion)) {
|
|
122
|
-
subNode.rotationQuaternion
|
|
154
|
+
subNode.rotationQuaternion.copyFrom(this._rotationQuaternion);
|
|
155
|
+
subNode.updateRotation();
|
|
123
156
|
}
|
|
124
157
|
else if (!subNode.rotation.equalsWithEpsilon(this._rotation)) {
|
|
125
|
-
subNode.rotation
|
|
158
|
+
subNode.rotation.copyFrom(this._rotation);
|
|
159
|
+
subNode.updateRotation();
|
|
126
160
|
}
|
|
127
161
|
}
|
|
128
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialAudio.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/spatialAudio.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,wBAAwB,EAA6B,MAAM,iCAAiC,CAAC;AACzJ,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAErF,gBAAgB;AAChB,MAAM,OAAO,aAAc,SAAQ,oBAAoB;IAMnD,gBAAgB;IAChB,YAAmB,QAAgC;QAC/C,KAAK,EAAE,CAAC;QAPJ,cAAS,GAAY,qBAAqB,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC5D,cAAS,GAAY,qBAAqB,CAAC,QAAQ,CAAC,KAAK,EAAE,CA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;QACL,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC1E,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QAC1D,CAAC;aAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QACtC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport type { Nullable } from \"../../../types\";\nimport type { _AbstractAudioSubGraph } from \"../subNodes/abstractAudioSubGraph\";\nimport { _GetSpatialAudioProperty, _GetSpatialAudioSubNode, _SetSpatialAudioProperty, type _SpatialAudioSubNode } from \"../subNodes/spatialAudioSubNode\";\nimport { _SpatialAudioDefaults, AbstractSpatialAudio } from \"./abstractSpatialAudio\";\n\n/** @internal */\nexport class _SpatialAudio extends AbstractSpatialAudio {\n private _position: Vector3 = _SpatialAudioDefaults.position.clone();\n private _rotation: Vector3 = _SpatialAudioDefaults.rotation.clone();\n private _rotationQuaternion: Quaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\n private _subGraph: _AbstractAudioSubGraph;\n\n /** @internal */\n public constructor(subGraph: _AbstractAudioSubGraph) {\n super();\n this._subGraph = subGraph;\n }\n\n /** @internal */\n public get coneInnerAngle(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"coneInnerAngle\") ?? _SpatialAudioDefaults.coneInnerAngle;\n }\n\n public set coneInnerAngle(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"coneInnerAngle\", value);\n }\n\n /** @internal */\n public get coneOuterAngle(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"coneOuterAngle\") ?? _SpatialAudioDefaults.coneOuterAngle;\n }\n\n public set coneOuterAngle(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"coneOuterAngle\", value);\n }\n\n /** @internal */\n public get coneOuterVolume(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"coneOuterVolume\") ?? _SpatialAudioDefaults.coneOuterVolume;\n }\n\n public set coneOuterVolume(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"coneOuterVolume\", value);\n }\n\n /** @internal */\n public get distanceModel(): DistanceModelType {\n return _GetSpatialAudioProperty(this._subGraph, \"distanceModel\") ?? _SpatialAudioDefaults.distanceModel;\n }\n\n public set distanceModel(value: DistanceModelType) {\n _SetSpatialAudioProperty(this._subGraph, \"distanceModel\", value);\n }\n\n /** @internal */\n public get maxDistance(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"maxDistance\") ?? _SpatialAudioDefaults.maxDistance;\n }\n\n public set maxDistance(value: number) {\n if (value <= 0) {\n value = 0.000001;\n }\n\n _SetSpatialAudioProperty(this._subGraph, \"maxDistance\", value);\n }\n\n /** @internal */\n public get panningModel(): PanningModelType {\n return _GetSpatialAudioProperty(this._subGraph, \"panningModel\") ?? _SpatialAudioDefaults.panningModel;\n }\n\n public set panningModel(value: PanningModelType) {\n _SetSpatialAudioProperty(this._subGraph, \"panningModel\", value);\n }\n\n /** @internal */\n public get position(): Vector3 {\n return this._position;\n }\n\n public set position(value: Vector3) {\n this._position = value;\n this._updatePosition();\n }\n\n /** @internal */\n public get referenceDistance(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"referenceDistance\") ?? _SpatialAudioDefaults.referenceDistance;\n }\n\n public set referenceDistance(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"referenceDistance\", value);\n }\n\n /** @internal */\n public get rolloffFactor(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"rolloffFactor\") ?? _SpatialAudioDefaults.rolloffFactor;\n }\n\n public set rolloffFactor(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"rolloffFactor\", value);\n }\n\n /** @internal */\n public get rotation(): Vector3 {\n return this._rotation;\n }\n\n public set rotation(value: Vector3) {\n this._rotation = value;\n this._updateRotation();\n }\n\n /** @internal */\n public get rotationQuaternion(): Quaternion {\n return this._rotationQuaternion;\n }\n\n public set rotationQuaternion(value: Quaternion) {\n this._rotationQuaternion = value;\n this._updateRotation();\n }\n\n /** @internal */\n public update(): void {\n const subNode = _GetSpatialAudioSubNode(this._subGraph);\n\n this._updatePosition(subNode);\n this._updateRotation(subNode);\n }\n\n private _updatePosition(subNode: Nullable<_SpatialAudioSubNode> = null): void {\n if (!subNode) {\n subNode = _GetSpatialAudioSubNode(this._subGraph);\n\n if (!subNode) {\n return;\n }\n }\n\n const position = subNode.position;\n if (!position.equalsWithEpsilon(this._position)) {\n subNode.position = this._position;\n }\n }\n\n private _updateRotation(subNode: Nullable<_SpatialAudioSubNode> = null): void {\n if (!subNode) {\n subNode = _GetSpatialAudioSubNode(this._subGraph);\n\n if (!subNode) {\n return;\n }\n }\n\n if (!subNode.rotationQuaternion.equalsWithEpsilon(this._rotationQuaternion)) {\n subNode.rotationQuaternion = this._rotationQuaternion;\n } else if (!subNode.rotation.equalsWithEpsilon(this._rotation)) {\n subNode.rotation = this._rotation;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"spatialAudio.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/spatialAudio.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC9H,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAErF,gBAAgB;AAChB,MAAM,OAAgB,aAAc,SAAQ,oBAAoB;IAM5D,gBAAgB;IAChB,YAAmB,QAAgC;QAC/C,KAAK,EAAE,CAAC;QAER,MAAM,OAAO,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,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C;IACL,CAAC;IAEO,eAAe,CAAC,UAA0C,IAAI;QAClE,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAElD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO;YACX,CAAC;QACL,CAAC;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7B,CAAC;IACL,CAAC;IAEO,eAAe,CAAC,UAA0C,IAAI;QAClE,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAElD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO;YACX,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC1E,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAC9D,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7B,CAAC;aAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Quaternion, Vector3 } from \"../../../Maths/math.vector\";\nimport type { Node } from \"../../../node\";\nimport type { Nullable } from \"../../../types\";\nimport { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\nimport type { _AbstractAudioSubGraph } from \"../subNodes/abstractAudioSubGraph\";\nimport { AudioSubNode } from \"../subNodes/audioSubNode\";\nimport type { _SpatialAudioSubNode } from \"../subNodes/spatialAudioSubNode\";\nimport { _GetSpatialAudioProperty, _GetSpatialAudioSubNode, _SetSpatialAudioProperty } from \"../subNodes/spatialAudioSubNode\";\nimport { _SpatialAudioDefaults, AbstractSpatialAudio } from \"./abstractSpatialAudio\";\n\n/** @internal */\nexport abstract class _SpatialAudio extends AbstractSpatialAudio {\n private _position: Vector3;\n private _rotation: Vector3;\n private _rotationQuaternion: Quaternion;\n private _subGraph: _AbstractAudioSubGraph;\n\n /** @internal */\n public constructor(subGraph: _AbstractAudioSubGraph) {\n super();\n\n const subNode = _GetSpatialAudioSubNode(subGraph);\n if (!subNode) {\n throw new Error(\"Sub node not found\");\n }\n\n this._position = subNode.position.clone();\n this._rotation = subNode.rotation.clone();\n this._rotationQuaternion = subNode.rotationQuaternion.clone();\n\n this._subGraph = subGraph;\n }\n\n /** @internal */\n public get coneInnerAngle(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"coneInnerAngle\") ?? _SpatialAudioDefaults.coneInnerAngle;\n }\n\n public set coneInnerAngle(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"coneInnerAngle\", value);\n }\n\n /** @internal */\n public get coneOuterAngle(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"coneOuterAngle\");\n }\n\n public set coneOuterAngle(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"coneOuterAngle\", value);\n }\n\n /** @internal */\n public get coneOuterVolume(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"coneOuterVolume\");\n }\n\n public set coneOuterVolume(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"coneOuterVolume\", value);\n }\n\n /** @internal */\n public get distanceModel(): DistanceModelType {\n return _GetSpatialAudioProperty(this._subGraph, \"distanceModel\");\n }\n\n public set distanceModel(value: DistanceModelType) {\n _SetSpatialAudioProperty(this._subGraph, \"distanceModel\", value);\n }\n\n /** @internal */\n public get isAttached(): boolean {\n return this._subGraph.getSubNode<_SpatialAudioSubNode>(AudioSubNode.SPATIAL)?.isAttached ?? false;\n }\n\n /** @internal */\n public get maxDistance(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"maxDistance\") ?? _SpatialAudioDefaults.maxDistance;\n }\n\n public set maxDistance(value: number) {\n if (value <= 0) {\n value = 0.000001;\n }\n\n _SetSpatialAudioProperty(this._subGraph, \"maxDistance\", value);\n }\n\n /** @internal */\n public get panningModel(): PanningModelType {\n return _GetSpatialAudioProperty(this._subGraph, \"panningModel\");\n }\n\n public set panningModel(value: PanningModelType) {\n _SetSpatialAudioProperty(this._subGraph, \"panningModel\", value);\n }\n\n /** @internal */\n public get position(): Vector3 {\n return this._position;\n }\n\n public set position(value: Vector3) {\n this._position = value;\n this._updatePosition();\n }\n\n /** @internal */\n public get referenceDistance(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"referenceDistance\");\n }\n\n public set referenceDistance(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"referenceDistance\", value);\n }\n\n /** @internal */\n public get rolloffFactor(): number {\n return _GetSpatialAudioProperty(this._subGraph, \"rolloffFactor\");\n }\n\n public set rolloffFactor(value: number) {\n _SetSpatialAudioProperty(this._subGraph, \"rolloffFactor\", value);\n }\n\n /** @internal */\n public get rotation(): Vector3 {\n return this._rotation;\n }\n\n public set rotation(value: Vector3) {\n this._rotation = value;\n this._updateRotation();\n }\n\n /** @internal */\n public get rotationQuaternion(): Quaternion {\n return this._rotationQuaternion;\n }\n\n public set rotationQuaternion(value: Quaternion) {\n this._rotationQuaternion = value;\n this._updateRotation();\n }\n\n /**\n * Attaches the audio source to a scene object.\n * @param sceneNode The scene node to attach the audio source to.\n * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.\n * @param attachmentType Whather to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.\n */\n public attach(sceneNode: Node, useBoundingBox: boolean = false, attachmentType: SpatialAudioAttachmentType = SpatialAudioAttachmentType.PositionAndRotation): void {\n _GetSpatialAudioSubNode(this._subGraph)?.attach(sceneNode, useBoundingBox, attachmentType);\n }\n\n /**\n * Detaches the audio source from the currently attached graphics node.\n */\n public detach(): void {\n _GetSpatialAudioSubNode(this._subGraph)?.detach();\n }\n\n /** @internal */\n public update(): void {\n const subNode = _GetSpatialAudioSubNode(this._subGraph);\n\n if (!subNode) {\n return;\n }\n\n if (subNode.isAttached) {\n subNode.update();\n } else {\n this._updatePosition(subNode);\n this._updateRotation(subNode);\n }\n }\n\n private _updatePosition(subNode: Nullable<_SpatialAudioSubNode> = null): void {\n if (!subNode) {\n subNode = _GetSpatialAudioSubNode(this._subGraph);\n\n if (!subNode) {\n return;\n }\n }\n\n const position = subNode.position;\n if (!position.equalsWithEpsilon(this._position)) {\n subNode.position.copyFrom(this._position);\n subNode.updatePosition();\n }\n }\n\n private _updateRotation(subNode: Nullable<_SpatialAudioSubNode> = null): void {\n if (!subNode) {\n subNode = _GetSpatialAudioSubNode(this._subGraph);\n\n if (!subNode) {\n return;\n }\n }\n\n if (!subNode.rotationQuaternion.equalsWithEpsilon(this._rotationQuaternion)) {\n subNode.rotationQuaternion.copyFrom(this._rotationQuaternion);\n subNode.updateRotation();\n } else if (!subNode.rotation.equalsWithEpsilon(this._rotation)) {\n subNode.rotation.copyFrom(this._rotation);\n subNode.updateRotation();\n }\n }\n}\n"]}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
import type { Node } from "../../../node";
|
|
2
|
+
import type { Nullable } from "../../../types";
|
|
3
|
+
import { SpatialAudioAttachmentType } from "../../spatialAudioAttachmentType";
|
|
4
|
+
import { _SpatialAudioAttacherComponent } from "../components/spatialAudioAttacherComponent";
|
|
1
5
|
import type { ISpatialAudioListenerOptions } from "./abstractSpatialAudioListener";
|
|
2
6
|
import { AbstractSpatialAudioListener } from "./abstractSpatialAudioListener";
|
|
3
7
|
/** @internal */
|
|
4
8
|
export declare abstract class _SpatialAudioListener extends AbstractSpatialAudioListener {
|
|
9
|
+
protected _attacherComponent: Nullable<_SpatialAudioAttacherComponent>;
|
|
10
|
+
protected constructor();
|
|
11
|
+
/** @internal */
|
|
12
|
+
get isAttached(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Attaches the audio source to a scene object.
|
|
15
|
+
* @param sceneNode The scene node to attach the audio source to.
|
|
16
|
+
* @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
|
|
17
|
+
* @param attachmentType Whether to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
|
|
18
|
+
*/
|
|
19
|
+
attach(sceneNode: Node, useBoundingBox?: boolean, attachmentType?: SpatialAudioAttachmentType): void;
|
|
20
|
+
/**
|
|
21
|
+
* Detaches the audio source from the currently attached camera, mesh or transform node.
|
|
22
|
+
*/
|
|
23
|
+
detach(): void;
|
|
5
24
|
/** @internal */
|
|
6
25
|
dispose(): void;
|
|
7
26
|
/** @internal */
|
|
8
27
|
setOptions(options: Partial<ISpatialAudioListenerOptions>): void;
|
|
28
|
+
abstract updatePosition(): void;
|
|
29
|
+
abstract updateRotation(): void;
|
|
9
30
|
}
|