mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
[ts] Ported all skin API changes, see #841.
This commit is contained in:
parent
40e6b026bd
commit
f9e4fd495d
5
spine-ts/build/spine-all.d.ts
vendored
5
spine-ts/build/spine-all.d.ts
vendored
@ -1103,9 +1103,9 @@ declare module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
deformAttachment: VertexAttachment;
|
||||
constructor(name: string);
|
||||
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
copyTo(attachment: VertexAttachment): void;
|
||||
}
|
||||
}
|
||||
@ -1157,14 +1157,13 @@ declare module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh;
|
||||
inheritDeform: boolean;
|
||||
tempColor: Color;
|
||||
constructor(name: string);
|
||||
updateUVs(): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
getParentMesh(): MeshAttachment;
|
||||
setParentMesh(parentMesh: MeshAttachment): void;
|
||||
copy(): Attachment;
|
||||
newLinkedMesh(): MeshAttachment;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -698,7 +698,7 @@ var spine;
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
|
||||
return;
|
||||
var deformArray = slot.deform;
|
||||
if (deformArray.length == 0)
|
||||
@ -4694,6 +4694,7 @@ var spine;
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -4769,8 +4770,7 @@ var spine;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5236,11 +5236,12 @@ var spine;
|
||||
}());
|
||||
spine.SkeletonJson = SkeletonJson;
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
@ -5334,18 +5335,15 @@ var spine;
|
||||
var attachments = skin.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
attachments = this.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment_1 = attachments[i];
|
||||
if (attachment_1.attachment instanceof spine.MeshAttachment) {
|
||||
var mesh = attachment_1.attachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment_1.slotIndex, mesh.getParentMesh().name));
|
||||
mesh.updateUVs();
|
||||
}
|
||||
if (attachment.attachment == null)
|
||||
continue;
|
||||
if (attachment.attachment instanceof spine.MeshAttachment) {
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6594,6 +6592,7 @@ var spine;
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
_this.worldVerticesLength = 0;
|
||||
_this.deformAttachment = _this;
|
||||
return _this;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -6655,9 +6654,6 @@ var spine;
|
||||
}
|
||||
}
|
||||
};
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.prototype.copyTo = function (attachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array(this.bones.length);
|
||||
@ -6672,6 +6668,7 @@ var spine;
|
||||
else
|
||||
attachment.vertices = null;
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
@ -6736,7 +6733,6 @@ var spine;
|
||||
function MeshAttachment(name) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.color = new spine.Color(1, 1, 1, 1);
|
||||
_this.inheritDeform = false;
|
||||
_this.tempColor = new spine.Color(0, 0, 0, 0);
|
||||
return _this;
|
||||
}
|
||||
@ -6800,9 +6796,6 @@ var spine;
|
||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
};
|
||||
MeshAttachment.prototype.getParentMesh = function () {
|
||||
return this.parentMesh;
|
||||
};
|
||||
@ -6819,31 +6812,36 @@ var spine;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.copy = function () {
|
||||
var copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null)
|
||||
return this.newLinkedMesh();
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
}
|
||||
else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
copy.color.setFromColor(this.color);
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
return copy;
|
||||
};
|
||||
MeshAttachment.prototype.newLinkedMesh = function () {
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
};
|
||||
return MeshAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
5
spine-ts/build/spine-canvas.d.ts
vendored
5
spine-ts/build/spine-canvas.d.ts
vendored
@ -1103,9 +1103,9 @@ declare module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
deformAttachment: VertexAttachment;
|
||||
constructor(name: string);
|
||||
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
copyTo(attachment: VertexAttachment): void;
|
||||
}
|
||||
}
|
||||
@ -1157,14 +1157,13 @@ declare module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh;
|
||||
inheritDeform: boolean;
|
||||
tempColor: Color;
|
||||
constructor(name: string);
|
||||
updateUVs(): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
getParentMesh(): MeshAttachment;
|
||||
setParentMesh(parentMesh: MeshAttachment): void;
|
||||
copy(): Attachment;
|
||||
newLinkedMesh(): MeshAttachment;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -698,7 +698,7 @@ var spine;
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
|
||||
return;
|
||||
var deformArray = slot.deform;
|
||||
if (deformArray.length == 0)
|
||||
@ -4694,6 +4694,7 @@ var spine;
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -4769,8 +4770,7 @@ var spine;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5236,11 +5236,12 @@ var spine;
|
||||
}());
|
||||
spine.SkeletonJson = SkeletonJson;
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
@ -5334,18 +5335,15 @@ var spine;
|
||||
var attachments = skin.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
attachments = this.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment_1 = attachments[i];
|
||||
if (attachment_1.attachment instanceof spine.MeshAttachment) {
|
||||
var mesh = attachment_1.attachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment_1.slotIndex, mesh.getParentMesh().name));
|
||||
mesh.updateUVs();
|
||||
}
|
||||
if (attachment.attachment == null)
|
||||
continue;
|
||||
if (attachment.attachment instanceof spine.MeshAttachment) {
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6594,6 +6592,7 @@ var spine;
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
_this.worldVerticesLength = 0;
|
||||
_this.deformAttachment = _this;
|
||||
return _this;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -6655,9 +6654,6 @@ var spine;
|
||||
}
|
||||
}
|
||||
};
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.prototype.copyTo = function (attachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array(this.bones.length);
|
||||
@ -6672,6 +6668,7 @@ var spine;
|
||||
else
|
||||
attachment.vertices = null;
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
@ -6736,7 +6733,6 @@ var spine;
|
||||
function MeshAttachment(name) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.color = new spine.Color(1, 1, 1, 1);
|
||||
_this.inheritDeform = false;
|
||||
_this.tempColor = new spine.Color(0, 0, 0, 0);
|
||||
return _this;
|
||||
}
|
||||
@ -6800,9 +6796,6 @@ var spine;
|
||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
};
|
||||
MeshAttachment.prototype.getParentMesh = function () {
|
||||
return this.parentMesh;
|
||||
};
|
||||
@ -6819,31 +6812,36 @@ var spine;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.copy = function () {
|
||||
var copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null)
|
||||
return this.newLinkedMesh();
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
}
|
||||
else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
copy.color.setFromColor(this.color);
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
return copy;
|
||||
};
|
||||
MeshAttachment.prototype.newLinkedMesh = function () {
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
};
|
||||
return MeshAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
5
spine-ts/build/spine-core.d.ts
vendored
5
spine-ts/build/spine-core.d.ts
vendored
@ -1103,9 +1103,9 @@ declare module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
deformAttachment: VertexAttachment;
|
||||
constructor(name: string);
|
||||
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
copyTo(attachment: VertexAttachment): void;
|
||||
}
|
||||
}
|
||||
@ -1157,14 +1157,13 @@ declare module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh;
|
||||
inheritDeform: boolean;
|
||||
tempColor: Color;
|
||||
constructor(name: string);
|
||||
updateUVs(): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
getParentMesh(): MeshAttachment;
|
||||
setParentMesh(parentMesh: MeshAttachment): void;
|
||||
copy(): Attachment;
|
||||
newLinkedMesh(): MeshAttachment;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -698,7 +698,7 @@ var spine;
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
|
||||
return;
|
||||
var deformArray = slot.deform;
|
||||
if (deformArray.length == 0)
|
||||
@ -4694,6 +4694,7 @@ var spine;
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -4769,8 +4770,7 @@ var spine;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5236,11 +5236,12 @@ var spine;
|
||||
}());
|
||||
spine.SkeletonJson = SkeletonJson;
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
@ -5334,18 +5335,15 @@ var spine;
|
||||
var attachments = skin.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
attachments = this.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment_1 = attachments[i];
|
||||
if (attachment_1.attachment instanceof spine.MeshAttachment) {
|
||||
var mesh = attachment_1.attachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment_1.slotIndex, mesh.getParentMesh().name));
|
||||
mesh.updateUVs();
|
||||
}
|
||||
if (attachment.attachment == null)
|
||||
continue;
|
||||
if (attachment.attachment instanceof spine.MeshAttachment) {
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6594,6 +6592,7 @@ var spine;
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
_this.worldVerticesLength = 0;
|
||||
_this.deformAttachment = _this;
|
||||
return _this;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -6655,9 +6654,6 @@ var spine;
|
||||
}
|
||||
}
|
||||
};
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.prototype.copyTo = function (attachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array(this.bones.length);
|
||||
@ -6672,6 +6668,7 @@ var spine;
|
||||
else
|
||||
attachment.vertices = null;
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
@ -6736,7 +6733,6 @@ var spine;
|
||||
function MeshAttachment(name) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.color = new spine.Color(1, 1, 1, 1);
|
||||
_this.inheritDeform = false;
|
||||
_this.tempColor = new spine.Color(0, 0, 0, 0);
|
||||
return _this;
|
||||
}
|
||||
@ -6800,9 +6796,6 @@ var spine;
|
||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
};
|
||||
MeshAttachment.prototype.getParentMesh = function () {
|
||||
return this.parentMesh;
|
||||
};
|
||||
@ -6819,31 +6812,36 @@ var spine;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.copy = function () {
|
||||
var copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null)
|
||||
return this.newLinkedMesh();
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
}
|
||||
else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
copy.color.setFromColor(this.color);
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
return copy;
|
||||
};
|
||||
MeshAttachment.prototype.newLinkedMesh = function () {
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
};
|
||||
return MeshAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
5
spine-ts/build/spine-player.d.ts
vendored
5
spine-ts/build/spine-player.d.ts
vendored
@ -1103,9 +1103,9 @@ declare module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
deformAttachment: VertexAttachment;
|
||||
constructor(name: string);
|
||||
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
copyTo(attachment: VertexAttachment): void;
|
||||
}
|
||||
}
|
||||
@ -1157,14 +1157,13 @@ declare module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh;
|
||||
inheritDeform: boolean;
|
||||
tempColor: Color;
|
||||
constructor(name: string);
|
||||
updateUVs(): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
getParentMesh(): MeshAttachment;
|
||||
setParentMesh(parentMesh: MeshAttachment): void;
|
||||
copy(): Attachment;
|
||||
newLinkedMesh(): MeshAttachment;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -698,7 +698,7 @@ var spine;
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
|
||||
return;
|
||||
var deformArray = slot.deform;
|
||||
if (deformArray.length == 0)
|
||||
@ -4694,6 +4694,7 @@ var spine;
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -4769,8 +4770,7 @@ var spine;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5236,11 +5236,12 @@ var spine;
|
||||
}());
|
||||
spine.SkeletonJson = SkeletonJson;
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
@ -5334,18 +5335,15 @@ var spine;
|
||||
var attachments = skin.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
attachments = this.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment_1 = attachments[i];
|
||||
if (attachment_1.attachment instanceof spine.MeshAttachment) {
|
||||
var mesh = attachment_1.attachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment_1.slotIndex, mesh.getParentMesh().name));
|
||||
mesh.updateUVs();
|
||||
}
|
||||
if (attachment.attachment == null)
|
||||
continue;
|
||||
if (attachment.attachment instanceof spine.MeshAttachment) {
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6594,6 +6592,7 @@ var spine;
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
_this.worldVerticesLength = 0;
|
||||
_this.deformAttachment = _this;
|
||||
return _this;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -6655,9 +6654,6 @@ var spine;
|
||||
}
|
||||
}
|
||||
};
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.prototype.copyTo = function (attachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array(this.bones.length);
|
||||
@ -6672,6 +6668,7 @@ var spine;
|
||||
else
|
||||
attachment.vertices = null;
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
@ -6736,7 +6733,6 @@ var spine;
|
||||
function MeshAttachment(name) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.color = new spine.Color(1, 1, 1, 1);
|
||||
_this.inheritDeform = false;
|
||||
_this.tempColor = new spine.Color(0, 0, 0, 0);
|
||||
return _this;
|
||||
}
|
||||
@ -6800,9 +6796,6 @@ var spine;
|
||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
};
|
||||
MeshAttachment.prototype.getParentMesh = function () {
|
||||
return this.parentMesh;
|
||||
};
|
||||
@ -6819,31 +6812,36 @@ var spine;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.copy = function () {
|
||||
var copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null)
|
||||
return this.newLinkedMesh();
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
}
|
||||
else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
copy.color.setFromColor(this.color);
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
return copy;
|
||||
};
|
||||
MeshAttachment.prototype.newLinkedMesh = function () {
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
};
|
||||
return MeshAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
5
spine-ts/build/spine-threejs.d.ts
vendored
5
spine-ts/build/spine-threejs.d.ts
vendored
@ -1103,9 +1103,9 @@ declare module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
deformAttachment: VertexAttachment;
|
||||
constructor(name: string);
|
||||
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
copyTo(attachment: VertexAttachment): void;
|
||||
}
|
||||
}
|
||||
@ -1157,14 +1157,13 @@ declare module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh;
|
||||
inheritDeform: boolean;
|
||||
tempColor: Color;
|
||||
constructor(name: string);
|
||||
updateUVs(): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
getParentMesh(): MeshAttachment;
|
||||
setParentMesh(parentMesh: MeshAttachment): void;
|
||||
copy(): Attachment;
|
||||
newLinkedMesh(): MeshAttachment;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -698,7 +698,7 @@ var spine;
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
|
||||
return;
|
||||
var deformArray = slot.deform;
|
||||
if (deformArray.length == 0)
|
||||
@ -4694,6 +4694,7 @@ var spine;
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -4769,8 +4770,7 @@ var spine;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5236,11 +5236,12 @@ var spine;
|
||||
}());
|
||||
spine.SkeletonJson = SkeletonJson;
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
@ -5334,18 +5335,15 @@ var spine;
|
||||
var attachments = skin.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
attachments = this.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment_1 = attachments[i];
|
||||
if (attachment_1.attachment instanceof spine.MeshAttachment) {
|
||||
var mesh = attachment_1.attachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment_1.slotIndex, mesh.getParentMesh().name));
|
||||
mesh.updateUVs();
|
||||
}
|
||||
if (attachment.attachment == null)
|
||||
continue;
|
||||
if (attachment.attachment instanceof spine.MeshAttachment) {
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6594,6 +6592,7 @@ var spine;
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
_this.worldVerticesLength = 0;
|
||||
_this.deformAttachment = _this;
|
||||
return _this;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -6655,9 +6654,6 @@ var spine;
|
||||
}
|
||||
}
|
||||
};
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.prototype.copyTo = function (attachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array(this.bones.length);
|
||||
@ -6672,6 +6668,7 @@ var spine;
|
||||
else
|
||||
attachment.vertices = null;
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
@ -6736,7 +6733,6 @@ var spine;
|
||||
function MeshAttachment(name) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.color = new spine.Color(1, 1, 1, 1);
|
||||
_this.inheritDeform = false;
|
||||
_this.tempColor = new spine.Color(0, 0, 0, 0);
|
||||
return _this;
|
||||
}
|
||||
@ -6800,9 +6796,6 @@ var spine;
|
||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
};
|
||||
MeshAttachment.prototype.getParentMesh = function () {
|
||||
return this.parentMesh;
|
||||
};
|
||||
@ -6819,31 +6812,36 @@ var spine;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.copy = function () {
|
||||
var copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null)
|
||||
return this.newLinkedMesh();
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
}
|
||||
else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
copy.color.setFromColor(this.color);
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
return copy;
|
||||
};
|
||||
MeshAttachment.prototype.newLinkedMesh = function () {
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
};
|
||||
return MeshAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
5
spine-ts/build/spine-webgl.d.ts
vendored
5
spine-ts/build/spine-webgl.d.ts
vendored
@ -1103,9 +1103,9 @@ declare module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
deformAttachment: VertexAttachment;
|
||||
constructor(name: string);
|
||||
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
copyTo(attachment: VertexAttachment): void;
|
||||
}
|
||||
}
|
||||
@ -1157,14 +1157,13 @@ declare module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh;
|
||||
inheritDeform: boolean;
|
||||
tempColor: Color;
|
||||
constructor(name: string);
|
||||
updateUVs(): void;
|
||||
applyDeform(sourceAttachment: VertexAttachment): boolean;
|
||||
getParentMesh(): MeshAttachment;
|
||||
setParentMesh(parentMesh: MeshAttachment): void;
|
||||
copy(): Attachment;
|
||||
newLinkedMesh(): MeshAttachment;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -698,7 +698,7 @@ var spine;
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
|
||||
return;
|
||||
var deformArray = slot.deform;
|
||||
if (deformArray.length == 0)
|
||||
@ -4694,6 +4694,7 @@ var spine;
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -4769,8 +4770,7 @@ var spine;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5236,11 +5236,12 @@ var spine;
|
||||
}());
|
||||
spine.SkeletonJson = SkeletonJson;
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent) {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
@ -5334,18 +5335,15 @@ var spine;
|
||||
var attachments = skin.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
attachments = this.getAttachments();
|
||||
for (var i = 0; i < attachments.length; i++) {
|
||||
var attachment_1 = attachments[i];
|
||||
if (attachment_1.attachment instanceof spine.MeshAttachment) {
|
||||
var mesh = attachment_1.attachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment_1.slotIndex, mesh.getParentMesh().name));
|
||||
mesh.updateUVs();
|
||||
}
|
||||
if (attachment.attachment == null)
|
||||
continue;
|
||||
if (attachment.attachment instanceof spine.MeshAttachment) {
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6594,6 +6592,7 @@ var spine;
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
_this.worldVerticesLength = 0;
|
||||
_this.deformAttachment = _this;
|
||||
return _this;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -6655,9 +6654,6 @@ var spine;
|
||||
}
|
||||
}
|
||||
};
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.prototype.copyTo = function (attachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array(this.bones.length);
|
||||
@ -6672,6 +6668,7 @@ var spine;
|
||||
else
|
||||
attachment.vertices = null;
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
@ -6736,7 +6733,6 @@ var spine;
|
||||
function MeshAttachment(name) {
|
||||
var _this = _super.call(this, name) || this;
|
||||
_this.color = new spine.Color(1, 1, 1, 1);
|
||||
_this.inheritDeform = false;
|
||||
_this.tempColor = new spine.Color(0, 0, 0, 0);
|
||||
return _this;
|
||||
}
|
||||
@ -6800,9 +6796,6 @@ var spine;
|
||||
uvs[i + 1] = v + regionUVs[i + 1] * height;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
};
|
||||
MeshAttachment.prototype.getParentMesh = function () {
|
||||
return this.parentMesh;
|
||||
};
|
||||
@ -6819,31 +6812,36 @@ var spine;
|
||||
}
|
||||
};
|
||||
MeshAttachment.prototype.copy = function () {
|
||||
var copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null)
|
||||
return this.newLinkedMesh();
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
}
|
||||
else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
copy.color.setFromColor(this.color);
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array(this.regionUVs.length);
|
||||
spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array(this.uvs.length);
|
||||
spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array(this.triangles.length);
|
||||
spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array(this.edges.length);
|
||||
spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
return copy;
|
||||
};
|
||||
MeshAttachment.prototype.newLinkedMesh = function () {
|
||||
var copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
};
|
||||
return MeshAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -755,7 +755,7 @@ module spine {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {
|
||||
let slot: Slot = skeleton.slots[this.slotIndex];
|
||||
let slotAttachment: Attachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof VertexAttachment) || !(<VertexAttachment>slotAttachment).applyDeform(this.attachment)) return;
|
||||
if (!(slotAttachment instanceof VertexAttachment) || !((<VertexAttachment>slotAttachment).deformAttachment == this.attachment)) return;
|
||||
|
||||
let deformArray: Array<number> = slot.deform;
|
||||
if (deformArray.length == 0) blend = MixBlend.setup;
|
||||
|
||||
@ -229,6 +229,7 @@ module spine {
|
||||
if (skin == null) throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent == null) throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? <VertexAttachment>parent : <VertexAttachment>linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(<MeshAttachment> parent);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -311,8 +312,7 @@ module spine {
|
||||
|
||||
let parent: string = this.getValue(map, "parent", null);
|
||||
if (parent != null) {
|
||||
mesh.inheritDeform = this.getValue(map, "deform", true);
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, <string> this.getValue(map, "skin", null), slotIndex, parent));
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, <string> this.getValue(map, "skin", null), slotIndex, parent, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
|
||||
@ -794,12 +794,14 @@ module spine {
|
||||
parent: string; skin: string;
|
||||
slotIndex: number;
|
||||
mesh: MeshAttachment;
|
||||
inheritDeform: boolean;
|
||||
|
||||
constructor (mesh: MeshAttachment, skin: string, slotIndex: number, parent: string) {
|
||||
constructor (mesh: MeshAttachment, skin: string, slotIndex: number, parent: string, inheritDeform: boolean) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,19 +111,13 @@ module spine {
|
||||
let attachments = skin.getAttachments();
|
||||
for (let i = 0; i < attachments.length; i++) {
|
||||
var attachment = attachments[i];
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
|
||||
attachments = this.getAttachments();
|
||||
for (let i = 0; i < attachments.length; i++) {
|
||||
let attachment = attachments[i];
|
||||
if (attachment.attachment == null) continue;
|
||||
if (attachment.attachment instanceof MeshAttachment) {
|
||||
let mesh = attachment.attachment as MeshAttachment;
|
||||
if (mesh.getParentMesh()) {
|
||||
mesh.setParentMesh(this.getAttachment(attachment.slotIndex, mesh.getParentMesh().name) as MeshAttachment);
|
||||
mesh.updateUVs();
|
||||
}
|
||||
attachment.attachment = attachment.attachment.newLinkedMesh();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
} else {
|
||||
attachment.attachment = attachment.attachment.copy();
|
||||
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ module spine {
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength = 0;
|
||||
deformAttachment: VertexAttachment = this;
|
||||
|
||||
constructor (name: string) {
|
||||
super(name);
|
||||
@ -114,11 +115,6 @@ module spine {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns true if a deform originally applied to the specified attachment should be applied to this attachment. */
|
||||
applyDeform (sourceAttachment: VertexAttachment) {
|
||||
return this == sourceAttachment;
|
||||
}
|
||||
|
||||
copyTo (attachment: VertexAttachment) {
|
||||
if (this.bones != null) {
|
||||
attachment.bones = new Array<number>(this.bones.length);
|
||||
@ -133,6 +129,7 @@ module spine {
|
||||
attachment.vertices = null;
|
||||
|
||||
attachment.worldVerticesLength = this.worldVerticesLength;
|
||||
attachment.deformAttachment = this.deformAttachment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,6 @@ module spine {
|
||||
hullLength: number;
|
||||
edges: Array<number>;
|
||||
private parentMesh: MeshAttachment;
|
||||
inheritDeform = false;
|
||||
tempColor = new Color(0, 0, 0, 0);
|
||||
|
||||
constructor (name: string) {
|
||||
@ -105,10 +104,6 @@ module spine {
|
||||
}
|
||||
}
|
||||
|
||||
applyDeform (sourceAttachment: VertexAttachment): boolean {
|
||||
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
|
||||
}
|
||||
|
||||
getParentMesh () {
|
||||
return this.parentMesh;
|
||||
}
|
||||
@ -128,37 +123,43 @@ module spine {
|
||||
}
|
||||
|
||||
copy (): Attachment {
|
||||
let copy = new MeshAttachment(name);
|
||||
if (this.parentMesh != null) return this.newLinkedMesh();
|
||||
|
||||
let copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
|
||||
if (this.parentMesh == null) {
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array<number>(this.regionUVs.length);
|
||||
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array<number>(this.uvs.length);
|
||||
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array<number>(this.triangles.length);
|
||||
Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.hullLength = this.hullLength;
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = new Array<number>(this.regionUVs.length);
|
||||
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
|
||||
copy.uvs = new Array<number>(this.uvs.length);
|
||||
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
|
||||
copy.triangles = new Array<number>(this.triangles.length);
|
||||
Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
|
||||
copy.hullLength = this.hullLength;
|
||||
|
||||
copy.inheritDeform = this.inheritDeform;
|
||||
|
||||
// Nonessential.
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array<number>(this.edges.length);
|
||||
Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
} else {
|
||||
copy.setParentMesh(this.parentMesh);
|
||||
copy.updateUVs();
|
||||
// Nonessential.
|
||||
if (this.edges != null) {
|
||||
copy.edges = new Array<number>(this.edges.length);
|
||||
Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
|
||||
}
|
||||
copy.width = this.width;
|
||||
copy.height = this.height;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
newLinkedMesh (): MeshAttachment {
|
||||
let copy = new MeshAttachment(this.name);
|
||||
copy.region = this.region;
|
||||
copy.path = this.path;
|
||||
copy.color.setFromColor(this.color);
|
||||
copy.deformAttachment = this.deformAttachment;
|
||||
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
|
||||
copy.updateUVs();
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
108
spine-ts/webgl/tests/test-skins.html
Normal file
108
spine-ts/webgl/tests/test-skins.html
Normal file
@ -0,0 +1,108 @@
|
||||
<html>
|
||||
<script src="../../build/spine-webgl.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; }
|
||||
body, html { height: 100% }
|
||||
canvas { position: absolute; width: 100% ;height: 100%; }
|
||||
</style>
|
||||
<body>
|
||||
<div id="label" style="position: absolute; top: 0; left: 0; color: #fff; z-index: 10"></div>
|
||||
<canvas id="canvas" style="background: red;"></canvas>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
var FILE = "goblins-pro";
|
||||
var ANIMATION = "walk";
|
||||
var SCALE = 0.5;
|
||||
|
||||
var canvas, context, gl, renderer, input, assetManager;
|
||||
var skeletons = [];
|
||||
var timeKeeper;
|
||||
var label = document.getElementById("label");
|
||||
var updateMean = new spine.WindowedMean();
|
||||
var renderMean = new spine.WindowedMean();
|
||||
|
||||
function init() {
|
||||
canvas = document.getElementById("canvas");
|
||||
canvas.width = canvas.clientWidth; canvas.height = canvas.clientHeight;
|
||||
context = new spine.webgl.ManagedWebGLRenderingContext(canvas, { alpha: false });
|
||||
gl = context.gl;
|
||||
|
||||
renderer = new spine.webgl.SceneRenderer(canvas, context);
|
||||
assetManager = new spine.webgl.AssetManager(context, "../example/assets/");
|
||||
input = new spine.webgl.Input(canvas);
|
||||
|
||||
assetManager.loadTextureAtlas(FILE.replace("-pro", "").replace("-ess", "") + "-pma.atlas");
|
||||
assetManager.loadText(FILE + ".json");
|
||||
|
||||
timeKeeper = new spine.TimeKeeper();
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
|
||||
var run = true;
|
||||
|
||||
function load() {
|
||||
timeKeeper.update();
|
||||
if (assetManager.isLoadingComplete()) {
|
||||
var atlas = assetManager.get(FILE.replace("-pro", "").replace("-ess", "") + "-pma.atlas");
|
||||
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||
skeletonJson.scale = SCALE;
|
||||
var skeletonData = skeletonJson.readSkeletonData(JSON.parse(assetManager.get(FILE + ".json")));
|
||||
|
||||
skeleton = new spine.Skeleton(skeletonData);
|
||||
var stateData = new spine.AnimationStateData(skeleton.data);
|
||||
state = new spine.AnimationState(stateData);
|
||||
stateData.defaultMix = 0;
|
||||
|
||||
var originalSkin = skeleton.data.findSkin("goblingirl");
|
||||
var copy = new spine.Skin("test");
|
||||
copy.copySkin(originalSkin);
|
||||
skeleton.setSkin(copy);
|
||||
skeleton.setSlotsToSetupPose();
|
||||
|
||||
state.setAnimation(0, ANIMATION, true);
|
||||
skeletons.push({ skeleton: skeleton, state: state });
|
||||
|
||||
requestAnimationFrame(render);
|
||||
} else {
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
var start = Date.now()
|
||||
timeKeeper.update();
|
||||
var delta = timeKeeper.delta;
|
||||
|
||||
for (var i = 0; i < skeletons.length; i++) {
|
||||
var state = skeletons[i].state;
|
||||
var skeleton = skeletons[i].skeleton;
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.updateWorldTransform();
|
||||
}
|
||||
updateMean.addValue(Date.now() - start);
|
||||
start = Date.now();
|
||||
|
||||
gl.clearColor(0.2, 0.2, 0.2, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
renderer.resize(spine.webgl.ResizeMode.Fit);
|
||||
renderer.begin();
|
||||
for (var i = 0; i < skeletons.length; i++) {
|
||||
var skeleton = skeletons[i].skeleton;
|
||||
renderer.drawSkeleton(skeleton, true);
|
||||
}
|
||||
renderer.end();
|
||||
|
||||
requestAnimationFrame(render)
|
||||
renderMean.addValue(Date.now() - start);
|
||||
label.innerHTML = ("Update time: " + Number(updateMean.getMean()).toFixed(2) + " ms\n" +
|
||||
"Render time: " + Number(renderMean.getMean()).toFixed(2) + " ms\n");
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user