Просмотр исходного кода

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

# Conflicts:
#	dist/preview release/babylon.d.ts
#	dist/preview release/babylon.js
#	dist/preview release/babylon.module.d.ts
#	dist/preview release/babylon.worker.js
#	dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
#	dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
#	dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
David Rousset 8 лет назад
Родитель
Сommit
39b471d3dd

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

@@ -304,8 +304,12 @@ declare module BABYLON.GUI {
     class StackPanel extends Container {
     class StackPanel extends Container {
         name: string;
         name: string;
         private _isVertical;
         private _isVertical;
+        private _manualWidth;
+        private _manualHeight;
         private _tempMeasureStore;
         private _tempMeasureStore;
         isVertical: boolean;
         isVertical: boolean;
+        manualWidth: boolean;
+        manualHeight: boolean;
         constructor(name?: string);
         constructor(name?: string);
         protected _getTypeName(): string;
         protected _getTypeName(): string;
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;

+ 24 - 9
dist/preview release/babylon.max.js

@@ -8434,8 +8434,8 @@ var BABYLON;
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          */
          */
         Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
         Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
-            var width = requiredWidth || (navigator.isCocoonJS ? window.innerWidth : this.getRenderWidth());
-            var height = requiredHeight || (navigator.isCocoonJS ? window.innerHeight : this.getRenderHeight());
+            var width = requiredWidth || this.getRenderWidth();
+            var height = requiredHeight || this.getRenderHeight();
             var x = viewport.x || 0;
             var x = viewport.x || 0;
             var y = viewport.y || 0;
             var y = viewport.y || 0;
             this._cachedViewport = viewport;
             this._cachedViewport = viewport;
@@ -8570,7 +8570,7 @@ var BABYLON;
                 this.vrDisplaysPromise = navigator.getVRDisplays().then(getWebVRDevices);
                 this.vrDisplaysPromise = navigator.getVRDisplays().then(getWebVRDevices);
             }
             }
         };
         };
-        Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight) {
+        Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
             if (this._currentRenderTarget) {
             if (this._currentRenderTarget) {
                 this.unBindFramebuffer(this._currentRenderTarget);
                 this.unBindFramebuffer(this._currentRenderTarget);
             }
             }
@@ -8580,7 +8580,12 @@ var BABYLON;
             if (texture.isCube) {
             if (texture.isCube) {
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
             }
             }
-            gl.viewport(0, 0, requiredWidth || texture._width, requiredHeight || texture._height);
+            if (this._cachedViewport && !forceFullscreenViewport) {
+                this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
+            }
+            else {
+                gl.viewport(0, 0, requiredWidth || texture._width, requiredHeight || texture._height);
+            }
             this.wipeCaches();
             this.wipeCaches();
         };
         };
         Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
         Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
