소스 검색

fixing security issue

David Catuhe 8 년 전
부모
커밋
4d5e53522d

+ 0 - 1
Tools/Gulp/config.json

@@ -1484,7 +1484,6 @@
                     "../../inspector/src/tabs/MaterialTab.ts",
                     "../../inspector/src/tabs/MeshTab.ts",
                     "../../inspector/src/tabs/SceneTab.ts",
-                    "../../inspector/src/tabs/ShaderTab.ts",
                     "../../inspector/src/tabs/ConsoleTab.ts",
                     "../../inspector/src/tabs/StatsTab.ts",
                     "../../inspector/src/tabs/TabBar.ts",

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 8751 - 8755
dist/preview release/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 30 - 30
dist/preview release/babylon.js


+ 23 - 135
dist/preview release/babylon.max.js

@@ -23693,12 +23693,6 @@ var BABYLON;
         Effect.prototype.getCompilationError = function () {
             return this._compilationError;
         };
-        Effect.prototype.getVertexShaderSource = function () {
-            return this._evaluateDefinesOnString(this._engine.getVertexShaderSource(this._program));
-        };
-        Effect.prototype.getFragmentShaderSource = function () {
-            return this._evaluateDefinesOnString(this._engine.getFragmentShaderSource(this._program));
-        };
         // Methods
         Effect.prototype.executeWhenCompiled = function (func) {
             if (this.isReady()) {
@@ -24232,110 +24226,6 @@ var BABYLON;
             }
             return this;
         };
-        Effect.prototype._recombineShader = function (node) {
-            if (node.define) {
-                if (node.condition) {
-                    var defineIndex = this.defines.indexOf("#define " + node.define);
-                    if (defineIndex === -1) {
-                        return null;
-                    }
-                    var nextComma = this.defines.indexOf("\n", defineIndex);
-                    var defineValue = this.defines.substr(defineIndex + 7, nextComma - defineIndex - 7).replace(node.define, "").trim();
-                    var condition = defineValue + node.condition;
-                    if (!eval(condition)) {
-                        return null;
-                    }
-                }
-                else if (node.ndef) {
-                    if (this.defines.indexOf("#define " + node.define) !== -1) {
-                        return null;
-                    }
-                }
-                else if (this.defines.indexOf("#define " + node.define) === -1) {
-                    return null;
-                }
-            }
-            var result = "";
-            for (var index = 0; index < node.children.length; index++) {
-                var line = node.children[index];
-                if (line.children) {
-                    var combined = this._recombineShader(line);
-                    if (combined !== null) {
-                        result += combined + "\r\n";
-                    }
-                    continue;
-                }
-                if (line.length > 0) {
-                    result += line + "\r\n";
-                }
-            }
-            return result;
-        };
-        Effect.prototype._evaluateDefinesOnString = function (shaderString) {
-            var root = {
-                children: []
-            };
-            var currentNode = root;
-            var lines = shaderString.split("\n");
-            for (var index = 0; index < lines.length; index++) {
-                var line = lines[index].trim();
-                // #ifdef
-                var pos = line.indexOf("#ifdef ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 7);
-                    var newNode = {
-                        condition: null,
-                        ndef: false,
-                        define: define,
-                        children: [],
-                        parent: currentNode
-                    };
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-                // #ifndef
-                var pos = line.indexOf("#ifndef ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 8);
-                    newNode = {
-                        condition: null,
-                        define: define,
-                        ndef: true,
-                        children: [],
-                        parent: currentNode
-                    };
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-                // #if
-                var pos = line.indexOf("#if ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 4).trim();
-                    var conditionPos = define.indexOf(" ");
-                    newNode = {
-                        condition: define.substr(conditionPos + 1),
-                        define: define.substr(0, conditionPos),
-                        ndef: false,
-                        children: [],
-                        parent: currentNode
-                    };
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-                // #endif
-                pos = line.indexOf("#endif");
-                if (pos !== -1) {
-                    currentNode = currentNode.parent;
-                    continue;
-                }
-                currentNode.children.push(line);
-            }
-            // Recombine
-            return this._recombineShader(root);
-        };
         Effect.ResetCache = function () {
             Effect._baseCache = {};
         };
@@ -35133,6 +35023,7 @@ var BABYLON;
                 if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
                     return;
                 }
+                this._targetHost = null;
                 this._target = newTarget;
                 this._targetBoundingCenter = null;
                 this.onMeshTargetChangedObservable.notifyObservers(null);
@@ -70023,8 +69914,22 @@ var BABYLON;
             if (framingPositionY == null) {
                 framingPositionY = this._positionY;
             }
-            // sets the radius and lower radius bounds
             mesh.computeWorldMatrix(true);
+            var zoomTarget;
+            var center = mesh.getBoundingInfo().boundingSphere.centerWorld;
+            if (focusOnOriginXZ) {
+                zoomTarget = new BABYLON.Vector3(0, center.y, 0);
+            }
+            else {
+                zoomTarget = center.clone();
+            }
+            // if (!this._vectorTransition) {
+            // 	this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
+            // }			
+            // this._animatables.push(Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 
+            // 						60, this._vectorTransition, this._framingTime));
+            this._attachedCamera.setTarget(zoomTarget);
+            // sets the radius and lower radius bounds
             if (radius == null) {
                 // Small delta ensures camera is not always at lower zoom limit.
                 var delta = 0.1;
@@ -70037,33 +69942,15 @@ var BABYLON;
                     radius = this._calculateLowerRadiusFromModelBoundingSphere(mesh);
                 }
             }
-            var zoomTarget;
-            var zoomTargetY;
-            var modelWorldPosition = new BABYLON.Vector3(0, 0, 0);
-            var modelWorldScale = new BABYLON.Vector3(0, 0, 0);
-            mesh.getWorldMatrix().decompose(modelWorldScale, new BABYLON.Quaternion(), modelWorldPosition);
-            //find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
-            var bottom = modelWorldPosition.y + mesh.getBoundingInfo().minimum.y;
-            var top = modelWorldPosition.y + mesh.getBoundingInfo().maximum.y;
-            zoomTargetY = bottom + (top - bottom) * framingPositionY;
             if (applyToLowerLimit) {
                 this._attachedCamera.lowerRadiusLimit = radius;
             }
-            if (focusOnOriginXZ) {
-                zoomTarget = new BABYLON.Vector3(0, zoomTargetY, 0);
-            }
-            else {
-                zoomTarget = new BABYLON.Vector3(modelWorldPosition.x, zoomTargetY, modelWorldPosition.z);
-            }
-            if (!this._vectorTransition) {
-                this._vectorTransition = BABYLON.Animation.CreateAnimation("target", BABYLON.Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
-            }
-            this._animatables.push(BABYLON.Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime));
             // transition to new radius
-            if (!this._radiusTransition) {
-                this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
-            }
-            this._animatables.push(BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime));
+            // if (!this._radiusTransition) {
+            // 	this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
+            // }
+            // this._animatables.push(Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 
+            // 						60, this._radiusTransition, this._framingTime));															
         };
         /**
          * Calculates the lowest radius for the camera based on the bounding box of the mesh.
@@ -70079,6 +69966,7 @@ var BABYLON;
             // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
             var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
             // Horizon distance
+            var sphereRadius = mesh.getBoundingInfo().boundingSphere.radiusWorld;
             var radius = radiusWithoutFraming * this._relativeRadius;
             var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
             var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
@@ -70188,7 +70076,7 @@ var BABYLON;
         /**
          * The camera is not allowed to zoom closer to the model than the point at which the adjusted bounding sphere touches the frustum sides
          */
