David Catuhe 10 anni fa
parent
commit
cc6a0a7d48

+ 1 - 1
Babylon/Mesh/babylon.geometry.ts

@@ -749,4 +749,4 @@
             }
         }
     }
-} 
+} 

+ 65 - 6
Babylon/Mesh/babylon.mesh.js

@@ -40,6 +40,7 @@ var BABYLON;
             this._renderIdForInstances = new Array();
             this._batchCache = new _InstancesBatch();
             this._instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
+            this._sideOrientation = Mesh._DEFAULTSIDE;
             if (source) {
                 // Geometry
                 if (source._geometry) {
@@ -266,6 +267,16 @@ var BABYLON;
         Mesh.prototype.isDisposed = function () {
             return this._isDisposed;
         };
+        Object.defineProperty(Mesh.prototype, "sideOrientation", {
+            get: function () {
+                return this._sideOrientation;
+            },
+            set: function (sideO) {
+                this._sideOrientation = sideO;
+            },
+            enumerable: true,
+            configurable: true
+        });
         // Methods  
         Mesh.prototype._preActivate = function () {
             var sceneRenderId = this.getScene().getRenderId();
@@ -368,6 +379,19 @@ var BABYLON;
                 this.updateVerticesDataDirectly(kind, data, offset, false);
             }
         };
+        // Mesh positions update function :
+        // updates the mesh positions according to the positionFunction returned values.
+        // The positionFunction argument must be a javascript function accepting the mesh "positions" array as parameter.
+        // This dedicated positionFunction computes new mesh positions according to the given mesh type.
+        Mesh.prototype.updateMeshPositions = function (positionFunction) {
+            var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+            positionFunction(positions);
+            var indices = this.getIndices();
+            var normals = this.getVerticesData(BABYLON.VertexBuffer.NormalKind);
+            this.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false, false);
+            BABYLON.VertexData.ComputeNormals(positions, indices, normals);
+            this.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false, false);
+        };
         Mesh.prototype.makeGeometryUnique = function () {
             if (!this._geometry) {
                 return;
@@ -891,7 +915,7 @@ var BABYLON;
          */
         Mesh.prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
             if (parallelProcessing === void 0) { parallelProcessing = true; }
-            if (simplificationType === void 0) { simplificationType = BABYLON.SimplificationType.QUADRATIC; }
+            if (simplificationType === void 0) { simplificationType = 0 /* QUADRATIC */; }
             this.getScene().simplificationQueue.addTask({
                 settings: settings,
                 parallelProcessing: parallelProcessing,
@@ -939,12 +963,47 @@ var BABYLON;
             });
         };
         // Statics
-        Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation) {
+        Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, ribbonInstance) {
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }
-            var ribbon = new Mesh(name, scene);
-            var vertexData = BABYLON.VertexData.CreateRibbon(pathArray, closeArray, closePath, offset, sideOrientation);
-            vertexData.applyToMesh(ribbon, updatable);
-            return ribbon;
+            if (ribbonInstance === void 0) { ribbonInstance = null; }
+            if (ribbonInstance) {
+                // positionFunction : ribbon case
+                // only pathArray and sideOrientation parameters are taken into account for positions update
+                var positionsOfRibbon = function (pathArray, sideOrientation) {
+                    var positionFunction = function (positions) {
+                        var minlg = pathArray[0].length;
+                        var i = 0;
+                        var ns = (sideOrientation == BABYLON.Mesh.DOUBLESIDE) ? 2 : 1;
+                        for (var si = 1; si <= ns; si++) {
+                            for (var p = 0; p < pathArray.length; p++) {
+                                var path = pathArray[p];
+                                var l = path.length;
+                                minlg = (minlg < l) ? minlg : l;
+                                var j = 0;
+                                while (j < minlg) {
+                                    positions[i] = path[j].x;
+                                    positions[i + 1] = path[j].y;
+                                    positions[i + 2] = path[j].z;
+                                    j++;
+                                    i += 3;
+                                }
+                            }
+                        }
+                    };
+                    return positionFunction;
+                };
+                var sideOrientation = ribbonInstance.sideOrientation;
+                var positionFunction = positionsOfRibbon(pathArray, sideOrientation);
+                ribbonInstance.updateMeshPositions(positionFunction);
+                return ribbonInstance;
+            }
+            else {
+                var ribbon = new Mesh(name, scene);
+                ribbon.sideOrientation = sideOrientation;
+                var vertexData = BABYLON.VertexData.CreateRibbon(pathArray, closeArray, closePath, offset, sideOrientation);
+                vertexData.applyToMesh(ribbon, updatable);
+                return ribbon;
+            }
         };
         Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }

