Deltakosh 12 gadi atpakaļ
vecāks
revīzija
d2f9b61488

+ 22 - 4
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -51,6 +51,8 @@
         var previousPosition;
         var that = this;
         var pointerId;
+
+        var engine = this._scene.getEngine();
         
         this._onPointerDown = function (evt) {
             
@@ -96,6 +98,20 @@
 
             evt.preventDefault();
         };
+        
+        this._onMouseMove = function (evt) {
+            if (!engine.isPointerLock) {
+                return;
+            }
+
+            var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
+            var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
+
+            that.inertialAlphaOffset -= offsetX / 1000;
+            that.inertialBetaOffset -= offsetY / 1000;
+
+            evt.preventDefault();
+        };
 
         this._wheel = function(event) {
             var delta = 0;
@@ -165,12 +181,13 @@
         canvas.addEventListener(eventPrefix + "up", this._onPointerUp);
         canvas.addEventListener(eventPrefix + "out", this._onPointerUp);
         canvas.addEventListener(eventPrefix + "move", this._onPointerMove);
+        canvas.addEventListener("mousemove", this._onMouseMove);
         canvas.addEventListener("MSPointerDown", this._onGestureStart);
-        canvas.addEventListener("MSGestureChange", this._onGesture, true);
-        window.addEventListener("keydown", this._onKeyDown, true);
-        window.addEventListener("keyup", this._onKeyUp, true);
+        canvas.addEventListener("MSGestureChange", this._onGesture);
+        window.addEventListener("keydown", this._onKeyDown);
+        window.addEventListener("keyup", this._onKeyUp);
         window.addEventListener('mousewheel', this._wheel);
-        window.addEventListener("blur", this._onLostFocus, true);
+        window.addEventListener("blur", this._onLostFocus);
     };
     
     BABYLON.ArcRotateCamera.prototype.detachControl = function (canvas) {
@@ -178,6 +195,7 @@
         canvas.removeEventListener(eventPrefix + "up", this._onPointerUp);
         canvas.removeEventListener(eventPrefix + "out", this._onPointerUp);
         canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
+        canvas.removeEventListener("mousemove", this._onMouseMove);
         canvas.removeEventListener("MSPointerDown", this._onGestureStart);
         canvas.removeEventListener("MSGestureChange", this._onGesture);
         window.removeEventListener("keydown", this._onKeyDown);

+ 77 - 75
Babylon/Cameras/babylon.freeCamera.js

@@ -14,10 +14,10 @@
         this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
 
         this._keys = [];
-        this.keysUp = [38, 87];
+        this.keysUp = [38];
         this.keysDown = [40];
-        this.keysLeft = [37, 81];
-        this.keysRight = [39, 68];
+        this.keysLeft = [37];
+        this.keysRight = [39];
 
         if (!scene.activeCamera) {
             scene.activeCamera = this;
@@ -88,91 +88,93 @@
         var that = this;
         var engine = this._scene.getEngine();
 
-        this._onMouseDown = function (evt) {
-            previousPosition = {
-                x: evt.clientX,
-                y: evt.clientY
+        if (this._onMouseDown === undefined) {
+            this._onMouseDown = function (evt) {
+                previousPosition = {
+                    x: evt.clientX,
+                    y: evt.clientY
+                };
+
+                evt.preventDefault();
             };
 
-            evt.preventDefault();
-        };
+            this._onMouseUp = function (evt) {
+                previousPosition = null;
+                evt.preventDefault();
+            };
 
-        this._onMouseUp = function (evt) {
-            previousPosition = null;
-            evt.preventDefault();
-        };
+            this._onMouseOut = function (evt) {
+                previousPosition = null;
+                that._keys = [];
+                evt.preventDefault();
+            };
 
-        this._onMouseOut = function (evt) {
-            previousPosition = null;
-            that._keys = [];
-            evt.preventDefault();
-        };
+            this._onMouseMove = function (evt) {
+                if (!previousPosition && !engine.isPointerLock) {
+                    return;
+                }
 
-        this._onMouseMove = function (evt) {
-            if (!previousPosition && !engine.isPointerLock) {
-                return;
-            }
+                var offsetX;
+                var offsetY;
 
-            var offsetX;
-            var offsetY;
+                if (!engine.isPointerLock) {
+                    offsetX = evt.clientX - previousPosition.x;
+                    offsetY = evt.clientY - previousPosition.y;
+                } else {
+                    offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
+                    offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
+                }
 
-            if (!engine.isPointerLock) {
-                offsetX = evt.clientX - previousPosition.x;
-                offsetY = evt.clientY - previousPosition.y;
-            } else {
-                offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
-                offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
-            }            
+                that.cameraRotation.y += offsetX / 2000.0;
+                that.cameraRotation.x += offsetY / 2000.0;
 
-            that.cameraRotation.y += offsetX / 2000.0;
-            that.cameraRotation.x += offsetY / 2000.0;
+                previousPosition = {
+                    x: evt.clientX,
+                    y: evt.clientY
+                };
+                evt.preventDefault();
+            };
 
-            previousPosition = {
-                x: evt.clientX,
-                y: evt.clientY
+            this._onKeyDown = function (evt) {
+                if (that.keysUp.indexOf(evt.keyCode) !== -1 ||
+                    that.keysDown.indexOf(evt.keyCode) !== -1 ||
+                    that.keysLeft.indexOf(evt.keyCode) !== -1 ||
+                    that.keysRight.indexOf(evt.keyCode) !== -1) {
+                    var index = that._keys.indexOf(evt.keyCode);
+
+                    if (index === -1) {
+                        that._keys.push(evt.keyCode);
+                    }
+                    evt.preventDefault();
+                }
             };
-            evt.preventDefault();
-        };
-
-        this._onKeyDown = function (evt) {
-            if (that.keysUp.indexOf(evt.keyCode) !== -1 ||
-                that.keysDown.indexOf(evt.keyCode) !== -1 ||
-                that.keysLeft.indexOf(evt.keyCode) !== -1 ||
-                that.keysRight.indexOf(evt.keyCode) !== -1) {
-                var index = that._keys.indexOf(evt.keyCode);
-
-                if (index === -1) {
-                    that._keys.push(evt.keyCode);
+
+            this._onKeyUp = function (evt) {
+                if (that.keysUp.indexOf(evt.keyCode) !== -1 ||
+                    that.keysDown.indexOf(evt.keyCode) !== -1 ||
+                    that.keysLeft.indexOf(evt.keyCode) !== -1 ||
+                    that.keysRight.indexOf(evt.keyCode) !== -1) {
+                    var index = that._keys.indexOf(evt.keyCode);
+
+                    if (index >= 0) {
+                        that._keys.splice(index, 1);
+                    }
+                    evt.preventDefault();
                 }
-                evt.preventDefault();
-            }
-        };
+            };
 
-        this._onKeyUp = function (evt) {
-            if (that.keysUp.indexOf(evt.keyCode) !== -1 ||
-                that.keysDown.indexOf(evt.keyCode) !== -1 ||
-                that.keysLeft.indexOf(evt.keyCode) !== -1 ||
-                that.keysRight.indexOf(evt.keyCode) !== -1) {
-                var index = that._keys.indexOf(evt.keyCode);
+            this._onLostFocus = function () {
+                that._keys = [];
+            };
+        }
 
-                if (index >= 0) {
-                    that._keys.splice(index, 1);
-                }
-                evt.preventDefault();
-            }
-        };
-
-        this._onLostFocus = function () {
-            that._keys = [];
-        };
-
-        canvas.addEventListener("mousedown", this._onMouseDown, true);
-        canvas.addEventListener("mouseup", this._onMouseUp, true);
-        canvas.addEventListener("mouseout", this._onMouseOut, true);
-        canvas.addEventListener("mousemove", this._onMouseMove, true);
-        window.addEventListener("keydown", this._onKeyDown, true);
-        window.addEventListener("keyup", this._onKeyUp, true);
-        window.addEventListener("blur", this._onLostFocus, true);
+        canvas.addEventListener("mousedown", this._onMouseDown, false);
+        canvas.addEventListener("mouseup", this._onMouseUp, false);
+        canvas.addEventListener("mouseout", this._onMouseOut, false);
+        canvas.addEventListener("mousemove", this._onMouseMove, false);
+        window.addEventListener("keydown", this._onKeyDown, false);
+        window.addEventListener("keyup", this._onKeyUp, false);
+        window.addEventListener("blur", this._onLostFocus, false);
     };
 
     BABYLON.FreeCamera.prototype.detachControl = function (canvas) {

+ 5 - 5
Babylon/Cameras/babylon.touchCamera.js

@@ -97,11 +97,11 @@
             that._offsetY = null;
         };
         
-        canvas.addEventListener("pointerdown", this._onPointerDown, true);
-        canvas.addEventListener("pointerup", this._onPointerUp, true);
-        canvas.addEventListener("pointerout", this._onPointerUp, true);
-        canvas.addEventListener("pointermove", this._onPointerMove, true);
-        window.addEventListener("blur", this._onLostFocus, true);
+        canvas.addEventListener("pointerdown", this._onPointerDown);
+        canvas.addEventListener("pointerup", this._onPointerUp);
+        canvas.addEventListener("pointerout", this._onPointerUp);
+        canvas.addEventListener("pointermove", this._onPointerMove);
+        window.addEventListener("blur", this._onLostFocus);
     };
 
     BABYLON.TouchCamera.prototype.detachControl = function (canvas) {

+ 24 - 20
Babylon/Culling/Octrees/babylon.octree.js

@@ -1,14 +1,31 @@
 var BABYLON = BABYLON || {};
 
-(function () {
-    BABYLON.Octree = function () {
+(function() {
+    BABYLON.Octree = function(maxBlockCapacity) {
         this.blocks = [];
+        this._maxBlockCapacity = maxBlockCapacity || 64;
         this._selection = new BABYLON.Tools.SmartArray(256);
     };
-    
+
     // Methods
-    BABYLON.Octree.prototype.update = function (worldMin, worldMax, meshes) {
-        this.blocks = [];
+    BABYLON.Octree.prototype.update = function(worldMin, worldMax, meshes) {
+        BABYLON.Octree._CreateBlocks(worldMin, worldMax, meshes, this._maxBlockCapacity, this);
+    };
+
+    BABYLON.Octree.prototype.select = function(frustumPlanes) {
+        this._selection.reset();
+
+        for (var index = 0; index < this.blocks.length; index++) {
+            var block = this.blocks[index];
+            block.select(frustumPlanes, this._selection);
+        }
+
+        return this._selection;
+    };
+
+    // Statics
+    BABYLON.Octree._CreateBlocks = function (worldMin, worldMax, meshes, maxBlockCapacity, target) {
+        target.blocks = [];
         var blockSize = new BABYLON.Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
 
         // Segmenting space
@@ -18,24 +35,11 @@
                     var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
                     var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
 
-                    var block = new BABYLON.OctreeBlock(x, y, z, localMin, localMax);
+                    var block = new BABYLON.OctreeBlock(localMin, localMax, maxBlockCapacity);
                     block.addEntries(meshes);
-                    this.blocks.push(block);
+                    target.blocks.push(block);
                 }
             }
         }
     };
-
-    BABYLON.Octree.prototype.select = function (frustumPlanes) {
-        this._selection.reset();
-
-        for (var index = 0; index < this.blocks.length; index++) {
-            var block = this.blocks[index];
-            if (block.intersects(frustumPlanes)) {                
-                this._selection.push(block);
-            }
-        }
-
-        return this._selection;
-    };
 })();

+ 15 - 8
Babylon/Culling/Octrees/babylon.octreeBlock.js

@@ -1,12 +1,10 @@
 var BABYLON = BABYLON || {};
 
 (function () {
-    BABYLON.OctreeBlock = function (x, y, z, minPoint, maxPoint) {
+    BABYLON.OctreeBlock = function (minPoint, maxPoint, capacity) {
         this.subMeshes = [];
         this.meshes = [];
-        this.x = x;
-        this.y = y;
-        this.z = z;
+        this._capacity = capacity;
 
         this._minPoint = minPoint;
         this._maxPoint = maxPoint;
@@ -53,13 +51,22 @@
                 }
             }
         }
+        
+        if (this.subMeshes.length > this._capacity) {
+            BABYLON.Octree._CreateBlocks(this._minPoint, this._maxPoint, this.meshes, this._capacity, this);
+        }
     };
 
-    BABYLON.OctreeBlock.prototype.intersects = function(frustumPlanes) {
+    BABYLON.OctreeBlock.prototype.select = function (frustumPlanes, selection) {
+        if (this.blocks) {
+            for (var index = 0; index < this.blocks.length; index++) {
+                var block = this.blocks[index];
+                block.select(frustumPlanes, selection);
+            }
+            return;
+        }
         if (BABYLON.BoundingBox.IsInFrustrum(this._boundingVectors, frustumPlanes)) {
-            return true;
+            selection.push(this);
         }
-
-        return false;
     };
 })();

+ 11 - 11
Babylon/Materials/babylon.effect.js

@@ -109,15 +109,15 @@
         this._engine.setTexture(this._samplers.indexOf(channel), texture);
     };
 
-    BABYLON.Effect.prototype._cacheMatrix = function (uniformName, matrix) {
-        if (!this._valueCache[uniformName]) {
-            this._valueCache[uniformName] = new BABYLON.Matrix();
-        }
+    //BABYLON.Effect.prototype._cacheMatrix = function (uniformName, matrix) {
+    //    if (!this._valueCache[uniformName]) {
+    //        this._valueCache[uniformName] = new BABYLON.Matrix();
+    //    }
         
-        for (var index = 0; index < 16; index++) {
-            this._valueCache[uniformName].m[index] = matrix.m[index];
-        }
-    };
+    //    for (var index = 0; index < 16; index++) {
+    //        this._valueCache[uniformName].m[index] = matrix.m[index];
+    //    }
+    //};
     
     BABYLON.Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
         if (!this._valueCache[uniformName]) {
@@ -164,10 +164,10 @@
     };
 
     BABYLON.Effect.prototype.setMatrix = function (uniformName, matrix) {
-        if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
-            return;
+        //if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
+        //    return;
 
-        this._cacheMatrix(uniformName, matrix);
+        //this._cacheMatrix(uniformName, matrix);
         this._engine.setMatrix(this.getUniform(uniformName), matrix);
     };
 

+ 2 - 1
Babylon/Materials/babylon.material.js

@@ -10,6 +10,7 @@
     };
     
     // Members
+    BABYLON.Material.prototype.checkReadyOnEveryCall = true;
     BABYLON.Material.prototype.alpha = 1.0;
     BABYLON.Material.prototype.wireframe = false;
     BABYLON.Material.prototype.backFaceCulling = true;
@@ -18,7 +19,7 @@
     BABYLON.Material.prototype.onDispose = null;
     
     // Properties
-    BABYLON.Material.prototype.isReady = function () {
+    BABYLON.Material.prototype.isReady = function (mesh) {
         return true;
     };
 

+ 16 - 6
Babylon/Materials/babylon.standardMaterial.js

@@ -52,7 +52,13 @@
     };
 
     // Methods   
-    BABYLON.StandardMaterial.prototype.isReady = function (mesh) {
+    BABYLON.StandardMaterial.prototype.isReady = function (mesh) {        
+        if (!this.checkReadyOnEveryCall) {
+            if (this._renderId === this._scene.getRenderId()) {
+                return true;
+            }
+        }
+
         var engine = this._scene.getEngine();
         var defines = [];
 
@@ -213,6 +219,7 @@
             return false;
         }
 
+        this._renderId = this._scene.getRenderId();
         return true;
     };
 
@@ -235,7 +242,12 @@
     BABYLON.StandardMaterial.prototype.bind = function (world, mesh) {
         this._baseColor.copyFrom(this.diffuseColor);
 
-        // Values
+        // Matrices        
+        world.multiplyToRef(this._scene.getTransformMatrix(), this._worldViewProjectionMatrix);
+        this._effect.setMatrix("world", world);
+        this._effect.setMatrix("worldViewProjection", this._worldViewProjectionMatrix);
+
+        // Textures        
         if (this.diffuseTexture) {
             this._effect.setTexture("diffuseSampler", this.diffuseTexture);
 
@@ -291,11 +303,9 @@
             this._effect.setMatrix("bumpMatrix", this.bumpTexture._computeTextureMatrix());
         }
 
-        world.multiplyToRef(this._scene.getTransformMatrix(), this._worldViewProjectionMatrix);
+        // Colors
         this._scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
 
-        this._effect.setMatrix("world", world);
-        this._effect.setMatrix("worldViewProjection", this._worldViewProjectionMatrix);
         this._effect.setVector3("vEyePosition", this._scene.activeCamera.position);
         this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
         this._effect.setColor4("vDiffuseColor", this._baseColor, this.alpha * mesh.visibility);
@@ -360,7 +370,7 @@
         if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
             this._effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
             this._effect.setColor3("vFogColor", this._scene.fogColor);
-        }
+        }        
     };
 
     BABYLON.StandardMaterial.prototype.getAnimatables = function () {

+ 12 - 9
Babylon/Mesh/babylon.mesh.js

@@ -15,7 +15,6 @@
         this.rotation = new BABYLON.Vector3(0, 0, 0);
         this.scaling = new BABYLON.Vector3(1, 1, 1);
 
-        this._vertices = [];
         this._indices = [];
         this.subMeshes = [];
 
@@ -548,12 +547,14 @@
     };
 
     // Clone