-        FramingBehavior.FitFrustumSidesMode = 0;
+        FramingBehavior.FitFrustumSidesMode = 1;
         return FramingBehavior;
     }());
     BABYLON.FramingBehavior = FramingBehavior;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 8751 - 8755
dist/preview release/babylon.module.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 42 - 42
dist/preview release/babylon.worker.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 780 - 784
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 23 - 23
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


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

@@ -23693,12 +23693,6 @@ var BABYLON;
         Effect.prototype.getCompilationError = function () {
             return this._compilationError;
         };
-        Effect.prototype.getVertexShaderSource = function () {
-            return this._evaluateDefinesOnString(this._engine.getVertexShaderSource(this._program));
-        };
-        Effect.prototype.getFragmentShaderSource = function () {
-            return this._evaluateDefinesOnString(this._engine.getFragmentShaderSource(this._program));
-        };
         // Methods
         Effect.prototype.executeWhenCompiled = function (func) {
             if (this.isReady()) {
@@ -24232,110 +24226,6 @@ var BABYLON;
             }
             return this;
         };
-        Effect.prototype._recombineShader = function (node) {
-            if (node.define) {
-                if (node.condition) {
-                    var defineIndex = this.defines.indexOf("#define " + node.define);
-                    if (defineIndex === -1) {
-                        return null;
-                    }
-                    var nextComma = this.defines.indexOf("\n", defineIndex);
-                    var defineValue = this.defines.substr(defineIndex + 7, nextComma - defineIndex - 7).replace(node.define, "").trim();
-                    var condition = defineValue + node.condition;
-                    if (!eval(condition)) {
-                        return null;
-                    }
-                }
-                else if (node.ndef) {
-                    if (this.defines.indexOf("#define " + node.define) !== -1) {
-                        return null;
-                    }
-                }
-                else if (this.defines.indexOf("#define " + node.define) === -1) {
-                    return null;
-                }
-            }
-            var result = "";
-            for (var index = 0; index < node.children.length; index++) {
-                var line = node.children[index];
-                if (line.children) {
-                    var combined = this._recombineShader(line);
-                    if (combined !== null) {
-                        result += combined + "\r\n";
-                    }
-                    continue;
-                }
-                if (line.length > 0) {
-                    result += line + "\r\n";
-                }
-            }
-            return result;
-        };
-        Effect.prototype._evaluateDefinesOnString = function (shaderString) {
-            var root = {
-                children: []
-            };
-            var currentNode = root;
-            var lines = shaderString.split("\n");
-            for (var index = 0; index < lines.length; index++) {
-                var line = lines[index].trim();
-                // #ifdef
-                var pos = line.indexOf("#ifdef ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 7);
-                    var newNode = {
-                        condition: null,
-                        ndef: false,
-                        define: define,
-                        children: [],
-                        parent: currentNode
-                    };
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-                // #ifndef
-                var pos = line.indexOf("#ifndef ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 8);
-                    newNode = {
-                        condition: null,
-                        define: define,
-                        ndef: true,
-                        children: [],
-                        parent: currentNode
-                    };
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-                // #if
-                var pos = line.indexOf("#if ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 4).trim();
-                    var conditionPos = define.indexOf(" ");
-                    newNode = {
-                        condition: define.substr(conditionPos + 1),
-                        define: define.substr(0, conditionPos),
-                        ndef: false,
-                        children: [],
-                        parent: currentNode
-                    };
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-                // #endif
-                pos = line.indexOf("#endif");
-                if (pos !== -1) {
-                    currentNode = currentNode.parent;
-                    continue;
-                }
-                currentNode.children.push(line);
-            }
-            // Recombine
-            return this._recombineShader(root);
-        };
         Effect.ResetCache = function () {
             Effect._baseCache = {};
         };
@@ -32227,6 +32117,7 @@ var BABYLON;
                 if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
                     return;
                 }
+                this._targetHost = null;
                 this._target = newTarget;
                 this._targetBoundingCenter = null;
                 this.onMeshTargetChangedObservable.notifyObservers(null);
@@ -50027,8 +49918,22 @@ var BABYLON;
             if (framingPositionY == null) {
                 framingPositionY = this._positionY;
             }
-            // sets the radius and lower radius bounds
             mesh.computeWorldMatrix(true);
+            var zoomTarget;
+            var center = mesh.getBoundingInfo().boundingSphere.centerWorld;
+            if (focusOnOriginXZ) {
+                zoomTarget = new BABYLON.Vector3(0, center.y, 0);
+            }
+            else {
+                zoomTarget = center.clone();
+            }
+            // if (!this._vectorTransition) {
+            // 	this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
+            // }			
+            // this._animatables.push(Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 
+            // 						60, this._vectorTransition, this._framingTime));
+            this._attachedCamera.setTarget(zoomTarget);
+            // sets the radius and lower radius bounds
             if (radius == null) {
                 // Small delta ensures camera is not always at lower zoom limit.
                 var delta = 0.1;
@@ -50041,33 +49946,15 @@ var BABYLON;
                     radius = this._calculateLowerRadiusFromModelBoundingSphere(mesh);
                 }
             }
-            var zoomTarget;
-            var zoomTargetY;
-            var modelWorldPosition = new BABYLON.Vector3(0, 0, 0);
-            var modelWorldScale = new BABYLON.Vector3(0, 0, 0);
-            mesh.getWorldMatrix().decompose(modelWorldScale, new BABYLON.Quaternion(), modelWorldPosition);
-            //find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
-            var bottom = modelWorldPosition.y + mesh.getBoundingInfo().minimum.y;
-            var top = modelWorldPosition.y + mesh.getBoundingInfo().maximum.y;
-            zoomTargetY = bottom + (top - bottom) * framingPositionY;
             if (applyToLowerLimit) {
                 this._attachedCamera.lowerRadiusLimit = radius;
             }
-            if (focusOnOriginXZ) {
-                zoomTarget = new BABYLON.Vector3(0, zoomTargetY, 0);
-            }
-            else {
-                zoomTarget = new BABYLON.Vector3(modelWorldPosition.x, zoomTargetY, modelWorldPosition.z);
-            }
-            if (!this._vectorTransition) {
-                this._vectorTransition = BABYLON.Animation.CreateAnimation("target", BABYLON.Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
-            }
-            this._animatables.push(BABYLON.Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime));
             // transition to new radius
-            if (!this._radiusTransition) {
-                this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
-            }
-            this._animatables.push(BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime));
+            // if (!this._radiusTransition) {
+            // 	this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
+            // }
+            // this._animatables.push(Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 
+            // 						60, this._radiusTransition, this._framingTime));															
         };
         /**
          * Calculates the lowest radius for the camera based on the bounding box of the mesh.
@@ -50083,6 +49970,7 @@ var BABYLON;
             // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
             var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
             // Horizon distance
+            var sphereRadius = mesh.getBoundingInfo().boundingSphere.radiusWorld;
             var radius = radiusWithoutFraming * this._relativeRadius;
             var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
             var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
@@ -50192,7 +50080,7 @@ var BABYLON;
         /**
          * The camera is not allowed to zoom closer to the model than the point at which the adjusted bounding sphere touches the frustum sides
          */
