Sfoglia il codice sorgente

Merge pull request #3591 from RaananW/viewer-url-bugfix

Viewer url bugfix
Raanan Weber 7 anni fa
parent
commit
d3e75cebc6

+ 4 - 3
Viewer/dist/basicExample.html

@@ -17,8 +17,9 @@
     </head>
 
     <body>
-        <babylon model.title="Damaged Helmet" model.subtitle="BabylonJS" model.thumbnail="https://www.babylonjs.com/img/favicon/apple-icon-144x144.png"
-            model.url="https://www.babylonjs.com/Assets/DamagedHelmet/glTF/DamagedHelmet.gltf" camera.behaviors.auto-rotate="0" templates.nav-bar.params.disable-on-fullscreen="true"></babylon>
+        <babylon configuration="config.json" model.title="Damaged Helmet" model.subtitle="BabylonJS" model.thumbnail="https://www.babylonjs.com/img/favicon/apple-icon-144x144.png"
+            model.url="https://www.babylonjs.com/Assets/DamagedHelmet/glTF/DamagedHelmet.gltf" camera.behaviors.auto-rotate="0"
+            templates.nav-bar.params.disable-on-fullscreen="true"></babylon>
         <script src="viewer.js"></script>
         <script>
             // The following lines are redundant. 
@@ -31,4 +32,4 @@
         </script>
     </body>
 
-</html>
+</html>

+ 5 - 0
Viewer/dist/config.json

@@ -0,0 +1,5 @@
+{
+    "scene": {
+        "debug": false
+    }
+}

+ 6 - 5
Viewer/dist/viewer.js

@@ -82698,7 +82698,6 @@ var MapperManager = (function () {
 }());
 exports.MapperManager = MapperManager;
 exports.mapperManager = new MapperManager();
-exports.default = exports.mapperManager;
 
 
 /***/ }),
@@ -82795,6 +82794,7 @@ var ViewerManager = (function () {
     };
     return ViewerManager;
 }());
+exports.ViewerManager = ViewerManager;
 exports.viewerManager = new ViewerManager();
 
 
@@ -110011,6 +110011,7 @@ var types_1 = __webpack_require__(21);
 var deepmerge = __webpack_require__(28);
 var ConfigurationLoader = (function () {
     function ConfigurationLoader() {
+        this.configurationCache = {};
     }
     ConfigurationLoader.prototype.loadConfiguration = function (initConfig) {
         if (initConfig === void 0) { initConfig = {}; }
@@ -110056,10 +110057,10 @@ var ConfigurationLoader = (function () {
                         cacheReference[url] = xhr.responseText;
                         resolve(xhr.responseText);
                     }
-                }
-                else {
-                    console.log('Error: ' + xhr.status, url);
-                    reject('Error: ' + xhr.status);
+                    else {
+                        console.log('Error: ' + xhr.status, url);
+                        reject('Error: ' + xhr.status);
+                    }
                 }
             };
         });

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


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

@@ -6,7 +6,11 @@ import * as deepmerge from '../../assets/deepmerge.min.js';
 
 export class ConfigurationLoader {
 
-    private configurationCache: { (url: string): any };
+    private configurationCache: { [url: string]: any };
+
+    constructor() {
+        this.configurationCache = {};
+    }
 
     public loadConfiguration(initConfig: ViewerConfiguration = {}): Promise<ViewerConfiguration> {
 
@@ -62,10 +66,10 @@ export class ConfigurationLoader {
                     if (xhr.status === OK) {
                         cacheReference[url] = xhr.responseText;
                         resolve(xhr.responseText); // 'This is the returned text.'
+                    } else {
+                        console.log('Error: ' + xhr.status, url);
+                        reject('Error: ' + xhr.status); // An error occurred during the request.
                     }
-                } else {
-                    console.log('Error: ' + xhr.status, url);
-                    reject('Error: ' + xhr.status); // An error occurred during the request.
                 }
             }
         });

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

@@ -117,5 +117,4 @@ export class MapperManager {
 
 }
 
-export let mapperManager = new MapperManager();
-export default mapperManager;
+export let mapperManager = new MapperManager();

+ 2 - 1
Viewer/src/configuration/types/index.ts

@@ -1,7 +1,8 @@
 import { minimalConfiguration } from './minimal';
 import { defaultConfiguration } from './default';
+import { ViewerConfiguration } from '../configuration';
 
-let getConfigurationType = function (type: string) {
+let getConfigurationType = function (type: string): ViewerConfiguration {
     switch (type) {
         case 'default':
             return defaultConfiguration;

+ 1 - 1
Viewer/src/viewer/viewerManager.ts

@@ -3,7 +3,7 @@
 import { Observable } from 'babylonjs';
 import { AbstractViewer } from './viewer';
 
-class ViewerManager {
+export class ViewerManager {
 
     private viewers: { [key: string]: AbstractViewer };