-    BABYLON.Mesh.prototype.clone = function (name, newParent) {
+    BABYLON.Mesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
         var result = new BABYLON.Mesh(name, this._scene);
 
         // Buffers
         result._vertexBuffers = this._vertexBuffers;
-        this._vertexBuffers.references++;
+        for (var kind in result._vertexBuffers) {
+            result._vertexBuffers[kind].references++;
+        }
 
         result._indexBuffer = this._indexBuffer;
         this._indexBuffer.references++;
@@ -562,7 +563,7 @@
         BABYLON.Tools.DeepCopy(this, result, ["name", "material"], ["_indices", "_totalVertices"]);
 
         // Bounding info
-        result._boundingInfo = new BABYLON.BoundingInfo(this._vertexBuffers[BABYLON.VertexBuffer.PositionKind].getData(), 0, this._totalVertices);
+        result._boundingInfo = new BABYLON.BoundingInfo(this.getVerticesData(BABYLON.VertexBuffer.PositionKind), 0, this._totalVertices);
 
         // Material
         result.material = this.material;
@@ -572,12 +573,14 @@
             result.parent = newParent;
         }
 
-        // Children
-        for (var index = 0; index < this._scene.meshes.length; index++) {
-            var mesh = this._scene.meshes[index];
+        if (!doNotCloneChildren) {
+            // Children
+            for (var index = 0; index < this._scene.meshes.length; index++) {
+                var mesh = this._scene.meshes[index];
 
-            if (mesh.parent == this) {
-                mesh.clone(mesh.name, result);
+                if (mesh.parent == this) {
+                    mesh.clone(mesh.name, result);
+                }
             }
         }
 

+ 1 - 1
Babylon/Mesh/babylon.vertexBuffer.js

@@ -30,7 +30,7 @@
                 this._strideSize = 2;
                 break;
             case BABYLON.VertexBuffer.ColorKind:
-                this._strideSize = 4;
+                this._strideSize = 3;
                 break;
         }
     };

