瀏覽代碼

Fixed bug with ArcRotateCamera.setTarget

David Catuhe 9 年之前
父節點
當前提交
13830d64ab

文件差異過大導致無法顯示
+ 12 - 12
dist/preview release/babylon.core.js


文件差異過大導致無法顯示
+ 3233 - 3232
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 18 - 18
dist/preview release/babylon.js


文件差異過大導致無法顯示
+ 2017 - 2087
dist/preview release/babylon.max.js


文件差異過大導致無法顯示
+ 18 - 18
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -7,4 +7,5 @@
     - Added a new OnPickOut trigger fired when you release the pointer button outside of a mesh or sprite. ([deltakosh](https://github.com/deltakosh))
     - Added a new OnPickOut trigger fired when you release the pointer button outside of a mesh or sprite. ([deltakosh](https://github.com/deltakosh))
     - Added support for OnPointerOver and OnPointerOut for sprites. ([deltakosh](https://github.com/deltakosh))
     - Added support for OnPointerOver and OnPointerOut for sprites. ([deltakosh](https://github.com/deltakosh))
   - **Bug fixes**
   - **Bug fixes**
+    - Fixed bug with ArcRotateCamera.setTarget ([deltakosh](https://github.com/deltakosh))
   - **Breaking changes**
   - **Breaking changes**

+ 12 - 6
src/Cameras/babylon.arcRotateCamera.js

@@ -448,11 +448,8 @@ var BABYLON;
                 this.radius = this.upperRadiusLimit;
                 this.radius = this.upperRadiusLimit;
             }
             }
         };
         };
-        ArcRotateCamera.prototype.setPosition = function (position) {
-            if (this.position.equals(position)) {
-                return;
-            }
-            var radiusv3 = position.subtract(this._getTargetPosition());
+        ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
+            var radiusv3 = this.position.subtract(this._getTargetPosition());
             this.radius = radiusv3.length();
             this.radius = radiusv3.length();
             // Alpha
             // Alpha
             this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
             this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
@@ -463,8 +460,17 @@ var BABYLON;
             this.beta = Math.acos(radiusv3.y / this.radius);
             this.beta = Math.acos(radiusv3.y / this.radius);
             this._checkLimits();
             this._checkLimits();
         };
         };
+        ArcRotateCamera.prototype.setPosition = function (position) {
+            if (this.position.equals(position)) {
+                return;
+            }
+            this.rebuildAnglesAndRadius();
+        };
         ArcRotateCamera.prototype.setTarget = function (target) {
         ArcRotateCamera.prototype.setTarget = function (target) {
-            this.target = target;
+            if (this.target.equals(target)) {
+                return;
+            }
+            this.rebuildAnglesAndRadius();
         };
         };
         ArcRotateCamera.prototype._getViewMatrix = function () {
         ArcRotateCamera.prototype._getViewMatrix = function () {
             // Compute
             // Compute

+ 13 - 6
src/Cameras/babylon.arcRotateCamera.ts

@@ -488,11 +488,8 @@
             }
             }
         }
         }
 
 
-        public setPosition(position: Vector3): void {
-            if (this.position.equals(position)) {
-                return;
-            }
-            var radiusv3 = position.subtract(this._getTargetPosition());
+        public rebuildAnglesAndRadius() {
+            var radiusv3 = this.position.subtract(this._getTargetPosition());
             this.radius = radiusv3.length();
             this.radius = radiusv3.length();
 
 
             // Alpha
             // Alpha
@@ -508,8 +505,18 @@
             this._checkLimits();
             this._checkLimits();
         }
         }
 
 
+        public setPosition(position: Vector3): void {
+            if (this.position.equals(position)) {
+                return;
+            }
+            this.rebuildAnglesAndRadius();
+        }
+
         public setTarget(target: Vector3): void {
         public setTarget(target: Vector3): void {
-            this.target = target;
+            if (this.target.equals(target)) {
+                return;
+            }
+            this.rebuildAnglesAndRadius();
         }
         }
 
 
         public _getViewMatrix(): Matrix {
         public _getViewMatrix(): Matrix {

+ 0 - 76
src/babylon.engine.js

@@ -387,82 +387,6 @@ var BABYLON;
             this._activeTexturesCache = new Array(this._maxTextureChannels);
             this._activeTexturesCache = new Array(this._maxTextureChannels);
             this._compiledEffects = {};
             this._compiledEffects = {};
             this._uintIndicesCurrentlySet = false;
             this._uintIndicesCurrentlySet = false;
-            this.createRawCubeTexture = function (url, scene, size, format, type, noMipmap, callback) {
-                var _this = this;
-                var gl = this._gl;
-                var texture = gl.createTexture();
-                scene._addPendingData(texture);
-                texture.isCube = true;
-                texture.references = 1;
-                texture.url = url;
-                var internalFormat = gl.RGBA;
-                switch (format) {
-                    case Engine.TEXTUREFORMAT_ALPHA:
-                        internalFormat = gl.ALPHA;
-                        break;
-                    case Engine.TEXTUREFORMAT_LUMINANCE:
-                        internalFormat = gl.LUMINANCE;
-                        break;
-                    case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
-                        internalFormat = gl.LUMINANCE_ALPHA;
-                        break;
-                    case Engine.TEXTUREFORMAT_RGB:
-                        internalFormat = gl.RGB;
-                        break;
-                    case Engine.TEXTUREFORMAT_RGBA:
-                        internalFormat = gl.RGBA;
-                        break;
-                }
-                var textureType = gl.UNSIGNED_BYTE;
-                if (type === Engine.TEXTURETYPE_FLOAT) {
-                    textureType = gl.FLOAT;
-                }
-                var width = size;
-                var height = width;
-                var isPot = (BABYLON.Tools.IsExponentOfTwo(width) && BABYLON.Tools.IsExponentOfTwo(height));
-                texture._width = width;
-                texture._height = height;
-                var onerror = function () {
-                    scene._removePendingData(texture);
-                };
-                var internalCallback = function (data) {
-                    var rgbeDataArrays = callback(data);
-                    var facesIndex = [
-                        gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
-                        gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
-                    ];
-                    gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
-                    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
-                    for (var index = 0; index < facesIndex.length; index++) {
-                        var faceData = rgbeDataArrays[index];
-                        gl.texImage2D(facesIndex[index], 0, internalFormat, width, height, 0, internalFormat, textureType, faceData);
-                    }
-                    if (!noMipmap && isPot) {
-                        gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
-                    }
-                    else {
-                        noMipmap = true;
-                    }
-                    if (textureType == gl.FLOAT && !_this._caps.textureFloatLinearFiltering) {
-                        gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
-                        gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
-                    }
-                    else {
-                        gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
-                        gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, noMipmap ? gl.LINEAR : gl.LINEAR_MIPMAP_LINEAR);
-                    }
-                    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-                    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-                    gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
-                    texture.isReady = true;
-                    _this.resetTextureCache();
-                    scene._removePendingData(texture);
-                };
-                BABYLON.Tools.LoadFile(url, function (data) {
-                    internalCallback(data);
-                }, onerror, scene.database, true);
-                return texture;
-            };
             this._renderingCanvas = canvas;
             this._renderingCanvas = canvas;
             options = options || {};
             options = options || {};
             options.antialias = antialias;
             options.antialias = antialias;