mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts] Ported rotated mesh region UV loading. See #1327.
This commit is contained in:
parent
d2c006dfd9
commit
037802bb0c
1
spine-ts/build/spine-all.d.ts
vendored
1
spine-ts/build/spine-all.d.ts
vendored
@ -880,6 +880,7 @@ declare module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5480,7 +5480,17 @@ var spine;
|
|||||||
var region = new TextureAtlasRegion();
|
var region = new TextureAtlasRegion();
|
||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
region.rotate = reader.readValue() == "true";
|
var rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
}
|
||||||
|
else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
var x = parseInt(tuple[0]);
|
var x = parseInt(tuple[0]);
|
||||||
var y = parseInt(tuple[1]);
|
var y = parseInt(tuple[1]);
|
||||||
@ -6582,23 +6592,45 @@ var spine;
|
|||||||
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
||||||
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
||||||
var uvs = this.uvs;
|
var uvs = this.uvs;
|
||||||
var u = 0, v = 0, width = 0, height = 0;
|
var n = this.uvs.length;
|
||||||
|
var u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof spine.TextureAtlasRegion) {
|
if (this.region instanceof spine.TextureAtlasRegion) {
|
||||||
var region = this.region;
|
var region = this.region;
|
||||||
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch (region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
width = region.originalHeight / textureWidth;
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
height = region.originalWidth / textureHeight;
|
width = region.originalHeight / textureWidth;
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
height = region.originalWidth / textureHeight;
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
}
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
}
|
}
|
||||||
@ -6607,12 +6639,10 @@ var spine;
|
|||||||
width = height = 1;
|
width = height = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-canvas.d.ts
vendored
1
spine-ts/build/spine-canvas.d.ts
vendored
@ -880,6 +880,7 @@ declare module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5480,7 +5480,17 @@ var spine;
|
|||||||
var region = new TextureAtlasRegion();
|
var region = new TextureAtlasRegion();
|
||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
region.rotate = reader.readValue() == "true";
|
var rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
}
|
||||||
|
else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
var x = parseInt(tuple[0]);
|
var x = parseInt(tuple[0]);
|
||||||
var y = parseInt(tuple[1]);
|
var y = parseInt(tuple[1]);
|
||||||
@ -6582,23 +6592,45 @@ var spine;
|
|||||||
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
||||||
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
||||||
var uvs = this.uvs;
|
var uvs = this.uvs;
|
||||||
var u = 0, v = 0, width = 0, height = 0;
|
var n = this.uvs.length;
|
||||||
|
var u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof spine.TextureAtlasRegion) {
|
if (this.region instanceof spine.TextureAtlasRegion) {
|
||||||
var region = this.region;
|
var region = this.region;
|
||||||
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch (region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
width = region.originalHeight / textureWidth;
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
height = region.originalWidth / textureHeight;
|
width = region.originalHeight / textureWidth;
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
height = region.originalWidth / textureHeight;
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
}
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
}
|
}
|
||||||
@ -6607,12 +6639,10 @@ var spine;
|
|||||||
width = height = 1;
|
width = height = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-core.d.ts
vendored
1
spine-ts/build/spine-core.d.ts
vendored
@ -880,6 +880,7 @@ declare module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5480,7 +5480,17 @@ var spine;
|
|||||||
var region = new TextureAtlasRegion();
|
var region = new TextureAtlasRegion();
|
||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
region.rotate = reader.readValue() == "true";
|
var rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
}
|
||||||
|
else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
var x = parseInt(tuple[0]);
|
var x = parseInt(tuple[0]);
|
||||||
var y = parseInt(tuple[1]);
|
var y = parseInt(tuple[1]);
|
||||||
@ -6582,23 +6592,45 @@ var spine;
|
|||||||
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
||||||
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
||||||
var uvs = this.uvs;
|
var uvs = this.uvs;
|
||||||
var u = 0, v = 0, width = 0, height = 0;
|
var n = this.uvs.length;
|
||||||
|
var u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof spine.TextureAtlasRegion) {
|
if (this.region instanceof spine.TextureAtlasRegion) {
|
||||||
var region = this.region;
|
var region = this.region;
|
||||||
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch (region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
width = region.originalHeight / textureWidth;
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
height = region.originalWidth / textureHeight;
|
width = region.originalHeight / textureWidth;
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
height = region.originalWidth / textureHeight;
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
}
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
}
|
}
|
||||||
@ -6607,12 +6639,10 @@ var spine;
|
|||||||
width = height = 1;
|
width = height = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-player.d.ts
vendored
1
spine-ts/build/spine-player.d.ts
vendored
@ -880,6 +880,7 @@ declare module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5480,7 +5480,17 @@ var spine;
|
|||||||
var region = new TextureAtlasRegion();
|
var region = new TextureAtlasRegion();
|
||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
region.rotate = reader.readValue() == "true";
|
var rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
}
|
||||||
|
else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
var x = parseInt(tuple[0]);
|
var x = parseInt(tuple[0]);
|
||||||
var y = parseInt(tuple[1]);
|
var y = parseInt(tuple[1]);
|
||||||
@ -6582,23 +6592,45 @@ var spine;
|
|||||||
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
||||||
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
||||||
var uvs = this.uvs;
|
var uvs = this.uvs;
|
||||||
var u = 0, v = 0, width = 0, height = 0;
|
var n = this.uvs.length;
|
||||||
|
var u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof spine.TextureAtlasRegion) {
|
if (this.region instanceof spine.TextureAtlasRegion) {
|
||||||
var region = this.region;
|
var region = this.region;
|
||||||
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch (region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
width = region.originalHeight / textureWidth;
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
height = region.originalWidth / textureHeight;
|
width = region.originalHeight / textureWidth;
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
height = region.originalWidth / textureHeight;
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
}
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
}
|
}
|
||||||
@ -6607,12 +6639,10 @@ var spine;
|
|||||||
width = height = 1;
|
width = height = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-threejs.d.ts
vendored
1
spine-ts/build/spine-threejs.d.ts
vendored
@ -880,6 +880,7 @@ declare module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5480,7 +5480,17 @@ var spine;
|
|||||||
var region = new TextureAtlasRegion();
|
var region = new TextureAtlasRegion();
|
||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
region.rotate = reader.readValue() == "true";
|
var rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
}
|
||||||
|
else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
var x = parseInt(tuple[0]);
|
var x = parseInt(tuple[0]);
|
||||||
var y = parseInt(tuple[1]);
|
var y = parseInt(tuple[1]);
|
||||||
@ -6582,23 +6592,45 @@ var spine;
|
|||||||
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
||||||
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
||||||
var uvs = this.uvs;
|
var uvs = this.uvs;
|
||||||
var u = 0, v = 0, width = 0, height = 0;
|
var n = this.uvs.length;
|
||||||
|
var u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof spine.TextureAtlasRegion) {
|
if (this.region instanceof spine.TextureAtlasRegion) {
|
||||||
var region = this.region;
|
var region = this.region;
|
||||||
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch (region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
width = region.originalHeight / textureWidth;
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
height = region.originalWidth / textureHeight;
|
width = region.originalHeight / textureWidth;
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
height = region.originalWidth / textureHeight;
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
}
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
}
|
}
|
||||||
@ -6607,12 +6639,10 @@ var spine;
|
|||||||
width = height = 1;
|
width = height = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-webgl.d.ts
vendored
1
spine-ts/build/spine-webgl.d.ts
vendored
@ -880,6 +880,7 @@ declare module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5480,7 +5480,17 @@ var spine;
|
|||||||
var region = new TextureAtlasRegion();
|
var region = new TextureAtlasRegion();
|
||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
region.rotate = reader.readValue() == "true";
|
var rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
}
|
||||||
|
else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
var x = parseInt(tuple[0]);
|
var x = parseInt(tuple[0]);
|
||||||
var y = parseInt(tuple[1]);
|
var y = parseInt(tuple[1]);
|
||||||
@ -6582,23 +6592,45 @@ var spine;
|
|||||||
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
if (this.uvs == null || this.uvs.length != regionUVs.length)
|
||||||
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
|
||||||
var uvs = this.uvs;
|
var uvs = this.uvs;
|
||||||
var u = 0, v = 0, width = 0, height = 0;
|
var n = this.uvs.length;
|
||||||
|
var u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof spine.TextureAtlasRegion) {
|
if (this.region instanceof spine.TextureAtlasRegion) {
|
||||||
var region = this.region;
|
var region = this.region;
|
||||||
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch (region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
width = region.originalHeight / textureWidth;
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
height = region.originalWidth / textureHeight;
|
width = region.originalHeight / textureWidth;
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
height = region.originalWidth / textureHeight;
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
}
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (var i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
}
|
}
|
||||||
@ -6607,12 +6639,10 @@ var spine;
|
|||||||
width = height = 1;
|
width = height = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
for (var i = 0, n = uvs.length; i < n; i += 2) {
|
for (var i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -87,7 +87,15 @@ module spine {
|
|||||||
region.name = line;
|
region.name = line;
|
||||||
region.page = page;
|
region.page = page;
|
||||||
|
|
||||||
region.rotate = reader.readValue() == "true";
|
let rotateValue = reader.readValue();
|
||||||
|
if (rotateValue.toLocaleLowerCase() == "true") {
|
||||||
|
region.degrees = 90;
|
||||||
|
} else if (rotateValue.toLocaleLowerCase() == "false") {
|
||||||
|
region.degrees = 0;
|
||||||
|
} else {
|
||||||
|
region.degrees = parseFloat(rotateValue);
|
||||||
|
}
|
||||||
|
region.rotate = region.degrees == 90;
|
||||||
|
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
let x = parseInt(tuple[0]);
|
let x = parseInt(tuple[0]);
|
||||||
@ -207,6 +215,7 @@ module spine {
|
|||||||
y: number;
|
y: number;
|
||||||
index: number;
|
index: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
|
degrees: number;
|
||||||
texture: Texture;
|
texture: Texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,36 +48,56 @@ module spine {
|
|||||||
let regionUVs = this.regionUVs;
|
let regionUVs = this.regionUVs;
|
||||||
if (this.uvs == null || this.uvs.length != regionUVs.length) this.uvs = Utils.newFloatArray(regionUVs.length);
|
if (this.uvs == null || this.uvs.length != regionUVs.length) this.uvs = Utils.newFloatArray(regionUVs.length);
|
||||||
let uvs = this.uvs;
|
let uvs = this.uvs;
|
||||||
let u = 0, v = 0, width = 0, height = 0;
|
let n = this.uvs.length;
|
||||||
|
let u = this.region.u, v = this.region.v, width = 0, height = 0;
|
||||||
if (this.region instanceof TextureAtlasRegion) {
|
if (this.region instanceof TextureAtlasRegion) {
|
||||||
let region = this.region;
|
let region = this.region;
|
||||||
let textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
let textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
|
||||||
if (region.rotate) {
|
switch(region.degrees) {
|
||||||
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
case 90:
|
||||||
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
||||||
|
v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
|
||||||
width = region.originalHeight / textureWidth;
|
width = region.originalHeight / textureWidth;
|
||||||
height = region.originalWidth / textureHeight;
|
height = region.originalWidth / textureHeight;
|
||||||
for (let i = 0, n = uvs.length; i < n; i += 2) {
|
for (let i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i + 1] * width;
|
uvs[i] = u + regionUVs[i + 1] * width;
|
||||||
uvs[i + 1] = v + height - regionUVs[i] * height;
|
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 180:
|
||||||
|
u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
|
||||||
|
v -= region.offsetY / textureHeight;
|
||||||
|
width = region.originalWidth / textureWidth;
|
||||||
|
height = region.originalHeight / textureHeight;
|
||||||
|
for (let i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i]) * width;
|
||||||
|
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 270:
|
||||||
|
u -= region.offsetY / textureWidth;
|
||||||
|
v -= region.offsetX / textureHeight;
|
||||||
|
width = region.originalHeight / textureWidth;
|
||||||
|
height = region.originalWidth / textureHeight;
|
||||||
|
for (let i = 0; i < n; i += 2) {
|
||||||
|
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
|
||||||
|
uvs[i + 1] = v + regionUVs[i] * height;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
u = region.u - region.offsetX / textureWidth;
|
u -= region.offsetX / textureWidth;
|
||||||
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
|
||||||
width = region.originalWidth / textureWidth;
|
width = region.originalWidth / textureWidth;
|
||||||
height = region.originalHeight / textureHeight;
|
height = region.originalHeight / textureHeight;
|
||||||
} else if (this.region == null) {
|
} else if (this.region == null) {
|
||||||
u = v = 0;
|
u = v = 0;
|
||||||
width = height = 1;
|
width = height = 1;
|
||||||
} else {
|
} else {
|
||||||
u = this.region.u;
|
|
||||||
v = this.region.v;
|
|
||||||
width = this.region.u2 - u;
|
width = this.region.u2 - u;
|
||||||
height = this.region.v2 - v;
|
height = this.region.v2 - v;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0, n = uvs.length; i < n; i += 2) {
|
for (let i = 0; i < n; i += 2) {
|
||||||
uvs[i] = u + regionUVs[i] * width;
|
uvs[i] = u + regionUVs[i] * width;
|
||||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user