-        FramingBehavior.FitFrustumSidesMode = 0;
+        FramingBehavior.FitFrustumSidesMode = 1;
         return FramingBehavior;
     }());
     BABYLON.FramingBehavior = FramingBehavior;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 780 - 784
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2 - 3
dist/preview release/inspector/babylon.inspector.bundle.js


+ 0 - 18
dist/preview release/inspector/babylon.inspector.d.ts

@@ -922,24 +922,6 @@ declare module INSPECTOR {
 }
 
 declare module INSPECTOR {
-    class ShaderTab extends Tab {
-        private _inspector;
-        private _vertexPanel;
-        private _fragmentPanel;
-        constructor(tabbar: TabBar, insp: Inspector);
-        private _selectShader(event);
-        /** Overrides super.dispose */
-        dispose(): void;
-        /** Returns the position of the first { and the corresponding } */
-        private _getBracket(str);
-        /**
-         * Beautify the given string : correct indentation
-         */
-        private _beautify(glsl, level?);
-    }
-}
-
-declare module INSPECTOR {
     /**
      * The console tab will have two features :
      * - hook all console.log call and display them in this panel (and in the browser console as well)

+ 0 - 135
dist/preview release/inspector/babylon.inspector.js

@@ -3510,140 +3510,6 @@ var __extends = (this && this.__extends) || (function () {
 })();
 var INSPECTOR;
 (function (INSPECTOR) {
-    var ShaderTab = (function (_super) {
-        __extends(ShaderTab, _super);
-        function ShaderTab(tabbar, insp) {
-            var _this = _super.call(this, tabbar, 'Shader') || this;
-            _this._inspector = insp;
-            // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
-            _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
-            var shaderPanel = INSPECTOR.Helpers.CreateDiv('shader-tree-panel');
-            _this._vertexPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
-            _this._fragmentPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
-            _this._panel.appendChild(shaderPanel);
-            _this._panel.appendChild(_this._vertexPanel);
-            _this._panel.appendChild(_this._fragmentPanel);
-            INSPECTOR.Helpers.LoadScript();
-            Split([_this._vertexPanel, _this._fragmentPanel], {
-                blockDrag: _this._inspector.popupMode,
-                sizes: [50, 50],
-                direction: 'vertical'
-            });
-            var comboBox = INSPECTOR.Helpers.CreateElement('select', '', shaderPanel);
-            comboBox.addEventListener('change', _this._selectShader.bind(_this));
-            var option = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
-            option.textContent = 'Select a shader';
-            option.setAttribute('value', "");
-            option.setAttribute('disabled', 'true');
-            option.setAttribute('selected', 'true');
-            // Build shaders combobox
-            for (var _i = 0, _a = _this._inspector.scene.materials; _i < _a.length; _i++) {
-                var mat = _a[_i];
-                if (mat instanceof BABYLON.ShaderMaterial) {
-                    var option_1 = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
-                    option_1.setAttribute('value', mat.id);
-                    option_1.textContent = mat.name + " - " + mat.id;
-                }
-            }
-            return _this;
-        }
-        ShaderTab.prototype._selectShader = function (event) {
-            var id = event.target.value;
-            var mat = this._inspector.scene.getMaterialByID(id);
-            // Clean shader panel
-            INSPECTOR.Helpers.CleanDiv(this._vertexPanel);
-            // add the title - vertex shader
-            var title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._vertexPanel);
-            title.textContent = 'Vertex shader';
-            // add code
-            var code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._vertexPanel));
-            code.textContent = this._beautify(mat.getEffect().getVertexShaderSource());
-            INSPECTOR.Helpers.CleanDiv(this._fragmentPanel);
-            // add the title - fragment shader
-            title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._fragmentPanel);
-            title.textContent = 'Frgament shader';
-            // add code
-            code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._fragmentPanel));
-            code.textContent = this._beautify(mat.getEffect().getFragmentShaderSource());
-            // Init the syntax highlighting
-            var styleInit = INSPECTOR.Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
-            styleInit.textContent = 'hljs.initHighlighting();';
-        };
-        /** Overrides super.dispose */
-        ShaderTab.prototype.dispose = function () {
-        };
-        /** Returns the position of the first { and the corresponding } */
-        ShaderTab.prototype._getBracket = function (str) {
-            var fb = str.indexOf('{');
-            var arr = str.substr(fb + 1).split('');
-            var counter = 1;
-            var currentPosInString = fb;
-            var lastBracketIndex = 0;
-            for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
-                var char = arr_1[_i];
-                currentPosInString++;
-                if (char === '{') {
-                    counter++;
-                }
-                if (char === '}') {
-                    counter--;
-                }
-                if (counter == 0) {
-                    lastBracketIndex = currentPosInString;
-                    break;
-                }
-            }
-            return { firstBracket: fb, lastBracket: lastBracketIndex };
-        };
-        /**
-         * Beautify the given string : correct indentation
-         */
-        ShaderTab.prototype._beautify = function (glsl, level) {
-            if (level === void 0) { level = 0; }
-            // return condition : no brackets at all
-            var brackets = this._getBracket(glsl);
-            var firstBracket = brackets.firstBracket;
-            var lastBracket = brackets.lastBracket;
-            var spaces = "";
-            for (var i = 0; i < level; i++) {
-                spaces += "    "; // 4 spaces
-            }
-            // If no brackets, return the indented string
-            if (firstBracket == -1) {
-                glsl = spaces + glsl; // indent first line
-                glsl = glsl
-                    .replace(/;./g, function (x) { return '\n' + x.substr(1); }); // new line after ;  except the last one
-                glsl = glsl.replace(/=/g, " = "); // space around =
-                glsl = glsl.replace(/\n/g, "\n" + spaces); // indentation
-                return glsl;
-            }
-            else {
-                // if brackets, beautify the inside                                 
-                // let insideWithBrackets = glsl.substr(firstBracket, lastBracket-firstBracket+1);
-                var left = glsl.substr(0, firstBracket);
-                var right = glsl.substr(lastBracket + 1, glsl.length);
-                var inside = glsl.substr(firstBracket + 1, lastBracket - firstBracket - 1);
-                inside = this._beautify(inside, level + 1);
-                return this._beautify(left, level) + '{\n' + inside + '\n' + spaces + '}\n' + this._beautify(right, level);
-            }
-        };
-        return ShaderTab;
-    }(INSPECTOR.Tab));
-    INSPECTOR.ShaderTab = ShaderTab;
-})(INSPECTOR || (INSPECTOR = {}));
-
-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]; };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-var INSPECTOR;
-(function (INSPECTOR) {
     /**
      * The console tab will have two features :
      * - hook all console.log call and display them in this panel (and in the browser console as well)
@@ -4083,7 +3949,6 @@ var INSPECTOR;
             _this._meshTab = new INSPECTOR.MeshTab(_this, _this._inspector);
             _this._tabs.push(new INSPECTOR.TextureTab(_this, _this._inspector));
             _this._tabs.push(_this._meshTab);
-            _this._tabs.push(new INSPECTOR.ShaderTab(_this, _this._inspector));
             _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
             _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
             if (BABYLON.GUI) {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2 - 3
dist/preview release/inspector/babylon.inspector.min.js


+ 0 - 145
inspector/src/tabs/ShaderTab.ts

@@ -1,145 +0,0 @@
-module INSPECTOR {
-
-    export class ShaderTab extends Tab {
-
-        private _inspector: Inspector;
-
-        private _vertexPanel: HTMLElement;
-        private _fragmentPanel: HTMLElement;
-
-        constructor(tabbar: TabBar, insp: Inspector) {
-            super(tabbar, 'Shader');
-            this._inspector = insp;
-
-            // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
-            this._panel = Helpers.CreateDiv('tab-panel') as HTMLDivElement;
-
-            let shaderPanel = Helpers.CreateDiv('shader-tree-panel') as HTMLDivElement;
-            this._vertexPanel = Helpers.CreateDiv('shader-panel') as HTMLDivElement;
-            this._fragmentPanel = Helpers.CreateDiv('shader-panel') as HTMLDivElement;
-
-            this._panel.appendChild(shaderPanel);
-            this._panel.appendChild(this._vertexPanel);
-            this._panel.appendChild(this._fragmentPanel);
-
-            Helpers.LoadScript();
-
-            Split([this._vertexPanel, this._fragmentPanel], {
-                blockDrag: this._inspector.popupMode,
-                sizes: [50, 50],
-                direction: 'vertical'
-            }
-            );
-
-            let comboBox = Helpers.CreateElement('select', '', shaderPanel);
-            comboBox.addEventListener('change', this._selectShader.bind(this));
-
-            let option = Helpers.CreateElement('option', '', comboBox);
-            option.textContent = 'Select a shader';
-            option.setAttribute('value', "");
-            option.setAttribute('disabled', 'true');
-            option.setAttribute('selected', 'true');
-
-            // Build shaders combobox
-            for (let mat of this._inspector.scene.materials) {
-                if (mat instanceof BABYLON.ShaderMaterial) {
-                    let option = Helpers.CreateElement('option', '', comboBox);
-                    option.setAttribute('value', mat.id);
-                    option.textContent = `${mat.name} - ${mat.id}`;
-
-                }
-            }
-
-        }
-
-        private _selectShader(event: Event) {
-            let id = (event.target as HTMLSelectElement).value;
-            let mat = this._inspector.scene.getMaterialByID(id);
-
-            // Clean shader panel
-            Helpers.CleanDiv(this._vertexPanel);
-            // add the title - vertex shader
-            let title = Helpers.CreateDiv('shader-panel-title', this._vertexPanel);
-            title.textContent = 'Vertex shader';
-            // add code
-            let code = Helpers.CreateElement('code', 'glsl', Helpers.CreateElement('pre', '', this._vertexPanel));
-            code.textContent = this._beautify(mat.getEffect().getVertexShaderSource());
-
-            Helpers.CleanDiv(this._fragmentPanel);
-            // add the title - fragment shader
-            title = Helpers.CreateDiv('shader-panel-title', this._fragmentPanel);
-            title.textContent = 'Frgament shader';
-            // add code
-            code = Helpers.CreateElement('code', 'glsl', Helpers.CreateElement('pre', '', this._fragmentPanel));
-            code.textContent = this._beautify(mat.getEffect().getFragmentShaderSource());
-
-            // Init the syntax highlighting
-            let styleInit = Helpers.CreateElement('script', '', Inspector.DOCUMENT.body);
-            styleInit.textContent = 'hljs.initHighlighting();';
-
-        }
-
-        /** Overrides super.dispose */
-        public dispose() {
-        }
-
-        /** Returns the position of the first { and the corresponding } */
-        private _getBracket(str) {
-            let fb = str.indexOf('{');
-            let arr = str.substr(fb + 1).split('');
-            let counter = 1;
-            let currentPosInString = fb;
-            let lastBracketIndex = 0;
-            for (let char of arr) {
-                currentPosInString++;
-                if (char === '{') {
-                    counter++
-                }
-                if (char === '}') {
-                    counter--
-                }
-                if (counter == 0) {
-                    lastBracketIndex = currentPosInString;
-                    break;
-                }
-            }
-
-            return { firstBracket: fb, lastBracket: lastBracketIndex };
-        }
-
-        /** 
-         * Beautify the given string : correct indentation
-         */
-        private _beautify(glsl: string, level: number = 0) {
-
-            // return condition : no brackets at all
-            let brackets = this._getBracket(glsl);
-            let firstBracket = brackets.firstBracket;
-            let lastBracket = brackets.lastBracket;
-
-            let spaces = "";
-            for (let i = 0; i < level; i++) {
-                spaces += "    "; // 4 spaces
-            }
-            // If no brackets, return the indented string
-            if (firstBracket == -1) {
-                glsl = spaces + glsl; // indent first line
-                glsl = glsl
-                    .replace(/;./g, x => '\n' + x.substr(1)) // new line after ;  except the last one
-                glsl = glsl.replace(/=/g, " = ") // space around =
-                glsl = glsl.replace(/\n/g, "\n" + spaces); // indentation
-                return glsl;
-            } else {
-                // if brackets, beautify the inside                                 
-                // let insideWithBrackets = glsl.substr(firstBracket, lastBracket-firstBracket+1);
-                let left = glsl.substr(0, firstBracket);
-                let right = glsl.substr(lastBracket + 1, glsl.length);
-                let inside = glsl.substr(firstBracket + 1, lastBracket - firstBracket - 1);
-                inside = this._beautify(inside, level + 1);
-                return this._beautify(left, level) + '{\n' + inside + '\n' + spaces + '}\n' + this._beautify(right, level);
-
-            }
-        }
-    }
-
-}

