@babylonjs/core 7.52.1 → 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.
Files changed (71) hide show
  1. package/AudioV2/abstractAudio/abstractSound.d.ts +1 -2
  2. package/AudioV2/abstractAudio/abstractSound.js +1 -5
  3. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  4. package/AudioV2/abstractAudio/audioBus.d.ts +1 -2
  5. package/AudioV2/abstractAudio/audioBus.js +1 -5
  6. package/AudioV2/abstractAudio/audioBus.js.map +1 -1
  7. package/AudioV2/abstractAudio/audioEngineV2.d.ts +1 -2
  8. package/AudioV2/abstractAudio/audioEngineV2.js +1 -5
  9. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  10. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +43 -0
  11. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +71 -0
  12. package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -0
  13. package/AudioV2/abstractAudio/staticSound.d.ts +1 -1
  14. package/AudioV2/abstractAudio/staticSound.js +2 -2
  15. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  16. package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
  17. package/AudioV2/abstractAudio/streamingSound.js +2 -2
  18. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  19. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +15 -0
  20. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +38 -3
  21. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
  22. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +29 -8
  23. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +1 -0
  24. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
  25. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +28 -1
  26. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +5 -1
  27. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
  28. package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +16 -1
  29. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +48 -14
  30. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  31. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +21 -0
  32. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +39 -4
  33. package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
  34. package/AudioV2/index.d.ts +1 -0
  35. package/AudioV2/index.js +1 -0
  36. package/AudioV2/index.js.map +1 -1
  37. package/AudioV2/spatialAudioAttachmentType.d.ts +5 -0
  38. package/AudioV2/spatialAudioAttachmentType.js +7 -0
  39. package/AudioV2/spatialAudioAttachmentType.js.map +1 -0
  40. package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.d.ts +13 -0
  41. package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js +38 -0
  42. package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js.map +1 -0
  43. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +13 -14
  44. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +39 -39
  45. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
  46. package/AudioV2/webAudio/subProperties/spatialWebAudio.d.ts +6 -2
  47. package/AudioV2/webAudio/subProperties/spatialWebAudio.js +13 -15
  48. package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
  49. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.d.ts +1 -1
  50. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +41 -56
  51. package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
  52. package/AudioV2/webAudio/webAudioBus.d.ts +3 -0
  53. package/AudioV2/webAudio/webAudioBus.js +23 -2
  54. package/AudioV2/webAudio/webAudioBus.js.map +1 -1
  55. package/AudioV2/webAudio/webAudioEngine.d.ts +3 -1
  56. package/AudioV2/webAudio/webAudioEngine.js +11 -3
  57. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  58. package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -0
  59. package/AudioV2/webAudio/webAudioStaticSound.js +23 -2
  60. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  61. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -0
  62. package/AudioV2/webAudio/webAudioStreamingSound.js +23 -2
  63. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  64. package/Engines/abstractEngine.js +2 -2
  65. package/Engines/abstractEngine.js.map +1 -1
  66. package/Meshes/geometry.js +14 -7
  67. package/Meshes/geometry.js.map +1 -1
  68. package/Meshes/mesh.vertexData.d.ts +1 -1
  69. package/Meshes/mesh.vertexData.js +2 -1
  70. package/Meshes/mesh.vertexData.js.map +1 -1
  71. package/package.json +1 -1
@@ -1,22 +1,57 @@
1
+ import { _SpatialAudioAttacherComponent } from "../components/spatialAudioAttacherComponent.js";
1
2
  import { _SpatialAudioListenerDefaults, AbstractSpatialAudioListener } from "./abstractSpatialAudioListener.js";
2
3
  /** @internal */
