Browse Source

Merge pull request #3161 from BabylonJS/master

Preview
Raanan Weber 7 years ago
parent
commit
d54de153b0

+ 2 - 4
Viewer/dist/domExample.html

@@ -15,9 +15,8 @@
     </head>
 
     <body>
-        <babylon extends="minimal">
-            <model url="https://ugcorigin.s-microsoft.com/12/2e77b8e3-0000-0000-7a48-6505db2f0ef9/952/1508427934473.gltf" title="The Bus!"
-                subtitle="Remix3D" thumbnail="http://d33wubrfki0l68.cloudfront.net/7e08139ddee0ec38005f4232346c7f7386831300/fd934/githubuniverse/remix3d.png">
+        <babylon extends="minimal" scene.default-camera="false">
+            <model url="https://playground.babylonjs.com/scenes/BoomBox.glb" title="GLB Model" subtitle="BabylonJS">
             </model>
             <camera>
                 <behaviors>
@@ -27,7 +26,6 @@
             <lights>
                 <light1 type="1" shadow-enabled="true" position.y="0.5" direction.y="-1" intensity="4.5">
                     <shadow-config use-blur-exponential-shadow-map="true" use-kernel-blur="true" blur-kernel="64" blur-scale="4">
-
                     </shadow-config>
                 </light1>
             </lights>

File diff suppressed because it is too large
+ 1444 - 1001
Viewer/dist/viewer.js


+ 2 - 4
Viewer/package.json

@@ -39,10 +39,8 @@
         "babylonjs-materials": "^3.1.0-beta3",
         "babylonjs-post-process": "^3.1.0-beta3",
         "babylonjs-procedural-textures": "^3.1.0-beta3",
+        "deepmerge": "^2.0.1",
         "es6-promise": "^4.1.1",
-        "handlebars": "^4.0.11",
-        "lodash": "^4.17.4",
-        "lodash.merge": "^4.6.0",
-        "promise-polyfill": "^6.0.2"
+        "handlebars": "^4.0.11"
     }
 }

+ 4 - 4
Viewer/src/configuration/loader.ts

@@ -2,7 +2,7 @@ import { mapperManager } from './mappers';
 import { ViewerConfiguration } from './configuration';
 import { getConfigurationType } from './types';
 