+ 0 - 1
inspector/src/tabs/TabBar.ts

@@ -30,7 +30,6 @@ module INSPECTOR {
             this._meshTab = new MeshTab(this, this._inspector);
             this._tabs.push(new TextureTab(this, this._inspector));
             this._tabs.push(this._meshTab);
-            this._tabs.push(new ShaderTab(this, this._inspector));
             this._tabs.push(new LightTab(this, this._inspector));
             this._tabs.push(new MaterialTab(this, this._inspector));
             if(BABYLON.GUI){

+ 17 - 0
sandbox/index.js

@@ -66,6 +66,23 @@
         }
         currentScene.activeCamera.attachControl(canvas);
 
+        // Enable camera's behaviors
+        currentScene.activeCamera.useBouncingBehavior = true;
+        currentScene.activeCamera.useAutoRotationBehavior  = true;
+        currentScene.activeCamera.useFramingBehavior = true;
+
+        if (currentScene.meshes.length) {
+            // Let's zoom on the first object with geometry
+            for (var index = 0; index < currentScene.meshes.length; index++) {
+                var mesh = currentScene.meshes[index];
+
+                if (mesh.getTotalVertices()) {
+                    currentScene.activeCamera.setTarget(mesh);
+                    break;
+                }
+            }
+        }
+
         // Environment
         if (currentScene.loadingPluginName === "gltf") {
             var hdrTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("Assets/environment.dds", currentScene);

+ 28 - 36
src/Behaviors/Cameras/babylon.framingBehavior.ts

@@ -221,13 +221,30 @@ module BABYLON {
 		 * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
 		 * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
 		 */
-		public zoomOnMesh(mesh: AbstractMesh, radius?: number, applyToLowerLimit: boolean = false, framingPositionY?: number, focusOnOriginXZ: boolean = true): void {
+		public zoomOnMesh(mesh: AbstractMesh, radius?: number, applyToLowerLimit: boolean = false, framingPositionY?: number, focusOnOriginXZ: boolean = false): void {
 			if (framingPositionY == null) {
 				framingPositionY = this._positionY;
 			}
 
-			// sets the radius and lower radius bounds
 			mesh.computeWorldMatrix(true);
+			
+			let zoomTarget: BABYLON.Vector3;
+			let center = mesh.getBoundingInfo().boundingSphere.centerWorld;
+
+			if (focusOnOriginXZ) {	
+				zoomTarget = new BABYLON.Vector3(0, center.y, 0);
+			} else {
+				zoomTarget = center.clone();
+			}
+
+			if (!this._vectorTransition) {
+				this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
+			}			
+
+			this._animatables.push(Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 
+									60, this._vectorTransition, this._framingTime));
+
+			// sets the radius and lower radius bounds
 			if (radius == null) {
 				// Small delta ensures camera is not always at lower zoom limit.
 				let delta = 0.1;
@@ -240,43 +257,17 @@ module BABYLON {
 				}
 			}
 
-			let zoomTarget: BABYLON.Vector3;
-			let zoomTargetY: number;
-
-			let modelWorldPosition = new BABYLON.Vector3(0, 0, 0);
-			let modelWorldScale = new BABYLON.Vector3(0, 0, 0);
-
-			mesh.getWorldMatrix().decompose(modelWorldScale, new BABYLON.Quaternion(), modelWorldPosition);
-
-			//find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
-			let bottom = modelWorldPosition.y + mesh.getBoundingInfo().minimum.y;
-			let top = modelWorldPosition.y + mesh.getBoundingInfo().maximum.y;
-			zoomTargetY = bottom + (top - bottom) * framingPositionY;
-
 			if (applyToLowerLimit) {
 				this._attachedCamera.lowerRadiusLimit = radius;
 			}
 
-			if (focusOnOriginXZ) {	
-				zoomTarget = new BABYLON.Vector3(0, zoomTargetY, 0);
-			} else {
-				zoomTarget = new BABYLON.Vector3(modelWorldPosition.x, zoomTargetY, modelWorldPosition.z);
-			}
-
-			if (!this._vectorTransition) {
-				this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
-			}			
-
-			this._animatables.push(Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 
-									60, this._vectorTransition, this._framingTime));
-
 			// transition to new radius
-			if (!this._radiusTransition) {
-				this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
-			}
+			// if (!this._radiusTransition) {
+			// 	this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
+			// }
 
-			this._animatables.push(Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 
-									60, this._radiusTransition, this._framingTime));															
+			// this._animatables.push(Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 
+			// 						60, this._radiusTransition, this._framingTime));															
 		}	
 		
 		/**
@@ -295,6 +286,7 @@ module BABYLON {
 			let radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
 
 			// Horizon distance
+			let sphereRadius = mesh.getBoundingInfo().boundingSphere.radiusWorld;
 			let radius = radiusWithoutFraming * this._relativeRadius;
 			let distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
 			let distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
@@ -322,8 +314,8 @@ module BABYLON {
 			let timeSinceInteraction = Tools.Now - this._lastInteractionTime;
 			let defaultBeta = Math.PI * 0.5 - this._defaultElevation;
 			let limitBeta = Math.PI * 0.5;
-            
-            // Bring the camera back up if below the ground plane
+			
+			// Bring the camera back up if below the ground plane
 			if (!this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
                 this._betaIsAnimating = true;
                 
@@ -416,6 +408,6 @@ module BABYLON {
         /**
          * The camera is not allowed to zoom closer to the model than the point at which the adjusted bounding sphere touches the frustum sides
          */
-        public static FitFrustumSidesMode = 0;
+        public static FitFrustumSidesMode = 1;
     }
 }