3
4
  export class _SpatialAudioListener extends AbstractSpatialAudioListener {
5
+ constructor() {
6
+ super();
7
+ this._attacherComponent = null;
8
+ this._attacherComponent = new _SpatialAudioAttacherComponent(this);
9
+ }
10
+ /** @internal */
11
+ get isAttached() {
12
+ return this._attacherComponent !== null && this._attacherComponent.isAttached;
13
+ }
14
+ /**
15
+ * Attaches the audio source to a scene object.
16
+ * @param sceneNode The scene node to attach the audio source to.
17
+ * @param useBoundingBox Whether to use the bounding box of the node for positioning. Defaults to `false`.
18
+ * @param attachmentType Whether to attach to the node's position and/or rotation. Defaults to `PositionAndRotation`.
19
+ */
20
+ attach(sceneNode, useBoundingBox = false, attachmentType = 3 /* SpatialAudioAttachmentType.PositionAndRotation */) {
21
+ if (!this._attacherComponent) {
22
+ this._attacherComponent = new _SpatialAudioAttacherComponent(this);
23
+ }
24
+ this._attacherComponent.attach(sceneNode, useBoundingBox, attachmentType);
25
+ }
26
+ /**
27
+ * Detaches the audio source from the currently attached camera, mesh or transform node.
28
+ */
29
+ detach() {
30
+ this._attacherComponent?.detach();
31
+ }
4
32
  /** @internal */
5
- dispose() { }
33
+ dispose() {
34
+ this._attacherComponent?.dispose();
35
+ this._attacherComponent = null;
36
+ }
6
37
  /** @internal */
7
38
  setOptions(options) {
8
- if (options.listenerPosition !== undefined) {
39
+ if (options.listenerMinUpdateTime !== undefined) {
40
+ this.minUpdateTime = options.listenerMinUpdateTime;
41
+ }
42
+ if (options.listenerPosition) {
9
43
  this.position = options.listenerPosition.clone();
10
44
  }
11
- if (options.listenerRotationQuaternion !== undefined) {
45
+ if (options.listenerRotationQuaternion) {
12
46
  this.rotationQuaternion = options.listenerRotationQuaternion.clone();
13
47
  }
14
- else if (options.listenerRotation !== undefined) {
48
+ else if (options.listenerRotation) {
15
49
  this.rotation = options.listenerRotation.clone();
16
50
  }
17
51
  else {
18
52
  this.rotationQuaternion = _SpatialAudioListenerDefaults.rotationQuaternion.clone();
19
53
  }
54
+ this.update();
20
55
  }
21
56
  }
22
57
  //# sourceMappingURL=spatialAudioListener.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spatialAudioListener.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/spatialAudioListener.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE7G,gBAAgB;AAChB,MAAM,OAAgB,qBAAsB,SAAQ,4BAA4B;IAC5E,gBAAgB;IACT,OAAO,KAAU,CAAC;IAEzB,gBAAgB;IACT,UAAU,CAAC,OAA8C;QAC5D,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACrD,CAAC;QAED,IAAI,OAAO,CAAC,0BAA0B,KAAK,SAAS,EAAE,CAAC;YACnD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;QACzE,CAAC;aAAM,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YAChD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACrD,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,kBAAkB,GAAG,6BAA6B,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACvF,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { ISpatialAudioListenerOptions } from \"./abstractSpatialAudioListener\";\nimport { _SpatialAudioListenerDefaults, AbstractSpatialAudioListener } from \"./abstractSpatialAudioListener\";\n\n/** @internal */\nexport abstract class _SpatialAudioListener extends AbstractSpatialAudioListener {\n /** @internal */\n public dispose(): void {}\n\n /** @internal */\n public setOptions(options: Partial<ISpatialAudioListenerOptions>): void {\n if (options.listenerPosition !== undefined) {\n this.position = options.listenerPosition.clone();\n }\n\n if (options.listenerRotationQuaternion !== undefined) {\n this.rotationQuaternion = options.listenerRotationQuaternion.clone();\n } else if (options.listenerRotation !== undefined) {\n this.rotation = options.listenerRotation.clone();\n } else {\n this.rotationQuaternion = _SpatialAudioListenerDefaults.rotationQuaternion.clone();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"spatialAudioListener.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subProperties/spatialAudioListener.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAE7F,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE7G,gBAA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C,0BAA0B,CAAC,KAAK,EAAE,CAAC;QACzE,CAAC;aAAM,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACrD,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,kBAAkB,GAAG,6BAA6B,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACvF,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;CAIJ","sourcesContent":["import type { Node } from \"../../../node\";\nimport type { Nullable } from \"../../../types\";\nimport { SpatialAudioAttachmentType } from \"../../spatialAudioAttachmentType\";\nimport { _SpatialAudioAttacherComponent } from \"../components/spatialAudioAttacherComponent\";\nimport type { ISpatialAudioListenerOptions } from \"./abstractSpatialAudioListener\";\nimport { _SpatialAudioListenerDefaults, AbstractSpatialAudioListener } from \"./abstractSpatialAudioListener\";\n\n/** @internal */\nexport abstract class _SpatialAudioListener extends AbstractSpatialAudioListener {\n protected _attacherComponent: Nullable<_SpatialAudioAttacherComponent> = null;\n\n protected constructor() {\n super();\n\n this._attacherComponent = new _SpatialAudioAttacherComponent(this);\n }\n\n /** @internal */\n public get isAttached(): boolean {\n return this._attacherComponent !== null && this._attacherComponent.isAttached;\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 Whether 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 if (!this._attacherComponent) {\n this._attacherComponent = new _SpatialAudioAttacherComponent(this);\n }\n this._attacherComponent.attach(sceneNode, useBoundingBox, attachmentType);\n }\n\n /**\n * Detaches the audio source from the currently attached camera, mesh or transform node.\n */\n public detach(): void {\n this._attacherComponent?.detach();\n }\n\n /** @internal */\n public dispose(): void {\n this._attacherComponent?.dispose();\n this._attacherComponent = null;\n }\n\n /** @internal */\n public setOptions(options: Partial<ISpatialAudioListenerOptions>): void {\n if (options.listenerMinUpdateTime !== undefined) {\n this.minUpdateTime = options.listenerMinUpdateTime;\n }\n\n if (options.listenerPosition) {\n this.position = options.listenerPosition.clone();\n }\n\n if (options.listenerRotationQuaternion) {\n this.rotationQuaternion = options.listenerRotationQuaternion.clone();\n } else if (options.listenerRotation) {\n this.rotation = options.listenerRotation.clone();\n } else {\n this.rotationQuaternion = _SpatialAudioListenerDefaults.rotationQuaternion.clone();\n }\n\n this.update();\n }\n\n public abstract updatePosition(): void;\n public abstract updateRotation(): void;\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  export * from "./abstractAudio/index";
2
2
  export * from "./soundState";
3
+ export * from "./spatialAudioAttachmentType";
3
4
  export * from "./webAudio/index";
package/AudioV2/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable import/no-internal-modules */
2
2
  export * from "./abstractAudio/index.js";
3
3
  export * from "./soundState.js";
4
+ export * from "./spatialAudioAttachmentType.js";
4
5
  export * from "./webAudio/index.js";
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\nexport * from \"./abstractAudio/index\";\nexport * from \"./soundState\";\nexport * from \"./webAudio/index\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\nexport * from \"./abstractAudio/index\";\nexport * from \"./soundState\";\nexport * from \"./spatialAudioAttachmentType\";\nexport * from \"./webAudio/index\";\n"]}
@@ -0,0 +1,5 @@
1
+ export declare enum SpatialAudioAttachmentType {
2
+ Position = 1,
3
+ Rotation = 2,
4
+ PositionAndRotation = 3
5
+ }
@@ -0,0 +1,7 @@
1
+ export var SpatialAudioAttachmentType;
2
+ (function (SpatialAudioAttachmentType) {
3
+ SpatialAudioAttachmentType[SpatialAudioAttachmentType["Position"] = 1] = "Position";
4
+ SpatialAudioAttachmentType[SpatialAudioAttachmentType["Rotation"] = 2] = "Rotation";
5
+ SpatialAudioAttachmentType[SpatialAudioAttachmentType["PositionAndRotation"] = 3] = "PositionAndRotation";
6
+ })(SpatialAudioAttachmentType || (SpatialAudioAttachmentType = {}));
7
+ //# sourceMappingURL=spatialAudioAttachmentType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatialAudioAttachmentType.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/spatialAudioAttachmentType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAkB,0BAIjB;AAJD,WAAkB,0BAA0B;IACxC,mFAAY,CAAA;IACZ,mFAAY,CAAA;IACZ,yGAAuB,CAAA;AAC3B,CAAC,EAJiB,0BAA0B,KAA1B,0BAA0B,QAI3C","sourcesContent":["export const enum SpatialAudioAttachmentType {\n Position = 1,\n Rotation = 2,\n PositionAndRotation = 3,\n}\n"]}
@@ -0,0 +1,13 @@
1
+ /** @internal */
2
+ export declare class _SpatialWebAudioUpdaterComponent {
3
+ private _autoUpdate;
4
+ private _lastUpdateTime;
5
+ /** @internal */
6
+ minUpdateTime: number;
7
+ /** @internal */
8
+ constructor(parent: {
9
+ update: () => void;
10
+ }, autoUpdate: boolean, minUpdateTime: number);
11
+ /** @internal */
12
+ dispose(): void;
13
+ }
@@ -0,0 +1,38 @@
1
+ import { PrecisionDate } from "../../../Misc/precisionDate.js";
2
+ /** @internal */
3
+ export class _SpatialWebAudioUpdaterComponent {
4
+ /** @internal */
5
+ constructor(parent, autoUpdate, minUpdateTime) {
6
+ this._autoUpdate = true;
7
+ this._lastUpdateTime = 0;
8
+ /** @internal */
9
+ this.minUpdateTime = 0;
10
+ if (!autoUpdate) {
11
+ return;
12
+ }
13
+ this.minUpdateTime = minUpdateTime;
14
+ const update = () => {
15
+ if (!this._autoUpdate) {
16
+ return;
17
+ }
18
+ let skipUpdate = false;
19
+ if (0 < this.minUpdateTime) {
20
+ const now = PrecisionDate.Now;
21
+ if (this._lastUpdateTime && now - this._lastUpdateTime < this.minUpdateTime) {
22
+ skipUpdate = true;
23
+ }
24
+ this._lastUpdateTime = now;
25
+ }
26
+ if (!skipUpdate) {
27
+ parent.update();
28
+ }
29
+ requestAnimationFrame(update);
30
+ };
31
+ requestAnimationFrame(update);
32
+ }
33
+ /** @internal */
34
+ dispose() {
35
+ this._autoUpdate = false;
36
+ }
37
+ }
38
+ //# sourceMappingURL=spatialWebAudioUpdaterComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatialWebAudioUpdaterComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,gBAAgB;AAChB,MAAM,OAAO,gCAAgC;IAOzC,gBAAgB;IAChB,YAAmB,MAA8B,EAAE,UAAmB,EAAE,aAAqB;QAPrF,gBAAW,GAAG,IAAI,CAAC;QACnB,oBAAe,GAAW,CAAC,CAAC;QAEpC,gBAAgB;QACT,kBAAa,GAAG,CAAC,CAAC;QAIrB,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,OAAO;QACX,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,MAAM,MAAM,GAAG,GAAG,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpB,OAAO;YACX,CAAC;YAED,IAAI,UAAU,GAAG,KAAK,CAAC;YAEvB,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;gBACzB,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;gBAC9B,IAAI,IAAI,CAAC,eAAe,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;oBAC1E,UAAU,GAAG,IAAI,CAAC;gBACtB,CAAC;gBACD,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;YAC/B,CAAC;YAED,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,MAAM,CAAC,MAAM,EAAE,CAAC;YACpB,CAAC;YAED,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC;QACF,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import { PrecisionDate } from \"../../../Misc/precisionDate\";\n\n/** @internal */\nexport class _SpatialWebAudioUpdaterComponent {\n private _autoUpdate = true;\n private _lastUpdateTime: number = 0;\n\n /** @internal */\n public minUpdateTime = 0;\n\n /** @internal */\n public constructor(parent: { update: () => void }, autoUpdate: boolean, minUpdateTime: number) {\n if (!autoUpdate) {\n return;\n }\n\n this.minUpdateTime = minUpdateTime;\n\n const update = () => {\n if (!this._autoUpdate) {\n return;\n }\n\n let skipUpdate = false;\n\n if (0 < this.minUpdateTime) {\n const now = PrecisionDate.Now;\n if (this._lastUpdateTime && now - this._lastUpdateTime < this.minUpdateTime) {\n skipUpdate = true;\n }\n this._lastUpdateTime = now;\n }\n\n if (!skipUpdate) {\n parent.update();\n }\n\n requestAnimationFrame(update);\n };\n requestAnimationFrame(update);\n }\n\n /** @internal */\n public dispose(): void {\n this._autoUpdate = false;\n }\n}\n"]}
@@ -6,10 +6,15 @@ import type { IWebAudioInNode } from "../webAudioNode";
6
6
  export declare function _CreateSpatialAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_SpatialAudioSubNode>;
7
7
  /** @internal */
8
8
  export declare class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
9
- private _position;
10
- private _rotation;
11
- private _rotationQuaternion;
12
- private _webAudioRotationQuaternion;
9
+ private _lastPosition;
10
+ private _lastRotation;
11
+ private _lastRotationQuaternion;
12
+ /** @internal */
13
+ readonly position: Vector3;
14
+ /** @internal */
15
+ readonly rotation: Vector3;
16
+ /** @internal */
17
+ readonly rotationQuaternion: Quaternion;
13
18
  /** @internal */
14
19
  readonly node: PannerNode;
15
20
  /** @internal */
@@ -33,27 +38,21 @@ export declare class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
33
38
  get panningModel(): "equalpower" | "HRTF";
34
39
  set panningModel(value: "equalpower" | "HRTF");
35
40
  /** @internal */
36
- get position(): Vector3;
37
- set position(value: Vector3);
38
- /** @internal */
39
41
  get referenceDistance(): number;
40
42
  set referenceDistance(value: number);
41
43
  /** @internal */
42
44
  get rolloffFactor(): number;
43
45
  set rolloffFactor(value: number);
44
46
  /** @internal */
45
- get rotation(): Vector3;
46
- set rotation(value: Vector3);
47
- /** @internal */
48
- get rotationQuaternion(): Quaternion;
49
- set rotationQuaternion(value: Quaternion);
50
- /** @internal */
51
47
  get inNode(): AudioNode;
52
48
  /** @internal */
53
49
  get outNode(): AudioNode;
50
+ /** @internal */
51
+ updatePosition(): void;
52
+ /** @internal */
53
+ updateRotation(): void;
54
54
  protected _connect(node: IWebAudioInNode): boolean;
55
55
  protected _disconnect(node: IWebAudioInNode): boolean;
56
56
  /** @internal */
57
57
  getClassName(): string;
58
- private _updateRotation;
59
58
  }
