瀏覽代碼

Merge remote-tracking branch 'upstream/master'

jeff Palmer 10 年之前
父節點
當前提交
79f3ca1093

+ 5 - 0
Babylon/Animations/babylon.animatable.js

@@ -78,6 +78,11 @@ var BABYLON;
                 var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
                 running = running || isRunning;
             }
+            if (!running) {
+                // Remove from active animatables
+                index = this._scene._activeAnimatables.indexOf(this);
+                this._scene._activeAnimatables.splice(index, 1);
+            }
             if (!running && this.onAnimationEnd) {
                 this.onAnimationEnd();
             }

+ 8 - 2
Babylon/Animations/babylon.animatable.ts

@@ -23,8 +23,8 @@
                 var animation = animations[index];
 
                 animation._target = target;
-                this._animations.push(animation);    
-            }            
+                this._animations.push(animation);
+            }
         }
 
         public getAnimationByTargetProperty(property: string) {
@@ -87,6 +87,12 @@
                 running = running || isRunning;
             }
 
+            if (!running) {
+                // Remove from active animatables
+                index = this._scene._activeAnimatables.indexOf(this);
+                this._scene._activeAnimatables.splice(index, 1);
+            }
+
             if (!running && this.onAnimationEnd) {
                 this.onAnimationEnd();
             }

+ 9 - 4
Babylon/Audio/babylon.sound.js

@@ -96,6 +96,9 @@ var BABYLON;
                     BABYLON.Tools.Error("Web Audio is not supported by your browser.");
                     BABYLON.Engine.audioEngine.WarnedWebAudioUnsupported = true;
                 }
