Przeglądaj źródła

very new changes doesn't break changes

DESKTOP-QJU4N0L\mityh 8 lat temu
rodzic
commit
4285d326b0

Plik diff jest za duży
+ 4825 - 4806
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 21 - 21
dist/preview release/babylon.js


Plik diff jest za duży
+ 102 - 11
dist/preview release/babylon.max.js


Plik diff jest za duży
+ 4825 - 4806
dist/preview release/babylon.module.d.ts


Plik diff jest za duży
+ 21 - 21
dist/preview release/babylon.worker.js


+ 25 - 14
src/Particles/babylon.particleSystem.ts

@@ -128,7 +128,6 @@
         private _actualFrame = 0;
         private _scaledUpdateSpeed: number;
 
-
         // sheet animation
         private _animationStarted = false;
         private _loopAnimation = false;
@@ -140,7 +139,7 @@
         private _time = 0;
         // end of sheet animation
 
-        constructor(public name: string, capacity: number, scene: Scene, customEffect?: Effect, cellSize?: any, epsilon: number = 0.01) {
+        constructor(public name: string, capacity: number, scene: Scene, customEffect?: Effect, private cellSize?: any, epsilon: number = 0.01) {
             this.id = name;
             this._capacity = capacity;
 
@@ -212,12 +211,14 @@
             }
 
             this._epsilon = epsilon;
-            if (cellSize.width && cellSize.height) {
-                this.cellWidth = cellSize.width;
-                this.cellHeight = cellSize.height;
-            } else if (cellSize !== undefined) {
-                this.cellWidth = cellSize;
-                this.cellHeight = cellSize;
+            if (cellSize) {
+                if (cellSize.width && cellSize.height) {
+                    this.cellWidth = cellSize.width;
+                    this.cellHeight = cellSize.height;
+                } else {
+                    this.cellWidth = cellSize;
+                    this.cellHeight = cellSize;
+                }
             }
         }
 
@@ -395,6 +396,10 @@
                 defines.push("#define CLIPPLANE");
             }
 
+            if (this.cellSize) {
+                defines.push("#define ANIMATESHEET");
+            }
+
             // Effect
             var join = defines.join("\n");
             if (this._cachedDefines !== join) {
@@ -472,12 +477,18 @@
             }
 
             // Animation sheet
-            var baseSize = this.particleTexture.getBaseSize();
-            var rowSize = baseSize.width / this.cellWidth;
-            var rowOffset = (this.cellIndex / rowSize) >> 0;
-            var columnOffset = this.cellIndex - rowOffset * rowSize;
-            var intertU = this.invertU ? 1 : 0;
-            var interV = this.invertV ? 1 : 0;
+            var rowOffset = 0;
+            var columnOffset = 0;
+            var intertU = 0;
+            var interV = 0;
+            if (this.cellSize) {
+                var baseSize = this.particleTexture.getBaseSize();
+                var rowSize = baseSize.width / this.cellWidth;
+                var rowOffset = (this.cellIndex / rowSize) >> 0;
+                var columnOffset = this.cellIndex - rowOffset * rowSize;
+                var intertU = this.invertU ? 1 : 0;
+                var interV = this.invertV ? 1 : 0;
+            }
 
             // Update VBO
             var offset = 0;

+ 7 - 3
src/Shaders/particles.vertex.fx

@@ -25,8 +25,7 @@ void main(void) {
 	float size = options.y;
 	float angle = options.x;
 	vec2 offset = options.zw;
-	vec2 uvScale = textureInfos.xy;
-
+	
 	cornerPos = vec3(offset.x - 0.5, offset.y  - 0.5, 0.) * size;
 
 	// Rotate
@@ -41,8 +40,13 @@ void main(void) {
 	
 	vColor = color;
 
-	vec2 uvOffset = vec2(abs(offset.x), 1.0 - abs(offset.y));
+	#ifdef ANIMATESHEET
+	vec2 uvScale = textureInfos.xy;
+	vec2 uvOffset = vec2(abs(offset.x - cellInfo.x), 1.0 - abs(offset.y- cellInfo.y));
 	vUV = (uvOffset + cellInfo.zw) * uvScale;
+	#else
+	vUV = offset;
+	#endif
 
 	// Clip plane
 #ifdef CLIPPLANE