@@ -19995,12 +20000,20 @@ var BABYLON;
         };
         };
         Texture.prototype.getReflectionTextureMatrix = function () {
         Texture.prototype.getReflectionTextureMatrix = function () {
             var _this = this;
             var _this = this;
+            var scene = this.getScene();
             if (this.uOffset === this._cachedUOffset &&
             if (this.uOffset === this._cachedUOffset &&
                 this.vOffset === this._cachedVOffset &&
                 this.vOffset === this._cachedVOffset &&
                 this.uScale === this._cachedUScale &&
                 this.uScale === this._cachedUScale &&
                 this.vScale === this._cachedVScale &&
                 this.vScale === this._cachedVScale &&
                 this.coordinatesMode === this._cachedCoordinatesMode) {
                 this.coordinatesMode === this._cachedCoordinatesMode) {
-                return this._cachedTextureMatrix;
+                if (this.coordinatesMode === Texture.PROJECTION_MODE) {
+                    if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
+                        return this._cachedTextureMatrix;
+                    }
+                }
+                else {
+                    return this._cachedTextureMatrix;
+                }
             }
             }
             if (!this._cachedTextureMatrix) {
             if (!this._cachedTextureMatrix) {
                 this._cachedTextureMatrix = BABYLON.Matrix.Zero();
                 this._cachedTextureMatrix = BABYLON.Matrix.Zero();
@@ -20028,13 +20041,15 @@ var BABYLON;
                     this._projectionModeMatrix.m[13] = 0.5;
                     this._projectionModeMatrix.m[13] = 0.5;
                     this._projectionModeMatrix.m[14] = 1.0;
                     this._projectionModeMatrix.m[14] = 1.0;
                     this._projectionModeMatrix.m[15] = 1.0;
                     this._projectionModeMatrix.m[15] = 1.0;
-                    this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
+                    var projectionMatrix = scene.getProjectionMatrix();
+                    this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
+                    projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
                     break;
                     break;
                 default:
                 default:
                     BABYLON.Matrix.IdentityToRef(this._cachedTextureMatrix);
                     BABYLON.Matrix.IdentityToRef(this._cachedTextureMatrix);
                     break;
                     break;
             }
             }
-            this.getScene().markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag, function (mat) {
+            scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag, function (mat) {
                 return (mat.getActiveTextures().indexOf(_this) !== -1);
                 return (mat.getActiveTextures().indexOf(_this) !== -1);
             });
             });
             return this._cachedTextureMatrix;
             return this._cachedTextureMatrix;
@@ -45952,11 +45967,11 @@ var BABYLON;
             }
             }
             if (this.enablePixelPerfectMode) {
             if (this.enablePixelPerfectMode) {
                 this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
                 this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
-                this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight);
+                this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, true);
             }
             }
             else {
             else {
                 this._scaleRatio.copyFromFloats(1, 1);
                 this._scaleRatio.copyFromFloats(1, 1);
-                this._engine.bindFramebuffer(target);
+                this._engine.bindFramebuffer(target, 0, undefined, undefined, true);
             }
             }
             this.onActivateObservable.notifyObservers(camera);
             this.onActivateObservable.notifyObservers(camera);
             // Clear
             // Clear

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

@@ -8434,8 +8434,8 @@ var BABYLON;
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          */
          */
         Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
         Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
-            var width = requiredWidth || (navigator.isCocoonJS ? window.innerWidth : this.getRenderWidth());
-            var height = requiredHeight || (navigator.isCocoonJS ? window.innerHeight : this.getRenderHeight());
+            var width = requiredWidth || this.getRenderWidth();
+            var height = requiredHeight || this.getRenderHeight();
             var x = viewport.x || 0;
             var x = viewport.x || 0;
             var y = viewport.y || 0;
             var y = viewport.y || 0;
             this._cachedViewport = viewport;
             this._cachedViewport = viewport;
@@ -8570,7 +8570,7 @@ var BABYLON;
                 this.vrDisplaysPromise = navigator.getVRDisplays().then(getWebVRDevices);
                 this.vrDisplaysPromise = navigator.getVRDisplays().then(getWebVRDevices);
             }
             }
         };
         };
-        Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight) {
+        Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
             if (this._currentRenderTarget) {
             if (this._currentRenderTarget) {
                 this.unBindFramebuffer(this._currentRenderTarget);
                 this.unBindFramebuffer(this._currentRenderTarget);
             }
             }
@@ -8580,7 +8580,12 @@ var BABYLON;
             if (texture.isCube) {
             if (texture.isCube) {
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
             }
             }
-            gl.viewport(0, 0, requiredWidth || texture._width, requiredHeight || texture._height);
+            if (this._cachedViewport && !forceFullscreenViewport) {
+                this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
+            }
+            else {
+                gl.viewport(0, 0, requiredWidth || texture._width, requiredHeight || texture._height);
+            }
             this.wipeCaches();
             this.wipeCaches();
         };
         };
         Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
         Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