+ 1 - 1
Babylon/Shaders/default.fragment.fx

@@ -260,7 +260,7 @@ float CalcFogFactor()
 		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
 	}
 
-	return min(1., max(0., fogCoeff));
+	return clamp(fogCoeff, 0.0, 1.0);
 }
 #endif
 

+ 1 - 1
Babylon/Shaders/iedefault.fragment.fx

@@ -144,7 +144,7 @@ float CalcFogFactor()
 		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
 	}
 
-	return min(1., max(0., fogCoeff));
+	return clamp(fogCoeff, 0.0, 1.0);
 }
 
 #endif

+ 31 - 13
Babylon/babylon.engine.js

@@ -267,17 +267,17 @@
         this._gl.bindBuffer(this._gl.ARRAY_BUFFER, null);
     };
 
-    BABYLON.Engine.prototype.createIndexBuffer = function (indices, is32Bits) {
+    BABYLON.Engine.prototype.createIndexBuffer = function (indices) {
         var vbo = this._gl.createBuffer();
         this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, vbo);
         this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), this._gl.STATIC_DRAW);
         this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, null);
         vbo.references = 1;
-        vbo.is32Bits = is32Bits;
         return vbo;
     };
 
     BABYLON.Engine.prototype.bindBuffers = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
+        this._cachedVertexBuffers = null;
         this._gl.bindBuffer(this._gl.ARRAY_BUFFER, vertexBuffer);
 
         var offset = 0;