+                if (this._readyToPlayCallback) {
+                    this._readyToPlayCallback();
+                }
             }
         }
         Sound.prototype.dispose = function () {
@@ -228,7 +231,7 @@ var BABYLON;
         };
         Sound.prototype.setPosition = function (newPosition) {
             this._position = newPosition;
-            if (this.isPlaying && this.spatialSound) {
+            if (this.spatialSound) {
                 this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
             }
         };
@@ -297,9 +300,11 @@ var BABYLON;
             }
         };
         Sound.prototype._onended = function () {
-            this.isPlaying = false;
-            if (this.onended) {
-                this.onended();
+            if (!this.loop) {
+                this.isPlaying = false;
+                if (this.onended) {
+                    this.onended();
+                }
             }
         };
         /**

+ 10 - 5
Babylon/Audio/babylon.sound.ts

@@ -89,7 +89,7 @@
                 if (urlOrArrayBuffer) {
                     // If it's an URL
                     if (typeof (urlOrArrayBuffer) === "string") {
-                        Tools.LoadFile(urlOrArrayBuffer,(data) => { this._soundLoaded(data); }, null, null, true);
+                        Tools.LoadFile(urlOrArrayBuffer, (data) => { this._soundLoaded(data); }, null, null, true);
                     }
                     else {
                         if (urlOrArrayBuffer instanceof ArrayBuffer) {
@@ -108,6 +108,9 @@
                     BABYLON.Tools.Error("Web Audio is not supported by your browser.");
                     Engine.audioEngine.WarnedWebAudioUnsupported = true;
                 }
+                if (this._readyToPlayCallback) {
+                    this._readyToPlayCallback();
+                }
             }
         }
 
@@ -248,7 +251,7 @@
         public setPosition(newPosition: Vector3) {
             this._position = newPosition;
 
-            if (this.isPlaying && this.spatialSound) {
+            if (this.spatialSound) {
                 this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
             }
         }
@@ -321,9 +324,11 @@
         }
 
         private _onended() {
-            this.isPlaying = false;
-            if (this.onended) {
-                this.onended();
+            if (!this.loop) {
+                this.isPlaying = false;
+                if (this.onended) {
+                    this.onended();
+                }
             }
         }
 

+ 3 - 3
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -22,6 +22,7 @@ var BABYLON;
             this._shadowMap = new BABYLON.RenderTargetTexture(light.name + "_shadowMap", mapSize, this._scene, false);
             this._shadowMap.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
             this._shadowMap.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
+            this._shadowMap.anisotropicFilteringLevel = 1;
             this._shadowMap.updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE);
             this._shadowMap.renderParticles = false;
             this._shadowMap.onAfterUnbind = function () {
@@ -32,9 +33,8 @@ var BABYLON;
                     _this._shadowMap2 = new BABYLON.RenderTargetTexture(light.name + "_shadowMap", mapSize, _this._scene, false);
                     _this._shadowMap2.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
                     _this._shadowMap2.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
-                    _this._shadowMap2.anisotropicFilteringLevel = 16;
                     _this._shadowMap2.updateSamplingMode(BABYLON.Texture.TRILINEAR_SAMPLINGMODE);
-                    _this._downSamplePostprocess = new BABYLON.PassPostProcess("downScale", 1.0 / _this.blurScale, null, BABYLON.Texture.NEAREST_SAMPLINGMODE, _this._scene.getEngine());
+                    _this._downSamplePostprocess = new BABYLON.PassPostProcess("downScale", 1.0 / _this.blurScale, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, _this._scene.getEngine());
                     _this._downSamplePostprocess.onApply = function (effect) {
                         effect.setTexture("textureSampler", _this._shadowMap);
                     };
@@ -172,7 +172,7 @@ var BABYLON;
                 this._filter = value;
                 if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) {
                     this._shadowMap.anisotropicFilteringLevel = 16;
-                    this._shadowMap.updateSamplingMode(BABYLON.Texture.TRILINEAR_SAMPLINGMODE);
+                    this._shadowMap.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE);
                 }
                 else {
                     this._shadowMap.anisotropicFilteringLevel = 1;

+ 3 - 3
Babylon/Lights/Shadows/babylon.shadowGenerator.ts

@@ -69,7 +69,7 @@
 
             if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) {
                 this._shadowMap.anisotropicFilteringLevel = 16;
-                this._shadowMap.updateSamplingMode(Texture.TRILINEAR_SAMPLINGMODE);
+                this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE);
             } else {
                 this._shadowMap.anisotropicFilteringLevel = 1;
                 this._shadowMap.updateSamplingMode(Texture.NEAREST_SAMPLINGMODE);
@@ -132,6 +132,7 @@
             this._shadowMap = new RenderTargetTexture(light.name + "_shadowMap", mapSize, this._scene, false);
             this._shadowMap.wrapU = Texture.CLAMP_ADDRESSMODE;
             this._shadowMap.wrapV = Texture.CLAMP_ADDRESSMODE;
+            this._shadowMap.anisotropicFilteringLevel = 1;
             this._shadowMap.updateSamplingMode(Texture.NEAREST_SAMPLINGMODE);
             this._shadowMap.renderParticles = false;
 
@@ -144,10 +145,9 @@
                     this._shadowMap2 = new RenderTargetTexture(light.name + "_shadowMap", mapSize, this._scene, false);
                     this._shadowMap2.wrapU = Texture.CLAMP_ADDRESSMODE;
                     this._shadowMap2.wrapV = Texture.CLAMP_ADDRESSMODE;
-                    this._shadowMap2.anisotropicFilteringLevel = 16;
                     this._shadowMap2.updateSamplingMode(Texture.TRILINEAR_SAMPLINGMODE);
 
-                    this._downSamplePostprocess = new PassPostProcess("downScale", 1.0 / this.blurScale, null, Texture.NEAREST_SAMPLINGMODE, this._scene.getEngine());
+                    this._downSamplePostprocess = new PassPostProcess("downScale", 1.0 / this.blurScale, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
                     this._downSamplePostprocess.onApply = effect => {
                         effect.setTexture("textureSampler", this._shadowMap);
                     };

+ 1 - 1
Babylon/Lights/babylon.directionalLight.js

@@ -11,7 +11,7 @@ var BABYLON;
         function DirectionalLight(name, direction, scene) {
             _super.call(this, name, scene);
             this.direction = direction;
-            this.shadowOrthoScale = 0.1;
+            this.shadowOrthoScale = 0.5;
             this.position = direction.scale(-1);
         }
         DirectionalLight.prototype.getAbsolutePosition = function () {

+ 1 - 1
Babylon/Lights/babylon.directionalLight.ts

@@ -6,7 +6,7 @@
         public transformedPosition: Vector3;
         private _worldMatrix: Matrix;
 
-        public shadowOrthoScale = 0.1;
+        public shadowOrthoScale = 0.5;
 
         constructor(name: string, public direction: Vector3, scene: Scene) {
             super(name, scene);

+ 3 - 0
Babylon/Loading/babylon.sceneLoader.js

@@ -26,6 +26,9 @@ var BABYLON;
         SceneLoader._getPluginForFilename = function (sceneFilename) {
             var dotPosition = sceneFilename.lastIndexOf(".");
             var queryStringPosition = sceneFilename.indexOf("?");
+            if (queryStringPosition === -1) {
+                queryStringPosition = sceneFilename.length;
+            }
             var extension = sceneFilename.substring(dotPosition, queryStringPosition).toLowerCase();
             for (var index = 0; index < this._registeredPlugins.length; index++) {
                 var plugin = this._registeredPlugins[index];

+ 5 - 0
Babylon/Loading/babylon.sceneLoader.ts

@@ -33,6 +33,11 @@
             var dotPosition = sceneFilename.lastIndexOf(".");
 
             var queryStringPosition = sceneFilename.indexOf("?");
+
+            if (queryStringPosition === -1) {
+                queryStringPosition = sceneFilename.length;
+            }
+
             var extension = sceneFilename.substring(dotPosition, queryStringPosition).toLowerCase();
 
             for (var index = 0; index < this._registeredPlugins.length; index++) {

+ 0 - 2
Babylon/Materials/babylon.standardMaterial.js

@@ -61,13 +61,11 @@ var BABYLON;
         StandardMaterial.prototype.isReady = function (mesh, useInstances) {
             if (this.checkReadyOnlyOnce) {
                 if (this._wasPreviouslyReady) {
-                    return true;
                 }
             }
             var scene = this.getScene();
             if (!this.checkReadyOnEveryCall) {
                 if (this._renderId === scene.getRenderId()) {
-                    return true;
                 }
             }
             var engine = scene.getEngine();

+ 2 - 2
Babylon/Materials/babylon.standardMaterial.ts

@@ -74,7 +74,7 @@
         public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
             if (this.checkReadyOnlyOnce) {
                 if (this._wasPreviouslyReady) {
-                    return true;
+                 //   return true;
                 }
             }
 
@@ -82,7 +82,7 @@
 
             if (!this.checkReadyOnEveryCall) {
                 if (this._renderId === scene.getRenderId()) {
-                    return true;
+                  //  return true;
                 }
             }
 

+ 3 - 3
Babylon/Math/babylon.math.js

@@ -631,14 +631,14 @@ var BABYLON;
             result.z = rz / rw;
         };
         Vector3.TransformCoordinatesToRefSIMD = function (vector, transformation, result) {
-            var v = SIMD.float32x4(vector.x, vector.y, vector.z, 0);
+            var v = SIMD.float32x4.loadXYZ(vector._data, 0);
             var m0 = SIMD.float32x4.load(transformation.m, 0);
             var m1 = SIMD.float32x4.load(transformation.m, 4);
             var m2 = SIMD.float32x4.load(transformation.m, 8);
             var m3 = SIMD.float32x4.load(transformation.m, 12);
             var r = SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(v, 0, 0, 0, 0), m0), SIMD.float32x4.mul(SIMD.float32x4.swizzle(v, 1, 1, 1, 1), m1)), SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(v, 2, 2, 2, 2), m2), m3));
             r = SIMD.float32x4.div(r, SIMD.float32x4.swizzle(r, 3, 3, 3, 3));
-            SIMD.float32x4.storeXYZ(result, 0, r);
+            SIMD.float32x4.storeXYZ(result._data, 0, r);
         };
         Vector3.TransformCoordinatesFromFloatsToRefSIMD = function (x, y, z, transformation, result) {
             var v0 = SIMD.float32x4.splat(x);
@@ -650,7 +650,7 @@ var BABYLON;
             var m3 = SIMD.float32x4.load(transformation.m, 12);
             var r = SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(v0, m0), SIMD.float32x4.mul(v1, m1)), SIMD.float32x4.add(SIMD.float32x4.mul(v2, m2), m3));
             r = SIMD.float32x4.div(r, SIMD.float32x4.swizzle(r, 3, 3, 3, 3));
-            SIMD.float32x4.storeXYZ(result, 0, r);
+            SIMD.float32x4.storeXYZ(result._data, 0, r);
         };
         Vector3.TransformNormal = function (vector, transformation) {
             var result = Vector3.Zero();

+ 3 - 3
Babylon/Math/babylon.math.ts

@@ -781,14 +781,14 @@
         }
 
         public static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void {
-            var v = SIMD.float32x4(vector.x, vector.y, vector.z, 0);
+            var v = SIMD.float32x4.loadXYZ((<any>vector)._data, 0);
             var m0 = SIMD.float32x4.load(transformation.m, 0);
             var m1 = SIMD.float32x4.load(transformation.m, 4);
             var m2 = SIMD.float32x4.load(transformation.m, 8);
             var m3 = SIMD.float32x4.load(transformation.m, 12);
             var r = SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(v, 0, 0, 0, 0), m0), SIMD.float32x4.mul(SIMD.float32x4.swizzle(v, 1, 1, 1, 1), m1)), SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(v, 2, 2, 2, 2), m2), m3));
             r = SIMD.float32x4.div(r, SIMD.float32x4.swizzle(r, 3, 3, 3, 3));
-            SIMD.float32x4.storeXYZ(result, 0, r);
+            SIMD.float32x4.storeXYZ((<any>result)._data, 0, r);
         }
 
         public static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void {
@@ -801,7 +801,7 @@
             var m3 = SIMD.float32x4.load(transformation.m, 12);
             var r = SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(v0, m0), SIMD.float32x4.mul(v1, m1)), SIMD.float32x4.add(SIMD.float32x4.mul(v2, m2), m3));
             r = SIMD.float32x4.div(r, SIMD.float32x4.swizzle(r, 3, 3, 3, 3));
-            SIMD.float32x4.storeXYZ(result, 0, r);
+            SIMD.float32x4.storeXYZ((<any>result)._data, 0, r);
         }
 
         public static TransformNormal(vector: Vector3, transformation: Matrix): Vector3 {

+ 5 - 0
Babylon/Mesh/babylon.geometry.js

@@ -11,6 +11,7 @@ var BABYLON;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
             this._totalVertices = 0;
             this._indices = [];
+            this._isDisposed = false;
             this.id = id;
             this._engine = scene.getEngine();
             this._meshes = [];
@@ -271,6 +272,9 @@ var BABYLON;
             }, function () {
             }, scene.database);
         };
+        Geometry.prototype.isDisposed = function () {
+            return this._isDisposed;
+        };
         Geometry.prototype.dispose = function () {
             var meshes = this._meshes;
             var numOfMeshes = meshes.length;
@@ -299,6 +303,7 @@ var BABYLON;
             if (index > -1) {
                 geometries.splice(index, 1);
             }
+            this._isDisposed = true;
         };
         Geometry.prototype.copy = function (id) {
             var vertexData = new BABYLON.VertexData();

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

@@ -348,7 +348,7 @@
                 if (onLoaded) {
                     onLoaded();
                 }
-            }, () => { }, scene.database);
+            },() => { }, scene.database);
         }
 
         public isDisposed(): boolean {
@@ -743,4 +743,3 @@
         }
     }
 } 
-

+ 1 - 2
Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.ts

@@ -24,8 +24,7 @@
             this._postProcessScaleFactor = cameraSettings.PostProcessScaleFactor;
             this._lensCenterOffset = cameraSettings.LensCenterOffset;
 
-
-           this.onSizeChanged = () => {
+            this.onSizeChanged = () => {
                 this.aspectRatio = this.width * .5 / this.height;
                 this._scaleIn = new BABYLON.Vector2(2, 2 / this.aspectRatio);
                 this._scaleFactor = new BABYLON.Vector2(.5 * (1 / this._postProcessScaleFactor), .5 * (1 / this._postProcessScaleFactor) * this.aspectRatio);

+ 6 - 1
Babylon/PostProcess/babylon.postProcess.js

@@ -58,7 +58,12 @@ var BABYLON;
                 this.onActivate(camera);
             }
             // Clear
-            this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
+            if (this.clearColor) {
+                this._engine.clear(this.clearColor, true, true);
+            }
+            else {
+                this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
+            }
             if (this._reusable) {
                 this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
             }

+ 6 - 2
Babylon/PostProcess/babylon.postProcess.ts

@@ -7,6 +7,7 @@
         public width = -1;
         public height = -1;
         public renderTargetSamplingMode: number;
+        public clearColor: Color4;
 
         private _camera: Camera;
         private _scene: Scene;
@@ -74,7 +75,6 @@
                 if (this.onSizeChanged) {
                     this.onSizeChanged();
                 }
-
             }
 
             this._engine.bindFramebuffer(this._textures.data[this._currentRenderTextureInd]);
@@ -84,7 +84,11 @@
             }
 
             // Clear
-            this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
+            if (this.clearColor) {
+                this._engine.clear(this.clearColor, true, true);
+            } else {
+                this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
+            }
 
             if (this._reusable) {
                 this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;

+ 0 - 1
Babylon/PostProcess/babylon.postProcessManager.ts

@@ -85,7 +85,6 @@
             if (postProcessesTakenIndices.length === 0 || !this._scene.postProcessesEnabled) {
                 return;
             }
-
             var engine = this._scene.getEngine();
 
             for (var index = 0; index < postProcessesTakenIndices.length; index++) {

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

@@ -283,7 +283,7 @@ float computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler, flo
 	depth = 0.5 * depth + vec3(0.5);
 	vec2 uv = depth.xy;
 
-	if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0 || depth.z > 1.0)
+	if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0 || depth.z >= 1.0)
 	{
 		return 1.0;
 	}

+ 6 - 6
Babylon/Shaders/sprites.vertex.fx

@@ -3,7 +3,7 @@ precision highp float;
 #endif
 
 // Attributes
-attribute vec3 position;
+attribute vec4 position;
 attribute vec4 options;
 attribute vec4 cellInfo;
 attribute vec4 color;
@@ -22,15 +22,15 @@ varying float fFogDistance;
 #endif
 
 void main(void) {	
-	vec3 viewPos = (view * vec4(position, 1.0)).xyz; 
-	vec3 cornerPos;
+	vec3 viewPos = (view * vec4(position.xyz, 1.0)).xyz; 
+	vec2 cornerPos;
 	
-	float angle = options.x;
-	float size = options.y;
+	float angle = position.w;
+	vec2 size = vec2(options.x, options.y);
 	vec2 offset = options.zw;
 	vec2 uvScale = textureInfos.xy;
 
-	cornerPos = vec3(offset.x - 0.5, offset.y  - 0.5, 0.) * size;
+	cornerPos = vec2(offset.x - 0.5, offset.y  - 0.5) * size;
 
 	// Rotate
 	vec3 rotatedCorner;

+ 13 - 1
Babylon/Sprites/babylon.sprite.js

@@ -4,7 +4,8 @@ var BABYLON;
         function Sprite(name, manager) {
             this.name = name;
             this.color = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
-            this.size = 1.0;
+            this.width = 1.0;
+            this.height = 1.0;
             this.angle = 0;
             this.cellIndex = 0;
             this.invertU = 0;
@@ -22,6 +23,17 @@ var BABYLON;
             this._manager.sprites.push(this);
             this.position = BABYLON.Vector3.Zero();
         }
+        Object.defineProperty(Sprite.prototype, "size", {
+            get: function () {
+                return this.width;
+            },
+            set: function (value) {
+                this.width = value;
+                this.height = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Sprite.prototype.playAnimation = function (from, to, loop, delay) {
             this._fromIndex = from;
             this._toIndex = to;

+ 11 - 1
Babylon/Sprites/babylon.sprite.ts

@@ -2,7 +2,8 @@
     export class Sprite {
         public position: Vector3;
         public color = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
-        public size = 1.0;
+        public width = 1.0;
+        public height = 1.0;
         public angle = 0;
         public cellIndex = 0;
         public invertU = 0;
@@ -20,6 +21,15 @@
         private _manager: SpriteManager;
         private _time = 0;
 
+        public get size(): number {
+            return this.width;
+        }
+
+        public set size(value: number) {
+            this.width = value;
+            this.height = value;
+        }
+
         constructor(public name: string, manager: SpriteManager) {
             this._manager = manager;
 

+ 15 - 16
Babylon/Sprites/babylon.spriteManager.js

@@ -8,8 +8,8 @@ var BABYLON;
             this.sprites = new Array();
             this.renderingGroupId = 0;
             this.fogEnabled = true;
-            this._vertexDeclaration = [3, 4, 4, 4];
-            this._vertexStrideSize = 15 * 4; // 15 floats per sprite (x, y, z, angle, size, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color)
+            this._vertexDeclaration = [4, 4, 4, 4];
+            this._vertexStrideSize = 16 * 4; // 15 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color)
             this._capacity = capacity;
             this._spriteTexture = new BABYLON.Texture(imgUrl, scene, true, false, samplingMode);
             this._spriteTexture.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
@@ -18,8 +18,6 @@ var BABYLON;
             this._scene = scene;
             this._scene.spriteManagers.push(this);
             // VBO
-            this._vertexDeclaration = [3, 4, 4, 4];
-            this._vertexStrideSize = 15 * 4;
             this._vertexBuffer = scene.getEngine().createDynamicVertexBuffer(capacity * this._vertexStrideSize * 4);
             var indices = [];
             var index = 0;
@@ -39,7 +37,7 @@ var BABYLON;
             this._effectFog = this._scene.getEngine().createEffect("sprites", ["position", "options", "cellInfo", "color"], ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"], ["diffuseSampler"], "#define FOG");
         }
         SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
-            var arrayOffset = index * 15;
+            var arrayOffset = index * 16;
             if (offsetX === 0)
                 offsetX = this._epsilon;
             else if (offsetX === 1)
@@ -52,19 +50,20 @@ var BABYLON;
             this._vertices[arrayOffset + 1] = sprite.position.y;
             this._vertices[arrayOffset + 2] = sprite.position.z;
             this._vertices[arrayOffset + 3] = sprite.angle;
-            this._vertices[arrayOffset + 4] = sprite.size;
-            this._vertices[arrayOffset + 5] = offsetX;
-            this._vertices[arrayOffset + 6] = offsetY;
-            this._vertices[arrayOffset + 7] = sprite.invertU ? 1 : 0;
-            this._vertices[arrayOffset + 8] = sprite.invertV ? 1 : 0;
+            this._vertices[arrayOffset + 4] = sprite.width;
+            this._vertices[arrayOffset + 5] = sprite.height;
+            this._vertices[arrayOffset + 6] = offsetX;
+            this._vertices[arrayOffset + 7] = offsetY;
+            this._vertices[arrayOffset + 8] = sprite.invertU ? 1 : 0;
+            this._vertices[arrayOffset + 9] = sprite.invertV ? 1 : 0;
             var offset = (sprite.cellIndex / rowSize) >> 0;
-            this._vertices[arrayOffset + 9] = sprite.cellIndex - offset * rowSize;
-            this._vertices[arrayOffset + 10] = offset;
+            this._vertices[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
+            this._vertices[arrayOffset + 11] = offset;
             // Color
-            this._vertices[arrayOffset + 11] = sprite.color.r;
-            this._vertices[arrayOffset + 12] = sprite.color.g;
-            this._vertices[arrayOffset + 13] = sprite.color.b;
-            this._vertices[arrayOffset + 14] = sprite.color.a;
+            this._vertices[arrayOffset + 12] = sprite.color.r;
+            this._vertices[arrayOffset + 13] = sprite.color.g;
+            this._vertices[arrayOffset + 14] = sprite.color.b;
+            this._vertices[arrayOffset + 15] = sprite.color.a;
         };
         SpriteManager.prototype.render = function () {
             // Check

+ 15 - 16
Babylon/Sprites/babylon.spriteManager.ts

@@ -11,8 +11,8 @@
 
         private _scene: Scene;
 
-        private _vertexDeclaration = [3, 4, 4, 4];
-        private _vertexStrideSize = 15 * 4; // 15 floats per sprite (x, y, z, angle, size, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color)
+        private _vertexDeclaration = [4, 4, 4, 4];
+        private _vertexStrideSize = 16 * 4; // 15 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color)
         private _vertexBuffer: WebGLBuffer;
         private _indexBuffer: WebGLBuffer;
         private _vertices: Float32Array;
@@ -31,8 +31,6 @@
             this._scene.spriteManagers.push(this);
 
             // VBO
-            this._vertexDeclaration = [3, 4, 4, 4];
-            this._vertexStrideSize = 15 * 4;
             this._vertexBuffer = scene.getEngine().createDynamicVertexBuffer(capacity * this._vertexStrideSize * 4);
 
             var indices = [];
@@ -63,7 +61,7 @@
         }
 
         private _appendSpriteVertex(index: number, sprite: Sprite, offsetX: number, offsetY: number, rowSize: number): void {
-            var arrayOffset = index * 15;
+            var arrayOffset = index * 16;
 
             if (offsetX === 0)
                 offsetX = this._epsilon;
@@ -79,19 +77,20 @@
             this._vertices[arrayOffset + 1] = sprite.position.y;
             this._vertices[arrayOffset + 2] = sprite.position.z;
             this._vertices[arrayOffset + 3] = sprite.angle;
-            this._vertices[arrayOffset + 4] = sprite.size;
-            this._vertices[arrayOffset + 5] = offsetX;
-            this._vertices[arrayOffset + 6] = offsetY;
-            this._vertices[arrayOffset + 7] = sprite.invertU ? 1 : 0;
-            this._vertices[arrayOffset + 8] = sprite.invertV ? 1 : 0;
+            this._vertices[arrayOffset + 4] = sprite.width;
+            this._vertices[arrayOffset + 5] = sprite.height;
+            this._vertices[arrayOffset + 6] = offsetX;
+            this._vertices[arrayOffset + 7] = offsetY;
+            this._vertices[arrayOffset + 8] = sprite.invertU ? 1 : 0;
+            this._vertices[arrayOffset + 9] = sprite.invertV ? 1 : 0;
             var offset = (sprite.cellIndex / rowSize) >> 0;
-            this._vertices[arrayOffset + 9] = sprite.cellIndex - offset * rowSize;
-            this._vertices[arrayOffset + 10] = offset;
+            this._vertices[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
+            this._vertices[arrayOffset + 11] = offset;
             // Color
-            this._vertices[arrayOffset + 11] = sprite.color.r;
-            this._vertices[arrayOffset + 12] = sprite.color.g;
-            this._vertices[arrayOffset + 13] = sprite.color.b;
-            this._vertices[arrayOffset + 14] = sprite.color.a;
+            this._vertices[arrayOffset + 12] = sprite.color.r;
+            this._vertices[arrayOffset + 13] = sprite.color.g;
+            this._vertices[arrayOffset + 14] = sprite.color.b;
+            this._vertices[arrayOffset + 15] = sprite.color.a;
         }
 
         public render(): void {

+ 1 - 4
Babylon/babylon.scene.js

@@ -508,10 +508,7 @@ var BABYLON;
             var now = BABYLON.Tools.Now;
             var delay = now - this._animationStartDate;
             for (var index = 0; index < this._activeAnimatables.length; index++) {
-                if (!this._activeAnimatables[index]._animate(delay)) {
-                    this._activeAnimatables.splice(index, 1);
-                    index--;
-                }
+                this._activeAnimatables[index]._animate(delay);
             }
         };
         // Matrix

+ 1 - 4
Babylon/babylon.scene.ts

@@ -692,10 +692,7 @@
             var delay = now - this._animationStartDate;
 
             for (var index = 0; index < this._activeAnimatables.length; index++) {
-                if (!this._activeAnimatables[index]._animate(delay)) {
-                    this._activeAnimatables.splice(index, 1);
-                    index--;
-                }
+                this._activeAnimatables[index]._animate(delay);
             }
         }
 

File diff suppressed because it is too large
+ 66 - 37
babylon.2.1-alpha.debug.js


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