Procházet zdrojové kódy

[ts] Fix for NaN bounds

This is a temporary fix. Customer send reproduction sample. A slot has a mesh and corresponding deform. The number of vertices in the mesh is != the number of vertices in the deform, resulting in NaNs, which propagate to the bounds calculation of the web player. It is unclear how the mesh and deform can have a different number of vertices.
badlogic před 4 roky
rodič
revize
748a03c7d7

+ 1 - 1
spine-ts/build/spine-all.d.ts

@@ -1402,7 +1402,7 @@ declare module spine.webgl {
 		static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
 		constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps?: boolean);
 		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
+		static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear;
 		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
 		update(useMipMaps: boolean): void;
 		restore(): void;

+ 17 - 4
spine-ts/build/spine-all.js

@@ -6,6 +6,8 @@ var __extends = (this && this.__extends) || (function () {
 		return extendStatics(d, b);
 	};
 	return function (d, b) {
+		if (typeof b !== "function" && b !== null)
+			throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
 		extendStatics(d, b);
 		function __() { this.constructor = d; }
 		d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -4101,11 +4103,17 @@ var spine;
 					var mesh = attachment;
 					verticesLength = mesh.worldVerticesLength;
 					vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
+					if (i == 43) {
+						console.log("WTF");
+					}
 					mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
 				}
 				if (vertices != null) {
 					for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
 						var x = vertices[ii], y = vertices[ii + 1];
+						if (isNaN(x) || isNaN(y)) {
+							console.log("WTF");
+						}
 						minX = Math.min(minX, x);
 						minY = Math.min(minY, y);
 						maxX = Math.max(maxX, x);
@@ -12450,10 +12458,15 @@ var spine;
 				this.animationState.apply(this.skeleton);
 				this.skeleton.updateWorldTransform();
 				this.skeleton.getBounds(offset, size);
-				minX = Math.min(offset.x, minX);
-				maxX = Math.max(offset.x + size.x, maxX);
-				minY = Math.min(offset.y, minY);
-				maxY = Math.max(offset.y + size.y, maxY);
+				if (!isNaN(offset.x) && !isNaN(offset.y) && !isNaN(size.x) && !isNaN(size.y)) {
+					minX = Math.min(offset.x, minX);
+					maxX = Math.max(offset.x + size.x, maxX);
+					minY = Math.min(offset.y, minY);
+					maxY = Math.max(offset.y + size.y, maxY);
+				}
+				else {
+					console.log("Bounds of animation " + animationName + " are NaN");
+				}
 			}
 			offset.x = minX;
 			offset.y = minY;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 8 - 0
spine-ts/build/spine-canvas.js

@@ -6,6 +6,8 @@ var __extends = (this && this.__extends) || (function () {
 		return extendStatics(d, b);
 	};
 	return function (d, b) {
+		if (typeof b !== "function" && b !== null)
+			throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
 		extendStatics(d, b);
 		function __() { this.constructor = d; }
 		d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -4101,11 +4103,17 @@ var spine;
 					var mesh = attachment;
 					verticesLength = mesh.worldVerticesLength;
 					vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
+					if (i == 43) {
+						console.log("WTF");
+					}
 					mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
 				}
 				if (vertices != null) {
 					for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
 						var x = vertices[ii], y = vertices[ii + 1];
+						if (isNaN(x) || isNaN(y)) {
+							console.log("WTF");
+						}
 						minX = Math.min(minX, x);
 						minY = Math.min(minY, y);
 						maxX = Math.max(maxX, x);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
spine-ts/build/spine-canvas.js.map


+ 8 - 0
spine-ts/build/spine-core.js

@@ -6,6 +6,8 @@ var __extends = (this && this.__extends) || (function () {
 		return extendStatics(d, b);
 	};
 	return function (d, b) {
+		if (typeof b !== "function" && b !== null)
+			throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
 		extendStatics(d, b);
 		function __() { this.constructor = d; }
 		d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -4101,11 +4103,17 @@ var spine;
 					var mesh = attachment;
 					verticesLength = mesh.worldVerticesLength;
 					vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
+					if (i == 43) {
+						console.log("WTF");
+					}
 					mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
 				}
 				if (vertices != null) {
 					for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
 						var x = vertices[ii], y = vertices[ii + 1];
+						if (isNaN(x) || isNaN(y)) {
+							console.log("WTF");
+						}
 						minX = Math.min(minX, x);
 						minY = Math.min(minY, y);
 						maxX = Math.max(maxX, x);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
spine-ts/build/spine-core.js.map


+ 1 - 1
spine-ts/build/spine-player.d.ts

@@ -1371,7 +1371,7 @@ declare module spine.webgl {
 		static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
 		constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps?: boolean);
 		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
+		static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear;
 		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
 		update(useMipMaps: boolean): void;
 		restore(): void;

+ 17 - 4
spine-ts/build/spine-player.js

@@ -6,6 +6,8 @@ var __extends = (this && this.__extends) || (function () {
 		return extendStatics(d, b);
 	};
 	return function (d, b) {
+		if (typeof b !== "function" && b !== null)
+			throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
 		extendStatics(d, b);
 		function __() { this.constructor = d; }
 		d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -4101,11 +4103,17 @@ var spine;
 					var mesh = attachment;
 					verticesLength = mesh.worldVerticesLength;
 					vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
+					if (i == 43) {
+						console.log("WTF");
+					}
 					mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
 				}
 				if (vertices != null) {
 					for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
 						var x = vertices[ii], y = vertices[ii + 1];
+						if (isNaN(x) || isNaN(y)) {
+							console.log("WTF");
+						}
 						minX = Math.min(minX, x);
 						minY = Math.min(minY, y);
 						maxX = Math.max(maxX, x);
@@ -11761,10 +11769,15 @@ var spine;
 				this.animationState.apply(this.skeleton);
 				this.skeleton.updateWorldTransform();
 				this.skeleton.getBounds(offset, size);
-				minX = Math.min(offset.x, minX);
-				maxX = Math.max(offset.x + size.x, maxX);
-				minY = Math.min(offset.y, minY);
-				maxY = Math.max(offset.y + size.y, maxY);
+				if (!isNaN(offset.x) && !isNaN(offset.y) && !isNaN(size.x) && !isNaN(size.y)) {
+					minX = Math.min(offset.x, minX);
+					maxX = Math.max(offset.x + size.x, maxX);
+					minY = Math.min(offset.y, minY);
+					maxY = Math.max(offset.y + size.y, maxY);
+				}
+				else {
+					console.log("Bounds of animation " + animationName + " are NaN");
+				}
 			}
 			offset.x = minX;
 			offset.y = minY;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
spine-ts/build/spine-player.js.map


+ 8 - 0
spine-ts/build/spine-threejs.js

@@ -6,6 +6,8 @@ var __extends = (this && this.__extends) || (function () {
 		return extendStatics(d, b);
 	};
 	return function (d, b) {
+		if (typeof b !== "function" && b !== null)
+			throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
 		extendStatics(d, b);
 		function __() { this.constructor = d; }
 		d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -4101,11 +4103,17 @@ var spine;
 					var mesh = attachment;
 					verticesLength = mesh.worldVerticesLength;
 					vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
+					if (i == 43) {
+						console.log("WTF");
+					}
 					mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
 				}
 				if (vertices != null) {
 					for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
 						var x = vertices[ii], y = vertices[ii + 1];
+						if (isNaN(x) || isNaN(y)) {
+							console.log("WTF");
+						}
 						minX = Math.min(minX, x);
 						minY = Math.min(minY, y);
 						maxX = Math.max(maxX, x);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
spine-ts/build/spine-threejs.js.map


+ 1 - 1
spine-ts/build/spine-webgl.d.ts

@@ -1371,7 +1371,7 @@ declare module spine.webgl {
 		static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
 		constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps?: boolean);
 		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
+		static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear;
 		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
 		update(useMipMaps: boolean): void;
 		restore(): void;

+ 8 - 0
spine-ts/build/spine-webgl.js

@@ -6,6 +6,8 @@ var __extends = (this && this.__extends) || (function () {
 		return extendStatics(d, b);
 	};
 	return function (d, b) {
+		if (typeof b !== "function" && b !== null)
+			throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
 		extendStatics(d, b);
 		function __() { this.constructor = d; }
 		d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -4101,11 +4103,17 @@ var spine;
 					var mesh = attachment;
 					verticesLength = mesh.worldVerticesLength;
 					vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
+					if (i == 43) {
+						console.log("WTF");
+					}
 					mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
 				}
 				if (vertices != null) {
 					for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
 						var x = vertices[ii], y = vertices[ii + 1];
+						if (isNaN(x) || isNaN(y)) {
+							console.log("WTF");
+						}
 						minX = Math.min(minX, x);
 						minY = Math.min(minY, y);
 						maxX = Math.max(maxX, x);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
spine-ts/build/spine-webgl.js.map


+ 8 - 4
spine-ts/player/src/Player.ts

@@ -1216,10 +1216,14 @@ module spine {
 				this.skeleton.updateWorldTransform();
 				this.skeleton.getBounds(offset, size);
 
-				minX = Math.min(offset.x, minX);
-				maxX = Math.max(offset.x + size.x, maxX);
-				minY = Math.min(offset.y, minY);
-				maxY = Math.max(offset.y + size.y, maxY);
+				if (!isNaN(offset.x) && !isNaN(offset.y) && !isNaN(size.x) && !isNaN(size.y)) {
+					minX = Math.min(offset.x, minX);
+					maxX = Math.max(offset.x + size.x, maxX);
+					minY = Math.min(offset.y, minY);
+					maxY = Math.max(offset.y + size.y, maxY);
+				} else {
+					console.log("Bounds of animation " + animationName + " are NaN");
+				}
 			}
 
 			offset.x = minX;

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů