Bläddra i källkod

Merge remote-tracking branch 'upstream/master'

jeff Palmer 11 år sedan
förälder
incheckning
ad12f3e300

+ 3 - 3
Babylon/Cameras/babylon.freeCamera.ts

@@ -23,7 +23,7 @@
         private _viewMatrix = BABYLON.Matrix.Zero();
         private _camMatrix = BABYLON.Matrix.Zero();
         private _cameraTransformMatrix = BABYLON.Matrix.Zero();
-        private _cameraRotationMatrix = BABYLON.Matrix.Zero();
+        public _cameraRotationMatrix = BABYLON.Matrix.Zero();
         private _referencePoint = BABYLON.Vector3.Zero();
         private _transformedReferencePoint = BABYLON.Vector3.Zero();
         private _oldPosition = BABYLON.Vector3.Zero();
@@ -41,7 +41,7 @@
         private _onMouseMove: (e: MouseEvent) => any;
         private _onKeyDown: (e: KeyboardEvent) => any;
         private _onKeyUp: (e: KeyboardEvent) => any;
-        private _onLostFocus: (e: FocusEvent) => any;
+        public _onLostFocus: (e: FocusEvent) => any;
         private _reset: () => void;
 
         constructor(name: string, position: Vector3, scene: Scene) {
@@ -97,7 +97,7 @@
         }
 
         // Methods
