Browse Source

Merge pull request #2808 from BabylonJS/master

Nightly
David Catuhe 8 years ago
parent
commit
ce8de6cd4a

+ 4 - 3
Tools/Gulp/gulp-addDtsExport.js

@@ -5,8 +5,9 @@ module.exports = function (varName) {
     return through.obj(function (file, enc, cb) {
 
         var moduleExportsAddition =
- //           '\nexport as namespace ' + varName + ';\n' +
-            '\nexport = ' + varName + ';\n';
+            'export = ' + varName + ';\n' +
+            'export as namespace ' + varName + ';\n\n';
+
 
         if (file.isNull()) {
             cb(null, file);
@@ -19,7 +20,7 @@ module.exports = function (varName) {
         }
 
         try {
-            file.contents = new Buffer(String(file.contents) + moduleExportsAddition);
+            file.contents = new Buffer(moduleExportsAddition + String(file.contents));
             this.push(file);
 
         } catch (err) {

+ 16 - 7
Tools/Gulp/gulp-addModuleExports.js

@@ -4,13 +4,22 @@ var through = require('through2');
 module.exports = function (varName) {
     return through.obj(function (file, enc, cb) {
 
-        var moduleExportsAddition =
-          '\nif (((typeof window != "undefined" && window.module) || (typeof module != "undefined")) && typeof module.exports != "undefined") {\n' +
-          '    module.exports = ' + varName + ';\n' +
-          '};\n';
+        var moduleExportsAddition = `(function universalModuleDefinition(root, factory) {
+            if(typeof exports === 'object' && typeof module === 'object')
+                module.exports = factory();
+            else if(typeof define === 'function' && define.amd)
+                define([], factory);
+            else if(typeof exports === 'object')
+                exports["BABYLON"] = factory();
+            else
+                root["BABYLON"] = factory();
+        })(this, function() {
+            return BABYLON;
+        });
+        `;
 
         var extendsAddition =
-        `var __extends = (this && this.__extends) || (function () {
+            `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]; };
@@ -23,12 +32,12 @@ module.exports = function (varName) {
         `;
 
         var decorateAddition =
-        'var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n' +
+            'var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n' +
             'var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n' +
             'if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);\n' +
             '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;\n' +
             'return c > 3 && r && Object.defineProperty(target, key, r), r;\n' +
-        '};\n';
+            '};\n';
 
         if (file.isNull()) {
             cb(null, file);

File diff suppressed because it is too large
+ 5887 - 5886
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 17 - 17
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 27 - 8
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 5889 - 5887
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 17 - 17
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 2365 - 2364
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff suppressed because it is too large
+ 17 - 17
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 27 - 8
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -16804,9 +16804,6 @@ var BABYLON;
                 this._outlineRenderer = new BABYLON.OutlineRenderer(this);
             }
             this.attachControl();
-            if (BABYLON.SoundTrack) {
-                this.mainSoundTrack = new BABYLON.SoundTrack(this, { mainTrack: true });
-            }
             //simplification queue
             if (BABYLON.SimplificationQueue) {
                 this.simplificationQueue = new BABYLON.SimplificationQueue();
@@ -17108,6 +17105,16 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Scene.prototype, "mainSoundTrack", {
+            get: function () {
+                if (!this._mainSoundTrack) {
+                    // this._mainSoundTrack = new SoundTrack(this, { mainTrack: true });
+                }
+                return this._mainSoundTrack;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
             get: function () {
                 return this._alternateRendering;
@@ -19245,7 +19252,7 @@ var BABYLON;
             this._activeParticles.addCount(0, true);
         };
         Scene.prototype._updateAudioParameters = function () {
-            if (!this.audioEnabled || (this.mainSoundTrack.soundCollection.length === 0 && this.soundTracks.length === 1)) {
+            if (!this.audioEnabled || !this._mainSoundTrack || (this._mainSoundTrack.soundCollection.length === 0 && this.soundTracks.length === 1)) {
                 return;
             }
             var listeningCamera;
@@ -19537,6 +19544,9 @@ var BABYLON;
         });
         // Release sounds & sounds tracks
         Scene.prototype.disposeSounds = function () {
+            if (!this._mainSoundTrack) {
+                return;
+            }
             this.mainSoundTrack.dispose();
             for (var scIndex = 0; scIndex < this.soundTracks.length; scIndex++) {
                 this.soundTracks[scIndex].dispose();
@@ -76655,7 +76665,16 @@ var BABYLON;
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=KHR_materials_pbrSpecularGlossiness.js.map
-
-if (((typeof window != "undefined" && window.module) || (typeof module != "undefined")) && typeof module.exports != "undefined") {
-    module.exports = BABYLON;
-};
+(function universalModuleDefinition(root, factory) {
+            if(typeof exports === 'object' && typeof module === 'object')
+                module.exports = factory();
+            else if(typeof define === 'function' && define.amd)
+                define([], factory);
+            else if(typeof exports === 'object')
+                exports["BABYLON"] = factory();
+            else
+                root["BABYLON"] = factory();
+        })(this, function() {
+            return BABYLON;
+        });
+        

File diff suppressed because it is too large
+ 1938 - 1936
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 3 - 2
dist/preview release/gui/babylon.gui.module.d.ts

@@ -1,3 +1,6 @@
+export = BABYLON.GUI;
+export as namespace BABYLON.GUI;
+
 /// <reference path="../../dist/preview release/babylon.d.ts" />
 declare module BABYLON.GUI {
     interface IFocusableControl {
@@ -672,5 +675,3 @@ declare module BABYLON.GUI {
         static CreateDefaultLayout(): VirtualKeyboard;
     }
 }
-
-export = BABYLON.GUI;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 14 - 6
src/babylon.scene.ts

@@ -684,11 +684,19 @@
         public _proceduralTextures = new Array<ProceduralTexture>();
 
         // Sound Tracks
-        public mainSoundTrack: SoundTrack;
+        private _mainSoundTrack: SoundTrack;
         public soundTracks = new Array<SoundTrack>();
         private _audioEnabled = true;
         private _headphone = false;
 
+        public get mainSoundTrack(): SoundTrack {
+            if (!this._mainSoundTrack) {
+               // this._mainSoundTrack = new SoundTrack(this, { mainTrack: true });
+            }
+
+            return this._mainSoundTrack;
+        }
+
         // VR Helper
         public VRHelper: VRExperienceHelper;
 
@@ -815,10 +823,6 @@
 
             this.attachControl();
 
-            if (SoundTrack) {
-                this.mainSoundTrack = new SoundTrack(this, { mainTrack: true });
-            }
-
             //simplification queue
             if (SimplificationQueue) {
                 this.simplificationQueue = new SimplificationQueue();
@@ -3305,7 +3309,7 @@
         }
 
         private _updateAudioParameters() {
-            if (!this.audioEnabled || (this.mainSoundTrack.soundCollection.length === 0 && this.soundTracks.length === 1)) {
+            if (!this.audioEnabled || !this._mainSoundTrack || (this._mainSoundTrack.soundCollection.length === 0 && this.soundTracks.length === 1)) {
                 return;
             }
 
@@ -3643,6 +3647,10 @@
 
         // Release sounds & sounds tracks
         public disposeSounds() {
+            if (!this._mainSoundTrack) {
+                return;
+            }
+
             this.mainSoundTrack.dispose();
 
             for (var scIndex = 0; scIndex < this.soundTracks.length; scIndex++) {