-import * as merge from 'lodash.merge';
+import deepmerge from 'deepmerge';
 
 export class ConfigurationLoader {
 
@@ -10,11 +10,11 @@ export class ConfigurationLoader {
 
     public loadConfiguration(initConfig: ViewerConfiguration = {}): Promise<ViewerConfiguration> {
 
-        let loadedConfig = merge({}, initConfig);
+        let loadedConfig = deepmerge({}, initConfig);
 
         let extendedConfiguration = getConfigurationType(loadedConfig && loadedConfig.extends);
 
-        loadedConfig = merge(extendedConfiguration, loadedConfig);
+        loadedConfig = deepmerge(extendedConfiguration, loadedConfig);
 
         if (loadedConfig.configuration) {
 
@@ -34,7 +34,7 @@ export class ConfigurationLoader {
             let mapper = mapperManager.getMapper(mapperType);
             return this.loadFile(url).then((data: any) => {
                 let parsed = mapper.map(data);
-                return merge(loadedConfig, parsed);
+                return deepmerge(loadedConfig, parsed);
             });
         } else {
             return Promise.resolve(loadedConfig);

+ 0 - 2
Viewer/src/configuration/mappers.ts

@@ -3,8 +3,6 @@ import { ViewerConfiguration } from './configuration';
 
 import { kebabToCamel } from '../helper';
 
-import * as merge from 'lodash.merge';
-
 export interface IMapper {
     map(rawSource: any): ViewerConfiguration;
 }

+ 5 - 3
Viewer/src/viewer/defaultViewer.ts

@@ -371,14 +371,16 @@ export class DefaultViewer extends AbstractViewer {
 
     private setupCamera(focusMeshes: Array<AbstractMesh> = []) {
 
+        let cameraConfig = this.configuration.camera || {};
         let sceneConfig = this.configuration.scene || { autoRotate: false, defaultCamera: true };
 
-        if (sceneConfig.defaultCamera) {
+        if (!this.configuration.camera && sceneConfig.defaultCamera) {
+            if (sceneConfig.autoRotate) {
+                this.camera.useAutoRotationBehavior = true;
+            }
             return;
         }
 
-        let cameraConfig = this.configuration.camera || {};
-
         if (cameraConfig.position) {
             this.camera.position.copyFromFloats(cameraConfig.position.x || 0, cameraConfig.position.y || 0, cameraConfig.position.z || 0);
         }

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


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


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


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


+ 21 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -52834,12 +52834,12 @@ var BABYLON;
             if (sceneFilename.name) {
                 sceneFilename = sceneFilename.name;
             }
-            var dotPosition = sceneFilename.lastIndexOf(".");
             var queryStringPosition = sceneFilename.indexOf("?");
-            if (queryStringPosition === -1) {
-                queryStringPosition = sceneFilename.length;
+            if (queryStringPosition !== -1) {
+                sceneFilename = sceneFilename.substring(0, queryStringPosition);
             }
-            var extension = sceneFilename.substring(dotPosition, queryStringPosition).toLowerCase();
+            var dotPosition = sceneFilename.lastIndexOf(".");
+            var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
             return SceneLoader._getPluginForExtension(extension);
         };
         // use babylon file loader directly if sceneFilename is prefixed with "data:"
@@ -80386,6 +80386,14 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
+                if (!GLTFLoader._progressEventFactory) {
+                    if (typeof window["ProgressEvent"] === "function") {
+                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
+                    }
+                    else {
+                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
+                    }
+                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -80396,6 +80404,14 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
+            GLTFLoader._createProgressEventByConstructor = function (name, data) {
+                return new ProgressEvent(name, data);
+            };
+            GLTFLoader._createProgressEventByDocument = function (name, data) {
+                var event = document.createEvent("ProgressEvent");
+                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
+                return event;
+            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -80456,7 +80472,7 @@ var BABYLON;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                     lengthComputable: true,
                     loaded: loaded,
                     total: total

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


+ 3 - 0
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -324,6 +324,9 @@ declare module BABYLON.GLTF2 {
             [name: string]: GLTFLoaderExtension;
         };
         static RegisterExtension(extension: GLTFLoaderExtension): void;
+        private static _progressEventFactory;
+        private static _createProgressEventByConstructor(name, data);
+        private static _createProgressEventByDocument(name, data);
         constructor(parent: GLTFFileLoader);
         dispose(): void;
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;

+ 17 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -333,6 +333,14 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
+                if (!GLTFLoader._progressEventFactory) {
+                    if (typeof window["ProgressEvent"] === "function") {
+                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
+                    }
+                    else {
+                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
+                    }
+                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -343,6 +351,14 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
+            GLTFLoader._createProgressEventByConstructor = function (name, data) {
+                return new ProgressEvent(name, data);
+            };
+            GLTFLoader._createProgressEventByDocument = function (name, data) {
+                var event = document.createEvent("ProgressEvent");
+                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
+                return event;
+            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -403,7 +419,7 @@ var BABYLON;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                     lengthComputable: true,
                     loaded: loaded,
                     total: total

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


+ 3 - 0
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -871,6 +871,9 @@ declare module BABYLON.GLTF2 {
             [name: string]: GLTFLoaderExtension;
         };
         static RegisterExtension(extension: GLTFLoaderExtension): void;
+        private static _progressEventFactory;
+        private static _createProgressEventByConstructor(name, data);
+        private static _createProgressEventByDocument(name, data);
         constructor(parent: GLTFFileLoader);
         dispose(): void;
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;

+ 17 - 1
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2478,6 +2478,14 @@ var BABYLON;
                 this._loaderPendingCount = 0;
                 this._loaderTrackers = new Array();
                 this._parent = parent;
+                if (!GLTFLoader._progressEventFactory) {
+                    if (typeof window["ProgressEvent"] === "function") {
+                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
+                    }
+                    else {
+                        GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
+                    }
+                }
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -2488,6 +2496,14 @@ var BABYLON;
                 // Keep the order of registration so that extensions registered first are called first.
                 GLTF2.GLTFLoaderExtension._Extensions.push(extension);
             };
+            GLTFLoader._createProgressEventByConstructor = function (name, data) {
+                return new ProgressEvent(name, data);
+            };
+            GLTFLoader._createProgressEventByDocument = function (name, data) {
+                var event = document.createEvent("ProgressEvent");
+                event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
+                return event;
+            };
             GLTFLoader.prototype.dispose = function () {
                 if (this._disposed) {
                     return;
@@ -2548,7 +2564,7 @@ var BABYLON;
                     loaded += request._loaded;
                     total += request._total;
                 }
-                this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+                this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                     lengthComputable: true,
                     loaded: loaded,
                     total: total

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


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


+ 28 - 1
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -38,6 +38,12 @@ module BABYLON.GLTF2 {
         _total: Nullable<number>;
     }
 
+    interface IProgressEventData {
+        lengthComputable: boolean;
+        loaded: number;
+        total: number;
+    }
+
     export class GLTFLoader implements IGLTFLoader {
         public _gltf: IGLTF;
         public _babylonScene: Scene;
@@ -77,8 +83,29 @@ module BABYLON.GLTF2 {
             GLTFLoaderExtension._Extensions.push(extension);
         }
 
+        // IE 11 Compatibility.
+        private static _progressEventFactory: (name: string, data: IProgressEventData) => ProgressEvent;
+        
+        private static _createProgressEventByConstructor(name: string, data: IProgressEventData): ProgressEvent {
+            return new ProgressEvent(name, data);
+        }
+
+        private static _createProgressEventByDocument(name: string, data: IProgressEventData): ProgressEvent {
+            const event = document.createEvent("ProgressEvent");
+            event.initProgressEvent(name, false, false, data.lengthComputable, data.loaded, data.total);
+            return event;
+        }
+
         public constructor(parent: GLTFFileLoader) {
             this._parent = parent;
+            if (!GLTFLoader._progressEventFactory) {
+                if (typeof (<any>window)["ProgressEvent"] === "function") {
+                    GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByConstructor;
+                }
+                else {
+                    GLTFLoader._progressEventFactory = GLTFLoader._createProgressEventByDocument;
+                }
+            }
         }
 
         public dispose(): void {
@@ -148,7 +175,7 @@ module BABYLON.GLTF2 {
                 total += request._total;
             }
 
-            this._progressCallback(new ProgressEvent("GLTFLoaderProgress", {
+            this._progressCallback(GLTFLoader._progressEventFactory("GLTFLoaderProgress", {
                 lengthComputable: true,
                 loaded: loaded,
                 total: total

+ 6 - 6
src/Loading/babylon.sceneLoader.ts

@@ -125,15 +125,15 @@
                 sceneFilename = sceneFilename.name;
             }
 
-            var dotPosition = sceneFilename.lastIndexOf(".");
-
             var queryStringPosition = sceneFilename.indexOf("?");
-
-            if (queryStringPosition === -1) {
-                queryStringPosition = sceneFilename.length;
+            
+            if (queryStringPosition !== -1) {
+                sceneFilename = sceneFilename.substring(0, queryStringPosition);
             }
 
-            var extension = sceneFilename.substring(dotPosition, queryStringPosition).toLowerCase();
+            var dotPosition = sceneFilename.lastIndexOf(".");
+
+            var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
             return SceneLoader._getPluginForExtension(extension);
         }