-        private _computeLocalCameraSpeed(): number {
+        public _computeLocalCameraSpeed(): number {
             return this.speed * ((BABYLON.Tools.GetDeltaTime() / (BABYLON.Tools.GetFps() * 10.0)));
         }
 

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

@@ -1,140 +1,140 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.TouchCamera = function (name, position, scene) {
-        BABYLON.FreeCamera.call(this, name, position, scene);
-            
-        // Offset
-        this._offsetX = null;
-        this._offsetY = null;
-        this._pointerCount = 0;
-        this._pointerPressed = [];
-
-        this.angularSensibility = 200000.0;
-        this.moveSensibility = 500.0;
-    };
-
-    BABYLON.TouchCamera.prototype = Object.create(BABYLON.FreeCamera.prototype);
-
-
-    // Controls
-    BABYLON.TouchCamera.prototype.attachControl = function (canvas, noPreventDefault) {
-        var previousPosition;
-        var that = this;
-        
-        if (this._attachedCanvas) {
-            return;
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    // We're mainly based on the logic defined into the FreeCamera code
+    var TouchCamera = (function (_super) {
+        __extends(TouchCamera, _super);
+        function TouchCamera(name, position, scene) {
+            _super.call(this, name, position, scene);
+            this._offsetX = null;
+            this._offsetY = null;
+            this._pointerCount = 0;
+            this._pointerPressed = [];
+            this.angularSensibility = 200000.0;
+            this.moveSensibility = 500.0;
         }
-        this._attachedCanvas = canvas;
-
-        if (this._onPointerDown === undefined) {
-
-            this._onPointerDown = function(evt) {
+        TouchCamera.prototype.attachControl = function (canvas, noPreventDefault) {
+            var _this = this;
+            var previousPosition;
+
+            if (this._attachedCanvas) {
+                return;
+            }
+            this._attachedCanvas = canvas;
+
+            if (this._onPointerDown === undefined) {
+                this._onPointerDown = function (evt) {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+
+                    _this._pointerPressed.push(evt.pointerId);
+
+                    if (_this._pointerPressed.length !== 1) {
+                        return;
+                    }
+
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                };
 
-                if (!noPreventDefault) {
-                    evt.preventDefault();
-                }
+                this._onPointerUp = function (evt) {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
 
-                that._pointerPressed.push(evt.pointerId);
+                    var index = _this._pointerPressed.indexOf(evt.pointerId);
 
-                if (that._pointerPressed.length !== 1) {
-                    return;
-                }
+                    if (index === -1) {
+                        return;
+                    }
+                    _this._pointerPressed.splice(index, 1);
 
-                previousPosition = {
-                    x: evt.clientX,
-                    y: evt.clientY
+                    if (index != 0) {
+                        return;
+                    }
+                    previousPosition = null;
+                    _this._offsetX = null;
+                    _this._offsetY = null;
                 };
-            };
-
-            this._onPointerUp = function(evt) {
-                if (!noPreventDefault) {
-                    evt.preventDefault();
-                }
-
-                var index = that._pointerPressed.indexOf(evt.pointerId);
-
-                if (index === -1) {
-                    return;
-                }
-                that._pointerPressed.splice(index, 1);
-
-                if (index != 0) {
-                    return;
-                }
-                previousPosition = null;
-                that._offsetX = null;
-                that._offsetY = null;
-            };
-
-            this._onPointerMove = function(evt) {
-                if (!noPreventDefault) {
-                    evt.preventDefault();
-                }
-
-                if (!previousPosition) {
-                    return;
-                }
-
-                var index = that._pointerPressed.indexOf(evt.pointerId);
-
-                if (index != 0) {
-                    return;
-                }
-
-                that._offsetX = evt.clientX - previousPosition.x;
-                that._offsetY = -(evt.clientY - previousPosition.y);
-            };
-
-            this._onLostFocus = function() {
-                that._offsetX = null;
-                that._offsetY = null;
-            };
-        }
 
-        canvas.addEventListener("pointerdown", this._onPointerDown);
-        canvas.addEventListener("pointerup", this._onPointerUp);
-        canvas.addEventListener("pointerout", this._onPointerUp);
-        canvas.addEventListener("pointermove", this._onPointerMove);
+                this._onPointerMove = function (evt) {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
 
-        BABYLON.Tools.RegisterTopRootEvents([
-            { name: "blur", handler: this._onLostFocus }
-        ]);
-    };
+                    if (!previousPosition) {
+                        return;
+                    }
 
-    BABYLON.TouchCamera.prototype.detachControl = function (canvas) {
-        if (this._attachedCanvas != canvas) {
-            return;
-        }
+                    var index = _this._pointerPressed.indexOf(evt.pointerId);
 
-        canvas.removeEventListener("pointerdown", this._onPointerDown);
-        canvas.removeEventListener("pointerup", this._onPointerUp);
-        canvas.removeEventListener("pointerout", this._onPointerUp);
-        canvas.removeEventListener("pointermove", this._onPointerMove);
-
-        BABYLON.Tools.UnregisterTopRootEvents([
-            { name: "blur", handler: this._onLostFocus }
-        ]);
-        
-        this._attachedCanvas = null;
-    };
-    
-    BABYLON.TouchCamera.prototype._checkInputs = function () {
-        if (!this._offsetX) {
-            return;
-        }
-        this.cameraRotation.y += this._offsetX / this.angularSensibility;
+                    if (index != 0) {
+                        return;
+                    }
 
-        if (this._pointerPressed.length > 1) {
-            this.cameraRotation.x += -this._offsetY / this.angularSensibility;
-        } else {
-            var speed = this._computeLocalCameraSpeed();
-            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+                    _this._offsetX = evt.clientX - previousPosition.x;
+                    _this._offsetY = -(evt.clientY - previousPosition.y);
+                };
 
-            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
-            this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
-        }
-    };
-})();
+                this._onLostFocus = function () {
+                    _this._offsetX = null;
+                    _this._offsetY = null;
+                };
+            }
+
+            canvas.addEventListener("pointerdown", this._onPointerDown);
+            canvas.addEventListener("pointerup", this._onPointerUp);
+            canvas.addEventListener("pointerout", this._onPointerUp);
+            canvas.addEventListener("pointermove", this._onPointerMove);
+
+            BABYLON.Tools.RegisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+        };
+
+        TouchCamera.prototype.detachControl = function (canvas) {
+            if (this._attachedCanvas != canvas) {
+                return;
+            }
+
+            canvas.removeEventListener("pointerdown", this._onPointerDown);
+            canvas.removeEventListener("pointerup", this._onPointerUp);
+            canvas.removeEventListener("pointerout", this._onPointerUp);
+            canvas.removeEventListener("pointermove", this._onPointerMove);
+
+            BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+
+            this._attachedCanvas = null;
+        };
+
+        TouchCamera.prototype._checkInputs = function () {
+            if (!this._offsetX) {
+                return;
+            }
+            this.cameraRotation.y += this._offsetX / this.angularSensibility;
+
+            if (this._pointerPressed.length > 1) {
+                this.cameraRotation.x += -this._offsetY / this.angularSensibility;
+            } else {
+                var speed = this._computeLocalCameraSpeed();
+                var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+
+                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+                this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+            }
+        };
+        return TouchCamera;
+    })(BABYLON.FreeCamera);
+    BABYLON.TouchCamera = TouchCamera;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.touchCamera.js.map

+ 137 - 0
Babylon/Cameras/babylon.touchCamera.ts

@@ -0,0 +1,137 @@
+module BABYLON {
+    // We're mainly based on the logic defined into the FreeCamera code
+    export class TouchCamera extends FreeCamera {
+        private _offsetX: number = null;
+        private _offsetY: number = null;
+        private _pointerCount:number = 0;
+        private _pointerPressed = [];
+        private _attachedCanvas: HTMLCanvasElement;
+        private _onPointerDown: (e: PointerEvent) => any;
+        private _onPointerUp: (e: PointerEvent) => any;
+        private _onPointerMove: (e: PointerEvent) => any;
+
+        public angularSensibility: number = 200000.0;
+        public moveSensibility: number = 500.0;
+
+        constructor(name: string, position: Vector3, scene: Scene) {
+            super(name, position, scene);
+        }
+
+        public attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void {
+            var previousPosition;
+
+            if (this._attachedCanvas) {
+                return;
+            }
+            this._attachedCanvas = canvas;
+
+            if (this._onPointerDown === undefined) {
+
+                this._onPointerDown = (evt) => {
+
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+
+                    this._pointerPressed.push(evt.pointerId);
+
+                    if (this._pointerPressed.length !== 1) {
+                        return;
+                    }
+
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                };
+
+                this._onPointerUp = (evt) => {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+
+                    var index: number = this._pointerPressed.indexOf(evt.pointerId);
+
+                    if (index === -1) {
+                        return;
+                    }
+                    this._pointerPressed.splice(index, 1);
+
+                    if (index != 0) {
+                        return;
+                    }
+                    previousPosition = null;
+                    this._offsetX = null;
+                    this._offsetY = null;
+                };
+
+                this._onPointerMove = (evt) => {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+
+                    if (!previousPosition) {
+                        return;
+                    }
+
+                    var index: number = this._pointerPressed.indexOf(evt.pointerId);
+
+                    if (index != 0) {
+                        return;
+                    }
+
+                    this._offsetX = evt.clientX - previousPosition.x;
+                    this._offsetY = -(evt.clientY - previousPosition.y);
+                };
+
+                this._onLostFocus = () => {
+                    this._offsetX = null;
+                    this._offsetY = null;
+                };
+            }
+
+            canvas.addEventListener("pointerdown", this._onPointerDown);
+            canvas.addEventListener("pointerup", this._onPointerUp);
+            canvas.addEventListener("pointerout", this._onPointerUp);
+            canvas.addEventListener("pointermove", this._onPointerMove);
+
+            BABYLON.Tools.RegisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+        }
+
+        public detachControl(canvas: HTMLCanvasElement): void {
+            if (this._attachedCanvas != canvas) {
+                return;
+            }
+
+            canvas.removeEventListener("pointerdown", this._onPointerDown);
+            canvas.removeEventListener("pointerup", this._onPointerUp);
+            canvas.removeEventListener("pointerout", this._onPointerUp);
+            canvas.removeEventListener("pointermove", this._onPointerMove);
+
+            BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+
+            this._attachedCanvas = null;
+        }
+
+        public _checkInputs(): void {
+            if (!this._offsetX) {
+                return;
+            }
+            this.cameraRotation.y += this._offsetX / this.angularSensibility;
+
+            if (this._pointerPressed.length > 1) {
+                this.cameraRotation.x += -this._offsetY / this.angularSensibility;
+            } else {
+                var speed = this._computeLocalCameraSpeed();
+                var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+
+                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+                this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+            }
+        }
+    }
+}

+ 20 - 1
Babylon/Collisions/babylon.pickingInfo.js

@@ -23,7 +23,7 @@
         }
         // Methods
         PickingInfo.prototype.getNormal = function () {
-            if (!this.pickedMesh) {
+            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
                 return null;
             }
 
@@ -40,6 +40,25 @@
 
             return new BABYLON.Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
         };
