Browse Source

Merge remote-tracking branch 'BabylonJS/master' into viewer-catch-errors

Raanan Weber 7 years ago
parent
commit
00eb853fa8

File diff suppressed because it is too large
+ 6584 - 6581
Playground/babylon.d.txt


+ 1 - 0
Viewer/src/configuration/loader.ts

@@ -73,6 +73,7 @@ export class ConfigurationLoader {
         this.loadRequests.forEach(request => {
             request.abort();
         });
+        this.loadRequests.length = 0;
     }
 
     private loadFile(url: string): Promise<any> {

+ 8 - 2
Viewer/src/viewer/viewer.ts

@@ -1,6 +1,6 @@
 import { viewerManager } from './viewerManager';
 import { TemplateManager } from './../templateManager';
-import configurationLoader from './../configuration/loader';
+import { ConfigurationLoader } from './../configuration/loader';
 import { CubeTexture, Color3, IEnvironmentHelperOptions, EnvironmentHelper, Effect, SceneOptimizer, SceneOptimizerOptions, Observable, Engine, Scene, ArcRotateCamera, Vector3, SceneLoader, AbstractMesh, Mesh, HemisphericLight, Database, SceneLoaderProgressEvent, ISceneLoaderPlugin, ISceneLoaderPluginAsync, Quaternion, Light, ShadowLight, ShadowGenerator, Tags, AutoRotationBehavior, BouncingBehavior, FramingBehavior, Behavior, Tools } from 'babylonjs';
 import { ViewerConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, IObserversConfiguration, IModelConfiguration, ISkyboxConfiguration, IGroundConfiguration, ILightConfiguration, ICameraConfiguration } from '../configuration/configuration';
 
@@ -52,6 +52,7 @@ export abstract class AbstractViewer {
     public canvas: HTMLCanvasElement;
 
     protected registeredOnBeforerenderFunctions: Array<() => void>;
+    protected _configurationLoader: ConfigurationLoader;
 
     constructor(public containerElement: HTMLElement, initialConfiguration: ViewerConfiguration = {}) {
         // if exists, use the container id. otherwise, generate a random string.
@@ -81,7 +82,8 @@ export abstract class AbstractViewer {
         this.prepareContainerElement();
 
         // extend the configuration
-        configurationLoader.loadConfiguration(initialConfiguration, (configuration) => {
+        this._configurationLoader = new ConfigurationLoader();
+        this._configurationLoader.loadConfiguration(initialConfiguration, (configuration) => {
             this.configuration = deepmerge(this.configuration || {}, configuration);
             if (this.configuration.observers) {
                 this.configureObservers(this.configuration.observers);
@@ -634,6 +636,10 @@ export abstract class AbstractViewer {
             this.environmentHelper.dispose();
         }
 
+        if (this._configurationLoader) {
+            this._configurationLoader.dispose();
+        }
+
         //observers
         this.onEngineInitObservable.clear();
         delete this.onEngineInitObservable;

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


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


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


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

@@ -96305,7 +96305,7 @@ var BABYLON;
                                 if (indexLOD !== 0) {
                                     var previousNodeLOD = nodeLODs[indexLOD - 1];
                                     if (previousNodeLOD._babylonMesh) {
-                                        previousNodeLOD._babylonMesh.dispose();
+                                        previousNodeLOD._babylonMesh.dispose(false, true);
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }

+ 1 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -96278,7 +96278,7 @@ var BABYLON;
                                 if (indexLOD !== 0) {
                                     var previousNodeLOD = nodeLODs[indexLOD - 1];
                                     if (previousNodeLOD._babylonMesh) {
-                                        previousNodeLOD._babylonMesh.dispose();
+                                        previousNodeLOD._babylonMesh.dispose(false, true);
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }

+ 4 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -357,6 +357,10 @@ declare module BABYLON.GUI {
         protected _children: Control[];
         protected _measureForChildren: Measure;
         protected _background: string;
+        protected _adaptWidthToChildren: boolean;
+        protected _adaptHeightToChildren: boolean;
+        adaptHeightToChildren: boolean;
+        adaptWidthToChildren: boolean;
         background: string;
         readonly children: Control[];
         constructor(name?: string | undefined);

+ 50 - 0
dist/preview release/gui/babylon.gui.js

@@ -1994,8 +1994,44 @@ var BABYLON;
                 _this.name = name;
                 _this._children = new Array();
                 _this._measureForChildren = GUI.Measure.Empty();
+                _this._adaptWidthToChildren = false;
+                _this._adaptHeightToChildren = false;
                 return _this;
             }
+            Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
+                get: function () {
+                    return this._adaptHeightToChildren;
+                },
+                set: function (value) {
+                    if (this._adaptHeightToChildren === value) {
+                        return;
+                    }
+                    this._adaptHeightToChildren = value;
+                    if (value) {
+                        this.height = "100%";
+                    }
+                    this._markAsDirty();
+                },
+                enumerable: true,
+                configurable: true
+            });
+            Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
+                get: function () {
+                    return this._adaptWidthToChildren;
+                },
+                set: function (value) {
+                    if (this._adaptWidthToChildren === value) {
+                        return;
+                    }
+                    this._adaptWidthToChildren = value;
+                    if (value) {
+                        this.width = "100%";
+                    }
+                    this._markAsDirty();
+                },
+                enumerable: true,
+                configurable: true
+            });
             Object.defineProperty(Container.prototype, "background", {
                 get: function () {
                     return this._background;
@@ -2119,6 +2155,8 @@ var BABYLON;
                 if (this._processMeasures(parentMeasure, context)) {
                     this._localDraw(context);
                     this._clipForChildren(context);
+                    var computedWidth = -1;
+                    var computedHeight = -1;
                     for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
                         var child = _a[_i];
                         if (child.isVisible && !child.notRenderable) {
@@ -2127,8 +2165,20 @@ var BABYLON;
                             if (child.onAfterDrawObservable.hasObservers()) {
                                 child.onAfterDrawObservable.notifyObservers(child);
                             }
+                            if (this.adaptWidthToChildren && child._width.isPixel) {
+                                computedWidth = Math.max(computedWidth, child._currentMeasure.width);
+                            }
+                            if (this.adaptHeightToChildren && child._height.isPixel) {
+                                computedHeight = Math.max(computedHeight, child._currentMeasure.height);
+                            }
                         }
                     }
+                    if (this.adaptWidthToChildren && computedWidth >= 0) {
+                        this.width = computedWidth + "px";
+                    }
+                    if (this.adaptHeightToChildren && computedHeight >= 0) {
+                        this.height = computedHeight + "px";
+                    }
                 }
                 context.restore();
                 if (this.onAfterDrawObservable.hasObservers()) {

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


+ 4 - 0
dist/preview release/gui/babylon.gui.module.d.ts

@@ -363,6 +363,10 @@ declare module BABYLON.GUI {
         protected _children: Control[];
         protected _measureForChildren: Measure;
         protected _background: string;
+        protected _adaptWidthToChildren: boolean;
+        protected _adaptHeightToChildren: boolean;
+        adaptHeightToChildren: boolean;
+        adaptWidthToChildren: boolean;
         background: string;
         readonly children: Control[];
         constructor(name?: string | undefined);

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

@@ -2022,7 +2022,7 @@ var BABYLON;
                                 if (indexLOD !== 0) {
                                     var previousNodeLOD = nodeLODs[indexLOD - 1];
                                     if (previousNodeLOD._babylonMesh) {
-                                        previousNodeLOD._babylonMesh.dispose();
+                                        previousNodeLOD._babylonMesh.dispose(false, true);
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }

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


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

@@ -4220,7 +4220,7 @@ var BABYLON;
                                 if (indexLOD !== 0) {
                                     var previousNodeLOD = nodeLODs[indexLOD - 1];
                                     if (previousNodeLOD._babylonMesh) {
-                                        previousNodeLOD._babylonMesh.dispose();
+                                        previousNodeLOD._babylonMesh.dispose(false, true);
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }

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


+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.js

@@ -5194,7 +5194,7 @@ var BABYLON;
                                 if (indexLOD !== 0) {
                                     var previousNodeLOD = nodeLODs[indexLOD - 1];
                                     if (previousNodeLOD._babylonMesh) {
-                                        previousNodeLOD._babylonMesh.dispose();
+                                        previousNodeLOD._babylonMesh.dispose(false, true);
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }

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


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


+ 7 - 2
dist/preview release/viewer/babylon.viewer.max.js

@@ -93685,7 +93685,8 @@ var AbstractViewer = (function () {
         viewerManager_1.viewerManager.addViewer(this);
         this.templateManager = new templateManager_1.TemplateManager(containerElement);
         this.prepareContainerElement();
-        loader_1.default.loadConfiguration(initialConfiguration, function (configuration) {
+        this._configurationLoader = new loader_1.ConfigurationLoader();
+        this._configurationLoader.loadConfiguration(initialConfiguration, function (configuration) {
             _this.configuration = deepmerge(_this.configuration || {}, configuration);
             if (_this.configuration.observers) {
                 _this.configureObservers(_this.configuration.observers);
@@ -94155,6 +94156,9 @@ var AbstractViewer = (function () {
         if (this.environmentHelper) {
             this.environmentHelper.dispose();
         }
+        if (this._configurationLoader) {
+            this._configurationLoader.dispose();
+        }
         this.onEngineInitObservable.clear();
         delete this.onEngineInitObservable;
         this.onInitDoneObservable.clear();
@@ -95145,6 +95149,7 @@ var ConfigurationLoader = (function () {
         this.loadRequests.forEach(function (request) {
             request.abort();
         });
+        this.loadRequests.length = 0;
     };
     ConfigurationLoader.prototype.loadFile = function (url) {
         var _this = this;
@@ -100827,7 +100832,7 @@ var BABYLON;
                                 if (indexLOD !== 0) {
                                     var previousNodeLOD = nodeLODs[indexLOD - 1];
                                     if (previousNodeLOD._babylonMesh) {
-                                        previousNodeLOD._babylonMesh.dispose();
+                                        previousNodeLOD._babylonMesh.dispose(false, true);
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }

+ 56 - 0
gui/src/controls/container.ts

@@ -5,6 +5,44 @@ module BABYLON.GUI {
         protected _children = new Array<Control>();
         protected _measureForChildren = Measure.Empty();  
         protected _background: string;   
+        protected _adaptWidthToChildren = false;
+        protected _adaptHeightToChildren = false;
+
+        public get adaptHeightToChildren(): boolean {
+            return this._adaptHeightToChildren;
+        }
+
+        public set adaptHeightToChildren(value: boolean) {
+            if (this._adaptHeightToChildren === value) {
+                return;
+            }
+
+            this._adaptHeightToChildren = value;
+
+            if (value) {
+                this.height = "100%";
+            }
+
+            this._markAsDirty();
+        }       
+        
+        public get adaptWidthToChildren(): boolean {
+            return this._adaptWidthToChildren;
+        }
+
+        public set adaptWidthToChildren(value: boolean) {
+            if (this._adaptWidthToChildren === value) {
+                return;
+            }
+
+            this._adaptWidthToChildren = value;
+
+            if (value) {
+                this.width = "100%";
+            }
+
+            this._markAsDirty();
+        }           
 
         public get background(): string {
             return this._background;
@@ -159,6 +197,10 @@ module BABYLON.GUI {
                 this._localDraw(context);
 
                 this._clipForChildren(context);
+
+                let computedWidth = -1;
+                let computedHeight = -1;
+
                 for (var child of this._children) {
                     if (child.isVisible && !child.notRenderable) {
                         child._tempParentMeasure.copyFrom(this._measureForChildren);
@@ -167,8 +209,22 @@ module BABYLON.GUI {
                         if (child.onAfterDrawObservable.hasObservers()) {
                             child.onAfterDrawObservable.notifyObservers(child);
                         }
+
+                        if (this.adaptWidthToChildren && child._width.isPixel) {
+                            computedWidth = Math.max(computedWidth, child._currentMeasure.width);
+                        }
+                        if (this.adaptHeightToChildren && child._height.isPixel) {
+                            computedHeight = Math.max(computedHeight, child._currentMeasure.height);
+                        }                        
                     }
                 }
+
+                if (this.adaptWidthToChildren && computedWidth >= 0) {
+                    this.width = computedWidth + "px";
+                }
+                if (this.adaptHeightToChildren && computedHeight >= 0) {
+                    this.height = computedHeight + "px";
+                }                
             }
             context.restore();
 

+ 1 - 2
gui/src/tsconfig.json

@@ -7,7 +7,6 @@
     "noImplicitReturns": true,
     "noImplicitThis": true,
     "noUnusedLocals": true,    
-    "strictNullChecks": true,
-    "strict": true
+    "strictNullChecks": true    
   }
 }

+ 1 - 1
loaders/src/glTF/2.0/Extensions/MSFT_lod.ts

@@ -43,7 +43,7 @@ module BABYLON.GLTF2.Extensions {
                         if (indexLOD !== 0) {
                             const previousNodeLOD = nodeLODs[indexLOD - 1];
                             if (previousNodeLOD._babylonMesh) {
-                                previousNodeLOD._babylonMesh.dispose();
+                                previousNodeLOD._babylonMesh.dispose(false, true);
                                 delete previousNodeLOD._babylonMesh;
                             }
                         }