|
@@ -9208,6 +9208,11 @@ var BABYLON;
|
|
|
document.msCancelFullScreen();
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
|
|
|
+ * @param url define the url we are trying
|
|
|
+ * @param element define the dom element where to configure the cors policy
|
|
|
+ */
|
|
|
Tools.SetCorsBehavior = function (url, element) {
|
|
|
if (url && url.indexOf("data:") === 0) {
|
|
|
return;
|
|
@@ -10535,14 +10540,14 @@ var BABYLON;
|
|
|
/**
|
|
|
* Create and run an async loop.
|
|
|
* @param iterations the number of iterations.
|
|
|
- * @param _fn the function to run each iteration
|
|
|
- * @param _successCallback the callback that will be called upon succesful execution
|
|
|
+ * @param fn the function to run each iteration
|
|
|
+ * @param successCallback the callback that will be called upon succesful execution
|
|
|
* @param offset starting offset.
|
|
|
* @returns the created async loop object
|
|
|
*/
|
|
|
- AsyncLoop.Run = function (iterations, _fn, _successCallback, offset) {
|
|
|
+ AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
|
|
|
if (offset === void 0) { offset = 0; }
|
|
|
- var loop = new AsyncLoop(iterations, _fn, _successCallback, offset);
|
|
|
+ var loop = new AsyncLoop(iterations, fn, successCallback, offset);
|
|
|
loop.executeNext();
|
|
|
return loop;
|
|
|
};
|
|
@@ -55583,6 +55588,9 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
var IntersectionInfo = /** @class */ (function () {
|
|
|
function IntersectionInfo(bu, bv, distance) {
|
|
|
this.bu = bu;
|
|
@@ -55596,7 +55604,7 @@ var BABYLON;
|
|
|
BABYLON.IntersectionInfo = IntersectionInfo;
|
|
|
/**
|
|
|
* Information about the result of picking within a scene
|
|
|
- * See https://doc.babylonjs.com/babylon101/picking_collisions
|
|
|
+ * @see https://doc.babylonjs.com/babylon101/picking_collisions
|
|
|
*/
|
|
|
var PickingInfo = /** @class */ (function () {
|
|
|
function PickingInfo() {
|
|
@@ -62981,15 +62989,36 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Component responsible of rendering the bounding box of the meshes in a scene.
|
|
|
+ * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
|
|
|
+ *
|
|
|
+ */
|
|
|
var BoundingBoxRenderer = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Instantiates a new bounding box renderer in a scene.
|
|
|
+ * @param scene the scene the renderer renders in
|
|
|
+ */
|
|
|
function BoundingBoxRenderer(scene) {
|
|
|
/**
|
|
|
* The component name helpfull to identify the component in the list of scene components.
|
|
|
*/
|
|
|
this.name = BABYLON.SceneComponentConstants.NAME_BOUNDINGBOXRENDERER;
|
|
|
+ /**
|
|
|
+ * Color of the bounding box lines placed in front of an object
|
|
|
+ */
|
|
|
this.frontColor = new BABYLON.Color3(1, 1, 1);
|
|
|
+ /**
|
|
|
+ * Color of the bounding box lines placed behind an object
|
|
|
+ */
|
|
|
this.backColor = new BABYLON.Color3(0.1, 0.1, 0.1);
|
|
|
+ /**
|
|
|
+ * Defines if the renderer should show the back lines or not
|
|
|
+ */
|
|
|
this.showBackLines = true;
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
this.renderList = new BABYLON.SmartArray(32);
|
|
|
this._vertexBuffers = {};
|
|
|
this.scene = scene;
|
|
@@ -63048,6 +63077,9 @@ var BABYLON;
|
|
|
}
|
|
|
this._createIndexBuffer();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
BoundingBoxRenderer.prototype.reset = function () {
|
|
|
this.renderList.reset();
|
|
|
};
|
|
@@ -63101,6 +63133,10 @@ var BABYLON;
|
|
|
engine.setDepthFunctionToLessOrEqual();
|
|
|
engine.setDepthWrite(true);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * In case of occlusion queries, we can render the occlusion bounding box through this method
|
|
|
+ * @param mesh Define the mesh to render the occlusion bounding box for
|
|
|
+ */
|
|
|
BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
|
|
|
this._prepareRessources();
|
|
|
if (!this._colorShader.isReady() || !mesh._boundingInfo) {
|
|
@@ -63128,6 +63164,9 @@ var BABYLON;
|
|
|
engine.setDepthWrite(true);
|
|
|
engine.setColorWrite(true);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Dispose and release the resources attached to this renderer.
|
|
|
+ */
|
|
|
BoundingBoxRenderer.prototype.dispose = function () {
|
|
|
if (!this._colorShader) {
|
|
|
return;
|
|
@@ -67336,7 +67375,6 @@ var BABYLON;
|
|
|
var _this = this;
|
|
|
this._audioContext = null;
|
|
|
this._audioContextInitialized = false;
|
|
|
- this._muteButtonDisplayed = false;
|
|
|
this._muteButton = null;
|
|
|
/**
|
|
|
* Gets whether the current host supports Web Audio and thus could create AudioContexts.
|
|
@@ -67360,7 +67398,7 @@ var BABYLON;
|
|
|
* Some Browsers have strong restrictions about Audio and won t autoplay unless
|
|
|
* a user interaction has happened.
|
|
|
*/
|
|
|
- this.unlocked = false;
|
|
|
+ this.unlocked = true;
|
|
|
/**
|
|
|
* Defines if the audio engine relies on a custom unlocked button.
|
|
|
* In this case, the embedded button will not be displayed.
|
|
@@ -67409,7 +67447,7 @@ var BABYLON;
|
|
|
this._initializeAudioContext();
|
|
|
}
|
|
|
else {
|
|
|
- if (!this.unlocked && !this._muteButtonDisplayed) {
|
|
|
+ if (!this.unlocked && !this._muteButton) {
|
|
|
this._displayMuteButton();
|
|
|
}
|
|
|
}
|
|
@@ -67433,9 +67471,11 @@ var BABYLON;
|
|
|
this._triggerRunningState();
|
|
|
};
|
|
|
AudioEngine.prototype._resumeAudioContext = function () {
|
|
|
+ var result;
|
|
|
if (this._audioContext.resume) {
|
|
|
- this._audioContext.resume();
|
|
|
+ result = this._audioContext.resume();
|
|
|
}
|
|
|
+ return result || Promise.resolve();
|
|
|
};
|
|
|
AudioEngine.prototype._initializeAudioContext = function () {
|
|
|
var _this = this;
|
|
@@ -67448,21 +67488,19 @@ var BABYLON;
|
|
|
this.masterGain.connect(this._audioContext.destination);
|
|
|
this._audioContextInitialized = true;
|
|
|
if (this._audioContext.state === "running") {
|
|
|
+ // Do not wait for the promise to unlock.
|
|
|
this._triggerRunningState();
|
|
|
}
|
|
|
else {
|
|
|
- if (!this._muteButtonDisplayed) {
|
|
|
- this._displayMuteButton();
|
|
|
- }
|
|
|
- // 3 possible states: https://webaudio.github.io/web-audio-api/#BaseAudioContext
|
|
|
- this._audioContext.addEventListener("statechange", function () {
|
|
|
- if (_this._audioContext.state === "running") {
|
|
|
+ if (this._audioContext && this._audioContext.resume) {
|
|
|
+ this._resumeAudioContext().then(function () {
|
|
|
_this._triggerRunningState();
|
|
|
- }
|
|
|
- else {
|
|
|
- _this._triggerSuspendedState();
|
|
|
- }
|
|
|
- });
|
|
|
+ }).catch(function () {
|
|
|
+ // Can not resume automatically
|
|
|
+ // Needs user action
|
|
|
+ _this.lock();
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -67472,13 +67510,18 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
AudioEngine.prototype._triggerRunningState = function () {
|
|
|
- this._resumeAudioContext();
|
|
|
- this.unlocked = true;
|
|
|
- if (this._muteButtonDisplayed) {
|
|
|
- this._hideMuteButton();
|
|
|
- }
|
|
|
- // Notify users that the audio stack is unlocked/unmuted
|
|
|
- this.onAudioUnlockedObservable.notifyObservers(this);
|
|
|
+ var _this = this;
|
|
|
+ this._resumeAudioContext()
|
|
|
+ .then(function () {
|
|
|
+ _this.unlocked = true;
|
|
|
+ if (_this._muteButton) {
|
|
|
+ _this._hideMuteButton();
|
|
|
+ }
|
|
|
+ // Notify users that the audio stack is unlocked/unmuted
|
|
|
+ _this.onAudioUnlockedObservable.notifyObservers(_this);
|
|
|
+ }).catch(function () {
|
|
|
+ _this.unlocked = false;
|
|
|
+ });
|
|
|
};
|
|
|
AudioEngine.prototype._triggerSuspendedState = function () {
|
|
|
this.unlocked = false;
|
|
@@ -67507,7 +67550,6 @@ var BABYLON;
|
|
|
this._muteButton.addEventListener('touchend', function () {
|
|
|
_this._triggerRunningState();
|
|
|
}, false);
|
|
|
- this._muteButtonDisplayed = true;
|
|
|
window.addEventListener("resize", this._onResize);
|
|
|
};
|
|
|
AudioEngine.prototype._moveButtonToTopLeft = function () {
|
|
@@ -67517,9 +67559,9 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
AudioEngine.prototype._hideMuteButton = function () {
|
|
|
- if (this._muteButtonDisplayed && this._muteButton) {
|
|
|
+ if (this._muteButton) {
|
|
|
document.body.removeChild(this._muteButton);
|
|
|
- this._muteButtonDisplayed = false;
|
|
|
+ this._muteButton = null;
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -67619,18 +67661,43 @@ var BABYLON;
|
|
|
*/
|
|
|
this.useCustomAttenuation = false;
|
|
|
/**
|
|
|
+ * Is this sound currently played.
|
|
|
+ */
|
|
|
+ this.isPlaying = false;
|
|
|
+ /**
|
|
|
+ * Is this sound currently paused.
|
|
|
+ */
|
|
|
+ this.isPaused = false;
|
|
|
+ /**
|
|
|
* Does this sound enables spatial sound.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
*/
|
|
|
this.spatialSound = false;
|
|
|
+ /**
|
|
|
+ * Define the reference distance the sound should be heard perfectly.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
this.refDistance = 1;
|
|
|
+ /**
|
|
|
+ * Define the roll off factor of spatial sounds.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
this.rolloffFactor = 1;
|
|
|
+ /**
|
|
|
+ * Define the max distance the sound should be heard (intensity just became 0 at this point).
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
this.maxDistance = 100;
|
|
|
+ /**
|
|
|
+ * Define the distance attenuation model the sound will follow.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
this.distanceModel = "linear";
|
|
|
- this._panningModel = "equalpower";
|
|
|
/**
|
|
|
* Observable event when the current playing sound finishes.
|
|
|
*/
|
|
|
this.onEndedObservable = new BABYLON.Observable();
|
|
|
+ this._panningModel = "equalpower";
|
|
|
this._playbackRate = 1;
|
|
|
this._streaming = false;
|
|
|
this._startTime = 0;
|
|
@@ -67641,8 +67708,6 @@ var BABYLON;
|
|
|
this._localDirection = new BABYLON.Vector3(1, 0, 0);
|
|
|
this._volume = 1;
|
|
|
this._isReadyToPlay = false;
|
|
|
- this.isPlaying = false;
|
|
|
- this.isPaused = false;
|
|
|
this._isDirectional = false;
|
|
|
// Used if you'd like to create a directional sound.
|
|
|
// If not set, the sound will be omnidirectional
|
|
@@ -67829,6 +67894,9 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Release the sound and its associated resources
|
|
|
+ */
|
|
|
Sound.prototype.dispose = function () {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
if (this.isPlaying) {
|
|
@@ -67868,6 +67936,10 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets if the sounds is ready to be played or not.
|
|
|
+ * @returns true if ready, otherwise false
|
|
|
+ */
|
|
|
Sound.prototype.isReady = function () {
|
|
|
return this._isReadyToPlay;
|
|
|
};
|
|
@@ -67887,12 +67959,20 @@ var BABYLON;
|
|
|
}
|
|
|
}, function (err) { BABYLON.Tools.Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Sets the data of the sound from an audiobuffer
|
|
|
+ * @param audioBuffer The audioBuffer containing the data
|
|
|
+ */
|
|
|
Sound.prototype.setAudioBuffer = function (audioBuffer) {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
this._audioBuffer = audioBuffer;
|
|
|
this._isReadyToPlay = true;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Updates the current sounds options such as maxdistance, loop...
|
|
|
+ * @param options A JSON object containing values named as the object properties
|
|
|
+ */
|
|
|
Sound.prototype.updateOptions = function (options) {
|
|
|
if (options) {
|
|
|
this.loop = options.loop || this.loop;
|
|
@@ -67945,10 +68025,20 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Switch the panning model to HRTF:
|
|
|
+ * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
Sound.prototype.switchPanningModelToHRTF = function () {
|
|
|
this._panningModel = "HRTF";
|
|
|
this._switchPanningModel();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Switch the panning model to Equal Power:
|
|
|
+ * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
Sound.prototype.switchPanningModelToEqualPower = function () {
|
|
|
this._panningModel = "equalpower";
|
|
|
this._switchPanningModel();
|
|
@@ -67958,6 +68048,10 @@ var BABYLON;
|
|
|
this._soundPanner.panningModel = this._panningModel;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Connect this sound to a sound track audio node like gain...
|
|
|
+ * @param soundTrackAudioNode the sound track audio node to connect to
|
|
|
+ */
|
|
|
Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
if (this._isOutputConnected) {
|
|
@@ -68037,12 +68131,20 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Sets the position of the emitter if spatial sound is enabled
|
|
|
+ * @param newPosition Defines the new posisiton
|
|
|
+ */
|
|
|
Sound.prototype.setPosition = function (newPosition) {
|
|
|
this._position = newPosition;
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
|
|
|
this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Sets the local direction of the emitter if spatial sound is enabled
|
|
|
+ * @param newLocalDirection Defines the new local direction
|
|
|
+ */
|
|
|
Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
|
|
|
this._localDirection = newLocalDirection;
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio && this._connectedMesh && this.isPlaying) {
|
|
@@ -68058,12 +68160,18 @@ var BABYLON;
|
|
|
direction.normalize();
|
|
|
this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
|
|
|
};
|
|
|
+ /** @hidden */
|
|
|
Sound.prototype.updateDistanceFromListener = function () {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio && this._connectedMesh && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
|
|
|
var distance = this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);
|
|
|
this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Sets a new custom attenuation function for the sound.
|
|
|
+ * @param callback Defines the function used for the attenuation
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
|
|
|
+ */
|
|
|
Sound.prototype.setAttenuationFunction = function (callback) {
|
|
|
this._customAttenuationFunction = callback;
|
|
|
};
|
|
@@ -68189,6 +68297,9 @@ var BABYLON;
|
|
|
this.isPlaying = false;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Put the sound in pause
|
|
|
+ */
|
|
|
Sound.prototype.pause = function () {
|
|
|
if (this.isPlaying) {
|
|
|
this.isPaused = true;
|
|
@@ -68206,6 +68317,11 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Sets a dedicated volume for this sounds
|
|
|
+ * @param newVolume Define the new volume of the sound
|
|
|
+ * @param time Define in how long the sound should be at this value
|
|
|
+ */
|
|
|
Sound.prototype.setVolume = function (newVolume, time) {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio && this._soundGain) {
|
|
|
if (time && BABYLON.Engine.audioEngine.audioContext) {
|
|
@@ -68219,6 +68335,10 @@ var BABYLON;
|
|
|
}
|
|
|
this._volume = newVolume;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Set the sound play back rate
|
|
|
+ * @param newPlaybackRate Define the playback rate the sound should be played at
|
|
|
+ */
|
|
|
Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
|
|
|
this._playbackRate = newPlaybackRate;
|
|
|
if (this.isPlaying) {
|
|
@@ -68230,9 +68350,18 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets the volume of the sound.
|
|
|
+ * @returns the volume of the sound
|
|
|
+ */
|
|
|
Sound.prototype.getVolume = function () {
|
|
|
return this._volume;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Attach the sound to a dedicated mesh
|
|
|
+ * @param meshToConnectTo The mesh to connect the sound with
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
|
|
|
+ */
|
|
|
Sound.prototype.attachToMesh = function (meshToConnectTo) {
|
|
|
var _this = this;
|
|
|
if (this._connectedMesh && this._registerFunc) {
|
|
@@ -68252,6 +68381,10 @@ var BABYLON;
|
|
|
this._registerFunc = function (connectedMesh) { return _this._onRegisterAfterWorldMatrixUpdate(connectedMesh); };
|
|
|
meshToConnectTo.registerAfterWorldMatrixUpdate(this._registerFunc);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Detach the sound from the previously attached mesh
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
|
|
|
+ */
|
|
|
Sound.prototype.detachFromMesh = function () {
|
|
|
if (this._connectedMesh && this._registerFunc) {
|
|
|
this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc);
|
|
@@ -68276,6 +68409,10 @@ var BABYLON;
|
|
|
this._updateDirection();
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Clone the current sound in the scene.
|
|
|
+ * @returns the new sound clone
|
|
|
+ */
|
|
|
Sound.prototype.clone = function () {
|
|
|
var _this = this;
|
|
|
if (!this._streaming) {
|
|
@@ -68311,9 +68448,17 @@ var BABYLON;
|
|
|
return null;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets the current underlying audio buffer containing the data
|
|
|
+ * @returns the audio buffer
|
|
|
+ */
|
|
|
Sound.prototype.getAudioBuffer = function () {
|
|
|
return this._audioBuffer;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Serializes the Sound in a JSON representation
|
|
|
+ * @returns the JSON representation of the sound
|
|
|
+ */
|
|
|
Sound.prototype.serialize = function () {
|
|
|
var serializationObject = {
|
|
|
name: this.name,
|
|
@@ -68344,6 +68489,14 @@ var BABYLON;
|
|
|
}
|
|
|
return serializationObject;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Parse a JSON representation of a sound to innstantiate in a given scene
|
|
|
+ * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
|
|
|
+ * @param scene Define the scene the new parsed sound should be created in
|
|
|
+ * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
|
|
|
+ * @param sourceSound Define a cound place holder if do not need to instantiate a new one
|
|
|
+ * @returns the newly parsed sound
|
|
|
+ */
|
|
|
Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
|
|
|
var soundName = parsedSound.name;
|
|
|
var soundUrl;
|
|
@@ -68410,8 +68563,23 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
|
|
|
+ * It will be also used in a future release to apply effects on a specific track.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
|
|
|
+ */
|
|
|
var SoundTrack = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Creates a new sound track.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
|
|
|
+ * @param scene Define the scene the sound track belongs to
|
|
|
+ * @param options
|
|
|
+ */
|
|
|
function SoundTrack(scene, options) {
|
|
|
+ if (options === void 0) { options = {}; }
|
|
|
+ /**
|
|
|
+ * The unique identifier of the sound track in the scene.
|
|
|
+ */
|
|
|
this.id = -1;
|
|
|
this._isMainTrack = false;
|
|
|
this._isInitialized = false;
|
|
@@ -68438,6 +68606,9 @@ var BABYLON;
|
|
|
this._isInitialized = true;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Release the sound track and its associated resources
|
|
|
+ */
|
|
|
SoundTrack.prototype.dispose = function () {
|
|
|
if (BABYLON.Engine.audioEngine && BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
if (this._connectedAnalyser) {
|
|
@@ -68452,6 +68623,11 @@ var BABYLON;
|
|
|
this._outputAudioNode = null;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Adds a sound to this sound track
|
|
|
+ * @param sound define the cound to add
|
|
|
+ * @ignoreNaming
|
|
|
+ */
|
|
|
SoundTrack.prototype.AddSound = function (sound) {
|
|
|
if (!this._isInitialized) {
|
|
|
this._initializeSoundTrackAudioGraph();
|
|
@@ -68470,17 +68646,31 @@ var BABYLON;
|
|
|
this.soundCollection.push(sound);
|
|
|
sound.soundTrackId = this.id;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Removes a sound to this sound track
|
|
|
+ * @param sound define the cound to remove
|
|
|
+ * @ignoreNaming
|
|
|
+ */
|
|
|
SoundTrack.prototype.RemoveSound = function (sound) {
|
|
|
var index = this.soundCollection.indexOf(sound);
|
|
|
if (index !== -1) {
|
|
|
this.soundCollection.splice(index, 1);
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Set a global volume for the full sound track.
|
|
|
+ * @param newVolume Define the new volume of the sound track
|
|
|
+ */
|
|
|
SoundTrack.prototype.setVolume = function (newVolume) {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio && this._outputAudioNode) {
|
|
|
this._outputAudioNode.gain.value = newVolume;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Switch the panning model to HRTF:
|
|
|
+ * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
SoundTrack.prototype.switchPanningModelToHRTF = function () {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
for (var i = 0; i < this.soundCollection.length; i++) {
|
|
@@ -68488,6 +68678,11 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Switch the panning model to Equal Power:
|
|
|
+ * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
|
|
|
+ */
|
|
|
SoundTrack.prototype.switchPanningModelToEqualPower = function () {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
for (var i = 0; i < this.soundCollection.length; i++) {
|
|
@@ -68495,6 +68690,12 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Connect the sound track to an audio analyser allowing some amazing
|
|
|
+ * synchornization between the sounds/music and your visualization (VuMeter for instance).
|
|
|
+ * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
|
|
|
+ * @param analyser The analyser to connect to the engine
|
|
|
+ */
|
|
|
SoundTrack.prototype.connectToAnalyser = function (analyser) {
|
|
|
if (this._connectedAnalyser) {
|
|
|
this._connectedAnalyser.stopDebugCanvas();
|
|
@@ -95747,6 +95948,9 @@ var BABYLON;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Force relase the drag action by code.
|
|
|
+ */
|
|
|
PointerDragBehavior.prototype.releaseDrag = function () {
|
|
|
this.dragging = false;
|
|
|
this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
|
|
@@ -95933,6 +96137,9 @@ var BABYLON;
|
|
|
* A behavior that when attached to a mesh will allow the mesh to be scaled
|
|
|
*/
|
|
|
var MultiPointerScaleBehavior = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
|
|
|
+ */
|
|
|
function MultiPointerScaleBehavior() {
|
|
|
this._startDistance = 0;
|
|
|
this._initialScale = new BABYLON.Vector3(0, 0, 0);
|
|
@@ -96036,6 +96243,9 @@ var BABYLON;
|
|
|
* A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
|
|
|
*/
|
|
|
var SixDofDragBehavior = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
|
|
|
+ */
|
|
|
function SixDofDragBehavior() {
|
|
|
this._sceneRenderObserver = null;
|
|
|
this._targetPosition = new BABYLON.Vector3(0, 0, 0);
|
|
@@ -104550,7 +104760,13 @@ var BABYLON;
|
|
|
if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
|
|
|
if (generateEdgesLines === void 0) { generateEdgesLines = true; }
|
|
|
var _this = this;
|
|
|
+ /**
|
|
|
+ * Define the size of the edges with an orthographic camera
|
|
|
+ */
|
|
|
this.edgesWidthScalerForOrthographic = 1000.0;
|
|
|
+ /**
|
|
|
+ * Define the size of the edges with a perspective camera
|
|
|
+ */
|
|
|
this.edgesWidthScalerForPerspective = 50.0;
|
|
|
this._linesPositions = new Array();
|
|
|
this._linesNormals = new Array();
|
|
@@ -108543,10 +108759,9 @@ var BABYLON;
|
|
|
this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
|
|
|
};
|
|
|
/**
|
|
|
- * Targets the given mesh and updates zoom level accordingly.
|
|
|
- * @param mesh The mesh to target.
|
|
|
- * @param radius Optional. If a cached radius position already exists, overrides default.
|
|
|
- * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
|
|
|
+ * Targets the bounding box info defined by its extends and updates zoom level accordingly.
|
|
|
+ * @param minimumWorld Determines the smaller position of the bounding box extend
|
|
|
+ * @param maximumWorld Determines the bigger position of the bounding box extend
|
|
|
* @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
|
|
|
* @param onAnimationEnd Callback triggered at the end of the framing animation
|
|
|
*/
|