@@ -2,6 +2,7 @@ import { Matrix, Quaternion, Vector3 } from "../../../Maths/math.vector.js";
2
2
  import { _SpatialAudioSubNode } from "../../abstractAudio/subNodes/spatialAudioSubNode.js";
3
3
  import { _SpatialAudioDefaults } from "../../abstractAudio/subProperties/abstractSpatialAudio.js";
4
4
  const TmpMatrix = Matrix.Zero();
5
+ const TmpQuaternion = new Quaternion();
5
6
  const TmpVector = Vector3.Zero();
6
7
  function d2r(degrees) {
7
8
  return (degrees * Math.PI) / 180;
@@ -18,10 +19,15 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
18
19
  /** @internal */
19
20
  constructor(engine) {
20
21
  super(engine);
21
- this._position = _SpatialAudioDefaults.position.clone();
22
- this._rotation = _SpatialAudioDefaults.rotation.clone();
23
- this._rotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();
24
- this._webAudioRotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();
22
+ this._lastPosition = Vector3.Zero();
23
+ this._lastRotation = Vector3.Zero();
24
+ this._lastRotationQuaternion = new Quaternion();
25
+ /** @internal */
26
+ this.position = _SpatialAudioDefaults.position.clone();
27
+ /** @internal */
28
+ this.rotation = _SpatialAudioDefaults.rotation.clone();
29
+ /** @internal */
30
+ this.rotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();
25
31
  this.node = new PannerNode(engine.audioContext);
26
32
  }
27
33
  /** @internal */
@@ -71,16 +77,6 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
71
77
  this.node.panningModel = value;
72
78
  }