@@ -19995,12 +20000,20 @@ var BABYLON;
         };
         };
         Texture.prototype.getReflectionTextureMatrix = function () {
         Texture.prototype.getReflectionTextureMatrix = function () {
             var _this = this;
             var _this = this;
+            var scene = this.getScene();
             if (this.uOffset === this._cachedUOffset &&
             if (this.uOffset === this._cachedUOffset &&
                 this.vOffset === this._cachedVOffset &&
                 this.vOffset === this._cachedVOffset &&
                 this.uScale === this._cachedUScale &&
                 this.uScale === this._cachedUScale &&
                 this.vScale === this._cachedVScale &&
                 this.vScale === this._cachedVScale &&
                 this.coordinatesMode === this._cachedCoordinatesMode) {
                 this.coordinatesMode === this._cachedCoordinatesMode) {
-                return this._cachedTextureMatrix;
+                if (this.coordinatesMode === Texture.PROJECTION_MODE) {
+                    if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
+                        return this._cachedTextureMatrix;
+                    }
+                }
+                else {
+                    return this._cachedTextureMatrix;
+                }
             }
             }
             if (!this._cachedTextureMatrix) {
             if (!this._cachedTextureMatrix) {
                 this._cachedTextureMatrix = BABYLON.Matrix.Zero();
                 this._cachedTextureMatrix = BABYLON.Matrix.Zero();
@@ -20028,13 +20041,15 @@ var BABYLON;
                     this._projectionModeMatrix.m[13] = 0.5;
                     this._projectionModeMatrix.m[13] = 0.5;
                     this._projectionModeMatrix.m[14] = 1.0;
                     this._projectionModeMatrix.m[14] = 1.0;
                     this._projectionModeMatrix.m[15] = 1.0;
                     this._projectionModeMatrix.m[15] = 1.0;
-                    this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
+                    var projectionMatrix = scene.getProjectionMatrix();
+                    this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
+                    projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
                     break;
                     break;
                 default:
                 default:
                     BABYLON.Matrix.IdentityToRef(this._cachedTextureMatrix);
                     BABYLON.Matrix.IdentityToRef(this._cachedTextureMatrix);
                     break;
                     break;
             }
             }
-            this.getScene().markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag, function (mat) {
+            scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag, function (mat) {
                 return (mat.getActiveTextures().indexOf(_this) !== -1);
                 return (mat.getActiveTextures().indexOf(_this) !== -1);
             });
             });
             return this._cachedTextureMatrix;
             return this._cachedTextureMatrix;
@@ -34387,11 +34402,11 @@ var BABYLON;
             }
             }
             if (this.enablePixelPerfectMode) {
             if (this.enablePixelPerfectMode) {
                 this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
                 this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
-                this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight);
+                this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, true);
             }
             }
             else {
             else {
                 this._scaleRatio.copyFromFloats(1, 1);
                 this._scaleRatio.copyFromFloats(1, 1);
-                this._engine.bindFramebuffer(target);
+                this._engine.bindFramebuffer(target, 0, undefined, undefined, true);
             }
             }
             this.onActivateObservable.notifyObservers(camera);
             this.onActivateObservable.notifyObservers(camera);
             // Clear
             // Clear

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

@@ -25,6 +25,7 @@ declare module BABYLON.GUI {
         idealHeight: number;
         idealHeight: number;
         renderAtIdealSize: boolean;
         renderAtIdealSize: boolean;
         readonly layer: Layer;
         readonly layer: Layer;
+        readonly rootContainer: Container;
         constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number);
         constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number);
         executeOnAllControls(func: (control: Control) => void, container?: Container): void;
         executeOnAllControls(func: (control: Control) => void, container?: Container): void;
         markAsDirty(): void;
         markAsDirty(): void;
@@ -307,8 +308,13 @@ declare module BABYLON.GUI {
     class StackPanel extends Container {
     class StackPanel extends Container {
         name: string;
         name: string;
         private _isVertical;
         private _isVertical;
+        private _manualWidth;
+        private _manualHeight;
+        private _doNotTrackManualChanges;
         private _tempMeasureStore;
         private _tempMeasureStore;
         isVertical: boolean;
         isVertical: boolean;
+        width: string | number;
+        height: string | number;
         constructor(name?: string);
         constructor(name?: string);
         protected _getTypeName(): string;
         protected _getTypeName(): string;
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;

+ 79 - 15
dist/preview release/gui/babylon.gui.js

@@ -104,6 +104,13 @@ var BABYLON;
                 enumerable: true,
                 enumerable: true,
                 configurable: true
                 configurable: true
             });
             });