+
+        PickingInfo.prototype.getTextureCoordinates = function () {
+            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
+                return null;
+            }
+
+            var indices = this.pickedMesh.getIndices();
+            var uvs = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
+
+            var uv0 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);
+            var uv1 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
+            var uv2 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
+
+            uv0 = uv0.scale(this.bu);
+            uv1 = uv1.scale(this.bv);
+            uv2 = uv2.scale(1.0 - this.bu - this.bv);
+
+            return new BABYLON.Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
+        };
         return PickingInfo;
     })();
     BABYLON.PickingInfo = PickingInfo;

+ 20 - 1
Babylon/Collisions/babylon.pickingInfo.ts

@@ -17,7 +17,7 @@
 
         // Methods
         public getNormal(): Vector3 {
-            if (!this.pickedMesh) {
+            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
                 return null;
             }
 
@@ -34,5 +34,24 @@
 
             return new BABYLON.Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
         }
+
+        public getTextureCoordinates(): Vector2 {
+            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
+                return null;
+            }
+
+            var indices = this.pickedMesh.getIndices();
+            var uvs = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
+
+            var uv0 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);
+            var uv1 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
+            var uv2 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
+
+            uv0 = uv0.scale(this.bu);
+            uv1 = uv1.scale(this.bv);
+            uv2 = uv2.scale(1.0 - this.bu - this.bv);
+
+            return new BABYLON.Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
+        }
     }
 } 

+ 0 - 1
Babylon/Culling/babylon.boundingSphere.js

@@ -8,7 +8,6 @@
             var distance = BABYLON.Vector3.Distance(minimum, maximum);
 
             this.center = BABYLON.Vector3.Lerp(minimum, maximum, 0.5);
-            ;
             this.radius = distance * 0.5;
 
             this.centerWorld = BABYLON.Vector3.Zero();

