|
@@ -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;
|
|
|
};
|
|
@@ -14677,7 +14682,7 @@ var BABYLON;
|
|
|
var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
|
|
|
var fromData = url.substr(0, 5) === "data:";
|
|
|
var fromBlob = url.substr(0, 5) === "blob:";
|
|
|
- var isBase64 = fromData && url.indexOf("base64") !== -1;
|
|
|
+ var isBase64 = fromData && url.indexOf(";base64,") !== -1;
|
|
|
var texture = fallback ? fallback : new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_URL);
|
|
|
// establish the file extension, if possible
|
|
|
var lastDot = url.lastIndexOf('.');
|
|
@@ -17901,16 +17906,18 @@ var BABYLON;
|
|
|
* Attach a behavior to the node
|
|
|
* @see http://doc.babylonjs.com/features/behaviour
|
|
|
* @param behavior defines the behavior to attach
|
|
|
+ * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
|
|
|
* @returns the current Node
|
|
|
*/
|
|
|
- Node.prototype.addBehavior = function (behavior) {
|
|
|
+ Node.prototype.addBehavior = function (behavior, attachImmediately) {
|
|
|
var _this = this;
|
|
|
+ if (attachImmediately === void 0) { attachImmediately = false; }
|
|
|
var index = this._behaviors.indexOf(behavior);
|
|
|
if (index !== -1) {
|
|
|
return this;
|
|
|
}
|
|
|
behavior.init();
|
|
|
- if (this._scene.isLoading) {
|
|
|
+ if (this._scene.isLoading && !attachImmediately) {
|
|
|
// We defer the attach when the scene will be loaded
|
|
|
this._scene.onDataLoadedObservable.addOnce(function () {
|
|
|
behavior.attach(_this);
|
|
@@ -55581,6 +55588,9 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
var IntersectionInfo = /** @class */ (function () {
|
|
|
function IntersectionInfo(bu, bv, distance) {
|
|
|
this.bu = bu;
|
|
@@ -55594,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() {
|
|
@@ -62979,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;
|
|
@@ -63046,6 +63077,9 @@ var BABYLON;
|
|
|
}
|
|
|
this._createIndexBuffer();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
BoundingBoxRenderer.prototype.reset = function () {
|
|
|
this.renderList.reset();
|
|
|
};
|
|
@@ -63099,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) {
|
|
@@ -63126,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;
|
|
@@ -67334,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.
|
|
@@ -67358,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.
|
|
@@ -67397,9 +67437,6 @@ var BABYLON;
|
|
|
catch (e) {
|
|
|
// protect error during capability check.
|
|
|
}
|
|
|
- if (/iPad|iPhone|iPod/.test(navigator.platform)) {
|
|
|
- this._unlockiOSaudio();
|
|
|
- }
|
|
|
}
|
|
|
Object.defineProperty(AudioEngine.prototype, "audioContext", {
|
|
|
/**
|
|
@@ -67410,7 +67447,7 @@ var BABYLON;
|
|
|
this._initializeAudioContext();
|
|
|
}
|
|
|
else {
|
|
|
- if (!this.unlocked && !this._muteButtonDisplayed) {
|
|
|
+ if (!this.unlocked && !this._muteButton) {
|
|
|
this._displayMuteButton();
|
|
|
}
|
|
|
}
|
|
@@ -67433,35 +67470,12 @@ var BABYLON;
|
|
|
AudioEngine.prototype.unlock = function () {
|
|
|
this._triggerRunningState();
|
|
|
};
|
|
|
- AudioEngine.prototype._unlockiOSaudio = function () {
|
|
|
- var _this = this;
|
|
|
- this._displayMuteButton(true);
|
|
|
- var unlockaudio = function () {
|
|
|
- if (!_this.audioContext) {
|
|
|
- return;
|
|
|
- }
|
|
|
- var buffer = _this.audioContext.createBuffer(1, 1, 22050);
|
|
|
- var source = _this.audioContext.createBufferSource();
|
|
|
- source.buffer = buffer;
|
|
|
- source.connect(_this.audioContext.destination);
|
|
|
- source.start(0);
|
|
|
- setTimeout(function () {
|
|
|
- if ((source.playbackState === source.PLAYING_STATE || source.playbackState === source.FINISHED_STATE)) {
|
|
|
- _this._triggerRunningState();
|
|
|
- if (_this._muteButton) {
|
|
|
- _this._muteButton.removeEventListener('touchend', unlockaudio, false);
|
|
|
- }
|
|
|
- }
|
|
|
- }, 0);
|
|
|
- };
|
|
|
- if (this._muteButton) {
|
|
|
- this._muteButton.addEventListener('touchend', unlockaudio, false);
|
|
|
- }
|
|
|
- };
|
|
|
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;
|
|
@@ -67474,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();
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -67498,22 +67510,26 @@ 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;
|
|
|
this.onAudioLockedObservable.notifyObservers(this);
|
|
|
this._displayMuteButton();
|
|
|
};
|
|
|
- AudioEngine.prototype._displayMuteButton = function (iOS) {
|
|
|
+ AudioEngine.prototype._displayMuteButton = function () {
|
|
|
var _this = this;
|
|
|
- if (iOS === void 0) { iOS = false; }
|
|
|
if (this.useCustomUnlockedButton) {
|
|
|
return;
|
|
|
}
|
|
@@ -67528,12 +67544,12 @@ var BABYLON;
|
|
|
document.getElementsByTagName('head')[0].appendChild(style);
|
|
|
document.body.appendChild(this._muteButton);
|
|
|
this._moveButtonToTopLeft();
|
|
|
- if (!iOS) {
|
|
|
- this._muteButton.addEventListener('mousedown', function () {
|
|
|
- _this._triggerRunningState();
|
|
|
- }, false);
|
|
|
- }
|
|
|
- this._muteButtonDisplayed = true;
|
|
|
+ this._muteButton.addEventListener('mousedown', function () {
|
|
|
+ _this._triggerRunningState();
|
|
|
+ }, false);
|
|
|
+ this._muteButton.addEventListener('touchend', function () {
|
|
|
+ _this._triggerRunningState();
|
|
|
+ }, false);
|
|
|
window.addEventListener("resize", this._onResize);
|
|
|
};
|
|
|
AudioEngine.prototype._moveButtonToTopLeft = function () {
|
|
@@ -67543,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;
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -67645,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;
|
|
@@ -67667,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
|
|
@@ -67805,6 +67844,7 @@ var BABYLON;
|
|
|
}
|
|
|
});
|
|
|
document.body.appendChild(this._htmlAudioElement);
|
|
|
+ this._htmlAudioElement.load();
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -67854,6 +67894,9 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Release the sound and its associated resources
|
|
|
+ */
|
|
|
Sound.prototype.dispose = function () {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
if (this.isPlaying) {
|
|
@@ -67893,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;
|
|
|
};
|
|
@@ -67912,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;
|
|
@@ -67970,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();
|
|
@@ -67983,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) {
|
|
@@ -68062,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) {
|
|
@@ -68083,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;
|
|
|
};
|
|
@@ -68214,6 +68297,9 @@ var BABYLON;
|
|
|
this.isPlaying = false;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Put the sound in pause
|
|
|
+ */
|
|
|
Sound.prototype.pause = function () {
|
|
|
if (this.isPlaying) {
|
|
|
this.isPaused = true;
|
|
@@ -68231,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) {
|
|
@@ -68244,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) {
|
|
@@ -68255,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) {
|
|
@@ -68277,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);
|
|
@@ -68301,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) {
|
|
@@ -68336,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,
|
|
@@ -68369,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;
|
|
@@ -68435,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;
|
|
@@ -68463,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) {
|
|
@@ -68477,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();
|
|
@@ -68495,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++) {
|
|
@@ -68513,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++) {
|
|
@@ -68520,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();
|
|
@@ -95739,6 +95915,14 @@ var BABYLON;
|
|
|
}
|
|
|
else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
|
|
|
var pointerId = pointerInfo.event.pointerId;
|
|
|
+ // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
|
|
|
+ if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
|
|
|
+ if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
|
|
|
+ _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
|
|
|
+ delete _this._lastPointerRay[_this.currentDraggingPointerID];
|
|
|
+ }
|
|
|
+ _this.currentDraggingPointerID = pointerId;
|
|
|
+ }
|
|
|
// Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
|
|
|
if (!_this._lastPointerRay[pointerId]) {
|
|
|
_this._lastPointerRay[pointerId] = new BABYLON.Ray(new BABYLON.Vector3(), new BABYLON.Vector3());
|
|
@@ -95764,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 });
|
|
@@ -95776,20 +95963,23 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Simulates the start of a pointer drag event on the behavior
|
|
|
- * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
|
|
|
+ * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
|
|
|
* @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
|
|
|
* @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
|
|
|
*/
|
|
|
PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
|
|
|
- if (pointerId === void 0) { pointerId = 1; }
|
|
|
+ if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
|
|
|
this._startDrag(pointerId, fromRay, startPickedPoint);
|
|
|
- if (this._lastPointerRay[pointerId]) {
|
|
|
+ var lastRay = this._lastPointerRay[pointerId];
|
|
|
+ if (pointerId === PointerDragBehavior._AnyMouseID) {
|
|
|
+ lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
|
|
|
+ }
|
|
|
+ if (lastRay) {
|
|
|
// if there was a last pointer ray drag the object there
|
|
|
- this._moveDrag(this._lastPointerRay[pointerId]);
|
|
|
+ this._moveDrag(lastRay);
|
|
|
}
|
|
|
};
|
|
|
PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
|
|
|
- if (pointerId === void 0) { pointerId = 1; }
|
|
|
if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
|
|
|
return;
|
|
|
}
|
|
@@ -95933,6 +96123,7 @@ var BABYLON;
|
|
|
this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
|
|
|
}
|
|
|
};
|
|
|
+ PointerDragBehavior._AnyMouseID = -2;
|
|
|
return PointerDragBehavior;
|
|
|
}());
|
|
|
BABYLON.PointerDragBehavior = PointerDragBehavior;
|
|
@@ -95946,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);
|
|
@@ -96049,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);
|
|
@@ -104563,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();
|
|
@@ -108556,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
|
|
|
*/
|