+            Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
+                get: function () {
+                    return this._rootContainer;
+                },
+                enumerable: true,
+                configurable: true
+            });
             AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
             AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
                 if (!container) {
                 if (!container) {
                     container = this._rootContainer;
                     container = this._rootContainer;
@@ -1750,6 +1757,9 @@ var BABYLON;
                 var _this = _super.call(this, name) || this;
                 var _this = _super.call(this, name) || this;
                 _this.name = name;
                 _this.name = name;
                 _this._isVertical = true;
                 _this._isVertical = true;
+                _this._manualWidth = false;
+                _this._manualHeight = false;
+                _this._doNotTrackManualChanges = false;
                 _this._tempMeasureStore = GUI.Measure.Empty();
                 _this._tempMeasureStore = GUI.Measure.Empty();
                 return _this;
                 return _this;
             }
             }
@@ -1767,50 +1777,104 @@ var BABYLON;
                 enumerable: true,
                 enumerable: true,
                 configurable: true
                 configurable: true
             });
             });
+            Object.defineProperty(StackPanel.prototype, "width", {
+                get: function () {
+                    return this._width.toString(this._host);
+                },
+                set: function (value) {
+                    if (!this._doNotTrackManualChanges) {
+                        this._manualWidth = true;
+                    }
+                    if (this._width.toString(this._host) === value) {
+                        return;
+                    }
+                    if (this._width.fromString(value)) {
+                        this._markAsDirty();
+                    }
+                },
+                enumerable: true,
+                configurable: true
+            });
+            Object.defineProperty(StackPanel.prototype, "height", {
+                get: function () {
+                    return this._height.toString(this._host);
+                },
+                set: function (value) {
+                    if (!this._doNotTrackManualChanges) {
+                        this._manualHeight = true;
+                    }
+                    if (this._height.toString(this._host) === value) {
+                        return;
+                    }
+                    if (this._height.fromString(value)) {
+                        this._markAsDirty();
+                    }
+                },
+                enumerable: true,
+                configurable: true
+            });
             StackPanel.prototype._getTypeName = function () {
             StackPanel.prototype._getTypeName = function () {
                 return "StackPanel";
                 return "StackPanel";
             };
             };
             StackPanel.prototype._preMeasure = function (parentMeasure, context) {
             StackPanel.prototype._preMeasure = function (parentMeasure, context) {
-                var stack = 0;
+                var stackWidth = 0;
+                var stackHeight = 0;
                 for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
                 for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
                     var child = _a[_i];
                     var child = _a[_i];
                     this._tempMeasureStore.copyFrom(child._currentMeasure);
                     this._tempMeasureStore.copyFrom(child._currentMeasure);
                     child._currentMeasure.copyFrom(parentMeasure);
                     child._currentMeasure.copyFrom(parentMeasure);
                     child._measure();
                     child._measure();
                     if (this._isVertical) {
                     if (this._isVertical) {
-                        child.top = stack + "px";
+                        child.top = stackHeight + "px";
                         if (!child._top.ignoreAdaptiveScaling) {
                         if (!child._top.ignoreAdaptiveScaling) {
                             child._markAsDirty();
                             child._markAsDirty();
                         }
                         }
                         child._top.ignoreAdaptiveScaling = true;
                         child._top.ignoreAdaptiveScaling = true;
-                        stack += child._currentMeasure.height;
+                        stackHeight += child._currentMeasure.height;
+                        if (child._currentMeasure.width > stackWidth) {
+                            stackWidth = child._currentMeasure.width;
+                        }
                         child.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
                         child.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
                     }
                     }
                     else {
                     else {
-                        child.left = stack + "px";
+                        child.left = stackWidth + "px";
                         if (!child._left.ignoreAdaptiveScaling) {
                         if (!child._left.ignoreAdaptiveScaling) {
                             child._markAsDirty();
                             child._markAsDirty();
                         }
                         }
                         child._left.ignoreAdaptiveScaling = true;
                         child._left.ignoreAdaptiveScaling = true;
-                        stack += child._currentMeasure.width;
+                        stackWidth += child._currentMeasure.width;
+                        if (child._currentMeasure.height > stackHeight) {
+                            stackHeight = child._currentMeasure.height;
+                        }
                         child.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
                         child.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
                     }
                     }
                     child._currentMeasure.copyFrom(this._tempMeasureStore);
                     child._currentMeasure.copyFrom(this._tempMeasureStore);
                 }
                 }