+ 14 - 14
Babylon/Mesh/babylon.mesh.ts

@@ -298,7 +298,7 @@
             return this._sideOrientation;
         }
 
-        public set sideOrientation(sideO : number) {
+        public set sideOrientation(sideO: number) {
             this._sideOrientation = sideO;
         }
 
@@ -799,7 +799,7 @@
 
                     this.delayLoadState = Engine.DELAYLOADSTATE_LOADED;
                     scene._removePendingData(this);
-                }, () => { }, scene.database, getBinaryData);
+                },() => { }, scene.database, getBinaryData);
             }
         }
 
@@ -956,7 +956,7 @@
                 }
             };
 
-            Tools.LoadImage(url, onload, () => { }, scene.database);
+            Tools.LoadImage(url, onload,() => { }, scene.database);
         }
 
         public applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number): void {
@@ -977,7 +977,7 @@
             for (var index = 0; index < positions.length; index += 3) {
                 Vector3.FromArrayToRef(positions, index, position);
                 Vector3.FromArrayToRef(normals, index, normal);
-                Vector2.FromArrayToRef(uvs, (index / 3) * 2, uv);
+                Vector2.FromArrayToRef(uvs,(index / 3) * 2, uv);
 
                 // Compute height
                 var u = ((Math.abs(uv.x) * heightMapWidth) % heightMapWidth) | 0;
@@ -1058,8 +1058,8 @@
                 indices[index + 2] = index + 2;
 
                 var p1 = Vector3.FromArray(positions, index * 3);
-                var p2 = Vector3.FromArray(positions, (index + 1) * 3);
-                var p3 = Vector3.FromArray(positions, (index + 2) * 3);
+                var p2 = Vector3.FromArray(positions,(index + 1) * 3);
+                var p3 = Vector3.FromArray(positions,(index + 2) * 3);
 
                 var p1p2 = p1.subtract(p2);
                 var p3p2 = p3.subtract(p2);
@@ -1138,7 +1138,7 @@
             }
             var dupes = [];
 
-            AsyncLoop.SyncAsyncForLoop(vectorPositions.length, 40, (iteration) => {
+            AsyncLoop.SyncAsyncForLoop(vectorPositions.length, 40,(iteration) => {
                 var realPos = vectorPositions.length - 1 - iteration;
                 var testedPosition = vectorPositions[realPos];
                 for (var j = 0; j < realPos; ++j) {
@@ -1148,7 +1148,7 @@
                         break;
                     }
                 }
-            }, () => {
+            },() => {
                     for (var i = 0; i < indices.length; ++i) {
                         indices[i] = dupes[indices[i]] || indices[i];
                     }
@@ -1165,13 +1165,13 @@
 
         // Statics
         public static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE, ribbonInstance: Mesh = null): Mesh {
-            
+
             if (ribbonInstance) {   // existing ribbon instance update
 
                 // positionFunction : ribbon case
                 // only pathArray and sideOrientation parameters are taken into account for positions update
-                var positionsOfRibbon = function(pathArray, sideOrientation) {
-                        var positionFunction = function(positions) {
+                var positionsOfRibbon = function (pathArray, sideOrientation) {
+                    var positionFunction = function (positions) {
                         var minlg = pathArray[0].length;
                         var i = 0;
                         var ns = (sideOrientation == BABYLON.Mesh.DOUBLESIDE) ? 2 : 1;
@@ -1185,7 +1185,7 @@
                                     positions[i] = path[j].x;
                                     positions[i + 1] = path[j].y;
                                     positions[i + 2] = path[j].z;
-                                    j ++;
+                                    j++;
                                     i += 3;
                                 }
                             }
@@ -1390,7 +1390,7 @@
                 }
             };
 
-            Tools.LoadImage(url, onload, () => { }, scene.database);
+            Tools.LoadImage(url, onload,() => { }, scene.database);
 
             return ground;
         }
@@ -1488,7 +1488,7 @@
                     return new PositionNormalVertex(
                         Vector3.Lerp(v0.position, v1.position, clipFactor),
                         Vector3.Lerp(v0.normal, v1.normal, clipFactor)
-                    );
+                        );
                 }
 
                 var result = new Array<PositionNormalVertex>();

+ 8 - 0
Babylon/Tools/babylon.smartCollection.js

@@ -85,6 +85,14 @@ var BABYLON;
                 this._keys = new Array(this._initialCapacity);
             }
         };
