|
@@ -306,7 +306,7 @@ var BABYLON;
|
|
|
* Play the sound
|
|
|
* @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
|
|
|
*/
|
|
|
- Sound.prototype.play = function (time) {
|
|
|
+ Sound.prototype.play = function (time, offset) {
|
|
|
var _this = this;
|
|
|
if (this._isReadyToPlay && this._scene.audioEnabled) {
|
|
|
try {
|
|
@@ -348,7 +348,7 @@ var BABYLON;
|
|
|
this._soundSource.loop = this.loop;
|
|
|
this._soundSource.playbackRate.value = this._playbackRate;
|
|
|
this._soundSource.onended = function () { _this._onended(); };
|
|
|
- this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0);
|
|
|
+ this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : offset ? offset : 0);
|
|
|
}
|
|
|
this._startTime = startTime;
|
|
|
this.isPlaying = true;
|
|
@@ -497,6 +497,36 @@ var BABYLON;
|
|
|
Sound.prototype.getAudioBuffer = function () {
|
|
|
return this._audioBuffer;
|
|
|
};
|
|
|
+ Sound.prototype.serialize = function () {
|
|
|
+ var serializationObject = {
|
|
|
+ name: this.name,
|
|
|
+ url: this.name,
|
|
|
+ autoplay: this.autoplay,
|
|
|
+ loop: this.loop,
|
|
|
+ volume: this._volume,
|
|
|
+ spatialSound: this.spatialSound,
|
|
|
+ maxDistance: this.maxDistance,
|
|
|
+ rolloffFactor: this.rolloffFactor,
|
|
|
+ refDistance: this.refDistance,
|
|
|
+ distanceModel: this.distanceModel,
|
|
|
+ playbackRate: this._playbackRate,
|
|
|
+ panningModel: this._panningModel,
|
|
|
+ soundTrackId: this.soundTrackId
|
|
|
+ };
|
|
|
+ if (this.spatialSound) {
|
|
|
+ if (this._connectedMesh)
|
|
|
+ serializationObject.connectedMeshId = this._connectedMesh.id;
|
|
|
+ serializationObject.position = this._position.asArray();
|
|
|
+ serializationObject.refDistance = this.refDistance;
|
|
|
+ serializationObject.distanceModel = this.distanceModel;
|
|
|
+ serializationObject.isDirectional = this._isDirectional;
|
|
|
+ serializationObject.localDirectionToMesh = this._localDirection.asArray();
|
|
|
+ serializationObject.coneInnerAngle = this._coneInnerAngle;
|
|
|
+ serializationObject.coneOuterAngle = this._coneOuterAngle;
|
|
|
+ serializationObject.coneOuterGain = this._coneOuterGain;
|
|
|
+ }
|
|
|
+ return serializationObject;
|
|
|
+ };
|
|
|
Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
|
|
|
var soundName = parsedSound.name;
|
|
|
var soundUrl;
|
|
@@ -555,6 +585,6 @@ var BABYLON;
|
|
|
return newSound;
|
|
|
};
|
|
|
return Sound;
|
|
|
- })();
|
|
|
+ }());
|
|
|
BABYLON.Sound = Sound;
|
|
|
})(BABYLON || (BABYLON = {}));
|