+ 1 - 1
Babylon/Culling/babylon.boundingSphere.ts

@@ -10,7 +10,7 @@
         constructor(public minimum: Vector3, public maximum: Vector3) {
             var distance = BABYLON.Vector3.Distance(minimum, maximum);
 
-            this.center = BABYLON.Vector3.Lerp(minimum, maximum, 0.5);;
+            this.center = BABYLON.Vector3.Lerp(minimum, maximum, 0.5);
             this.radius = distance * 0.5;
 
             this.centerWorld = BABYLON.Vector3.Zero();

+ 8 - 0
Babylon/Math/babylon.math.js

@@ -326,6 +326,14 @@
             return new Vector2(0, 0);
         };
 
+        Vector2.FromArray = function (array, offset) {
+            if (!offset) {
+                offset = 0;
+            }
+
+            return new Vector2(array[offset], array[offset + 1]);
+        };
+
         Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
             var squared = amount * amount;
             var cubed = amount * squared;

+ 8 - 0
Babylon/Math/babylon.math.ts

@@ -294,6 +294,14 @@
             return new Vector2(0, 0);
         }
 
+        public static FromArray(array: number[], offset?: number): Vector2 {
+            if (!offset) {
+                offset = 0;
+            }
+
+            return new Vector2(array[offset], array[offset + 1]);
+        }
+
         public static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2 {
             var squared = amount * amount;
             var cubed = amount * squared;

+ 6 - 1
Babylon/Mesh/babylon.abstractMesh.js

@@ -33,6 +33,7 @@ var BABYLON;
             this._physicImpostor = BABYLON.PhysicsEngine.NoImpostor;
             // Collisions
             this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
+            this.ellipsoidOffset = new BABYLON.Vector3(0, 0, 0);
             this._collider = new BABYLON.Collider();
             this._oldPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
             this._diffPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
@@ -116,6 +117,9 @@ var BABYLON;
         };
 
         AbstractMesh.prototype.getBoundingInfo = function () {
+            if (!this._boundingInfo) {
+                this._updateBoundingInfo();
+            }
             return this._boundingInfo;
         };
 
@@ -534,9 +538,10 @@ var BABYLON;
             var globalPosition = this.getAbsolutePosition();
 
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
+            this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset);
             this._collider.radius = this.ellipsoid;
 
-            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions);
+            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions, this);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
 
             if (this._diffPositionForCollisions.length() > BABYLON.Engine.CollisionsEpsilon) {

+ 6 - 1
Babylon/Mesh/babylon.abstractMesh.ts

@@ -61,6 +61,7 @@
 
         // Collisions
         public ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
+        public ellipsoidOffset = new BABYLON.Vector3(0, 0, 0);
         private _collider = new Collider();
         private _oldPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
         private _diffPositionForCollisions = new BABYLON.Vector3(0, 0, 0);
@@ -115,6 +116,9 @@
         }
 
         public getBoundingInfo(): BoundingInfo {
+            if (!this._boundingInfo) {
+                this._updateBoundingInfo();
+            }
             return this._boundingInfo;
         }
 
@@ -530,9 +534,10 @@
             var globalPosition = this.getAbsolutePosition();
 
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
+            this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset);
             this._collider.radius = this.ellipsoid;
 
-            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions);
+            this.getScene()._getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this._newPositionForCollisions, this);
             this._newPositionForCollisions.subtractToRef(this._oldPositionForCollisions, this._diffPositionForCollisions);
 
             if (this._diffPositionForCollisions.length() > Engine.CollisionsEpsilon) {

+ 20 - 0
Babylon/Mesh/babylon.linesMesh.js

@@ -27,6 +27,22 @@ var BABYLON;
             configurable: true
         });
 
