diff --git a/formatters/README.md b/formatters/README.md index fbe877933..3f00aced9 100644 --- a/formatters/README.md +++ b/formatters/README.md @@ -4,7 +4,7 @@ This folder contains formatter configuration files to be used with IDEs as well You will need the following on your `PATH`: - JDK 10+ -- clang-format 12 (i.e. `brew install clang-format`) +- clang-format 12 (i.e. `brew install clang-format`). Also set the environment variable `CLANGFORMAT` to the path of the `clang-format` executable. - dotnet format (i.e. `dotnet tool install -g dotnet-format`, comes with dotnet 6 out of the box) - tsfmt, (i.e. `npm install -g typescript-formatter`) diff --git a/spine-ts/spine-canvas/src/AssetManager.ts b/spine-ts/spine-canvas/src/AssetManager.ts index e8bd5de31..da652a55a 100644 --- a/spine-ts/spine-canvas/src/AssetManager.ts +++ b/spine-ts/spine-canvas/src/AssetManager.ts @@ -31,7 +31,7 @@ import { AssetManagerBase, Downloader } from "@esotericsoftware/spine-core" import { CanvasTexture } from "./CanvasTexture"; export class AssetManager extends AssetManagerBase { - constructor(pathPrefix: string = "", downloader: Downloader = null) { + constructor (pathPrefix: string = "", downloader: Downloader = null) { super((image: HTMLImageElement) => { return new CanvasTexture(image); }, pathPrefix, downloader); } } diff --git a/spine-ts/spine-canvas/src/CanvasTexture.ts b/spine-ts/spine-canvas/src/CanvasTexture.ts index e60112e71..aaf0b0019 100644 --- a/spine-ts/spine-canvas/src/CanvasTexture.ts +++ b/spine-ts/spine-canvas/src/CanvasTexture.ts @@ -30,11 +30,11 @@ import { Texture, TextureFilter, TextureWrap } from "@esotericsoftware/spine-core"; export class CanvasTexture extends Texture { - constructor(image: HTMLImageElement) { + constructor (image: HTMLImageElement) { super(image); } - setFilters(minFilter: TextureFilter, magFilter: TextureFilter) { } - setWraps(uWrap: TextureWrap, vWrap: TextureWrap) { } - dispose() { } + setFilters (minFilter: TextureFilter, magFilter: TextureFilter) { } + setWraps (uWrap: TextureWrap, vWrap: TextureWrap) { } + dispose () { } } diff --git a/spine-ts/spine-canvas/src/SkeletonRenderer.ts b/spine-ts/spine-canvas/src/SkeletonRenderer.ts index 986902d11..9cc2b72e2 100644 --- a/spine-ts/spine-canvas/src/SkeletonRenderer.ts +++ b/spine-ts/spine-canvas/src/SkeletonRenderer.ts @@ -41,16 +41,16 @@ export class SkeletonRenderer { private vertices = Utils.newFloatArray(8 * 1024); private tempColor = new Color(); - constructor(context: CanvasRenderingContext2D) { + constructor (context: CanvasRenderingContext2D) { this.ctx = context; } - draw(skeleton: Skeleton) { + draw (skeleton: Skeleton) { if (this.triangleRendering) this.drawTriangles(skeleton); else this.drawImages(skeleton); } - private drawImages(skeleton: Skeleton) { + private drawImages (skeleton: Skeleton) { let ctx = this.ctx; let color = this.tempColor; let skeletonColor = skeleton.color; @@ -107,7 +107,7 @@ export class SkeletonRenderer { } } - private drawTriangles(skeleton: Skeleton) { + private drawTriangles (skeleton: Skeleton) { let ctx = this.ctx; let color = this.tempColor; let skeletonColor = skeleton.color; @@ -182,7 +182,7 @@ export class SkeletonRenderer { // Adapted from http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 // Apache 2 licensed - private drawTriangle(img: HTMLImageElement, x0: number, y0: number, u0: number, v0: number, + private drawTriangle (img: HTMLImageElement, x0: number, y0: number, u0: number, v0: number, x1: number, y1: number, u1: number, v1: number, x2: number, y2: number, u2: number, v2: number) { let ctx = this.ctx; @@ -229,7 +229,7 @@ export class SkeletonRenderer { ctx.restore(); } - private computeRegionVertices(slot: Slot, region: RegionAttachment, pma: boolean) { + private computeRegionVertices (slot: Slot, region: RegionAttachment, pma: boolean) { let skeletonColor = slot.bone.skeleton.color; let slotColor = slot.color; let regionColor = region.color; @@ -277,7 +277,7 @@ export class SkeletonRenderer { return vertices; } - private computeMeshVertices(slot: Slot, mesh: MeshAttachment, pma: boolean) { + private computeMeshVertices (slot: Slot, mesh: MeshAttachment, pma: boolean) { let skeletonColor = slot.bone.skeleton.color; let slotColor = slot.color; let regionColor = mesh.color; diff --git a/spine-ts/spine-core/src/Animation.ts b/spine-ts/spine-core/src/Animation.ts index 30eec2743..0ff5d7a68 100644 --- a/spine-ts/spine-core/src/Animation.ts +++ b/spine-ts/spine-core/src/Animation.ts @@ -46,14 +46,14 @@ export class Animation { /** The duration of the animation in seconds, which is the highest time of all keys in the timeline. */ duration: number; - constructor(name: string, timelines: Array, duration: number) { + constructor (name: string, timelines: Array, duration: number) { if (!name) throw new Error("name cannot be null."); this.name = name; this.setTimelines(timelines); this.duration = duration; } - setTimelines(timelines: Array) { + setTimelines (timelines: Array) { if (!timelines) throw new Error("timelines cannot be null."); this.timelines = timelines; this.timelineIds = new StringSet(); @@ -61,7 +61,7 @@ export class Animation { this.timelineIds.addAll(timelines[i].getPropertyIds()); } - hasTimeline(ids: string[]): boolean { + hasTimeline (ids: string[]): boolean { for (let i = 0; i < ids.length; i++) if (this.timelineIds.contains(ids[i])) return true; return false; @@ -72,7 +72,7 @@ export class Animation { * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. * @param loop If true, the animation repeats after {@link #getDuration()}. * @param events May be null to ignore fired events. */ - apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { if (!skeleton) throw new Error("skeleton cannot be null."); if (loop && this.duration != 0) { @@ -154,37 +154,37 @@ export abstract class Timeline { propertyIds: string[]; frames: NumberArrayLike; - constructor(frameCount: number, propertyIds: string[]) { + constructor (frameCount: number, propertyIds: string[]) { this.propertyIds = propertyIds; this.frames = Utils.newFloatArray(frameCount * this.getFrameEntries()); } - getPropertyIds() { + getPropertyIds () { return this.propertyIds; } - getFrameEntries(): number { + getFrameEntries (): number { return 1; } - getFrameCount() { + getFrameCount () { return this.frames.length / this.getFrameEntries(); } - getDuration(): number { + getDuration (): number { return this.frames[this.frames.length - this.getFrameEntries()]; } - abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; + abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; - static search1(frames: NumberArrayLike, time: number) { + static search1 (frames: NumberArrayLike, time: number) { let n = frames.length; for (let i = 1; i < n; i++) if (frames[i] > time) return i - 1; return n - 1; } - static search(frames: NumberArrayLike, time: number, step: number) { + static search (frames: NumberArrayLike, time: number, step: number) { let n = frames.length; for (let i = step; i < n; i += step) if (frames[i] > time) return i - step; @@ -206,25 +206,25 @@ export interface SlotTimeline { export abstract class CurveTimeline extends Timeline { protected curves: NumberArrayLike; // type, x, y, ... - constructor(frameCount: number, bezierCount: number, propertyIds: string[]) { + constructor (frameCount: number, bezierCount: number, propertyIds: string[]) { super(frameCount, propertyIds); this.curves = Utils.newFloatArray(frameCount + bezierCount * 18/*BEZIER_SIZE*/); this.curves[frameCount - 1] = 1/*STEPPED*/; } /** Sets the specified key frame to linear interpolation. */ - setLinear(frame: number) { + setLinear (frame: number) { this.curves[frame] = 0/*LINEAR*/; } /** Sets the specified key frame to stepped interpolation. */ - setStepped(frame: number) { + setStepped (frame: number) { this.curves[frame] = 1/*STEPPED*/; } /** Shrinks the storage for Bezier curves, for use when bezierCount (specified in the constructor) was larger * than the actual number of Bezier curves. */ - shrink(bezierCount: number) { + shrink (bezierCount: number) { let size = this.getFrameCount() + bezierCount * 18/*BEZIER_SIZE*/; if (this.curves.length > size) { let newCurves = Utils.newFloatArray(size); @@ -247,7 +247,7 @@ export abstract class CurveTimeline extends Timeline { * @param cy2 The value for the second Bezier handle. * @param time2 The time for the second key. * @param value2 The value for the second key. */ - setBezier(bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number, + setBezier (bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number, cy2: number, time2: number, value2: number) { let curves = this.curves; let i = this.getFrameCount() + bezier * 18/*BEZIER_SIZE*/; @@ -273,7 +273,7 @@ export abstract class CurveTimeline extends Timeline { * @param frameIndex The index into {@link #getFrames()} for the values of the frame before time. * @param valueOffset The offset from frameIndex to the value this curve is used for. * @param i The index of the Bezier segments. See {@link #getCurveType(int)}. */ - getBezierValue(time: number, frameIndex: number, valueOffset: number, i: number) { + getBezierValue (time: number, frameIndex: number, valueOffset: number, i: number) { let curves = this.curves; if (curves[i] > time) { let x = this.frames[frameIndex], y = this.frames[frameIndex + valueOffset]; @@ -293,25 +293,25 @@ export abstract class CurveTimeline extends Timeline { } export abstract class CurveTimeline1 extends CurveTimeline { - constructor(frameCount: number, bezierCount: number, propertyId: string) { + constructor (frameCount: number, bezierCount: number, propertyId: string) { super(frameCount, bezierCount, [propertyId]); } - getFrameEntries() { + getFrameEntries () { return 2/*ENTRIES*/; } /** Sets the time and value for the specified frame. * @param frame Between 0 and frameCount, inclusive. * @param time The frame time in seconds. */ - setFrame(frame: number, time: number, value: number) { + setFrame (frame: number, time: number, value: number) { frame <<= 1; this.frames[frame] = time; this.frames[frame + 1/*VALUE*/] = value; } /** Returns the interpolated value for the specified time. */ - getCurveValue(time: number) { + getCurveValue (time: number) { let frames = this.frames; let i = frames.length - 2; for (let ii = 2; ii <= i; ii += 2) { @@ -337,18 +337,18 @@ export abstract class CurveTimeline1 extends CurveTimeline { export abstract class CurveTimeline2 extends CurveTimeline { /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}. * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - constructor(frameCount: number, bezierCount: number, propertyId1: string, propertyId2: string) { + constructor (frameCount: number, bezierCount: number, propertyId1: string, propertyId2: string) { super(frameCount, bezierCount, [propertyId1, propertyId2]); } - getFrameEntries() { + getFrameEntries () { return 3/*ENTRIES*/; } /** Sets the time and values for the specified frame. * @param frame Between 0 and frameCount, inclusive. * @param time The frame time in seconds. */ - setFrame(frame: number, time: number, value1: number, value2: number) { + setFrame (frame: number, time: number, value1: number, value2: number) { frame *= 3/*ENTRIES*/; this.frames[frame] = time; this.frames[frame + 1/*VALUE1*/] = value1; @@ -360,12 +360,12 @@ export abstract class CurveTimeline2 extends CurveTimeline { export class RotateTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.rotate + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -399,7 +399,7 @@ export class RotateTimeline extends CurveTimeline1 implements BoneTimeline { export class TranslateTimeline extends CurveTimeline2 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.x + "|" + boneIndex, Property.y + "|" + boneIndex, @@ -407,7 +407,7 @@ export class TranslateTimeline extends CurveTimeline2 implements BoneTimeline { this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -467,12 +467,12 @@ export class TranslateTimeline extends CurveTimeline2 implements BoneTimeline { export class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.x + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -507,12 +507,12 @@ export class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline { export class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.y + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -547,7 +547,7 @@ export class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline { export class ScaleTimeline extends CurveTimeline2 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex @@ -555,7 +555,7 @@ export class ScaleTimeline extends CurveTimeline2 implements BoneTimeline { this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -657,12 +657,12 @@ export class ScaleTimeline extends CurveTimeline2 implements BoneTimeline { export class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.scaleX + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -726,12 +726,12 @@ export class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline { export class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.scaleY + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -795,7 +795,7 @@ export class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline { export class ShearTimeline extends CurveTimeline2 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex @@ -803,7 +803,7 @@ export class ShearTimeline extends CurveTimeline2 implements BoneTimeline { this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -863,12 +863,12 @@ export class ShearTimeline extends CurveTimeline2 implements BoneTimeline { export class ShearXTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.shearX + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -903,12 +903,12 @@ export class ShearXTimeline extends CurveTimeline1 implements BoneTimeline { export class ShearYTimeline extends CurveTimeline1 implements BoneTimeline { boneIndex = 0; - constructor(frameCount: number, bezierCount: number, boneIndex: number) { + constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, Property.shearY + "|" + boneIndex); this.boneIndex = boneIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let bone = skeleton.bones[this.boneIndex]; if (!bone.active) return; @@ -943,7 +943,7 @@ export class ShearYTimeline extends CurveTimeline1 implements BoneTimeline { export class RGBATimeline extends CurveTimeline implements SlotTimeline { slotIndex = 0; - constructor(frameCount: number, bezierCount: number, slotIndex: number) { + constructor (frameCount: number, bezierCount: number, slotIndex: number) { super(frameCount, bezierCount, [ Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex @@ -951,12 +951,12 @@ export class RGBATimeline extends CurveTimeline implements SlotTimeline { this.slotIndex = slotIndex; } - getFrameEntries() { + getFrameEntries () { return 5/*ENTRIES*/; } /** Sets the time in seconds, red, green, blue, and alpha for the specified key frame. */ - setFrame(frame: number, time: number, r: number, g: number, b: number, a: number) { + setFrame (frame: number, time: number, r: number, g: number, b: number, a: number) { frame *= 5/*ENTRIES*/; this.frames[frame] = time; this.frames[frame + 1/*R*/] = r; @@ -965,7 +965,7 @@ export class RGBATimeline extends CurveTimeline implements SlotTimeline { this.frames[frame + 4/*A*/] = a; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; @@ -1025,19 +1025,19 @@ export class RGBATimeline extends CurveTimeline implements SlotTimeline { export class RGBTimeline extends CurveTimeline implements SlotTimeline { slotIndex = 0; - constructor(frameCount: number, bezierCount: number, slotIndex: number) { + constructor (frameCount: number, bezierCount: number, slotIndex: number) { super(frameCount, bezierCount, [ Property.rgb + "|" + slotIndex ]); this.slotIndex = slotIndex; } - getFrameEntries() { + getFrameEntries () { return 4/*ENTRIES*/; } /** Sets the time in seconds, red, green, blue, and alpha for the specified key frame. */ - setFrame(frame: number, time: number, r: number, g: number, b: number) { + setFrame (frame: number, time: number, r: number, g: number, b: number) { frame <<= 2; this.frames[frame] = time; this.frames[frame + 1/*R*/] = r; @@ -1045,7 +1045,7 @@ export class RGBTimeline extends CurveTimeline implements SlotTimeline { this.frames[frame + 3/*B*/] = b; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; @@ -1113,12 +1113,12 @@ export class RGBTimeline extends CurveTimeline implements SlotTimeline { export class AlphaTimeline extends CurveTimeline1 implements SlotTimeline { slotIndex = 0; - constructor(frameCount: number, bezierCount: number, slotIndex: number) { + constructor (frameCount: number, bezierCount: number, slotIndex: number) { super(frameCount, bezierCount, Property.alpha + "|" + slotIndex); this.slotIndex = slotIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; @@ -1149,7 +1149,7 @@ export class AlphaTimeline extends CurveTimeline1 implements SlotTimeline { export class RGBA2Timeline extends CurveTimeline implements SlotTimeline { slotIndex = 0; - constructor(frameCount: number, bezierCount: number, slotIndex: number) { + constructor (frameCount: number, bezierCount: number, slotIndex: number) { super(frameCount, bezierCount, [ Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex, @@ -1158,12 +1158,12 @@ export class RGBA2Timeline extends CurveTimeline implements SlotTimeline { this.slotIndex = slotIndex; } - getFrameEntries() { + getFrameEntries () { return 8/*ENTRIES*/; } /** Sets the time in seconds, light, and dark colors for the specified key frame. */ - setFrame(frame: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number) { + setFrame (frame: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number) { frame <<= 3; this.frames[frame] = time; this.frames[frame + 1/*R*/] = r; @@ -1175,7 +1175,7 @@ export class RGBA2Timeline extends CurveTimeline implements SlotTimeline { this.frames[frame + 7/*B2*/] = b2; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; @@ -1266,7 +1266,7 @@ export class RGBA2Timeline extends CurveTimeline implements SlotTimeline { export class RGB2Timeline extends CurveTimeline implements SlotTimeline { slotIndex = 0; - constructor(frameCount: number, bezierCount: number, slotIndex: number) { + constructor (frameCount: number, bezierCount: number, slotIndex: number) { super(frameCount, bezierCount, [ Property.rgb + "|" + slotIndex, Property.rgb2 + "|" + slotIndex @@ -1274,12 +1274,12 @@ export class RGB2Timeline extends CurveTimeline implements SlotTimeline { this.slotIndex = slotIndex; } - getFrameEntries() { + getFrameEntries () { return 7/*ENTRIES*/; } /** Sets the time in seconds, light, and dark colors for the specified key frame. */ - setFrame(frame: number, time: number, r: number, g: number, b: number, r2: number, g2: number, b2: number) { + setFrame (frame: number, time: number, r: number, g: number, b: number, r2: number, g2: number, b2: number) { frame *= 7/*ENTRIES*/; this.frames[frame] = time; this.frames[frame + 1/*R*/] = r; @@ -1290,7 +1290,7 @@ export class RGB2Timeline extends CurveTimeline implements SlotTimeline { this.frames[frame + 6/*B2*/] = b2; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; @@ -1389,7 +1389,7 @@ export class AttachmentTimeline extends Timeline implements SlotTimeline { /** The attachment name for each key frame. May contain null values to clear the attachment. */ attachmentNames: Array; - constructor(frameCount: number, slotIndex: number) { + constructor (frameCount: number, slotIndex: number) { super(frameCount, [ Property.attachment + "|" + slotIndex ]); @@ -1397,17 +1397,17 @@ export class AttachmentTimeline extends Timeline implements SlotTimeline { this.attachmentNames = new Array(frameCount); } - getFrameCount() { + getFrameCount () { return this.frames.length; } /** Sets the time in seconds and the attachment name for the specified key frame. */ - setFrame(frame: number, time: number, attachmentName: string) { + setFrame (frame: number, time: number, attachmentName: string) { this.frames[frame] = time; this.attachmentNames[frame] = attachmentName; } - apply(skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; @@ -1424,7 +1424,7 @@ export class AttachmentTimeline extends Timeline implements SlotTimeline { this.setAttachment(skeleton, slot, this.attachmentNames[Timeline.search1(this.frames, time)]); } - setAttachment(skeleton: Skeleton, slot: Slot, attachmentName: string) { + setAttachment (skeleton: Skeleton, slot: Slot, attachmentName: string) { slot.setAttachment(!attachmentName ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); } } @@ -1439,7 +1439,7 @@ export class DeformTimeline extends CurveTimeline implements SlotTimeline { /** The vertices for each key frame. */ vertices: Array; - constructor(frameCount: number, bezierCount: number, slotIndex: number, attachment: VertexAttachment) { + constructor (frameCount: number, bezierCount: number, slotIndex: number, attachment: VertexAttachment) { super(frameCount, bezierCount, [ Property.deform + "|" + slotIndex + "|" + attachment.id ]); @@ -1448,20 +1448,20 @@ export class DeformTimeline extends CurveTimeline implements SlotTimeline { this.vertices = new Array(frameCount); } - getFrameCount() { + getFrameCount () { return this.frames.length; } /** Sets the time in seconds and the vertices for the specified key frame. * @param vertices Vertex positions for an unweighted VertexAttachment, or deform offsets if it has weights. */ - setFrame(frame: number, time: number, vertices: NumberArrayLike) { + setFrame (frame: number, time: number, vertices: NumberArrayLike) { this.frames[frame] = time; this.vertices[frame] = vertices; } /** @param value1 Ignored (0 is used for a deform timeline). * @param value2 Ignored (1 is used for a deform timeline). */ - setBezier(bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number, + setBezier (bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number, cy2: number, time2: number, value2: number) { let curves = this.curves; let i = this.getFrameCount() + bezier * 18/*BEZIER_SIZE*/; @@ -1483,7 +1483,7 @@ export class DeformTimeline extends CurveTimeline implements SlotTimeline { } } - getCurvePercent(time: number, frame: number) { + getCurvePercent (time: number, frame: number) { let curves = this.curves; let i = curves[frame]; switch (i) { @@ -1509,7 +1509,7 @@ export class DeformTimeline extends CurveTimeline implements SlotTimeline { return y + (1 - y) * (time - x) / (this.frames[frame + this.getFrameEntries()] - x); } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot: Slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) return; let slotAttachment: Attachment = slot.getAttachment(); @@ -1691,24 +1691,24 @@ export class EventTimeline extends Timeline { /** The event for each key frame. */ events: Array; - constructor(frameCount: number) { + constructor (frameCount: number) { super(frameCount, EventTimeline.propertyIds); this.events = new Array(frameCount); } - getFrameCount() { + getFrameCount () { return this.frames.length; } /** Sets the time in seconds and the event for the specified key frame. */ - setFrame(frame: number, event: Event) { + setFrame (frame: number, event: Event) { this.frames[frame] = event.time; this.events[frame] = event; } /** Fires events for frames > `lastTime` and <= `time`. */ - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { if (!firedEvents) return; let frames = this.frames; @@ -1744,24 +1744,24 @@ export class DrawOrderTimeline extends Timeline { /** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */ drawOrders: Array>; - constructor(frameCount: number) { + constructor (frameCount: number) { super(frameCount, DrawOrderTimeline.propertyIds); this.drawOrders = new Array>(frameCount); } - getFrameCount() { + getFrameCount () { return this.frames.length; } /** Sets the time in seconds and the draw order for the specified key frame. * @param drawOrder For each slot in {@link Skeleton#slots}, the index of the new draw order. May be null to use setup pose * draw order. */ - setFrame(frame: number, time: number, drawOrder: Array) { + setFrame (frame: number, time: number, drawOrder: Array) { this.frames[frame] = time; this.drawOrders[frame] = drawOrder; } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { if (direction == MixDirection.mixOut) { if (blend == MixBlend.setup) Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); return; @@ -1790,19 +1790,19 @@ export class IkConstraintTimeline extends CurveTimeline { /** The index of the IK constraint slot in {@link Skeleton#ikConstraints} that will be changed. */ ikConstraintIndex: number; - constructor(frameCount: number, bezierCount: number, ikConstraintIndex: number) { + constructor (frameCount: number, bezierCount: number, ikConstraintIndex: number) { super(frameCount, bezierCount, [ Property.ikConstraint + "|" + ikConstraintIndex ]); this.ikConstraintIndex = ikConstraintIndex; } - getFrameEntries() { + getFrameEntries () { return 6/*ENTRIES*/; } /** Sets the time in seconds, mix, softness, bend direction, compress, and stretch for the specified key frame. */ - setFrame(frame: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean) { + setFrame (frame: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean) { frame *= 6/*ENTRIES*/; this.frames[frame] = time; this.frames[frame + 1/*MIX*/] = mix; @@ -1812,7 +1812,7 @@ export class IkConstraintTimeline extends CurveTimeline { this.frames[frame + 5/*STRETCH*/] = stretch ? 1 : 0; } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let constraint: IkConstraint = skeleton.ikConstraints[this.ikConstraintIndex]; if (!constraint.active) return; @@ -1888,19 +1888,19 @@ export class TransformConstraintTimeline extends CurveTimeline { /** The index of the transform constraint slot in {@link Skeleton#transformConstraints} that will be changed. */ transformConstraintIndex: number; - constructor(frameCount: number, bezierCount: number, transformConstraintIndex: number) { + constructor (frameCount: number, bezierCount: number, transformConstraintIndex: number) { super(frameCount, bezierCount, [ Property.transformConstraint + "|" + transformConstraintIndex ]); this.transformConstraintIndex = transformConstraintIndex; } - getFrameEntries() { + getFrameEntries () { return 7/*ENTRIES*/; } /** The time in seconds, rotate mix, translate mix, scale mix, and shear mix for the specified key frame. */ - setFrame(frame: number, time: number, mixRotate: number, mixX: number, mixY: number, mixScaleX: number, mixScaleY: number, + setFrame (frame: number, time: number, mixRotate: number, mixX: number, mixY: number, mixScaleX: number, mixScaleY: number, mixShearY: number) { let frames = this.frames; frame *= 7/*ENTRIES*/; @@ -1913,7 +1913,7 @@ export class TransformConstraintTimeline extends CurveTimeline { frames[frame + 6/*SHEARY*/] = mixShearY; } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let constraint: TransformConstraint = skeleton.transformConstraints[this.transformConstraintIndex]; if (!constraint.active) return; @@ -2001,12 +2001,12 @@ export class PathConstraintPositionTimeline extends CurveTimeline1 { /** The index of the path constraint slot in {@link Skeleton#pathConstraints} that will be changed. */ pathConstraintIndex: number; - constructor(frameCount: number, bezierCount: number, pathConstraintIndex: number) { + constructor (frameCount: number, bezierCount: number, pathConstraintIndex: number) { super(frameCount, bezierCount, Property.pathConstraintPosition + "|" + pathConstraintIndex); this.pathConstraintIndex = pathConstraintIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex]; if (!constraint.active) return; @@ -2036,12 +2036,12 @@ export class PathConstraintSpacingTimeline extends CurveTimeline1 { /** The index of the path constraint slot in {@link Skeleton#getPathConstraints()} that will be changed. */ pathConstraintIndex = 0; - constructor(frameCount: number, bezierCount: number, pathConstraintIndex: number) { + constructor (frameCount: number, bezierCount: number, pathConstraintIndex: number) { super(frameCount, bezierCount, Property.pathConstraintSpacing + "|" + pathConstraintIndex); this.pathConstraintIndex = pathConstraintIndex; } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex]; if (!constraint.active) return; @@ -2072,18 +2072,18 @@ export class PathConstraintMixTimeline extends CurveTimeline { /** The index of the path constraint slot in {@link Skeleton#getPathConstraints()} that will be changed. */ pathConstraintIndex = 0; - constructor(frameCount: number, bezierCount: number, pathConstraintIndex: number) { + constructor (frameCount: number, bezierCount: number, pathConstraintIndex: number) { super(frameCount, bezierCount, [ Property.pathConstraintMix + "|" + pathConstraintIndex ]); this.pathConstraintIndex = pathConstraintIndex; } - getFrameEntries() { + getFrameEntries () { return 4/*ENTRIES*/; } - setFrame(frame: number, time: number, mixRotate: number, mixX: number, mixY: number) { + setFrame (frame: number, time: number, mixRotate: number, mixX: number, mixY: number) { let frames = this.frames; frame <<= 2; frames[frame] = time; @@ -2092,7 +2092,7 @@ export class PathConstraintMixTimeline extends CurveTimeline { frames[frame + 3/*Y*/] = mixY; } - apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { + apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex]; if (!constraint.active) return; diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index fe7ad23f1..d8ec32c93 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -40,7 +40,7 @@ import { Event } from "./Event"; * * See [Applying Animations](http://esotericsoftware.com/spine-applying-animations/) in the Spine Runtimes Guide. */ export class AnimationState { - private static emptyAnimation(): Animation { + private static emptyAnimation (): Animation { if (!_emptyAnimation) _emptyAnimation = new Animation("", [], 0); return _emptyAnimation; } @@ -66,12 +66,12 @@ export class AnimationState { trackEntryPool = new Pool(() => new TrackEntry()); - constructor(data: AnimationStateData) { + constructor (data: AnimationStateData) { this.data = data; } /** Increments each track entry {@link TrackEntry#trackTime()}, setting queued animations as current if needed. */ - update(delta: number) { + update (delta: number) { delta *= this.timeScale; let tracks = this.tracks; for (let i = 0, n = tracks.length; i < n; i++) { @@ -129,7 +129,7 @@ export class AnimationState { } /** Returns true when all mixing from entries are complete. */ - updateMixingFrom(to: TrackEntry, delta: number): boolean { + updateMixingFrom (to: TrackEntry, delta: number): boolean { let from = to.mixingFrom; if (!from) return true; @@ -158,7 +158,7 @@ export class AnimationState { /** Poses the skeleton using the track entry animations. There are no side effects other than invoking listeners, so the * animation state can be applied to multiple skeletons to pose them identically. * @returns True if any animations were applied. */ - apply(skeleton: Skeleton): boolean { + apply (skeleton: Skeleton): boolean { if (!skeleton) throw new Error("skeleton cannot be null."); if (this.animationsChanged) this._animationsChanged(); @@ -244,7 +244,7 @@ export class AnimationState { return applied; } - applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend) { + applyMixingFrom (to: TrackEntry, skeleton: Skeleton, blend: MixBlend) { let from = to.mixingFrom; if (from.mixingFrom) this.applyMixingFrom(from, skeleton, blend); @@ -333,7 +333,7 @@ export class AnimationState { return mix; } - applyAttachmentTimeline(timeline: AttachmentTimeline, skeleton: Skeleton, time: number, blend: MixBlend, attachments: boolean) { + applyAttachmentTimeline (timeline: AttachmentTimeline, skeleton: Skeleton, time: number, blend: MixBlend, attachments: boolean) { var slot = skeleton.slots[timeline.slotIndex]; if (!slot.bone.active) return; @@ -347,12 +347,12 @@ export class AnimationState { if (slot.attachmentState <= this.unkeyedState) slot.attachmentState = this.unkeyedState + SETUP; } - setAttachment(skeleton: Skeleton, slot: Slot, attachmentName: string, attachments: boolean) { + setAttachment (skeleton: Skeleton, slot: Slot, attachmentName: string, attachments: boolean) { slot.setAttachment(!attachmentName ? null : skeleton.getAttachment(slot.data.index, attachmentName)); if (attachments) slot.attachmentState = this.unkeyedState + CURRENT; } - applyRotateTimeline(timeline: RotateTimeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, + applyRotateTimeline (timeline: RotateTimeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array, i: number, firstFrame: boolean) { if (firstFrame) timelinesRotation[i] = 0; @@ -410,7 +410,7 @@ export class AnimationState { bone.rotation = r1 + total * alpha; } - queueEvents(entry: TrackEntry, animationTime: number) { + queueEvents (entry: TrackEntry, animationTime: number) { let animationStart = entry.animationStart, animationEnd = entry.animationEnd; let duration = animationEnd - animationStart; let trackLastWrapped = entry.trackLast % duration; @@ -445,7 +445,7 @@ export class AnimationState { * * It may be desired to use {@link AnimationState#setEmptyAnimation()} to mix the skeletons back to the setup pose, * rather than leaving them in their current pose. */ - clearTracks() { + clearTracks () { let oldDrainDisabled = this.queue.drainDisabled; this.queue.drainDisabled = true; for (let i = 0, n = this.tracks.length; i < n; i++) @@ -459,7 +459,7 @@ export class AnimationState { * * It may be desired to use {@link AnimationState#setEmptyAnimation()} to mix the skeletons back to the setup pose, * rather than leaving them in their current pose. */ - clearTrack(trackIndex: number) { + clearTrack (trackIndex: number) { if (trackIndex >= this.tracks.length) return; let current = this.tracks[trackIndex]; if (!current) return; @@ -483,7 +483,7 @@ export class AnimationState { this.queue.drain(); } - setCurrent(index: number, current: TrackEntry, interrupt: boolean) { + setCurrent (index: number, current: TrackEntry, interrupt: boolean) { let from = this.expandToIndex(index); this.tracks[index] = current; current.previous = null; @@ -507,7 +507,7 @@ export class AnimationState { /** Sets an animation by name. * * See {@link #setAnimationWith()}. */ - setAnimation(trackIndex: number, animationName: string, loop: boolean = false) { + setAnimation (trackIndex: number, animationName: string, loop: boolean = false) { let animation = this.data.skeletonData.findAnimation(animationName); if (!animation) throw new Error("Animation not found: " + animationName); return this.setAnimationWith(trackIndex, animation, loop); @@ -519,7 +519,7 @@ export class AnimationState { * duration. In either case {@link TrackEntry#trackEnd} determines when the track is cleared. * @returns A track entry to allow further customization of animation playback. References to the track entry must not be kept * after the {@link AnimationStateListener#dispose()} event occurs. */ - setAnimationWith(trackIndex: number, animation: Animation, loop: boolean = false) { + setAnimationWith (trackIndex: number, animation: Animation, loop: boolean = false) { if (!animation) throw new Error("animation cannot be null."); let interrupt = true; let current = this.expandToIndex(trackIndex); @@ -544,7 +544,7 @@ export class AnimationState { /** Queues an animation by name. * * See {@link #addAnimationWith()}. */ - addAnimation(trackIndex: number, animationName: string, loop: boolean = false, delay: number = 0) { + addAnimation (trackIndex: number, animationName: string, loop: boolean = false, delay: number = 0) { let animation = this.data.skeletonData.findAnimation(animationName); if (!animation) throw new Error("Animation not found: " + animationName); return this.addAnimationWith(trackIndex, animation, loop, delay); @@ -558,7 +558,7 @@ export class AnimationState { * previous entry is looping, its next loop completion is used instead of its duration. * @returns A track entry to allow further customization of animation playback. References to the track entry must not be kept * after the {@link AnimationStateListener#dispose()} event occurs. */ - addAnimationWith(trackIndex: number, animation: Animation, loop: boolean = false, delay: number = 0) { + addAnimationWith (trackIndex: number, animation: Animation, loop: boolean = false, delay: number = 0) { if (!animation) throw new Error("animation cannot be null."); let last = this.expandToIndex(trackIndex); @@ -596,7 +596,7 @@ export class AnimationState { * {@link TrackEntry#setMixDuration()}. Mixing from an empty animation causes the new animation to be applied more and * more over the mix duration. Properties keyed in the new animation transition from the value from lower tracks or from the * setup pose value if no lower tracks key the property to the value keyed in the new animation. */ - setEmptyAnimation(trackIndex: number, mixDuration: number = 0) { + setEmptyAnimation (trackIndex: number, mixDuration: number = 0) { let entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation(), false); entry.mixDuration = mixDuration; entry.trackEnd = mixDuration; @@ -614,7 +614,7 @@ export class AnimationState { * loop completion is used instead of its duration. * @return A track entry to allow further customization of animation playback. References to the track entry must not be kept * after the {@link AnimationStateListener#dispose()} event occurs. */ - addEmptyAnimation(trackIndex: number, mixDuration: number = 0, delay: number = 0) { + addEmptyAnimation (trackIndex: number, mixDuration: number = 0, delay: number = 0) { let entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay); if (delay <= 0) entry.delay += entry.mixDuration - mixDuration; entry.mixDuration = mixDuration; @@ -624,7 +624,7 @@ export class AnimationState { /** Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix * duration. */ - setEmptyAnimations(mixDuration: number = 0) { + setEmptyAnimations (mixDuration: number = 0) { let oldDrainDisabled = this.queue.drainDisabled; this.queue.drainDisabled = true; for (let i = 0, n = this.tracks.length; i < n; i++) { @@ -635,7 +635,7 @@ export class AnimationState { this.queue.drain(); } - expandToIndex(index: number) { + expandToIndex (index: number) { if (index < this.tracks.length) return this.tracks[index]; Utils.ensureArrayCapacity(this.tracks, index + 1, null); this.tracks.length = index + 1; @@ -643,7 +643,7 @@ export class AnimationState { } /** @param last May be null. */ - trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry) { + trackEntry (trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry) { let entry = this.trackEntryPool.obtain(); entry.trackIndex = trackIndex; entry.animation = animation; @@ -675,7 +675,7 @@ export class AnimationState { } /** Removes the {@link TrackEntry#getNext() next entry} and all entries after it for the specified entry. */ - clearNext(entry: TrackEntry) { + clearNext (entry: TrackEntry) { let next = entry.next; while (next) { this.queue.dispose(next); @@ -684,7 +684,7 @@ export class AnimationState { entry.next = null; } - _animationsChanged() { + _animationsChanged () { this.animationsChanged = false; this.propertyIDs.clear(); @@ -701,7 +701,7 @@ export class AnimationState { } } - computeHold(entry: TrackEntry) { + computeHold (entry: TrackEntry) { let to = entry.mixingTo; let timelines = entry.animation.timelines; let timelinesCount = entry.animation.timelines.length; @@ -742,32 +742,32 @@ export class AnimationState { } /** Returns the track entry for the animation currently playing on the track, or null if no animation is currently playing. */ - getCurrent(trackIndex: number) { + getCurrent (trackIndex: number) { if (trackIndex >= this.tracks.length) return null; return this.tracks[trackIndex]; } /** Adds a listener to receive events for all track entries. */ - addListener(listener: AnimationStateListener) { + addListener (listener: AnimationStateListener) { if (!listener) throw new Error("listener cannot be null."); this.listeners.push(listener); } /** Removes the listener added with {@link #addListener()}. */ - removeListener(listener: AnimationStateListener) { + removeListener (listener: AnimationStateListener) { let index = this.listeners.indexOf(listener); if (index >= 0) this.listeners.splice(index, 1); } /** Removes all listeners added with {@link #addListener()}. */ - clearListeners() { + clearListeners () { this.listeners.length = 0; } /** Discards all listener notifications that have not yet been delivered. This can be useful to call from an * {@link AnimationStateListener} when it is known that further notifications that may have been already queued for delivery * are not wanted because new animations are being set. */ - clearListenerNotifications() { + clearListenerNotifications () { this.queue.clear(); } } @@ -930,7 +930,7 @@ export class TrackEntry { timelineHoldMix = new Array(); timelinesRotation = new Array(); - reset() { + reset () { this.next = null; this.previous = null; this.mixingFrom = null; @@ -945,7 +945,7 @@ export class TrackEntry { /** Uses {@link #trackTime} to compute the `animationTime`, which is between {@link #animationStart} * and {@link #animationEnd}. When the `trackTime` is 0, the `animationTime` is equal to the * `animationStart` time. */ - getAnimationTime() { + getAnimationTime () { if (this.loop) { let duration = this.animationEnd - this.animationStart; if (duration == 0) return this.animationStart; @@ -954,7 +954,7 @@ export class TrackEntry { return Math.min(this.trackTime + this.animationStart, this.animationEnd); } - setAnimationLast(animationLast: number) { + setAnimationLast (animationLast: number) { this.animationLast = animationLast; this.nextAnimationLast = animationLast; } @@ -962,7 +962,7 @@ export class TrackEntry { /** Returns true if at least one loop has been completed. * * See {@link AnimationStateListener#complete()}. */ - isComplete() { + isComplete () { return this.trackTime >= this.animationEnd - this.animationStart; } @@ -973,11 +973,11 @@ export class TrackEntry { * the short way or the long way around. The two rotations likely change over time, so which direction is the short or long * way also changes. If the short way was always chosen, bones would flip to the other side when that direction became the * long way. TrackEntry chooses the short way the first time it is applied and remembers that direction. */ - resetRotationDirections() { + resetRotationDirections () { this.timelinesRotation.length = 0; } - getTrackComplete() { + getTrackComplete () { let duration = this.animationEnd - this.animationStart; if (duration != 0) { if (this.loop) return duration * (1 + ((this.trackTime / duration) | 0)); // Completion of next loop. @@ -992,44 +992,44 @@ export class EventQueue { drainDisabled = false; animState: AnimationState; - constructor(animState: AnimationState) { + constructor (animState: AnimationState) { this.animState = animState; } - start(entry: TrackEntry) { + start (entry: TrackEntry) { this.objects.push(EventType.start); this.objects.push(entry); this.animState.animationsChanged = true; } - interrupt(entry: TrackEntry) { + interrupt (entry: TrackEntry) { this.objects.push(EventType.interrupt); this.objects.push(entry); } - end(entry: TrackEntry) { + end (entry: TrackEntry) { this.objects.push(EventType.end); this.objects.push(entry); this.animState.animationsChanged = true; } - dispose(entry: TrackEntry) { + dispose (entry: TrackEntry) { this.objects.push(EventType.dispose); this.objects.push(entry); } - complete(entry: TrackEntry) { + complete (entry: TrackEntry) { this.objects.push(EventType.complete); this.objects.push(entry); } - event(entry: TrackEntry, event: Event) { + event (entry: TrackEntry, event: Event) { this.objects.push(EventType.event); this.objects.push(entry); this.objects.push(event); } - drain() { + drain () { if (this.drainDisabled) return; this.drainDisabled = true; @@ -1079,7 +1079,7 @@ export class EventQueue { this.drainDisabled = false; } - clear() { + clear () { this.objects.length = 0; } } @@ -1095,43 +1095,43 @@ export enum EventType { * {@link AnimationState#addListener()}. */ export interface AnimationStateListener { /** Invoked when this entry has been set as the current entry. */ - start(entry: TrackEntry): void; + start (entry: TrackEntry): void; /** Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for * mixing. */ - interrupt(entry: TrackEntry): void; + interrupt (entry: TrackEntry): void; /** Invoked when this entry is no longer the current entry and will never be applied again. */ - end(entry: TrackEntry): void; + end (entry: TrackEntry): void; /** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry. * References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */ - dispose(entry: TrackEntry): void; + dispose (entry: TrackEntry): void; /** Invoked every time this entry's animation completes a loop. */ - complete(entry: TrackEntry): void; + complete (entry: TrackEntry): void; /** Invoked when this entry's animation triggers an event. */ - event(entry: TrackEntry, event: Event): void; + event (entry: TrackEntry, event: Event): void; } export abstract class AnimationStateAdapter implements AnimationStateListener { - start(entry: TrackEntry) { + start (entry: TrackEntry) { } - interrupt(entry: TrackEntry) { + interrupt (entry: TrackEntry) { } - end(entry: TrackEntry) { + end (entry: TrackEntry) { } - dispose(entry: TrackEntry) { + dispose (entry: TrackEntry) { } - complete(entry: TrackEntry) { + complete (entry: TrackEntry) { } - event(entry: TrackEntry, event: Event) { + event (entry: TrackEntry, event: Event) { } } diff --git a/spine-ts/spine-core/src/AnimationStateData.ts b/spine-ts/spine-core/src/AnimationStateData.ts index 2c94e81b5..8a68b7c73 100644 --- a/spine-ts/spine-core/src/AnimationStateData.ts +++ b/spine-ts/spine-core/src/AnimationStateData.ts @@ -42,7 +42,7 @@ export class AnimationStateData { /** The mix duration to use when no mix duration has been defined between two animations. */ defaultMix = 0; - constructor(skeletonData: SkeletonData) { + constructor (skeletonData: SkeletonData) { if (!skeletonData) throw new Error("skeletonData cannot be null."); this.skeletonData = skeletonData; } @@ -50,7 +50,7 @@ export class AnimationStateData { /** Sets a mix duration by animation name. * * See {@link #setMixWith()}. */ - setMix(fromName: string, toName: string, duration: number) { + setMix (fromName: string, toName: string, duration: number) { let from = this.skeletonData.findAnimation(fromName); if (!from) throw new Error("Animation not found: " + fromName); let to = this.skeletonData.findAnimation(toName); @@ -61,7 +61,7 @@ export class AnimationStateData { /** Sets the mix duration when changing from the specified animation to the other. * * See {@link TrackEntry#mixDuration}. */ - setMixWith(from: Animation, to: Animation, duration: number) { + setMixWith (from: Animation, to: Animation, duration: number) { if (!from) throw new Error("from cannot be null."); if (!to) throw new Error("to cannot be null."); let key = from.name + "." + to.name; @@ -70,7 +70,7 @@ export class AnimationStateData { /** Returns the mix duration to use when changing from the specified animation to the other, or the {@link #defaultMix} if * no mix duration has been set. */ - getMix(from: Animation, to: Animation) { + getMix (from: Animation, to: Animation) { let key = from.name + "." + to.name; let value = this.animationToMixTime[key]; return value === undefined ? this.defaultMix : value; diff --git a/spine-ts/spine-core/src/AssetManagerBase.ts b/spine-ts/spine-core/src/AssetManagerBase.ts index 08d9e6c73..273812478 100644 --- a/spine-ts/spine-core/src/AssetManagerBase.ts +++ b/spine-ts/spine-core/src/AssetManagerBase.ts @@ -40,36 +40,36 @@ export class AssetManagerBase implements Disposable { private toLoad = 0; private loaded = 0; - constructor(textureLoader: (image: HTMLImageElement | ImageBitmap) => Texture, pathPrefix: string = "", downloader: Downloader = null) { + constructor (textureLoader: (image: HTMLImageElement | ImageBitmap) => Texture, pathPrefix: string = "", downloader: Downloader = null) { this.textureLoader = textureLoader; this.pathPrefix = pathPrefix; this.downloader = downloader || new Downloader(); } - private start(path: string): string { + private start (path: string): string { this.toLoad++; return this.pathPrefix + path; } - private success(callback: (path: string, data: any) => void, path: string, asset: any) { + private success (callback: (path: string, data: any) => void, path: string, asset: any) { this.toLoad--; this.loaded++; this.assets[path] = asset; if (callback) callback(path, asset); } - private error(callback: (path: string, message: string) => void, path: string, message: string) { + private error (callback: (path: string, message: string) => void, path: string, message: string) { this.toLoad--; this.loaded++; this.errors[path] = message; if (callback) callback(path, message); } - setRawDataURI(path: string, data: string) { + setRawDataURI (path: string, data: string) { this.downloader.rawDataUris[this.pathPrefix + path] = data; } - loadBinary(path: string, + loadBinary (path: string, success: (path: string, binary: Uint8Array) => void = null, error: (path: string, message: string) => void = null) { path = this.start(path); @@ -81,7 +81,7 @@ export class AssetManagerBase implements Disposable { }); } - loadText(path: string, + loadText (path: string, success: (path: string, text: string) => void = null, error: (path: string, message: string) => void = null) { path = this.start(path); @@ -93,7 +93,7 @@ export class AssetManagerBase implements Disposable { }); } - loadJson(path: string, + loadJson (path: string, success: (path: string, object: object) => void = null, error: (path: string, message: string) => void = null) { path = this.start(path); @@ -105,7 +105,7 @@ export class AssetManagerBase implements Disposable { }); } - loadTexture(path: string, + loadTexture (path: string, success: (path: string, texture: Texture) => void = null, error: (path: string, message: string) => void = null) { path = this.start(path); @@ -136,7 +136,7 @@ export class AssetManagerBase implements Disposable { } } - loadTextureAtlas(path: string, + loadTextureAtlas (path: string, success: (path: string, atlas: TextureAtlas) => void = null, error: (path: string, message: string) => void = null ) { @@ -170,11 +170,11 @@ export class AssetManagerBase implements Disposable { }); } - get(path: string) { + get (path: string) { return this.assets[this.pathPrefix + path]; } - require(path: string) { + require (path: string) { path = this.pathPrefix + path; let asset = this.assets[path]; if (asset) return asset; @@ -182,7 +182,7 @@ export class AssetManagerBase implements Disposable { throw Error("Asset not found: " + path + (error ? "\n" + error : "")); } - remove(path: string) { + remove (path: string) { path = this.pathPrefix + path; let asset = this.assets[path]; if ((asset).dispose) (asset).dispose(); @@ -190,7 +190,7 @@ export class AssetManagerBase implements Disposable { return asset; } - removeAll() { + removeAll () { for (let key in this.assets) { let asset = this.assets[key]; if ((asset).dispose) (asset).dispose(); @@ -198,27 +198,27 @@ export class AssetManagerBase implements Disposable { this.assets = {}; } - isLoadingComplete(): boolean { + isLoadingComplete (): boolean { return this.toLoad == 0; } - getToLoad(): number { + getToLoad (): number { return this.toLoad; } - getLoaded(): number { + getLoaded (): number { return this.loaded; } - dispose() { + dispose () { this.removeAll(); } - hasErrors() { + hasErrors () { return Object.keys(this.errors).length > 0; } - getErrors() { + getErrors () { return this.errors; } } @@ -227,7 +227,7 @@ export class Downloader { private callbacks: StringMap> = {}; rawDataUris: StringMap = {}; - downloadText(url: string, success: (data: string) => void, error: (status: number, responseText: string) => void) { + downloadText (url: string, success: (data: string) => void, error: (status: number, responseText: string) => void) { if (this.rawDataUris[url]) url = this.rawDataUris[url]; if (this.start(url, success, error)) return; let request = new XMLHttpRequest(); @@ -241,13 +241,13 @@ export class Downloader { request.send(); } - downloadJson(url: string, success: (data: object) => void, error: (status: number, responseText: string) => void) { + downloadJson (url: string, success: (data: object) => void, error: (status: number, responseText: string) => void) { this.downloadText(url, (data: string): void => { success(JSON.parse(data)); }, error); } - downloadBinary(url: string, success: (data: Uint8Array) => void, error: (status: number, responseText: string) => void) { + downloadBinary (url: string, success: (data: Uint8Array) => void, error: (status: number, responseText: string) => void) { if (this.rawDataUris[url]) url = this.rawDataUris[url]; if (this.start(url, success, error)) return; let request = new XMLHttpRequest(); @@ -266,7 +266,7 @@ export class Downloader { request.send(); } - private start(url: string, success: any, error: any) { + private start (url: string, success: any, error: any) { let callbacks = this.callbacks[url]; try { if (callbacks) return true; @@ -276,7 +276,7 @@ export class Downloader { } } - private finish(url: string, status: number, data: any) { + private finish (url: string, status: number, data: any) { let callbacks = this.callbacks[url]; delete this.callbacks[url]; let args = status == 200 ? [data] : [status, data]; diff --git a/spine-ts/spine-core/src/AtlasAttachmentLoader.ts b/spine-ts/spine-core/src/AtlasAttachmentLoader.ts index 46e41e904..c61dd0aea 100644 --- a/spine-ts/spine-core/src/AtlasAttachmentLoader.ts +++ b/spine-ts/spine-core/src/AtlasAttachmentLoader.ts @@ -44,11 +44,11 @@ import { TextureAtlas } from "./TextureAtlas"; export class AtlasAttachmentLoader implements AttachmentLoader { atlas: TextureAtlas; - constructor(atlas: TextureAtlas) { + constructor (atlas: TextureAtlas) { this.atlas = atlas; } - newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment { + newRegionAttachment (skin: Skin, name: string, path: string): RegionAttachment { let region = this.atlas.findRegion(path); if (!region) throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")"); region.renderObject = region; @@ -57,7 +57,7 @@ export class AtlasAttachmentLoader implements AttachmentLoader { return attachment; } - newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment { + newMeshAttachment (skin: Skin, name: string, path: string): MeshAttachment { let region = this.atlas.findRegion(path); if (!region) throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); region.renderObject = region; @@ -66,19 +66,19 @@ export class AtlasAttachmentLoader implements AttachmentLoader { return attachment; } - newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment { + newBoundingBoxAttachment (skin: Skin, name: string): BoundingBoxAttachment { return new BoundingBoxAttachment(name); } - newPathAttachment(skin: Skin, name: string): PathAttachment { + newPathAttachment (skin: Skin, name: string): PathAttachment { return new PathAttachment(name); } - newPointAttachment(skin: Skin, name: string): PointAttachment { + newPointAttachment (skin: Skin, name: string): PointAttachment { return new PointAttachment(name); } - newClippingAttachment(skin: Skin, name: string): ClippingAttachment { + newClippingAttachment (skin: Skin, name: string): ClippingAttachment { return new ClippingAttachment(name); } } diff --git a/spine-ts/spine-core/src/Bone.ts b/spine-ts/spine-core/src/Bone.ts index e623dc8c2..9db42d6e9 100644 --- a/spine-ts/spine-core/src/Bone.ts +++ b/spine-ts/spine-core/src/Bone.ts @@ -114,7 +114,7 @@ export class Bone implements Updatable { active = false; /** @param parent May be null. */ - constructor(data: BoneData, skeleton: Skeleton, parent: Bone) { + constructor (data: BoneData, skeleton: Skeleton, parent: Bone) { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; @@ -125,19 +125,19 @@ export class Bone implements Updatable { /** Returns false when the bone has not been computed because {@link BoneData#skinRequired} is true and the * {@link Skeleton#skin active skin} does not {@link Skin#bones contain} this bone. */ - isActive() { + isActive () { return this.active; } /** Computes the world transform using the parent bone and this bone's local applied transform. */ - update() { + update () { this.updateWorldTransformWith(this.ax, this.ay, this.arotation, this.ascaleX, this.ascaleY, this.ashearX, this.ashearY); } /** Computes the world transform using the parent bone and this bone's local transform. * * See {@link #updateWorldTransformWith()}. */ - updateWorldTransform() { + updateWorldTransform () { this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); } @@ -146,7 +146,7 @@ export class Bone implements Updatable { * * See [World transforms](http://esotericsoftware.com/spine-runtime-skeletons#World-transforms) in the Spine * Runtimes Guide. */ - updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number) { + updateWorldTransformWith (x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number) { this.ax = x; this.ay = y; this.arotation = rotation; @@ -256,7 +256,7 @@ export class Bone implements Updatable { } /** Sets this bone's local transform to the setup pose. */ - setToSetupPose() { + setToSetupPose () { let data = this.data; this.x = data.x; this.y = data.y; @@ -268,22 +268,22 @@ export class Bone implements Updatable { } /** The world rotation for the X axis, calculated using {@link #a} and {@link #c}. */ - getWorldRotationX() { + getWorldRotationX () { return Math.atan2(this.c, this.a) * MathUtils.radDeg; } /** The world rotation for the Y axis, calculated using {@link #b} and {@link #d}. */ - getWorldRotationY() { + getWorldRotationY () { return Math.atan2(this.d, this.b) * MathUtils.radDeg; } /** The magnitude (always positive) of the world scale X, calculated using {@link #a} and {@link #c}. */ - getWorldScaleX() { + getWorldScaleX () { return Math.sqrt(this.a * this.a + this.c * this.c); } /** The magnitude (always positive) of the world scale Y, calculated using {@link #b} and {@link #d}. */ - getWorldScaleY() { + getWorldScaleY () { return Math.sqrt(this.b * this.b + this.d * this.d); } @@ -295,7 +295,7 @@ export class Bone implements Updatable { * * Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. The applied transform after * calling this method is equivalent to the local transform used to compute the world transform, but may not be identical. */ - updateAppliedTransform() { + updateAppliedTransform () { let parent = this.parent; if (!parent) { this.ax = this.worldX; @@ -336,7 +336,7 @@ export class Bone implements Updatable { } /** Transforms a point from world coordinates to the bone's local coordinates. */ - worldToLocal(world: Vector2) { + worldToLocal (world: Vector2) { let invDet = 1 / (this.a * this.d - this.b * this.c); let x = world.x - this.worldX, y = world.y - this.worldY; world.x = x * this.d * invDet - y * this.b * invDet; @@ -345,7 +345,7 @@ export class Bone implements Updatable { } /** Transforms a point from the bone's local coordinates to world coordinates. */ - localToWorld(local: Vector2) { + localToWorld (local: Vector2) { let x = local.x, y = local.y; local.x = x * this.a + y * this.b + this.worldX; local.y = x * this.c + y * this.d + this.worldY; @@ -353,13 +353,13 @@ export class Bone implements Updatable { } /** Transforms a world rotation to a local rotation. */ - worldToLocalRotation(worldRotation: number) { + worldToLocalRotation (worldRotation: number) { let sin = MathUtils.sinDeg(worldRotation), cos = MathUtils.cosDeg(worldRotation); return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * MathUtils.radDeg + this.rotation - this.shearX; } /** Transforms a local rotation to a world rotation. */ - localToWorldRotation(localRotation: number) { + localToWorldRotation (localRotation: number) { localRotation -= this.rotation - this.shearX; let sin = MathUtils.sinDeg(localRotation), cos = MathUtils.cosDeg(localRotation); return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * MathUtils.radDeg; @@ -369,7 +369,7 @@ export class Bone implements Updatable { *

* After changes are made to the world transform, {@link #updateAppliedTransform()} should be called and {@link #update()} will * need to be called on any child bones, recursively. */ - rotateWorld(degrees: number) { + rotateWorld (degrees: number) { let a = this.a, b = this.b, c = this.c, d = this.d; let cos = MathUtils.cosDeg(degrees), sin = MathUtils.sinDeg(degrees); this.a = cos * a - sin * c; diff --git a/spine-ts/spine-core/src/BoneData.ts b/spine-ts/spine-core/src/BoneData.ts index 159d663d7..a236d2494 100644 --- a/spine-ts/spine-core/src/BoneData.ts +++ b/spine-ts/spine-core/src/BoneData.ts @@ -76,7 +76,7 @@ export class BoneData { * rendered at runtime. */ color = new Color(); - constructor(index: number, name: string, parent: BoneData) { + constructor (index: number, name: string, parent: BoneData) { if (index < 0) throw new Error("index must be >= 0."); if (!name) throw new Error("name cannot be null."); this.index = index; diff --git a/spine-ts/spine-core/src/ConstraintData.ts b/spine-ts/spine-core/src/ConstraintData.ts index de3614c3c..96156164f 100644 --- a/spine-ts/spine-core/src/ConstraintData.ts +++ b/spine-ts/spine-core/src/ConstraintData.ts @@ -29,5 +29,5 @@ /** The base class for all constraint datas. */ export abstract class ConstraintData { - constructor(public name: string, public order: number, public skinRequired: boolean) { } + constructor (public name: string, public order: number, public skinRequired: boolean) { } } diff --git a/spine-ts/spine-core/src/Event.ts b/spine-ts/spine-core/src/Event.ts index d34ecd5a0..720768310 100644 --- a/spine-ts/spine-core/src/Event.ts +++ b/spine-ts/spine-core/src/Event.ts @@ -43,7 +43,7 @@ export class Event { volume: number; balance: number; - constructor(time: number, data: EventData) { + constructor (time: number, data: EventData) { if (!data) throw new Error("data cannot be null."); this.time = time; this.data = data; diff --git a/spine-ts/spine-core/src/EventData.ts b/spine-ts/spine-core/src/EventData.ts index b77240c80..5429b9ccd 100644 --- a/spine-ts/spine-core/src/EventData.ts +++ b/spine-ts/spine-core/src/EventData.ts @@ -39,7 +39,7 @@ export class EventData { volume: number; balance: number; - constructor(name: string) { + constructor (name: string) { this.name = name; } } diff --git a/spine-ts/spine-core/src/IkConstraint.ts b/spine-ts/spine-core/src/IkConstraint.ts index c8e28181b..eca4444a5 100644 --- a/spine-ts/spine-core/src/IkConstraint.ts +++ b/spine-ts/spine-core/src/IkConstraint.ts @@ -65,7 +65,7 @@ export class IkConstraint implements Updatable { softness = 0; active = false; - constructor(data: IkConstraintData, skeleton: Skeleton) { + constructor (data: IkConstraintData, skeleton: Skeleton) { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; @@ -81,11 +81,11 @@ export class IkConstraint implements Updatable { this.target = skeleton.findBone(data.target.name); } - isActive() { + isActive () { return this.active; } - update() { + update () { if (this.mix == 0) return; let target = this.target; let bones = this.bones; @@ -100,7 +100,7 @@ export class IkConstraint implements Updatable { } /** Applies 1 bone IK. The target is specified in the world coordinate system. */ - apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number) { + apply1 (bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number) { let p = bone.parent; let pa = p.a, pb = p.b, pc = p.c, pd = p.d; let rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0; @@ -151,7 +151,7 @@ export class IkConstraint implements Updatable { /** Applies 2 bone IK. The target is specified in the world coordinate system. * @param child A direct descendant of the parent bone. */ - apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, uniform: boolean, softness: number, alpha: number) { + apply2 (parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, uniform: boolean, softness: number, alpha: number) { let px = parent.ax, py = parent.ay, psx = parent.ascaleX, psy = parent.ascaleY, sx = psx, sy = psy, csx = child.ascaleX; let os1 = 0, os2 = 0, s2 = 0; if (psx < 0) { diff --git a/spine-ts/spine-core/src/IkConstraintData.ts b/spine-ts/spine-core/src/IkConstraintData.ts index 780dfacdb..5743a80d0 100644 --- a/spine-ts/spine-core/src/IkConstraintData.ts +++ b/spine-ts/spine-core/src/IkConstraintData.ts @@ -61,7 +61,7 @@ export class IkConstraintData extends ConstraintData { /** For two bone IK, the distance from the maximum reach of the bones that rotation will slow. */ softness = 0; - constructor(name: string) { + constructor (name: string) { super(name, 0, false); } } diff --git a/spine-ts/spine-core/src/PathConstraint.ts b/spine-ts/spine-core/src/PathConstraint.ts index 1b98c8024..be5f95b0e 100644 --- a/spine-ts/spine-core/src/PathConstraint.ts +++ b/spine-ts/spine-core/src/PathConstraint.ts @@ -71,7 +71,7 @@ export class PathConstraint implements Updatable { active = false; - constructor(data: PathConstraintData, skeleton: Skeleton) { + constructor (data: PathConstraintData, skeleton: Skeleton) { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; @@ -86,11 +86,11 @@ export class PathConstraint implements Updatable { this.mixY = data.mixY; } - isActive() { + isActive () { return this.active; } - update() { + update () { let attachment = this.target.getAttachment(); if (!(attachment instanceof PathAttachment)) return; @@ -219,7 +219,7 @@ export class PathConstraint implements Updatable { } } - computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean) { + computeWorldPositions (path: PathAttachment, spacesCount: number, tangents: boolean) { let target = this.target; let position = this.position; let spaces = this.spaces, out = Utils.setArraySize(this.positions, spacesCount * 3 + 2), world: Array = null; @@ -452,21 +452,21 @@ export class PathConstraint implements Updatable { return out; } - addBeforePosition(p: number, temp: Array, i: number, out: Array, o: number) { + addBeforePosition (p: number, temp: Array, i: number, out: Array, o: number) { let x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx); out[o] = x1 + p * Math.cos(r); out[o + 1] = y1 + p * Math.sin(r); out[o + 2] = r; } - addAfterPosition(p: number, temp: Array, i: number, out: Array, o: number) { + addAfterPosition (p: number, temp: Array, i: number, out: Array, o: number) { let x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx); out[o] = x1 + p * Math.cos(r); out[o + 1] = y1 + p * Math.sin(r); out[o + 2] = r; } - addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, + addCurvePosition (p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array, o: number, tangents: boolean) { if (p == 0 || isNaN(p)) { out[o] = x1; diff --git a/spine-ts/spine-core/src/PathConstraintData.ts b/spine-ts/spine-core/src/PathConstraintData.ts index 2dcbbe33c..b3da75df7 100644 --- a/spine-ts/spine-core/src/PathConstraintData.ts +++ b/spine-ts/spine-core/src/PathConstraintData.ts @@ -65,7 +65,7 @@ export class PathConstraintData extends ConstraintData { mixX = 0; mixY = 0; - constructor(name: string) { + constructor (name: string) { super(name, 0, false); } } diff --git a/spine-ts/spine-core/src/Skeleton.ts b/spine-ts/spine-core/src/Skeleton.ts index b9b4bcdb4..153a9432e 100644 --- a/spine-ts/spine-core/src/Skeleton.ts +++ b/spine-ts/spine-core/src/Skeleton.ts @@ -94,7 +94,7 @@ export class Skeleton { /** Sets the skeleton Y position, which is added to the root bone worldY position. */ y = 0; - constructor(data: SkeletonData) { + constructor (data: SkeletonData) { if (!data) throw new Error("data cannot be null."); this.data = data; @@ -146,7 +146,7 @@ export class Skeleton { /** Caches information about bones and constraints. Must be called if the {@link #getSkin()} is modified or if bones, * constraints, or weighted path attachments are added or removed. */ - updateCache() { + updateCache () { let updateCache = this._updateCache; updateCache.length = 0; @@ -205,7 +205,7 @@ export class Skeleton { this.sortBone(bones[i]); } - sortIkConstraint(constraint: IkConstraint) { + sortIkConstraint (constraint: IkConstraint) { constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin && Utils.contains(this.skin.constraints, constraint.data, true))); if (!constraint.active) return; @@ -230,7 +230,7 @@ export class Skeleton { } } - sortPathConstraint(constraint: PathConstraint) { + sortPathConstraint (constraint: PathConstraint) { constraint.active = constraint.target.bone.isActive() && (!constraint.data.skinRequired || (this.skin && Utils.contains(this.skin.constraints, constraint.data, true))); if (!constraint.active) return; @@ -259,7 +259,7 @@ export class Skeleton { constrained[i].sorted = true; } - sortTransformConstraint(constraint: TransformConstraint) { + sortTransformConstraint (constraint: TransformConstraint) { constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin && Utils.contains(this.skin.constraints, constraint.data, true))); if (!constraint.active) return; @@ -287,7 +287,7 @@ export class Skeleton { constrained[i].sorted = true; } - sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone) { + sortPathConstraintAttachment (skin: Skin, slotIndex: number, slotBone: Bone) { let attachments = skin.attachments[slotIndex]; if (!attachments) return; for (let key in attachments) { @@ -295,7 +295,7 @@ export class Skeleton { } } - sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone) { + sortPathConstraintAttachmentWith (attachment: Attachment, slotBone: Bone) { if (!(attachment instanceof PathAttachment)) return; let pathBones = (attachment).bones; if (!pathBones) @@ -311,7 +311,7 @@ export class Skeleton { } } - sortBone(bone: Bone) { + sortBone (bone: Bone) { if (bone.sorted) return; let parent = bone.parent; if (parent) this.sortBone(parent); @@ -319,7 +319,7 @@ export class Skeleton { this._updateCache.push(bone); } - sortReset(bones: Array) { + sortReset (bones: Array) { for (let i = 0, n = bones.length; i < n; i++) { let bone = bones[i]; if (!bone.active) continue; @@ -332,7 +332,7 @@ export class Skeleton { * * See [World transforms](http://esotericsoftware.com/spine-runtime-skeletons#World-transforms) in the Spine * Runtimes Guide. */ - updateWorldTransform() { + updateWorldTransform () { let bones = this.bones; for (let i = 0, n = bones.length; i < n; i++) { let bone = bones[i]; @@ -350,7 +350,7 @@ export class Skeleton { updateCache[i].update(); } - updateWorldTransformWith(parent: Bone) { + updateWorldTransformWith (parent: Bone) { // Apply the parent bone transform to the root bone. The root bone always inherits scale, rotation and reflection. let rootBone = this.getRootBone(); let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; @@ -376,13 +376,13 @@ export class Skeleton { } /** Sets the bones, constraints, and slots to their setup pose values. */ - setToSetupPose() { + setToSetupPose () { this.setBonesToSetupPose(); this.setSlotsToSetupPose(); } /** Sets the bones and constraints to their setup pose values. */ - setBonesToSetupPose() { + setBonesToSetupPose () { let bones = this.bones; for (let i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); @@ -422,7 +422,7 @@ export class Skeleton { } /** Sets the slots and draw order to their setup pose values. */ - setSlotsToSetupPose() { + setSlotsToSetupPose () { let slots = this.slots; Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); for (let i = 0, n = slots.length; i < n; i++) @@ -430,13 +430,13 @@ export class Skeleton { } /** @returns May return null. */ - getRootBone() { + getRootBone () { if (this.bones.length == 0) return null; return this.bones[0]; } /** @returns May be null. */ - findBone(boneName: string) { + findBone (boneName: string) { if (!boneName) throw new Error("boneName cannot be null."); let bones = this.bones; for (let i = 0, n = bones.length; i < n; i++) { @@ -447,7 +447,7 @@ export class Skeleton { } /** @returns -1 if the bone was not found. */ - findBoneIndex(boneName: string) { + findBoneIndex (boneName: string) { if (!boneName) throw new Error("boneName cannot be null."); let bones = this.bones; for (let i = 0, n = bones.length; i < n; i++) @@ -458,7 +458,7 @@ export class Skeleton { /** Finds a slot by comparing each slot's name. It is more efficient to cache the results of this method than to call it * repeatedly. * @returns May be null. */ - findSlot(slotName: string) { + findSlot (slotName: string) { if (!slotName) throw new Error("slotName cannot be null."); let slots = this.slots; for (let i = 0, n = slots.length; i < n; i++) { @@ -469,7 +469,7 @@ export class Skeleton { } /** @returns -1 if the bone was not found. */ - findSlotIndex(slotName: string) { + findSlotIndex (slotName: string) { if (!slotName) throw new Error("slotName cannot be null."); let slots = this.slots; for (let i = 0, n = slots.length; i < n; i++) @@ -480,7 +480,7 @@ export class Skeleton { /** Sets a skin by name. * * See {@link #setSkin()}. */ - setSkinByName(skinName: string) { + setSkinByName (skinName: string) { let skin = this.data.findSkin(skinName); if (!skin) throw new Error("Skin not found: " + skinName); this.setSkin(skin); @@ -496,7 +496,7 @@ export class Skeleton { * {@link #setSlotsToSetupPose()}. Also, often {@link AnimationState#apply()} is called before the next time the * skeleton is rendered to allow any attachment keys in the current animation(s) to hide or show attachments from the new skin. * @param newSkin May be null. */ - setSkin(newSkin: Skin) { + setSkin (newSkin: Skin) { if (newSkin == this.skin) return; if (newSkin) { if (this.skin) @@ -523,7 +523,7 @@ export class Skeleton { * * See {@link #getAttachment()}. * @returns May be null. */ - getAttachmentByName(slotName: string, attachmentName: string): Attachment { + getAttachmentByName (slotName: string, attachmentName: string): Attachment { return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); } @@ -532,7 +532,7 @@ export class Skeleton { * * See [Runtime skins](http://esotericsoftware.com/spine-runtime-skins) in the Spine Runtimes Guide. * @returns May be null. */ - getAttachment(slotIndex: number, attachmentName: string): Attachment { + getAttachment (slotIndex: number, attachmentName: string): Attachment { if (!attachmentName) throw new Error("attachmentName cannot be null."); if (this.skin) { let attachment: Attachment = this.skin.getAttachment(slotIndex, attachmentName); @@ -545,7 +545,7 @@ export class Skeleton { /** A convenience method to set an attachment by finding the slot with {@link #findSlot()}, finding the attachment with * {@link #getAttachment()}, then setting the slot's {@link Slot#attachment}. * @param attachmentName May be null to clear the slot's attachment. */ - setAttachment(slotName: string, attachmentName: string) { + setAttachment (slotName: string, attachmentName: string) { if (!slotName) throw new Error("slotName cannot be null."); let slots = this.slots; for (let i = 0, n = slots.length; i < n; i++) { @@ -567,7 +567,7 @@ export class Skeleton { /** Finds an IK constraint by comparing each IK constraint's name. It is more efficient to cache the results of this method * than to call it repeatedly. * @return May be null. */ - findIkConstraint(constraintName: string) { + findIkConstraint (constraintName: string) { if (!constraintName) throw new Error("constraintName cannot be null."); let ikConstraints = this.ikConstraints; for (let i = 0, n = ikConstraints.length; i < n; i++) { @@ -580,7 +580,7 @@ export class Skeleton { /** Finds a transform constraint by comparing each transform constraint's name. It is more efficient to cache the results of * this method than to call it repeatedly. * @return May be null. */ - findTransformConstraint(constraintName: string) { + findTransformConstraint (constraintName: string) { if (!constraintName) throw new Error("constraintName cannot be null."); let transformConstraints = this.transformConstraints; for (let i = 0, n = transformConstraints.length; i < n; i++) { @@ -593,7 +593,7 @@ export class Skeleton { /** Finds a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method * than to call it repeatedly. * @return May be null. */ - findPathConstraint(constraintName: string) { + findPathConstraint (constraintName: string) { if (!constraintName) throw new Error("constraintName cannot be null."); let pathConstraints = this.pathConstraints; for (let i = 0, n = pathConstraints.length; i < n; i++) { @@ -607,7 +607,7 @@ export class Skeleton { * @param offset An output value, the distance from the skeleton origin to the bottom left corner of the AABB. * @param size An output value, the width and height of the AABB. * @param temp Working memory to temporarily store attachments' computed world vertices. */ - getBounds(offset: Vector2, size: Vector2, temp: Array = new Array(2)) { + getBounds (offset: Vector2, size: Vector2, temp: Array = new Array(2)) { if (!offset) throw new Error("offset cannot be null."); if (!size) throw new Error("size cannot be null."); let drawOrder = this.drawOrder; @@ -643,7 +643,7 @@ export class Skeleton { } /** Increments the skeleton's {@link #time}. */ - update(delta: number) { + update (delta: number) { this.time += delta; } } diff --git a/spine-ts/spine-core/src/SkeletonBinary.ts b/spine-ts/spine-core/src/SkeletonBinary.ts index 01e9cffca..bd0866d0e 100644 --- a/spine-ts/spine-core/src/SkeletonBinary.ts +++ b/spine-ts/spine-core/src/SkeletonBinary.ts @@ -57,11 +57,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(); @@ -247,7 +247,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; @@ -282,7 +282,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(); @@ -441,7 +441,7 @@ export class SkeletonBinary { return null; } - 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(); @@ -466,7 +466,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++) @@ -478,7 +478,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++) @@ -486,7 +486,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; @@ -960,30 +960,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) { @@ -1005,12 +1005,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: @@ -1041,13 +1041,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; } } @@ -1058,7 +1058,7 @@ class LinkedMesh { mesh: MeshAttachment; inheritDeform: 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; @@ -1068,12 +1068,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); @@ -1092,7 +1092,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); @@ -1113,7 +1113,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/SkeletonBounds.ts b/spine-ts/spine-core/src/SkeletonBounds.ts index cf370b450..3596c27ef 100644 --- a/spine-ts/spine-core/src/SkeletonBounds.ts +++ b/spine-ts/spine-core/src/SkeletonBounds.ts @@ -61,7 +61,7 @@ export class SkeletonBounds { * box's polygon. * @param updateAabb If true, the axis aligned bounding box containing all the polygons is computed. If false, the * SkeletonBounds AABB methods will always return true. */ - update(skeleton: Skeleton, updateAabb: boolean) { + update (skeleton: Skeleton, updateAabb: boolean) { if (!skeleton) throw new Error("skeleton cannot be null."); let boundingBoxes = this.boundingBoxes; let polygons = this.polygons; @@ -100,7 +100,7 @@ export class SkeletonBounds { } } - aabbCompute() { + aabbCompute () { let minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; let polygons = this.polygons; for (let i = 0, n = polygons.length; i < n; i++) { @@ -122,12 +122,12 @@ export class SkeletonBounds { } /** Returns true if the axis aligned bounding box contains the point. */ - aabbContainsPoint(x: number, y: number) { + aabbContainsPoint (x: number, y: number) { return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; } /** Returns true if the axis aligned bounding box intersects the line segment. */ - aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number) { + aabbIntersectsSegment (x1: number, y1: number, x2: number, y2: number) { let minX = this.minX; let minY = this.minY; let maxX = this.maxX; @@ -147,13 +147,13 @@ export class SkeletonBounds { } /** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */ - aabbIntersectsSkeleton(bounds: SkeletonBounds) { + aabbIntersectsSkeleton (bounds: SkeletonBounds) { return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; } /** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more * efficient to only call this method if {@link #aabbContainsPoint(float, float)} returns true. */ - containsPoint(x: number, y: number): BoundingBoxAttachment { + containsPoint (x: number, y: number): BoundingBoxAttachment { let polygons = this.polygons; for (let i = 0, n = polygons.length; i < n; i++) if (this.containsPointPolygon(polygons[i], x, y)) return this.boundingBoxes[i]; @@ -161,7 +161,7 @@ export class SkeletonBounds { } /** Returns true if the polygon contains the point. */ - containsPointPolygon(polygon: NumberArrayLike, x: number, y: number) { + containsPointPolygon (polygon: NumberArrayLike, x: number, y: number) { let vertices = polygon; let nn = polygon.length; @@ -182,7 +182,7 @@ export class SkeletonBounds { /** Returns the first bounding box attachment that contains any part of the line segment, or null. When doing many checks, it * is usually more efficient to only call this method if {@link #aabbIntersectsSegment()} returns * true. */ - intersectsSegment(x1: number, y1: number, x2: number, y2: number) { + intersectsSegment (x1: number, y1: number, x2: number, y2: number) { let polygons = this.polygons; for (let i = 0, n = polygons.length; i < n; i++) if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) return this.boundingBoxes[i]; @@ -190,7 +190,7 @@ export class SkeletonBounds { } /** Returns true if the polygon contains any part of the line segment. */ - intersectsSegmentPolygon(polygon: NumberArrayLike, x1: number, y1: number, x2: number, y2: number) { + intersectsSegmentPolygon (polygon: NumberArrayLike, x1: number, y1: number, x2: number, y2: number) { let vertices = polygon; let nn = polygon.length; @@ -214,19 +214,19 @@ export class SkeletonBounds { } /** Returns the polygon for the specified bounding box, or null. */ - getPolygon(boundingBox: BoundingBoxAttachment) { + getPolygon (boundingBox: BoundingBoxAttachment) { if (!boundingBox) throw new Error("boundingBox cannot be null."); let index = this.boundingBoxes.indexOf(boundingBox); return index == -1 ? null : this.polygons[index]; } /** The width of the axis aligned bounding box. */ - getWidth() { + getWidth () { return this.maxX - this.minX; } /** The height of the axis aligned bounding box. */ - getHeight() { + getHeight () { return this.maxY - this.minY; } } \ No newline at end of file diff --git a/spine-ts/spine-core/src/SkeletonClipping.ts b/spine-ts/spine-core/src/SkeletonClipping.ts index 4c826afc9..37c0cc5d2 100644 --- a/spine-ts/spine-core/src/SkeletonClipping.ts +++ b/spine-ts/spine-core/src/SkeletonClipping.ts @@ -43,7 +43,7 @@ export class SkeletonClipping { private clipAttachment: ClippingAttachment; private clippingPolygons: Array>; - clipStart(slot: Slot, clip: ClippingAttachment): number { + clipStart (slot: Slot, clip: ClippingAttachment): number { if (this.clipAttachment) return 0; this.clipAttachment = clip; @@ -63,11 +63,11 @@ export class SkeletonClipping { return clippingPolygons.length; } - clipEndWithSlot(slot: Slot) { + clipEndWithSlot (slot: Slot) { if (this.clipAttachment && this.clipAttachment.endSlot == slot.data) this.clipEnd(); } - clipEnd() { + clipEnd () { if (!this.clipAttachment) return; this.clipAttachment = null; this.clippingPolygons = null; @@ -76,11 +76,11 @@ export class SkeletonClipping { this.clippingPolygon.length = 0; } - isClipping(): boolean { + isClipping (): boolean { return this.clipAttachment != null; } - clipTriangles(vertices: NumberArrayLike, verticesLength: number, triangles: NumberArrayLike, trianglesLength: number, uvs: NumberArrayLike, + clipTriangles (vertices: NumberArrayLike, verticesLength: number, triangles: NumberArrayLike, trianglesLength: number, uvs: NumberArrayLike, light: Color, dark: Color, twoColor: boolean) { let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; @@ -229,7 +229,7 @@ export class SkeletonClipping { /** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping * area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */ - clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array) { + clip (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array, output: Array) { let originalOutput = output; let clipped = false; @@ -324,7 +324,7 @@ export class SkeletonClipping { return clipped; } - public static makeClockwise(polygon: NumberArrayLike) { + public static makeClockwise (polygon: NumberArrayLike) { let vertices = polygon; let verticeslength = polygon.length; diff --git a/spine-ts/spine-core/src/SkeletonData.ts b/spine-ts/spine-core/src/SkeletonData.ts index 735f3a517..3973c8602 100644 --- a/spine-ts/spine-core/src/SkeletonData.ts +++ b/spine-ts/spine-core/src/SkeletonData.ts @@ -104,7 +104,7 @@ export class SkeletonData { /** Finds a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it * multiple times. * @returns May be null. */ - findBone(boneName: string) { + findBone (boneName: string) { if (!boneName) throw new Error("boneName cannot be null."); let bones = this.bones; for (let i = 0, n = bones.length; i < n; i++) { @@ -114,7 +114,7 @@ export class SkeletonData { return null; } - findBoneIndex(boneName: string) { + findBoneIndex (boneName: string) { if (!boneName) throw new Error("boneName cannot be null."); let bones = this.bones; for (let i = 0, n = bones.length; i < n; i++) @@ -125,7 +125,7 @@ export class SkeletonData { /** Finds a slot by comparing each slot's name. It is more efficient to cache the results of this method than to call it * multiple times. * @returns May be null. */ - findSlot(slotName: string) { + findSlot (slotName: string) { if (!slotName) throw new Error("slotName cannot be null."); let slots = this.slots; for (let i = 0, n = slots.length; i < n; i++) { @@ -135,7 +135,7 @@ export class SkeletonData { return null; } - findSlotIndex(slotName: string) { + findSlotIndex (slotName: string) { if (!slotName) throw new Error("slotName cannot be null."); let slots = this.slots; for (let i = 0, n = slots.length; i < n; i++) @@ -146,7 +146,7 @@ export class SkeletonData { /** Finds a skin by comparing each skin's name. It is more efficient to cache the results of this method than to call it * multiple times. * @returns May be null. */ - findSkin(skinName: string) { + findSkin (skinName: string) { if (!skinName) throw new Error("skinName cannot be null."); let skins = this.skins; for (let i = 0, n = skins.length; i < n; i++) { @@ -159,7 +159,7 @@ export class SkeletonData { /** Finds an event by comparing each events's name. It is more efficient to cache the results of this method than to call it * multiple times. * @returns May be null. */ - findEvent(eventDataName: string) { + findEvent (eventDataName: string) { if (!eventDataName) throw new Error("eventDataName cannot be null."); let events = this.events; for (let i = 0, n = events.length; i < n; i++) { @@ -172,7 +172,7 @@ export class SkeletonData { /** Finds an animation by comparing each animation's name. It is more efficient to cache the results of this method than to * call it multiple times. * @returns May be null. */ - findAnimation(animationName: string) { + findAnimation (animationName: string) { if (!animationName) throw new Error("animationName cannot be null."); let animations = this.animations; for (let i = 0, n = animations.length; i < n; i++) { @@ -185,7 +185,7 @@ export class SkeletonData { /** Finds an IK constraint by comparing each IK constraint's name. It is more efficient to cache the results of this method * than to call it multiple times. * @return May be null. */ - findIkConstraint(constraintName: string) { + findIkConstraint (constraintName: string) { if (!constraintName) throw new Error("constraintName cannot be null."); let ikConstraints = this.ikConstraints; for (let i = 0, n = ikConstraints.length; i < n; i++) { @@ -198,7 +198,7 @@ export class SkeletonData { /** Finds a transform constraint by comparing each transform constraint's name. It is more efficient to cache the results of * this method than to call it multiple times. * @return May be null. */ - findTransformConstraint(constraintName: string) { + findTransformConstraint (constraintName: string) { if (!constraintName) throw new Error("constraintName cannot be null."); let transformConstraints = this.transformConstraints; for (let i = 0, n = transformConstraints.length; i < n; i++) { @@ -211,7 +211,7 @@ export class SkeletonData { /** Finds a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method * than to call it multiple times. * @return May be null. */ - findPathConstraint(constraintName: string) { + findPathConstraint (constraintName: string) { if (!constraintName) throw new Error("constraintName cannot be null."); let pathConstraints = this.pathConstraints; for (let i = 0, n = pathConstraints.length; i < n; i++) { diff --git a/spine-ts/spine-core/src/SkeletonJson.ts b/spine-ts/spine-core/src/SkeletonJson.ts index 930d929eb..04a5e1624 100644 --- a/spine-ts/spine-core/src/SkeletonJson.ts +++ b/spine-ts/spine-core/src/SkeletonJson.ts @@ -57,11 +57,11 @@ export class SkeletonJson { scale = 1; private linkedMeshes = new Array(); - constructor(attachmentLoader: AttachmentLoader) { + constructor (attachmentLoader: AttachmentLoader) { this.attachmentLoader = attachmentLoader; } - readSkeletonData(json: string | any): SkeletonData { + readSkeletonData (json: string | any): SkeletonData { let scale = this.scale; let skeletonData = new SkeletonData(); let root = typeof (json) === "string" ? JSON.parse(json) : json; @@ -291,7 +291,7 @@ export class SkeletonJson { return skeletonData; } - readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment { + readAttachment (map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment { let scale = this.scale; name = getValue(map, "name", name); @@ -399,7 +399,7 @@ export class SkeletonJson { return null; } - readVertices(map: any, attachment: VertexAttachment, verticesLength: number) { + readVertices (map: any, attachment: VertexAttachment, verticesLength: number) { let scale = this.scale; attachment.worldVerticesLength = verticesLength; let vertices: Array = map.vertices; @@ -428,7 +428,7 @@ export class SkeletonJson { attachment.vertices = Utils.toFloatArray(weights); } - readAnimation(map: any, name: string, skeletonData: SkeletonData) { + readAnimation (map: any, name: string, skeletonData: SkeletonData) { let scale = this.scale; let timelines = new Array(); @@ -899,7 +899,7 @@ class LinkedMesh { mesh: MeshAttachment; inheritDeform: 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; @@ -908,7 +908,7 @@ class LinkedMesh { } } -function readTimeline1(keys: any[], timeline: CurveTimeline1, defaultValue: number, scale: number) { +function readTimeline1 (keys: any[], timeline: CurveTimeline1, defaultValue: number, scale: number) { let keyMap = keys[0]; let time = getValue(keyMap, "time", 0); let value = getValue(keyMap, "value", defaultValue) * scale; @@ -929,7 +929,7 @@ function readTimeline1(keys: any[], timeline: CurveTimeline1, defaultValue: numb } } -function readTimeline2(keys: any[], timeline: CurveTimeline2, name1: string, name2: string, defaultValue: number, scale: number) { +function readTimeline2 (keys: any[], timeline: CurveTimeline2, name1: string, name2: string, defaultValue: number, scale: number) { let keyMap = keys[0]; let time = getValue(keyMap, "time", 0); let value1 = getValue(keyMap, name1, defaultValue) * scale; @@ -957,7 +957,7 @@ function readTimeline2(keys: any[], timeline: CurveTimeline2, name1: string, nam } } -function readCurve(curve: any, timeline: CurveTimeline, bezier: number, frame: number, value: number, time1: number, time2: number, +function readCurve (curve: any, timeline: CurveTimeline, bezier: number, frame: number, value: number, time1: number, time2: number, value1: number, value2: number, scale: number) { if (curve == "stepped") { timeline.setStepped(frame); @@ -972,6 +972,6 @@ function readCurve(curve: any, timeline: CurveTimeline, bezier: number, frame: n return bezier + 1; } -function getValue(map: any, property: string, defaultValue: any) { +function getValue (map: any, property: string, defaultValue: any) { return map[property] !== undefined ? map[property] : defaultValue; } diff --git a/spine-ts/spine-core/src/Skin.ts b/spine-ts/spine-core/src/Skin.ts index 49254db1f..b58866801 100644 --- a/spine-ts/spine-core/src/Skin.ts +++ b/spine-ts/spine-core/src/Skin.ts @@ -36,7 +36,7 @@ import { StringMap } from "./Utils"; /** Stores an entry in the skin consisting of the slot index, name, and attachment **/ export class SkinEntry { - constructor(public slotIndex: number, public name: string, public attachment: Attachment) { } + constructor (public slotIndex: number, public name: string, public attachment: Attachment) { } } /** Stores attachments by slot index and attachment name. @@ -51,13 +51,13 @@ export class Skin { bones = Array(); constraints = new Array(); - constructor(name: string) { + constructor (name: string) { if (!name) throw new Error("name cannot be null."); this.name = name; } /** Adds an attachment to the skin for the specified slot index and name. */ - setAttachment(slotIndex: number, name: string, attachment: Attachment) { + setAttachment (slotIndex: number, name: string, attachment: Attachment) { if (!attachment) throw new Error("attachment cannot be null."); let attachments = this.attachments; if (slotIndex >= attachments.length) attachments.length = slotIndex + 1; @@ -66,7 +66,7 @@ export class Skin { } /** Adds all attachments, bones, and constraints from the specified skin to this skin. */ - addSkin(skin: Skin) { + addSkin (skin: Skin) { for (let i = 0; i < skin.bones.length; i++) { let bone = skin.bones[i]; let contained = false; @@ -100,7 +100,7 @@ export class Skin { /** Adds all bones and constraints and copies of all attachments from the specified skin to this skin. Mesh attachments are not * copied, instead a new linked mesh is created. The attachment copies can be modified without affecting the originals. */ - copySkin(skin: Skin) { + copySkin (skin: Skin) { for (let i = 0; i < skin.bones.length; i++) { let bone = skin.bones[i]; let contained = false; @@ -140,19 +140,19 @@ export class Skin { } /** Returns the attachment for the specified slot index and name, or null. */ - getAttachment(slotIndex: number, name: string): Attachment { + getAttachment (slotIndex: number, name: string): Attachment { let dictionary = this.attachments[slotIndex]; return dictionary ? dictionary[name] : null; } /** Removes the attachment in the skin for the specified slot index and name, if any. */ - removeAttachment(slotIndex: number, name: string) { + removeAttachment (slotIndex: number, name: string) { let dictionary = this.attachments[slotIndex]; if (dictionary) dictionary[name] = null; } /** Returns all attachments in this skin. */ - getAttachments(): Array { + getAttachments (): Array { let entries = new Array(); for (var i = 0; i < this.attachments.length; i++) { let slotAttachments = this.attachments[i]; @@ -167,7 +167,7 @@ export class Skin { } /** Returns all attachments in this skin for the specified slot index. */ - getAttachmentsForSlot(slotIndex: number, attachments: Array) { + getAttachmentsForSlot (slotIndex: number, attachments: Array) { let slotAttachments = this.attachments[slotIndex]; if (slotAttachments) { for (let name in slotAttachments) { @@ -178,14 +178,14 @@ export class Skin { } /** Clears all attachments, bones, and constraints. */ - clear() { + clear () { this.attachments.length = 0; this.bones.length = 0; this.constraints.length = 0; } /** Attach each attachment in this skin if the corresponding attachment in the old skin is currently attached. */ - attachAll(skeleton: Skeleton, oldSkin: Skin) { + attachAll (skeleton: Skeleton, oldSkin: Skin) { let slotIndex = 0; for (let i = 0; i < skeleton.slots.length; i++) { let slot = skeleton.slots[i]; diff --git a/spine-ts/spine-core/src/Slot.ts b/spine-ts/spine-core/src/Slot.ts index 52f23d9de..dcf6d2f47 100644 --- a/spine-ts/spine-core/src/Slot.ts +++ b/spine-ts/spine-core/src/Slot.ts @@ -63,7 +63,7 @@ export class Slot { * See {@link VertexAttachment#computeWorldVertices()} and {@link DeformTimeline}. */ deform = new Array(); - constructor(data: SlotData, bone: Bone) { + constructor (data: SlotData, bone: Bone) { if (!data) throw new Error("data cannot be null."); if (!bone) throw new Error("bone cannot be null."); this.data = data; @@ -74,12 +74,12 @@ export class Slot { } /** The skeleton this slot belongs to. */ - getSkeleton(): Skeleton { + getSkeleton (): Skeleton { return this.bone.skeleton; } /** The current attachment for the slot, or null if the slot has no attachment. */ - getAttachment(): Attachment { + getAttachment (): Attachment { return this.attachment; } @@ -87,7 +87,7 @@ export class Slot { * The deform is not cleared if the old attachment has the same {@link VertexAttachment#getDeformAttachment()} as the specified * attachment. * @param attachment May be null. */ - setAttachment(attachment: Attachment) { + setAttachment (attachment: Attachment) { if (this.attachment == attachment) return; if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || (attachment).deformAttachment != (this.attachment).deformAttachment) { @@ -97,18 +97,18 @@ export class Slot { this.attachmentTime = this.bone.skeleton.time; } - setAttachmentTime(time: number) { + setAttachmentTime (time: number) { this.attachmentTime = this.bone.skeleton.time - time; } /** The time that has elapsed since the last time the attachment was set or cleared. Relies on Skeleton * {@link Skeleton#time}. */ - getAttachmentTime(): number { + getAttachmentTime (): number { return this.bone.skeleton.time - this.attachmentTime; } /** Sets this slot to the setup pose. */ - setToSetupPose() { + setToSetupPose () { this.color.setFromColor(this.data.color); if (this.darkColor) this.darkColor.setFromColor(this.data.darkColor); if (!this.data.attachmentName) diff --git a/spine-ts/spine-core/src/SlotData.ts b/spine-ts/spine-core/src/SlotData.ts index 0d95ebe1e..c118406c0 100644 --- a/spine-ts/spine-core/src/SlotData.ts +++ b/spine-ts/spine-core/src/SlotData.ts @@ -55,7 +55,7 @@ export class SlotData { /** The blend mode for drawing the slot's attachment. */ blendMode: BlendMode; - constructor(index: number, name: string, boneData: BoneData) { + constructor (index: number, name: string, boneData: BoneData) { if (index < 0) throw new Error("index must be >= 0."); if (!name) throw new Error("name cannot be null."); if (!boneData) throw new Error("boneData cannot be null."); diff --git a/spine-ts/spine-core/src/Texture.ts b/spine-ts/spine-core/src/Texture.ts index 2a995323a..fd04ed343 100644 --- a/spine-ts/spine-core/src/Texture.ts +++ b/spine-ts/spine-core/src/Texture.ts @@ -30,17 +30,17 @@ export abstract class Texture { protected _image: HTMLImageElement | ImageBitmap; - constructor(image: HTMLImageElement | ImageBitmap) { + constructor (image: HTMLImageElement | ImageBitmap) { this._image = image; } - getImage(): HTMLImageElement | ImageBitmap { + getImage (): HTMLImageElement | ImageBitmap { return this._image; } - abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void; - abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void; - abstract dispose(): void; + abstract setFilters (minFilter: TextureFilter, magFilter: TextureFilter): void; + abstract setWraps (uWrap: TextureWrap, vWrap: TextureWrap): void; + abstract dispose (): void; } export enum TextureFilter { @@ -70,7 +70,7 @@ export class TextureRegion { } export class FakeTexture extends Texture { - setFilters(minFilter: TextureFilter, magFilter: TextureFilter) { } - setWraps(uWrap: TextureWrap, vWrap: TextureWrap) { } - dispose() { } + setFilters (minFilter: TextureFilter, magFilter: TextureFilter) { } + setWraps (uWrap: TextureWrap, vWrap: TextureWrap) { } + dispose () { } } diff --git a/spine-ts/spine-core/src/TextureAtlas.ts b/spine-ts/spine-core/src/TextureAtlas.ts index d98fc90db..78b24be50 100644 --- a/spine-ts/spine-core/src/TextureAtlas.ts +++ b/spine-ts/spine-core/src/TextureAtlas.ts @@ -35,7 +35,7 @@ export class TextureAtlas implements Disposable { pages = new Array(); regions = new Array(); - constructor(atlasText: string) { + constructor (atlasText: string) { let reader = new TextureAtlasReader(atlasText); let entry = new Array(4); let page: TextureAtlasPage = null; @@ -176,7 +176,7 @@ export class TextureAtlas implements Disposable { } } - findRegion(name: string): TextureAtlasRegion { + findRegion (name: string): TextureAtlasRegion { for (let i = 0; i < this.regions.length; i++) { if (this.regions[i].name == name) { return this.regions[i]; @@ -185,12 +185,12 @@ export class TextureAtlas implements Disposable { return null; } - setTextures(assetManager: AssetManagerBase, pathPrefix: string = "") { + setTextures (assetManager: AssetManagerBase, pathPrefix: string = "") { for (let page of this.pages) page.setTexture(assetManager.get(pathPrefix + page.name)); } - dispose() { + dispose () { for (let i = 0; i < this.pages.length; i++) { this.pages[i].texture.dispose(); } @@ -201,17 +201,17 @@ class TextureAtlasReader { lines: Array; index: number = 0; - constructor(text: string) { + constructor (text: string) { this.lines = text.split(/\r\n|\r|\n/); } - readLine(): string { + readLine (): string { if (this.index >= this.lines.length) return null; return this.lines[this.index++]; } - readEntry(entry: string[], line: string): number { + readEntry (entry: string[], line: string): number { if (!line) return 0; line = line.trim(); if (line.length == 0) return 0; @@ -243,7 +243,7 @@ export class TextureAtlasPage { height: number; pma: boolean; - setTexture(texture: Texture) { + setTexture (texture: Texture) { this.texture = texture; texture.setFilters(this.minFilter, this.magFilter); texture.setWraps(this.uWrap, this.vWrap); diff --git a/spine-ts/spine-core/src/TransformConstraint.ts b/spine-ts/spine-core/src/TransformConstraint.ts index 2be520883..a1f39c1ed 100644 --- a/spine-ts/spine-core/src/TransformConstraint.ts +++ b/spine-ts/spine-core/src/TransformConstraint.ts @@ -54,7 +54,7 @@ export class TransformConstraint implements Updatable { temp = new Vector2(); active = false; - constructor(data: TransformConstraintData, skeleton: Skeleton) { + constructor (data: TransformConstraintData, skeleton: Skeleton) { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; @@ -70,11 +70,11 @@ export class TransformConstraint implements Updatable { this.target = skeleton.findBone(data.target.name); } - isActive() { + isActive () { return this.active; } - update() { + update () { if (this.mixRotate == 0 && this.mixX == 0 && this.mixY == 0 && this.mixScaleX == 0 && this.mixScaleX == 0 && this.mixShearY == 0) return; if (this.data.local) { @@ -90,7 +90,7 @@ export class TransformConstraint implements Updatable { } } - applyAbsoluteWorld() { + applyAbsoluteWorld () { let mixRotate = this.mixRotate, mixX = this.mixX, mixY = this.mixY, mixScaleX = this.mixScaleX, mixScaleY = this.mixScaleY, mixShearY = this.mixShearY; let translate = mixX != 0 || mixY != 0; @@ -158,7 +158,7 @@ export class TransformConstraint implements Updatable { } } - applyRelativeWorld() { + applyRelativeWorld () { let mixRotate = this.mixRotate, mixX = this.mixX, mixY = this.mixY, mixScaleX = this.mixScaleX, mixScaleY = this.mixScaleY, mixShearY = this.mixShearY; let translate = mixX != 0 || mixY != 0; @@ -222,7 +222,7 @@ export class TransformConstraint implements Updatable { } } - applyAbsoluteLocal() { + applyAbsoluteLocal () { let mixRotate = this.mixRotate, mixX = this.mixX, mixY = this.mixY, mixScaleX = this.mixScaleX, mixScaleY = this.mixScaleY, mixShearY = this.mixShearY; @@ -260,7 +260,7 @@ export class TransformConstraint implements Updatable { } } - applyRelativeLocal() { + applyRelativeLocal () { let mixRotate = this.mixRotate, mixX = this.mixX, mixY = this.mixY, mixScaleX = this.mixScaleX, mixScaleY = this.mixScaleY, mixShearY = this.mixShearY; diff --git a/spine-ts/spine-core/src/TransformConstraintData.ts b/spine-ts/spine-core/src/TransformConstraintData.ts index 36e64f484..3c74d87fb 100644 --- a/spine-ts/spine-core/src/TransformConstraintData.ts +++ b/spine-ts/spine-core/src/TransformConstraintData.ts @@ -69,7 +69,7 @@ export class TransformConstraintData extends ConstraintData { relative = false; local = false; - constructor(name: string) { + constructor (name: string) { super(name, 0, false); } } diff --git a/spine-ts/spine-core/src/Triangulator.ts b/spine-ts/spine-core/src/Triangulator.ts index 5334219b6..0ebc56e3a 100644 --- a/spine-ts/spine-core/src/Triangulator.ts +++ b/spine-ts/spine-core/src/Triangulator.ts @@ -45,7 +45,7 @@ export class Triangulator { return new Array(); }); - public triangulate(verticesArray: NumberArrayLike): Array { + public triangulate (verticesArray: NumberArrayLike): Array { let vertices = verticesArray; let vertexCount = verticesArray.length >> 1; @@ -121,7 +121,7 @@ export class Triangulator { return triangles; } - decompose(verticesArray: Array, triangles: Array): Array> { + decompose (verticesArray: Array, triangles: Array): Array> { let vertices = verticesArray; let convexPolygons = this.convexPolygons; this.polygonPool.freeAll(convexPolygons); @@ -250,7 +250,7 @@ export class Triangulator { return convexPolygons; } - private static isConcave(index: number, vertexCount: number, vertices: NumberArrayLike, indices: NumberArrayLike): boolean { + private static isConcave (index: number, vertexCount: number, vertices: NumberArrayLike, indices: NumberArrayLike): boolean { let previous = indices[(vertexCount + index - 1) % vertexCount] << 1; let current = indices[index] << 1; let next = indices[(index + 1) % vertexCount] << 1; @@ -258,11 +258,11 @@ export class Triangulator { vertices[next + 1]); } - private static positiveArea(p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number): boolean { + private static positiveArea (p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number): boolean { return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; } - private static winding(p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number): number { + private static winding (p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number): number { let px = p2x - p1x, py = p2y - p1y; return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; } diff --git a/spine-ts/spine-core/src/Updatable.ts b/spine-ts/spine-core/src/Updatable.ts index b2d7170ad..0fc7f7347 100644 --- a/spine-ts/spine-core/src/Updatable.ts +++ b/spine-ts/spine-core/src/Updatable.ts @@ -29,11 +29,11 @@ /** The interface for items updated by {@link Skeleton#updateWorldTransform()}. */ export interface Updatable { - update(): void; + update (): void; /** Returns false when this item has not been updated because a skin is required and the {@link Skeleton#skin active skin} * does not contain this item. * @see Skin#getBones() * @see Skin#getConstraints() */ - isActive(): boolean; + isActive (): boolean; } diff --git a/spine-ts/spine-core/src/Utils.ts b/spine-ts/spine-core/src/Utils.ts index a878846c3..9889cf6df 100644 --- a/spine-ts/spine-core/src/Utils.ts +++ b/spine-ts/spine-core/src/Utils.ts @@ -37,21 +37,21 @@ export interface StringMap { export class IntSet { array = new Array(); - add(value: number): boolean { + add (value: number): boolean { let contains = this.contains(value); this.array[value | 0] = value | 0; return !contains; } - contains(value: number) { + contains (value: number) { return this.array[value | 0] != undefined; } - remove(value: number) { + remove (value: number) { this.array[value | 0] = undefined; } - clear() { + clear () { this.array.length = 0; } } @@ -60,7 +60,7 @@ export class StringSet { entries: StringMap = {}; size = 0; - add(value: string): boolean { + add (value: string): boolean { let contains = this.entries[value]; this.entries[value] = true; if (!contains) { @@ -70,18 +70,18 @@ export class StringSet { return false; } - addAll(values: string[]): boolean { + addAll (values: string[]): boolean { let oldSize = this.size; for (var i = 0, n = values.length; i < n; i++) this.add(values[i]); return oldSize != this.size; } - contains(value: string) { + contains (value: string) { return this.entries[value]; } - clear() { + clear () { this.entries = {}; this.size = 0; } @@ -93,11 +93,11 @@ export interface NumberArrayLike { } export interface Disposable { - dispose(): void; + dispose (): void; } export interface Restorable { - restore(): void; + restore (): void; } export class Color { @@ -107,10 +107,10 @@ export class Color { public static BLUE = new Color(0, 0, 1, 1); public static MAGENTA = new Color(1, 0, 1, 1); - constructor(public r: number = 0, public g: number = 0, public b: number = 0, public a: number = 0) { + constructor (public r: number = 0, public g: number = 0, public b: number = 0, public a: number = 0) { } - set(r: number, g: number, b: number, a: number) { + set (r: number, g: number, b: number, a: number) { this.r = r; this.g = g; this.b = b; @@ -118,7 +118,7 @@ export class Color { return this.clamp(); } - setFromColor(c: Color) { + setFromColor (c: Color) { this.r = c.r; this.g = c.g; this.b = c.b; @@ -126,7 +126,7 @@ export class Color { return this; } - setFromString(hex: string) { + setFromString (hex: string) { hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; this.r = parseInt(hex.substr(0, 2), 16) / 255; this.g = parseInt(hex.substr(2, 2), 16) / 255; @@ -135,7 +135,7 @@ export class Color { return this; } - add(r: number, g: number, b: number, a: number) { + add (r: number, g: number, b: number, a: number) { this.r += r; this.g += g; this.b += b; @@ -143,7 +143,7 @@ export class Color { return this.clamp(); } - clamp() { + clamp () { if (this.r < 0) this.r = 0; else if (this.r > 1) this.r = 1; @@ -158,20 +158,20 @@ export class Color { return this; } - static rgba8888ToColor(color: Color, value: number) { + static rgba8888ToColor (color: Color, value: number) { color.r = ((value & 0xff000000) >>> 24) / 255; color.g = ((value & 0x00ff0000) >>> 16) / 255; color.b = ((value & 0x0000ff00) >>> 8) / 255; color.a = ((value & 0x000000ff)) / 255; } - static rgb888ToColor(color: Color, value: number) { + static rgb888ToColor (color: Color, value: number) { color.r = ((value & 0x00ff0000) >>> 16) / 255; color.g = ((value & 0x0000ff00) >>> 8) / 255; color.b = ((value & 0x000000ff)) / 255; } - static fromString(hex: string): Color { + static fromString (hex: string): Color { return new Color().setFromString(hex); } } @@ -184,52 +184,52 @@ export class MathUtils { static degreesToRadians = MathUtils.PI / 180; static degRad = MathUtils.degreesToRadians; - static clamp(value: number, min: number, max: number) { + static clamp (value: number, min: number, max: number) { if (value < min) return min; if (value > max) return max; return value; } - static cosDeg(degrees: number) { + static cosDeg (degrees: number) { return Math.cos(degrees * MathUtils.degRad); } - static sinDeg(degrees: number) { + static sinDeg (degrees: number) { return Math.sin(degrees * MathUtils.degRad); } - static signum(value: number): number { + static signum (value: number): number { return value > 0 ? 1 : value < 0 ? -1 : 0; } - static toInt(x: number) { + static toInt (x: number) { return x > 0 ? Math.floor(x) : Math.ceil(x); } - static cbrt(x: number) { + static cbrt (x: number) { let y = Math.pow(Math.abs(x), 1 / 3); return x < 0 ? -y : y; } - static randomTriangular(min: number, max: number): number { + static randomTriangular (min: number, max: number): number { return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); } - static randomTriangularWith(min: number, max: number, mode: number): number { + static randomTriangularWith (min: number, max: number, mode: number): number { let u = Math.random(); let d = max - min; if (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min)); return max - Math.sqrt((1 - u) * d * (max - mode)); } - static isPowerOfTwo(value: number) { + static isPowerOfTwo (value: number) { return value && (value & (value - 1)) === 0; } } export abstract class Interpolation { - protected abstract applyInternal(a: number): number; - apply(start: number, end: number, a: number): number { + protected abstract applyInternal (a: number): number; + apply (start: number, end: number, a: number): number { return start + (end - start) * this.applyInternal(a); } } @@ -237,23 +237,23 @@ export abstract class Interpolation { export class Pow extends Interpolation { protected power = 2; - constructor(power: number) { + constructor (power: number) { super(); this.power = power; } - applyInternal(a: number): number { + applyInternal (a: number): number { if (a <= 0.5) return Math.pow(a * 2, this.power) / 2; return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; } } export class PowOut extends Pow { - constructor(power: number) { + constructor (power: number) { super(power); } - applyInternal(a: number): number { + applyInternal (a: number): number { return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; } } @@ -261,18 +261,18 @@ export class PowOut extends Pow { export class Utils { static SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; - static arrayCopy(source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number) { + static arrayCopy (source: ArrayLike, sourceStart: number, dest: ArrayLike, destStart: number, numElements: number) { for (let i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { dest[j] = source[i]; } } - static arrayFill(array: ArrayLike, fromIndex: number, toIndex: number, value: T) { + static arrayFill (array: ArrayLike, fromIndex: number, toIndex: number, value: T) { for (let i = fromIndex; i < toIndex; i++) array[i] = value; } - static setArraySize(array: Array, size: number, value: any = 0): Array { + static setArraySize (array: Array, size: number, value: any = 0): Array { let oldSize = array.length; if (oldSize == size) return array; array.length = size; @@ -282,18 +282,18 @@ export class Utils { return array; } - static ensureArrayCapacity(array: Array, size: number, value: any = 0): Array { + static ensureArrayCapacity (array: Array, size: number, value: any = 0): Array { if (array.length >= size) return array; return Utils.setArraySize(array, size, value); } - static newArray(size: number, defaultValue: T): Array { + static newArray (size: number, defaultValue: T): Array { let array = new Array(size); for (let i = 0; i < size; i++) array[i] = defaultValue; return array; } - static newFloatArray(size: number): NumberArrayLike { + static newFloatArray (size: number): NumberArrayLike { if (Utils.SUPPORTS_TYPED_ARRAYS) return new Float32Array(size) else { @@ -303,7 +303,7 @@ export class Utils { } } - static newShortArray(size: number): NumberArrayLike { + static newShortArray (size: number): NumberArrayLike { if (Utils.SUPPORTS_TYPED_ARRAYS) return new Int16Array(size) else { @@ -313,31 +313,31 @@ export class Utils { } } - static toFloatArray(array: Array) { + static toFloatArray (array: Array) { return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; } - static toSinglePrecision(value: number) { + static toSinglePrecision (value: number) { return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; } // This function is used to fix WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109 - static webkit602BugfixHelper(alpha: number, blend: MixBlend) { + static webkit602BugfixHelper (alpha: number, blend: MixBlend) { } - static contains(array: Array, element: T, identity = true) { + static contains (array: Array, element: T, identity = true) { for (var i = 0; i < array.length; i++) if (array[i] == element) return true; return false; } - static enumValue(type: any, name: string) { + static enumValue (type: any, name: string) { return type[name[0].toUpperCase() + name.slice(1)]; } } export class DebugUtils { - static logBones(skeleton: Skeleton) { + static logBones (skeleton: Skeleton) { for (let i = 0; i < skeleton.bones.length; i++) { let bone = skeleton.bones[i]; console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY); @@ -349,46 +349,46 @@ export class Pool { private items = new Array(); private instantiator: () => T; - constructor(instantiator: () => T) { + constructor (instantiator: () => T) { this.instantiator = instantiator; } - obtain() { + obtain () { return this.items.length > 0 ? this.items.pop() : this.instantiator(); } - free(item: T) { + free (item: T) { if ((item as any).reset) (item as any).reset(); this.items.push(item); } - freeAll(items: ArrayLike) { + freeAll (items: ArrayLike) { for (let i = 0; i < items.length; i++) this.free(items[i]); } - clear() { + clear () { this.items.length = 0; } } export class Vector2 { - constructor(public x = 0, public y = 0) { + constructor (public x = 0, public y = 0) { } - set(x: number, y: number): Vector2 { + set (x: number, y: number): Vector2 { this.x = x; this.y = y; return this; } - length() { + length () { let x = this.x; let y = this.y; return Math.sqrt(x * x + y * y); } - normalize() { + normalize () { let len = this.length(); if (len != 0) { this.x /= len; @@ -408,7 +408,7 @@ export class TimeKeeper { private frameCount = 0; private frameTime = 0; - update() { + update () { let now = Date.now() / 1000; this.delta = now - this.lastTime; this.frameTime += this.delta; @@ -437,22 +437,22 @@ export class WindowedMean { mean = 0; dirty = true; - constructor(windowSize: number = 32) { + constructor (windowSize: number = 32) { this.values = new Array(windowSize); } - hasEnoughData() { + hasEnoughData () { return this.addedValues >= this.values.length; } - addValue(value: number) { + addValue (value: number) { if (this.addedValues < this.values.length) this.addedValues++; this.values[this.lastValue++] = value; if (this.lastValue > this.values.length - 1) this.lastValue = 0; this.dirty = true; } - getMean() { + getMean () { if (this.hasEnoughData()) { if (this.dirty) { let mean = 0; diff --git a/spine-ts/spine-core/src/VertexEffect.ts b/spine-ts/spine-core/src/VertexEffect.ts index 98632b69b..9feeb9afb 100644 --- a/spine-ts/spine-core/src/VertexEffect.ts +++ b/spine-ts/spine-core/src/VertexEffect.ts @@ -31,7 +31,7 @@ import { Skeleton } from "./Skeleton"; import { Vector2, Color } from "./Utils"; export interface VertexEffect { - begin(skeleton: Skeleton): void; - transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void; - end(): void; + begin (skeleton: Skeleton): void; + transform (position: Vector2, uv: Vector2, light: Color, dark: Color): void; + end (): void; } diff --git a/spine-ts/spine-core/src/attachments/Attachment.ts b/spine-ts/spine-core/src/attachments/Attachment.ts index a987710f1..b7bb21af6 100644 --- a/spine-ts/spine-core/src/attachments/Attachment.ts +++ b/spine-ts/spine-core/src/attachments/Attachment.ts @@ -34,12 +34,12 @@ import { NumberArrayLike, Utils } from "../Utils"; export abstract class Attachment { name: string; - constructor(name: string) { + constructor (name: string) { if (!name) throw new Error("name cannot be null."); this.name = name; } - abstract copy(): Attachment; + abstract copy (): Attachment; } /** Base class for an attachment with vertices that are transformed by one or more bones and can be deformed by a slot's @@ -67,7 +67,7 @@ export abstract class VertexAttachment extends Attachment { /** Deform keys for the deform attachment are also applied to this attachment. May be null if no deform keys should be applied. */ deformAttachment: VertexAttachment = this; - constructor(name: string) { + constructor (name: string) { super(name); } @@ -82,7 +82,7 @@ export abstract class VertexAttachment extends Attachment { * `stride` / 2. * @param offset The `worldVertices` index to begin writing values. * @param stride The number of `worldVertices` entries between the value pairs written. */ - computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: NumberArrayLike, offset: number, stride: number) { + computeWorldVertices (slot: Slot, start: number, count: number, worldVertices: NumberArrayLike, offset: number, stride: number) { count = offset + (count >> 1) * stride; let skeleton = slot.bone.skeleton; let deformArray = slot.deform; @@ -141,7 +141,7 @@ export abstract class VertexAttachment extends Attachment { } /** Does not copy id (generated) or name (set on construction). **/ - copyTo(attachment: VertexAttachment) { + copyTo (attachment: VertexAttachment) { if (this.bones) { attachment.bones = new Array(this.bones.length); Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length); diff --git a/spine-ts/spine-core/src/attachments/AttachmentLoader.ts b/spine-ts/spine-core/src/attachments/AttachmentLoader.ts index cf30f2c4f..0be3e606a 100644 --- a/spine-ts/spine-core/src/attachments/AttachmentLoader.ts +++ b/spine-ts/spine-core/src/attachments/AttachmentLoader.ts @@ -41,20 +41,20 @@ import { RegionAttachment } from "./RegionAttachment"; * Runtimes Guide. */ export interface AttachmentLoader { /** @return May be null to not load an attachment. */ - newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment; + newRegionAttachment (skin: Skin, name: string, path: string): RegionAttachment; /** @return May be null to not load an attachment. */ - newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment; + newMeshAttachment (skin: Skin, name: string, path: string): MeshAttachment; /** @return May be null to not load an attachment. */ - newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment; + newBoundingBoxAttachment (skin: Skin, name: string): BoundingBoxAttachment; /** @return May be null to not load an attachment */ - newPathAttachment(skin: Skin, name: string): PathAttachment; + newPathAttachment (skin: Skin, name: string): PathAttachment; /** @return May be null to not load an attachment */ - newPointAttachment(skin: Skin, name: string): PointAttachment; + newPointAttachment (skin: Skin, name: string): PointAttachment; /** @return May be null to not load an attachment */ - newClippingAttachment(skin: Skin, name: string): ClippingAttachment; + newClippingAttachment (skin: Skin, name: string): ClippingAttachment; } diff --git a/spine-ts/spine-core/src/attachments/BoundingBoxAttachment.ts b/spine-ts/spine-core/src/attachments/BoundingBoxAttachment.ts index 187f5701c..fdb0804db 100644 --- a/spine-ts/spine-core/src/attachments/BoundingBoxAttachment.ts +++ b/spine-ts/spine-core/src/attachments/BoundingBoxAttachment.ts @@ -38,11 +38,11 @@ import { VertexAttachment, Attachment } from "./Attachment"; export class BoundingBoxAttachment extends VertexAttachment { color = new Color(1, 1, 1, 1); - constructor(name: string) { + constructor (name: string) { super(name); } - copy(): Attachment { + copy (): Attachment { let copy = new BoundingBoxAttachment(this.name); this.copyTo(copy); copy.color.setFromColor(this.color); diff --git a/spine-ts/spine-core/src/attachments/ClippingAttachment.ts b/spine-ts/spine-core/src/attachments/ClippingAttachment.ts index 60d7cdd05..f8b1a4b73 100644 --- a/spine-ts/spine-core/src/attachments/ClippingAttachment.ts +++ b/spine-ts/spine-core/src/attachments/ClippingAttachment.ts @@ -42,11 +42,11 @@ export class ClippingAttachment extends VertexAttachment { * are not usually rendered at runtime. */ color = new Color(0.2275, 0.2275, 0.8078, 1); // ce3a3aff - constructor(name: string) { + constructor (name: string) { super(name); } - copy(): Attachment { + copy (): Attachment { let copy = new ClippingAttachment(this.name); this.copyTo(copy); copy.endSlot = this.endSlot; diff --git a/spine-ts/spine-core/src/attachments/MeshAttachment.ts b/spine-ts/spine-core/src/attachments/MeshAttachment.ts index 0b3091269..419911f3f 100644 --- a/spine-ts/spine-core/src/attachments/MeshAttachment.ts +++ b/spine-ts/spine-core/src/attachments/MeshAttachment.ts @@ -72,13 +72,13 @@ export class MeshAttachment extends VertexAttachment { private parentMesh: MeshAttachment; tempColor = new Color(0, 0, 0, 0); - constructor(name: string) { + constructor (name: string) { super(name); } /** Calculates {@link #uvs} using {@link #regionUVs} and the {@link #region}. Must be called after changing the region UVs or * region. */ - updateUVs() { + updateUVs () { let regionUVs = this.regionUVs; if (!this.uvs || this.uvs.length != regionUVs.length) this.uvs = Utils.newFloatArray(regionUVs.length); let uvs = this.uvs; @@ -140,12 +140,12 @@ export class MeshAttachment extends VertexAttachment { /** The parent mesh if this is a linked mesh, else null. A linked mesh shares the {@link #bones}, {@link #vertices}, * {@link #regionUVs}, {@link #triangles}, {@link #hullLength}, {@link #edges}, {@link #width}, and {@link #height} with the * parent mesh, but may have a different {@link #name} or {@link #path} (and therefore a different texture). */ - getParentMesh() { + getParentMesh () { return this.parentMesh; } /** @param parentMesh May be null. */ - setParentMesh(parentMesh: MeshAttachment) { + setParentMesh (parentMesh: MeshAttachment) { this.parentMesh = parentMesh; if (parentMesh) { this.bones = parentMesh.bones; @@ -158,7 +158,7 @@ export class MeshAttachment extends VertexAttachment { } } - copy(): Attachment { + copy (): Attachment { if (this.parentMesh) return this.newLinkedMesh(); let copy = new MeshAttachment(this.name); @@ -187,7 +187,7 @@ export class MeshAttachment extends VertexAttachment { } /** Returns a new mesh with the {@link #parentMesh} set to this mesh's parent mesh, if any, else to this mesh. **/ - newLinkedMesh(): MeshAttachment { + newLinkedMesh (): MeshAttachment { let copy = new MeshAttachment(this.name); copy.region = this.region; copy.path = this.path; diff --git a/spine-ts/spine-core/src/attachments/PathAttachment.ts b/spine-ts/spine-core/src/attachments/PathAttachment.ts index 7d4d3a89d..5230fd77e 100644 --- a/spine-ts/spine-core/src/attachments/PathAttachment.ts +++ b/spine-ts/spine-core/src/attachments/PathAttachment.ts @@ -49,11 +49,11 @@ export class PathAttachment extends VertexAttachment { * rendered at runtime. */ color = new Color(1, 1, 1, 1); - constructor(name: string) { + constructor (name: string) { super(name); } - copy(): Attachment { + copy (): Attachment { let copy = new PathAttachment(this.name); this.copyTo(copy); copy.lengths = new Array(this.lengths.length); diff --git a/spine-ts/spine-core/src/attachments/PointAttachment.ts b/spine-ts/spine-core/src/attachments/PointAttachment.ts index aa502d93a..755a550d7 100644 --- a/spine-ts/spine-core/src/attachments/PointAttachment.ts +++ b/spine-ts/spine-core/src/attachments/PointAttachment.ts @@ -43,24 +43,24 @@ export class PointAttachment extends VertexAttachment { * are not usually rendered at runtime. */ color = new Color(0.38, 0.94, 0, 1); - constructor(name: string) { + constructor (name: string) { super(name); } - computeWorldPosition(bone: Bone, point: Vector2) { + computeWorldPosition (bone: Bone, point: Vector2) { point.x = this.x * bone.a + this.y * bone.b + bone.worldX; point.y = this.x * bone.c + this.y * bone.d + bone.worldY; return point; } - computeWorldRotation(bone: Bone) { + computeWorldRotation (bone: Bone) { let cos = MathUtils.cosDeg(this.rotation), sin = MathUtils.sinDeg(this.rotation); let x = cos * bone.a + sin * bone.b; let y = cos * bone.c + sin * bone.d; return Math.atan2(y, x) * MathUtils.radDeg; } - copy(): Attachment { + copy (): Attachment { let copy = new PointAttachment(this.name); copy.x = this.x; copy.y = this.y; diff --git a/spine-ts/spine-core/src/attachments/RegionAttachment.ts b/spine-ts/spine-core/src/attachments/RegionAttachment.ts index 77a3901df..828a60ffc 100644 --- a/spine-ts/spine-core/src/attachments/RegionAttachment.ts +++ b/spine-ts/spine-core/src/attachments/RegionAttachment.ts @@ -75,12 +75,12 @@ export class RegionAttachment extends Attachment { tempColor = new Color(1, 1, 1, 1); - constructor(name: string) { + constructor (name: string) { super(name); } /** Calculates the {@link #offset} using the region settings. Must be called after changing region settings. */ - updateOffset(): void { + updateOffset (): void { let region = this.region; let regionScaleX = this.width / this.region.originalWidth * this.scaleX; let regionScaleY = this.height / this.region.originalHeight * this.scaleY; @@ -111,7 +111,7 @@ export class RegionAttachment extends Attachment { offset[7] = localYCos + localX2Sin; } - setRegion(region: TextureRegion): void { + setRegion (region: TextureRegion): void { this.region = region; let uvs = this.uvs; if (region.degrees == 90) { @@ -142,7 +142,7 @@ export class RegionAttachment extends Attachment { * @param worldVertices The output world vertices. Must have a length >= `offset` + 8. * @param offset The `worldVertices` index to begin writing values. * @param stride The number of `worldVertices` entries between the value pairs written. */ - computeWorldVertices(bone: Bone, worldVertices: NumberArrayLike, offset: number, stride: number) { + computeWorldVertices (bone: Bone, worldVertices: NumberArrayLike, offset: number, stride: number) { let vertexOffset = this.offset; let x = bone.worldX, y = bone.worldY; let a = bone.a, b = bone.b, c = bone.c, d = bone.d; @@ -172,7 +172,7 @@ export class RegionAttachment extends Attachment { worldVertices[offset + 1] = offsetX * c + offsetY * d + y; } - copy(): Attachment { + copy (): Attachment { let copy = new RegionAttachment(this.name); copy.region = this.region; copy.rendererObject = this.rendererObject; diff --git a/spine-ts/spine-core/src/vertexeffects/JitterEffect.ts b/spine-ts/spine-core/src/vertexeffects/JitterEffect.ts index a1e435d85..f610abb63 100644 --- a/spine-ts/spine-core/src/vertexeffects/JitterEffect.ts +++ b/spine-ts/spine-core/src/vertexeffects/JitterEffect.ts @@ -35,19 +35,19 @@ export class JitterEffect implements VertexEffect { jitterX = 0; jitterY = 0; - constructor(jitterX: number, jitterY: number) { + constructor (jitterX: number, jitterY: number) { this.jitterX = jitterX; this.jitterY = jitterY; } - begin(skeleton: Skeleton): void { + begin (skeleton: Skeleton): void { } - transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void { + transform (position: Vector2, uv: Vector2, light: Color, dark: Color): void { position.x += MathUtils.randomTriangular(-this.jitterX, this.jitterY); position.y += MathUtils.randomTriangular(-this.jitterX, this.jitterY); } - end(): void { + end (): void { } } diff --git a/spine-ts/spine-core/src/vertexeffects/SwirlEffect.ts b/spine-ts/spine-core/src/vertexeffects/SwirlEffect.ts index 1b1dd5af2..201074457 100644 --- a/spine-ts/spine-core/src/vertexeffects/SwirlEffect.ts +++ b/spine-ts/spine-core/src/vertexeffects/SwirlEffect.ts @@ -40,16 +40,16 @@ export class SwirlEffect implements VertexEffect { private worldX = 0; private worldY = 0; - constructor(radius: number) { + constructor (radius: number) { this.radius = radius; } - begin(skeleton: Skeleton): void { + begin (skeleton: Skeleton): void { this.worldX = skeleton.x + this.centerX; this.worldY = skeleton.y + this.centerY; } - transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void { + transform (position: Vector2, uv: Vector2, light: Color, dark: Color): void { let radAngle = this.angle * MathUtils.degreesToRadians; let x = position.x - this.worldX; let y = position.y - this.worldY; @@ -63,6 +63,6 @@ export class SwirlEffect implements VertexEffect { } } - end(): void { + end (): void { } } diff --git a/spine-ts/spine-player/src/Player.ts b/spine-ts/spine-player/src/Player.ts index 706d1e570..d923ec2ba 100644 --- a/spine-ts/spine-player/src/Player.ts +++ b/spine-ts/spine-player/src/Player.ts @@ -217,7 +217,7 @@ export class SpinePlayer { private previousViewport: Viewport; private viewportTransitionStart = 0; - constructor(parent: HTMLElement | string, private config: SpinePlayerConfig) { + constructor (parent: HTMLElement | string, private config: SpinePlayerConfig) { this.parent = typeof parent === "string" ? document.getElementById(parent) : parent; if (!this.parent) throw new Error("SpinePlayer parent not found: " + parent); @@ -254,7 +254,7 @@ export class SpinePlayer { requestAnimationFrame(() => this.drawFrame()); } - private validateConfig(config: SpinePlayerConfig) { + private validateConfig (config: SpinePlayerConfig) { if (!config) throw new Error("A configuration object must be passed to to new SpinePlayer()."); if ((config as any).skelUrl) config.binaryUrl = (config as any).skelUrl; if (!config.jsonUrl && !config.binaryUrl) throw new Error("A URL must be specified for the skeleton JSON or binary file."); @@ -278,7 +278,7 @@ export class SpinePlayer { if (config.defaultMix === void 0) config.defaultMix = 0.25; } - private initialize(): HTMLElement { + private initialize (): HTMLElement { let config = this.config; let dom = this.dom; @@ -391,7 +391,7 @@ export class SpinePlayer { return dom; } - private loadSkeleton() { + private loadSkeleton () { if (this.error) return; if (this.assetManager.hasErrors()) @@ -515,7 +515,7 @@ export class SpinePlayer { } } - private setupInput() { + private setupInput () { let config = this.config; let controlBones = config.controlBones; if (!controlBones.length && !config.showControls) return; @@ -621,7 +621,7 @@ export class SpinePlayer { } } - play() { + play () { this.paused = false; let config = this.config; if (config.showControls) { @@ -642,7 +642,7 @@ export class SpinePlayer { } } - pause() { + pause () { this.paused = true; if (this.config.showControls) { this.playerControls.classList.remove("spine-player-controls-hidden"); @@ -653,19 +653,19 @@ export class SpinePlayer { } /* Sets a new animation and viewport on track 0. */ - setAnimation(animation: string | Animation, loop: boolean = true): TrackEntry { + setAnimation (animation: string | Animation, loop: boolean = true): TrackEntry { animation = this.setViewport(animation); return this.animationState.setAnimationWith(0, animation, loop); } /* Adds a new animation and viewport on track 0. */ - addAnimation(animation: string | Animation, loop: boolean = true, delay: number = 0): TrackEntry { + addAnimation (animation: string | Animation, loop: boolean = true, delay: number = 0): TrackEntry { animation = this.setViewport(animation); return this.animationState.addAnimationWith(0, animation, loop, delay); } /* Sets the viewport for the specified animation. */ - setViewport(animation: string | Animation): Animation { + setViewport (animation: string | Animation): Animation { if (typeof animation == "string") animation = this.skeleton.data.findAnimation(animation); this.previousViewport = this.currentViewport; @@ -711,13 +711,13 @@ export class SpinePlayer { return animation; } - private percentageToWorldUnit(size: number, percentageOrAbsolute: string | number): number { + private percentageToWorldUnit (size: number, percentageOrAbsolute: string | number): number { if (typeof percentageOrAbsolute === "string") return size * parseFloat(percentageOrAbsolute.substr(0, percentageOrAbsolute.length - 1)) / 100; return percentageOrAbsolute; } - private calculateAnimationViewport(animation: Animation, viewport: Viewport) { + private calculateAnimationViewport (animation: Animation, viewport: Viewport) { this.skeleton.setToSetupPose(); let steps = 100, stepTime = animation.duration ? animation.duration / steps : 0, time = 0; @@ -744,7 +744,7 @@ export class SpinePlayer { viewport.height = maxY - minY; } - private drawFrame(requestNextFrame = true) { + private drawFrame (requestNextFrame = true) { try { if (this.error) return; if (requestNextFrame && !this.stopRequestAnimationFrame) requestAnimationFrame(() => this.drawFrame()); @@ -884,15 +884,15 @@ export class SpinePlayer { } } - stopRendering() { + stopRendering () { this.stopRequestAnimationFrame = true; } - private hidePopup(id: string): boolean { + private hidePopup (id: string): boolean { return this.popup && this.popup.hide(id); } - private showSpeedDialog(speedButton: HTMLElement) { + private showSpeedDialog (speedButton: HTMLElement) { let id = "speed"; if (this.hidePopup(id)) return; @@ -912,7 +912,7 @@ export class SpinePlayer { popup.show(); } - private showAnimationsDialog(animationsButton: HTMLElement) { + private showAnimationsDialog (animationsButton: HTMLElement) { let id = "animations"; if (this.hidePopup(id)) return; if (!this.skeleton || !this.skeleton.data.animations.length) return; @@ -942,7 +942,7 @@ export class SpinePlayer { popup.show(); } - private showSkinsDialog(skinButton: HTMLElement) { + private showSkinsDialog (skinButton: HTMLElement) { let id = "skins"; if (this.hidePopup(id)) return; if (!this.skeleton || !this.skeleton.data.animations.length) return; @@ -970,7 +970,7 @@ export class SpinePlayer { popup.show(); } - private showSettingsDialog(settingsButton: HTMLElement) { + private showSettingsDialog (settingsButton: HTMLElement) { let id = "settings"; if (this.hidePopup(id)) return; if (!this.skeleton || !this.skeleton.data.animations.length) return; @@ -998,7 +998,7 @@ export class SpinePlayer { popup.show(); } - private showError(message: string, error: Error = null) { + private showError (message: string, error: Error = null) { if (this.error) { if (error) throw error; // Don't lose error if showError throws, is caught, and showError is called again. } else { @@ -1016,14 +1016,14 @@ class Popup { public dom: HTMLElement; private className: string; - constructor(private id: string, private button: HTMLElement, private player: SpinePlayer, parent: HTMLElement, htmlContent: string) { + constructor (private id: string, private button: HTMLElement, private player: SpinePlayer, parent: HTMLElement, htmlContent: string) { this.dom = createElement(/*html*/`

`); this.dom.innerHTML = htmlContent; parent.appendChild(this.dom); this.className = "spine-player-button-icon-" + id + "-selected"; } - hide(id: string): boolean { + hide (id: string): boolean { this.dom.remove(); this.button.classList.remove(this.className); if (this.id == id) { @@ -1032,7 +1032,7 @@ class Popup { } } - show() { + show () { this.player.popup = this; this.button.classList.add(this.className); this.dom.classList.remove("spine-player-hidden"); @@ -1072,9 +1072,9 @@ class Switch { private enabled = false; public change: (value: boolean) => void; - constructor(private text: string) { } + constructor (private text: string) { } - create(): HTMLElement { + create (): HTMLElement { this.switch = createElement(/*html*/`
${this.text} @@ -1089,13 +1089,13 @@ class Switch { return this.switch; } - setEnabled(enabled: boolean) { + setEnabled (enabled: boolean) { if (enabled) this.switch.classList.add("active"); else this.switch.classList.remove("active"); this.enabled = enabled; } - isEnabled(): boolean { + isEnabled (): boolean { return this.enabled; } } @@ -1106,9 +1106,9 @@ class Slider { private knob: HTMLElement; public change: (percentage: number) => void; - constructor(public snaps = 0, public snapPercentage = 0.1, public big = false) { } + constructor (public snaps = 0, public snapPercentage = 0.1, public big = false) { } - create(): HTMLElement { + create (): HTMLElement { this.slider = createElement(/*html*/`
@@ -1140,7 +1140,7 @@ class Slider { return this.slider; } - setValue(percentage: number): number { + setValue (percentage: number): number { percentage = Math.max(0, Math.min(1, percentage)); if (this.snaps) { let snap = 1 / this.snaps; @@ -1158,22 +1158,22 @@ class Slider { } } -function findWithClass(element: HTMLElement, className: string): HTMLElement { +function findWithClass (element: HTMLElement, className: string): HTMLElement { return element.getElementsByClassName(className)[0] as HTMLElement; } -function createElement(html: string): HTMLElement { +function createElement (html: string): HTMLElement { let div = document.createElement("div"); div.innerHTML = html; return div.children[0] as HTMLElement; } -function removeClass(elements: HTMLCollection, clazz: string) { +function removeClass (elements: HTMLCollection, clazz: string) { for (let i = 0; i < elements.length; i++) elements[i].classList.remove(clazz); } -function toString(object: any) { +function toString (object: any) { return JSON.stringify(object) .replace(/&/g, "&") .replace(/
@@ -90,19 +90,19 @@ body { margin: 0px; } }) } - setPreAndPostfix(prefix: string, postfix: string) { + setPreAndPostfix (prefix: string, postfix: string) { this.prefix = prefix; this.postfix = postfix; this.startPlayer() } - setCode(code: string) { + setCode (code: string) { this.code.setValue(code); this.startPlayer(); } private timerId = 0; - startPlayer() { + startPlayer () { clearTimeout(this.timerId); this.timerId = setTimeout(() => { let code = this.code.getDoc().getValue(); diff --git a/spine-ts/spine-threejs/src/AssetManager.ts b/spine-ts/spine-threejs/src/AssetManager.ts index 9ffe137a3..3fcc12866 100644 --- a/spine-ts/spine-threejs/src/AssetManager.ts +++ b/spine-ts/spine-threejs/src/AssetManager.ts @@ -31,7 +31,7 @@ import { AssetManagerBase, Downloader } from "@esotericsoftware/spine-core" import { ThreeJsTexture } from "./ThreeJsTexture"; export class AssetManager extends AssetManagerBase { - constructor(pathPrefix: string = "", downloader: Downloader = null) { + constructor (pathPrefix: string = "", downloader: Downloader = null) { super((image: HTMLImageElement) => { return new ThreeJsTexture(image); }, pathPrefix, downloader); diff --git a/spine-ts/spine-threejs/src/MeshBatcher.ts b/spine-ts/spine-threejs/src/MeshBatcher.ts index d724c7c62..d2b3948af 100644 --- a/spine-ts/spine-threejs/src/MeshBatcher.ts +++ b/spine-ts/spine-threejs/src/MeshBatcher.ts @@ -38,7 +38,7 @@ export class MeshBatcher extends THREE.Mesh { private indices: Uint16Array; private indicesLength = 0; - constructor(maxVertices: number = 10920, materialCustomizer: SkeletonMeshMaterialParametersCustomizer = (parameters) => { }) { + constructor (maxVertices: number = 10920, materialCustomizer: SkeletonMeshMaterialParametersCustomizer = (parameters) => { }) { super(); if (maxVertices > 10920) throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); let vertices = this.vertices = new Float32Array(maxVertices * MeshBatcher.VERTEX_SIZE); @@ -57,7 +57,7 @@ export class MeshBatcher extends THREE.Mesh { this.material = new SkeletonMeshMaterial(materialCustomizer); } - dispose() { + dispose () { this.geometry.dispose(); if (this.material instanceof THREE.Material) this.material.dispose(); @@ -70,7 +70,7 @@ export class MeshBatcher extends THREE.Mesh { } } - clear() { + clear () { let geo = (this.geometry); geo.drawRange.start = 0; geo.drawRange.count = 0; @@ -78,18 +78,18 @@ export class MeshBatcher extends THREE.Mesh { return this; } - begin() { + begin () { this.verticesLength = 0; this.indicesLength = 0; } - canBatch(verticesLength: number, indicesLength: number) { + canBatch (verticesLength: number, indicesLength: number) { if (this.indicesLength + indicesLength >= this.indices.byteLength / 2) return false; if (this.verticesLength + verticesLength >= this.vertices.byteLength / 2) return false; return true; } - batch(vertices: ArrayLike, verticesLength: number, indices: ArrayLike, indicesLength: number, z: number = 0) { + batch (vertices: ArrayLike, verticesLength: number, indices: ArrayLike, indicesLength: number, z: number = 0) { let indexStart = this.verticesLength / MeshBatcher.VERTEX_SIZE; let vertexBuffer = this.vertices; let i = this.verticesLength; @@ -113,7 +113,7 @@ export class MeshBatcher extends THREE.Mesh { this.indicesLength += indicesLength; } - end() { + end () { this.vertexBuffer.needsUpdate = this.verticesLength > 0; this.vertexBuffer.updateRange.offset = 0; this.vertexBuffer.updateRange.count = this.verticesLength; diff --git a/spine-ts/spine-threejs/src/SkeletonMesh.ts b/spine-ts/spine-threejs/src/SkeletonMesh.ts index 12e948f88..a817ba888 100644 --- a/spine-ts/spine-threejs/src/SkeletonMesh.ts +++ b/spine-ts/spine-threejs/src/SkeletonMesh.ts @@ -37,7 +37,7 @@ export interface SkeletonMeshMaterialParametersCustomizer { } export class SkeletonMeshMaterial extends THREE.ShaderMaterial { - constructor(customizer: SkeletonMeshMaterialParametersCustomizer) { + constructor (customizer: SkeletonMeshMaterialParametersCustomizer) { let vertexShader = ` attribute vec4 color; varying vec2 vUv; @@ -93,7 +93,7 @@ export class SkeletonMesh extends THREE.Object3D { private tempColor = new Color(); private materialCustomizer: SkeletonMeshMaterialParametersCustomizer; - constructor(skeletonData: SkeletonData, materialCustomizer: SkeletonMeshMaterialParametersCustomizer = (parameters) => { }) { + constructor (skeletonData: SkeletonData, materialCustomizer: SkeletonMeshMaterialParametersCustomizer = (parameters) => { }) { super(); this.materialCustomizer = materialCustomizer; this.skeleton = new Skeleton(skeletonData); @@ -101,7 +101,7 @@ export class SkeletonMesh extends THREE.Object3D { this.state = new AnimationState(animData); } - update(deltaTime: number) { + update (deltaTime: number) { let state = this.state; let skeleton = this.skeleton; @@ -112,13 +112,13 @@ export class SkeletonMesh extends THREE.Object3D { this.updateGeometry(); } - dispose() { + dispose () { for (var i = 0; i < this.batches.length; i++) { this.batches[i].dispose(); } } - private clearBatches() { + private clearBatches () { for (var i = 0; i < this.batches.length; i++) { this.batches[i].clear(); this.batches[i].visible = false; @@ -126,7 +126,7 @@ export class SkeletonMesh extends THREE.Object3D { this.nextBatchIndex = 0; } - private nextBatch() { + private nextBatch () { if (this.batches.length == this.nextBatchIndex) { let batch = new MeshBatcher(10920, this.materialCustomizer); this.add(batch); @@ -137,7 +137,7 @@ export class SkeletonMesh extends THREE.Object3D { return batch; } - private updateGeometry() { + private updateGeometry () { this.clearBatches(); let tempPos = this.tempPos; diff --git a/spine-ts/spine-threejs/src/ThreeJsTexture.ts b/spine-ts/spine-threejs/src/ThreeJsTexture.ts index a59f93588..f29cd4fea 100644 --- a/spine-ts/spine-threejs/src/ThreeJsTexture.ts +++ b/spine-ts/spine-threejs/src/ThreeJsTexture.ts @@ -33,28 +33,28 @@ import * as THREE from "three"; export class ThreeJsTexture extends Texture { texture: THREE.Texture; - constructor(image: HTMLImageElement) { + constructor (image: HTMLImageElement) { super(image); this.texture = new THREE.Texture(image); this.texture.flipY = false; this.texture.needsUpdate = true; } - setFilters(minFilter: TextureFilter, magFilter: TextureFilter) { + setFilters (minFilter: TextureFilter, magFilter: TextureFilter) { this.texture.minFilter = ThreeJsTexture.toThreeJsTextureFilter(minFilter); this.texture.magFilter = ThreeJsTexture.toThreeJsTextureFilter(magFilter); } - setWraps(uWrap: TextureWrap, vWrap: TextureWrap) { + setWraps (uWrap: TextureWrap, vWrap: TextureWrap) { this.texture.wrapS = ThreeJsTexture.toThreeJsTextureWrap(uWrap); this.texture.wrapT = ThreeJsTexture.toThreeJsTextureWrap(vWrap); } - dispose() { + dispose () { this.texture.dispose(); } - static toThreeJsTextureFilter(filter: TextureFilter) { + static toThreeJsTextureFilter (filter: TextureFilter) { if (filter === TextureFilter.Linear) return THREE.LinearFilter; else if (filter === TextureFilter.MipMap) return THREE.LinearMipMapLinearFilter; // also includes TextureFilter.MipMapLinearLinear else if (filter === TextureFilter.MipMapLinearNearest) return THREE.LinearMipMapNearestFilter; @@ -64,7 +64,7 @@ export class ThreeJsTexture extends Texture { else throw new Error("Unknown texture filter: " + filter); } - static toThreeJsTextureWrap(wrap: TextureWrap) { + static toThreeJsTextureWrap (wrap: TextureWrap) { if (wrap === TextureWrap.ClampToEdge) return THREE.ClampToEdgeWrapping; else if (wrap === TextureWrap.MirroredRepeat) return THREE.MirroredRepeatWrapping; else if (wrap === TextureWrap.Repeat) return THREE.RepeatWrapping; diff --git a/spine-ts/spine-webgl/src/AssetManager.ts b/spine-ts/spine-webgl/src/AssetManager.ts index 22d237673..76a0edde9 100644 --- a/spine-ts/spine-webgl/src/AssetManager.ts +++ b/spine-ts/spine-webgl/src/AssetManager.ts @@ -33,7 +33,7 @@ import { GLTexture } from "./GLTexture"; export class AssetManager extends AssetManagerBase { - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, pathPrefix: string = "", downloader: Downloader = null) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, pathPrefix: string = "", downloader: Downloader = null) { super((image: HTMLImageElement | ImageBitmap) => { return new GLTexture(context, image); }, pathPrefix, downloader); diff --git a/spine-ts/spine-webgl/src/Camera.ts b/spine-ts/spine-webgl/src/Camera.ts index c0fb9a65d..92cc5f1bb 100644 --- a/spine-ts/spine-webgl/src/Camera.ts +++ b/spine-ts/spine-webgl/src/Camera.ts @@ -44,13 +44,13 @@ export class OrthoCamera { projection = new Matrix4(); view = new Matrix4(); - constructor(viewportWidth: number, viewportHeight: number) { + constructor (viewportWidth: number, viewportHeight: number) { this.viewportWidth = viewportWidth; this.viewportHeight = viewportHeight; this.update(); } - update() { + update () { let projection = this.projection; let view = this.view; let projectionView = this.projectionView; @@ -65,7 +65,7 @@ export class OrthoCamera { inverseProjectionView.set(projectionView.values).invert(); } - screenToWorld(screenCoords: Vector3, screenWidth: number, screenHeight: number) { + screenToWorld (screenCoords: Vector3, screenWidth: number, screenHeight: number) { let x = screenCoords.x, y = screenHeight - screenCoords.y - 1; screenCoords.x = (2 * x) / screenWidth - 1; screenCoords.y = (2 * y) / screenHeight - 1; @@ -74,7 +74,7 @@ export class OrthoCamera { return screenCoords; } - worldToScreen(worldCoords: Vector3, screenWidth: number, screenHeight: number) { + worldToScreen (worldCoords: Vector3, screenWidth: number, screenHeight: number) { worldCoords.project(this.projectionView); worldCoords.x = screenWidth * (worldCoords.x + 1) / 2; worldCoords.y = screenHeight * (worldCoords.y + 1) / 2; @@ -82,7 +82,7 @@ export class OrthoCamera { return worldCoords; } - setViewport(viewportWidth: number, viewportHeight: number) { + setViewport (viewportWidth: number, viewportHeight: number) { this.viewportWidth = viewportWidth; this.viewportHeight = viewportHeight; } diff --git a/spine-ts/spine-webgl/src/GLTexture.ts b/spine-ts/spine-webgl/src/GLTexture.ts index 0fa15213f..e189a130e 100644 --- a/spine-ts/spine-webgl/src/GLTexture.ts +++ b/spine-ts/spine-webgl/src/GLTexture.ts @@ -38,7 +38,7 @@ export class GLTexture extends Texture implements Disposable, Restorable { public static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false; - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps: boolean = false) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps: boolean = false) { super(image); this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); this.useMipMaps = useMipMaps; @@ -46,14 +46,14 @@ export class GLTexture extends Texture implements Disposable, Restorable { this.context.addRestorable(this); } - setFilters(minFilter: TextureFilter, magFilter: TextureFilter) { + setFilters (minFilter: TextureFilter, magFilter: TextureFilter) { let gl = this.context.gl; this.bind(); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, GLTexture.validateMagFilter(magFilter)); } - static validateMagFilter(magFilter: TextureFilter) { + static validateMagFilter (magFilter: TextureFilter) { switch (magFilter) { case TextureFilter.MipMap: case TextureFilter.MipMapLinearLinear: @@ -66,14 +66,14 @@ export class GLTexture extends Texture implements Disposable, Restorable { } } - setWraps(uWrap: TextureWrap, vWrap: TextureWrap) { + setWraps (uWrap: TextureWrap, vWrap: TextureWrap) { let gl = this.context.gl; this.bind(); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap); } - update(useMipMaps: boolean) { + update (useMipMaps: boolean) { let gl = this.context.gl; if (!this.texture) this.texture = this.context.gl.createTexture(); this.bind(); @@ -86,25 +86,25 @@ export class GLTexture extends Texture implements Disposable, Restorable { if (useMipMaps) gl.generateMipmap(gl.TEXTURE_2D); } - restore() { + restore () { this.texture = null; this.update(this.useMipMaps); } - bind(unit: number = 0) { + bind (unit: number = 0) { let gl = this.context.gl; this.boundUnit = unit; gl.activeTexture(gl.TEXTURE0 + unit); gl.bindTexture(gl.TEXTURE_2D, this.texture); } - unbind() { + unbind () { let gl = this.context.gl; gl.activeTexture(gl.TEXTURE0 + this.boundUnit); gl.bindTexture(gl.TEXTURE_2D, null); } - dispose() { + dispose () { this.context.removeRestorable(this); let gl = this.context.gl; gl.deleteTexture(this.texture); diff --git a/spine-ts/spine-webgl/src/Input.ts b/spine-ts/spine-webgl/src/Input.ts index 1c74e884f..0fa3a7098 100644 --- a/spine-ts/spine-webgl/src/Input.ts +++ b/spine-ts/spine-webgl/src/Input.ts @@ -41,12 +41,12 @@ export class Input { return new Touch(0, 0, 0); }); - constructor(element: HTMLElement) { + constructor (element: HTMLElement) { this.element = element; this.setupCallbacks(element); } - private setupCallbacks(element: HTMLElement) { + private setupCallbacks (element: HTMLElement) { let mouseDown = (ev: UIEvent) => { if (ev instanceof MouseEvent) { let rect = element.getBoundingClientRect(); @@ -208,11 +208,11 @@ export class Input { }, false); } - addListener(listener: InputListener) { + addListener (listener: InputListener) { this.listeners.push(listener); } - removeListener(listener: InputListener) { + removeListener (listener: InputListener) { let idx = this.listeners.indexOf(listener); if (idx > -1) { this.listeners.splice(idx, 1); @@ -221,13 +221,13 @@ export class Input { } export class Touch { - constructor(public identifier: number, public x: number, public y: number) { + constructor (public identifier: number, public x: number, public y: number) { } } export interface InputListener { - down(x: number, y: number): void; - up(x: number, y: number): void; - moved(x: number, y: number): void; - dragged(x: number, y: number): void; + down (x: number, y: number): void; + up (x: number, y: number): void; + moved (x: number, y: number): void; + dragged (x: number, y: number): void; } diff --git a/spine-ts/spine-webgl/src/LoadingScreen.ts b/spine-ts/spine-webgl/src/LoadingScreen.ts index 33a523955..f577aca12 100644 --- a/spine-ts/spine-webgl/src/LoadingScreen.ts +++ b/spine-ts/spine-webgl/src/LoadingScreen.ts @@ -49,7 +49,7 @@ export class LoadingScreen { backgroundColor = new Color(0.135, 0.135, 0.135, 1); private tempColor = new Color(); - constructor(renderer: SceneRenderer) { + constructor (renderer: SceneRenderer) { this.renderer = renderer; this.timeKeeper.maxDelta = 9; @@ -70,7 +70,7 @@ export class LoadingScreen { } } - draw(complete = false) { + draw (complete = false) { if (loaded < 2 || (complete && this.fadeOut > FADE_OUT)) return; this.timeKeeper.update(); diff --git a/spine-ts/spine-webgl/src/Matrix4.ts b/spine-ts/spine-webgl/src/Matrix4.ts index 601e7b11e..fb7574bcb 100644 --- a/spine-ts/spine-webgl/src/Matrix4.ts +++ b/spine-ts/spine-webgl/src/Matrix4.ts @@ -55,7 +55,7 @@ export class Matrix4 { private static zAxis: Vector3 = null; private static tmpMatrix = new Matrix4(); - constructor() { + constructor () { let v = this.values; v[M00] = 1; v[M11] = 1; @@ -63,12 +63,12 @@ export class Matrix4 { v[M33] = 1; } - set(values: ArrayLike): Matrix4 { + set (values: ArrayLike): Matrix4 { this.values.set(values); return this; } - transpose(): Matrix4 { + transpose (): Matrix4 { let t = this.temp; let v = this.values; t[M00] = v[M00]; @@ -90,7 +90,7 @@ export class Matrix4 { return this.set(t); } - identity(): Matrix4 { + identity (): Matrix4 { let v = this.values; v[M00] = 1; v[M01] = 0; @@ -111,7 +111,7 @@ export class Matrix4 { return this; } - invert(): Matrix4 { + invert (): Matrix4 { let v = this.values; let t = this.temp; let l_det = v[M30] * v[M21] * v[M12] * v[M03] - v[M20] * v[M31] * v[M12] * v[M03] - v[M30] * v[M11] * v[M22] * v[M03] @@ -175,7 +175,7 @@ export class Matrix4 { return this; } - determinant(): number { + determinant (): number { let v = this.values; return v[M30] * v[M21] * v[M12] * v[M03] - v[M20] * v[M31] * v[M12] * v[M03] - v[M30] * v[M11] * v[M22] * v[M03] + v[M10] * v[M31] * v[M22] * v[M03] + v[M20] * v[M11] * v[M32] * v[M03] - v[M10] * v[M21] * v[M32] * v[M03] @@ -187,7 +187,7 @@ export class Matrix4 { - v[M00] * v[M21] * v[M12] * v[M33] - v[M10] * v[M01] * v[M22] * v[M33] + v[M00] * v[M11] * v[M22] * v[M33]; } - translate(x: number, y: number, z: number): Matrix4 { + translate (x: number, y: number, z: number): Matrix4 { let v = this.values; v[M03] += x; v[M13] += y; @@ -195,11 +195,11 @@ export class Matrix4 { return this; } - copy(): Matrix4 { + copy (): Matrix4 { return new Matrix4().set(this.values); } - projection(near: number, far: number, fovy: number, aspectRatio: number): Matrix4 { + projection (near: number, far: number, fovy: number, aspectRatio: number): Matrix4 { this.identity(); let l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0)); let l_a1 = (far + near) / (near - far); @@ -224,11 +224,11 @@ export class Matrix4 { return this; } - ortho2d(x: number, y: number, width: number, height: number): Matrix4 { + ortho2d (x: number, y: number, width: number, height: number): Matrix4 { return this.ortho(x, x + width, y, y + height, 0, 1); } - ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4 { + ortho (left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4 { this.identity(); let x_orth = 2 / (right - left); let y_orth = 2 / (top - bottom); @@ -258,7 +258,7 @@ export class Matrix4 { return this; } - multiply(matrix: Matrix4): Matrix4 { + multiply (matrix: Matrix4): Matrix4 { let t = this.temp; let v = this.values; let m = matrix.values; @@ -281,7 +281,7 @@ export class Matrix4 { return this.set(this.temp); } - multiplyLeft(matrix: Matrix4): Matrix4 { + multiplyLeft (matrix: Matrix4): Matrix4 { let t = this.temp; let v = this.values; let m = matrix.values; @@ -304,7 +304,7 @@ export class Matrix4 { return this.set(this.temp); } - lookAt(position: Vector3, direction: Vector3, up: Vector3) { + lookAt (position: Vector3, direction: Vector3, up: Vector3) { Matrix4.initTemps(); let xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis; zAxis.setFrom(direction).normalize(); @@ -332,7 +332,7 @@ export class Matrix4 { return this; } - static initTemps() { + static initTemps () { if (Matrix4.xAxis === null) Matrix4.xAxis = new Vector3(); if (Matrix4.yAxis === null) Matrix4.yAxis = new Vector3(); if (Matrix4.zAxis === null) Matrix4.zAxis = new Vector3(); diff --git a/spine-ts/spine-webgl/src/Mesh.ts b/spine-ts/spine-webgl/src/Mesh.ts index 24ae69e5d..18cceb0ab 100644 --- a/spine-ts/spine-webgl/src/Mesh.ts +++ b/spine-ts/spine-webgl/src/Mesh.ts @@ -44,25 +44,25 @@ export class Mesh implements Disposable, Restorable { private dirtyIndices = false; private elementsPerVertex = 0; - getAttributes(): VertexAttribute[] { return this.attributes; } + getAttributes (): VertexAttribute[] { return this.attributes; } - maxVertices(): number { return this.vertices.length / this.elementsPerVertex; } - numVertices(): number { return this.verticesLength / this.elementsPerVertex; } - setVerticesLength(length: number) { + maxVertices (): number { return this.vertices.length / this.elementsPerVertex; } + numVertices (): number { return this.verticesLength / this.elementsPerVertex; } + setVerticesLength (length: number) { this.dirtyVertices = true; this.verticesLength = length; } - getVertices(): Float32Array { return this.vertices; } + getVertices (): Float32Array { return this.vertices; } - maxIndices(): number { return this.indices.length; } - numIndices(): number { return this.indicesLength; } - setIndicesLength(length: number) { + maxIndices (): number { return this.indices.length; } + numIndices (): number { return this.indicesLength; } + setIndicesLength (length: number) { this.dirtyIndices = true; this.indicesLength = length; } - getIndices(): Uint16Array { return this.indices }; + getIndices (): Uint16Array { return this.indices }; - getVertexSizeInFloats(): number { + getVertexSizeInFloats (): number { let size = 0; for (var i = 0; i < this.attributes.length; i++) { let attribute = this.attributes[i]; @@ -71,7 +71,7 @@ export class Mesh implements Disposable, Restorable { return size; } - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, private attributes: VertexAttribute[], maxVertices: number, maxIndices: number) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, private attributes: VertexAttribute[], maxVertices: number, maxIndices: number) { this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); this.elementsPerVertex = 0; for (let i = 0; i < attributes.length; i++) { @@ -82,25 +82,25 @@ export class Mesh implements Disposable, Restorable { this.context.addRestorable(this); } - setVertices(vertices: Array) { + setVertices (vertices: Array) { this.dirtyVertices = true; if (vertices.length > this.vertices.length) throw Error("Mesh can't store more than " + this.maxVertices() + " vertices"); this.vertices.set(vertices, 0); this.verticesLength = vertices.length; } - setIndices(indices: Array) { + setIndices (indices: Array) { this.dirtyIndices = true; if (indices.length > this.indices.length) throw Error("Mesh can't store more than " + this.maxIndices() + " indices"); this.indices.set(indices, 0); this.indicesLength = indices.length; } - draw(shader: Shader, primitiveType: number) { + draw (shader: Shader, primitiveType: number) { this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex); } - drawWithOffset(shader: Shader, primitiveType: number, offset: number, count: number) { + drawWithOffset (shader: Shader, primitiveType: number, offset: number, count: number) { let gl = this.context.gl; if (this.dirtyVertices || this.dirtyIndices) this.update(); this.bind(shader); @@ -112,7 +112,7 @@ export class Mesh implements Disposable, Restorable { this.unbind(shader); } - bind(shader: Shader) { + bind (shader: Shader) { let gl = this.context.gl; gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); let offset = 0; @@ -126,7 +126,7 @@ export class Mesh implements Disposable, Restorable { if (this.indicesLength > 0) gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); } - unbind(shader: Shader) { + unbind (shader: Shader) { let gl = this.context.gl; for (let i = 0; i < this.attributes.length; i++) { let attrib = this.attributes[i]; @@ -137,7 +137,7 @@ export class Mesh implements Disposable, Restorable { if (this.indicesLength > 0) gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); } - private update() { + private update () { let gl = this.context.gl; if (this.dirtyVertices) { if (!this.verticesBuffer) { @@ -158,13 +158,13 @@ export class Mesh implements Disposable, Restorable { } } - restore() { + restore () { this.verticesBuffer = null; this.indicesBuffer = null; this.update(); } - dispose() { + dispose () { this.context.removeRestorable(this); let gl = this.context.gl; gl.deleteBuffer(this.verticesBuffer); @@ -173,35 +173,35 @@ export class Mesh implements Disposable, Restorable { } export class VertexAttribute { - constructor(public name: string, public type: VertexAttributeType, public numElements: number) { } + constructor (public name: string, public type: VertexAttributeType, public numElements: number) { } } export class Position2Attribute extends VertexAttribute { - constructor() { + constructor () { super(Shader.POSITION, VertexAttributeType.Float, 2); } } export class Position3Attribute extends VertexAttribute { - constructor() { + constructor () { super(Shader.POSITION, VertexAttributeType.Float, 3); } } export class TexCoordAttribute extends VertexAttribute { - constructor(unit: number = 0) { + constructor (unit: number = 0) { super(Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2); } } export class ColorAttribute extends VertexAttribute { - constructor() { + constructor () { super(Shader.COLOR, VertexAttributeType.Float, 4); } } export class Color2Attribute extends VertexAttribute { - constructor() { + constructor () { super(Shader.COLOR2, VertexAttributeType.Float, 4); } } diff --git a/spine-ts/spine-webgl/src/PolygonBatcher.ts b/spine-ts/spine-webgl/src/PolygonBatcher.ts index 874b9d97c..9df3ec9e5 100644 --- a/spine-ts/spine-webgl/src/PolygonBatcher.ts +++ b/spine-ts/spine-webgl/src/PolygonBatcher.ts @@ -46,7 +46,7 @@ export class PolygonBatcher implements Disposable { private srcAlphaBlend: number; private dstBlend: number; - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, twoColorTint: boolean = true, maxVertices: number = 10920) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, twoColorTint: boolean = true, maxVertices: number = 10920) { if (maxVertices > 10920) throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); let attributes = twoColorTint ? @@ -59,7 +59,7 @@ export class PolygonBatcher implements Disposable { this.dstBlend = gl.ONE_MINUS_SRC_ALPHA; } - begin(shader: Shader) { + begin (shader: Shader) { if (this.isDrawing) throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()"); this.drawCalls = 0; this.shader = shader; @@ -71,7 +71,7 @@ export class PolygonBatcher implements Disposable { gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend); } - setBlendMode(srcColorBlend: number, srcAlphaBlend: number, dstBlend: number) { + setBlendMode (srcColorBlend: number, srcAlphaBlend: number, dstBlend: number) { this.srcColorBlend = srcColorBlend; this.srcAlphaBlend = srcAlphaBlend; this.dstBlend = dstBlend; @@ -82,7 +82,7 @@ export class PolygonBatcher implements Disposable { } } - draw(texture: GLTexture, vertices: ArrayLike, indices: Array) { + draw (texture: GLTexture, vertices: ArrayLike, indices: Array) { if (texture != this.lastTexture) { this.flush(); this.lastTexture = texture; @@ -103,7 +103,7 @@ export class PolygonBatcher implements Disposable { this.mesh.setIndicesLength(this.indicesLength); } - flush() { + flush () { if (this.verticesLength == 0) return; this.lastTexture.bind(); @@ -116,7 +116,7 @@ export class PolygonBatcher implements Disposable { this.drawCalls++; } - end() { + end () { if (!this.isDrawing) throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()"); if (this.verticesLength > 0 || this.indicesLength > 0) this.flush(); this.shader = null; @@ -127,11 +127,11 @@ export class PolygonBatcher implements Disposable { gl.disable(gl.BLEND); } - getDrawCalls() { + getDrawCalls () { return this.drawCalls; } - dispose() { + dispose () { this.mesh.dispose(); } } diff --git a/spine-ts/spine-webgl/src/SceneRenderer.ts b/spine-ts/spine-webgl/src/SceneRenderer.ts index 05104037e..245e54104 100644 --- a/spine-ts/spine-webgl/src/SceneRenderer.ts +++ b/spine-ts/spine-webgl/src/SceneRenderer.ts @@ -60,7 +60,7 @@ export class SceneRenderer implements Disposable { skeletonRenderer: SkeletonRenderer; skeletonDebugRenderer: SkeletonDebugRenderer; - constructor(canvas: HTMLCanvasElement, context: ManagedWebGLRenderingContext | WebGLRenderingContext, twoColorTint: boolean = true) { + constructor (canvas: HTMLCanvasElement, context: ManagedWebGLRenderingContext | WebGLRenderingContext, twoColorTint: boolean = true) { this.canvas = canvas; this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); this.twoColorTint = twoColorTint; @@ -73,24 +73,24 @@ export class SceneRenderer implements Disposable { this.skeletonDebugRenderer = new SkeletonDebugRenderer(this.context); } - begin() { + begin () { this.camera.update(); this.enableRenderer(this.batcher); } - drawSkeleton(skeleton: Skeleton, premultipliedAlpha = false, slotRangeStart = -1, slotRangeEnd = -1) { + drawSkeleton (skeleton: Skeleton, premultipliedAlpha = false, slotRangeStart = -1, slotRangeEnd = -1) { this.enableRenderer(this.batcher); this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha; this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd); } - drawSkeletonDebug(skeleton: Skeleton, premultipliedAlpha = false, ignoredBones: Array = null) { + drawSkeletonDebug (skeleton: Skeleton, premultipliedAlpha = false, ignoredBones: Array = null) { this.enableRenderer(this.shapes); this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha; this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones); } - drawTexture(texture: GLTexture, x: number, y: number, width: number, height: number, color: Color = null) { + drawTexture (texture: GLTexture, x: number, y: number, width: number, height: number, color: Color = null) { this.enableRenderer(this.batcher); if (color === null) color = WHITE; var i = 0; @@ -153,7 +153,7 @@ export class SceneRenderer implements Disposable { this.batcher.draw(texture, quad, QUAD_TRIANGLES); } - drawTextureUV(texture: GLTexture, x: number, y: number, width: number, height: number, u: number, v: number, u2: number, v2: number, color: Color = null) { + drawTextureUV (texture: GLTexture, x: number, y: number, width: number, height: number, u: number, v: number, u2: number, v2: number, color: Color = null) { this.enableRenderer(this.batcher); if (color === null) color = WHITE; var i = 0; @@ -216,7 +216,7 @@ export class SceneRenderer implements Disposable { this.batcher.draw(texture, quad, QUAD_TRIANGLES); } - drawTextureRotated(texture: GLTexture, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number, angle: number, color: Color = null) { + drawTextureRotated (texture: GLTexture, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number, angle: number, color: Color = null) { this.enableRenderer(this.batcher); if (color === null) color = WHITE; @@ -346,7 +346,7 @@ export class SceneRenderer implements Disposable { this.batcher.draw(texture, quad, QUAD_TRIANGLES); } - drawRegion(region: TextureAtlasRegion, x: number, y: number, width: number, height: number, color: Color = null) { + drawRegion (region: TextureAtlasRegion, x: number, y: number, width: number, height: number, color: Color = null) { this.enableRenderer(this.batcher); if (color === null) color = WHITE; var i = 0; @@ -409,53 +409,53 @@ export class SceneRenderer implements Disposable { this.batcher.draw(region.page.texture, quad, QUAD_TRIANGLES); } - line(x: number, y: number, x2: number, y2: number, color: Color = null, color2: Color = null) { + line (x: number, y: number, x2: number, y2: number, color: Color = null, color2: Color = null) { this.enableRenderer(this.shapes); this.shapes.line(x, y, x2, y2, color); } - triangle(filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, color: Color = null, color2: Color = null, color3: Color = null) { + triangle (filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, color: Color = null, color2: Color = null, color3: Color = null) { this.enableRenderer(this.shapes); this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3); } - quad(filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, color: Color = null, color2: Color = null, color3: Color = null, color4: Color = null) { + quad (filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, color: Color = null, color2: Color = null, color3: Color = null, color4: Color = null) { this.enableRenderer(this.shapes); this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4); } - rect(filled: boolean, x: number, y: number, width: number, height: number, color: Color = null) { + rect (filled: boolean, x: number, y: number, width: number, height: number, color: Color = null) { this.enableRenderer(this.shapes); this.shapes.rect(filled, x, y, width, height, color); } - rectLine(filled: boolean, x1: number, y1: number, x2: number, y2: number, width: number, color: Color = null) { + rectLine (filled: boolean, x1: number, y1: number, x2: number, y2: number, width: number, color: Color = null) { this.enableRenderer(this.shapes); this.shapes.rectLine(filled, x1, y1, x2, y2, width, color); } - polygon(polygonVertices: ArrayLike, offset: number, count: number, color: Color = null) { + polygon (polygonVertices: ArrayLike, offset: number, count: number, color: Color = null) { this.enableRenderer(this.shapes); this.shapes.polygon(polygonVertices, offset, count, color); } - circle(filled: boolean, x: number, y: number, radius: number, color: Color = null, segments: number = 0) { + circle (filled: boolean, x: number, y: number, radius: number, color: Color = null, segments: number = 0) { this.enableRenderer(this.shapes); this.shapes.circle(filled, x, y, radius, color, segments); } - curve(x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, segments: number, color: Color = null) { + curve (x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, segments: number, color: Color = null) { this.enableRenderer(this.shapes); this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color); } - end() { + end () { if (this.activeRenderer === this.batcher) this.batcher.end(); else if (this.activeRenderer === this.shapes) this.shapes.end(); this.activeRenderer = null; } - resize(resizeMode: ResizeMode) { + resize (resizeMode: ResizeMode) { let canvas = this.canvas; var dpr = window.devicePixelRatio || 1; var w = Math.round(canvas.clientWidth * dpr); @@ -481,7 +481,7 @@ export class SceneRenderer implements Disposable { this.camera.update(); } - private enableRenderer(renderer: PolygonBatcher | ShapeRenderer | SkeletonDebugRenderer) { + private enableRenderer (renderer: PolygonBatcher | ShapeRenderer | SkeletonDebugRenderer) { if (this.activeRenderer === renderer) return; this.end(); if (renderer instanceof PolygonBatcher) { @@ -499,7 +499,7 @@ export class SceneRenderer implements Disposable { this.activeRenderer = this.skeletonDebugRenderer; } - dispose() { + dispose () { this.batcher.dispose(); this.batcherShader.dispose(); this.shapes.dispose(); diff --git a/spine-ts/spine-webgl/src/Shader.ts b/spine-ts/spine-webgl/src/Shader.ts index 7cf95cf45..c7645011d 100644 --- a/spine-ts/spine-webgl/src/Shader.ts +++ b/spine-ts/spine-webgl/src/Shader.ts @@ -48,13 +48,13 @@ export class Shader implements Disposable, Restorable { private tmp3x3: Float32Array = new Float32Array(3 * 3); private tmp4x4: Float32Array = new Float32Array(4 * 4); - public getProgram() { return this.program; } - public getVertexShader() { return this.vertexShader; } - public getFragmentShader() { return this.fragmentShader; } - public getVertexShaderSource() { return this.vsSource; } - public getFragmentSource() { return this.fsSource; } + public getProgram () { return this.program; } + public getVertexShader () { return this.vertexShader; } + public getFragmentShader () { return this.fragmentShader; } + public getVertexShaderSource () { return this.vsSource; } + public getFragmentSource () { return this.fsSource; } - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, private vertexShader: string, private fragmentShader: string) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, private vertexShader: string, private fragmentShader: string) { this.vsSource = vertexShader; this.fsSource = fragmentShader; this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); @@ -62,7 +62,7 @@ export class Shader implements Disposable, Restorable { this.compile(); } - private compile() { + private compile () { let gl = this.context.gl; try { this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader); @@ -74,7 +74,7 @@ export class Shader implements Disposable, Restorable { } } - private compileShader(type: number, source: string) { + private compileShader (type: number, source: string) { let gl = this.context.gl; let shader = gl.createShader(type); gl.shaderSource(shader, source); @@ -87,7 +87,7 @@ export class Shader implements Disposable, Restorable { return shader; } - private compileProgram(vs: WebGLShader, fs: WebGLShader) { + private compileProgram (vs: WebGLShader, fs: WebGLShader) { let gl = this.context.gl; let program = gl.createProgram(); gl.attachShader(program, vs); @@ -102,71 +102,71 @@ export class Shader implements Disposable, Restorable { return program; } - restore() { + restore () { this.compile(); } - public bind() { + public bind () { this.context.gl.useProgram(this.program); } - public unbind() { + public unbind () { this.context.gl.useProgram(null); } - public setUniformi(uniform: string, value: number) { + public setUniformi (uniform: string, value: number) { this.context.gl.uniform1i(this.getUniformLocation(uniform), value); } - public setUniformf(uniform: string, value: number) { + public setUniformf (uniform: string, value: number) { this.context.gl.uniform1f(this.getUniformLocation(uniform), value); } - public setUniform2f(uniform: string, value: number, value2: number) { + public setUniform2f (uniform: string, value: number, value2: number) { this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2); } - public setUniform3f(uniform: string, value: number, value2: number, value3: number) { + public setUniform3f (uniform: string, value: number, value2: number, value3: number) { this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3); } - public setUniform4f(uniform: string, value: number, value2: number, value3: number, value4: number) { + public setUniform4f (uniform: string, value: number, value2: number, value3: number, value4: number) { this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4); } - public setUniform2x2f(uniform: string, value: ArrayLike) { + public setUniform2x2f (uniform: string, value: ArrayLike) { let gl = this.context.gl; this.tmp2x2.set(value); gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2); } - public setUniform3x3f(uniform: string, value: ArrayLike) { + public setUniform3x3f (uniform: string, value: ArrayLike) { let gl = this.context.gl; this.tmp3x3.set(value); gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3); } - public setUniform4x4f(uniform: string, value: ArrayLike) { + public setUniform4x4f (uniform: string, value: ArrayLike) { let gl = this.context.gl; this.tmp4x4.set(value); gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4); } - public getUniformLocation(uniform: string): WebGLUniformLocation { + public getUniformLocation (uniform: string): WebGLUniformLocation { let gl = this.context.gl; let location = gl.getUniformLocation(this.program, uniform); if (!location && !gl.isContextLost()) throw new Error(`Couldn't find location for uniform ${uniform}`); return location; } - public getAttributeLocation(attribute: string): number { + public getAttributeLocation (attribute: string): number { let gl = this.context.gl; let location = gl.getAttribLocation(this.program, attribute); if (location == -1 && !gl.isContextLost()) throw new Error(`Couldn't find location for attribute ${attribute}`); return location; } - public dispose() { + public dispose () { this.context.removeRestorable(this); let gl = this.context.gl; @@ -186,7 +186,7 @@ export class Shader implements Disposable, Restorable { } } - public static newColoredTextured(context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader { + public static newColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader { let vs = ` attribute vec4 ${Shader.POSITION}; attribute vec4 ${Shader.COLOR}; @@ -221,7 +221,7 @@ export class Shader implements Disposable, Restorable { return new Shader(context, vs, fs); } - public static newTwoColoredTextured(context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader { + public static newTwoColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader { let vs = ` attribute vec4 ${Shader.POSITION}; attribute vec4 ${Shader.COLOR}; @@ -262,7 +262,7 @@ export class Shader implements Disposable, Restorable { return new Shader(context, vs, fs); } - public static newColored(context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader { + public static newColored (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader { let vs = ` attribute vec4 ${Shader.POSITION}; attribute vec4 ${Shader.COLOR}; diff --git a/spine-ts/spine-webgl/src/ShapeRenderer.ts b/spine-ts/spine-webgl/src/ShapeRenderer.ts index 78f3495d0..2018ef3e1 100644 --- a/spine-ts/spine-webgl/src/ShapeRenderer.ts +++ b/spine-ts/spine-webgl/src/ShapeRenderer.ts @@ -45,7 +45,7 @@ export class ShapeRenderer implements Disposable { private srcAlphaBlend: number; private dstBlend: number; - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, maxVertices: number = 10920) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext, maxVertices: number = 10920) { if (maxVertices > 10920) throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); this.mesh = new Mesh(context, [new Position2Attribute(), new ColorAttribute()], maxVertices, 0); @@ -55,7 +55,7 @@ export class ShapeRenderer implements Disposable { this.dstBlend = gl.ONE_MINUS_SRC_ALPHA; } - begin(shader: Shader) { + begin (shader: Shader) { if (this.isDrawing) throw new Error("ShapeRenderer.begin() has already been called"); this.shader = shader; this.vertexIndex = 0; @@ -66,7 +66,7 @@ export class ShapeRenderer implements Disposable { gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend); } - setBlendMode(srcColorBlend: number, srcAlphaBlend: number, dstBlend: number) { + setBlendMode (srcColorBlend: number, srcAlphaBlend: number, dstBlend: number) { this.srcColorBlend = srcColorBlend; this.srcAlphaBlend = srcAlphaBlend; this.dstBlend = dstBlend; @@ -77,21 +77,21 @@ export class ShapeRenderer implements Disposable { } } - setColor(color: Color) { + setColor (color: Color) { this.color.setFromColor(color); } - setColorWith(r: number, g: number, b: number, a: number) { + setColorWith (r: number, g: number, b: number, a: number) { this.color.set(r, g, b, a); } - point(x: number, y: number, color: Color = null) { + point (x: number, y: number, color: Color = null) { this.check(ShapeType.Point, 1); if (color === null) color = this.color; this.vertex(x, y, color); } - line(x: number, y: number, x2: number, y2: number, color: Color = null) { + line (x: number, y: number, x2: number, y2: number, color: Color = null) { this.check(ShapeType.Line, 2); let vertices = this.mesh.getVertices(); let idx = this.vertexIndex; @@ -100,7 +100,7 @@ export class ShapeRenderer implements Disposable { this.vertex(x2, y2, color); } - triangle(filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, color: Color = null, color2: Color = null, color3: Color = null) { + triangle (filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, color: Color = null, color2: Color = null, color3: Color = null) { this.check(filled ? ShapeType.Filled : ShapeType.Line, 3); let vertices = this.mesh.getVertices(); let idx = this.vertexIndex; @@ -123,7 +123,7 @@ export class ShapeRenderer implements Disposable { } } - quad(filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, color: Color = null, color2: Color = null, color3: Color = null, color4: Color = null) { + quad (filled: boolean, x: number, y: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, color: Color = null, color2: Color = null, color3: Color = null, color4: Color = null) { this.check(filled ? ShapeType.Filled : ShapeType.Line, 3); let vertices = this.mesh.getVertices(); let idx = this.vertexIndex; @@ -142,11 +142,11 @@ export class ShapeRenderer implements Disposable { } } - rect(filled: boolean, x: number, y: number, width: number, height: number, color: Color = null) { + rect (filled: boolean, x: number, y: number, width: number, height: number, color: Color = null) { this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color); } - rectLine(filled: boolean, x1: number, y1: number, x2: number, y2: number, width: number, color: Color = null) { + rectLine (filled: boolean, x1: number, y1: number, x2: number, y2: number, width: number, color: Color = null) { this.check(filled ? ShapeType.Filled : ShapeType.Line, 8); if (color === null) color = this.color; let t = this.tmp.set(y2 - y1, x1 - x2); @@ -176,12 +176,12 @@ export class ShapeRenderer implements Disposable { } } - x(x: number, y: number, size: number) { + x (x: number, y: number, size: number) { this.line(x - size, y - size, x + size, y + size); this.line(x - size, y + size, x + size, y - size); } - polygon(polygonVertices: ArrayLike, offset: number, count: number, color: Color = null) { + polygon (polygonVertices: ArrayLike, offset: number, count: number, color: Color = null) { if (count < 3) throw new Error("Polygon must contain at least 3 vertices"); this.check(ShapeType.Line, count * 2); if (color === null) color = this.color; @@ -215,7 +215,7 @@ export class ShapeRenderer implements Disposable { } } - circle(filled: boolean, x: number, y: number, radius: number, color: Color = null, segments: number = 0) { + circle (filled: boolean, x: number, y: number, radius: number, color: Color = null, segments: number = 0) { if (segments === 0) segments = Math.max(1, (6 * MathUtils.cbrt(radius)) | 0); if (segments <= 0) throw new Error("segments must be > 0."); if (color === null) color = this.color; @@ -256,7 +256,7 @@ export class ShapeRenderer implements Disposable { this.vertex(x + cx, y + cy, color); } - curve(x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, segments: number, color: Color = null) { + curve (x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, segments: number, color: Color = null) { this.check(ShapeType.Line, segments * 2 + 2); if (color === null) color = this.color; @@ -302,7 +302,7 @@ export class ShapeRenderer implements Disposable { this.vertex(x2, y2, color); } - private vertex(x: number, y: number, color: Color) { + private vertex (x: number, y: number, color: Color) { let idx = this.vertexIndex; let vertices = this.mesh.getVertices(); vertices[idx++] = x; @@ -314,7 +314,7 @@ export class ShapeRenderer implements Disposable { this.vertexIndex = idx; } - end() { + end () { if (!this.isDrawing) throw new Error("ShapeRenderer.begin() has not been called"); this.flush(); let gl = this.context.gl; @@ -322,14 +322,14 @@ export class ShapeRenderer implements Disposable { this.isDrawing = false; } - private flush() { + private flush () { if (this.vertexIndex == 0) return; this.mesh.setVerticesLength(this.vertexIndex); this.mesh.draw(this.shader, this.shapeType); this.vertexIndex = 0; } - private check(shapeType: ShapeType, numVertices: number) { + private check (shapeType: ShapeType, numVertices: number) { if (!this.isDrawing) throw new Error("ShapeRenderer.begin() has not been called"); if (this.shapeType == shapeType) { if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices) this.flush(); @@ -340,7 +340,7 @@ export class ShapeRenderer implements Disposable { } } - dispose() { + dispose () { this.mesh.dispose(); } } diff --git a/spine-ts/spine-webgl/src/SkeletonDebugRenderer.ts b/spine-ts/spine-webgl/src/SkeletonDebugRenderer.ts index 9ac84ef99..92a0ca14f 100644 --- a/spine-ts/spine-webgl/src/SkeletonDebugRenderer.ts +++ b/spine-ts/spine-webgl/src/SkeletonDebugRenderer.ts @@ -58,11 +58,11 @@ export class SkeletonDebugRenderer implements Disposable { private static LIGHT_GRAY = new Color(192 / 255, 192 / 255, 192 / 255, 1); private static GREEN = new Color(0, 1, 0, 1); - constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext) { + constructor (context: ManagedWebGLRenderingContext | WebGLRenderingContext) { this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context); } - draw(shapes: ShapeRenderer, skeleton: Skeleton, ignoredBones: Array = null) { + draw (shapes: ShapeRenderer, skeleton: Skeleton, ignoredBones: Array = null) { let skeletonX = skeleton.x; let skeletonY = skeleton.y; let gl = this.context.gl; @@ -222,6 +222,6 @@ export class SkeletonDebugRenderer implements Disposable { } } - dispose() { + dispose () { } } diff --git a/spine-ts/spine-webgl/src/SkeletonRenderer.ts b/spine-ts/spine-webgl/src/SkeletonRenderer.ts index e1b0365e9..b4ccbcd08 100644 --- a/spine-ts/spine-webgl/src/SkeletonRenderer.ts +++ b/spine-ts/spine-webgl/src/SkeletonRenderer.ts @@ -34,7 +34,7 @@ import { ManagedWebGLRenderingContext, WebGLBlendModeConverter } from "./WebGL"; class Renderable { - constructor(public vertices: NumberArrayLike, public numVertices: number, public numFloats: number) { } + constructor (public vertices: NumberArrayLike, public numVertices: number, public numFloats: number) { } }; export class SkeletonRenderer { @@ -54,14 +54,14 @@ export class SkeletonRenderer { private temp3 = new Color(); private temp4 = new Color(); - constructor(context: ManagedWebGLRenderingContext, twoColorTint: boolean = true) { + constructor (context: ManagedWebGLRenderingContext, twoColorTint: boolean = true) { this.twoColorTint = twoColorTint; if (twoColorTint) this.vertexSize += 4; this.vertices = Utils.newFloatArray(this.vertexSize * 1024); } - draw(batcher: PolygonBatcher, skeleton: Skeleton, slotRangeStart: number = -1, slotRangeEnd: number = -1) { + draw (batcher: PolygonBatcher, skeleton: Skeleton, slotRangeStart: number = -1, slotRangeEnd: number = -1) { let clipper = this.clipper; let premultipliedAlpha = this.premultipliedAlpha; let twoColorTint = this.twoColorTint; diff --git a/spine-ts/spine-webgl/src/Vector3.ts b/spine-ts/spine-webgl/src/Vector3.ts index 9e71ffdde..3dc30c491 100644 --- a/spine-ts/spine-webgl/src/Vector3.ts +++ b/spine-ts/spine-webgl/src/Vector3.ts @@ -34,48 +34,48 @@ export class Vector3 { y = 0; z = 0; - constructor(x: number = 0, y: number = 0, z: number = 0) { + constructor (x: number = 0, y: number = 0, z: number = 0) { this.x = x; this.y = y; this.z = z; } - setFrom(v: Vector3): Vector3 { + setFrom (v: Vector3): Vector3 { this.x = v.x; this.y = v.y; this.z = v.z; return this; } - set(x: number, y: number, z: number): Vector3 { + set (x: number, y: number, z: number): Vector3 { this.x = x; this.y = y; this.z = z; return this; } - add(v: Vector3): Vector3 { + add (v: Vector3): Vector3 { this.x += v.x; this.y += v.y; this.z += v.z; return this; } - sub(v: Vector3): Vector3 { + sub (v: Vector3): Vector3 { this.x -= v.x; this.y -= v.y; this.z -= v.z; return this; } - scale(s: number): Vector3 { + scale (s: number): Vector3 { this.x *= s; this.y *= s; this.z *= s; return this; } - normalize(): Vector3 { + normalize (): Vector3 { let len = this.length(); if (len == 0) return this; len = 1 / len; @@ -85,18 +85,18 @@ export class Vector3 { return this; } - cross(v: Vector3): Vector3 { + cross (v: Vector3): Vector3 { return this.set(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x) } - multiply(matrix: Matrix4): Vector3 { + multiply (matrix: Matrix4): Vector3 { let l_mat = matrix.values; return this.set(this.x * l_mat[M00] + this.y * l_mat[M01] + this.z * l_mat[M02] + l_mat[M03], this.x * l_mat[M10] + this.y * l_mat[M11] + this.z * l_mat[M12] + l_mat[M13], this.x * l_mat[M20] + this.y * l_mat[M21] + this.z * l_mat[M22] + l_mat[M23]); } - project(matrix: Matrix4): Vector3 { + project (matrix: Matrix4): Vector3 { let l_mat = matrix.values; let l_w = 1 / (this.x * l_mat[M30] + this.y * l_mat[M31] + this.z * l_mat[M32] + l_mat[M33]); return this.set((this.x * l_mat[M00] + this.y * l_mat[M01] + this.z * l_mat[M02] + l_mat[M03]) * l_w, @@ -104,15 +104,15 @@ export class Vector3 { (this.x * l_mat[M20] + this.y * l_mat[M21] + this.z * l_mat[M22] + l_mat[M23]) * l_w); } - dot(v: Vector3): number { + dot (v: Vector3): number { return this.x * v.x + this.y * v.y + this.z * v.z; } - length(): number { + length (): number { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } - distance(v: Vector3): number { + distance (v: Vector3): number { let a = v.x - this.x; let b = v.y - this.y; let c = v.z - this.z; diff --git a/spine-ts/spine-webgl/src/WebGL.ts b/spine-ts/spine-webgl/src/WebGL.ts index cb9d1505a..1ad25f125 100644 --- a/spine-ts/spine-webgl/src/WebGL.ts +++ b/spine-ts/spine-webgl/src/WebGL.ts @@ -34,7 +34,7 @@ export class ManagedWebGLRenderingContext { public gl: WebGLRenderingContext; private restorables = new Array(); - constructor(canvasOrContext: HTMLCanvasElement | WebGLRenderingContext | EventTarget, contextConfig: any = { alpha: "true" }) { + constructor (canvasOrContext: HTMLCanvasElement | WebGLRenderingContext | EventTarget, contextConfig: any = { alpha: "true" }) { if (!((canvasOrContext instanceof WebGLRenderingContext) || (typeof WebGL2RenderingContext !== 'undefined' && canvasOrContext instanceof WebGL2RenderingContext))) this.setupCanvas(canvasOrContext, contextConfig); else { @@ -43,7 +43,7 @@ export class ManagedWebGLRenderingContext { } } - private setupCanvas(canvas: any, contextConfig: any) { + private setupCanvas (canvas: any, contextConfig: any) { this.gl = (canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig)); this.canvas = canvas; canvas.addEventListener("webglcontextlost", (e: any) => { @@ -57,11 +57,11 @@ export class ManagedWebGLRenderingContext { }); } - addRestorable(restorable: Restorable) { + addRestorable (restorable: Restorable) { this.restorables.push(restorable); } - removeRestorable(restorable: Restorable) { + removeRestorable (restorable: Restorable) { let index = this.restorables.indexOf(restorable); if (index > -1) this.restorables.splice(index, 1); } @@ -75,7 +75,7 @@ const ONE_MINUS_DST_ALPHA = 0x0305; const DST_COLOR = 0x0306; export class WebGLBlendModeConverter { - static getDestGLBlendMode(blendMode: BlendMode) { + static getDestGLBlendMode (blendMode: BlendMode) { switch (blendMode) { case BlendMode.Normal: return ONE_MINUS_SRC_ALPHA; case BlendMode.Additive: return ONE; @@ -85,7 +85,7 @@ export class WebGLBlendModeConverter { } } - static getSourceColorGLBlendMode(blendMode: BlendMode, premultipliedAlpha: boolean = false) { + static getSourceColorGLBlendMode (blendMode: BlendMode, premultipliedAlpha: boolean = false) { switch (blendMode) { case BlendMode.Normal: return premultipliedAlpha ? ONE : SRC_ALPHA; case BlendMode.Additive: return premultipliedAlpha ? ONE : SRC_ALPHA; @@ -95,7 +95,7 @@ export class WebGLBlendModeConverter { } } - static getSourceAlphaGLBlendMode(blendMode: BlendMode) { + static getSourceAlphaGLBlendMode (blendMode: BlendMode) { switch (blendMode) { case BlendMode.Normal: return ONE; case BlendMode.Additive: return ONE;