+ 1 - 0
src/Cameras/babylon.arcRotateCamera.ts

@@ -511,6 +511,7 @@ module BABYLON {
                 if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
                    return;
                 }
+                this._targetHost = null;
                 this._target = newTarget;
                 this._targetBoundingCenter = null;
                 this.onMeshTargetChangedObservable.notifyObservers(null);

+ 0 - 134
src/Materials/babylon.effect.ts

@@ -239,14 +239,6 @@
             return this._compilationError;
         }
 
-        public getVertexShaderSource(): string {
-            return this._evaluateDefinesOnString(this._engine.getVertexShaderSource(this._program));
-        }
-
-        public getFragmentShaderSource(): string {
-            return this._evaluateDefinesOnString(this._engine.getFragmentShaderSource(this._program));
-        }
-
         // Methods
         public executeWhenCompiled(func: (effect: Effect) => void): void {
             if (this.isReady()) {
@@ -889,132 +881,6 @@
             return this;
         }
 
-        private _recombineShader(node: any): string {
-            if (node.define) {
-                if (node.condition) {
-                    var defineIndex = this.defines.indexOf("#define " + node.define);
-                    if (defineIndex === -1) {
-                        return null;
-                    }
-
-                    var nextComma = this.defines.indexOf("\n", defineIndex);
-                    var defineValue = this.defines.substr(defineIndex + 7, nextComma - defineIndex - 7).replace(node.define, "").trim();
-                    var condition = defineValue + node.condition;
-                    if (!eval(condition)) {
-                        return null;
-                    }
-                }
-                else if (node.ndef) {
-                    if (this.defines.indexOf("#define " + node.define) !== -1) {
-                        return null;
-                    }
-                }
-                else if (this.defines.indexOf("#define " + node.define) === -1) {
-                    return null;
-                }
-            }
-
-            var result = "";
-            for (var index = 0; index < node.children.length; index++) {
-                var line = node.children[index];
-
-                if (line.children) {
-                    var combined = this._recombineShader(line);
-                    if (combined !== null) {
-                        result += combined + "\r\n";
-                    }
-
-                    continue;
-                }
-
-                if (line.length > 0) {
-                    result += line + "\r\n";
-                }
-            }
-
-            return result;
-        }
-
-        private _evaluateDefinesOnString(shaderString: string): string {
-            var root = <any>{
-                children: []
-            };
-            var currentNode = root;
-
-            var lines = shaderString.split("\n");
-
-            for (var index = 0; index < lines.length; index++) {
-                var line = lines[index].trim();
-
-                // #ifdef
-                var pos = line.indexOf("#ifdef ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 7);
-
-                    var newNode = {
-                        condition: null,
-                        ndef: false,
-                        define: define,
-                        children: [],
-                        parent: currentNode
-                    }
-                    
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-
-                // #ifndef
-                var pos = line.indexOf("#ifndef ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 8);
-
-                    newNode = {
-                        condition: null,
-                        define: define,
-                        ndef: true,
-                        children: [],
-                        parent: currentNode
-                    }
-                    
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-
-                // #if
-                var pos = line.indexOf("#if ");
-                if (pos !== -1) {
-                    var define = line.substr(pos + 4).trim();
-                    var conditionPos = define.indexOf(" ");
-
-                    newNode = {
-                        condition: define.substr(conditionPos + 1),
-                        define: define.substr(0, conditionPos),
-                        ndef: false,
-                        children: [],
-                        parent: currentNode
-                    }
-                    
-                    currentNode.children.push(newNode);
-                    currentNode = newNode;
-                    continue;
-                }
-
-                // #endif
-                pos = line.indexOf("#endif");
-                if (pos !== -1) {
-                    currentNode = currentNode.parent;
-                    continue;
-                }
-
-                currentNode.children.push(line);
-            }
-
-            // Recombine
-            return this._recombineShader(root);
-        }
-
         // Statics
         public static ShadersStore = {};
         public static IncludesShadersStore = {};