+        Object.defineProperty(LinesMesh.prototype, "isPickable", {
+            get: function () {
+                return false;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
+            get: function () {
+                return false;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
         LinesMesh.prototype._bind = function (subMesh, effect, wireframe) {
             var engine = this.getScene().getEngine();
 
@@ -50,6 +66,10 @@ var BABYLON;
             engine.draw(false, subMesh.indexStart, subMesh.indexCount);
         };
 
+        LinesMesh.prototype.intersects = function (ray, fastCheck) {
+            return null;
+        };
+
         LinesMesh.prototype.dispose = function (doNotRecurse) {
             this._colorShader.dispose();
 

+ 12 - 0
Babylon/Mesh/babylon.linesMesh.ts

@@ -22,6 +22,14 @@
             return this._colorShader;
         }
 
+        public get isPickable(): boolean {
+            return false;
+        }
+
+        public get checkCollisions(): boolean {
+            return false;
+        }
+
         public _bind(subMesh: SubMesh, effect: Effect, wireframe?: boolean): void {
             var engine = this.getScene().getEngine();
 
@@ -45,6 +53,10 @@
             engine.draw(false, subMesh.indexStart, subMesh.indexCount);
         }
 
+        public intersects(ray: Ray, fastCheck?: boolean) {
+            return null;
+        }
+
         public dispose(doNotRecurse?: boolean): void {
             this._colorShader.dispose();
 

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

@@ -768,7 +768,7 @@
         }
 
         // Torus  (Code from SharpDX.org)
-        public static CreateTorus(name: string, diameter, thickness: number, tessellation: number, scene: Scene, updatable?: boolean): Mesh {
+        public static CreateTorus(name: string, diameter:number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean): Mesh {
             var torus = new BABYLON.Mesh(name, scene);
             var vertexData = BABYLON.VertexData.CreateTorus(diameter, thickness, tessellation);
 

+ 16 - 21
Babylon/Mesh/babylon.mesh.vertexData.js

@@ -394,6 +394,7 @@
         };
 
         VertexData.CreateCylinder = function (height, diameterTop, diameterBottom, tessellation, subdivisions) {
+            if (typeof subdivisions === "undefined") { subdivisions = 1; }
             var radiusTop = diameterTop / 2;
             var radiusBottom = diameterBottom / 2;
             var indices = [];
@@ -401,12 +402,12 @@
             var normals = [];
             var uvs = [];
 
-            height          = height || 1;
-            diameterTop     = diameterTop || 0.5;
-            diameterBottom  = diameterBottom || 1;
-            tessellation    = tessellation || 16;
-            subdivisions    = subdivisions || 1;
-            subdivisions    = (subdivisions < 1) ? 1 : subdivisions;
+            height = height || 1;
+            diameterTop = diameterTop || 0.5;
+            diameterBottom = diameterBottom || 1;
+            tessellation = tessellation || 16;
+            subdivisions = subdivisions || 1;
+            subdivisions = (subdivisions < 1) ? 1 : subdivisions;
 
             var getCircleVector = function (i) {
                 var angle = (i * 2.0 * Math.PI / tessellation);
@@ -432,20 +433,15 @@
                     textureScale.x = -textureScale.x;
                 }
 
-                // Positions, normals & uvs
                 for (i = 0; i < tessellation; i++) {
                     var circleVector = getCircleVector(i);
                     var position = circleVector.scale(radius).add(offset);
-                    var textureCoordinate = new BABYLON.Vector2(
-                        circleVector.x * textureScale.x + 0.5,
-                        circleVector.z * textureScale.y + 0.5
-                    );
+                    var textureCoordinate = new BABYLON.Vector2(circleVector.x * textureScale.x + 0.5, circleVector.z * textureScale.y + 0.5);
 
                     positions.push(position.x, position.y, position.z);
                     uvs.push(textureCoordinate.x, textureCoordinate.y);
                 }
 
-                // Indices
                 for (var i = 0; i < tessellation - 2; i++) {
                     if (!isTop) {
                         indices.push(vbase);
@@ -459,11 +455,10 @@
                 }
             };
 
-            var base    = new BABYLON.Vector3(0, -1, 0).scale(height / 2);
-            var offset  = new BABYLON.Vector3(0, 1, 0).scale(height / subdivisions);
-            var stride  = tessellation + 1;
+            var base = new BABYLON.Vector3(0, -1, 0).scale(height / 2);
+            var offset = new BABYLON.Vector3(0, 1, 0).scale(height / subdivisions);
+            var stride = tessellation + 1;
 
-            // Positions, normals & uvs
             for (var i = 0; i <= tessellation; i++) {
                 var circleVector = getCircleVector(i);
                 var textureCoordinate = new BABYLON.Vector2(i / tessellation, 0);
@@ -474,7 +469,7 @@
                     position = circleVector.scale(radius);
                     position.addInPlace(base.add(offset.scale(s)));
                     textureCoordinate.y += 1 / subdivisions;
-                    radius += (radiusTop - radiusBottom)/subdivisions;
+                    radius += (radiusTop - radiusBottom) / subdivisions;
 
                     // Push in arrays
                     positions.push(position.x, position.y, position.z);
@@ -483,14 +478,14 @@
             }
 
             subdivisions += 1;
-            // Indices
+
             for (var s = 0; s < subdivisions - 1; s++) {
                 for (var i = 0; i <= tessellation; i++) {
-                    indices.push( i * subdivisions + s);
+                    indices.push(i * subdivisions + s);
                     indices.push((i * subdivisions + (s + subdivisions)) % (stride * subdivisions));
-                    indices.push( i * subdivisions + (s + 1));
+                    indices.push(i * subdivisions + (s + 1));
 
-                    indices.push( i * subdivisions + (s + 1));
+                    indices.push(i * subdivisions + (s + 1));
                     indices.push((i * subdivisions + (s + subdivisions)) % (stride * subdivisions));
                     indices.push((i * subdivisions + (s + subdivisions + 1)) % (stride * subdivisions));
                 }

+ 1 - 1
Babylon/Mesh/babylon.mesh.vertexData.ts

@@ -410,7 +410,7 @@
             return vertexData;
         }
 
-        public static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: number): VertexData {
+        public static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: number = 1): VertexData {
             var radiusTop = diameterTop / 2;
             var radiusBottom = diameterBottom / 2;
             var indices = [];

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

@@ -162,7 +162,7 @@
 
                 if (vertexIndex < minVertexIndex)
                     minVertexIndex = vertexIndex;
-                else if (vertexIndex > maxVertexIndex)
+                if (vertexIndex > maxVertexIndex)
                     maxVertexIndex = vertexIndex;
             }
 

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

@@ -172,7 +172,7 @@
 
                 if (vertexIndex < minVertexIndex)
                     minVertexIndex = vertexIndex;
-                else if (vertexIndex > maxVertexIndex)
+                if (vertexIndex > maxVertexIndex)
                     maxVertexIndex = vertexIndex;
             }
 

+ 4 - 0
Babylon/Physics/babylon.physicsEngine.js

@@ -58,6 +58,10 @@
         PhysicsEngine.PlaneImpostor = 3;
         PhysicsEngine.CompoundImpostor = 4;
         PhysicsEngine.MeshImpostor = 4;
+        PhysicsEngine.CapsuleImpostor = 5;
+        PhysicsEngine.ConeImpostor = 6;
+        PhysicsEngine.CylinderImpostor = 7;
+        PhysicsEngine.ConvexHullImpostor = 8;
         PhysicsEngine.Epsilon = 0.001;
         return PhysicsEngine;
     })();

+ 4 - 0
Babylon/Physics/babylon.physicsEngine.ts

@@ -89,6 +89,10 @@
         public static PlaneImpostor = 3;
         public static CompoundImpostor = 4;
         public static MeshImpostor = 4;
+        public static CapsuleImpostor = 5;
+        public static ConeImpostor = 6;
+        public static CylinderImpostor = 7;
+        public static ConvexHullImpostor = 8;
         public static Epsilon = 0.001;
     }
 }