73
79
  /** @internal */
74
- get position() {
75
- return this._position;
76
- }
77
- set position(value) {
78
- this._position.copyFrom(value);
79
- this.node.positionX.value = value.x;
80
- this.node.positionY.value = value.y;
81
- this.node.positionZ.value = value.z;
82
- }
83
- /** @internal */
84
80
  get referenceDistance() {
85
81
  return this.node.refDistance;
86
82
  }
@@ -95,24 +91,6 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
95
91
  this.node.rolloffFactor = value;
96
92
  }
97
93
  /** @internal */
98
- get rotation() {
99
- return this._rotation;
100
- }
101
- set rotation(value) {
102
- this._rotation.copyFrom(value);
103
- Quaternion.FromEulerAnglesToRef(value.x, value.y, value.z, this._webAudioRotationQuaternion);
104
- this._updateRotation();
105
- }
106
- /** @internal */
107
- get rotationQuaternion() {
108
- return this._rotationQuaternion;
109
- }
110
- set rotationQuaternion(value) {
111
- this._rotationQuaternion.copyFrom(value);
112
- this._webAudioRotationQuaternion.copyFrom(value);
113
- this._updateRotation();
114
- }
115
- /** @internal */
116
94
  get inNode() {
117
95
  return this.node;
118
96
  }
@@ -120,6 +98,35 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
120
98
  get outNode() {
121
99
  return this.node;
122
100
  }
