UNPKG

@esotericsoftware/spine-webgl

Version:
4 lines 1.03 MB
{ "version": 3, "sources": ["../../../spine-core/src/Utils.ts", "../../../spine-core/src/attachments/Attachment.ts", "../../../spine-core/src/attachments/Sequence.ts", "../../../spine-core/src/Animation.ts", "../../../spine-core/src/AnimationState.ts", "../../../spine-core/src/AnimationStateData.ts", "../../../spine-core/src/attachments/BoundingBoxAttachment.ts", "../../../spine-core/src/attachments/ClippingAttachment.ts", "../../../spine-core/src/Texture.ts", "../../../spine-core/src/TextureAtlas.ts", "../../../spine-core/src/attachments/MeshAttachment.ts", "../../../spine-core/src/attachments/PathAttachment.ts", "../../../spine-core/src/attachments/PointAttachment.ts", "../../../spine-core/src/attachments/RegionAttachment.ts", "../../../spine-core/src/AtlasAttachmentLoader.ts", "../../../spine-core/src/BoneData.ts", "../../../spine-core/src/Bone.ts", "../../../spine-core/src/ConstraintData.ts", "../../../spine-core/src/AssetManagerBase.ts", "../../../spine-core/src/Event.ts", "../../../spine-core/src/EventData.ts", "../../../spine-core/src/IkConstraint.ts", "../../../spine-core/src/IkConstraintData.ts", "../../../spine-core/src/PathConstraintData.ts", "../../../spine-core/src/PathConstraint.ts", "../../../spine-core/src/PhysicsConstraint.ts", "../../../spine-core/src/Slot.ts", "../../../spine-core/src/TransformConstraint.ts", "../../../spine-core/src/Skeleton.ts", "../../../spine-core/src/PhysicsConstraintData.ts", "../../../spine-core/src/SkeletonData.ts", "../../../spine-core/src/Skin.ts", "../../../spine-core/src/SlotData.ts", "../../../spine-core/src/TransformConstraintData.ts", "../../../spine-core/src/SkeletonBinary.ts", "../../../spine-core/src/SkeletonBounds.ts", "../../../spine-core/src/Triangulator.ts", "../../../spine-core/src/SkeletonClipping.ts", "../../../spine-core/src/SkeletonJson.ts", "../../../spine-core/src/polyfills.ts", "../../src/WebGL.ts", "../../src/GLTexture.ts", "../../src/AssetManager.ts", "../../src/Vector3.ts", "../../src/Matrix4.ts", "../../src/Camera.ts", "../../src/Input.ts", "../../src/CameraController.ts", "../../src/Shader.ts", "../../src/Mesh.ts", "../../src/PolygonBatcher.ts", "../../src/ShapeRenderer.ts", "../../src/SkeletonDebugRenderer.ts", "../../src/SkeletonRenderer.ts", "../../src/SceneRenderer.ts", "../../src/LoadingScreen.ts", "../../src/SpineCanvas.ts"], "sourcesContent": ["/******************************************************************************\n * Spine Runtimes License Agreement\n * Last updated April 5, 2025. Replaces all prior versions.\n *\n * Copyright (c) 2013-2025, Esoteric Software LLC\n *\n * Integration of the Spine Runtimes into software or otherwise creating\n * derivative works of the Spine Runtimes is permitted under the terms and\n * conditions of Section 2 of the Spine Editor License Agreement:\n * http://esotericsoftware.com/spine-editor-license\n *\n * Otherwise, it is permitted to integrate the Spine Runtimes into software\n * or otherwise create derivative works of the Spine Runtimes (collectively,\n * \"Products\"), provided that each user of the Products must obtain their own\n * Spine Editor license and redistribution of the Products in any form must\n * include this license and copyright notice.\n *\n * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,\n * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *****************************************************************************/\n\nimport { Skeleton } from \"./Skeleton.js\";\nimport { MixBlend } from \"./Animation.js\";\n\nexport interface StringMap<T> {\n\t[key: string]: T;\n}\n\nexport class IntSet {\n\tarray = new Array<number | undefined>();\n\n\tadd (value: number): boolean {\n\t\tlet contains = this.contains(value);\n\t\tthis.array[value | 0] = value | 0;\n\t\treturn !contains;\n\t}\n\n\tcontains (value: number) {\n\t\treturn this.array[value | 0] != undefined;\n\t}\n\n\tremove (value: number) {\n\t\tthis.array[value | 0] = undefined;\n\t}\n\n\tclear () {\n\t\tthis.array.length = 0;\n\t}\n}\n\nexport class StringSet {\n\tentries: StringMap<boolean> = {};\n\tsize = 0;\n\n\tadd (value: string): boolean {\n\t\tlet contains = this.entries[value];\n\t\tthis.entries[value] = true;\n\t\tif (!contains) {\n\t\t\tthis.size++;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\taddAll (values: string[]): boolean {\n\t\tlet oldSize = this.size;\n\t\tfor (var i = 0, n = values.length; i < n; i++)\n\t\t\tthis.add(values[i]);\n\t\treturn oldSize != this.size;\n\t}\n\n\tcontains (value: string) {\n\t\treturn this.entries[value];\n\t}\n\n\tclear () {\n\t\tthis.entries = {};\n\t\tthis.size = 0;\n\t}\n}\n\nexport type NumberArrayLike = Array<number> | Float32Array;\nexport type IntArrayLike = Array<number> | Int16Array;\n\nexport interface Disposable {\n\tdispose (): void;\n}\n\nexport interface Restorable {\n\trestore (): void;\n}\n\nexport class Color {\n\tpublic static WHITE = new Color(1, 1, 1, 1);\n\tpublic static RED = new Color(1, 0, 0, 1);\n\tpublic static GREEN = new Color(0, 1, 0, 1);\n\tpublic static BLUE = new Color(0, 0, 1, 1);\n\tpublic static MAGENTA = new Color(1, 0, 1, 1);\n\n\tconstructor (public r: number = 0, public g: number = 0, public b: number = 0, public a: number = 0) {\n\t}\n\n\tset (r: number, g: number, b: number, a: number) {\n\t\tthis.r = r;\n\t\tthis.g = g;\n\t\tthis.b = b;\n\t\tthis.a = a;\n\t\treturn this.clamp();\n\t}\n\n\tsetFromColor (c: Color) {\n\t\tthis.r = c.r;\n\t\tthis.g = c.g;\n\t\tthis.b = c.b;\n\t\tthis.a = c.a;\n\t\treturn this;\n\t}\n\n\tsetFromString (hex: string) {\n\t\thex = hex.charAt(0) == '#' ? hex.substr(1) : hex;\n\t\tthis.r = parseInt(hex.substr(0, 2), 16) / 255;\n\t\tthis.g = parseInt(hex.substr(2, 2), 16) / 255;\n\t\tthis.b = parseInt(hex.substr(4, 2), 16) / 255;\n\t\tthis.a = hex.length != 8 ? 1 : parseInt(hex.substr(6, 2), 16) / 255;\n\t\treturn this;\n\t}\n\n\tadd (r: number, g: number, b: number, a: number) {\n\t\tthis.r += r;\n\t\tthis.g += g;\n\t\tthis.b += b;\n\t\tthis.a += a;\n\t\treturn this.clamp();\n\t}\n\n\tclamp () {\n\t\tif (this.r < 0) this.r = 0;\n\t\telse if (this.r > 1) this.r = 1;\n\n\t\tif (this.g < 0) this.g = 0;\n\t\telse if (this.g > 1) this.g = 1;\n\n\t\tif (this.b < 0) this.b = 0;\n\t\telse if (this.b > 1) this.b = 1;\n\n\t\tif (this.a < 0) this.a = 0;\n\t\telse if (this.a > 1) this.a = 1;\n\t\treturn this;\n\t}\n\n\tstatic rgba8888ToColor (color: Color, value: number) {\n\t\tcolor.r = ((value & 0xff000000) >>> 24) / 255;\n\t\tcolor.g = ((value & 0x00ff0000) >>> 16) / 255;\n\t\tcolor.b = ((value & 0x0000ff00) >>> 8) / 255;\n\t\tcolor.a = ((value & 0x000000ff)) / 255;\n\t}\n\n\tstatic rgb888ToColor (color: Color, value: number) {\n\t\tcolor.r = ((value & 0x00ff0000) >>> 16) / 255;\n\t\tcolor.g = ((value & 0x0000ff00) >>> 8) / 255;\n\t\tcolor.b = ((value & 0x000000ff)) / 255;\n\t}\n\n\ttoRgb888 () {\n\t\tconst hex = (x: number) => (\"0\" + (x * 255).toString(16)).slice(-2);\n\t\treturn Number(\"0x\" + hex(this.r) + hex(this.g) + hex(this.b));\n\t}\n\n\tstatic fromString (hex: string, color = new Color()): Color {\n\t\treturn color.setFromString(hex);\n\t}\n}\n\nexport class MathUtils {\n\tstatic PI = 3.1415927;\n\tstatic PI2 = MathUtils.PI * 2;\n\tstatic invPI2 = 1 / MathUtils.PI2;\n\tstatic radiansToDegrees = 180 / MathUtils.PI;\n\tstatic radDeg = MathUtils.radiansToDegrees;\n\tstatic degreesToRadians = MathUtils.PI / 180;\n\tstatic degRad = MathUtils.degreesToRadians;\n\n\tstatic clamp (value: number, min: number, max: number) {\n\t\tif (value < min) return min;\n\t\tif (value > max) return max;\n\t\treturn value;\n\t}\n\n\tstatic cosDeg (degrees: number) {\n\t\treturn Math.cos(degrees * MathUtils.degRad);\n\t}\n\n\tstatic sinDeg (degrees: number) {\n\t\treturn Math.sin(degrees * MathUtils.degRad);\n\t}\n\n\tstatic atan2Deg (y: number, x: number) {\n\t\treturn Math.atan2(y, x) * MathUtils.degRad;\n\t}\n\n\tstatic signum (value: number): number {\n\t\treturn value > 0 ? 1 : value < 0 ? -1 : 0;\n\t}\n\n\tstatic toInt (x: number) {\n\t\treturn x > 0 ? Math.floor(x) : Math.ceil(x);\n\t}\n\n\tstatic cbrt (x: number) {\n\t\tlet y = Math.pow(Math.abs(x), 1 / 3);\n\t\treturn x < 0 ? -y : y;\n\t}\n\n\tstatic randomTriangular (min: number, max: number): number {\n\t\treturn MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);\n\t}\n\n\tstatic randomTriangularWith (min: number, max: number, mode: number): number {\n\t\tlet u = Math.random();\n\t\tlet d = max - min;\n\t\tif (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min));\n\t\treturn max - Math.sqrt((1 - u) * d * (max - mode));\n\t}\n\n\tstatic isPowerOfTwo (value: number) {\n\t\treturn value && (value & (value - 1)) === 0;\n\t}\n}\n\nexport abstract class Interpolation {\n\tprotected abstract applyInternal (a: number): number;\n\tapply (start: number, end: number, a: number): number {\n\t\treturn start + (end - start) * this.applyInternal(a);\n\t}\n}\n\nexport class Pow extends Interpolation {\n\tprotected power = 2;\n\n\tconstructor (power: number) {\n\t\tsuper();\n\t\tthis.power = power;\n\t}\n\n\tapplyInternal (a: number): number {\n\t\tif (a <= 0.5) return Math.pow(a * 2, this.power) / 2;\n\t\treturn Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;\n\t}\n}\n\nexport class PowOut extends Pow {\n\tconstructor (power: number) {\n\t\tsuper(power);\n\t}\n\n\tapplyInternal (a: number): number {\n\t\treturn Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;\n\t}\n}\n\nexport class Utils {\n\tstatic SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== \"undefined\";\n\n\tstatic arrayCopy<T> (source: ArrayLike<T>, sourceStart: number, dest: ArrayLike<T>, destStart: number, numElements: number) {\n\t\tfor (let i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) {\n\t\t\tdest[j] = source[i];\n\t\t}\n\t}\n\n\tstatic arrayFill<T> (array: ArrayLike<T>, fromIndex: number, toIndex: number, value: T) {\n\t\tfor (let i = fromIndex; i < toIndex; i++)\n\t\t\tarray[i] = value;\n\t}\n\n\tstatic setArraySize<T> (array: Array<T>, size: number, value: any = 0): Array<T> {\n\t\tlet oldSize = array.length;\n\t\tif (oldSize == size) return array;\n\t\tarray.length = size;\n\t\tif (oldSize < size) {\n\t\t\tfor (let i = oldSize; i < size; i++) array[i] = value;\n\t\t}\n\t\treturn array;\n\t}\n\n\tstatic ensureArrayCapacity<T> (array: Array<T>, size: number, value: any = 0): Array<T> {\n\t\tif (array.length >= size) return array;\n\t\treturn Utils.setArraySize(array, size, value);\n\t}\n\n\tstatic newArray<T> (size: number, defaultValue: T): Array<T> {\n\t\tlet array = new Array<T>(size);\n\t\tfor (let i = 0; i < size; i++) array[i] = defaultValue;\n\t\treturn array;\n\t}\n\n\tstatic newFloatArray (size: number): NumberArrayLike {\n\t\tif (Utils.SUPPORTS_TYPED_ARRAYS)\n\t\t\treturn new Float32Array(size)\n\t\telse {\n\t\t\tlet array = new Array<number>(size);\n\t\t\tfor (let i = 0; i < array.length; i++) array[i] = 0;\n\t\t\treturn array;\n\t\t}\n\t}\n\n\tstatic newShortArray (size: number): IntArrayLike {\n\t\tif (Utils.SUPPORTS_TYPED_ARRAYS)\n\t\t\treturn new Int16Array(size)\n\t\telse {\n\t\t\tlet array = new Array<number>(size);\n\t\t\tfor (let i = 0; i < array.length; i++) array[i] = 0;\n\t\t\treturn array;\n\t\t}\n\t}\n\n\tstatic toFloatArray (array: Array<number>) {\n\t\treturn Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;\n\t}\n\n\tstatic toSinglePrecision (value: number) {\n\t\treturn Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;\n\t}\n\n\t// This function is used to fix WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109\n\tstatic webkit602BugfixHelper (alpha: number, blend: MixBlend) {\n\t}\n\n\tstatic contains<T> (array: Array<T>, element: T, identity = true) {\n\t\tfor (var i = 0; i < array.length; i++)\n\t\t\tif (array[i] == element) return true;\n\t\treturn false;\n\t}\n\n\tstatic enumValue (type: any, name: string) {\n\t\treturn type[name[0].toUpperCase() + name.slice(1)];\n\t}\n}\n\nexport class DebugUtils {\n\tstatic logBones (skeleton: Skeleton) {\n\t\tfor (let i = 0; i < skeleton.bones.length; i++) {\n\t\t\tlet bone = skeleton.bones[i];\n\t\t\tconsole.log(bone.data.name + \", \" + bone.a + \", \" + bone.b + \", \" + bone.c + \", \" + bone.d + \", \" + bone.worldX + \", \" + bone.worldY);\n\t\t}\n\t}\n}\n\nexport class Pool<T> {\n\tprivate items = new Array<T>();\n\tprivate instantiator: () => T;\n\n\tconstructor (instantiator: () => T) {\n\t\tthis.instantiator = instantiator;\n\t}\n\n\tobtain () {\n\t\treturn this.items.length > 0 ? this.items.pop()! : this.instantiator();\n\t}\n\n\tfree (item: T) {\n\t\tif ((item as any).reset) (item as any).reset();\n\t\tthis.items.push(item);\n\t}\n\n\tfreeAll (items: ArrayLike<T>) {\n\t\tfor (let i = 0; i < items.length; i++)\n\t\t\tthis.free(items[i]);\n\t}\n\n\tclear () {\n\t\tthis.items.length = 0;\n\t}\n}\n\nexport class Vector2 {\n\tconstructor (public x = 0, public y = 0) {\n\t}\n\n\tset (x: number, y: number): Vector2 {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tlength () {\n\t\tlet x = this.x;\n\t\tlet y = this.y;\n\t\treturn Math.sqrt(x * x + y * y);\n\t}\n\n\tnormalize () {\n\t\tlet len = this.length();\n\t\tif (len != 0) {\n\t\t\tthis.x /= len;\n\t\t\tthis.y /= len;\n\t\t}\n\t\treturn this;\n\t}\n}\n\nexport class TimeKeeper {\n\tmaxDelta = 0.064;\n\tframesPerSecond = 0;\n\tdelta = 0;\n\ttotalTime = 0;\n\n\tprivate lastTime = Date.now() / 1000;\n\tprivate frameCount = 0;\n\tprivate frameTime = 0;\n\n\tupdate () {\n\t\tlet now = Date.now() / 1000;\n\t\tthis.delta = now - this.lastTime;\n\t\tthis.frameTime += this.delta;\n\t\tthis.totalTime += this.delta;\n\t\tif (this.delta > this.maxDelta) this.delta = this.maxDelta;\n\t\tthis.lastTime = now;\n\n\t\tthis.frameCount++;\n\t\tif (this.frameTime > 1) {\n\t\t\tthis.framesPerSecond = this.frameCount / this.frameTime;\n\t\t\tthis.frameTime = 0;\n\t\t\tthis.frameCount = 0;\n\t\t}\n\t}\n}\n\nexport interface ArrayLike<T> {\n\tlength: number;\n\t[n: number]: T;\n}\n\nexport class WindowedMean {\n\tvalues: Array<number>;\n\taddedValues = 0;\n\tlastValue = 0;\n\tmean = 0;\n\tdirty = true;\n\n\tconstructor (windowSize: number = 32) {\n\t\tthis.values = new Array<number>(windowSize);\n\t}\n\n\thasEnoughData () {\n\t\treturn this.addedValues >= this.values.length;\n\t}\n\n\taddValue (value: number) {\n\t\tif (this.addedValues < this.values.length) this.addedValues++;\n\t\tthis.values[this.lastValue++] = value;\n\t\tif (this.lastValue > this.values.length - 1) this.lastValue = 0;\n\t\tthis.dirty = true;\n\t}\n\n\tgetMean () {\n\t\tif (this.hasEnoughData()) {\n\t\t\tif (this.dirty) {\n\t\t\t\tlet mean = 0;\n\t\t\t\tfor (let i = 0; i < this.values.length; i++)\n\t\t\t\t\tmean += this.values[i];\n\t\t\t\tthis.mean = mean / this.values.length;\n\t\t\t\tthis.dirty = false;\n\t\t\t}\n\t\t\treturn this.mean;\n\t\t}\n\t\treturn 0;\n\t}\n}\n", "/******************************************************************************\n * Spine Runtimes License Agreement\n * Last updated April 5, 2025. Replaces all prior versions.\n *\n * Copyright (c) 2013-2025, Esoteric Software LLC\n *\n * Integration of the Spine Runtimes into software or otherwise creating\n * derivative works of the Spine Runtimes is permitted under the terms and\n * conditions of Section 2 of the Spine Editor License Agreement:\n * http://esotericsoftware.com/spine-editor-license\n *\n * Otherwise, it is permitted to integrate the Spine Runtimes into software\n * or otherwise create derivative works of the Spine Runtimes (collectively,\n * \"Products\"), provided that each user of the Products must obtain their own\n * Spine Editor license and redistribution of the Products in any form must\n * include this license and copyright notice.\n *\n * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,\n * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *****************************************************************************/\n\nimport { Slot } from \"../Slot.js\";\nimport { NumberArrayLike, Utils } from \"../Utils.js\";\n\n/** The base class for all attachments. */\nexport abstract class Attachment {\n\tname: string;\n\n\tconstructor (name: string) {\n\t\tif (!name) throw new Error(\"name cannot be null.\");\n\t\tthis.name = name;\n\t}\n\n\tabstract copy (): Attachment;\n}\n\n/** Base class for an attachment with vertices that are transformed by one or more bones and can be deformed by a slot's\n * {@link Slot#deform}. */\nexport abstract class VertexAttachment extends Attachment {\n\tprivate static nextID = 0;\n\n\t/** The unique ID for this attachment. */\n\tid = VertexAttachment.nextID++;\n\n\t/** The bones which affect the {@link #getVertices()}. The array entries are, for each vertex, the number of bones affecting\n\t * the vertex followed by that many bone indices, which is the index of the bone in {@link Skeleton#bones}. Will be null\n\t * if this attachment has no weights. */\n\tbones: Array<number> | null = null;\n\n\t/** The vertex positions in the bone's coordinate system. For a non-weighted attachment, the values are `x,y`\n\t * entries for each vertex. For a weighted attachment, the values are `x,y,weight` entries for each bone affecting\n\t * each vertex. */\n\tvertices: NumberArrayLike = [];\n\n\t/** The maximum number of world vertex values that can be output by\n\t * {@link #computeWorldVertices()} using the `count` parameter. */\n\tworldVerticesLength = 0;\n\n\t/** Timelines for the timeline attachment are also applied to this attachment.\n\t * May be null if no attachment-specific timelines should be applied. */\n\ttimelineAttachment: Attachment = this;\n\n\tconstructor (name: string) {\n\t\tsuper(name);\n\t}\n\n\t/** Transforms the attachment's local {@link #vertices} to world coordinates. If the slot's {@link Slot#deform} is\n\t * not empty, it is used to deform the vertices.\n\t *\n\t * See [World transforms](http://esotericsoftware.com/spine-runtime-skeletons#World-transforms) in the Spine\n\t * Runtimes Guide.\n\t * @param start The index of the first {@link #vertices} value to transform. Each vertex has 2 values, x and y.\n\t * @param count The number of world vertex values to output. Must be <= {@link #worldVerticesLength} - `start`.\n\t * @param worldVertices The output world vertices. Must have a length >= `offset` + `count` *\n\t * `stride` / 2.\n\t * @param offset The `worldVertices` index to begin writing values.\n\t * @param stride The number of `worldVertices` entries between the value pairs written. */\n\tcomputeWorldVertices (slot: Slot, start: number, count: number, worldVertices: NumberArrayLike, offset: number, stride: number) {\n\t\tcount = offset + (count >> 1) * stride;\n\t\tlet skeleton = slot.bone.skeleton;\n\t\tlet deformArray = slot.deform;\n\t\tlet vertices = this.vertices;\n\t\tlet bones = this.bones;\n\t\tif (!bones) {\n\t\t\tif (deformArray.length > 0) vertices = deformArray;\n\t\t\tlet bone = slot.bone;\n\t\t\tlet x = bone.worldX;\n\t\t\tlet y = bone.worldY;\n\t\t\tlet a = bone.a, b = bone.b, c = bone.c, d = bone.d;\n\t\t\tfor (let v = start, w = offset; w < count; v += 2, w += stride) {\n\t\t\t\tlet vx = vertices[v], vy = vertices[v + 1];\n\t\t\t\tworldVertices[w] = vx * a + vy * b + x;\n\t\t\t\tworldVertices[w + 1] = vx * c + vy * d + y;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tlet v = 0, skip = 0;\n\t\tfor (let i = 0; i < start; i += 2) {\n\t\t\tlet n = bones[v];\n\t\t\tv += n + 1;\n\t\t\tskip += n;\n\t\t}\n\t\tlet skeletonBones = skeleton.bones;\n\t\tif (deformArray.length == 0) {\n\t\t\tfor (let w = offset, b = skip * 3; w < count; w += stride) {\n\t\t\t\tlet wx = 0, wy = 0;\n\t\t\t\tlet n = bones[v++];\n\t\t\t\tn += v;\n\t\t\t\tfor (; v < n; v++, b += 3) {\n\t\t\t\t\tlet bone = skeletonBones[bones[v]];\n\t\t\t\t\tlet vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2];\n\t\t\t\t\twx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;\n\t\t\t\t\twy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;\n\t\t\t\t}\n\t\t\t\tworldVertices[w] = wx;\n\t\t\t\tworldVertices[w + 1] = wy;\n\t\t\t}\n\t\t} else {\n\t\t\tlet deform = deformArray;\n\t\t\tfor (let w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {\n\t\t\t\tlet wx = 0, wy = 0;\n\t\t\t\tlet n = bones[v++];\n\t\t\t\tn += v;\n\t\t\t\tfor (; v < n; v++, b += 3, f += 2) {\n\t\t\t\t\tlet bone = skeletonBones[bones[v]];\n\t\t\t\t\tlet vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2];\n\t\t\t\t\twx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;\n\t\t\t\t\twy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;\n\t\t\t\t}\n\t\t\t\tworldVertices[w] = wx;\n\t\t\t\tworldVertices[w + 1] = wy;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Does not copy id (generated) or name (set on construction). **/\n\tcopyTo (attachment: VertexAttachment) {\n\t\tif (this.bones) {\n\t\t\tattachment.bones = new Array<number>(this.bones.length);\n\t\t\tUtils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length);\n\t\t} else\n\t\t\tattachment.bones = null;\n\n\t\tif (this.vertices) {\n\t\t\tattachment.vertices = Utils.newFloatArray(this.vertices.length);\n\t\t\tUtils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);\n\t\t}\n\n\t\tattachment.worldVerticesLength = this.worldVerticesLength;\n\t\tattachment.timelineAttachment = this.timelineAttachment;\n\t}\n}\n", "/******************************************************************************\n * Spine Runtimes License Agreement\n * Last updated April 5, 2025. Replaces all prior versions.\n *\n * Copyright (c) 2013-2025, Esoteric Software LLC\n *\n * Integration of the Spine Runtimes into software or otherwise creating\n * derivative works of the Spine Runtimes is permitted under the terms and\n * conditions of Section 2 of the Spine Editor License Agreement:\n * http://esotericsoftware.com/spine-editor-license\n *\n * Otherwise, it is permitted to integrate the Spine Runtimes into software\n * or otherwise create derivative works of the Spine Runtimes (collectively,\n * \"Products\"), provided that each user of the Products must obtain their own\n * Spine Editor license and redistribution of the Products in any form must\n * include this license and copyright notice.\n *\n * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,\n * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *****************************************************************************/\n\nimport { TextureRegion } from \"../Texture.js\";\nimport { Slot } from \"../Slot.js\";\nimport { HasTextureRegion } from \"./HasTextureRegion.js\";\nimport { Utils } from \"../Utils.js\";\n\n\nexport class Sequence {\n\tprivate static _nextID = 0;\n\n\tid = Sequence.nextID();\n\tregions: TextureRegion[];\n\tstart = 0;\n\tdigits = 0;\n\t/** The index of the region to show for the setup pose. */\n\tsetupIndex = 0;\n\n\tconstructor (count: number) {\n\t\tthis.regions = new Array<TextureRegion>(count);\n\t}\n\n\tcopy (): Sequence {\n\t\tlet copy = new Sequence(this.regions.length);\n\t\tUtils.arrayCopy(this.regions, 0, copy.regions, 0, this.regions.length);\n\t\tcopy.start = this.start;\n\t\tcopy.digits = this.digits;\n\t\tcopy.setupIndex = this.setupIndex;\n\t\treturn copy;\n\t}\n\n\tapply (slot: Slot, attachment: HasTextureRegion) {\n\t\tlet index = slot.sequenceIndex;\n\t\tif (index == -1) index = this.setupIndex;\n\t\tif (index >= this.regions.length) index = this.regions.length - 1;\n\t\tlet region = this.regions[index];\n\t\tif (attachment.region != region) {\n\t\t\tattachment.region = region;\n\t\t\tattachment.updateRegion();\n\t\t}\n\t}\n\n\tgetPath (basePath: string, index: number): string {\n\t\tlet result = basePath;\n\t\tlet frame = (this.start + index).toString();\n\t\tfor (let i = this.digits - frame.length; i > 0; i--)\n\t\t\tresult += \"0\";\n\t\tresult += frame;\n\t\treturn result;\n\t}\n\n\tprivate static nextID (): number {\n\t\treturn Sequence._nextID++;\n\t}\n}\n\nexport enum SequenceMode {\n\thold = 0,\n\tonce = 1,\n\tloop = 2,\n\tpingpong = 3,\n\tonceReverse = 4,\n\tloopReverse = 5,\n\tpingpongReverse = 6\n}\n\nexport const SequenceModeValues = [\n\tSequenceMode.hold,\n\tSequenceMode.once,\n\tSequenceMode.loop,\n\tSequenceMode.pingpong,\n\tSequenceMode.onceReverse,\n\tSequenceMode.loopReverse,\n\tSequenceMode.pingpongReverse\n];\n", "/******************************************************************************\n * Spine Runtimes License Agreement\n * Last updated April 5, 2025. Replaces all prior versions.\n *\n * Copyright (c) 2013-2025, Esoteric Software LLC\n *\n * Integration of the Spine Runtimes into software or otherwise creating\n * derivative works of the Spine Runtimes is permitted under the terms and\n * conditions of Section 2 of the Spine Editor License Agreement:\n * http://esotericsoftware.com/spine-editor-license\n *\n * Otherwise, it is permitted to integrate the Spine Runtimes into software\n * or otherwise create derivative works of the Spine Runtimes (collectively,\n * \"Products\"), provided that each user of the Products must obtain their own\n * Spine Editor license and redistribution of the Products in any form must\n * include this license and copyright notice.\n *\n * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,\n * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *****************************************************************************/\n\nimport { VertexAttachment, Attachment } from \"./attachments/Attachment.js\";\nimport { IkConstraint } from \"./IkConstraint.js\";\nimport { PathConstraint } from \"./PathConstraint.js\";\nimport { Skeleton } from \"./Skeleton.js\";\nimport { Slot } from \"./Slot.js\";\nimport { TransformConstraint } from \"./TransformConstraint.js\";\nimport { StringSet, Utils, MathUtils, NumberArrayLike } from \"./Utils.js\";\nimport { Event } from \"./Event.js\";\nimport { HasTextureRegion } from \"./attachments/HasTextureRegion.js\";\nimport { SequenceMode, SequenceModeValues } from \"./attachments/Sequence.js\";\nimport { PhysicsConstraint } from \"./PhysicsConstraint.js\";\nimport { PhysicsConstraintData } from \"./PhysicsConstraintData.js\";\nimport { Inherit } from \"./BoneData.js\";\n\n/** A simple container for a list of timelines and a name. */\nexport class Animation {\n\t/** The animation's name, which is unique across all animations in the skeleton. */\n\tname: string;\n\ttimelines: Array<Timeline> = [];\n\ttimelineIds: StringSet = new StringSet();\n\n\t/** The duration of the animation in seconds, which is the highest time of all keys in the timeline. */\n\tduration: number;\n\n\tconstructor (name: string, timelines: Array<Timeline>, duration: number) {\n\t\tif (!name) throw new Error(\"name cannot be null.\");\n\t\tthis.name = name;\n\t\tthis.setTimelines(timelines);\n\t\tthis.duration = duration;\n\t}\n\n\tsetTimelines (timelines: Array<Timeline>) {\n\t\tif (!timelines) throw new Error(\"timelines cannot be null.\");\n\t\tthis.timelines = timelines;\n\t\tthis.timelineIds.clear();\n\t\tfor (var i = 0; i < timelines.length; i++)\n\t\t\tthis.timelineIds.addAll(timelines[i].getPropertyIds());\n\t}\n\n\thasTimeline (ids: string[]): boolean {\n\t\tfor (let i = 0; i < ids.length; i++)\n\t\t\tif (this.timelineIds.contains(ids[i])) return true;\n\t\treturn false;\n\t}\n\n\t/** Applies all the animation's timelines to the specified skeleton.\n\t *\n\t * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}.\n\t * @param loop If true, the animation repeats after {@link #getDuration()}.\n\t * @param events May be null to ignore fired events. */\n\tapply (skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {\n\t\tif (!skeleton) throw new Error(\"skeleton cannot be null.\");\n\n\t\tif (loop && this.duration != 0) {\n\t\t\ttime %= this.duration;\n\t\t\tif (lastTime > 0) lastTime %= this.duration;\n\t\t}\n\n\t\tlet timelines = this.timelines;\n\t\tfor (let i = 0, n = timelines.length; i < n; i++)\n\t\t\ttimelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);\n\t}\n}\n\n/** Controls how a timeline value is mixed with the setup pose value or current pose value when a timeline's `alpha`\n * < 1.\n *\n * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. */\nexport enum MixBlend {\n\t/** Transitions from the setup value to the timeline value (the current value is not used). Before the first key, the setup\n\t * value is set. */\n\tsetup,\n\t/** Transitions from the current value to the timeline value. Before the first key, transitions from the current value to\n\t * the setup value. Timelines which perform instant transitions, such as {@link DrawOrderTimeline} or\n\t * {@link AttachmentTimeline}, use the setup value before the first key.\n\t *\n\t * `first` is intended for the first animations applied, not for animations layered on top of those. */\n\tfirst,\n\t/** Transitions from the current value to the timeline value. No change is made before the first key (the current value is\n\t * kept until the first key).\n\t *\n\t * `replace` is intended for animations layered on top of others, not for the first animations applied. */\n\treplace,\n\t/** Transitions from the current value to the current value plus the timeline value. No change is made before the first key\n\t * (the current value is kept until the first key).\n\t *\n\t * `add` is intended for animations layered on top of others, not for the first animations applied. Properties\n\t * keyed by additive animations must be set manually or by another animation before applying the additive animations, else\n\t * the property values will increase continually. */\n\tadd\n}\n\n/** Indicates whether a timeline's `alpha` is mixing out over time toward 0 (the setup or current pose value) or\n * mixing in toward 1 (the timeline's value).\n *\n * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. */\nexport enum MixDirection {\n\tmixIn, mixOut\n}\n\nconst Property = {\n\trotate: 0,\n\tx: 1,\n\ty: 2,\n\tscaleX: 3,\n\tscaleY: 4,\n\tshearX: 5,\n\tshearY: 6,\n\tinherit: 7,\n\n\trgb: 8,\n\talpha: 9,\n\trgb2: 10,\n\n\tattachment: 11,\n\tdeform: 12,\n\n\tevent: 13,\n\tdrawOrder: 14,\n\n\tikConstraint: 15,\n\ttransformConstraint: 16,\n\n\tpathConstraintPosition: 17,\n\tpathConstraintSpacing: 18,\n\tpathConstraintMix: 19,\n\n\tphysicsConstraintInertia: 20,\n\tphysicsConstraintStrength: 21,\n\tphysicsConstraintDamping: 22,\n\tphysicsConstraintMass: 23,\n\tphysicsConstraintWind: 24,\n\tphysicsConstraintGravity: 25,\n\tphysicsConstraintMix: 26,\n\tphysicsConstraintReset: 27,\n\n\tsequence: 28,\n}\n\n/** The interface for all timelines. */\nexport abstract class Timeline {\n\tpropertyIds: string[];\n\tframes: NumberArrayLike;\n\n\tconstructor (frameCount: number, propertyIds: string[]) {\n\t\tthis.propertyIds = propertyIds;\n\t\tthis.frames = Utils.newFloatArray(frameCount * this.getFrameEntries());\n\t}\n\n\tgetPropertyIds () {\n\t\treturn this.propertyIds;\n\t}\n\n\tgetFrameEntries (): number {\n\t\treturn 1;\n\t}\n\n\tgetFrameCount () {\n\t\treturn this.frames.length / this.getFrameEntries();\n\t}\n\n\tgetDuration (): number {\n\t\treturn this.frames[this.frames.length - this.getFrameEntries()];\n\t}\n\n\tabstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event> | null, alpha: number, blend: MixBlend, direction: MixDirection): void;\n\n\tstatic search1 (frames: NumberArrayLike, time: number) {\n\t\tlet n = frames.length;\n\t\tfor (let i = 1; i < n; i++)\n\t\t\tif (frames[i] > time) return i - 1;\n\t\treturn n - 1;\n\t}\n\n\tstatic search (frames: NumberArrayLike, time: number, step: number) {\n\t\tlet n = frames.length;\n\t\tfor (let i = step; i < n; i += step)\n\t\t\tif (frames[i] > time) return i - step;\n\t\treturn n - step;\n\t}\n}\n\nexport interface BoneTimeline {\n\t/** The index of the bone in {@link Skeleton#bones} that will be changed. */\n\tboneIndex: number;\n}\n\nexport interface SlotTimeline {\n\t/** The index of the slot in {@link Skeleton#slots} that will be changed. */\n\tslotIndex: number;\n}\n\n/** The base class for timelines that use interpolation between key frame values. */\nexport abstract class CurveTimeline extends Timeline {\n\tprotected curves: NumberArrayLike; // type, x, y, ...\n\n\tconstructor (frameCount: number, bezierCount: number, propertyIds: string[]) {\n\t\tsuper(frameCount, propertyIds);\n\t\tthis.curves = Utils.newFloatArray(frameCount + bezierCount * 18/*BEZIER_SIZE*/);\n\t\tthis.curves[frameCount - 1] = 1/*STEPPED*/;\n\t}\n\n\t/** Sets the specified key frame to linear interpolation. */\n\tsetLinear (frame: number) {\n\t\tthis.curves[frame] = 0/*LINEAR*/;\n\t}\n\n\t/** Sets the specified key frame to stepped interpolation. */\n\tsetStepped (frame: number) {\n\t\tthis.curves[frame] = 1/*STEPPED*/;\n\t}\n\n\t/** Shrinks the storage for Bezier curves, for use when <code>bezierCount</code> (specified in the constructor) was larger\n\t * than the actual number of Bezier curves. */\n\tshrink (bezierCount: number) {\n\t\tlet size = this.getFrameCount() + bezierCount * 18/*BEZIER_SIZE*/;\n\t\tif (this.curves.length > size) {\n\t\t\tlet newCurves = Utils.newFloatArray(size);\n\t\t\tUtils.arrayCopy(this.curves, 0, newCurves, 0, size);\n\t\t\tthis.curves = newCurves;\n\t\t}\n\t}\n\n\t/** Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than\n\t * one curve per frame.\n\t * @param bezier The ordinal of this Bezier curve for this timeline, between 0 and <code>bezierCount - 1</code> (specified\n\t * in the constructor), inclusive.\n\t * @param frame Between 0 and <code>frameCount - 1</code>, inclusive.\n\t * @param value The index of the value for this frame that this curve is used for.\n\t * @param time1 The time for the first key.\n\t * @param value1 The value for the first key.\n\t * @param cx1 The time for the first Bezier handle.\n\t * @param cy1 The value for the first Bezier handle.\n\t * @param cx2 The time of the second Bezier handle.\n\t * @param cy2 The value for the second Bezier handle.\n\t * @param time2 The time for the second key.\n\t * @param value2 The value for the second key. */\n\tsetBezier (bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number,\n\t\tcy2: number, time2: number, value2: number) {\n\t\tlet curves = this.curves;\n\t\tlet i = this.getFrameCount() + bezier * 18/*BEZIER_SIZE*/;\n\t\tif (value == 0) curves[frame] = 2/*BEZIER*/ + i;\n\t\tlet tmpx = (time1 - cx1 * 2 + cx2) * 0.03, tmpy = (value1 - cy1 * 2 + cy2) * 0.03;\n\t\tlet dddx = ((cx1 - cx2) * 3 - time1 + time2) * 0.006, dddy = ((cy1 - cy2) * 3 - value1 + value2) * 0.006;\n\t\tlet ddx = tmpx * 2 + dddx, ddy = tmpy * 2 + dddy;\n\t\tlet dx = (cx1 - time1) * 0.3 + tmpx + dddx * 0.16666667, dy = (cy1 - value1) * 0.3 + tmpy + dddy * 0.16666667;\n\t\tlet x = time1 + dx, y = value1 + dy;\n\t\tfor (let n = i + 18/*BEZIER_SIZE*/; i < n; i += 2) {\n\t\t\tcurves[i] = x;\n\t\t\tcurves[i + 1] = y;\n\t\t\tdx += ddx;\n\t\t\tdy += ddy;\n\t\t\tddx += dddx;\n\t\t\tddy += dddy;\n\t\t\tx += dx;\n\t\t\ty += dy;\n\t\t}\n\t}\n\n\t/** Returns the Bezier interpolated value for the specified time.\n\t * @param frameIndex The index into {@link #getFrames()} for the values of the frame before <code>time</code>.\n\t * @param valueOffset The offset from <code>frameIndex</code> to the value this curve is used for.\n\t * @param i The index of the Bezier segments. See {@link #getCurveType(int)}. */\n\tgetBezierValue (time: number, frameIndex: number, valueOffset: number, i: number) {\n\t\tlet curves = this.curves;\n\t\tif (curves[i] > time) {\n\t\t\tlet x = this.frames[frameIndex], y = this.frames[frameIndex + valueOffset];\n\t\t\treturn y + (time - x) / (curves[i] - x) * (curves[i + 1] - y);\n\t\t}\n\t\tlet n = i + 18/*BEZIER_SIZE*/;\n\t\tfor (i += 2; i < n; i += 2) {\n\t\t\tif (curves[i] >= time) {\n\t\t\t\tlet x = curves[i - 2], y = curves[i - 1];\n\t\t\t\treturn y + (time - x) / (curves[i] - x) * (curves[i + 1] - y);\n\t\t\t}\n\t\t}\n\t\tframeIndex += this.getFrameEntries();\n\t\tlet x = curves[n - 2], y = curves[n - 1];\n\t\treturn y + (time - x) / (this.frames[frameIndex] - x) * (this.frames[frameIndex + valueOffset] - y);\n\t}\n}\n\nexport abstract class CurveTimeline1 extends CurveTimeline {\n\tconstructor (frameCount: number, bezierCount: number, propertyId: string) {\n\t\tsuper(frameCount, bezierCount, [propertyId]);\n\t}\n\n\tgetFrameEntries () {\n\t\treturn 2/*ENTRIES*/;\n\t}\n\n\t/** Sets the time and value for the specified frame.\n\t * @param frame Between 0 and <code>frameCount</code>, inclusive.\n\t * @param time The frame time in seconds. */\n\tsetFrame (frame: number, time: number, value: number) {\n\t\tframe <<= 1;\n\t\tthis.frames[frame] = time;\n\t\tthis.frames[frame + 1/*VALUE*/] = value;\n\t}\n\n\t/** Returns the interpolated value for the specified time. */\n\tgetCurveValue (time: number) {\n\t\tlet frames = this.frames;\n\t\tlet i = frames.length - 2;\n\t\tfor (let ii = 2; ii <= i; ii += 2) {\n\t\t\tif (frames[ii] > time) {\n\t\t\t\ti = ii - 2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tlet curveType = this.curves[i >> 1];\n\t\tswitch (curveType) {\n\t\t\tcase 0/*LINEAR*/:\n\t\t\t\tlet before = frames[i], value = frames[i + 1/*VALUE*/];\n\t\t\t\treturn value + (time - before) / (frames[i + 2/*ENTRIES*/] - before) * (frames[i + 2/*ENTRIES*/ + 1/*VALUE*/] - value);\n\t\t\tcase 1/*STEPPED*/:\n\t\t\t\treturn frames[i + 1/*VALUE*/];\n\t\t}\n\t\treturn this.getBezierValue(time, i, 1/*VALUE*/, curveType - 2/*BEZIER*/);\n\t}\n\n\tgetRelativeValue (time: number, alpha: number, blend: MixBlend, current: number, setup: number) {\n\t\tif (time < this.frames[0]) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\treturn setup;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\t\treturn current + (setup - current) * alpha;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tlet value = this.getCurveValue(time);\n\t\tswitch (blend) {\n\t\t\tcase MixBlend.setup:\n\t\t\t\treturn setup + value * alpha;\n\t\t\tcase MixBlend.first:\n\t\t\tcase MixBlend.replace:\n\t\t\t\tvalue += setup - current;\n\t\t}\n\t\treturn current + value * alpha;\n\t}\n\n\tgetAbsoluteValue (time: number, alpha: number, blend: MixBlend, current: number, setup: number) {\n\t\tif (time < this.frames[0]) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\treturn setup;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\t\treturn current + (setup - current) * alpha;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tlet value = this.getCurveValue(time);\n\t\tif (blend == MixBlend.setup) return setup + (value - setup) * alpha;\n\t\treturn current + (value - current) * alpha;\n\t}\n\n\tgetAbsoluteValue2 (time: number, alpha: number, blend: MixBlend, current: number, setup: number, value: number) {\n\t\tif (time < this.frames[0]) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\treturn setup;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\t\treturn current + (setup - current) * alpha;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tif (blend == MixBlend.setup) return setup + (value - setup) * alpha;\n\t\treturn current + (value - current) * alpha;\n\t}\n\n\tgetScaleValue (time: number, alpha: number, blend: MixBlend, direction: MixDirection, current: number, setup: number) {\n\t\tconst frames = this.frames;\n\t\tif (time < frames[0]) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\treturn setup;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\t\treturn current + (setup - current) * alpha;\n\t\t\t}\n\t\t\treturn current;\n\t\t}\n\t\tlet value = this.getCurveValue(time) * setup;\n\t\tif (alpha == 1) {\n\t\t\tif (blend == MixBlend.add) return current + value - setup;\n\t\t\treturn value;\n\t\t}\n\t\t// Mixing out uses sign of setup or current pose, else use sign of key.\n\t\tif (direction == MixDirection.mixOut) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\treturn setup + (Math.abs(value) * MathUtils.signum(setup) - setup) * alpha;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\tcase MixBlend.replace:\n\t\t\t\t\treturn current + (Math.abs(value) * MathUtils.signum(current) - current) * alpha;\n\t\t\t}\n\t\t} else {\n\t\t\tlet s = 0;\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\ts = Math.abs(setup) * MathUtils.signum(value);\n\t\t\t\t\treturn s + (value - s) * alpha;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\tcase MixBlend.replace:\n\t\t\t\t\ts = Math.abs(current) * MathUtils.signum(value);\n\t\t\t\t\treturn s + (value - s) * alpha;\n\t\t\t}\n\t\t}\n\t\treturn current + (value - setup) * alpha;\n\t}\n}\n\n/** The base class for a {@link CurveTimeline} which sets two properties. */\nexport abstract class CurveTimeline2 extends CurveTimeline {\n\t/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.\n\t * @param propertyIds Unique identifiers for the properties the timeline modifies. */\n\tconstructor (frameCount: number, bezierCount: number, propertyId1: string, propertyId2: string) {\n\t\tsuper(frameCount, bezierCount, [propertyId1, propertyId2]);\n\t}\n\n\tgetFrameEntries () {\n\t\treturn 3/*ENTRIES*/;\n\t}\n\n\t/** Sets the time and values for the specified frame.\n\t * @param frame Between 0 and <code>frameCount</code>, inclusive.\n\t * @param time The frame time in seconds. */\n\tsetFrame (frame: number, time: number, value1: number, value2: number) {\n\t\tframe *= 3/*ENTRIES*/;\n\t\tthis.frames[frame] = time;\n\t\tthis.frames[frame + 1/*VALUE1*/] = value1;\n\t\tthis.frames[frame + 2/*VALUE2*/] = value2;\n\t}\n}\n\n/** Changes a bone's local {@link Bone#rotation}. */\nexport class RotateTimeline extends CurveTimeline1 implements BoneTimeline {\n\tboneIndex = 0;\n\n\tconstructor (frameCount: number, bezierCount: number, boneIndex: number) {\n\t\tsuper(frameCount, bezierCount, Property.rotate + \"|\" + boneIndex);\n\t\tthis.boneIndex = boneIndex;\n\t}\n\n\tapply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event> | null, alpha: number, blend: MixBlend, direction: MixDirection) {\n\t\tlet bone = skeleton.bones[this.boneIndex];\n\t\tif (bone.active) bone.rotation = this.getRelativeValue(time, alpha, blend, bone.rotation, bone.data.rotation);\n\t}\n}\n\n/** Changes a bone's local {@link Bone#x} and {@link Bone#y}. */\nexport class TranslateTimeline extends CurveTimeline2 implements BoneTimeline {\n\tboneIndex = 0;\n\n\tconstructor (frameCount: number, bezierCount: number, boneIndex: number) {\n\t\tsuper(frameCount, bezierCount,\n\t\t\tProperty.x + \"|\" + boneIndex,\n\t\t\tProperty.y + \"|\" + boneIndex,\n\t\t);\n\t\tthis.boneIndex = boneIndex;\n\t}\n\n\tapply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {\n\t\tlet bone = skeleton.bones[this.boneIndex];\n\t\tif (!bone.active) return;\n\n\t\tlet frames = this.frames;\n\t\tif (time < frames[0]) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\tbone.x = bone.data.x;\n\t\t\t\t\tbone.y = bone.data.y;\n\t\t\t\t\treturn;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\t\tbone.x += (bone.data.x - bone.x) * alpha;\n\t\t\t\t\tbone.y += (bone.data.y - bone.y) * alpha;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tlet x = 0, y = 0;\n\t\tlet i = Timeline.search(frames, time, 3/*ENTRIES*/);\n\t\tlet curveType = this.curves[i / 3/*ENTRIES*/];\n\t\tswitch (curveType) {\n\t\t\tcase 0/*LINEAR*/:\n\t\t\t\tlet before = frames[i];\n\t\t\t\tx = frames[i + 1/*VALUE1*/];\n\t\t\t\ty = frames[i + 2/*VALUE2*/];\n\t\t\t\tlet t = (time - before) / (frames[i + 3/*ENTRIES*/] - before);\n\t\t\t\tx += (frames[i + 3/*ENTRIES*/ + 1/*VALUE1*/] - x) * t;\n\t\t\t\ty += (frames[i + 3/*ENTRIES*/ + 2/*VALUE2*/] - y) * t;\n\t\t\t\tbreak;\n\t\t\tcase 1/*STEPPED*/:\n\t\t\t\tx = frames[i + 1/*VALUE1*/];\n\t\t\t\ty = frames[i + 2/*VALUE2*/];\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tx = this.getBezierValue(time, i, 1/*VALUE1*/, curveType - 2/*BEZIER*/);\n\t\t\t\ty = this.getBezierValue(time, i, 2/*VALUE2*/, curveType + 18/*BEZIER_SIZE*/ - 2/*BEZIER*/);\n\t\t}\n\n\t\tswitch (blend) {\n\t\t\tcase MixBlend.setup:\n\t\t\t\tbone.x = bone.data.x + x * alpha;\n\t\t\t\tbone.y = bone.data.y + y * alpha;\n\t\t\t\tbreak;\n\t\t\tcase MixBlend.first:\n\t\t\tcase MixBlend.replace:\n\t\t\t\tbone.x += (bone.data.x + x - bone.x) * alpha;\n\t\t\t\tbone.y += (bone.data.y + y - bone.y) * alpha;\n\t\t\t\tbreak;\n\t\t\tcase MixBlend.add:\n\t\t\t\tbone.x += x * alpha;\n\t\t\t\tbone.y += y * alpha;\n\t\t}\n\t}\n}\n\n/** Changes a bone's local {@link Bone#x}. */\nexport class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline {\n\tboneIndex = 0;\n\n\tconstructor (frameCount: number, bezierCount: number, boneIndex: number) {\n\t\tsuper(frameCount, bezierCount, Property.x + \"|\" + boneIndex);\n\t\tthis.boneIndex = boneIndex;\n\t}\n\n\tapply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {\n\t\tlet bone = skeleton.bones[this.boneIndex];\n\t\tif (bone.active) bone.x = this.getRelativeValue(time, alpha, blend, bone.x, bone.data.x);\n\t}\n}\n\n/** Changes a bone's local {@link Bone#x}. */\nexport class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline {\n\tboneIndex = 0;\n\n\tconstructor (frameCount: number, bezierCount: number, boneIndex: number) {\n\t\tsuper(frameCount, bezierCount, Property.y + \"|\" + boneIndex);\n\t\tthis.boneIndex = boneIndex;\n\t}\n\n\tapply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {\n\t\tlet bone = skeleton.bones[this.boneIndex];\n\t\tif (bone.active) bone.y = this.getRelativeValue(time, alpha, blend, bone.y, bone.data.y);\n\t}\n}\n\n/** Changes a bone's local {@link Bone#scaleX)} and {@link Bone#scaleY}. */\nexport class ScaleTimeline extends CurveTimeline2 implements BoneTimeline {\n\tboneIndex = 0;\n\n\tconstructor (frameCount: number, bezierCount: number, boneIndex: number) {\n\t\tsuper(frameCount, bezierCount,\n\t\t\tProperty.scaleX + \"|\" + boneIndex,\n\t\t\tProperty.scaleY + \"|\" + boneIndex\n\t\t);\n\t\tthis.boneIndex = boneIndex;\n\t}\n\n\tapply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {\n\t\tlet bone = skeleton.bones[this.boneIndex];\n\t\tif (!bone.active) return;\n\n\t\tlet frames = this.frames;\n\t\tif (time < frames[0]) {\n\t\t\tswitch (blend) {\n\t\t\t\tcase MixBlend.setup:\n\t\t\t\t\tbone.scaleX = bone.data.scaleX;\n\t\t\t\t\tbone.scaleY = bone.data.scaleY;\n\t\t\t\t\treturn;\n\t\t\t\tcase MixBlend.first:\n\t\t\t\t\tbone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;\n\t\t\t\t\tbone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tlet x, y;\n\t\tlet i = Timeline.search(frames, time, 3/*ENTRIES*/);\n\t\tlet curveType = this.curves[i / 3/*ENTRIES*/];\n\t\tswitch (curveType) {\n\t\t\tcase 0/*LINEAR*/:\n\t\t\t\tlet before = frames[i];\n\t\t\t\tx = frames[i + 1/*