+ 2 - 2
Babylon/Tools/babylon.database.js

@@ -9,7 +9,7 @@ var BABYLON = BABYLON || {};
         var fileName = url.substring(url.lastIndexOf("/") + 1, url.length);
         var absLocation = url.substring(0, url.indexOf(fileName, 0));
         return absLocation;
-    };
+    }
 
     // Handling various flavors of prefixed version of IndexedDB
     var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB ||
@@ -45,7 +45,7 @@ var BABYLON = BABYLON || {};
             BABYLON.Tools.Log("Valid manifest file not found. Scene & textures will be loaded directly from the web server.");
             that.enableSceneOffline = false;
             that.enableTexturesOffline = false;
-        };
+        }
 
         var that = this;
         var manifestURL = this.currentSceneUrl + ".manifest";

+ 0 - 1
Babylon/Tools/babylon.tools.js

@@ -580,7 +580,6 @@ var BABYLON;
         Object.defineProperty(Tools, "AllLogLevel", {
             get: function () {
                 return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;
-                ;
             },
             enumerable: true,
             configurable: true

+ 1 - 1
Babylon/Tools/babylon.tools.ts

@@ -611,7 +611,7 @@ module BABYLON {
         }
 
         static get AllLogLevel(): number {
-            return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;;
+            return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;
         }
 
         private static _FormatMessage(message: string): string {

+ 7 - 0
Babylon/babylon.engine.js

@@ -1358,6 +1358,13 @@
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
             }
 
+            for (var i in this._vertexAttribArrays) {
+                if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArrays[i]) {
+                    continue;
+                }
+                this._gl.disableVertexAttribArray(i);
+            }
+
             // Events
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("focus", this._onFocus);

+ 8 - 0
Babylon/babylon.engine.ts

@@ -1386,6 +1386,14 @@
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
             }
 
+            // Unbind
+            for (var i in this._vertexAttribArrays) {
+                if (i > this._gl.VERTEX_ATTRIB_ARRAY_ENABLED || !this._vertexAttribArrays[i]) {
+                    continue;
+                }
+                this._gl.disableVertexAttribArray(i);
+            }
+
             // Events
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("focus", this._onFocus);

+ 23 - 12
Babylon/babylon.scene.js

@@ -179,6 +179,11 @@
 
             this._pointerX = evt.clientX - canvasRect.left;
             this._pointerY = evt.clientY - canvasRect.top;
+
+            if (this.cameraToUseForPointers) {
+                this._pointerX = this._pointerX - this.cameraToUseForPointers.viewport.x * this._engine.getRenderWidth();
+                this._pointerY = this._pointerY - this.cameraToUseForPointers.viewport.y * this._engine.getRenderHeight();
+            }
         };
 
         // Pointers handling