@@ -290,24 +290,34 @@
             offset += vertexDeclaration[index] * 4;
         }
 
-        this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+        if (this._cachedIndexBuffer !== indexBuffer) {
+            this._cachedIndexBuffer = indexBuffer;
+            this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+        }
     };
     
     BABYLON.Engine.prototype.bindMultiBuffers = function (vertexBuffers, indexBuffer, effect) {
-        var attributes = effect.getAttributesNames();
-        
-        for (var index = 0; index < attributes.length; index++) {
-            var order = effect.getAttribute(index);
+        if (this._cachedVertexBuffers !== vertexBuffers) {
+            this._cachedVertexBuffers = vertexBuffers;
+            
+            var attributes = effect.getAttributesNames();
 
-            if (order >= 0) {
-                var vertexBuffer = vertexBuffers[attributes[index]];
-                var stride = vertexBuffer.getStrideSize();
-                this._gl.bindBuffer(this._gl.ARRAY_BUFFER, vertexBuffer._buffer);
-                this._gl.vertexAttribPointer(order, stride, this._gl.FLOAT, false, stride * 4, 0);
+            for (var index = 0; index < attributes.length; index++) {
+                var order = effect.getAttribute(index);
+
+                if (order >= 0) {
+                    var vertexBuffer = vertexBuffers[attributes[index]];
+                    var stride = vertexBuffer.getStrideSize();
+                    this._gl.bindBuffer(this._gl.ARRAY_BUFFER, vertexBuffer._buffer);
+                    this._gl.vertexAttribPointer(order, stride, this._gl.FLOAT, false, stride * 4, 0);
+                }
             }
         }
 
-        this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+        if (this._cachedIndexBuffer !== indexBuffer) {
+            this._cachedIndexBuffer = indexBuffer;
+            this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+        }
     };
 
     BABYLON.Engine.prototype._releaseBuffer = function (buffer) {
@@ -356,6 +366,11 @@
         this._gl.attachShader(shaderProgram, fragmentShader);
 
         this._gl.linkProgram(shaderProgram);
+
+        var error = this._gl.getProgramInfoLog(shaderProgram);
+        if (error) {
+            throw new Error(error);
+        }
         
         this._gl.deleteShader(vertexShader);
         this._gl.deleteShader(fragmentShader);
@@ -535,6 +550,9 @@
         this._currentState = {
             culling: null
         };
+        
+        this._cachedVertexBuffers = null;
+        this._cachedVertexBuffers = null;
     };
 
     var getExponantOfTwo = function (value, max) {

+ 7 - 3
Babylon/babylon.scene.js

@@ -134,6 +134,10 @@
     BABYLON.Scene.prototype.getAnimationRatio = function () {
         return this._animationRatio;
     };
+    
+    BABYLON.Scene.prototype.getRenderId = function () {
+        return this._renderId;
+    };
 
     // Ready
     BABYLON.Scene.prototype.isReady = function () {
@@ -368,10 +372,9 @@
         this._totalVertices = 0;
         this._activeVertices = 0;
 
-        // meshes
+        // Meshes
         if (this._selectionOctree) { // Octree
             var selection = this._selectionOctree.select(this._frustumPlanes);
-            this._renderId++;
 
             for (var blockIndex = 0; blockIndex < selection.length; blockIndex++) {
                 var block = selection.data[blockIndex];
@@ -532,6 +535,7 @@
         this._animate();
 
         // Meshes
+        this._renderId++;
         var beforeEvaluateActiveMeshesDate = new Date();
         this._evaluateActiveMeshes();
         this._evaluateActiveMeshesDuration = new Date() - beforeEvaluateActiveMeshesDate;
@@ -550,7 +554,7 @@
         var beforeRenderTargetDate = new Date();
         for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
             var renderTarget = this._renderTargets.data[renderIndex];
-
+            this._renderId++;
             renderTarget.render();
         }
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
Samples/Scenes/WorldMonger/babylon.js


+ 2 - 2
Samples/Scenes/WorldMonger/elevationControl.js

@@ -119,8 +119,8 @@
         if (this._facesOfVertices == null) {
             this._facesOfVertices = [];
 
-            this._groundVerticesPositions = this._ground.getVerticesData(BABYLON.VertexBuffer.PositionKind).getData();
-            this._groundVerticesNormals = this._ground.getVerticesData(BABYLON.VertexBuffer.NormalKind).getData();
+            this._groundVerticesPositions = this._ground.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+            this._groundVerticesNormals = this._ground.getVerticesData(BABYLON.VertexBuffer.NormalKind);
             this._groundIndices = this._ground.getIndices();
 
             this._groundPositions = [];

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 13
babylon.1.3.0.js


+ 2 - 1
what's new.md

@@ -1,6 +1,7 @@
 Changes list
 ============
-
+- 1.3.2:
+ - Fixing a bug with camera.detachControl
 - 1.3.0:
  - Selection octrees
  - Breaking changes: Meshes now use multi vertex buffers (one for each attribute) instead of a big one. This is for more flexibility. The .babylon file format has changed accordingly (no more .vertices property on meshes but .positions, .normals, .colors, .uvs, .uvs2)