-                var panelChanged = false;
-                if (this._isVertical) {
-                    var previousHeight = this.height;
-                    this.height = stack + "px";
-                    panelChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
+                this._doNotTrackManualChanges = true;
+                // Let stack panel width and height default to stackHeight and stackWidth if dimensions are not specified.
+                // User can now define their own height and width for stack panel.
+                var panelWidthChanged = false;
+                var panelHeightChanged = false;
+                var previousHeight = this.height;
+                var previousWidth = this.width;
+                if (!this._manualHeight) {
+                    // do not specify height if strictly defined by user
+                    this.height = stackHeight + "px";
+                }
+                if (!this._manualWidth) {
+                    // do not specify width if strictly defined by user
+                    this.width = stackWidth + "px";
+                }
+                panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
+                panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
+                if (panelHeightChanged) {
                     this._height.ignoreAdaptiveScaling = true;
                     this._height.ignoreAdaptiveScaling = true;
                 }
                 }
-                else {
-                    var previousWidth = this.width;
-                    this.width = stack + "px";
-                    panelChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
+                if (panelWidthChanged) {
                     this._width.ignoreAdaptiveScaling = true;
                     this._width.ignoreAdaptiveScaling = true;
                 }
                 }
-                if (panelChanged) {
+                this._doNotTrackManualChanges = false;
+                if (panelWidthChanged || panelHeightChanged) {
                     this._markAllAsDirty();
                     this._markAllAsDirty();
                 }
                 }
                 _super.prototype._preMeasure.call(this, parentMeasure, context);
                 _super.prototype._preMeasure.call(this, parentMeasure, context);

Разница между файлами не показана из-за своего большого размера
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


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

@@ -25,6 +25,7 @@ declare module BABYLON.GUI {
         idealHeight: number;
         idealHeight: number;
         renderAtIdealSize: boolean;
         renderAtIdealSize: boolean;
         readonly layer: Layer;
         readonly layer: Layer;
+        readonly rootContainer: Container;
         constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number);
         constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number);
         executeOnAllControls(func: (control: Control) => void, container?: Container): void;
         executeOnAllControls(func: (control: Control) => void, container?: Container): void;
         markAsDirty(): void;
         markAsDirty(): void;