@@ -191,7 +196,7 @@
 
                 var pickResult = _this.pick(_this._pointerX, _this._pointerY, function (mesh) {
                     return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasPointerTriggers;
-                });
+                }, false, _this.cameraToUseForPointers);
 
                 if (pickResult.hit) {
                     _this.setPointerOverMesh(pickResult.pickedMesh);
@@ -216,20 +221,20 @@
 
                 _this._updatePointerPosition(evt);
 
-                var pickResult = _this.pick(_this._pointerX, _this._pointerY, predicate);
+                var pickResult = _this.pick(_this._pointerX, _this._pointerY, predicate, false, _this.cameraToUseForPointers);
 
                 if (pickResult.hit) {
                     if (pickResult.pickedMesh.actionManager) {
-                        switch (evt.buttons) {
-                            case 1:
+                        switch (evt.button) {
+                            case 0:
                                 pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnLeftPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
                                 break;
+                            case 1:
+                                pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnCenterPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
+                                break;
                             case 2:
                                 pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnRightPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
                                 break;
-                            case 3:
-                                pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnCenterPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
-                                break;
                         }
                         pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
                     }
@@ -1004,6 +1009,10 @@
             this._boundingBoxRenderer.dispose();
 
             // Events
+            if (this.onDispose) {
+                this.onDispose();
+            }
+
             this.detachControl();
 
             // Detach cameras
@@ -1061,19 +1070,21 @@
         };
 
         // Collisions
-        Scene.prototype._getNewPosition = function (position, velocity, collider, maximumRetry, finalPosition) {
+        Scene.prototype._getNewPosition = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
+            if (typeof excludedMesh === "undefined") { excludedMesh = null; }
             position.divideToRef(collider.radius, this._scaledPosition);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
 
             collider.retry = 0;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialPosition = this._scaledPosition;
-            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition, excludedMesh);
 
             finalPosition.multiplyInPlace(collider.radius);
         };
 
-        Scene.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition) {
+        Scene.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
+            if (typeof excludedMesh === "undefined") { excludedMesh = null; }
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
 
             if (collider.retry >= maximumRetry) {
@@ -1085,7 +1096,7 @@
 
             for (var index = 0; index < this.meshes.length; index++) {
                 var mesh = this.meshes[index];
-                if (mesh.isEnabled() && mesh.checkCollisions) {
+                if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {
                     mesh._checkCollision(collider);
                 }
             }
@@ -1105,7 +1116,7 @@
             }
 
             collider.retry++;
-            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
         };
 
         // Octrees

+ 26 - 12
Babylon/babylon.scene.ts

@@ -19,6 +19,7 @@
         public ambientColor = new BABYLON.Color3(0, 0, 0);
         public beforeRender: () => void;
         public afterRender: () => void;
+        public onDispose: () => void;
         public beforeCameraRender: (camera: Camera) => void;
         public afterCameraRender: (camera: Camera) => void;
         public forceWireframe = false;
@@ -28,6 +29,7 @@
         private _onPointerMove: (evt: PointerEvent) => void;
         private _onPointerDown: (evt: PointerEvent) => void;
         public onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
+        public cameraToUseForPointers: Camera; // Define this parameter if you are using multiple cameras and you want to specify which one should be sued for pointer position
         private _pointerX: number;
         private _pointerY: number;
         private _meshUnderPointer: AbstractMesh;
@@ -248,6 +250,11 @@
 
             this._pointerX = evt.clientX - canvasRect.left;
             this._pointerY = evt.clientY - canvasRect.top;
+
+            if (this.cameraToUseForPointers) {
+                this._pointerX = this._pointerX - this.cameraToUseForPointers.viewport.x * this._engine.getRenderWidth();
+                this._pointerY = this._pointerY - this.cameraToUseForPointers.viewport.y * this._engine.getRenderHeight();
+            }
         }
 
         // Pointers handling
@@ -257,7 +264,10 @@
 
                 this._updatePointerPosition(evt);
 
