@babylonjs/core 5.42.0 → 5.42.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/Audio/sound.d.ts CHANGED
@@ -305,4 +305,5 @@ export declare class Sound {
305
305
  * @returns the newly parsed sound
306
306
  */
307
307
  static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
308
+ private _setOffset;
308
309
  }
package/Audio/sound.js CHANGED
@@ -306,7 +306,7 @@ export class Sound {
306
306
  if (this._htmlAudioElement) {
307
307
  return this._htmlAudioElement.currentTime;
308
308
  }
309
- let currentTime = this._startOffset + (this._offset ? this._offset : 0);
309
+ let currentTime = this._startOffset;
310
310
  if (this.isPlaying && ((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.audioContext)) {
311
311
  currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;
312
312
  }
@@ -438,7 +438,7 @@ export class Sound {
438
438
  this.distanceModel = (_f = options.distanceModel) !== null && _f !== void 0 ? _f : this.distanceModel;
439
439
  this._playbackRate = (_g = options.playbackRate) !== null && _g !== void 0 ? _g : this._playbackRate;
440
440
  this._length = (_h = options.length) !== null && _h !== void 0 ? _h : undefined;
441
- this._offset = (_j = options.offset) !== null && _j !== void 0 ? _j : undefined;
441
+ this._setOffset((_j = options.offset) !== null && _j !== void 0 ? _j : undefined);
442
442
  this.setVolume((_k = options.volume) !== null && _k !== void 0 ? _k : this._volume);
443
443
  this._updateSpatialParameters();
444
444
  if (this.isPlaying) {
@@ -743,7 +743,7 @@ export class Sound {
743
743
  if ((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.audioContext) {
744
744
  length = length || this._length;
745
745
  if (offset !== undefined) {
746
- this._offset = offset;
746
+ this._setOffset(offset);
747
747
  }
748
748
  if (this._soundSource) {
749
749
  const oldSource = this._soundSource;
@@ -1141,6 +1141,16 @@ export class Sound {
1141
1141
  }
1142
1142
  return newSound;
1143
1143
  }
1144
+ _setOffset(value) {
1145
+ if (this._offset === value) {
1146
+ return;
1147
+ }
1148
+ if (this.isPaused) {
1149
+ this.stop();
1150
+ this.isPaused = false;
1151
+ }
1152
+ this._offset = value;
1153
+ }
1144
1154
  }
1145
1155
  /**
1146
1156
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"sound.js","sourceRoot":"","sources":["../../../../lts/core/generated/Audio/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAyJd;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,gBAAqB,EAAE,KAAuB,EAAE,sBAA4C,IAAI,EAAE,OAAuB;;QA5JnJ;;WAEG;QACI,aAAQ,GAAY,KAAK,CAAC;QAEzB,UAAK,GAAG,KAAK,CAAC;QAiBtB;;;;WAIG;QACI,yBAAoB,GAAY,KAAK,CAAC;QAK7C;;WAEG;QACI,cAAS,GAAY,KAAK,CAAC;QAClC;;WAEG;QACI,aAAQ,GAAY,KAAK,CAAC;QACjC;;;WAGG;QACI,gBAAW,GAAW,CAAC,CAAC;QAC/B;;;WAGG;QACI,kBAAa,GAAW,CAAC,CAAC;QACjC;;;WAGG;QACI,gBAAW,GAAW,GAAG,CAAC;QACjC;;;WAGG;QACI,kBAAa,GAAW,QAAQ,CAAC;QAMxC;;WAEG;QACI,aAAQ,GAAQ,IAAI,CAAC;QAE5B;;WAEG;QACI,sBAAiB,GAAG,IA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AAW,CAAC,aAAa,EAAE;YAC3B,QAAQ,CAAC,kBAAkB,CAAC,WAAW,CAAC,cAAc,IAAI,GAAG,EAAE,WAAW,CAAC,cAAc,IAAI,GAAG,EAAE,WAAW,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;YAClI,IAAI,WAAW,CAAC,oBAAoB,EAAE;gBAClC,MAAM,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;gBACjF,QAAQ,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;aAC1D;SACJ;QACD,IAAI,WAAW,CAAC,eAAe,EAAE;YAC7B,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YACrE,IAAI,aAAa,EAAE;gBACf,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;aACxC;SACJ;QAED,IAAI,WAAW,CAAC,QAAQ,EAAE;YACtB,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;SAC5C;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;;AA5iCD;;GAEG;AACW,mCAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { ISoundOptions } from \"./Interfaces/ISoundOptions\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Defines a sound that can be played in the application.\r\n * The sound can either be an ambient track or a simple sound played in reaction to a user action.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class Sound {\r\n /**\r\n * The name of the sound in the scene.\r\n */\r\n public name: string;\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n public autoplay: boolean = false;\r\n\r\n private _loop = false;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n public get loop(): boolean {\r\n return this._loop;\r\n }\r\n\r\n public set loop(value: boolean) {\r\n if (value === this._loop) {\r\n return;\r\n }\r\n\r\n this._loop = value;\r\n this.updateOptions({ loop: value });\r\n }\r\n\r\n /**\r\n * Does the sound use a custom attenuation curve to simulate the falloff\r\n * happening when the source gets further away from the camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public useCustomAttenuation: boolean = false;\r\n /**\r\n * The sound track id this sound belongs to.\r\n */\r\n public soundTrackId: number;\r\n /**\r\n * Is this sound currently played.\r\n */\r\n public isPlaying: boolean = false;\r\n /**\r\n * Is this sound currently paused.\r\n */\r\n public isPaused: boolean = false;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public refDistance: number = 1;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public rolloffFactor: number = 1;\r\n /**\r\n * Define the max distance the sound should be heard (intensity just became 0 at this point).\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public maxDistance: number = 100;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public distanceModel: string = \"linear\";\r\n /**\r\n * @internal\r\n * Back Compat\r\n **/\r\n public onended: () => any;\r\n /**\r\n * Gets or sets an object used to store user defined information for the sound.\r\n */\r\n public metadata: any = null;\r\n\r\n /**\r\n * Observable event when the current playing sound finishes.\r\n */\r\n public onEndedObservable = new Observable<Sound>();\r\n\r\n /**\r\n * Gets the current time for the sound.\r\n */\r\n public get currentTime(): number {\r\n if (this._htmlAudioElement) {\r\n return this._htmlAudioElement.currentTime;\r\n }\r\n\r\n let currentTime: number = this._startOffset + (this._offset ? this._offset : 0);\r\n if (this.isPlaying && Engine.audioEngine?.audioContext) {\r\n currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n return currentTime;\r\n }\r\n\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public get spatialSound(): boolean {\r\n return this._spatialSound;\r\n }\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public set spatialSound(newValue: boolean) {\r\n this._spatialSound = newValue;\r\n if (this._spatialSound && Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._createSpatialParameters();\r\n }\r\n }\r\n private _spatialSound: boolean = false;\r\n private _panningModel: string = \"equalpower\";\r\n private _playbackRate: number = 1;\r\n private _streaming: boolean = false;\r\n private _startTime: number = 0;\r\n private _startOffset: number = 0;\r\n private _position: Vector3 = Vector3.Zero();\r\n private _localDirection: Vector3 = new Vector3(1, 0, 0);\r\n private _volume: number = 1;\r\n private _isReadyToPlay: boolean = false;\r\n private _isDirectional: boolean = false;\r\n private _readyToPlayCallback: Nullable<() => any>;\r\n private _audioBuffer: Nullable<AudioBuffer>;\r\n private _soundSource: Nullable<AudioBufferSourceNode>;\r\n private _streamingSource: AudioNode;\r\n private _soundPanner: Nullable<PannerNode>;\r\n private _soundGain: Nullable<GainNode>;\r\n private _inputAudioNode: Nullable<AudioNode>;\r\n private _outputAudioNode: Nullable<AudioNode>;\r\n // Used if you'd like to create a directional sound.\r\n // If not set, the sound will be omnidirectional\r\n private _coneInnerAngle: number = 360;\r\n private _coneOuterAngle: number = 360;\r\n private _coneOuterGain: number = 0;\r\n private _scene: Scene;\r\n private _connectedTransformNode: Nullable<TransformNode>;\r\n private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;\r\n private _registerFunc: Nullable<(connectedMesh: TransformNode) => void>;\r\n private _isOutputConnected = false;\r\n private _htmlAudioElement: HTMLAudioElement;\r\n private _urlType: \"Unknown\" | \"String\" | \"Array\" | \"ArrayBuffer\" | \"MediaStream\" | \"AudioBuffer\" | \"MediaElement\" = \"Unknown\";\r\n private _length?: number;\r\n private _offset?: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"AudioSceneComponent\");\r\n };\r\n\r\n /**\r\n * Create a sound and attach it to a scene\r\n * @param name Name of your sound\r\n * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers\r\n * @param scene defines the scene the sound belongs to\r\n * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played\r\n * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming\r\n */\r\n constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback: Nullable<() => void> = null, options?: ISoundOptions) {\r\n this.name = name;\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n Sound._SceneComponentInitialization(scene);\r\n\r\n this._readyToPlayCallback = readyToPlayCallback;\r\n // Default custom attenuation function is a linear attenuation\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {\r\n if (currentDistance < maxDistance) {\r\n return currentVolume * (1 - currentDistance / maxDistance);\r\n } else {\r\n return 0;\r\n }\r\n };\r\n if (options) {\r\n this.autoplay = options.autoplay || false;\r\n this._loop = options.loop || false;\r\n // if volume === 0, we need another way to check this option\r\n if (options.volume !== undefined) {\r\n this._volume = options.volume;\r\n }\r\n this._spatialSound = options.spatialSound ?? false;\r\n this.maxDistance = options.maxDistance ?? 100;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? false;\r\n this.rolloffFactor = options.rolloffFactor || 1;\r\n this.refDistance = options.refDistance || 1;\r\n this.distanceModel = options.distanceModel || \"linear\";\r\n this._playbackRate = options.playbackRate || 1;\r\n this._streaming = options.streaming ?? false;\r\n this._length = options.length;\r\n this._offset = options.offset;\r\n }\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._soundGain = Engine.audioEngine.audioContext.createGain();\r\n this._soundGain!.gain.value = this._volume;\r\n this._inputAudioNode = this._soundGain;\r\n this._outputAudioNode = this._soundGain;\r\n if (this._spatialSound) {\r\n this._createSpatialParameters();\r\n }\r\n this._scene.mainSoundTrack.addSound(this);\r\n let validParameter = true;\r\n\r\n // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound\r\n if (urlOrArrayBuffer) {\r\n try {\r\n if (typeof urlOrArrayBuffer === \"string\") {\r\n this._urlType = \"String\";\r\n } else if (urlOrArrayBuffer instanceof ArrayBuffer) {\r\n this._urlType = \"ArrayBuffer\";\r\n } else if (urlOrArrayBuffer instanceof HTMLMediaElement) {\r\n this._urlType = \"MediaElement\";\r\n } else if (urlOrArrayBuffer instanceof MediaStream) {\r\n this._urlType = \"MediaStream\";\r\n } else if (urlOrArrayBuffer instanceof AudioBuffer) {\r\n this._urlType = \"AudioBuffer\";\r\n } else if (Array.isArray(urlOrArrayBuffer)) {\r\n this._urlType = \"Array\";\r\n }\r\n\r\n let urls: string[] = [];\r\n let codecSupportedFound = false;\r\n\r\n switch (this._urlType) {\r\n case \"MediaElement\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"MediaStream\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"ArrayBuffer\":\r\n if ((<ArrayBuffer>urlOrArrayBuffer).byteLength > 0) {\r\n codecSupportedFound = true;\r\n this._soundLoaded(urlOrArrayBuffer);\r\n }\r\n break;\r\n case \"AudioBuffer\":\r\n this._audioBufferLoaded(urlOrArrayBuffer);\r\n break;\r\n case \"String\":\r\n urls.push(urlOrArrayBuffer);\r\n // eslint-disable-next-line no-fallthrough\r\n case \"Array\":\r\n if (urls.length === 0) {\r\n urls = urlOrArrayBuffer;\r\n }\r\n // If we found a supported format, we load it immediately and stop the loop\r\n for (let i = 0; i < urls.length; i++) {\r\n const url = urls[i];\r\n codecSupportedFound =\r\n (options && options.skipCodecCheck) ||\r\n (url.indexOf(\".mp3\", url.length - 4) !== -1 && Engine.audioEngine.isMP3supported) ||\r\n (url.indexOf(\".ogg\", url.length - 4) !== -1 && Engine.audioEngine.isOGGsupported) ||\r\n url.indexOf(\".wav\", url.length - 4) !== -1 ||\r\n url.indexOf(\".m4a\", url.length - 4) !== -1 ||\r\n url.indexOf(\".mp4\", url.length - 4) !== -1 ||\r\n url.indexOf(\"blob:\") !== -1;\r\n if (codecSupportedFound) {\r\n // Loading sound\r\n if (!this._streaming) {\r\n this._scene._loadFile(\r\n url,\r\n (data) => {\r\n this._soundLoaded(data as ArrayBuffer);\r\n },\r\n undefined,\r\n true,\r\n true,\r\n (exception) => {\r\n if (exception) {\r\n Logger.Error(\"XHR \" + exception.status + \" error on: \" + url + \".\");\r\n }\r\n Logger.Error(\"Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n );\r\n }\r\n // Streaming sound using HTML5 Audio tag\r\n else {\r\n this._htmlAudioElement = new Audio(url);\r\n this._htmlAudioElement.controls = false;\r\n this._htmlAudioElement.loop = this.loop;\r\n Tools.SetCorsBehavior(url, this._htmlAudioElement);\r\n this._htmlAudioElement.preload = \"auto\";\r\n this._htmlAudioElement.addEventListener(\"canplaythrough\", () => {\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n });\r\n document.body.appendChild(this._htmlAudioElement);\r\n this._htmlAudioElement.load();\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n default:\r\n validParameter = false;\r\n break;\r\n }\r\n\r\n if (!validParameter) {\r\n Logger.Error(\"Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.\");\r\n } else {\r\n if (!codecSupportedFound) {\r\n this._isReadyToPlay = true;\r\n // Simulating a ready to play event to avoid breaking code path\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n } catch (ex) {\r\n Logger.Error(\"Unexpected error. Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n }\r\n } else {\r\n // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers\r\n this._scene.mainSoundTrack.addSound(this);\r\n if (Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported) {\r\n Logger.Error(\"Web Audio is not supported by your browser.\");\r\n Engine.audioEngine.WarnedWebAudioUnsupported = true;\r\n }\r\n // Simulating a ready to play event to avoid breaking code for non web audio browsers\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound and its associated resources\r\n */\r\n public dispose() {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (this.isPlaying) {\r\n this.stop();\r\n }\r\n this._isReadyToPlay = false;\r\n if (this.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(this);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[this.soundTrackId].removeSound(this);\r\n }\r\n if (this._soundGain) {\r\n this._soundGain.disconnect();\r\n this._soundGain = null;\r\n }\r\n if (this._soundPanner) {\r\n this._soundPanner.disconnect();\r\n this._soundPanner = null;\r\n }\r\n if (this._soundSource) {\r\n this._soundSource.disconnect();\r\n this._soundSource = null;\r\n }\r\n this._audioBuffer = null;\r\n\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n this._htmlAudioElement.src = \"\";\r\n document.body.removeChild(this._htmlAudioElement);\r\n }\r\n\r\n if (this._streamingSource) {\r\n this._streamingSource.disconnect();\r\n }\r\n\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the sounds is ready to be played or not.\r\n * @returns true if ready, otherwise false\r\n */\r\n public isReady(): boolean {\r\n return this._isReadyToPlay;\r\n }\r\n\r\n /**\r\n * Get the current class name.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return \"Sound\";\r\n }\r\n\r\n private _audioBufferLoaded(buffer: AudioBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n this._audioBuffer = buffer;\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }\r\n\r\n private _soundLoaded(audioData: ArrayBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n Engine.audioEngine.audioContext.decodeAudioData(\r\n audioData,\r\n (buffer) => {\r\n this._audioBufferLoaded(buffer);\r\n },\r\n (err: any) => {\r\n Logger.Error(\"Error while decoding audio data for: \" + this.name + \" / Error: \" + err);\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Sets the data of the sound from an audiobuffer\r\n * @param audioBuffer The audioBuffer containing the data\r\n */\r\n public setAudioBuffer(audioBuffer: AudioBuffer): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n this._audioBuffer = audioBuffer;\r\n this._isReadyToPlay = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the current sounds options such as maxdistance, loop...\r\n * @param options A JSON object containing values named as the object properties\r\n */\r\n public updateOptions(options: ISoundOptions): void {\r\n if (options) {\r\n this.loop = options.loop ?? this.loop;\r\n this.maxDistance = options.maxDistance ?? this.maxDistance;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;\r\n this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;\r\n this.refDistance = options.refDistance ?? this.refDistance;\r\n this.distanceModel = options.distanceModel ?? this.distanceModel;\r\n this._playbackRate = options.playbackRate ?? this._playbackRate;\r\n this._length = options.length ?? undefined;\r\n this._offset = options.offset ?? undefined;\r\n this.setVolume(options.volume ?? this._volume);\r\n this._updateSpatialParameters();\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n if (this._htmlAudioElement.loop !== this.loop) {\r\n this._htmlAudioElement.loop = this.loop;\r\n }\r\n } else {\r\n if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n if (this._soundSource.loop !== this.loop) {\r\n this._soundSource.loop = this.loop;\r\n }\r\n if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {\r\n this._soundSource.loopStart = this._offset;\r\n }\r\n if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {\r\n this._soundSource.loopEnd = (this._offset! | 0) + this._length!;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _createSpatialParameters() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n if (this._scene.headphone) {\r\n this._panningModel = \"HRTF\";\r\n }\r\n this._soundPanner = this._soundPanner ?? Engine.audioEngine.audioContext.createPanner();\r\n if (this._soundPanner && this._outputAudioNode) {\r\n this._updateSpatialParameters();\r\n this._soundPanner.connect(this._outputAudioNode);\r\n this._inputAudioNode = this._soundPanner;\r\n }\r\n }\r\n }\r\n\r\n private _updateSpatialParameters() {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (this.useCustomAttenuation) {\r\n // Tricks to disable in a way embedded Web Audio attenuation\r\n this._soundPanner.distanceModel = \"linear\";\r\n this._soundPanner.maxDistance = Number.MAX_VALUE;\r\n this._soundPanner.refDistance = 1;\r\n this._soundPanner.rolloffFactor = 1;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n } else {\r\n this._soundPanner.distanceModel = this.distanceModel as any;\r\n this._soundPanner.maxDistance = this.maxDistance;\r\n this._soundPanner.refDistance = this.refDistance;\r\n this._soundPanner.rolloffFactor = this.rolloffFactor;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF() {\r\n this._panningModel = \"HRTF\";\r\n this._switchPanningModel();\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower() {\r\n this._panningModel = \"equalpower\";\r\n this._switchPanningModel();\r\n }\r\n\r\n private _switchPanningModel() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this sound to a sound track audio node like gain...\r\n * @param soundTrackAudioNode the sound track audio node to connect to\r\n */\r\n public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n if (this._isOutputConnected) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode.connect(soundTrackAudioNode);\r\n this._isOutputConnected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Transform this sound into a directional source\r\n * @param coneInnerAngle Size of the inner cone in degree\r\n * @param coneOuterAngle Size of the outer cone in degree\r\n * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)\r\n */\r\n public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {\r\n if (coneOuterAngle < coneInnerAngle) {\r\n Logger.Error(\"setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n this._coneInnerAngle = coneInnerAngle;\r\n this._coneOuterAngle = coneOuterAngle;\r\n this._coneOuterGain = coneOuterGain;\r\n this._isDirectional = true;\r\n\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public get directionalConeInnerAngle(): number {\r\n return this._coneInnerAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public set directionalConeInnerAngle(value: number) {\r\n if (value != this._coneInnerAngle) {\r\n if (this._coneOuterAngle < value) {\r\n Logger.Error(\"directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneInnerAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public get directionalConeOuterAngle(): number {\r\n return this._coneOuterAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public set directionalConeOuterAngle(value: number) {\r\n if (value != this._coneOuterAngle) {\r\n if (value < this._coneInnerAngle) {\r\n Logger.Error(\"directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneOuterAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the position of the emitter if spatial sound is enabled\r\n * @param newPosition Defines the new position\r\n */\r\n public setPosition(newPosition: Vector3): void {\r\n if (newPosition.equals(this._position)) {\r\n return;\r\n }\r\n this._position.copyFrom(newPosition);\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the local direction of the emitter if spatial sound is enabled\r\n * @param newLocalDirection Defines the new local direction\r\n */\r\n public setLocalDirectionToMesh(newLocalDirection: Vector3): void {\r\n this._localDirection = newLocalDirection;\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n private _updateDirection() {\r\n if (!this._connectedTransformNode || !this._soundPanner) {\r\n return;\r\n }\r\n\r\n const mat = this._connectedTransformNode.getWorldMatrix();\r\n const direction = Vector3.TransformNormal(this._localDirection, mat);\r\n direction.normalize();\r\n this._soundPanner.orientationX.value = direction.x;\r\n this._soundPanner.orientationY.value = direction.y;\r\n this._soundPanner.orientationZ.value = direction.z;\r\n }\r\n\r\n /** @internal */\r\n public updateDistanceFromListener() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {\r\n const distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);\r\n this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);\r\n }\r\n }\r\n\r\n /**\r\n * Sets a new custom attenuation function for the sound.\r\n * @param callback Defines the function used for the attenuation\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void {\r\n this._customAttenuationFunction = callback;\r\n }\r\n\r\n /**\r\n * Play the sound\r\n * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.\r\n * @param offset (optional) Start the sound at a specific time in seconds\r\n * @param length (optional) Sound duration (in seconds)\r\n */\r\n public play(time?: number, offset?: number, length?: number): void {\r\n if (this._isReadyToPlay && this._scene.audioEnabled && Engine.audioEngine?.audioContext) {\r\n try {\r\n if (this._startOffset < 0) {\r\n time = -this._startOffset;\r\n this._startOffset = 0;\r\n }\r\n let startTime = time ? Engine.audioEngine?.audioContext.currentTime + time : Engine.audioEngine?.audioContext.currentTime;\r\n if (!this._soundSource || !this._streamingSource) {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n if (this._isDirectional) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n this._soundPanner.coneOuterGain = this._coneOuterGain;\r\n if (this._connectedTransformNode) {\r\n this._updateDirection();\r\n } else {\r\n this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);\r\n }\r\n }\r\n }\r\n }\r\n if (this._streaming) {\r\n if (!this._streamingSource) {\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);\r\n this._htmlAudioElement.onended = () => {\r\n this._onended();\r\n };\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n }\r\n this._streamingSource.disconnect();\r\n if (this._inputAudioNode) {\r\n this._streamingSource.connect(this._inputAudioNode);\r\n }\r\n if (this._htmlAudioElement) {\r\n // required to manage properly the new suspended default state of Chrome\r\n // When the option 'streaming: true' is used, we need first to wait for\r\n // the audio engine to be unlocked by a user gesture before trying to play\r\n // an HTML Audio element\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.unlocked) {\r\n const playPromise = this._htmlAudioElement.play();\r\n\r\n // In browsers that don’t yet support this functionality,\r\n // playPromise won’t be defined.\r\n if (playPromise !== undefined) {\r\n playPromise.catch(() => {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine?.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n });\r\n }\r\n } else {\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n }\r\n };\r\n tryToPlay();\r\n }\r\n } else {\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.audioContext) {\r\n length = length || this._length;\r\n\r\n if (offset !== undefined) {\r\n this._offset = offset;\r\n }\r\n\r\n if (this._soundSource) {\r\n const oldSource = this._soundSource;\r\n oldSource.onended = () => {\r\n oldSource.disconnect();\r\n };\r\n }\r\n this._soundSource = Engine.audioEngine?.audioContext.createBufferSource();\r\n if (this._soundSource && this._inputAudioNode) {\r\n this._soundSource.buffer = this._audioBuffer;\r\n this._soundSource.connect(this._inputAudioNode);\r\n this._soundSource.loop = this.loop;\r\n if (offset !== undefined) {\r\n this._soundSource.loopStart = offset;\r\n }\r\n if (length !== undefined) {\r\n this._soundSource.loopEnd = (offset! | 0) + length!;\r\n }\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n this._soundSource.onended = () => {\r\n this._onended();\r\n };\r\n startTime = time ? Engine.audioEngine?.audioContext!.currentTime + time : Engine.audioEngine.audioContext!.currentTime;\r\n const actualOffset = ((this.isPaused ? this._startOffset : 0) + (this._offset ?? 0)) % this._soundSource!.buffer!.duration;\r\n this._soundSource!.start(startTime, actualOffset, this.loop ? undefined : length);\r\n }\r\n }\r\n };\r\n\r\n if (Engine.audioEngine?.audioContext.state === \"suspended\") {\r\n // Wait a bit for FF as context seems late to be ready.\r\n setTimeout(() => {\r\n if (Engine.audioEngine?.audioContext!.state === \"suspended\") {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n } else {\r\n tryToPlay();\r\n }\r\n }, 500);\r\n } else {\r\n tryToPlay();\r\n }\r\n }\r\n this._startTime = startTime;\r\n this.isPlaying = true;\r\n this.isPaused = false;\r\n } catch (ex) {\r\n Logger.Error(\"Error while trying to play audio: \" + this.name + \", \" + ex.message);\r\n }\r\n }\r\n }\r\n\r\n private _onended() {\r\n this.isPlaying = false;\r\n this._startOffset = 0;\r\n if (this.onended) {\r\n this.onended();\r\n }\r\n this.onEndedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Stop the sound\r\n * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.\r\n */\r\n public stop(time?: number): void {\r\n if (this.isPlaying) {\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n // Test needed for Firefox or it will generate an Invalid State Error\r\n if (this._htmlAudioElement.currentTime > 0) {\r\n this._htmlAudioElement.currentTime = 0;\r\n }\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n const stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : undefined;\r\n this._soundSource.stop(stopTime);\r\n if (stopTime === undefined) {\r\n this.isPlaying = false;\r\n this._soundSource.onended = () => void 0;\r\n } else {\r\n this._soundSource.onended = () => {\r\n this.isPlaying = false;\r\n };\r\n }\r\n if (!this.isPaused) {\r\n this._startOffset = 0;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Put the sound in pause\r\n */\r\n public pause(): void {\r\n if (this.isPlaying) {\r\n this.isPaused = true;\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext) {\r\n this.stop(0);\r\n this._startOffset += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets a dedicated volume for this sounds\r\n * @param newVolume Define the new volume of the sound\r\n * @param time Define time for gradual change to new volume\r\n */\r\n public setVolume(newVolume: number, time?: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._soundGain) {\r\n if (time && Engine.audioEngine.audioContext) {\r\n this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.linearRampToValueAtTime(newVolume, Engine.audioEngine.audioContext.currentTime + time);\r\n } else {\r\n this._soundGain.gain.value = newVolume;\r\n }\r\n }\r\n this._volume = newVolume;\r\n }\r\n\r\n /**\r\n * Set the sound play back rate\r\n * @param newPlaybackRate Define the playback rate the sound should be played at\r\n */\r\n public setPlaybackRate(newPlaybackRate: number): void {\r\n this._playbackRate = newPlaybackRate;\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n } else if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sound play back rate.\r\n * @returns the play back rate of the sound\r\n */\r\n public getPlaybackRate(): number {\r\n return this._playbackRate;\r\n }\r\n\r\n /**\r\n * Gets the volume of the sound.\r\n * @returns the volume of the sound\r\n */\r\n public getVolume(): number {\r\n return this._volume;\r\n }\r\n\r\n /**\r\n * Attach the sound to a dedicated mesh\r\n * @param transformNode The transform node to connect the sound with\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public attachToMesh(transformNode: TransformNode): void {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n this._connectedTransformNode = transformNode;\r\n if (!this._spatialSound) {\r\n this._spatialSound = true;\r\n this._createSpatialParameters();\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);\r\n this._registerFunc = (transformNode: TransformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);\r\n this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);\r\n }\r\n\r\n /**\r\n * Detach the sound from the previously attached mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public detachFromMesh() {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n\r\n private _onRegisterAfterWorldMatrixUpdate(node: TransformNode): void {\r\n if (!(<any>node).getBoundingInfo) {\r\n this.setPosition(node.absolutePosition);\r\n } else {\r\n const mesh = node as AbstractMesh;\r\n const boundingInfo = mesh.getBoundingInfo();\r\n this.setPosition(boundingInfo.boundingSphere.centerWorld);\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current sound in the scene.\r\n * @returns the new sound clone\r\n */\r\n public clone(): Nullable<Sound> {\r\n if (!this._streaming) {\r\n const setBufferAndRun = () => {\r\n if (this._isReadyToPlay) {\r\n clonedSound._audioBuffer = this.getAudioBuffer();\r\n clonedSound._isReadyToPlay = true;\r\n if (clonedSound.autoplay) {\r\n clonedSound.play(0, this._offset, this._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n const currentOptions = {\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n useCustomAttenuation: this.useCustomAttenuation,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n };\r\n\r\n const clonedSound = new Sound(this.name + \"_cloned\", new ArrayBuffer(0), this._scene, null, currentOptions);\r\n if (this.useCustomAttenuation) {\r\n clonedSound.setAttenuationFunction(this._customAttenuationFunction);\r\n }\r\n clonedSound.setPosition(this._position);\r\n clonedSound.setPlaybackRate(this._playbackRate);\r\n setBufferAndRun();\r\n\r\n return clonedSound;\r\n }\r\n // Can't clone a streaming sound\r\n else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current underlying audio buffer containing the data\r\n * @returns the audio buffer\r\n */\r\n public getAudioBuffer(): Nullable<AudioBuffer> {\r\n return this._audioBuffer;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.\r\n * @returns the source node\r\n */\r\n public getSoundSource(): Nullable<AudioBufferSourceNode> {\r\n return this._soundSource;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.\r\n * @returns the gain node\r\n */\r\n public getSoundGain(): Nullable<GainNode> {\r\n return this._soundGain;\r\n }\r\n\r\n /**\r\n * Serializes the Sound in a JSON representation\r\n * @returns the JSON representation of the sound\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {\r\n name: this.name,\r\n url: this.name,\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n playbackRate: this._playbackRate,\r\n panningModel: this._panningModel,\r\n soundTrackId: this.soundTrackId,\r\n metadata: this.metadata,\r\n };\r\n\r\n if (this._spatialSound) {\r\n if (this._connectedTransformNode) {\r\n serializationObject.connectedMeshId = this._connectedTransformNode.id;\r\n }\r\n\r\n serializationObject.position = this._position.asArray();\r\n serializationObject.refDistance = this.refDistance;\r\n serializationObject.distanceModel = this.distanceModel;\r\n\r\n serializationObject.isDirectional = this._isDirectional;\r\n serializationObject.localDirectionToMesh = this._localDirection.asArray();\r\n serializationObject.coneInnerAngle = this._coneInnerAngle;\r\n serializationObject.coneOuterAngle = this._coneOuterAngle;\r\n serializationObject.coneOuterGain = this._coneOuterGain;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse a JSON representation of a sound to instantiate in a given scene\r\n * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)\r\n * @param scene Define the scene the new parsed sound should be created in\r\n * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies\r\n * @param sourceSound Define a sound place holder if do not need to instantiate a new one\r\n * @returns the newly parsed sound\r\n */\r\n public static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound {\r\n const soundName = parsedSound.name;\r\n let soundUrl;\r\n\r\n if (parsedSound.url) {\r\n soundUrl = rootUrl + parsedSound.url;\r\n } else {\r\n soundUrl = rootUrl + soundName;\r\n }\r\n\r\n const options = {\r\n autoplay: parsedSound.autoplay,\r\n loop: parsedSound.loop,\r\n volume: parsedSound.volume,\r\n spatialSound: parsedSound.spatialSound,\r\n maxDistance: parsedSound.maxDistance,\r\n rolloffFactor: parsedSound.rolloffFactor,\r\n refDistance: parsedSound.refDistance,\r\n distanceModel: parsedSound.distanceModel,\r\n playbackRate: parsedSound.playbackRate,\r\n };\r\n\r\n let newSound: Sound;\r\n\r\n if (!sourceSound) {\r\n newSound = new Sound(\r\n soundName,\r\n soundUrl,\r\n scene,\r\n () => {\r\n scene.removePendingData(newSound);\r\n },\r\n options\r\n );\r\n scene.addPendingData(newSound);\r\n } else {\r\n const setBufferAndRun = () => {\r\n if (sourceSound._isReadyToPlay) {\r\n newSound._audioBuffer = sourceSound.getAudioBuffer();\r\n newSound._isReadyToPlay = true;\r\n if (newSound.autoplay) {\r\n newSound.play(0, newSound._offset, newSound._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);\r\n setBufferAndRun();\r\n }\r\n\r\n if (parsedSound.position) {\r\n const soundPosition = Vector3.FromArray(parsedSound.position);\r\n newSound.setPosition(soundPosition);\r\n }\r\n if (parsedSound.isDirectional) {\r\n newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);\r\n if (parsedSound.localDirectionToMesh) {\r\n const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);\r\n newSound.setLocalDirectionToMesh(localDirectionToMesh);\r\n }\r\n }\r\n if (parsedSound.connectedMeshId) {\r\n const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);\r\n if (connectedMesh) {\r\n newSound.attachToMesh(connectedMesh);\r\n }\r\n }\r\n\r\n if (parsedSound.metadata) {\r\n newSound.metadata = parsedSound.metadata;\r\n }\r\n\r\n return newSound;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sound.js","sourceRoot":"","sources":["../../../../lts/core/generated/Audio/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAyJd;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,gBAAqB,EAAE,KAAuB,EAAE,sBAA4C,IAAI,EAAE,OAAuB;;QA5JnJ;;WAEG;QACI,aAAQ,GAAY,KAAK,CAAC;QAEzB,UAAK,GAAG,KAAK,CAAC;QAiBtB;;;;WAIG;QACI,yBAAoB,GAAY,KAAK,CAAC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;AAvjCD;;GAEG;AACW,mCAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { ISoundOptions } from \"./Interfaces/ISoundOptions\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Defines a sound that can be played in the application.\r\n * The sound can either be an ambient track or a simple sound played in reaction to a user action.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class Sound {\r\n /**\r\n * The name of the sound in the scene.\r\n */\r\n public name: string;\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n public autoplay: boolean = false;\r\n\r\n private _loop = false;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n public get loop(): boolean {\r\n return this._loop;\r\n }\r\n\r\n public set loop(value: boolean) {\r\n if (value === this._loop) {\r\n return;\r\n }\r\n\r\n this._loop = value;\r\n this.updateOptions({ loop: value });\r\n }\r\n\r\n /**\r\n * Does the sound use a custom attenuation curve to simulate the falloff\r\n * happening when the source gets further away from the camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public useCustomAttenuation: boolean = false;\r\n /**\r\n * The sound track id this sound belongs to.\r\n */\r\n public soundTrackId: number;\r\n /**\r\n * Is this sound currently played.\r\n */\r\n public isPlaying: boolean = false;\r\n /**\r\n * Is this sound currently paused.\r\n */\r\n public isPaused: boolean = false;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public refDistance: number = 1;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public rolloffFactor: number = 1;\r\n /**\r\n * Define the max distance the sound should be heard (intensity just became 0 at this point).\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public maxDistance: number = 100;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public distanceModel: string = \"linear\";\r\n /**\r\n * @internal\r\n * Back Compat\r\n **/\r\n public onended: () => any;\r\n /**\r\n * Gets or sets an object used to store user defined information for the sound.\r\n */\r\n public metadata: any = null;\r\n\r\n /**\r\n * Observable event when the current playing sound finishes.\r\n */\r\n public onEndedObservable = new Observable<Sound>();\r\n\r\n /**\r\n * Gets the current time for the sound.\r\n */\r\n public get currentTime(): number {\r\n if (this._htmlAudioElement) {\r\n return this._htmlAudioElement.currentTime;\r\n }\r\n\r\n let currentTime: number = this._startOffset;\r\n if (this.isPlaying && Engine.audioEngine?.audioContext) {\r\n currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n return currentTime;\r\n }\r\n\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public get spatialSound(): boolean {\r\n return this._spatialSound;\r\n }\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public set spatialSound(newValue: boolean) {\r\n this._spatialSound = newValue;\r\n if (this._spatialSound && Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._createSpatialParameters();\r\n }\r\n }\r\n private _spatialSound: boolean = false;\r\n private _panningModel: string = \"equalpower\";\r\n private _playbackRate: number = 1;\r\n private _streaming: boolean = false;\r\n private _startTime: number = 0;\r\n private _startOffset: number = 0;\r\n private _position: Vector3 = Vector3.Zero();\r\n private _localDirection: Vector3 = new Vector3(1, 0, 0);\r\n private _volume: number = 1;\r\n private _isReadyToPlay: boolean = false;\r\n private _isDirectional: boolean = false;\r\n private _readyToPlayCallback: Nullable<() => any>;\r\n private _audioBuffer: Nullable<AudioBuffer>;\r\n private _soundSource: Nullable<AudioBufferSourceNode>;\r\n private _streamingSource: AudioNode;\r\n private _soundPanner: Nullable<PannerNode>;\r\n private _soundGain: Nullable<GainNode>;\r\n private _inputAudioNode: Nullable<AudioNode>;\r\n private _outputAudioNode: Nullable<AudioNode>;\r\n // Used if you'd like to create a directional sound.\r\n // If not set, the sound will be omnidirectional\r\n private _coneInnerAngle: number = 360;\r\n private _coneOuterAngle: number = 360;\r\n private _coneOuterGain: number = 0;\r\n private _scene: Scene;\r\n private _connectedTransformNode: Nullable<TransformNode>;\r\n private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;\r\n private _registerFunc: Nullable<(connectedMesh: TransformNode) => void>;\r\n private _isOutputConnected = false;\r\n private _htmlAudioElement: HTMLAudioElement;\r\n private _urlType: \"Unknown\" | \"String\" | \"Array\" | \"ArrayBuffer\" | \"MediaStream\" | \"AudioBuffer\" | \"MediaElement\" = \"Unknown\";\r\n private _length?: number;\r\n private _offset?: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"AudioSceneComponent\");\r\n };\r\n\r\n /**\r\n * Create a sound and attach it to a scene\r\n * @param name Name of your sound\r\n * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers\r\n * @param scene defines the scene the sound belongs to\r\n * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played\r\n * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming\r\n */\r\n constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback: Nullable<() => void> = null, options?: ISoundOptions) {\r\n this.name = name;\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n Sound._SceneComponentInitialization(scene);\r\n\r\n this._readyToPlayCallback = readyToPlayCallback;\r\n // Default custom attenuation function is a linear attenuation\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {\r\n if (currentDistance < maxDistance) {\r\n return currentVolume * (1 - currentDistance / maxDistance);\r\n } else {\r\n return 0;\r\n }\r\n };\r\n if (options) {\r\n this.autoplay = options.autoplay || false;\r\n this._loop = options.loop || false;\r\n // if volume === 0, we need another way to check this option\r\n if (options.volume !== undefined) {\r\n this._volume = options.volume;\r\n }\r\n this._spatialSound = options.spatialSound ?? false;\r\n this.maxDistance = options.maxDistance ?? 100;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? false;\r\n this.rolloffFactor = options.rolloffFactor || 1;\r\n this.refDistance = options.refDistance || 1;\r\n this.distanceModel = options.distanceModel || \"linear\";\r\n this._playbackRate = options.playbackRate || 1;\r\n this._streaming = options.streaming ?? false;\r\n this._length = options.length;\r\n this._offset = options.offset;\r\n }\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._soundGain = Engine.audioEngine.audioContext.createGain();\r\n this._soundGain!.gain.value = this._volume;\r\n this._inputAudioNode = this._soundGain;\r\n this._outputAudioNode = this._soundGain;\r\n if (this._spatialSound) {\r\n this._createSpatialParameters();\r\n }\r\n this._scene.mainSoundTrack.addSound(this);\r\n let validParameter = true;\r\n\r\n // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound\r\n if (urlOrArrayBuffer) {\r\n try {\r\n if (typeof urlOrArrayBuffer === \"string\") {\r\n this._urlType = \"String\";\r\n } else if (urlOrArrayBuffer instanceof ArrayBuffer) {\r\n this._urlType = \"ArrayBuffer\";\r\n } else if (urlOrArrayBuffer instanceof HTMLMediaElement) {\r\n this._urlType = \"MediaElement\";\r\n } else if (urlOrArrayBuffer instanceof MediaStream) {\r\n this._urlType = \"MediaStream\";\r\n } else if (urlOrArrayBuffer instanceof AudioBuffer) {\r\n this._urlType = \"AudioBuffer\";\r\n } else if (Array.isArray(urlOrArrayBuffer)) {\r\n this._urlType = \"Array\";\r\n }\r\n\r\n let urls: string[] = [];\r\n let codecSupportedFound = false;\r\n\r\n switch (this._urlType) {\r\n case \"MediaElement\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"MediaStream\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"ArrayBuffer\":\r\n if ((<ArrayBuffer>urlOrArrayBuffer).byteLength > 0) {\r\n codecSupportedFound = true;\r\n this._soundLoaded(urlOrArrayBuffer);\r\n }\r\n break;\r\n case \"AudioBuffer\":\r\n this._audioBufferLoaded(urlOrArrayBuffer);\r\n break;\r\n case \"String\":\r\n urls.push(urlOrArrayBuffer);\r\n // eslint-disable-next-line no-fallthrough\r\n case \"Array\":\r\n if (urls.length === 0) {\r\n urls = urlOrArrayBuffer;\r\n }\r\n // If we found a supported format, we load it immediately and stop the loop\r\n for (let i = 0; i < urls.length; i++) {\r\n const url = urls[i];\r\n codecSupportedFound =\r\n (options && options.skipCodecCheck) ||\r\n (url.indexOf(\".mp3\", url.length - 4) !== -1 && Engine.audioEngine.isMP3supported) ||\r\n (url.indexOf(\".ogg\", url.length - 4) !== -1 && Engine.audioEngine.isOGGsupported) ||\r\n url.indexOf(\".wav\", url.length - 4) !== -1 ||\r\n url.indexOf(\".m4a\", url.length - 4) !== -1 ||\r\n url.indexOf(\".mp4\", url.length - 4) !== -1 ||\r\n url.indexOf(\"blob:\") !== -1;\r\n if (codecSupportedFound) {\r\n // Loading sound\r\n if (!this._streaming) {\r\n this._scene._loadFile(\r\n url,\r\n (data) => {\r\n this._soundLoaded(data as ArrayBuffer);\r\n },\r\n undefined,\r\n true,\r\n true,\r\n (exception) => {\r\n if (exception) {\r\n Logger.Error(\"XHR \" + exception.status + \" error on: \" + url + \".\");\r\n }\r\n Logger.Error(\"Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n );\r\n }\r\n // Streaming sound using HTML5 Audio tag\r\n else {\r\n this._htmlAudioElement = new Audio(url);\r\n this._htmlAudioElement.controls = false;\r\n this._htmlAudioElement.loop = this.loop;\r\n Tools.SetCorsBehavior(url, this._htmlAudioElement);\r\n this._htmlAudioElement.preload = \"auto\";\r\n this._htmlAudioElement.addEventListener(\"canplaythrough\", () => {\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n });\r\n document.body.appendChild(this._htmlAudioElement);\r\n this._htmlAudioElement.load();\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n default:\r\n validParameter = false;\r\n break;\r\n }\r\n\r\n if (!validParameter) {\r\n Logger.Error(\"Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.\");\r\n } else {\r\n if (!codecSupportedFound) {\r\n this._isReadyToPlay = true;\r\n // Simulating a ready to play event to avoid breaking code path\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n } catch (ex) {\r\n Logger.Error(\"Unexpected error. Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n }\r\n } else {\r\n // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers\r\n this._scene.mainSoundTrack.addSound(this);\r\n if (Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported) {\r\n Logger.Error(\"Web Audio is not supported by your browser.\");\r\n Engine.audioEngine.WarnedWebAudioUnsupported = true;\r\n }\r\n // Simulating a ready to play event to avoid breaking code for non web audio browsers\r\n if (this._readyToPlayCallback) {\r\n setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound and its associated resources\r\n */\r\n public dispose() {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (this.isPlaying) {\r\n this.stop();\r\n }\r\n this._isReadyToPlay = false;\r\n if (this.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(this);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[this.soundTrackId].removeSound(this);\r\n }\r\n if (this._soundGain) {\r\n this._soundGain.disconnect();\r\n this._soundGain = null;\r\n }\r\n if (this._soundPanner) {\r\n this._soundPanner.disconnect();\r\n this._soundPanner = null;\r\n }\r\n if (this._soundSource) {\r\n this._soundSource.disconnect();\r\n this._soundSource = null;\r\n }\r\n this._audioBuffer = null;\r\n\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n this._htmlAudioElement.src = \"\";\r\n document.body.removeChild(this._htmlAudioElement);\r\n }\r\n\r\n if (this._streamingSource) {\r\n this._streamingSource.disconnect();\r\n }\r\n\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the sounds is ready to be played or not.\r\n * @returns true if ready, otherwise false\r\n */\r\n public isReady(): boolean {\r\n return this._isReadyToPlay;\r\n }\r\n\r\n /**\r\n * Get the current class name.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return \"Sound\";\r\n }\r\n\r\n private _audioBufferLoaded(buffer: AudioBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n this._audioBuffer = buffer;\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }\r\n\r\n private _soundLoaded(audioData: ArrayBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n Engine.audioEngine.audioContext.decodeAudioData(\r\n audioData,\r\n (buffer) => {\r\n this._audioBufferLoaded(buffer);\r\n },\r\n (err: any) => {\r\n Logger.Error(\"Error while decoding audio data for: \" + this.name + \" / Error: \" + err);\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Sets the data of the sound from an audiobuffer\r\n * @param audioBuffer The audioBuffer containing the data\r\n */\r\n public setAudioBuffer(audioBuffer: AudioBuffer): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n this._audioBuffer = audioBuffer;\r\n this._isReadyToPlay = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the current sounds options such as maxdistance, loop...\r\n * @param options A JSON object containing values named as the object properties\r\n */\r\n public updateOptions(options: ISoundOptions): void {\r\n if (options) {\r\n this.loop = options.loop ?? this.loop;\r\n this.maxDistance = options.maxDistance ?? this.maxDistance;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;\r\n this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;\r\n this.refDistance = options.refDistance ?? this.refDistance;\r\n this.distanceModel = options.distanceModel ?? this.distanceModel;\r\n this._playbackRate = options.playbackRate ?? this._playbackRate;\r\n this._length = options.length ?? undefined;\r\n this._setOffset(options.offset ?? undefined);\r\n this.setVolume(options.volume ?? this._volume);\r\n this._updateSpatialParameters();\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n if (this._htmlAudioElement.loop !== this.loop) {\r\n this._htmlAudioElement.loop = this.loop;\r\n }\r\n } else {\r\n if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n if (this._soundSource.loop !== this.loop) {\r\n this._soundSource.loop = this.loop;\r\n }\r\n if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {\r\n this._soundSource.loopStart = this._offset;\r\n }\r\n if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {\r\n this._soundSource.loopEnd = (this._offset! | 0) + this._length!;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _createSpatialParameters() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n if (this._scene.headphone) {\r\n this._panningModel = \"HRTF\";\r\n }\r\n this._soundPanner = this._soundPanner ?? Engine.audioEngine.audioContext.createPanner();\r\n if (this._soundPanner && this._outputAudioNode) {\r\n this._updateSpatialParameters();\r\n this._soundPanner.connect(this._outputAudioNode);\r\n this._inputAudioNode = this._soundPanner;\r\n }\r\n }\r\n }\r\n\r\n private _updateSpatialParameters() {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (this.useCustomAttenuation) {\r\n // Tricks to disable in a way embedded Web Audio attenuation\r\n this._soundPanner.distanceModel = \"linear\";\r\n this._soundPanner.maxDistance = Number.MAX_VALUE;\r\n this._soundPanner.refDistance = 1;\r\n this._soundPanner.rolloffFactor = 1;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n } else {\r\n this._soundPanner.distanceModel = this.distanceModel as any;\r\n this._soundPanner.maxDistance = this.maxDistance;\r\n this._soundPanner.refDistance = this.refDistance;\r\n this._soundPanner.rolloffFactor = this.rolloffFactor;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF() {\r\n this._panningModel = \"HRTF\";\r\n this._switchPanningModel();\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower() {\r\n this._panningModel = \"equalpower\";\r\n this._switchPanningModel();\r\n }\r\n\r\n private _switchPanningModel() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this sound to a sound track audio node like gain...\r\n * @param soundTrackAudioNode the sound track audio node to connect to\r\n */\r\n public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n if (this._isOutputConnected) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode.connect(soundTrackAudioNode);\r\n this._isOutputConnected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Transform this sound into a directional source\r\n * @param coneInnerAngle Size of the inner cone in degree\r\n * @param coneOuterAngle Size of the outer cone in degree\r\n * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)\r\n */\r\n public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {\r\n if (coneOuterAngle < coneInnerAngle) {\r\n Logger.Error(\"setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n this._coneInnerAngle = coneInnerAngle;\r\n this._coneOuterAngle = coneOuterAngle;\r\n this._coneOuterGain = coneOuterGain;\r\n this._isDirectional = true;\r\n\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public get directionalConeInnerAngle(): number {\r\n return this._coneInnerAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public set directionalConeInnerAngle(value: number) {\r\n if (value != this._coneInnerAngle) {\r\n if (this._coneOuterAngle < value) {\r\n Logger.Error(\"directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneInnerAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public get directionalConeOuterAngle(): number {\r\n return this._coneOuterAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public set directionalConeOuterAngle(value: number) {\r\n if (value != this._coneOuterAngle) {\r\n if (value < this._coneInnerAngle) {\r\n Logger.Error(\"directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneOuterAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the position of the emitter if spatial sound is enabled\r\n * @param newPosition Defines the new position\r\n */\r\n public setPosition(newPosition: Vector3): void {\r\n if (newPosition.equals(this._position)) {\r\n return;\r\n }\r\n this._position.copyFrom(newPosition);\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the local direction of the emitter if spatial sound is enabled\r\n * @param newLocalDirection Defines the new local direction\r\n */\r\n public setLocalDirectionToMesh(newLocalDirection: Vector3): void {\r\n this._localDirection = newLocalDirection;\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n private _updateDirection() {\r\n if (!this._connectedTransformNode || !this._soundPanner) {\r\n return;\r\n }\r\n\r\n const mat = this._connectedTransformNode.getWorldMatrix();\r\n const direction = Vector3.TransformNormal(this._localDirection, mat);\r\n direction.normalize();\r\n this._soundPanner.orientationX.value = direction.x;\r\n this._soundPanner.orientationY.value = direction.y;\r\n this._soundPanner.orientationZ.value = direction.z;\r\n }\r\n\r\n /** @internal */\r\n public updateDistanceFromListener() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {\r\n const distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);\r\n this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);\r\n }\r\n }\r\n\r\n /**\r\n * Sets a new custom attenuation function for the sound.\r\n * @param callback Defines the function used for the attenuation\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function\r\n */\r\n public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void {\r\n this._customAttenuationFunction = callback;\r\n }\r\n\r\n /**\r\n * Play the sound\r\n * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.\r\n * @param offset (optional) Start the sound at a specific time in seconds\r\n * @param length (optional) Sound duration (in seconds)\r\n */\r\n public play(time?: number, offset?: number, length?: number): void {\r\n if (this._isReadyToPlay && this._scene.audioEnabled && Engine.audioEngine?.audioContext) {\r\n try {\r\n if (this._startOffset < 0) {\r\n time = -this._startOffset;\r\n this._startOffset = 0;\r\n }\r\n let startTime = time ? Engine.audioEngine?.audioContext.currentTime + time : Engine.audioEngine?.audioContext.currentTime;\r\n if (!this._soundSource || !this._streamingSource) {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n if (this._isDirectional) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n this._soundPanner.coneOuterGain = this._coneOuterGain;\r\n if (this._connectedTransformNode) {\r\n this._updateDirection();\r\n } else {\r\n this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);\r\n }\r\n }\r\n }\r\n }\r\n if (this._streaming) {\r\n if (!this._streamingSource) {\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);\r\n this._htmlAudioElement.onended = () => {\r\n this._onended();\r\n };\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n }\r\n this._streamingSource.disconnect();\r\n if (this._inputAudioNode) {\r\n this._streamingSource.connect(this._inputAudioNode);\r\n }\r\n if (this._htmlAudioElement) {\r\n // required to manage properly the new suspended default state of Chrome\r\n // When the option 'streaming: true' is used, we need first to wait for\r\n // the audio engine to be unlocked by a user gesture before trying to play\r\n // an HTML Audio element\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.unlocked) {\r\n const playPromise = this._htmlAudioElement.play();\r\n\r\n // In browsers that don’t yet support this functionality,\r\n // playPromise won’t be defined.\r\n if (playPromise !== undefined) {\r\n playPromise.catch(() => {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine?.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n });\r\n }\r\n } else {\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n }\r\n };\r\n tryToPlay();\r\n }\r\n } else {\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.audioContext) {\r\n length = length || this._length;\r\n\r\n if (offset !== undefined) {\r\n this._setOffset(offset);\r\n }\r\n\r\n if (this._soundSource) {\r\n const oldSource = this._soundSource;\r\n oldSource.onended = () => {\r\n oldSource.disconnect();\r\n };\r\n }\r\n this._soundSource = Engine.audioEngine?.audioContext.createBufferSource();\r\n if (this._soundSource && this._inputAudioNode) {\r\n this._soundSource.buffer = this._audioBuffer;\r\n this._soundSource.connect(this._inputAudioNode);\r\n this._soundSource.loop = this.loop;\r\n if (offset !== undefined) {\r\n this._soundSource.loopStart = offset;\r\n }\r\n if (length !== undefined) {\r\n this._soundSource.loopEnd = (offset! | 0) + length!;\r\n }\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n this._soundSource.onended = () => {\r\n this._onended();\r\n };\r\n startTime = time ? Engine.audioEngine?.audioContext!.currentTime + time : Engine.audioEngine.audioContext!.currentTime;\r\n const actualOffset = ((this.isPaused ? this._startOffset : 0) + (this._offset ?? 0)) % this._soundSource!.buffer!.duration;\r\n this._soundSource!.start(startTime, actualOffset, this.loop ? undefined : length);\r\n }\r\n }\r\n };\r\n\r\n if (Engine.audioEngine?.audioContext.state === \"suspended\") {\r\n // Wait a bit for FF as context seems late to be ready.\r\n setTimeout(() => {\r\n if (Engine.audioEngine?.audioContext!.state === \"suspended\") {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n } else {\r\n tryToPlay();\r\n }\r\n }, 500);\r\n } else {\r\n tryToPlay();\r\n }\r\n }\r\n this._startTime = startTime;\r\n this.isPlaying = true;\r\n this.isPaused = false;\r\n } catch (ex) {\r\n Logger.Error(\"Error while trying to play audio: \" + this.name + \", \" + ex.message);\r\n }\r\n }\r\n }\r\n\r\n private _onended() {\r\n this.isPlaying = false;\r\n this._startOffset = 0;\r\n if (this.onended) {\r\n this.onended();\r\n }\r\n this.onEndedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Stop the sound\r\n * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.\r\n */\r\n public stop(time?: number): void {\r\n if (this.isPlaying) {\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n // Test needed for Firefox or it will generate an Invalid State Error\r\n if (this._htmlAudioElement.currentTime > 0) {\r\n this._htmlAudioElement.currentTime = 0;\r\n }\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n const stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : undefined;\r\n this._soundSource.stop(stopTime);\r\n if (stopTime === undefined) {\r\n this.isPlaying = false;\r\n this._soundSource.onended = () => void 0;\r\n } else {\r\n this._soundSource.onended = () => {\r\n this.isPlaying = false;\r\n };\r\n }\r\n if (!this.isPaused) {\r\n this._startOffset = 0;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Put the sound in pause\r\n */\r\n public pause(): void {\r\n if (this.isPlaying) {\r\n this.isPaused = true;\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext) {\r\n this.stop(0);\r\n this._startOffset += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets a dedicated volume for this sounds\r\n * @param newVolume Define the new volume of the sound\r\n * @param time Define time for gradual change to new volume\r\n */\r\n public setVolume(newVolume: number, time?: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._soundGain) {\r\n if (time && Engine.audioEngine.audioContext) {\r\n this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.linearRampToValueAtTime(newVolume, Engine.audioEngine.audioContext.currentTime + time);\r\n } else {\r\n this._soundGain.gain.value = newVolume;\r\n }\r\n }\r\n this._volume = newVolume;\r\n }\r\n\r\n /**\r\n * Set the sound play back rate\r\n * @param newPlaybackRate Define the playback rate the sound should be played at\r\n */\r\n public setPlaybackRate(newPlaybackRate: number): void {\r\n this._playbackRate = newPlaybackRate;\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n } else if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sound play back rate.\r\n * @returns the play back rate of the sound\r\n */\r\n public getPlaybackRate(): number {\r\n return this._playbackRate;\r\n }\r\n\r\n /**\r\n * Gets the volume of the sound.\r\n * @returns the volume of the sound\r\n */\r\n public getVolume(): number {\r\n return this._volume;\r\n }\r\n\r\n /**\r\n * Attach the sound to a dedicated mesh\r\n * @param transformNode The transform node to connect the sound with\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public attachToMesh(transformNode: TransformNode): void {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n this._connectedTransformNode = transformNode;\r\n if (!this._spatialSound) {\r\n this._spatialSound = true;\r\n this._createSpatialParameters();\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);\r\n this._registerFunc = (transformNode: TransformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);\r\n this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);\r\n }\r\n\r\n /**\r\n * Detach the sound from the previously attached mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh\r\n */\r\n public detachFromMesh() {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n\r\n private _onRegisterAfterWorldMatrixUpdate(node: TransformNode): void {\r\n if (!(<any>node).getBoundingInfo) {\r\n this.setPosition(node.absolutePosition);\r\n } else {\r\n const mesh = node as AbstractMesh;\r\n const boundingInfo = mesh.getBoundingInfo();\r\n this.setPosition(boundingInfo.boundingSphere.centerWorld);\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current sound in the scene.\r\n * @returns the new sound clone\r\n */\r\n public clone(): Nullable<Sound> {\r\n if (!this._streaming) {\r\n const setBufferAndRun = () => {\r\n if (this._isReadyToPlay) {\r\n clonedSound._audioBuffer = this.getAudioBuffer();\r\n clonedSound._isReadyToPlay = true;\r\n if (clonedSound.autoplay) {\r\n clonedSound.play(0, this._offset, this._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n const currentOptions = {\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n useCustomAttenuation: this.useCustomAttenuation,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n };\r\n\r\n const clonedSound = new Sound(this.name + \"_cloned\", new ArrayBuffer(0), this._scene, null, currentOptions);\r\n if (this.useCustomAttenuation) {\r\n clonedSound.setAttenuationFunction(this._customAttenuationFunction);\r\n }\r\n clonedSound.setPosition(this._position);\r\n clonedSound.setPlaybackRate(this._playbackRate);\r\n setBufferAndRun();\r\n\r\n return clonedSound;\r\n }\r\n // Can't clone a streaming sound\r\n else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current underlying audio buffer containing the data\r\n * @returns the audio buffer\r\n */\r\n public getAudioBuffer(): Nullable<AudioBuffer> {\r\n return this._audioBuffer;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.\r\n * @returns the source node\r\n */\r\n public getSoundSource(): Nullable<AudioBufferSourceNode> {\r\n return this._soundSource;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.\r\n * @returns the gain node\r\n */\r\n public getSoundGain(): Nullable<GainNode> {\r\n return this._soundGain;\r\n }\r\n\r\n /**\r\n * Serializes the Sound in a JSON representation\r\n * @returns the JSON representation of the sound\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {\r\n name: this.name,\r\n url: this.name,\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n playbackRate: this._playbackRate,\r\n panningModel: this._panningModel,\r\n soundTrackId: this.soundTrackId,\r\n metadata: this.metadata,\r\n };\r\n\r\n if (this._spatialSound) {\r\n if (this._connectedTransformNode) {\r\n serializationObject.connectedMeshId = this._connectedTransformNode.id;\r\n }\r\n\r\n serializationObject.position = this._position.asArray();\r\n serializationObject.refDistance = this.refDistance;\r\n serializationObject.distanceModel = this.distanceModel;\r\n\r\n serializationObject.isDirectional = this._isDirectional;\r\n serializationObject.localDirectionToMesh = this._localDirection.asArray();\r\n serializationObject.coneInnerAngle = this._coneInnerAngle;\r\n serializationObject.coneOuterAngle = this._coneOuterAngle;\r\n serializationObject.coneOuterGain = this._coneOuterGain;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse a JSON representation of a sound to instantiate in a given scene\r\n * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)\r\n * @param scene Define the scene the new parsed sound should be created in\r\n * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies\r\n * @param sourceSound Define a sound place holder if do not need to instantiate a new one\r\n * @returns the newly parsed sound\r\n */\r\n public static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound {\r\n const soundName = parsedSound.name;\r\n let soundUrl;\r\n\r\n if (parsedSound.url) {\r\n soundUrl = rootUrl + parsedSound.url;\r\n } else {\r\n soundUrl = rootUrl + soundName;\r\n }\r\n\r\n const options = {\r\n autoplay: parsedSound.autoplay,\r\n loop: parsedSound.loop,\r\n volume: parsedSound.volume,\r\n spatialSound: parsedSound.spatialSound,\r\n maxDistance: parsedSound.maxDistance,\r\n rolloffFactor: parsedSound.rolloffFactor,\r\n refDistance: parsedSound.refDistance,\r\n distanceModel: parsedSound.distanceModel,\r\n playbackRate: parsedSound.playbackRate,\r\n };\r\n\r\n let newSound: Sound;\r\n\r\n if (!sourceSound) {\r\n newSound = new Sound(\r\n soundName,\r\n soundUrl,\r\n scene,\r\n () => {\r\n scene.removePendingData(newSound);\r\n },\r\n options\r\n );\r\n scene.addPendingData(newSound);\r\n } else {\r\n const setBufferAndRun = () => {\r\n if (sourceSound._isReadyToPlay) {\r\n newSound._audioBuffer = sourceSound.getAudioBuffer();\r\n newSound._isReadyToPlay = true;\r\n if (newSound.autoplay) {\r\n newSound.play(0, newSound._offset, newSound._length);\r\n }\r\n } else {\r\n setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);\r\n setBufferAndRun();\r\n }\r\n\r\n if (parsedSound.position) {\r\n const soundPosition = Vector3.FromArray(parsedSound.position);\r\n newSound.setPosition(soundPosition);\r\n }\r\n if (parsedSound.isDirectional) {\r\n newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);\r\n if (parsedSound.localDirectionToMesh) {\r\n const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);\r\n newSound.setLocalDirectionToMesh(localDirectionToMesh);\r\n }\r\n }\r\n if (parsedSound.connectedMeshId) {\r\n const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);\r\n if (connectedMesh) {\r\n newSound.attachToMesh(connectedMesh);\r\n }\r\n }\r\n\r\n if (parsedSound.metadata) {\r\n newSound.metadata = parsedSound.metadata;\r\n }\r\n\r\n return newSound;\r\n }\r\n\r\n private _setOffset(value?: number) {\r\n if (this._offset === value) {\r\n return;\r\n }\r\n if (this.isPaused) {\r\n this.stop();\r\n this.isPaused = false;\r\n }\r\n this._offset = value;\r\n }\r\n}\r\n"]}
@@ -171,6 +171,7 @@ interface INativeEngineConstructor {
171
171
  readonly COMMAND_DRAW: NativeData;
172
172
  readonly COMMAND_CLEAR: NativeData;
173
173
  readonly COMMAND_SETSTENCIL: NativeData;
174
+ readonly COMMAND_SETVIEWPORT: NativeData;
174
175
  }
175
176
  /** @internal */
176
177
  export interface INativeCamera {
@@ -1 +1 @@
1
- {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(buffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n copyTexture(desination: NativeTexture, source: NativeTexture): void;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBufferView | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(texture: Nullable<NativeTexture>, width: number, height: number, generateStencilBuffer: boolean, generateDepthBuffer: boolean): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n getHardwareScalingLevel(): number;\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n Engine: INativeEngineConstructor;\r\n Camera: INativeCameraConstructor;\r\n Canvas: INativeCanvasConstructor;\r\n Image: INativeImageConstructor;\r\n XMLHttpRequest: any; // TODO: how to do this?\r\n DeviceInputSystem: IDeviceInputSystemConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n}\r\n"]}
1
+ {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(buffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n copyTexture(desination: NativeTexture, source: NativeTexture): void;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBufferView | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(texture: Nullable<NativeTexture>, width: number, height: number, generateStencilBuffer: boolean, generateDepthBuffer: boolean): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n getHardwareScalingLevel(): number;\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n Engine: INativeEngineConstructor;\r\n Camera: INativeCameraConstructor;\r\n Canvas: INativeCanvasConstructor;\r\n Image: INativeImageConstructor;\r\n XMLHttpRequest: any; // TODO: how to do this?\r\n DeviceInputSystem: IDeviceInputSystemConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n}\r\n"]}
@@ -581,7 +581,12 @@ export class NativeEngine extends Engine {
581
581
  }
582
582
  setViewport(viewport, requiredWidth, requiredHeight) {
583
583
  this._cachedViewport = viewport;
584
- this._engine.setViewPort(viewport.x, viewport.y, viewport.width, viewport.height);
584
+ this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETVIEWPORT);
585
+ this._commandBufferEncoder.encodeCommandArgAsFloat32(viewport.x);
586
+ this._commandBufferEncoder.encodeCommandArgAsFloat32(viewport.y);
587
+ this._commandBufferEncoder.encodeCommandArgAsFloat32(viewport.width);
588
+ this._commandBufferEncoder.encodeCommandArgAsFloat32(viewport.height);
589
+ this._commandBufferEncoder.finishEncodingCommand();
585
590
  }
586
591
  setState(culling, zOffset = 0, force, reverseSide = false, cullBackFaces, stencil, zOffsetUnits = 0) {
587
592
  var _a, _b;
@@ -2121,5 +2126,5 @@ export class NativeEngine extends Engine {
2121
2126
  }
2122
2127
  }
2123
2128
  // This must match the protocol version in NativeEngine.cpp
2124
- NativeEngine.PROTOCOL_VERSION = 7;
2129
+ NativeEngine.PROTOCOL_VERSION = 8;
2125
2130
  //# sourceMappingURL=nativeEngine.js.map