@@ -307,8 +308,13 @@ declare module BABYLON.GUI {
     class StackPanel extends Container {
     class StackPanel extends Container {
         name: string;
         name: string;
         private _isVertical;
         private _isVertical;
+        private _manualWidth;
+        private _manualHeight;
+        private _doNotTrackManualChanges;
         private _tempMeasureStore;
         private _tempMeasureStore;
         isVertical: boolean;
         isVertical: boolean;
+        width: string | number;
+        height: string | number;
         constructor(name?: string);
         constructor(name?: string);
         protected _getTypeName(): string;
         protected _getTypeName(): string;
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 4 - 0
gui/src/advancedDynamicTexture.ts

@@ -79,6 +79,10 @@ module BABYLON.GUI {
         public get layer(): Layer {
         public get layer(): Layer {
             return this._layerToDispose;
             return this._layerToDispose;
         }   
         }   
+
+        public get rootContainer(): Container {
+            return this._rootContainer;
+        }
        
        
         constructor(name: string, width = 0, height = 0, scene: Scene, generateMipMaps = false, samplingMode = Texture.NEAREST_SAMPLINGMODE) {
         constructor(name: string, width = 0, height = 0, scene: Scene, generateMipMaps = false, samplingMode = Texture.NEAREST_SAMPLINGMODE) {
             super(name, {width: width, height: height}, scene, generateMipMaps, samplingMode, Engine.TEXTUREFORMAT_RGBA);
             super(name, {width: width, height: height}, scene, generateMipMaps, samplingMode, Engine.TEXTUREFORMAT_RGBA);

+ 80 - 17
gui/src/controls/stackPanel.ts

@@ -3,6 +3,9 @@
 module BABYLON.GUI {
 module BABYLON.GUI {
     export class StackPanel extends Container {
     export class StackPanel extends Container {
         private _isVertical = true;
         private _isVertical = true;
+        private _manualWidth = false;
+        private _manualHeight = false;
+        private _doNotTrackManualChanges = false;
         private _tempMeasureStore = Measure.Empty();
         private _tempMeasureStore = Measure.Empty();
 
 
         public get isVertical(): boolean {
         public get isVertical(): boolean {
@@ -16,7 +19,43 @@ module BABYLON.GUI {
 
 
             this._isVertical = value;
             this._isVertical = value;
             this._markAsDirty();
             this._markAsDirty();
-        }           
+        }
+       
+        public set width(value: string | number ) {
+            if (!this._doNotTrackManualChanges) {
+                this._manualWidth = true;
+            }
+
+            if (this._width.toString(this._host) === value) {
+                return;
+            }
+
+            if (this._width.fromString(value)) {
+                this._markAsDirty();
+            }
+        }
+
+        public get width(): string | number {
+            return this._width.toString(this._host);
+        }        
+
+        public set height(value: string | number ) {
+            if (!this._doNotTrackManualChanges) {
+                this._manualHeight = true;
+            }
+
+            if (this._height.toString(this._host) === value) {
+                return;
+            }
+
+            if (this._height.fromString(value)) {
+                this._markAsDirty();
+            }
+        }        
+                
+        public get height(): string | number  {
+            return this._height.toString(this._host);
+        }
     
     
         constructor(public name?: string) {
         constructor(public name?: string) {
             super(name);
             super(name);
@@ -27,50 +66,74 @@ module BABYLON.GUI {
         }              
         }              
 
 
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void {
         protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void {
-            var stack = 0;
+            var stackWidth = 0;
+            var stackHeight = 0;
             for (var child of this._children) {
             for (var child of this._children) {
                 this._tempMeasureStore.copyFrom(child._currentMeasure);
                 this._tempMeasureStore.copyFrom(child._currentMeasure);
                 child._currentMeasure.copyFrom(parentMeasure);
                 child._currentMeasure.copyFrom(parentMeasure);
                 child._measure();
                 child._measure();
                 
                 
                 if (this._isVertical) {
                 if (this._isVertical) {
-                    child.top = stack + "px";
+                    child.top = stackHeight + "px";
                     if (!child._top.ignoreAdaptiveScaling) {
                     if (!child._top.ignoreAdaptiveScaling) {
                         child._markAsDirty();
                         child._markAsDirty();
                     }
                     }
                     child._top.ignoreAdaptiveScaling = true;
                     child._top.ignoreAdaptiveScaling = true;
-                    stack += child._currentMeasure.height;
+                    stackHeight += child._currentMeasure.height;
+                    if(child._currentMeasure.width > stackWidth) {
+                        stackWidth = child._currentMeasure.width;                        
+                    }
                     child.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
                     child.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
                 } else {
                 } else {
-                    child.left = stack + "px";
+                    child.left = stackWidth + "px";
                     if (!child._left.ignoreAdaptiveScaling) {
                     if (!child._left.ignoreAdaptiveScaling) {
                         child._markAsDirty();
                         child._markAsDirty();
                     }                    
                     }                    
                     child._left.ignoreAdaptiveScaling = true;
                     child._left.ignoreAdaptiveScaling = true;
-                    stack += child._currentMeasure.width;
+                    stackWidth += child._currentMeasure.width;
+                    if(child._currentMeasure.height > stackHeight) {
+                        stackHeight = child._currentMeasure.height;                        
+                    }
                     child.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
                     child.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
                 }
                 }
 
 
                 child._currentMeasure.copyFrom(this._tempMeasureStore);
                 child._currentMeasure.copyFrom(this._tempMeasureStore);
             }
             }
+            
+            this._doNotTrackManualChanges = true;
 
 
-            let panelChanged = false;
-            if (this._isVertical) {
-                let previousHeight = this.height;
-                this.height = stack + "px";
-                
-                panelChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
+            // Let stack panel width and height default to stackHeight and stackWidth if dimensions are not specified.
+            // User can now define their own height and width for stack panel.
+
+            let panelWidthChanged = false;
+            let panelHeightChanged = false;
 
 
+            let previousHeight = this.height;
+            let previousWidth = this.width;
+
+            if (!this._manualHeight) {
+                // do not specify height if strictly defined by user
+                this.height = stackHeight + "px";
+            }
+            if (!this._manualWidth) {
+                // do not specify width if strictly defined by user
+                this.width = stackWidth + "px";
+            }
+
+            panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
+            panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
+
+            if (panelHeightChanged) {
                 this._height.ignoreAdaptiveScaling = true;
                 this._height.ignoreAdaptiveScaling = true;
-            } else {
-                let previousWidth = this.width;
-                this.width = stack + "px";
-                panelChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
+            }
 
 
+            if (panelWidthChanged) {
                 this._width.ignoreAdaptiveScaling = true;
                 this._width.ignoreAdaptiveScaling = true;
             }
             }
 
 
-            if (panelChanged) {
+            this._doNotTrackManualChanges = false;
+
+            if (panelWidthChanged || panelHeightChanged) {
                 this._markAllAsDirty();
                 this._markAllAsDirty();
             }
             }
             
             

+ 13 - 3
src/Materials/Textures/babylon.texture.ts

@@ -80,6 +80,7 @@
         private _cachedUAng: number;
         private _cachedUAng: number;
         private _cachedVAng: number;
         private _cachedVAng: number;
         private _cachedWAng: number;
         private _cachedWAng: number;
+        private _cachedProjectionMatrixId: number;
         private _cachedCoordinatesMode: number;
         private _cachedCoordinatesMode: number;
         public _samplingMode: number;
         public _samplingMode: number;
         private _buffer: any;
         private _buffer: any;
@@ -260,13 +261,20 @@
         }
         }
 
 
         public getReflectionTextureMatrix(): Matrix {
         public getReflectionTextureMatrix(): Matrix {
+            let scene = this.getScene();
             if (
             if (
                 this.uOffset === this._cachedUOffset &&
                 this.uOffset === this._cachedUOffset &&
                 this.vOffset === this._cachedVOffset &&
                 this.vOffset === this._cachedVOffset &&
                 this.uScale === this._cachedUScale &&
                 this.uScale === this._cachedUScale &&
                 this.vScale === this._cachedVScale &&
                 this.vScale === this._cachedVScale &&
                 this.coordinatesMode === this._cachedCoordinatesMode) {
                 this.coordinatesMode === this._cachedCoordinatesMode) {
-                return this._cachedTextureMatrix;
+                    if (this.coordinatesMode === Texture.PROJECTION_MODE) {
+                        if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
+                            return this._cachedTextureMatrix;
+                        }
+                    } else {
+                        return this._cachedTextureMatrix;
+                    }
             }
             }
 
 
             if (!this._cachedTextureMatrix) {
             if (!this._cachedTextureMatrix) {
@@ -299,14 +307,16 @@
                     this._projectionModeMatrix.m[14] = 1.0;
                     this._projectionModeMatrix.m[14] = 1.0;
                     this._projectionModeMatrix.m[15] = 1.0;
                     this._projectionModeMatrix.m[15] = 1.0;
 
 
-                    this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
+                    let projectionMatrix = scene.getProjectionMatrix();
+                    this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
+                    projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
                     break;
                     break;
                 default:
                 default:
                     Matrix.IdentityToRef(this._cachedTextureMatrix);
                     Matrix.IdentityToRef(this._cachedTextureMatrix);
                     break;
                     break;
             }
             }
             
             
-            this.getScene().markAllMaterialsAsDirty(Material.TextureDirtyFlag, (mat) => {
+            scene.markAllMaterialsAsDirty(Material.TextureDirtyFlag, (mat) => {
                 return (mat.getActiveTextures().indexOf(this) !== -1);
                 return (mat.getActiveTextures().indexOf(this) !== -1);
             });
             });
 
 

+ 2 - 2
src/PostProcess/babylon.postProcess.ts

@@ -283,11 +283,11 @@
 
 
             if (this.enablePixelPerfectMode) {
             if (this.enablePixelPerfectMode) {
                 this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
                 this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
-                this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight);
+                this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, true);
             }
             }
             else {
             else {
                 this._scaleRatio.copyFromFloats(1, 1);
                 this._scaleRatio.copyFromFloats(1, 1);
-                this._engine.bindFramebuffer(target);
+                this._engine.bindFramebuffer(target, 0, undefined, undefined, true);
             }
             }
 
 
             this.onActivateObservable.notifyObservers(camera);
             this.onActivateObservable.notifyObservers(camera);

+ 8 - 4
src/babylon.engine.ts

@@ -1304,8 +1304,8 @@
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          */
          */
         public setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void {
         public setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void {
-            var width = requiredWidth || (navigator.isCocoonJS ? window.innerWidth : this.getRenderWidth());
-            var height = requiredHeight || (navigator.isCocoonJS ? window.innerHeight : this.getRenderHeight());
+            var width = requiredWidth || this.getRenderWidth();
+            var height = requiredHeight || this.getRenderHeight();
             var x = viewport.x || 0;
             var x = viewport.x || 0;
             var y = viewport.y || 0;
             var y = viewport.y || 0;
 
 
@@ -1484,7 +1484,7 @@
             }
             }
         }
         }
 
 
-        public bindFramebuffer(texture: WebGLTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number): void {
+        public bindFramebuffer(texture: WebGLTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void {
             if (this._currentRenderTarget) {
             if (this._currentRenderTarget) {
                 this.unBindFramebuffer(this._currentRenderTarget);
                 this.unBindFramebuffer(this._currentRenderTarget);
             }
             }
@@ -1495,7 +1495,11 @@
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
             }
             }
 
 
-            gl.viewport(0, 0, requiredWidth || texture._width, requiredHeight || texture._height);
+            if (this._cachedViewport && !forceFullscreenViewport) {
+                this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);            
+            } else {
+                gl.viewport(0, 0, requiredWidth || texture._width, requiredHeight || texture._height);
+            }
 
 
             this.wipeCaches();
             this.wipeCaches();
         }
         }

BIN
tests/validation/ReferenceImages/refprobe.png


+ 2 - 1
tests/validation/config.json

@@ -189,10 +189,11 @@
     },
     },
     {
     {
       "title": "Reflection probes",
       "title": "Reflection probes",
+      "renderCount": 10,
       "scriptToRun": "/Demos/RefProbe/reflectionProbe.js",
       "scriptToRun": "/Demos/RefProbe/reflectionProbe.js",
       "functionToCall": "CreateReflectionProbeTestScene ",
       "functionToCall": "CreateReflectionProbeTestScene ",
       "referenceImage": "refprobe.png"
       "referenceImage": "refprobe.png"
-    },
+    },   
     {
     {
       "title": "PBRMetallicRoughnessMaterial",
       "title": "PBRMetallicRoughnessMaterial",
       "playgroundId": "#2FDQT5#13",
       "playgroundId": "#2FDQT5#13",