101
+ /** @internal */
102
+ updatePosition() {
103
+ if (this._lastPosition.equalsWithEpsilon(this.position)) {
104
+ return;
105
+ }
106
+ this.node.positionX.value = this.position.x;
107
+ this.node.positionY.value = this.position.y;
108
+ this.node.positionZ.value = this.position.z;
109
+ this._lastPosition.copyFrom(this.position);
110
+ }
111
+ /** @internal */
112
+ updateRotation() {
113
+ if (!this._lastRotationQuaternion.equalsWithEpsilon(this.rotationQuaternion)) {
114
+ TmpQuaternion.copyFrom(this.rotationQuaternion);
115
+ this._lastRotationQuaternion.copyFrom(this.rotationQuaternion);
116
+ }
117
+ else if (!this._lastRotation.equalsWithEpsilon(this.rotation)) {
118
+ Quaternion.FromEulerAnglesToRef(this.rotation.x, this.rotation.y, this.rotation.z, TmpQuaternion);
119
+ this._lastRotation.copyFrom(this.rotation);
120
+ }
121
+ else {
122
+ return;
123
+ }
124
+ Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);
125
+ Vector3.TransformNormalToRef(Vector3.RightReadOnly, TmpMatrix, TmpVector);
126
+ this.node.orientationX.value = TmpVector.x;
127
+ this.node.orientationY.value = TmpVector.y;
128
+ this.node.orientationZ.value = TmpVector.z;
129
+ }
123
130
  _connect(node) {
124
131
  const connected = super._connect(node);
125
132
  if (!connected) {
@@ -145,12 +152,5 @@ export class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {
145
152
  getClassName() {
146
153
  return "_SpatialWebAudioSubNode";
147
154
  }
148
- _updateRotation() {
149
- Matrix.FromQuaternionToRef(this._webAudioRotationQuaternion, TmpMatrix);
150
- Vector3.TransformNormalToRef(Vector3.Right(), TmpMatrix, TmpVector);
151
- this.node.orientationX.value = TmpVector.x;
152
- this.node.orientationY.value = TmpVector.y;
153
- this.node.orientationZ.value = TmpVector.z;
154
- }
155
155
  }
156
156
  //# sourceMappingURL=spatialWebAudioSubNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spatialWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAI/F,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;AAChC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAEjC,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC;AAED,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACrC,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,MAAuB;IACzE,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,uBAAwB,SAAQ,oBAAoB;IAS7D,gBAAgB;IAChB,YAAmB,MAAuB;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QAVV,cAAS,GAAG,qBAAqB,CAAC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B;QAChD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB;IACT,YAAY;QACf,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAEO,eAAe;QACnB,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,2BAA2B,EAAE,SAAS,CAAC,CAAC;QACxE,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAEpE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/C,CAAC;CACJ","sourcesContent":["import { Matrix, Quaternion, Vector3 } from \"../../../Maths/math.vector\";\r\nimport { _SpatialAudioSubNode } from \"../../abstractAudio/subNodes/spatialAudioSubNode\";\r\nimport { _SpatialAudioDefaults } from \"../../abstractAudio/subProperties/abstractSpatialAudio\";\r\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\r\nimport type { IWebAudioInNode } from \"../webAudioNode\";\r\n\r\nconst TmpMatrix = Matrix.Zero();\r\nconst TmpVector = Vector3.Zero();\r\n\r\nfunction d2r(degrees: number): number {\r\n return (degrees * Math.PI) / 180;\r\n}\r\n\r\nfunction r2d(radians: number): number {\r\n return (radians * 180) / Math.PI;\r\n}\r\n\r\n/** @internal */\r\nexport async function _CreateSpatialAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_SpatialAudioSubNode> {\r\n return new _SpatialWebAudioSubNode(engine);\r\n}\r\n\r\n/** @internal */\r\nexport class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {\r\n private _position = _SpatialAudioDefaults.position.clone();\r\n private _rotation: Vector3 = _SpatialAudioDefaults.rotation.clone();\r\n private _rotationQuaternion: Quaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\r\n private _webAudioRotationQuaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\r\n\r\n /** @internal */\r\n public readonly node: PannerNode;\r\n\r\n /** @internal */\r\n public constructor(engine: _WebAudioEngine) {\r\n super(engine);\r\n\r\n this.node = new PannerNode(engine.audioContext);\r\n }\r\n\r\n /** @internal */\r\n public get coneInnerAngle(): number {\r\n return d2r(this.node.coneInnerAngle);\r\n }\r\n\r\n public set coneInnerAngle(value: number) {\r\n this.node.coneInnerAngle = r2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterAngle(): number {\r\n return d2r(this.node.coneOuterAngle);\r\n }\r\n\r\n public set coneOuterAngle(value: number) {\r\n this.node.coneOuterAngle = r2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterVolume(): number {\r\n return this.node.coneOuterGain;\r\n }\r\n\r\n public set coneOuterVolume(value: number) {\r\n this.node.coneOuterGain = value;\r\n }\r\n\r\n /** @internal */\r\n public get distanceModel(): \"linear\" | \"inverse\" | \"exponential\" {\r\n return this.node.distanceModel;\r\n }\r\n\r\n public set distanceModel(value: \"linear\" | \"inverse\" | \"exponential\") {\r\n this.node.distanceModel = value;\r\n\r\n // Wiggle the max distance to make the change take effect.\r\n const maxDistance = this.node.maxDistance;\r\n this.node.maxDistance = maxDistance + 0.001;\r\n this.node.maxDistance = maxDistance;\r\n }\r\n\r\n /** @internal */\r\n public get maxDistance(): number {\r\n return this.node.maxDistance;\r\n }\r\n\r\n public set maxDistance(value: number) {\r\n this.node.maxDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get panningModel(): \"equalpower\" | \"HRTF\" {\r\n return this.node.panningModel;\r\n }\r\n\r\n public set panningModel(value: \"equalpower\" | \"HRTF\") {\r\n this.node.panningModel = value;\r\n }\r\n\r\n /** @internal */\r\n public get position(): Vector3 {\r\n return this._position;\r\n }\r\n\r\n public set position(value: Vector3) {\r\n this._position.copyFrom(value);\r\n\r\n this.node.positionX.value = value.x;\r\n this.node.positionY.value = value.y;\r\n this.node.positionZ.value = value.z;\r\n }\r\n\r\n /** @internal */\r\n public get referenceDistance(): number {\r\n return this.node.refDistance;\r\n }\r\n\r\n public set referenceDistance(value: number) {\r\n this.node.refDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get rolloffFactor(): number {\r\n return this.node.rolloffFactor;\r\n }\r\n\r\n public set rolloffFactor(value: number) {\r\n this.node.rolloffFactor = value;\r\n }\r\n\r\n /** @internal */\r\n public get rotation(): Vector3 {\r\n return this._rotation;\r\n }\r\n\r\n public set rotation(value: Vector3) {\r\n this._rotation.copyFrom(value);\r\n Quaternion.FromEulerAnglesToRef(value.x, value.y, value.z, this._webAudioRotationQuaternion);\r\n this._updateRotation();\r\n }\r\n\r\n /** @internal */\r\n public get rotationQuaternion(): Quaternion {\r\n return this._rotationQuaternion;\r\n }\r\n\r\n public set rotationQuaternion(value: Quaternion) {\r\n this._rotationQuaternion.copyFrom(value);\r\n this._webAudioRotationQuaternion.copyFrom(value);\r\n this._updateRotation();\r\n }\r\n\r\n /** @internal */\r\n public get inNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public get outNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n protected override _connect(node: IWebAudioInNode): boolean {\r\n const connected = super._connect(node);\r\n\r\n if (!connected) {\r\n return false;\r\n }\r\n\r\n // If the wrapped node is not available now, it will be connected later by the subgraph.\r\n if (node.inNode) {\r\n this.node.connect(node.inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected override _disconnect(node: IWebAudioInNode): boolean {\r\n const disconnected = super._disconnect(node);\r\n\r\n if (!disconnected) {\r\n return false;\r\n }\r\n\r\n if (node.inNode) {\r\n this.node.disconnect(node.inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public getClassName(): string {\r\n return \"_SpatialWebAudioSubNode\";\r\n }\r\n\r\n private _updateRotation(): void {\r\n Matrix.FromQuaternionToRef(this._webAudioRotationQuaternion, TmpMatrix);\r\n Vector3.TransformNormalToRef(Vector3.Right(), TmpMatrix, TmpVector);\r\n\r\n this.node.orientationX.value = TmpVector.x;\r\n this.node.orientationY.value = TmpVector.y;\r\n this.node.orientationZ.value = TmpVector.z;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"spatialWebAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAI/F,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;AAChC,MAAM,aAAa,GAAG,IAAI,UAAU,EAAE,CAAC;AACvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAEjC,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC;AAED,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACrC,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,MAAuB;IACzE,OAAO,IAAI,uBA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atialAudioSubNode } from \"../../abstractAudio/subNodes/spatialAudioSubNode\";\r\nimport { _SpatialAudioDefaults } from \"../../abstractAudio/subProperties/abstractSpatialAudio\";\r\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\r\nimport type { IWebAudioInNode } from \"../webAudioNode\";\r\n\r\nconst TmpMatrix = Matrix.Zero();\r\nconst TmpQuaternion = new Quaternion();\r\nconst TmpVector = Vector3.Zero();\r\n\r\nfunction d2r(degrees: number): number {\r\n return (degrees * Math.PI) / 180;\r\n}\r\n\r\nfunction r2d(radians: number): number {\r\n return (radians * 180) / Math.PI;\r\n}\r\n\r\n/** @internal */\r\nexport async function _CreateSpatialAudioSubNodeAsync(engine: _WebAudioEngine): Promise<_SpatialAudioSubNode> {\r\n return new _SpatialWebAudioSubNode(engine);\r\n}\r\n\r\n/** @internal */\r\nexport class _SpatialWebAudioSubNode extends _SpatialAudioSubNode {\r\n private _lastPosition: Vector3 = Vector3.Zero();\r\n private _lastRotation: Vector3 = Vector3.Zero();\r\n private _lastRotationQuaternion: Quaternion = new Quaternion();\r\n\r\n /** @internal */\r\n public readonly position = _SpatialAudioDefaults.position.clone();\r\n /** @internal */\r\n public readonly rotation: Vector3 = _SpatialAudioDefaults.rotation.clone();\r\n /** @internal */\r\n public readonly rotationQuaternion: Quaternion = _SpatialAudioDefaults.rotationQuaternion.clone();\r\n\r\n /** @internal */\r\n public readonly node: PannerNode;\r\n\r\n /** @internal */\r\n public constructor(engine: _WebAudioEngine) {\r\n super(engine);\r\n\r\n this.node = new PannerNode(engine.audioContext);\r\n }\r\n\r\n /** @internal */\r\n public get coneInnerAngle(): number {\r\n return d2r(this.node.coneInnerAngle);\r\n }\r\n\r\n public set coneInnerAngle(value: number) {\r\n this.node.coneInnerAngle = r2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterAngle(): number {\r\n return d2r(this.node.coneOuterAngle);\r\n }\r\n\r\n public set coneOuterAngle(value: number) {\r\n this.node.coneOuterAngle = r2d(value);\r\n }\r\n\r\n /** @internal */\r\n public get coneOuterVolume(): number {\r\n return this.node.coneOuterGain;\r\n }\r\n\r\n public set coneOuterVolume(value: number) {\r\n this.node.coneOuterGain = value;\r\n }\r\n\r\n /** @internal */\r\n public get distanceModel(): \"linear\" | \"inverse\" | \"exponential\" {\r\n return this.node.distanceModel;\r\n }\r\n\r\n public set distanceModel(value: \"linear\" | \"inverse\" | \"exponential\") {\r\n this.node.distanceModel = value;\r\n\r\n // Wiggle the max distance to make the change take effect.\r\n const maxDistance = this.node.maxDistance;\r\n this.node.maxDistance = maxDistance + 0.001;\r\n this.node.maxDistance = maxDistance;\r\n }\r\n\r\n /** @internal */\r\n public get maxDistance(): number {\r\n return this.node.maxDistance;\r\n }\r\n\r\n public set maxDistance(value: number) {\r\n this.node.maxDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get panningModel(): \"equalpower\" | \"HRTF\" {\r\n return this.node.panningModel;\r\n }\r\n\r\n public set panningModel(value: \"equalpower\" | \"HRTF\") {\r\n this.node.panningModel = value;\r\n }\r\n\r\n /** @internal */\r\n public get referenceDistance(): number {\r\n return this.node.refDistance;\r\n }\r\n\r\n public set referenceDistance(value: number) {\r\n this.node.refDistance = value;\r\n }\r\n\r\n /** @internal */\r\n public get rolloffFactor(): number {\r\n return this.node.rolloffFactor;\r\n }\r\n\r\n public set rolloffFactor(value: number) {\r\n this.node.rolloffFactor = value;\r\n }\r\n\r\n /** @internal */\r\n public get inNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public get outNode(): AudioNode {\r\n return this.node;\r\n }\r\n\r\n /** @internal */\r\n public updatePosition(): void {\r\n if (this._lastPosition.equalsWithEpsilon(this.position)) {\r\n return;\r\n }\r\n\r\n this.node.positionX.value = this.position.x;\r\n this.node.positionY.value = this.position.y;\r\n this.node.positionZ.value = this.position.z;\r\n\r\n this._lastPosition.copyFrom(this.position);\r\n }\r\n\r\n /** @internal */\r\n public updateRotation(): void {\r\n if (!this._lastRotationQuaternion.equalsWithEpsilon(this.rotationQuaternion)) {\r\n TmpQuaternion.copyFrom(this.rotationQuaternion);\r\n this._lastRotationQuaternion.copyFrom(this.rotationQuaternion);\r\n } else if (!this._lastRotation.equalsWithEpsilon(this.rotation)) {\r\n Quaternion.FromEulerAnglesToRef(this.rotation.x, this.rotation.y, this.rotation.z, TmpQuaternion);\r\n this._lastRotation.copyFrom(this.rotation);\r\n } else {\r\n return;\r\n }\r\n\r\n Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);\r\n Vector3.TransformNormalToRef(Vector3.RightReadOnly, TmpMatrix, TmpVector);\r\n\r\n this.node.orientationX.value = TmpVector.x;\r\n this.node.orientationY.value = TmpVector.y;\r\n this.node.orientationZ.value = TmpVector.z;\r\n }\r\n\r\n protected override _connect(node: IWebAudioInNode): boolean {\r\n const connected = super._connect(node);\r\n\r\n if (!connected) {\r\n return false;\r\n }\r\n\r\n // If the wrapped node is not available now, it will be connected later by the subgraph.\r\n if (node.inNode) {\r\n this.node.connect(node.inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected override _disconnect(node: IWebAudioInNode): boolean {\r\n const disconnected = super._disconnect(node);\r\n\r\n if (!disconnected) {\r\n return false;\r\n }\r\n\r\n if (node.inNode) {\r\n this.node.disconnect(node.inNode);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public getClassName(): string {\r\n return \"_SpatialWebAudioSubNode\";\r\n }\r\n}\r\n"]}
@@ -2,9 +2,13 @@ import type { _AbstractAudioSubGraph } from "../../abstractAudio/subNodes/abstra
2
2
  import { _SpatialAudio } from "../../abstractAudio/subProperties/spatialAudio";
3
3
  /** @internal */
4
4
  export declare class _SpatialWebAudio extends _SpatialAudio {
5
- private _autoUpdate;
5
+ private _updaterComponent;
6
6
  /** @internal */
7
- constructor(subGraph: _AbstractAudioSubGraph, autoUpdate: boolean);
7
+ constructor(subGraph: _AbstractAudioSubGraph, autoUpdate: boolean, minUpdateTime: number);
8
+ /** @internal */
9
+ get minUpdateTime(): number;
10
+ /** @internal */
11
+ set minUpdateTime(value: number);
8
12
  /** @internal */
9
13
  dispose(): void;
10
14
  }
@@ -1,26 +1,24 @@
1
1
  import { _SpatialAudio } from "../../abstractAudio/subProperties/spatialAudio.js";
2
+ import { _SpatialWebAudioUpdaterComponent } from "../components/spatialWebAudioUpdaterComponent.js";
2
3
  /** @internal */
3
4
  export class _SpatialWebAudio extends _SpatialAudio {
4
5
  /** @internal */
5
- constructor(subGraph, autoUpdate) {
6
+ constructor(subGraph, autoUpdate, minUpdateTime) {
6
7
  super(subGraph);
7
- this._autoUpdate = false;
8
- if (!autoUpdate) {
9
- return;
10
- }
11
- this._autoUpdate = true;
12
- const update = () => {
13
- if (!this._autoUpdate) {
14
- return;
15
- }
16
- this.update();
17
- requestAnimationFrame(update);
18
- };
19
- requestAnimationFrame(update);
8
+ this._updaterComponent = new _SpatialWebAudioUpdaterComponent(this, autoUpdate, minUpdateTime);
9
+ }
10
+ /** @internal */
11
+ get minUpdateTime() {
12
+ return this._updaterComponent.minUpdateTime;
13
+ }
14
+ /** @internal */
15
+ set minUpdateTime(value) {
16
+ this._updaterComponent.minUpdateTime = value;
20
17
  }
21
18
  /** @internal */
22
19
  dispose() {
23
- this._autoUpdate = false;
20
+ this._updaterComponent.dispose();
21
+ this._updaterComponent = null;
24
22
  }
25
23
  }
26
24
  //# sourceMappingURL=spatialWebAudio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spatialWebAudio.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subProperties/spatialWebAudio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAE/E,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAG/C,gBAAgB;IAChB,YAAmB,QAAgC,EAAE,UAAmB;QACpE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAJZ,gBAAW,GAAG,KAAK,CAAC;QAMxB,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,MAAM,MAAM,GAAG,GAAG,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpB,OAAO;YACX,CAAC;YAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC;QAEF,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { _AbstractAudioSubGraph } from \"../../abstractAudio/subNodes/abstractAudioSubGraph\";\nimport { _SpatialAudio } from \"../../abstractAudio/subProperties/spatialAudio\";\n\n/** @internal */\nexport class _SpatialWebAudio extends _SpatialAudio {\n private _autoUpdate = false;\n\n /** @internal */\n public constructor(subGraph: _AbstractAudioSubGraph, autoUpdate: boolean) {\n super(subGraph);\n\n if (!autoUpdate) {\n return;\n }\n\n this._autoUpdate = true;\n\n const update = () => {\n if (!this._autoUpdate) {\n return;\n }\n\n this.update();\n requestAnimationFrame(update);\n };\n\n requestAnimationFrame(update);\n }\n\n /** @internal */\n public dispose(): void {\n this._autoUpdate = false;\n }\n}\n"]}
1
+ {"version":3,"file":"spatialWebAudio.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subProperties/spatialWebAudio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AAEjG,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAG/C,gBAAgB;IAChB,YAAmB,QAAgC,EAAE,UAAmB,EAAE,aAAqB;QAC3F,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,CAAC,iBAAiB,GAAG,IAAI,gCAAgC,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACnG,CAAC;IAED,gBAAgB;IAChB,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;IAChD,CAAC;IAED,gBAAgB;IAChB,IAAW,aAAa,CAAC,KAAa;QAClC,IAAI,CAAC,iBAAiB,CAAC,aAAa,GAAG,KAAK,CAAC;IACjD,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,iBAAiB,GAAG,IAAK,CAAC;IACnC,CAAC;CACJ","sourcesContent":["import type { _AbstractAudioSubGraph } from \"../../abstractAudio/subNodes/abstractAudioSubGraph\";\nimport { _SpatialAudio } from \"../../abstractAudio/subProperties/spatialAudio\";\nimport { _SpatialWebAudioUpdaterComponent } from \"../components/spatialWebAudioUpdaterComponent\";\n\n/** @internal */\nexport class _SpatialWebAudio extends _SpatialAudio {\n private _updaterComponent: _SpatialWebAudioUpdaterComponent;\n\n /** @internal */\n public constructor(subGraph: _AbstractAudioSubGraph, autoUpdate: boolean, minUpdateTime: number) {\n super(subGraph);\n\n this._updaterComponent = new _SpatialWebAudioUpdaterComponent(this, autoUpdate, minUpdateTime);\n }\n\n /** @internal */\n public get minUpdateTime(): number {\n return this._updaterComponent.minUpdateTime;\n }\n\n /** @internal */\n public set minUpdateTime(value: number) {\n this._updaterComponent.minUpdateTime = value;\n }\n\n /** @internal */\n public dispose(): void {\n this._updaterComponent.dispose();\n this._updaterComponent = null!;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import { _SpatialAudioListener } from "../../abstractAudio/subProperties/spatialAudioListener";
2
2
  import type { _WebAudioEngine } from "../webAudioEngine";
3
3
  /** @internal */
4
- export declare function _CreateSpatialAudioListener(engine: _WebAudioEngine, autoUpdate: boolean): _SpatialAudioListener;
4
+ export declare function _CreateSpatialAudioListener(engine: _WebAudioEngine, autoUpdate: boolean, minUpdateTime: number): _SpatialAudioListener;
@@ -1,11 +1,12 @@
1
1
  import { Matrix, Quaternion, Vector3 } from "../../../Maths/math.vector.js";
2
2
  import { _SpatialAudioListener } from "../../abstractAudio/subProperties/spatialAudioListener.js";
3
+ import { _SpatialWebAudioUpdaterComponent } from "../components/spatialWebAudioUpdaterComponent.js";
3
4
  const TmpMatrix = Matrix.Zero();
4
5
  const TmpQuaternion = new Quaternion();
5
6
  const TmpVector = Vector3.Zero();
6
7
  /** @internal */
7
- export function _CreateSpatialAudioListener(engine, autoUpdate) {
8
- return new _SpatialWebAudioListener(engine, autoUpdate);
8
+ export function _CreateSpatialAudioListener(engine, autoUpdate, minUpdateTime) {
9
+ return new _SpatialWebAudioListener(engine, autoUpdate, minUpdateTime);
9
10
  }
10
11
  /**
11
12
  * This sub property is not backed by a sub node and all properties are set directly on the audio context listener.
@@ -14,88 +15,72 @@ export function _CreateSpatialAudioListener(engine, autoUpdate) {
14
15
  */
15
16
  class _SpatialWebAudioListener extends _SpatialAudioListener {
16
17
  /** @internal */
17
- constructor(engine, autoUpdate) {
18
+ constructor(engine, autoUpdate, minUpdateTime) {
18
19
  super();
19
- this._autoUpdate = false;
20
20
  this._lastPosition = Vector3.Zero();
21
21
  this._lastRotation = Vector3.Zero();
22
22
  this._lastRotationQuaternion = new Quaternion();
23
- this._position = Vector3.Zero();
24
- this._rotation = Vector3.Zero();
25
- this._rotationQuaternion = new Quaternion();
23
+ /** @internal */
24
+ this.position = Vector3.Zero();
25
+ /** @internal */
26
+ this.rotation = Vector3.Zero();
27
+ /** @internal */
28
+ this.rotationQuaternion = new Quaternion();
26
29
  this._audioContext = engine.audioContext;
27
- if (!autoUpdate) {
28
- return;
29
- }
30
- this._autoUpdate = true;
31
- const update = () => {
32
- if (!this._autoUpdate) {
33
- return;
34
- }
35
- this.update();
36
- requestAnimationFrame(update);
37
- };
38
- requestAnimationFrame(update);
39
- }
40
- /** @internal */
41
- get position() {
42
- return this._position;
43
- }
44
- set position(value) {
45
- this._position = value;
46
- this._updatePosition();
30
+ this._updaterComponent = new _SpatialWebAudioUpdaterComponent(this, autoUpdate, minUpdateTime);
47
31
  }
48
32
  /** @internal */
49
- get rotation() {
50
- return this._rotation;
51
- }
52
- set rotation(value) {
53
- this._rotation = value;
54
- this._updateRotation();
33
+ get minUpdateTime() {
34
+ return this._updaterComponent.minUpdateTime;
55
35
  }
56
36
  /** @internal */
57
- get rotationQuaternion() {
58
- return this._rotationQuaternion;
59
- }
60
- set rotationQuaternion(value) {
61
- this._rotationQuaternion = value;
62
- this._updateRotation();
37
+ set minUpdateTime(value) {
38
+ this._updaterComponent.minUpdateTime = value;
63
39
  }
64
40
  /** @internal */
65
41
  dispose() {
66
42
  super.dispose();
67
- this._autoUpdate = false;
43
+ this._updaterComponent.dispose();
44
+ this._updaterComponent = null;
68
45
  }
69
46
  /** @internal */
70
47
  update() {
71
- this._updatePosition();
72
- this._updateRotation();
48
+ if (this.isAttached) {
49
+ this._attacherComponent?.update();
50
+ }
51
+ else {
52
+ this.updatePosition();
53
+ this.updateRotation();
54
+ }
73
55
  }
74
- _updatePosition() {
75
- if (this._lastPosition.equalsWithEpsilon(this._position)) {
56
+ /** @internal */
57
+ updatePosition() {
58
+ if (this._lastPosition.equalsWithEpsilon(this.position)) {
76
59
  return;
77
60
  }
78
61
  const listener = this._audioContext.listener;
79
- listener.positionX.value = this._position.x;
80
- listener.positionY.value = this._position.y;
81
- listener.positionZ.value = this._position.z;
82
- this._lastPosition.copyFrom(this._position);
62
+ listener.positionX.value = this.position.x;
63
+ listener.positionY.value = this.position.y;
64
+ listener.positionZ.value = this.position.z;
65
+ this._lastPosition.copyFrom(this.position);
83
66
  }
84
- _updateRotation() {
85
- if (!this._lastRotationQuaternion.equalsWithEpsilon(this._rotationQuaternion)) {
86
- TmpQuaternion.copyFrom(this._rotationQuaternion);
87
- this._lastRotationQuaternion.copyFrom(this._rotationQuaternion);
67
+ /** @internal */
68
+ updateRotation() {
69
+ if (!this._lastRotationQuaternion.equalsWithEpsilon(this.rotationQuaternion)) {
70
+ TmpQuaternion.copyFrom(this.rotationQuaternion);
71
+ this._lastRotationQuaternion.copyFrom(this.rotationQuaternion);
88
72
  }
89
- else if (!this._lastRotation.equalsWithEpsilon(this._rotation)) {
90
- Quaternion.FromEulerAnglesToRef(this._rotation.x, this._rotation.y, this._rotation.z, TmpQuaternion);
91
- this._lastRotation.copyFrom(this._rotation);
73
+ else if (!this._lastRotation.equalsWithEpsilon(this.rotation)) {
74
+ Quaternion.FromEulerAnglesToRef(this.rotation.x, this.rotation.y, this.rotation.z, TmpQuaternion);
75
+ this._lastRotation.copyFrom(this.rotation);
92
76
  }
93
77
  else {
94
78
  return;
95
79
  }
96
80
  Matrix.FromQuaternionToRef(TmpQuaternion, TmpMatrix);
97
81
  const listener = this._audioContext.listener;
98
- Vector3.TransformNormalToRef(Vector3.Forward(), TmpMatrix, TmpVector);
82
+ // NB: The WebAudio API is right-handed.
83
+ Vector3.TransformNormalToRef(Vector3.RightHandedForwardReadOnly, TmpMatrix, TmpVector);
99
84
  listener.forwardX.value = TmpVector.x;
100
85
  listener.forwardY.value = TmpVector.y;
101
86
  listener.forwardZ.value = TmpVector.z;