-                var pickResult = this.pick(this._pointerX, this._pointerY, (mesh: AbstractMesh): boolean => mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasPointerTriggers);
+                var pickResult = this.pick(this._pointerX, this._pointerY,
+                    (mesh: AbstractMesh): boolean => mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasPointerTriggers,
+                    false,
+                    this.cameraToUseForPointers);
 
                 if (pickResult.hit) {
                     this.setPointerOverMesh(pickResult.pickedMesh);
@@ -283,20 +293,20 @@
 
                 this._updatePointerPosition(evt);
 
-                var pickResult = this.pick(this._pointerX, this._pointerY, predicate);
+                var pickResult = this.pick(this._pointerX, this._pointerY, predicate, false, this.cameraToUseForPointers);
 
                 if (pickResult.hit) {
                     if (pickResult.pickedMesh.actionManager) {
-                        switch (evt.buttons) {
-                            case 1:
+                        switch (evt.button) {
+                            case 0:
                                 pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnLeftPickTrigger, ActionEvent.CreateNew(pickResult.pickedMesh));
                                 break;
+                            case 1:
+                                pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnCenterPickTrigger, ActionEvent.CreateNew(pickResult.pickedMesh));
+                                break;
                             case 2:
                                 pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnRightPickTrigger, ActionEvent.CreateNew(pickResult.pickedMesh));
                                 break;
-                            case 3:
-                                pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnCenterPickTrigger, ActionEvent.CreateNew(pickResult.pickedMesh));
-                                break;
                         }
                         pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnPickTrigger, ActionEvent.CreateNew(pickResult.pickedMesh));
                     }
@@ -1077,6 +1087,10 @@
             this._boundingBoxRenderer.dispose();
 
             // Events
+            if (this.onDispose) {
+                this.onDispose();
+            }
+
             this.detachControl();
 
             // Detach cameras
@@ -1142,19 +1156,19 @@
         }
 
         // Collisions
-        public _getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3): void {
+        public _getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3, excludedMesh: AbstractMesh = null): void {
             position.divideToRef(collider.radius, this._scaledPosition);
             velocity.divideToRef(collider.radius, this._scaledVelocity);
 
             collider.retry = 0;
             collider.initialVelocity = this._scaledVelocity;
             collider.initialPosition = this._scaledPosition;
-            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition, excludedMesh);
 
             finalPosition.multiplyInPlace(collider.radius);
         }
 
-        private _collideWithWorld(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3): void {
+        private _collideWithWorld(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3, excludedMesh: AbstractMesh = null): void {
             var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
 
             if (collider.retry >= maximumRetry) {
@@ -1167,7 +1181,7 @@
             // Check all meshes
             for (var index = 0; index < this.meshes.length; index++) {
                 var mesh = this.meshes[index];
-                if (mesh.isEnabled() && mesh.checkCollisions) {
+                if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {
                     mesh._checkCollision(collider);
                 }
             }
@@ -1187,7 +1201,7 @@
             }
 
             collider.retry++;
-            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition);
+            this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
         }
 
         // Octrees

+ 1 - 1
Exporters/Blender/io_export_babylon.py

@@ -644,7 +644,7 @@ class Export_babylon(bpy.types.Operator, ExportHelper):
 
         # Export Physics
         if object.rigid_body != None:
-            shape_items = {'BOX': 1, 'SPHERE': 2}
+            shape_items = { 'SPHERE': 1, 'BOX': 2, 'MESH': 4, 'CAPSULE': 5, 'CONE': 6, 'CYLINDER': 7, 'CONVEX_HULL': 8}
             shape_type = shape_items[object.rigid_body.collision_shape]
             Export_babylon.write_int(file_handler, "physicsImpostor", shape_type)
             mass = object.rigid_body.mass

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
babylon.1.13-beta-debug.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 13 - 13
babylon.1.13-beta.js


+ 5 - 5
readme.md

@@ -1,18 +1,18 @@
 Babylon.js
 ==========
 
+Getting started? Play directly with the Babylon.js API via our [playground](http://www.babylonjs.com/playground). It contains also lot of simple samples to learn how to use it. 
+
 Official web site: [www.babylonjs.com](http://www.babylonjs.com/) 
 
 Official [forum](http://www.html5gamedevs.com/forum/16-babylonjs/) on www.html5gamedevs.com
 
-Online [assets converter](http://www.babylonjs.com/converter.html) for .FBX, .DAE, .OBJ and .MXB
-
 Online [sandbox](http://www.babylonjs.com/sandbox) where you can test your .babylon scenes with a simple drag'n'drop
 
-Online [playground](http://www.babylonjs.com/playground) where you can interactively learn how to use babylon.js
-
 Online [shader creation tool](http://www.babylonjs.com/cyos/) where you can learn how to create GLSL shaders
 
+Online [asset converter](http://www.babylonjs.com/converter.html) where you can generate .babylon file from .OBJ, .FBX, .DAE
+
 ## Documentation
 - [Wiki](https://github.com/babylonjs/babylon.js/wiki)
 - [Tutorials](https://github.com/BabylonJS/Babylon.js/wiki/Tutorials)
@@ -83,7 +83,7 @@ Online [shader creation tool](http://www.babylonjs.com/cyos/) where you can lear
  - Height maps
  - Constructive solid geometries
 -  Import: 
- - Babylon scene file can be converted from .OBJ, .FBX, .MXB
+ - Babylon scene file can be converted from .OBJ, .FBX
  - Exporter for Blender
  - Exporter for Cheetah3d
  - Exporter for 3ds Max