|
@@ -18381,7 +18381,7 @@ var BABYLON;
|
|
|
return _this;
|
|
|
}
|
|
|
/**
|
|
|
- * Gets a string idenfifying the name of the class
|
|
|
+ * Gets a string identifying the name of the class
|
|
|
* @returns "TransformNode" string
|
|
|
*/
|
|
|
TransformNode.prototype.getClassName = function () {
|
|
@@ -18495,7 +18495,7 @@ var BABYLON;
|
|
|
configurable: true
|
|
|
});
|
|
|
/**
|
|
|
- * Copies the paramater passed Matrix into the mesh Pose matrix.
|
|
|
+ * Copies the parameter passed Matrix into the mesh Pose matrix.
|
|
|
* Returns the TransformNode.
|
|
|
*/
|
|
|
TransformNode.prototype.updatePoseMatrix = function (matrix) {
|
|
@@ -18553,7 +18553,7 @@ var BABYLON;
|
|
|
Object.defineProperty(TransformNode.prototype, "absolutePosition", {
|
|
|
/**
|
|
|
* Returns the current mesh absolute position.
|
|
|
- * Retuns a Vector3.
|
|
|
+ * Returns a Vector3.
|
|
|
*/
|
|
|
get: function () {
|
|
|
return this._absolutePosition;
|
|
@@ -50566,7 +50566,7 @@ var BABYLON;
|
|
|
});
|
|
|
Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
|
|
|
/**
|
|
|
- * Get the Vectpr2 animation type
|
|
|
+ * Get the Vector2 animation type
|
|
|
*/
|
|
|
get: function () {
|
|
|
return Animation._ANIMATIONTYPE_VECTOR2;
|
|
@@ -50835,6 +50835,10 @@ var BABYLON;
|
|
|
* This observable will notify when all animations have ended.
|
|
|
*/
|
|
|
this.onAnimationGroupEndObservable = new BABYLON.Observable();
|
|
|
+ /**
|
|
|
+ * This observable will notify when all animations have paused.
|
|
|
+ */
|
|
|
+ this.onAnimationGroupPauseObservable = new BABYLON.Observable();
|
|
|
this._scene = scene || BABYLON.Engine.LastCreatedScene;
|
|
|
this._scene.animationGroups.push(this);
|
|
|
}
|
|
@@ -51018,6 +51022,7 @@ var BABYLON;
|
|
|
var animatable = this._animatables[index];
|
|
|
animatable.pause();
|
|
|
}
|
|
|
+ this.onAnimationGroupPauseObservable.notifyObservers(this);
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
@@ -51646,7 +51651,7 @@ var BABYLON;
|
|
|
index--;
|
|
|
}
|
|
|
event.isDone = true;
|
|
|
- event.action();
|
|
|
+ event.action(currentFrame);
|
|
|
} // Don't do anything if the event has already be done.
|
|
|
}
|
|
|
}
|
|
@@ -64350,11 +64355,17 @@ var BABYLON;
|
|
|
this.maxDistance = 100;
|
|
|
this.distanceModel = "linear";
|
|
|
this._panningModel = "equalpower";
|
|
|
+ /**
|
|
|
+ * Observable event when the current playing sound finishes.
|
|
|
+ */
|
|
|
+ this.onEndedObservable = new BABYLON.Observable();
|
|
|
this._playbackRate = 1;
|
|
|
this._streaming = false;
|
|
|
this._startTime = 0;
|
|
|
this._startOffset = 0;
|
|
|
this._position = BABYLON.Vector3.Zero();
|
|
|
+ /** @hidden */
|
|
|
+ this._positionInEmitterSpace = false;
|
|
|
this._localDirection = new BABYLON.Vector3(1, 0, 0);
|
|
|
this._volume = 1;
|
|
|
this._isReadyToPlay = false;
|
|
@@ -64400,7 +64411,7 @@ var BABYLON;
|
|
|
this._soundGain = BABYLON.Engine.audioEngine.audioContext.createGain();
|
|
|
this._soundGain.gain.value = this._volume;
|
|
|
this._inputAudioNode = this._soundGain;
|
|
|
- this._ouputAudioNode = this._soundGain;
|
|
|
+ this._outputAudioNode = this._soundGain;
|
|
|
if (this.spatialSound) {
|
|
|
this._createSpatialParameters();
|
|
|
}
|
|
@@ -64633,7 +64644,7 @@ var BABYLON;
|
|
|
}
|
|
|
this._soundPanner = BABYLON.Engine.audioEngine.audioContext.createPanner();
|
|
|
this._updateSpatialParameters();
|
|
|
- this._soundPanner.connect(this._ouputAudioNode);
|
|
|
+ this._soundPanner.connect(this._outputAudioNode);
|
|
|
this._inputAudioNode = this._soundPanner;
|
|
|
}
|
|
|
};
|
|
@@ -64672,9 +64683,9 @@ var BABYLON;
|
|
|
Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
if (this._isOutputConnected) {
|
|
|
- this._ouputAudioNode.disconnect();
|
|
|
+ this._outputAudioNode.disconnect();
|
|
|
}
|
|
|
- this._ouputAudioNode.connect(soundTrackAudioNode);
|
|
|
+ this._outputAudioNode.connect(soundTrackAudioNode);
|
|
|
this._isOutputConnected = true;
|
|
|
}
|
|
|
};
|
|
@@ -64698,9 +64709,59 @@ var BABYLON;
|
|
|
this.play();
|
|
|
}
|
|
|
};
|
|
|
+ Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
|
|
|
+ /**
|
|
|
+ * Gets or sets the inner angle for the directional cone.
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._coneInnerAngle;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Gets or sets the inner angle for the directional cone.
|
|
|
+ */
|
|
|
+ set: function (value) {
|
|
|
+ if (value != this._coneInnerAngle) {
|
|
|
+ if (this._coneOuterAngle < value) {
|
|
|
+ BABYLON.Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._coneInnerAngle = value;
|
|
|
+ if (BABYLON.Engine.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
|
|
|
+ this._soundPanner.coneInnerAngle = this._coneInnerAngle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
|
|
|
+ /**
|
|
|
+ * Gets or sets the outer angle for the directional cone.
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._coneOuterAngle;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Gets or sets the outer angle for the directional cone.
|
|
|
+ */
|
|
|
+ set: function (value) {
|
|
|
+ if (value != this._coneOuterAngle) {
|
|
|
+ if (value < this._coneInnerAngle) {
|
|
|
+ BABYLON.Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._coneOuterAngle = value;
|
|
|
+ if (BABYLON.Engine.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
|
|
|
+ this._soundPanner.coneOuterAngle = this._coneOuterAngle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
Sound.prototype.setPosition = function (newPosition) {
|
|
|
this._position = newPosition;
|
|
|
- if (BABYLON.Engine.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
|
|
|
+ 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);
|
|
|
}
|
|
|
};
|
|
@@ -64744,7 +64805,9 @@ var BABYLON;
|
|
|
var startTime = time ? BABYLON.Engine.audioEngine.audioContext.currentTime + time : BABYLON.Engine.audioEngine.audioContext.currentTime;
|
|
|
if (!this._soundSource || !this._streamingSource) {
|
|
|
if (this.spatialSound && this._soundPanner) {
|
|
|
- this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
|
|
|
+ if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
|
|
|
+ this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
|
|
|
+ }
|
|
|
if (this._isDirectional) {
|
|
|
this._soundPanner.coneInnerAngle = this._coneInnerAngle;
|
|
|
this._soundPanner.coneOuterAngle = this._coneOuterAngle;
|
|
@@ -64795,6 +64858,7 @@ var BABYLON;
|
|
|
if (this.onended) {
|
|
|
this.onended();
|
|
|
}
|
|
|
+ this.onEndedObservable.notifyObservers(this);
|
|
|
};
|
|
|
/**
|
|
|
* Stop the sound
|
|
@@ -64900,8 +64964,14 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
var mesh = node;
|
|
|
- var boundingInfo = mesh.getBoundingInfo();
|
|
|
- this.setPosition(boundingInfo.boundingSphere.centerWorld);
|
|
|
+ if (this._positionInEmitterSpace) {
|
|
|
+ mesh.worldMatrixFromCache.invertToRef(BABYLON.Tmp.Matrix[0]);
|
|
|
+ this.setPosition(BABYLON.Tmp.Matrix[0].getTranslation());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var boundingInfo = mesh.getBoundingInfo();
|
|
|
+ this.setPosition(boundingInfo.boundingSphere.centerWorld);
|
|
|
+ }
|
|
|
if (BABYLON.Engine.audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
|
|
|
this._updateDirection();
|
|
|
}
|
|
@@ -65320,6 +65390,190 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.analyser.js.map
|
|
|
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Wraps one or more Sound objects and selects one with random weight for playback.
|
|
|
+ */
|
|
|
+ var WeightedSound = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Creates a new WeightedSound from the list of sounds given.
|
|
|
+ * @param loop When true a Sound will be selected and played when the current playing Sound completes.
|
|
|
+ * @param sounds Array of Sounds that will be selected from.
|
|
|
+ * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
|
|
|
+ */
|
|
|
+ function WeightedSound(loop, sounds, weights) {
|
|
|
+ var _this = this;
|
|
|
+ /** When true a Sound will be selected and played when the current playing Sound completes. */
|
|
|
+ this.loop = false;
|
|
|
+ this._coneInnerAngle = 360;
|
|
|
+ this._coneOuterAngle = 360;
|
|
|
+ this._volume = 1;
|
|
|
+ /** A Sound is currently playing. */
|
|
|
+ this.isPlaying = false;
|
|
|
+ /** A Sound is currently paused. */
|
|
|
+ this.isPaused = false;
|
|
|
+ this._sounds = [];
|
|
|
+ this._weights = [];
|
|
|
+ if (sounds.length !== weights.length) {
|
|
|
+ throw new Error('Sounds length does not equal weights length');
|
|
|
+ }
|
|
|
+ this.loop = loop;
|
|
|
+ this._weights = weights;
|
|
|
+ // Normalize the weights
|
|
|
+ var weightSum = 0;
|
|
|
+ for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
|
|
|
+ var weight = weights_1[_i];
|
|
|
+ weightSum += weight;
|
|
|
+ }
|
|
|
+ var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
|
|
|
+ for (var i = 0; i < this._weights.length; i++) {
|
|
|
+ this._weights[i] *= invWeightSum;
|
|
|
+ }
|
|
|
+ this._sounds = sounds;
|
|
|
+ for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
|
|
|
+ var sound = _b[_a];
|
|
|
+ sound.onEndedObservable.add(function () { _this._onended(); });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
|
|
|
+ /**
|
|
|
+ * The size of cone in degrees for a directional sound in which there will be no attenuation.
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._coneInnerAngle;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * The size of cone in degress for a directional sound in which there will be no attenuation.
|
|
|
+ */
|
|
|
+ set: function (value) {
|
|
|
+ if (value !== this._coneInnerAngle) {
|
|
|
+ if (this._coneOuterAngle < value) {
|
|
|
+ BABYLON.Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._coneInnerAngle = value;
|
|
|
+ for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
|
|
|
+ var sound = _a[_i];
|
|
|
+ sound.directionalConeInnerAngle = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
|
|
|
+ /**
|
|
|
+ * Size of cone in degrees for a directional sound outside of which there will be no sound.
|
|
|
+ * Listener angles between innerAngle and outerAngle will falloff linearly.
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._coneOuterAngle;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Size of cone in degrees for a directional sound outside of which there will be no sound.
|
|
|
+ * Listener angles between innerAngle and outerAngle will falloff linearly.
|
|
|
+ */
|
|
|
+ set: function (value) {
|
|
|
+ if (value !== this._coneOuterAngle) {
|
|
|
+ if (value < this._coneInnerAngle) {
|
|
|
+ BABYLON.Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._coneOuterAngle = value;
|
|
|
+ for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
|
|
|
+ var sound = _a[_i];
|
|
|
+ sound.directionalConeOuterAngle = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ Object.defineProperty(WeightedSound.prototype, "volume", {
|
|
|
+ /**
|
|
|
+ * Playback volume.
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._volume;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Playback volume.
|
|
|
+ */
|
|
|
+ set: function (value) {
|
|
|
+ if (value !== this._volume) {
|
|
|
+ for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
|
|
|
+ var sound = _a[_i];
|
|
|
+ sound.setVolume(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ WeightedSound.prototype._onended = function () {
|
|
|
+ if (this._currentIndex !== undefined) {
|
|
|
+ this._sounds[this._currentIndex].autoplay = false;
|
|
|
+ }
|
|
|
+ if (this.loop && this.isPlaying) {
|
|
|
+ this.play();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.isPlaying = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Suspend playback
|
|
|
+ */
|
|
|
+ WeightedSound.prototype.pause = function () {
|
|
|
+ this.isPaused = true;
|
|
|
+ if (this._currentIndex !== undefined) {
|
|
|
+ this._sounds[this._currentIndex].pause();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Stop playback
|
|
|
+ */
|
|
|
+ WeightedSound.prototype.stop = function () {
|
|
|
+ this.isPlaying = false;
|
|
|
+ if (this._currentIndex !== undefined) {
|
|
|
+ this._sounds[this._currentIndex].stop();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Start playback.
|
|
|
+ * @param startOffset Position the clip head at a specific time in seconds.
|
|
|
+ */
|
|
|
+ WeightedSound.prototype.play = function (startOffset) {
|
|
|
+ if (!this.isPaused) {
|
|
|
+ this.stop();
|
|
|
+ var randomValue = Math.random();
|
|
|
+ var total = 0;
|
|
|
+ for (var i = 0; i < this._weights.length; i++) {
|
|
|
+ total += this._weights[i];
|
|
|
+ if (randomValue <= total) {
|
|
|
+ this._currentIndex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var sound = this._sounds[this._currentIndex];
|
|
|
+ if (sound.isReady()) {
|
|
|
+ sound.play(0, this.isPaused ? undefined : startOffset);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sound.autoplay = true;
|
|
|
+ }
|
|
|
+ this.isPlaying = true;
|
|
|
+ this.isPaused = false;
|
|
|
+ };
|
|
|
+ return WeightedSound;
|
|
|
+ }());
|
|
|
+ BABYLON.WeightedSound = WeightedSound;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.weightedsound.js.map
|
|
|
+
|
|
|
|
|
|
|
|
|
|