+        SmartCollection.prototype.forEach = function (block) {
+            var key;
+            for (key in this.items) {
+                if (this.items.hasOwnProperty(key)) {
+                    block(this.items[key]);
+                }
+            }
+        };
         return SmartCollection;
     })();
     BABYLON.SmartCollection = SmartCollection;

+ 1 - 43
Babylon/Tools/babylon.virtualJoystick.js

@@ -27,7 +27,7 @@ var BABYLON;
             this.reverseLeftRight = false;
             this.reverseUpDown = false;
             // collections of pointers
-            this._touches = new BABYLON.VirtualJoystick.Collection();
+            this._touches = new BABYLON.SmartCollection();
             this.deltaPosition = BABYLON.Vector3.Zero();
             this._joystickSensibility = 25;
             this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
@@ -268,46 +268,4 @@ var BABYLON;
     })();
     BABYLON.VirtualJoystick = VirtualJoystick;
 })(BABYLON || (BABYLON = {}));
-var BABYLON;
-(function (BABYLON) {
-    var VirtualJoystick;
-    (function (VirtualJoystick) {
-        var Collection = (function () {
-            function Collection() {
-                this._count = 0;
-                this._collection = new Array();
-            }
-            Collection.prototype.Count = function () {
-                return this._count;
-            };
-            Collection.prototype.add = function (key, item) {
-                if (this._collection[key] != undefined) {
-                    return undefined;
-                }
-                this._collection[key] = item;
-                return ++this._count;
-            };
-            Collection.prototype.remove = function (key) {
-                if (this._collection[key] == undefined) {
-                    return undefined;
-                }
-                delete this._collection[key];
-                return --this._count;
-            };
-            Collection.prototype.item = function (key) {
-                return this._collection[key];
-            };
-            Collection.prototype.forEach = function (block) {
-                var key;
-                for (key in this._collection) {
-                    if (this._collection.hasOwnProperty(key)) {
-                        block(this._collection[key]);
-                    }
-                }
-            };
-            return Collection;
-        })();
-        VirtualJoystick.Collection = Collection;
-    })(VirtualJoystick = BABYLON.VirtualJoystick || (BABYLON.VirtualJoystick = {}));
-})(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.virtualJoystick.js.map

+ 16 - 17
Babylon/Tools/babylon.virtualJoystick.ts

@@ -20,8 +20,8 @@ module BABYLON {
         private static vjCanvas: HTMLCanvasElement;
         private static vjCanvasContext: CanvasRenderingContext2D;
         private static vjCanvasWidth: number;
-        private static vjCanvasHeight: number; 
-        private static halfWidth: number; 
+        private static vjCanvasHeight: number;
+        private static halfWidth: number;
         private static halfHeight: number;
 
         private _action: () => any;
@@ -72,7 +72,7 @@ module BABYLON {
 
             // injecting a canvas element on top of the canvas 3D game
             if (!VirtualJoystick.vjCanvas) {
-                window.addEventListener("resize", () => {
+                window.addEventListener("resize",() => {
                     VirtualJoystick.vjCanvasWidth = window.innerWidth;
                     VirtualJoystick.vjCanvasHeight = window.innerHeight;
                     VirtualJoystick.vjCanvas.width = VirtualJoystick.vjCanvasWidth;
@@ -111,30 +111,30 @@ module BABYLON {
             this._joystickPointerStartPos = new BABYLON.Vector2(0, 0);
             this._deltaJoystickVector = new BABYLON.Vector2(0, 0);
 
-            VirtualJoystick.vjCanvas.addEventListener('pointerdown', (evt) => {
+            VirtualJoystick.vjCanvas.addEventListener('pointerdown',(evt) => {
                 this._onPointerDown(evt);
             }, false);
-            VirtualJoystick.vjCanvas.addEventListener('pointermove', (evt) => {
+            VirtualJoystick.vjCanvas.addEventListener('pointermove',(evt) => {
                 this._onPointerMove(evt);
             }, false);
-            VirtualJoystick.vjCanvas.addEventListener('pointerup',  (evt) => {
+            VirtualJoystick.vjCanvas.addEventListener('pointerup',(evt) => {
                 this._onPointerUp(evt);
             }, false);
-            VirtualJoystick.vjCanvas.addEventListener('pointerout', (evt) => {
+            VirtualJoystick.vjCanvas.addEventListener('pointerout',(evt) => {
                 this._onPointerUp(evt);
             }, false);
-            VirtualJoystick.vjCanvas.addEventListener("contextmenu", (evt) => {
+            VirtualJoystick.vjCanvas.addEventListener("contextmenu",(evt) => {
                 evt.preventDefault();    // Disables system menu
             }, false);
             requestAnimationFrame(() => { this._drawVirtualJoystick(); });
         }
 
-        public setJoystickSensibility (newJoystickSensibility: number) {
+        public setJoystickSensibility(newJoystickSensibility: number) {
             this._joystickSensibility = newJoystickSensibility;
             this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
         }
 
-        private _onPointerDown (e: PointerEvent) {
+        private _onPointerDown(e: PointerEvent) {
             var positionOnScreenCondition: boolean;
 
             e.preventDefault();
@@ -166,7 +166,7 @@ module BABYLON {
             }
         }
 
-        private _onPointerMove (e: PointerEvent) {
+        private _onPointerMove(e: PointerEvent) {
             // If the current pointer is the one associated to the joystick (first touch contact)
             if (this._joystickPointerID == e.pointerId) {
                 this._joystickPointerPos.x = e.clientX;
@@ -218,18 +218,18 @@ module BABYLON {
             this._deltaJoystickVector.x = 0;
             this._deltaJoystickVector.y = 0;
 
-           this._touches.remove(e.pointerId.toString());
+            this._touches.remove(e.pointerId.toString());
         }
 
         /**
         * Change the color of the virtual joystick
         * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
         */
-        public setJoystickColor (newColor: string) {
+        public setJoystickColor(newColor: string) {
             this._joystickColor = newColor;
         }
 
-        public setActionOnTouch (action: () => any) {
+        public setActionOnTouch(action: () => any) {
             this._action = action;
         }
 
@@ -267,7 +267,7 @@ module BABYLON {
             }
             else {
                 VirtualJoystick.vjCanvasContext.clearRect(VirtualJoystick.vjCanvasWidth / 2, 0, VirtualJoystick.vjCanvasWidth, VirtualJoystick.vjCanvasHeight);
-            } 
+            }
         }
 
         private _drawVirtualJoystick() {
@@ -304,7 +304,7 @@ module BABYLON {
             requestAnimationFrame(() => { this._drawVirtualJoystick(); });
         }
 
-        public releaseCanvas () {
+        public releaseCanvas() {
             if (VirtualJoystick.vjCanvas) {
                 document.body.removeChild(VirtualJoystick.vjCanvas);
                 VirtualJoystick.vjCanvas = null;
@@ -314,4 +314,3 @@ module BABYLON {
 }
 
 
-

+ 103 - 54
babylon.2.1-alpha.debug.js

@@ -8872,8 +8872,27 @@ var BABYLON;
                 return false;
             }
             this._geometries.push(geometry);
+            if (this.onGeometryAdded) {
+                this.onGeometryAdded(geometry);
+            }
             return true;
         };
+        /**
+         * Removes an existing geometry
+         * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
+         * @return {boolean} was the geometry removed or not
+         */
+        Scene.prototype.removeGeometry = function (geometry) {
+            var index = this._geometries.indexOf(geometry);
+            if (index > -1) {
+                this._geometries.splice(index, 1);
+                if (this.onGeometryRemoved) {
+                    this.onGeometryRemoved(geometry);
+                }
+                return true;
+            }
+            return false;
+        };
         Scene.prototype.getGeometries = function () {
             return this._geometries;
         };
@@ -10823,6 +10842,7 @@ var BABYLON;
             this._renderIdForInstances = new Array();
             this._batchCache = new _InstancesBatch();
             this._instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
+            this._sideOrientation = Mesh._DEFAULTSIDE;
             if (source) {
                 // Geometry
                 if (source._geometry) {
@@ -11049,6 +11069,16 @@ var BABYLON;
         Mesh.prototype.isDisposed = function () {
             return this._isDisposed;
         };
+        Object.defineProperty(Mesh.prototype, "sideOrientation", {
+            get: function () {
+                return this._sideOrientation;
+            },
+            set: function (sideO) {
+                this._sideOrientation = sideO;
+            },
+            enumerable: true,
+            configurable: true
+        });
         // Methods  
         Mesh.prototype._preActivate = function () {
             var sceneRenderId = this.getScene().getRenderId();
@@ -11151,6 +11181,19 @@ var BABYLON;
                 this.updateVerticesDataDirectly(kind, data, offset, false);
             }
         };
+        // Mesh positions update function :
+        // updates the mesh positions according to the positionFunction returned values.
+        // The positionFunction argument must be a javascript function accepting the mesh "positions" array as parameter.
+        // This dedicated positionFunction computes new mesh positions according to the given mesh type.
+        Mesh.prototype.updateMeshPositions = function (positionFunction) {
+            var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+            positionFunction(positions);
+            var indices = this.getIndices();
+            var normals = this.getVerticesData(BABYLON.VertexBuffer.NormalKind);
+            this.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false, false);
+            BABYLON.VertexData.ComputeNormals(positions, indices, normals);
+            this.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false, false);
+        };
         Mesh.prototype.makeGeometryUnique = function () {
             if (!this._geometry) {
                 return;
@@ -11722,12 +11765,47 @@ var BABYLON;
             });
         };
         // Statics
-        Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation) {
+        Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, ribbonInstance) {
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }
-            var ribbon = new Mesh(name, scene);
-            var vertexData = BABYLON.VertexData.CreateRibbon(pathArray, closeArray, closePath, offset, sideOrientation);
-            vertexData.applyToMesh(ribbon, updatable);
-            return ribbon;
+            if (ribbonInstance === void 0) { ribbonInstance = null; }
+            if (ribbonInstance) {
+                // positionFunction : ribbon case
+                // only pathArray and sideOrientation parameters are taken into account for positions update
+                var positionsOfRibbon = function (pathArray, sideOrientation) {
+                    var positionFunction = function (positions) {
+                        var minlg = pathArray[0].length;
+                        var i = 0;
+                        var ns = (sideOrientation == BABYLON.Mesh.DOUBLESIDE) ? 2 : 1;
+                        for (var si = 1; si <= ns; si++) {
+                            for (var p = 0; p < pathArray.length; p++) {
+                                var path = pathArray[p];
+                                var l = path.length;
+                                minlg = (minlg < l) ? minlg : l;
+                                var j = 0;
+                                while (j < minlg) {
+                                    positions[i] = path[j].x;
+                                    positions[i + 1] = path[j].y;
+                                    positions[i + 2] = path[j].z;
+                                    j++;
+                                    i += 3;
+                                }
+                            }
+                        }
+                    };
+                    return positionFunction;
+                };
+                var sideOrientation = ribbonInstance.sideOrientation;
+                var positionFunction = positionsOfRibbon(pathArray, sideOrientation);
+                ribbonInstance.updateMeshPositions(positionFunction);
+                return ribbonInstance;
+            }
+            else {
+                var ribbon = new Mesh(name, scene);
+                ribbon.sideOrientation = sideOrientation;
+                var vertexData = BABYLON.VertexData.CreateRibbon(pathArray, closeArray, closePath, offset, sideOrientation);
+                vertexData.applyToMesh(ribbon, updatable);
+                return ribbon;
+            }
         };
         Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }
@@ -12059,7 +12137,6 @@ var BABYLON;
                 for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
                     var vertex = faceVertices[vIndex];
                     vertexData.indices.push(currentVertexDataIndex);
-                    //Vector3.TransformCoordinates(vertex.position, localRotationMatrix).toArray(vertexData.positions, currentVertexDataIndex * 3);
                     vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
                     vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
                     vertexData.uvs.push(0.5 + vertex.position.x / size.x);
@@ -21309,7 +21386,7 @@ var BABYLON;
             this.reverseLeftRight = false;
             this.reverseUpDown = false;
             // collections of pointers
-            this._touches = new BABYLON.VirtualJoystick.Collection();
+            this._touches = new BABYLON.SmartCollection();
             this.deltaPosition = BABYLON.Vector3.Zero();
             this._joystickSensibility = 25;
             this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
@@ -21550,48 +21627,6 @@ var BABYLON;
     })();
     BABYLON.VirtualJoystick = VirtualJoystick;
 })(BABYLON || (BABYLON = {}));
-var BABYLON;
-(function (BABYLON) {
-    var VirtualJoystick;
-    (function (VirtualJoystick) {
-        var Collection = (function () {
-            function Collection() {
-                this._count = 0;
-                this._collection = new Array();
-            }
-            Collection.prototype.Count = function () {
-                return this._count;
-            };
-            Collection.prototype.add = function (key, item) {
-                if (this._collection[key] != undefined) {
-                    return undefined;
-                }
-                this._collection[key] = item;
-                return ++this._count;
-            };
-            Collection.prototype.remove = function (key) {
-                if (this._collection[key] == undefined) {
-                    return undefined;
-                }
-                delete this._collection[key];
-                return --this._count;
-            };
-            Collection.prototype.item = function (key) {
-                return this._collection[key];
-            };
-            Collection.prototype.forEach = function (block) {
-                var key;
-                for (key in this._collection) {
-                    if (this._collection.hasOwnProperty(key)) {
-                        block(this._collection[key]);
-                    }
-                }
-            };
-            return Collection;
-        })();
-        VirtualJoystick.Collection = Collection;
-    })(VirtualJoystick = BABYLON.VirtualJoystick || (BABYLON.VirtualJoystick = {}));
-})(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.virtualJoystick.js.map
 var BABYLON;
 (function (BABYLON) {
@@ -25260,6 +25295,7 @@ var BABYLON;
         };
         Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
             vertexData.applyToGeometry(this, updatable);
+            this.notifyUpdate();
         };
         Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
             this._vertexBuffers = this._vertexBuffers || {};
@@ -25281,6 +25317,7 @@ var BABYLON;
                     mesh.computeWorldMatrix(true);
                 }
             }
+            this.notifyUpdate(kind);
         };
         Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset) {
             var vertexBuffer = this.getVertexBuffer(kind);
@@ -25288,6 +25325,7 @@ var BABYLON;
                 return;
             }
             vertexBuffer.updateDirectly(data, offset);
+            this.notifyUpdate(kind);
         };
         Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
             var vertexBuffer = this.getVertexBuffer(kind);
@@ -25316,6 +25354,7 @@ var BABYLON;
                     }
                 }
             }
+            this.notifyUpdate(kind);
         };
         Geometry.prototype.getTotalVertices = function () {
             if (!this.isReady()) {
@@ -25381,6 +25420,7 @@ var BABYLON;
             for (var index = 0; index < numOfMeshes; index++) {
                 meshes[index]._createGlobalSubMesh();
             }
+            this.notifyUpdate();
         };
         Geometry.prototype.getTotalIndices = function () {
             if (!this.isReady()) {
@@ -25462,6 +25502,11 @@ var BABYLON;
                 this._indexBuffer.references = numOfMeshes;
             }
         };
+        Geometry.prototype.notifyUpdate = function (kind) {
+            if (this.onGeometryUpdated) {
+                this.onGeometryUpdated(this, kind);
+            }
+        };
         Geometry.prototype.load = function (scene, onLoaded) {
             var _this = this;
             if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADING) {
@@ -25517,11 +25562,7 @@ var BABYLON;
             this._delayLoadingFunction = null;
             this._delayInfo = [];
             this._boundingInfo = null; // todo: .dispose()
-            var geometries = this._scene.getGeometries();
-            index = geometries.indexOf(this);
-            if (index > -1) {
-                geometries.splice(index, 1);
-            }
+            this._scene.removeGeometry(this);
             this._isDisposed = true;
         };
         Geometry.prototype.copy = function (id) {
@@ -30283,6 +30324,14 @@ var BABYLON;
                 this._keys = new Array(this._initialCapacity);
             }
         };
+        SmartCollection.prototype.forEach = function (block) {
+            var key;
+            for (key in this.items) {
+                if (this.items.hasOwnProperty(key)) {
+                    block(this.items[key]);
+                }
+            }
+        };
         return SmartCollection;
     })();
     BABYLON.SmartCollection = SmartCollection;

File diff suppressed because it is too large
+ 22 - 26
babylon.2.1-alpha.js