@pixi-spine/runtime-3.8
Version:
Pixi runtime for spine 3.8 models
61 lines (58 loc) • 2.07 kB
JavaScript
import { VertexAttachment } from './Attachment.mjs';
import { AttachmentType, Color, Utils } from '@pixi-spine/base';
class MeshAttachment extends VertexAttachment {
constructor(name) {
super(name);
this.type = AttachmentType.Mesh;
this.color = new Color(1, 1, 1, 1);
this.tempColor = new Color(0, 0, 0, 0);
}
getParentMesh() {
return this.parentMesh;
}
/** @param parentMesh May be null. */
setParentMesh(parentMesh) {
this.parentMesh = parentMesh;
if (parentMesh != null) {
this.bones = parentMesh.bones;
this.vertices = parentMesh.vertices;
this.worldVerticesLength = parentMesh.worldVerticesLength;
this.regionUVs = parentMesh.regionUVs;
this.triangles = parentMesh.triangles;
this.hullLength = parentMesh.hullLength;
this.worldVerticesLength = parentMesh.worldVerticesLength;
}
}
copy() {
if (this.parentMesh != null)
return this.newLinkedMesh();
const copy = new MeshAttachment(this.name);
copy.region = this.region;
copy.path = this.path;
copy.color.setFromColor(this.color);
this.copyTo(copy);
copy.regionUVs = new Float32Array(this.regionUVs.length);
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
copy.triangles = new Array(this.triangles.length);
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);
Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
}
copy.width = this.width;
copy.height = this.height;
return copy;
}
newLinkedMesh() {
const 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);
return copy;
}
}
export { MeshAttachment };
//# sourceMappingURL=MeshAttachment.mjs.map