|
@@ -1,32 +1,51 @@
|
|
|
-var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
|
-var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
|
-if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
|
-else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
|
-return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
|
-};
|
|
|
-var __extends = (this && this.__extends) || (function () {
|
|
|
- var extendStatics = Object.setPrototypeOf ||
|
|
|
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
|
- return function (d, b) {
|
|
|
- extendStatics(d, b);
|
|
|
- function __() { this.constructor = d; }
|
|
|
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
- };
|
|
|
- })();
|
|
|
-
|
|
|
+var __decorate=this&&this.__decorate||function(e,t,r,c){var o,f=arguments.length,n=f<3?t:null===c?c=Object.getOwnPropertyDescriptor(t,r):c;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,c);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(n=(f<3?o(n):f>3?o(t,r,n):o(t,r))||n);return f>3&&n&&Object.defineProperty(t,r,n),n};
|
|
|
+var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)o.hasOwnProperty(n)&&(t[n]=o[n])};return function(o,n){function r(){this.constructor=o}t(o,n),o.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();
|
|
|
+
|
|
|
|
|
|
(function universalModuleDefinition(root, factory) {
|
|
|
+ var amdDependencies = [];
|
|
|
+ var CANNON = root. CANNON;
|
|
|
+ if(!CANNON) {
|
|
|
+ if(typeof exports === 'object') {
|
|
|
+ try { CANNON = require("cannon"); } catch(e) {}
|
|
|
+ } else if(typeof define === 'function' && define.amd) {
|
|
|
+ if(require.specified && require.specified("cannon")) amdDependencies.push("cannon");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(typeof define === 'function' && define.amd) {
|
|
|
+ if(!(require.specified && require.specified("' + dep.module + '"))) {
|
|
|
+ try { define("cannon", [], function () { return CANNON; }); } catch(e) { }
|
|
|
+ }
|
|
|
+ amdDependencies.push("cannon");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var OIMO = root. OIMO;
|
|
|
+ if(!OIMO) {
|
|
|
+ if(typeof exports === 'object') {
|
|
|
+ try { OIMO = require("oimo"); } catch(e) {}
|
|
|
+ } else if(typeof define === 'function' && define.amd) {
|
|
|
+ if(require.specified && require.specified("oimo")) amdDependencies.push("oimo");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(typeof define === 'function' && define.amd) {
|
|
|
+ if(!(require.specified && require.specified("' + dep.module + '"))) {
|
|
|
+ try { define("oimo", [], function () { return OIMO; }); } catch(e) { }
|
|
|
+ }
|
|
|
+ amdDependencies.push("oimo");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
|
- module.exports = factory();
|
|
|
+ module.exports = factory(CANNON,OIMO);
|
|
|
else if(typeof define === 'function' && define.amd)
|
|
|
- define("babylonjs", [], factory);
|
|
|
+ define("babylonjs", amdDependencies, factory);
|
|
|
else if(typeof exports === 'object')
|
|
|
- exports["babylonjs"] = factory();
|
|
|
+ exports["babylonjs"] = factory(CANNON,OIMO);
|
|
|
else {
|
|
|
- root["BABYLON"] = factory(root["BABYLON"]);
|
|
|
+ root["BABYLON"] = factory(CANNON,OIMO);
|
|
|
}
|
|
|
-})(this, function() {
|
|
|
+})(this, function(CANNON,OIMO) {
|
|
|
"use strict";
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
@@ -58220,87 +58239,101 @@ var BABYLON;
|
|
|
var validParameter = true;
|
|
|
// if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
|
|
|
if (urlOrArrayBuffer) {
|
|
|
- if (typeof (urlOrArrayBuffer) === "string")
|
|
|
- this._urlType = "String";
|
|
|
- if (Array.isArray(urlOrArrayBuffer))
|
|
|
- this._urlType = "Array";
|
|
|
- if (urlOrArrayBuffer instanceof ArrayBuffer)
|
|
|
- this._urlType = "ArrayBuffer";
|
|
|
- var urls = [];
|
|
|
- var codecSupportedFound = false;
|
|
|
- switch (this._urlType) {
|
|
|
- case "ArrayBuffer":
|
|
|
- if (urlOrArrayBuffer.byteLength > 0) {
|
|
|
- codecSupportedFound = true;
|
|
|
- this._soundLoaded(urlOrArrayBuffer);
|
|
|
- }
|
|
|
- break;
|
|
|
- case "String":
|
|
|
- urls.push(urlOrArrayBuffer);
|
|
|
- case "Array":
|
|
|
- if (urls.length === 0)
|
|
|
- urls = urlOrArrayBuffer;
|
|
|
- // If we found a supported format, we load it immediately and stop the loop
|
|
|
- for (var i = 0; i < urls.length; i++) {
|
|
|
- var url = urls[i];
|
|
|
- if (url.indexOf(".mp3", url.length - 4) !== -1 && BABYLON.Engine.audioEngine.isMP3supported) {
|
|
|
- codecSupportedFound = true;
|
|
|
- }
|
|
|
- if (url.indexOf(".ogg", url.length - 4) !== -1 && BABYLON.Engine.audioEngine.isOGGsupported) {
|
|
|
- codecSupportedFound = true;
|
|
|
- }
|
|
|
- if (url.indexOf(".wav", url.length - 4) !== -1) {
|
|
|
- codecSupportedFound = true;
|
|
|
- }
|
|
|
- if (url.indexOf("blob:") !== -1) {
|
|
|
+ try {
|
|
|
+ if (typeof (urlOrArrayBuffer) === "string")
|
|
|
+ this._urlType = "String";
|
|
|
+ if (Array.isArray(urlOrArrayBuffer))
|
|
|
+ this._urlType = "Array";
|
|
|
+ if (urlOrArrayBuffer instanceof ArrayBuffer)
|
|
|
+ this._urlType = "ArrayBuffer";
|
|
|
+ var urls = [];
|
|
|
+ var codecSupportedFound = false;
|
|
|
+ switch (this._urlType) {
|
|
|
+ case "ArrayBuffer":
|
|
|
+ if (urlOrArrayBuffer.byteLength > 0) {
|
|
|
codecSupportedFound = true;
|
|
|
+ this._soundLoaded(urlOrArrayBuffer);
|
|
|
}
|
|
|
- if (codecSupportedFound) {
|
|
|
- // Loading sound using XHR2
|
|
|
- if (!this._streaming) {
|
|
|
- this._scene._loadFile(url, function (data) { _this._soundLoaded(data); }, undefined, true, true);
|
|
|
+ break;
|
|
|
+ case "String":
|
|
|
+ urls.push(urlOrArrayBuffer);
|
|
|
+ case "Array":
|
|
|
+ if (urls.length === 0)
|
|
|
+ urls = urlOrArrayBuffer;
|
|
|
+ // If we found a supported format, we load it immediately and stop the loop
|
|
|
+ for (var i = 0; i < urls.length; i++) {
|
|
|
+ var url = urls[i];
|
|
|
+ if (url.indexOf(".mp3", url.length - 4) !== -1 && BABYLON.Engine.audioEngine.isMP3supported) {
|
|
|
+ codecSupportedFound = true;
|
|
|
}
|
|
|
- else {
|
|
|
- this._htmlAudioElement = new Audio(url);
|
|
|
- this._htmlAudioElement.controls = false;
|
|
|
- this._htmlAudioElement.loop = this.loop;
|
|
|
- BABYLON.Tools.SetCorsBehavior(url, this._htmlAudioElement);
|
|
|
- this._htmlAudioElement.preload = "auto";
|
|
|
- this._htmlAudioElement.addEventListener("canplaythrough", function () {
|
|
|
- _this._isReadyToPlay = true;
|
|
|
- if (_this.autoplay) {
|
|
|
- _this.play();
|
|
|
- }
|
|
|
- if (_this._readyToPlayCallback) {
|
|
|
- _this._readyToPlayCallback();
|
|
|
- }
|
|
|
- });
|
|
|
- document.body.appendChild(this._htmlAudioElement);
|
|
|
+ if (url.indexOf(".ogg", url.length - 4) !== -1 && BABYLON.Engine.audioEngine.isOGGsupported) {
|
|
|
+ codecSupportedFound = true;
|
|
|
}
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- validParameter = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- if (!validParameter) {
|
|
|
- BABYLON.Tools.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
|
|
|
- }
|
|
|
- else {
|
|
|
- if (!codecSupportedFound) {
|
|
|
- this._isReadyToPlay = true;
|
|
|
- // Simulating a ready to play event to avoid breaking code path
|
|
|
- if (this._readyToPlayCallback) {
|
|
|
- window.setTimeout(function () {
|
|
|
- if (_this._readyToPlayCallback) {
|
|
|
- _this._readyToPlayCallback();
|
|
|
+ if (url.indexOf(".wav", url.length - 4) !== -1) {
|
|
|
+ codecSupportedFound = true;
|
|
|
}
|
|
|
- }, 1000);
|
|
|
+ if (url.indexOf("blob:") !== -1) {
|
|
|
+ codecSupportedFound = true;
|
|
|
+ }
|
|
|
+ if (codecSupportedFound) {
|
|
|
+ // Loading sound using XHR2
|
|
|
+ if (!this._streaming) {
|
|
|
+ this._scene._loadFile(url, function (data) {
|
|
|
+ _this._soundLoaded(data);
|
|
|
+ }, undefined, true, true, function (exception) {
|
|
|
+ if (exception) {
|
|
|
+ BABYLON.Tools.Error("XHR " + exception.status + " error on: " + url + ".");
|
|
|
+ }
|
|
|
+ BABYLON.Tools.Error("Sound creation aborted.");
|
|
|
+ _this._scene.mainSoundTrack.RemoveSound(_this);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._htmlAudioElement = new Audio(url);
|
|
|
+ this._htmlAudioElement.controls = false;
|
|
|
+ this._htmlAudioElement.loop = this.loop;
|
|
|
+ BABYLON.Tools.SetCorsBehavior(url, this._htmlAudioElement);
|
|
|
+ this._htmlAudioElement.preload = "auto";
|
|
|
+ this._htmlAudioElement.addEventListener("canplaythrough", function () {
|
|
|
+ _this._isReadyToPlay = true;
|
|
|
+ if (_this.autoplay) {
|
|
|
+ _this.play();
|
|
|
+ }
|
|
|
+ if (_this._readyToPlayCallback) {
|
|
|
+ _this._readyToPlayCallback();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ document.body.appendChild(this._htmlAudioElement);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ validParameter = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!validParameter) {
|
|
|
+ BABYLON.Tools.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (!codecSupportedFound) {
|
|
|
+ this._isReadyToPlay = true;
|
|
|
+ // Simulating a ready to play event to avoid breaking code path
|
|
|
+ if (this._readyToPlayCallback) {
|
|
|
+ window.setTimeout(function () {
|
|
|
+ if (_this._readyToPlayCallback) {
|
|
|
+ _this._readyToPlayCallback();
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ catch (ex) {
|
|
|
+ BABYLON.Tools.Error("Unexpected error. Sound creation aborted.");
|
|
|
+ this._scene.mainSoundTrack.RemoveSound(this);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -58321,7 +58354,7 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
Sound.prototype.dispose = function () {
|
|
|
- if (BABYLON.Engine.audioEngine.canUseWebAudio && this._isReadyToPlay) {
|
|
|
+ if (BABYLON.Engine.audioEngine.canUseWebAudio) {
|
|
|
if (this.isPlaying) {
|
|
|
this.stop();
|
|
|
}
|
|
@@ -78945,7 +78978,7 @@ var BABYLON;
|
|
|
this._physicsMaterials = new Array();
|
|
|
this._fixedTimeStep = 1 / 60;
|
|
|
//See https://github.com/schteppe/CANNON.js/blob/gh-pages/demos/collisionFilter.html
|
|
|
- this.BJSCANNON = typeof CANNON !== 'undefined' ? CANNON : (typeof require !== 'undefined' ? require('cannon') : undefined);
|
|
|
+ this.BJSCANNON = CANNON;
|
|
|
this._minus90X = new BABYLON.Quaternion(-0.7071067811865475, 0, 0, 0.7071067811865475);
|
|
|
this._plus90X = new BABYLON.Quaternion(0.7071067811865475, 0, 0, 0.7071067811865475);
|
|
|
this._tmpPosition = BABYLON.Vector3.Zero();
|
|
@@ -79500,7 +79533,7 @@ var BABYLON;
|
|
|
this.name = "OimoJSPlugin";
|
|
|
this._tmpImpostorsArray = [];
|
|
|
this._tmpPositionVector = BABYLON.Vector3.Zero();
|
|
|
- this.BJSOIMO = typeof OIMO !== 'undefined' ? OIMO : (typeof require !== 'undefined' ? require('./Oimo') : undefined);
|
|
|
+ this.BJSOIMO = OIMO;
|
|
|
this.world = new this.BJSOIMO.World({
|
|
|
iterations: iterations
|
|
|
});
|