diff --git a/examples/export/runtimes.sh b/examples/export/runtimes.sh index 54b4c283b..4e3a1ff60 100755 --- a/examples/export/runtimes.sh +++ b/examples/export/runtimes.sh @@ -197,7 +197,7 @@ cp -f ../goblins/export/goblins-pma.png "$ROOT/spine-ts/spine-webgl/example/asse cp -f ../dragon/export/dragon-ess.json "$ROOT/spine-ts/spine-webgl/example/assets/" cp -f ../dragon/export/dragon-ess.skel "$ROOT/spine-ts/spine-webgl/example/assets/" cp -f ../dragon/export/dragon-pma.atlas "$ROOT/spine-ts/spine-webgl/example/assets/" -cp -f ../dragon/export/dragon-pma.png "$ROOT/spine-ts/spine-webgl/example/assets/" +cp -f ../dragon/export/dragon-pma*.png "$ROOT/spine-ts/spine-webgl/example/assets/" cp -f ../raptor/export/raptor-pro.json "$ROOT/spine-ts/spine-webgl/example/assets/" cp -f ../raptor/export/raptor-pro.skel "$ROOT/spine-ts/spine-webgl/example/assets/" diff --git a/spine-ts/.vscode/launch.json b/spine-ts/.vscode/launch.json index 109a37100..0b179766a 100644 --- a/spine-ts/.vscode/launch.json +++ b/spine-ts/.vscode/launch.json @@ -17,6 +17,13 @@ "name": "drag-and-drop", "url": "http://localhost:8080/spine-webgl/example/drag-and-drop.html", "webRoot": "${workspaceFolder}" + }, + { + "type": "pwa-chrome", + "request": "launch", + "name": "barebones-dragon", + "url": "http://localhost:8080/spine-webgl/example/barebones-dragon.html", + "webRoot": "${workspaceFolder}" } ] } \ No newline at end of file diff --git a/spine-ts/spine-core/src/Animation.ts b/spine-ts/spine-core/src/Animation.ts index 601c4b869..99f0e9b19 100644 --- a/spine-ts/spine-core/src/Animation.ts +++ b/spine-ts/spine-core/src/Animation.ts @@ -2210,7 +2210,7 @@ export class SequenceTimeline extends Timeline implements SlotTimeline { let index = modeAndIndex >> 4, count = this.attachment.sequence.regions.length; let mode = SequenceModeValues[modeAndIndex & 0xf]; if (mode != SequenceMode.hold) { - index += (time - before) / delay + 0.00001; + index += (((time - before) / delay + 0.00001) | 0); switch (mode) { case SequenceMode.once: index = Math.min(count - 1, index); diff --git a/spine-ts/spine-core/src/SkeletonBinary.ts b/spine-ts/spine-core/src/SkeletonBinary.ts index 4a575f672..804dfe702 100644 --- a/spine-ts/spine-core/src/SkeletonBinary.ts +++ b/spine-ts/spine-core/src/SkeletonBinary.ts @@ -59,11 +59,11 @@ export class SkeletonBinary { attachmentLoader: AttachmentLoader; private linkedMeshes = new Array(); - constructor(attachmentLoader: AttachmentLoader) { + constructor (attachmentLoader: AttachmentLoader) { this.attachmentLoader = attachmentLoader; } - readSkeletonData(binary: Uint8Array): SkeletonData { + readSkeletonData (binary: Uint8Array): SkeletonData { let scale = this.scale; let skeletonData = new SkeletonData(); @@ -249,7 +249,7 @@ export class SkeletonBinary { return skeletonData; } - private readSkin(input: BinaryInput, skeletonData: SkeletonData, defaultSkin: boolean, nonessential: boolean): Skin { + private readSkin (input: BinaryInput, skeletonData: SkeletonData, defaultSkin: boolean, nonessential: boolean): Skin { let skin = null; let slotCount = 0; @@ -284,7 +284,7 @@ export class SkeletonBinary { return skin; } - private readAttachment(input: BinaryInput, skeletonData: SkeletonData, skin: Skin, slotIndex: number, attachmentName: string, nonessential: boolean): Attachment { + private readAttachment (input: BinaryInput, skeletonData: SkeletonData, skin: Skin, slotIndex: number, attachmentName: string, nonessential: boolean): Attachment { let scale = this.scale; let name = input.readStringRef(); @@ -449,7 +449,7 @@ export class SkeletonBinary { return null; } - private readSequence(input: BinaryInput) { + private readSequence (input: BinaryInput) { if (!input.readBoolean()) return null; let sequence = new Sequence(input.readInt(true)); sequence.start = input.readInt(true); @@ -458,7 +458,7 @@ export class SkeletonBinary { return sequence; } - private readVertices(input: BinaryInput, vertexCount: number): Vertices { + private readVertices (input: BinaryInput, vertexCount: number): Vertices { let scale = this.scale; let verticesLength = vertexCount << 1; let vertices = new Vertices(); @@ -483,7 +483,7 @@ export class SkeletonBinary { return vertices; } - private readFloatArray(input: BinaryInput, n: number, scale: number): number[] { + private readFloatArray (input: BinaryInput, n: number, scale: number): number[] { let array = new Array(n); if (scale == 1) { for (let i = 0; i < n; i++) @@ -495,7 +495,7 @@ export class SkeletonBinary { return array; } - private readShortArray(input: BinaryInput): number[] { + private readShortArray (input: BinaryInput): number[] { let n = input.readInt(true); let array = new Array(n); for (let i = 0; i < n; i++) @@ -503,7 +503,7 @@ export class SkeletonBinary { return array; } - private readAnimation(input: BinaryInput, name: string, skeletonData: SkeletonData): Animation { + private readAnimation (input: BinaryInput, name: string, skeletonData: SkeletonData): Animation { input.readInt(true); // Number of timelines. let timelines = new Array(); let scale = this.scale; @@ -996,30 +996,30 @@ export class SkeletonBinary { } export class BinaryInput { - constructor(data: Uint8Array, public strings = new Array(), private index: number = 0, private buffer = new DataView(data.buffer)) { + constructor (data: Uint8Array, public strings = new Array(), private index: number = 0, private buffer = new DataView(data.buffer)) { } - readByte(): number { + readByte (): number { return this.buffer.getInt8(this.index++); } - readUnsignedByte(): number { + readUnsignedByte (): number { return this.buffer.getUint8(this.index++); } - readShort(): number { + readShort (): number { let value = this.buffer.getInt16(this.index); this.index += 2; return value; } - readInt32(): number { + readInt32 (): number { let value = this.buffer.getInt32(this.index) this.index += 4; return value; } - readInt(optimizePositive: boolean) { + readInt (optimizePositive: boolean) { let b = this.readByte(); let result = b & 0x7F; if ((b & 0x80) != 0) { @@ -1041,12 +1041,12 @@ export class BinaryInput { return optimizePositive ? result : ((result >>> 1) ^ -(result & 1)); } - readStringRef(): string { + readStringRef (): string { let index = this.readInt(true); return index == 0 ? null : this.strings[index - 1]; } - readString(): string { + readString (): string { let byteCount = this.readInt(true); switch (byteCount) { case 0: @@ -1077,13 +1077,13 @@ export class BinaryInput { return chars; } - readFloat(): number { + readFloat (): number { let value = this.buffer.getFloat32(this.index); this.index += 4; return value; } - readBoolean(): boolean { + readBoolean (): boolean { return this.readByte() != 0; } } @@ -1094,7 +1094,7 @@ class LinkedMesh { mesh: MeshAttachment; inheritTimeline: boolean; - constructor(mesh: MeshAttachment, skin: string, slotIndex: number, parent: string, inheritDeform: boolean) { + constructor (mesh: MeshAttachment, skin: string, slotIndex: number, parent: string, inheritDeform: boolean) { this.mesh = mesh; this.skin = skin; this.slotIndex = slotIndex; @@ -1104,12 +1104,12 @@ class LinkedMesh { } class Vertices { - constructor(public bones: Array = null, public vertices: Array | Float32Array = null) { } + constructor (public bones: Array = null, public vertices: Array | Float32Array = null) { } } enum AttachmentType { Region, BoundingBox, Mesh, LinkedMesh, Path, Point, Clipping } -function readTimeline1(input: BinaryInput, timeline: CurveTimeline1, scale: number): CurveTimeline1 { +function readTimeline1 (input: BinaryInput, timeline: CurveTimeline1, scale: number): CurveTimeline1 { let time = input.readFloat(), value = input.readFloat() * scale; for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1; ; frame++) { timeline.setFrame(frame, time, value); @@ -1128,7 +1128,7 @@ function readTimeline1(input: BinaryInput, timeline: CurveTimeline1, scale: numb return timeline; } -function readTimeline2(input: BinaryInput, timeline: CurveTimeline2, scale: number): CurveTimeline2 { +function readTimeline2 (input: BinaryInput, timeline: CurveTimeline2, scale: number): CurveTimeline2 { let time = input.readFloat(), value1 = input.readFloat() * scale, value2 = input.readFloat() * scale; for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1; ; frame++) { timeline.setFrame(frame, time, value1, value2); @@ -1149,7 +1149,7 @@ function readTimeline2(input: BinaryInput, timeline: CurveTimeline2, scale: numb return timeline; } -function setBezier(input: BinaryInput, timeline: CurveTimeline, bezier: number, frame: number, value: number, +function setBezier (input: BinaryInput, timeline: CurveTimeline, bezier: number, frame: number, value: number, time1: number, time2: number, value1: number, value2: number, scale: number) { timeline.setBezier(bezier, frame, value, time1, value1, input.readFloat(), input.readFloat() * scale, input.readFloat(), input.readFloat() * scale, time2, value2); } diff --git a/spine-ts/spine-core/src/attachments/HasTextureRegion.ts b/spine-ts/spine-core/src/attachments/HasTextureRegion.ts index b8ca7d42a..a308a9020 100644 --- a/spine-ts/spine-core/src/attachments/HasTextureRegion.ts +++ b/spine-ts/spine-core/src/attachments/HasTextureRegion.ts @@ -32,19 +32,25 @@ import { Color } from "../Utils" import { Sequence } from "./Sequence" export interface HasTextureRegion { - /** The name used to find the {@link #region()}. */ - path: string; + /** The name used to find the {@link #getRegion()}. */ + getPath (): string; - /** The region used to draw the attachment. After setting the region or if the region's properties are changed, + setPath (path: string): void; + + getRegion (): TextureRegion; + + /** Sets the region used to draw the attachment. After setting the region or if the region's properties are changed, * {@link #updateRegion()} must be called. */ - region: TextureRegion; + setRegion (region: TextureRegion): void; /** Updates any values the attachment calculates using the {@link #getRegion()}. Must be called after setting the * {@link #getRegion()} or if the region's properties are changed. */ updateRegion (): void; /** The color to tint the attachment. */ - color: Color; + getColor (): Color; - sequence: Sequence; + getSequence (): Sequence; + + setSequence (sequence: Sequence): void; } \ No newline at end of file diff --git a/spine-ts/spine-core/src/attachments/RegionAttachment.ts b/spine-ts/spine-core/src/attachments/RegionAttachment.ts index a447a30db..70d9598a1 100644 --- a/spine-ts/spine-core/src/attachments/RegionAttachment.ts +++ b/spine-ts/spine-core/src/attachments/RegionAttachment.ts @@ -145,7 +145,8 @@ export class RegionAttachment extends Attachment implements HasTextureRegion { * @param offset The worldVertices index to begin writing values. * @param stride The number of worldVertices entries between the value pairs written. */ computeWorldVertices (slot: Slot, worldVertices: NumberArrayLike, offset: number, stride: number) { - if (this.sequence != null) this.sequence.apply(slot, this); + if (this.sequence != null) + this.sequence.apply(slot, this); let bone = slot.bone; let vertexOffset = this.offset; diff --git a/spine-ts/spine-webgl/example/assets/dragon-pma_2.png b/spine-ts/spine-webgl/example/assets/dragon-pma_2.png new file mode 100644 index 000000000..084bc5e93 Binary files /dev/null and b/spine-ts/spine-webgl/example/assets/dragon-pma_2.png differ diff --git a/spine-ts/spine-webgl/example/assets/dragon-pma_3.png b/spine-ts/spine-webgl/example/assets/dragon-pma_3.png new file mode 100644 index 000000000..17276d4e6 Binary files /dev/null and b/spine-ts/spine-webgl/example/assets/dragon-pma_3.png differ diff --git a/spine-ts/spine-webgl/example/assets/dragon-pma_4.png b/spine-ts/spine-webgl/example/assets/dragon-pma_4.png new file mode 100644 index 000000000..f0b9d721b Binary files /dev/null and b/spine-ts/spine-webgl/example/assets/dragon-pma_4.png differ diff --git a/spine-ts/spine-webgl/example/assets/dragon-pma_5.png b/spine-ts/spine-webgl/example/assets/dragon-pma_5.png new file mode 100644 index 000000000..f98942cba Binary files /dev/null and b/spine-ts/spine-webgl/example/assets/dragon-pma_5.png differ diff --git a/spine-ts/spine-webgl/example/assets/dragon-pma_6.png b/spine-ts/spine-webgl/example/assets/dragon-pma_6.png new file mode 100644 index 000000000..ebbfe9285 Binary files /dev/null and b/spine-ts/spine-webgl/example/assets/dragon-pma_6.png differ diff --git a/spine-ts/spine-webgl/example/barebones-dragon.html b/spine-ts/spine-webgl/example/barebones-dragon.html new file mode 100644 index 000000000..be0f7111a --- /dev/null +++ b/spine-ts/spine-webgl/example/barebones-dragon.html @@ -0,0 +1,81 @@ + + + + + + + + + + \ No newline at end of file