mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 08:16:41 +08:00
[ts] Added support for loading binaries via SkeletonBinary. Player configuration object now lets you specify skelUrl instead of jsonUrl to load from a binary file. Updated demos to use .skel files instead of .json.
This commit is contained in:
parent
b113966ed4
commit
ca3916dad8
@ -286,40 +286,40 @@ cp -f ../owl/export/owl.png "$RUNTIME_DIR/spine-starling/spine-starling-example/
|
||||
|
||||
echo "spine-ts"
|
||||
rm "$RUNTIME_DIR/spine-ts/webgl/example/assets/"*
|
||||
cp -f ../coin/export/coin-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../coin/export/coin-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../coin/export/coin-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../coin/export/coin-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../goblins/export/goblins-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../goblins/export/goblins-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../goblins/export/goblins-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../goblins/export/goblins-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../raptor/export/raptor-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../raptor/export/raptor-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../raptor/export/raptor-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../raptor/export/raptor-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../spineboy/export/spineboy-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../tank/export/tank-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../tank/export/tank-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../tank/export/tank-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../tank/export/tank-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../vine/export/vine-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../vine/export/vine-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../vine/export/vine-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../vine/export/vine-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../owl/export/owl-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../owl/export/owl-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../owl/export/owl-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../owl/export/owl-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../stretchyman/export/stretchyman-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../stretchyman/export/stretchyman-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../stretchyman/export/stretchyman-pma.atlas "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../stretchyman/export/stretchyman-pma.png "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
cp -f ../stretchyman/export/stretchyman-stretchy-ik-pro.json "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
cp -f ../stretchyman/export/stretchyman-stretchy-ik-pro.skel "$RUNTIME_DIR/spine-ts/webgl/example/assets/"
|
||||
|
||||
rm "$RUNTIME_DIR/spine-ts/canvas/example/assets/"*
|
||||
cp -f ../spineboy/export/spineboy-ess.json "$RUNTIME_DIR/spine-ts/canvas/example/assets/"
|
||||
@ -336,7 +336,7 @@ cp -f ../raptor/export/raptor-pro.json "$RUNTIME_DIR/spine-ts/player/example/ass
|
||||
cp -f ../raptor/export/raptor-pma.atlas "$RUNTIME_DIR/spine-ts/player/example/assets/"
|
||||
cp -f ../raptor/export/raptor-pma.png "$RUNTIME_DIR/spine-ts/player/example/assets/"
|
||||
|
||||
cp -f ../spineboy/export/spineboy-pro.json "$RUNTIME_DIR/spine-ts/player/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy-pro.skel "$RUNTIME_DIR/spine-ts/player/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy-pma.atlas "$RUNTIME_DIR/spine-ts/player/example/assets/"
|
||||
cp -f ../spineboy/export/spineboy-pma.png "$RUNTIME_DIR/spine-ts/player/example/assets/"
|
||||
|
||||
|
||||
43
spine-ts/build/spine-all.d.ts
vendored
43
spine-ts/build/spine-all.d.ts
vendored
@ -384,6 +384,7 @@ declare module spine {
|
||||
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
|
||||
private static downloadText(url, success, error);
|
||||
private static downloadBinary(url, success, error);
|
||||
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
|
||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
@ -481,6 +482,7 @@ declare module spine {
|
||||
shearY: number;
|
||||
transformMode: TransformMode;
|
||||
skinRequired: boolean;
|
||||
color: Color;
|
||||
constructor(index: number, name: string, parent: BoneData);
|
||||
}
|
||||
enum TransformMode {
|
||||
@ -680,6 +682,42 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBinary {
|
||||
static AttachmentTypeValues: number[];
|
||||
static TransformModeValues: TransformMode[];
|
||||
static PositionModeValues: PositionMode[];
|
||||
static SpacingModeValues: SpacingMode[];
|
||||
static RotateModeValues: RotateMode[];
|
||||
static BlendModeValues: BlendMode[];
|
||||
static BONE_ROTATE: number;
|
||||
static BONE_TRANSLATE: number;
|
||||
static BONE_SCALE: number;
|
||||
static BONE_SHEAR: number;
|
||||
static SLOT_ATTACHMENT: number;
|
||||
static SLOT_COLOR: number;
|
||||
static SLOT_TWO_COLOR: number;
|
||||
static PATH_POSITION: number;
|
||||
static PATH_SPACING: number;
|
||||
static PATH_MIX: number;
|
||||
static CURVE_LINEAR: number;
|
||||
static CURVE_STEPPED: number;
|
||||
static CURVE_BEZIER: number;
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale: number;
|
||||
private linkedMeshes;
|
||||
constructor(attachmentLoader: AttachmentLoader);
|
||||
readSkeletonData(binary: Uint8Array): SkeletonData;
|
||||
private readSkin(input, skeletonData, defaultSkin, nonessential);
|
||||
private readAttachment(input, skeletonData, skin, slotIndex, attachmentName, nonessential);
|
||||
private readVertices(input, vertexCount);
|
||||
private readFloatArray(input, n, scale);
|
||||
private readShortArray(input);
|
||||
private readAnimation(input, name, skeletonData);
|
||||
private readCurve(input, frameIndex, timeline);
|
||||
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBounds {
|
||||
minX: number;
|
||||
@ -742,6 +780,7 @@ declare module spine {
|
||||
hash: string;
|
||||
fps: number;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
findBone(boneName: string): BoneData;
|
||||
findBoneIndex(boneName: string): number;
|
||||
findSlot(slotName: string): SlotData;
|
||||
@ -997,6 +1036,8 @@ declare module spine {
|
||||
setFromString(hex: string): this;
|
||||
add(r: number, g: number, b: number, a: number): this;
|
||||
clamp(): this;
|
||||
static rgba8888ToColor(color: Color, value: number): void;
|
||||
static rgb888ToColor(color: Color, value: number): void;
|
||||
}
|
||||
class MathUtils {
|
||||
static PI: number;
|
||||
@ -1132,6 +1173,7 @@ declare module spine {
|
||||
LinkedMesh = 3,
|
||||
Path = 4,
|
||||
Point = 5,
|
||||
Clipping = 6,
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -1819,6 +1861,7 @@ declare module spine {
|
||||
}
|
||||
interface SpinePlayerConfig {
|
||||
jsonUrl: string;
|
||||
skelUrl: string;
|
||||
atlasUrl: string;
|
||||
animation: string;
|
||||
animations: string[];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
42
spine-ts/build/spine-canvas.d.ts
vendored
42
spine-ts/build/spine-canvas.d.ts
vendored
@ -384,6 +384,7 @@ declare module spine {
|
||||
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
|
||||
private static downloadText(url, success, error);
|
||||
private static downloadBinary(url, success, error);
|
||||
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
|
||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
@ -481,6 +482,7 @@ declare module spine {
|
||||
shearY: number;
|
||||
transformMode: TransformMode;
|
||||
skinRequired: boolean;
|
||||
color: Color;
|
||||
constructor(index: number, name: string, parent: BoneData);
|
||||
}
|
||||
enum TransformMode {
|
||||
@ -680,6 +682,42 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBinary {
|
||||
static AttachmentTypeValues: number[];
|
||||
static TransformModeValues: TransformMode[];
|
||||
static PositionModeValues: PositionMode[];
|
||||
static SpacingModeValues: SpacingMode[];
|
||||
static RotateModeValues: RotateMode[];
|
||||
static BlendModeValues: BlendMode[];
|
||||
static BONE_ROTATE: number;
|
||||
static BONE_TRANSLATE: number;
|
||||
static BONE_SCALE: number;
|
||||
static BONE_SHEAR: number;
|
||||
static SLOT_ATTACHMENT: number;
|
||||
static SLOT_COLOR: number;
|
||||
static SLOT_TWO_COLOR: number;
|
||||
static PATH_POSITION: number;
|
||||
static PATH_SPACING: number;
|
||||
static PATH_MIX: number;
|
||||
static CURVE_LINEAR: number;
|
||||
static CURVE_STEPPED: number;
|
||||
static CURVE_BEZIER: number;
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale: number;
|
||||
private linkedMeshes;
|
||||
constructor(attachmentLoader: AttachmentLoader);
|
||||
readSkeletonData(binary: Uint8Array): SkeletonData;
|
||||
private readSkin(input, skeletonData, defaultSkin, nonessential);
|
||||
private readAttachment(input, skeletonData, skin, slotIndex, attachmentName, nonessential);
|
||||
private readVertices(input, vertexCount);
|
||||
private readFloatArray(input, n, scale);
|
||||
private readShortArray(input);
|
||||
private readAnimation(input, name, skeletonData);
|
||||
private readCurve(input, frameIndex, timeline);
|
||||
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBounds {
|
||||
minX: number;
|
||||
@ -742,6 +780,7 @@ declare module spine {
|
||||
hash: string;
|
||||
fps: number;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
findBone(boneName: string): BoneData;
|
||||
findBoneIndex(boneName: string): number;
|
||||
findSlot(slotName: string): SlotData;
|
||||
@ -997,6 +1036,8 @@ declare module spine {
|
||||
setFromString(hex: string): this;
|
||||
add(r: number, g: number, b: number, a: number): this;
|
||||
clamp(): this;
|
||||
static rgba8888ToColor(color: Color, value: number): void;
|
||||
static rgb888ToColor(color: Color, value: number): void;
|
||||
}
|
||||
class MathUtils {
|
||||
static PI: number;
|
||||
@ -1132,6 +1173,7 @@ declare module spine {
|
||||
LinkedMesh = 3,
|
||||
Path = 4,
|
||||
Point = 5,
|
||||
Clipping = 6,
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -2181,6 +2181,26 @@ var spine;
|
||||
};
|
||||
request.send();
|
||||
};
|
||||
AssetManager.prototype.loadBinary = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
if (error === void 0) { error = null; }
|
||||
path = this.pathPrefix + path;
|
||||
this.toLoad++;
|
||||
AssetManager.downloadBinary(path, function (data) {
|
||||
_this.assets[path] = data;
|
||||
if (success)
|
||||
success(path, data);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
}, function (state, responseText) {
|
||||
_this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
|
||||
if (error)
|
||||
error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
});
|
||||
};
|
||||
AssetManager.prototype.loadText = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
@ -2691,6 +2711,7 @@ var spine;
|
||||
this.shearY = 0;
|
||||
this.transformMode = TransformMode.Normal;
|
||||
this.skinRequired = false;
|
||||
this.color = new spine.Color();
|
||||
if (index < 0)
|
||||
throw new Error("index must be >= 0.");
|
||||
if (name == null)
|
||||
@ -3999,6 +4020,810 @@ var spine;
|
||||
spine.Skeleton = Skeleton;
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBinary = (function () {
|
||||
function SkeletonBinary(attachmentLoader) {
|
||||
this.scale = 1;
|
||||
this.linkedMeshes = new Array();
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
}
|
||||
SkeletonBinary.prototype.readSkeletonData = function (binary) {
|
||||
var scale = this.scale;
|
||||
var skeletonData = new spine.SkeletonData();
|
||||
skeletonData.name = "";
|
||||
var input = new BinaryInput(binary);
|
||||
skeletonData.hash = input.readString();
|
||||
skeletonData.version = input.readString();
|
||||
skeletonData.x = input.readFloat();
|
||||
skeletonData.y = input.readFloat();
|
||||
skeletonData.width = input.readFloat();
|
||||
skeletonData.height = input.readFloat();
|
||||
var nonessential = input.readBoolean();
|
||||
if (nonessential) {
|
||||
skeletonData.fps = input.readFloat();
|
||||
skeletonData.imagesPath = input.readString();
|
||||
skeletonData.audioPath = input.readString();
|
||||
}
|
||||
var n = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
input.strings.push(input.readString());
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var name_2 = input.readString();
|
||||
var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.BoneData(i, name_2, parent_2);
|
||||
data.rotation = input.readFloat();
|
||||
data.x = input.readFloat() * scale;
|
||||
data.y = input.readFloat() * scale;
|
||||
data.scaleX = input.readFloat();
|
||||
data.scaleY = input.readFloat();
|
||||
data.shearX = input.readFloat();
|
||||
data.shearY = input.readFloat();
|
||||
data.length = input.readFloat() * scale;
|
||||
data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
|
||||
data.skinRequired = input.readBoolean();
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
skeletonData.bones.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var slotName = input.readString();
|
||||
var boneData = skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.SlotData(i, slotName, boneData);
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
var darkColor = input.readInt32();
|
||||
if (darkColor != -1)
|
||||
spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor);
|
||||
data.attachmentName = input.readStringRef();
|
||||
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.IkConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.mix = input.readFloat();
|
||||
data.bendDirection = input.readByte();
|
||||
data.compress = input.readBoolean();
|
||||
data.stretch = input.readBoolean();
|
||||
data.uniform = input.readBoolean();
|
||||
skeletonData.ikConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.TransformConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.local = input.readBoolean();
|
||||
data.relative = input.readBoolean();
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.offsetX = input.readFloat() * scale;
|
||||
data.offsetY = input.readFloat() * scale;
|
||||
data.offsetScaleX = input.readFloat();
|
||||
data.offsetScaleY = input.readFloat();
|
||||
data.offsetShearY = input.readFloat();
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
data.scaleMix = input.readFloat();
|
||||
data.shearMix = input.readFloat();
|
||||
skeletonData.transformConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.PathConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.slots[input.readInt(true)];
|
||||
data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
|
||||
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
|
||||
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.position = input.readFloat();
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
data.position *= scale;
|
||||
data.spacing = input.readFloat();
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
data.spacing *= scale;
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
skeletonData.pathConstraints.push(data);
|
||||
}
|
||||
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
|
||||
if (defaultSkin != null) {
|
||||
skeletonData.defaultSkin = defaultSkin;
|
||||
skeletonData.skins.push(defaultSkin);
|
||||
}
|
||||
{
|
||||
var i = skeletonData.skins.length;
|
||||
spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
|
||||
for (; i < n; i++)
|
||||
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
|
||||
}
|
||||
n = this.linkedMeshes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var linkedMesh = this.linkedMeshes[i];
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var data = new spine.EventData(input.readStringRef());
|
||||
data.intValue = input.readInt(false);
|
||||
data.floatValue = input.readFloat();
|
||||
data.stringValue = input.readString();
|
||||
data.audioPath = input.readString();
|
||||
if (data.audioPath != null) {
|
||||
data.volume = input.readFloat();
|
||||
data.balance = input.readFloat();
|
||||
}
|
||||
skeletonData.events.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
|
||||
return skeletonData;
|
||||
};
|
||||
SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) {
|
||||
var skin = new spine.Skin(defaultSkin ? "default" : input.readStringRef());
|
||||
if (!defaultSkin) {
|
||||
skin.bones.length = input.readInt(true);
|
||||
for (var i = 0, n = skin.bones.length; i < n; i++)
|
||||
skin.bones[i] = skeletonData.bones[input.readInt(true)];
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var name_3 = input.readStringRef();
|
||||
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential);
|
||||
if (attachment != null)
|
||||
skin.setAttachment(slotIndex, name_3, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
};
|
||||
SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
|
||||
var scale = this.scale;
|
||||
var name = input.readStringRef();
|
||||
if (name == null)
|
||||
name = attachmentName;
|
||||
var typeIndex = input.readByte();
|
||||
var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
|
||||
switch (type) {
|
||||
case spine.AttachmentType.Region: {
|
||||
var path = input.readStringRef();
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var scaleX = input.readFloat();
|
||||
var scaleY = input.readFloat();
|
||||
var width = input.readFloat();
|
||||
var height = input.readFloat();
|
||||
var color = input.readInt32();
|
||||
if (path == null)
|
||||
path = name;
|
||||
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
|
||||
if (region == null)
|
||||
return null;
|
||||
region.path = path;
|
||||
region.x = x * scale;
|
||||
region.y = y * scale;
|
||||
region.scaleX = scaleX;
|
||||
region.scaleY = scaleY;
|
||||
region.rotation = rotation;
|
||||
region.width = width * scale;
|
||||
region.height = height * scale;
|
||||
spine.Color.rgba8888ToColor(region.color, color);
|
||||
region.updateOffset();
|
||||
return region;
|
||||
}
|
||||
case spine.AttachmentType.BoundingBox: {
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
|
||||
if (box == null)
|
||||
return null;
|
||||
box.worldVerticesLength = vertexCount << 1;
|
||||
box.vertices = vertices.vertices;
|
||||
box.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(box.color, color);
|
||||
return box;
|
||||
}
|
||||
case spine.AttachmentType.Mesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var vertexCount = input.readInt(true);
|
||||
var uvs = this.readFloatArray(input, vertexCount << 1, 1);
|
||||
var triangles = this.readShortArray(input);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var hullLength = input.readInt(true);
|
||||
var edges = null;
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
edges = this.readShortArray(input);
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
mesh.bones = vertices.bones;
|
||||
mesh.vertices = vertices.vertices;
|
||||
mesh.worldVerticesLength = vertexCount << 1;
|
||||
mesh.triangles = triangles;
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.updateUVs();
|
||||
mesh.hullLength = hullLength << 1;
|
||||
if (nonessential) {
|
||||
mesh.edges = edges;
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.LinkedMesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var skinName = input.readStringRef();
|
||||
var parent_4 = input.readStringRef();
|
||||
var inheritDeform = input.readBoolean();
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
if (nonessential) {
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.Path: {
|
||||
var closed_1 = input.readBoolean();
|
||||
var constantSpeed = input.readBoolean();
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var lengths = spine.Utils.newArray(vertexCount / 3, 0);
|
||||
for (var i = 0, n = lengths.length; i < n; i++)
|
||||
lengths[i] = input.readFloat() * scale;
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var path = this.attachmentLoader.newPathAttachment(skin, name);
|
||||
if (path == null)
|
||||
return null;
|
||||
path.closed = closed_1;
|
||||
path.constantSpeed = constantSpeed;
|
||||
path.worldVerticesLength = vertexCount << 1;
|
||||
path.vertices = vertices.vertices;
|
||||
path.bones = vertices.bones;
|
||||
path.lengths = lengths;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(path.color, color);
|
||||
return path;
|
||||
}
|
||||
case spine.AttachmentType.Point: {
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var point = this.attachmentLoader.newPointAttachment(skin, name);
|
||||
if (point == null)
|
||||
return null;
|
||||
point.x = x * scale;
|
||||
point.y = y * scale;
|
||||
point.rotation = rotation;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(point.color, color);
|
||||
return point;
|
||||
}
|
||||
case spine.AttachmentType.Clipping: {
|
||||
var endSlotIndex = input.readInt(true);
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null)
|
||||
return null;
|
||||
clip.endSlot = skeletonData.slots[endSlotIndex];
|
||||
clip.worldVerticesLength = vertexCount << 1;
|
||||
clip.vertices = vertices.vertices;
|
||||
clip.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(clip.color, color);
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
SkeletonBinary.prototype.readVertices = function (input, vertexCount) {
|
||||
var verticesLength = vertexCount << 1;
|
||||
var vertices = new Vertices();
|
||||
var scale = this.scale;
|
||||
if (!input.readBoolean()) {
|
||||
vertices.vertices = this.readFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
var weights = new Array();
|
||||
var bonesArray = new Array();
|
||||
for (var i = 0; i < vertexCount; i++) {
|
||||
var boneCount = input.readInt(true);
|
||||
bonesArray.push(boneCount);
|
||||
for (var ii = 0; ii < boneCount; ii++) {
|
||||
bonesArray.push(input.readInt(true));
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat());
|
||||
}
|
||||
}
|
||||
vertices.vertices = spine.Utils.toFloatArray(weights);
|
||||
vertices.bones = bonesArray;
|
||||
return vertices;
|
||||
};
|
||||
SkeletonBinary.prototype.readFloatArray = function (input, n, scale) {
|
||||
var array = new Array(n);
|
||||
if (scale == 1) {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat() * scale;
|
||||
}
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readShortArray = function (input) {
|
||||
var n = input.readInt(true);
|
||||
var array = new Array(n);
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readShort();
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) {
|
||||
var timelines = new Array();
|
||||
var scale = this.scale;
|
||||
var duration = 0;
|
||||
var tempColor1 = new spine.Color();
|
||||
var tempColor2 = new spine.Color();
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.SLOT_ATTACHMENT: {
|
||||
var timeline = new spine.AttachmentTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_COLOR: {
|
||||
var timeline = new spine.ColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_TWO_COLOR: {
|
||||
var timeline = new spine.TwoColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
spine.Color.rgb888ToColor(tempColor2, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var boneIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.BONE_ROTATE: {
|
||||
var timeline = new spine.RotateTimeline(frameCount);
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.BONE_TRANSLATE:
|
||||
case SkeletonBinary.BONE_SCALE:
|
||||
case SkeletonBinary.BONE_SHEAR: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.BONE_SCALE)
|
||||
timeline = new spine.ScaleTimeline(frameCount);
|
||||
else if (timelineType == SkeletonBinary.BONE_SHEAR)
|
||||
timeline = new spine.ShearTimeline(frameCount);
|
||||
else {
|
||||
timeline = new spine.TranslateTimeline(frameCount);
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.IkConstraintTimeline(frameCount);
|
||||
timeline.ikConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readByte(), input.readBoolean(), input.readBoolean());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.TransformConstraintTimeline(frameCount);
|
||||
timeline.transformConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var data = skeletonData.pathConstraints[index];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.PATH_POSITION:
|
||||
case SkeletonBinary.PATH_SPACING: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.PATH_SPACING) {
|
||||
timeline = new spine.PathConstraintSpacingTimeline(frameCount);
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
else {
|
||||
timeline = new spine.PathConstraintPositionTimeline(frameCount);
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.PATH_MIX: {
|
||||
var timeline = new spine.PathConstraintMixTimeline(frameCount);
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var skin = skeletonData.skins[input.readInt(true)];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
|
||||
var attachment = skin.getAttachment(slotIndex, input.readStringRef());
|
||||
var weighted = attachment.bones != null;
|
||||
var vertices = attachment.vertices;
|
||||
var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.DeformTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
timeline.attachment = attachment;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
var deform = void 0;
|
||||
var end = input.readInt(true);
|
||||
if (end == 0)
|
||||
deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
|
||||
else {
|
||||
deform = spine.Utils.newFloatArray(deformLength);
|
||||
var start = input.readInt(true);
|
||||
end += start;
|
||||
if (scale == 1) {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat() * scale;
|
||||
}
|
||||
if (!weighted) {
|
||||
for (var v = 0, vn = deform.length; v < vn; v++)
|
||||
deform[v] += vertices[v];
|
||||
}
|
||||
}
|
||||
timeline.setFrame(frameIndex, time, deform);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
var drawOrderCount = input.readInt(true);
|
||||
if (drawOrderCount > 0) {
|
||||
var timeline = new spine.DrawOrderTimeline(drawOrderCount);
|
||||
var slotCount = skeletonData.slots.length;
|
||||
for (var i = 0; i < drawOrderCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var offsetCount = input.readInt(true);
|
||||
var drawOrder = spine.Utils.newArray(slotCount, 0);
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
drawOrder[ii] = -1;
|
||||
var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0);
|
||||
var originalIndex = 0, unchangedIndex = 0;
|
||||
for (var ii = 0; ii < offsetCount; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
while (originalIndex != slotIndex)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
|
||||
}
|
||||
while (originalIndex < slotCount)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
if (drawOrder[ii] == -1)
|
||||
drawOrder[ii] = unchanged[--unchangedIndex];
|
||||
timeline.setFrame(i, time, drawOrder);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
|
||||
}
|
||||
var eventCount = input.readInt(true);
|
||||
if (eventCount > 0) {
|
||||
var timeline = new spine.EventTimeline(eventCount);
|
||||
for (var i = 0; i < eventCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var eventData = skeletonData.events[input.readInt(true)];
|
||||
var event_4 = new spine.Event(time, eventData);
|
||||
event_4.intValue = input.readInt(false);
|
||||
event_4.floatValue = input.readFloat();
|
||||
event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
|
||||
if (event_4.data.audioPath != null) {
|
||||
event_4.volume = input.readFloat();
|
||||
event_4.balance = input.readFloat();
|
||||
}
|
||||
timeline.setFrame(i, event_4);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[eventCount - 1]);
|
||||
}
|
||||
return new spine.Animation(name, timelines, duration);
|
||||
};
|
||||
SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) {
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frameIndex);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
break;
|
||||
}
|
||||
};
|
||||
SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
|
||||
timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
|
||||
};
|
||||
SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6];
|
||||
SkeletonBinary.TransformModeValues = [spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection];
|
||||
SkeletonBinary.PositionModeValues = [spine.PositionMode.Fixed, spine.PositionMode.Percent];
|
||||
SkeletonBinary.SpacingModeValues = [spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent];
|
||||
SkeletonBinary.RotateModeValues = [spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale];
|
||||
SkeletonBinary.BlendModeValues = [spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen];
|
||||
SkeletonBinary.BONE_ROTATE = 0;
|
||||
SkeletonBinary.BONE_TRANSLATE = 1;
|
||||
SkeletonBinary.BONE_SCALE = 2;
|
||||
SkeletonBinary.BONE_SHEAR = 3;
|
||||
SkeletonBinary.SLOT_ATTACHMENT = 0;
|
||||
SkeletonBinary.SLOT_COLOR = 1;
|
||||
SkeletonBinary.SLOT_TWO_COLOR = 2;
|
||||
SkeletonBinary.PATH_POSITION = 0;
|
||||
SkeletonBinary.PATH_SPACING = 1;
|
||||
SkeletonBinary.PATH_MIX = 2;
|
||||
SkeletonBinary.CURVE_LINEAR = 0;
|
||||
SkeletonBinary.CURVE_STEPPED = 1;
|
||||
SkeletonBinary.CURVE_BEZIER = 2;
|
||||
return SkeletonBinary;
|
||||
}());
|
||||
spine.SkeletonBinary = SkeletonBinary;
|
||||
var BinaryInput = (function () {
|
||||
function BinaryInput(data, strings, index, buffer) {
|
||||
if (strings === void 0) { strings = new Array(); }
|
||||
if (index === void 0) { index = 0; }
|
||||
if (buffer === void 0) { buffer = new DataView(data.buffer); }
|
||||
this.strings = strings;
|
||||
this.index = index;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
BinaryInput.prototype.readByte = function () {
|
||||
return this.buffer.getInt8(this.index++);
|
||||
};
|
||||
BinaryInput.prototype.readShort = function () {
|
||||
var value = this.buffer.getInt16(this.index);
|
||||
this.index += 2;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt32 = function () {
|
||||
var value = this.buffer.getInt32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt = function (optimizePositive) {
|
||||
var b = this.readByte();
|
||||
var result = b & 0x7F;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 7;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 14;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 21;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
|
||||
};
|
||||
BinaryInput.prototype.readStringRef = function () {
|
||||
var index = this.readInt(true);
|
||||
return index == 0 ? null : this.strings[index - 1];
|
||||
};
|
||||
BinaryInput.prototype.readString = function () {
|
||||
var byteCount = this.readInt(true);
|
||||
switch (byteCount) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return "";
|
||||
}
|
||||
byteCount--;
|
||||
var chars = "";
|
||||
var charCount = 0;
|
||||
for (var i = 0; i < byteCount;) {
|
||||
var b = this.readByte();
|
||||
switch (b >> 4) {
|
||||
case 12:
|
||||
case 13:
|
||||
chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
|
||||
i += 2;
|
||||
break;
|
||||
case 14:
|
||||
chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
|
||||
i += 3;
|
||||
break;
|
||||
default:
|
||||
chars += String.fromCharCode(b);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
BinaryInput.prototype.readFloat = function () {
|
||||
var value = this.buffer.getFloat32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readBoolean = function () {
|
||||
return this.readByte() != 0;
|
||||
};
|
||||
return BinaryInput;
|
||||
}());
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
var Vertices = (function () {
|
||||
function Vertices(bones, vertices) {
|
||||
if (bones === void 0) { bones = null; }
|
||||
if (vertices === void 0) { vertices = null; }
|
||||
this.bones = bones;
|
||||
this.vertices = vertices;
|
||||
}
|
||||
return Vertices;
|
||||
}());
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBounds = (function () {
|
||||
function SkeletonBounds() {
|
||||
@ -4528,9 +5353,9 @@ var spine;
|
||||
throw new Error("eventDataName cannot be null.");
|
||||
var events = this.events;
|
||||
for (var i = 0, n = events.length; i < n; i++) {
|
||||
var event_4 = events[i];
|
||||
if (event_4.name == eventDataName)
|
||||
return event_4;
|
||||
var event_5 = events[i];
|
||||
if (event_5.name == eventDataName)
|
||||
return event_5;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@ -4617,14 +5442,14 @@ var spine;
|
||||
if (root.bones) {
|
||||
for (var i = 0; i < root.bones.length; i++) {
|
||||
var boneMap = root.bones[i];
|
||||
var parent_2 = null;
|
||||
var parent_5 = null;
|
||||
var parentName = this.getValue(boneMap, "parent", null);
|
||||
if (parentName != null) {
|
||||
parent_2 = skeletonData.findBone(parentName);
|
||||
if (parent_2 == null)
|
||||
parent_5 = skeletonData.findBone(parentName);
|
||||
if (parent_5 == null)
|
||||
throw new Error("Parent bone not found: " + parentName);
|
||||
}
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2);
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5);
|
||||
data.length = this.getValue(boneMap, "length", 0) * scale;
|
||||
data.x = this.getValue(boneMap, "x", 0) * scale;
|
||||
data.y = this.getValue(boneMap, "y", 0) * scale;
|
||||
@ -4806,11 +5631,11 @@ var spine;
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_6 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_6);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
@ -4883,9 +5708,9 @@ var spine;
|
||||
mesh.color.setFromString(color);
|
||||
mesh.width = this.getValue(map, "width", 0) * scale;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
var parent_7 = this.getValue(map, "parent", null);
|
||||
if (parent_7 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5264,15 +6089,15 @@ var spine;
|
||||
var eventData = skeletonData.findEvent(eventMap.name);
|
||||
if (eventData == null)
|
||||
throw new Error("Event not found: " + eventMap.name);
|
||||
var event_5 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_5.data.audioPath != null) {
|
||||
event_5.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_5.balance = this.getValue(eventMap, "balance", 0);
|
||||
var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_6.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_6.data.audioPath != null) {
|
||||
event_6.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_6.balance = this.getValue(eventMap, "balance", 0);
|
||||
}
|
||||
timeline.setFrame(frameIndex++, event_5);
|
||||
timeline.setFrame(frameIndex++, event_6);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
|
||||
@ -5478,10 +6303,10 @@ var spine;
|
||||
for (var i = 0; i < this.attachments.length; i++) {
|
||||
var slotAttachments = this.attachments[i];
|
||||
if (slotAttachments) {
|
||||
for (var name_2 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_2];
|
||||
for (var name_4 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_4];
|
||||
if (attachment)
|
||||
entries.push(new SkinEntry(i, name_2, attachment));
|
||||
entries.push(new SkinEntry(i, name_4, attachment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5490,10 +6315,10 @@ var spine;
|
||||
Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) {
|
||||
var slotAttachments = this.attachments[slotIndex];
|
||||
if (slotAttachments) {
|
||||
for (var name_3 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_3];
|
||||
for (var name_5 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_5];
|
||||
if (attachment)
|
||||
attachments.push(new SkinEntry(slotIndex, name_3, attachment));
|
||||
attachments.push(new SkinEntry(slotIndex, name_5, attachment));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6394,6 +7219,17 @@ var spine;
|
||||
this.a = 1;
|
||||
return this;
|
||||
};
|
||||
Color.rgba8888ToColor = function (color, value) {
|
||||
color.r = ((value & 0xff000000) >>> 24) / 255;
|
||||
color.g = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.b = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.a = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.rgb888ToColor = function (color, value) {
|
||||
color.r = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.b = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.WHITE = new Color(1, 1, 1, 1);
|
||||
Color.RED = new Color(1, 0, 0, 1);
|
||||
Color.GREEN = new Color(0, 1, 0, 1);
|
||||
@ -6810,6 +7646,7 @@ var spine;
|
||||
AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
|
||||
AttachmentType[AttachmentType["Path"] = 4] = "Path";
|
||||
AttachmentType[AttachmentType["Point"] = 5] = "Point";
|
||||
AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping";
|
||||
})(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
|
||||
File diff suppressed because one or more lines are too long
42
spine-ts/build/spine-core.d.ts
vendored
42
spine-ts/build/spine-core.d.ts
vendored
@ -384,6 +384,7 @@ declare module spine {
|
||||
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
|
||||
private static downloadText(url, success, error);
|
||||
private static downloadBinary(url, success, error);
|
||||
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
|
||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
@ -481,6 +482,7 @@ declare module spine {
|
||||
shearY: number;
|
||||
transformMode: TransformMode;
|
||||
skinRequired: boolean;
|
||||
color: Color;
|
||||
constructor(index: number, name: string, parent: BoneData);
|
||||
}
|
||||
enum TransformMode {
|
||||
@ -680,6 +682,42 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBinary {
|
||||
static AttachmentTypeValues: number[];
|
||||
static TransformModeValues: TransformMode[];
|
||||
static PositionModeValues: PositionMode[];
|
||||
static SpacingModeValues: SpacingMode[];
|
||||
static RotateModeValues: RotateMode[];
|
||||
static BlendModeValues: BlendMode[];
|
||||
static BONE_ROTATE: number;
|
||||
static BONE_TRANSLATE: number;
|
||||
static BONE_SCALE: number;
|
||||
static BONE_SHEAR: number;
|
||||
static SLOT_ATTACHMENT: number;
|
||||
static SLOT_COLOR: number;
|
||||
static SLOT_TWO_COLOR: number;
|
||||
static PATH_POSITION: number;
|
||||
static PATH_SPACING: number;
|
||||
static PATH_MIX: number;
|
||||
static CURVE_LINEAR: number;
|
||||
static CURVE_STEPPED: number;
|
||||
static CURVE_BEZIER: number;
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale: number;
|
||||
private linkedMeshes;
|
||||
constructor(attachmentLoader: AttachmentLoader);
|
||||
readSkeletonData(binary: Uint8Array): SkeletonData;
|
||||
private readSkin(input, skeletonData, defaultSkin, nonessential);
|
||||
private readAttachment(input, skeletonData, skin, slotIndex, attachmentName, nonessential);
|
||||
private readVertices(input, vertexCount);
|
||||
private readFloatArray(input, n, scale);
|
||||
private readShortArray(input);
|
||||
private readAnimation(input, name, skeletonData);
|
||||
private readCurve(input, frameIndex, timeline);
|
||||
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBounds {
|
||||
minX: number;
|
||||
@ -742,6 +780,7 @@ declare module spine {
|
||||
hash: string;
|
||||
fps: number;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
findBone(boneName: string): BoneData;
|
||||
findBoneIndex(boneName: string): number;
|
||||
findSlot(slotName: string): SlotData;
|
||||
@ -997,6 +1036,8 @@ declare module spine {
|
||||
setFromString(hex: string): this;
|
||||
add(r: number, g: number, b: number, a: number): this;
|
||||
clamp(): this;
|
||||
static rgba8888ToColor(color: Color, value: number): void;
|
||||
static rgb888ToColor(color: Color, value: number): void;
|
||||
}
|
||||
class MathUtils {
|
||||
static PI: number;
|
||||
@ -1132,6 +1173,7 @@ declare module spine {
|
||||
LinkedMesh = 3,
|
||||
Path = 4,
|
||||
Point = 5,
|
||||
Clipping = 6,
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -2181,6 +2181,26 @@ var spine;
|
||||
};
|
||||
request.send();
|
||||
};
|
||||
AssetManager.prototype.loadBinary = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
if (error === void 0) { error = null; }
|
||||
path = this.pathPrefix + path;
|
||||
this.toLoad++;
|
||||
AssetManager.downloadBinary(path, function (data) {
|
||||
_this.assets[path] = data;
|
||||
if (success)
|
||||
success(path, data);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
}, function (state, responseText) {
|
||||
_this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
|
||||
if (error)
|
||||
error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
});
|
||||
};
|
||||
AssetManager.prototype.loadText = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
@ -2691,6 +2711,7 @@ var spine;
|
||||
this.shearY = 0;
|
||||
this.transformMode = TransformMode.Normal;
|
||||
this.skinRequired = false;
|
||||
this.color = new spine.Color();
|
||||
if (index < 0)
|
||||
throw new Error("index must be >= 0.");
|
||||
if (name == null)
|
||||
@ -3999,6 +4020,810 @@ var spine;
|
||||
spine.Skeleton = Skeleton;
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBinary = (function () {
|
||||
function SkeletonBinary(attachmentLoader) {
|
||||
this.scale = 1;
|
||||
this.linkedMeshes = new Array();
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
}
|
||||
SkeletonBinary.prototype.readSkeletonData = function (binary) {
|
||||
var scale = this.scale;
|
||||
var skeletonData = new spine.SkeletonData();
|
||||
skeletonData.name = "";
|
||||
var input = new BinaryInput(binary);
|
||||
skeletonData.hash = input.readString();
|
||||
skeletonData.version = input.readString();
|
||||
skeletonData.x = input.readFloat();
|
||||
skeletonData.y = input.readFloat();
|
||||
skeletonData.width = input.readFloat();
|
||||
skeletonData.height = input.readFloat();
|
||||
var nonessential = input.readBoolean();
|
||||
if (nonessential) {
|
||||
skeletonData.fps = input.readFloat();
|
||||
skeletonData.imagesPath = input.readString();
|
||||
skeletonData.audioPath = input.readString();
|
||||
}
|
||||
var n = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
input.strings.push(input.readString());
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var name_2 = input.readString();
|
||||
var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.BoneData(i, name_2, parent_2);
|
||||
data.rotation = input.readFloat();
|
||||
data.x = input.readFloat() * scale;
|
||||
data.y = input.readFloat() * scale;
|
||||
data.scaleX = input.readFloat();
|
||||
data.scaleY = input.readFloat();
|
||||
data.shearX = input.readFloat();
|
||||
data.shearY = input.readFloat();
|
||||
data.length = input.readFloat() * scale;
|
||||
data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
|
||||
data.skinRequired = input.readBoolean();
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
skeletonData.bones.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var slotName = input.readString();
|
||||
var boneData = skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.SlotData(i, slotName, boneData);
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
var darkColor = input.readInt32();
|
||||
if (darkColor != -1)
|
||||
spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor);
|
||||
data.attachmentName = input.readStringRef();
|
||||
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.IkConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.mix = input.readFloat();
|
||||
data.bendDirection = input.readByte();
|
||||
data.compress = input.readBoolean();
|
||||
data.stretch = input.readBoolean();
|
||||
data.uniform = input.readBoolean();
|
||||
skeletonData.ikConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.TransformConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.local = input.readBoolean();
|
||||
data.relative = input.readBoolean();
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.offsetX = input.readFloat() * scale;
|
||||
data.offsetY = input.readFloat() * scale;
|
||||
data.offsetScaleX = input.readFloat();
|
||||
data.offsetScaleY = input.readFloat();
|
||||
data.offsetShearY = input.readFloat();
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
data.scaleMix = input.readFloat();
|
||||
data.shearMix = input.readFloat();
|
||||
skeletonData.transformConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.PathConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.slots[input.readInt(true)];
|
||||
data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
|
||||
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
|
||||
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.position = input.readFloat();
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
data.position *= scale;
|
||||
data.spacing = input.readFloat();
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
data.spacing *= scale;
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
skeletonData.pathConstraints.push(data);
|
||||
}
|
||||
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
|
||||
if (defaultSkin != null) {
|
||||
skeletonData.defaultSkin = defaultSkin;
|
||||
skeletonData.skins.push(defaultSkin);
|
||||
}
|
||||
{
|
||||
var i = skeletonData.skins.length;
|
||||
spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
|
||||
for (; i < n; i++)
|
||||
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
|
||||
}
|
||||
n = this.linkedMeshes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var linkedMesh = this.linkedMeshes[i];
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var data = new spine.EventData(input.readStringRef());
|
||||
data.intValue = input.readInt(false);
|
||||
data.floatValue = input.readFloat();
|
||||
data.stringValue = input.readString();
|
||||
data.audioPath = input.readString();
|
||||
if (data.audioPath != null) {
|
||||
data.volume = input.readFloat();
|
||||
data.balance = input.readFloat();
|
||||
}
|
||||
skeletonData.events.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
|
||||
return skeletonData;
|
||||
};
|
||||
SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) {
|
||||
var skin = new spine.Skin(defaultSkin ? "default" : input.readStringRef());
|
||||
if (!defaultSkin) {
|
||||
skin.bones.length = input.readInt(true);
|
||||
for (var i = 0, n = skin.bones.length; i < n; i++)
|
||||
skin.bones[i] = skeletonData.bones[input.readInt(true)];
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var name_3 = input.readStringRef();
|
||||
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential);
|
||||
if (attachment != null)
|
||||
skin.setAttachment(slotIndex, name_3, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
};
|
||||
SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
|
||||
var scale = this.scale;
|
||||
var name = input.readStringRef();
|
||||
if (name == null)
|
||||
name = attachmentName;
|
||||
var typeIndex = input.readByte();
|
||||
var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
|
||||
switch (type) {
|
||||
case spine.AttachmentType.Region: {
|
||||
var path = input.readStringRef();
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var scaleX = input.readFloat();
|
||||
var scaleY = input.readFloat();
|
||||
var width = input.readFloat();
|
||||
var height = input.readFloat();
|
||||
var color = input.readInt32();
|
||||
if (path == null)
|
||||
path = name;
|
||||
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
|
||||
if (region == null)
|
||||
return null;
|
||||
region.path = path;
|
||||
region.x = x * scale;
|
||||
region.y = y * scale;
|
||||
region.scaleX = scaleX;
|
||||
region.scaleY = scaleY;
|
||||
region.rotation = rotation;
|
||||
region.width = width * scale;
|
||||
region.height = height * scale;
|
||||
spine.Color.rgba8888ToColor(region.color, color);
|
||||
region.updateOffset();
|
||||
return region;
|
||||
}
|
||||
case spine.AttachmentType.BoundingBox: {
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
|
||||
if (box == null)
|
||||
return null;
|
||||
box.worldVerticesLength = vertexCount << 1;
|
||||
box.vertices = vertices.vertices;
|
||||
box.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(box.color, color);
|
||||
return box;
|
||||
}
|
||||
case spine.AttachmentType.Mesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var vertexCount = input.readInt(true);
|
||||
var uvs = this.readFloatArray(input, vertexCount << 1, 1);
|
||||
var triangles = this.readShortArray(input);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var hullLength = input.readInt(true);
|
||||
var edges = null;
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
edges = this.readShortArray(input);
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
mesh.bones = vertices.bones;
|
||||
mesh.vertices = vertices.vertices;
|
||||
mesh.worldVerticesLength = vertexCount << 1;
|
||||
mesh.triangles = triangles;
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.updateUVs();
|
||||
mesh.hullLength = hullLength << 1;
|
||||
if (nonessential) {
|
||||
mesh.edges = edges;
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.LinkedMesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var skinName = input.readStringRef();
|
||||
var parent_4 = input.readStringRef();
|
||||
var inheritDeform = input.readBoolean();
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
if (nonessential) {
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.Path: {
|
||||
var closed_1 = input.readBoolean();
|
||||
var constantSpeed = input.readBoolean();
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var lengths = spine.Utils.newArray(vertexCount / 3, 0);
|
||||
for (var i = 0, n = lengths.length; i < n; i++)
|
||||
lengths[i] = input.readFloat() * scale;
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var path = this.attachmentLoader.newPathAttachment(skin, name);
|
||||
if (path == null)
|
||||
return null;
|
||||
path.closed = closed_1;
|
||||
path.constantSpeed = constantSpeed;
|
||||
path.worldVerticesLength = vertexCount << 1;
|
||||
path.vertices = vertices.vertices;
|
||||
path.bones = vertices.bones;
|
||||
path.lengths = lengths;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(path.color, color);
|
||||
return path;
|
||||
}
|
||||
case spine.AttachmentType.Point: {
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var point = this.attachmentLoader.newPointAttachment(skin, name);
|
||||
if (point == null)
|
||||
return null;
|
||||
point.x = x * scale;
|
||||
point.y = y * scale;
|
||||
point.rotation = rotation;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(point.color, color);
|
||||
return point;
|
||||
}
|
||||
case spine.AttachmentType.Clipping: {
|
||||
var endSlotIndex = input.readInt(true);
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null)
|
||||
return null;
|
||||
clip.endSlot = skeletonData.slots[endSlotIndex];
|
||||
clip.worldVerticesLength = vertexCount << 1;
|
||||
clip.vertices = vertices.vertices;
|
||||
clip.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(clip.color, color);
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
SkeletonBinary.prototype.readVertices = function (input, vertexCount) {
|
||||
var verticesLength = vertexCount << 1;
|
||||
var vertices = new Vertices();
|
||||
var scale = this.scale;
|
||||
if (!input.readBoolean()) {
|
||||
vertices.vertices = this.readFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
var weights = new Array();
|
||||
var bonesArray = new Array();
|
||||
for (var i = 0; i < vertexCount; i++) {
|
||||
var boneCount = input.readInt(true);
|
||||
bonesArray.push(boneCount);
|
||||
for (var ii = 0; ii < boneCount; ii++) {
|
||||
bonesArray.push(input.readInt(true));
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat());
|
||||
}
|
||||
}
|
||||
vertices.vertices = spine.Utils.toFloatArray(weights);
|
||||
vertices.bones = bonesArray;
|
||||
return vertices;
|
||||
};
|
||||
SkeletonBinary.prototype.readFloatArray = function (input, n, scale) {
|
||||
var array = new Array(n);
|
||||
if (scale == 1) {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat() * scale;
|
||||
}
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readShortArray = function (input) {
|
||||
var n = input.readInt(true);
|
||||
var array = new Array(n);
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readShort();
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) {
|
||||
var timelines = new Array();
|
||||
var scale = this.scale;
|
||||
var duration = 0;
|
||||
var tempColor1 = new spine.Color();
|
||||
var tempColor2 = new spine.Color();
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.SLOT_ATTACHMENT: {
|
||||
var timeline = new spine.AttachmentTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_COLOR: {
|
||||
var timeline = new spine.ColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_TWO_COLOR: {
|
||||
var timeline = new spine.TwoColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
spine.Color.rgb888ToColor(tempColor2, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var boneIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.BONE_ROTATE: {
|
||||
var timeline = new spine.RotateTimeline(frameCount);
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.BONE_TRANSLATE:
|
||||
case SkeletonBinary.BONE_SCALE:
|
||||
case SkeletonBinary.BONE_SHEAR: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.BONE_SCALE)
|
||||
timeline = new spine.ScaleTimeline(frameCount);
|
||||
else if (timelineType == SkeletonBinary.BONE_SHEAR)
|
||||
timeline = new spine.ShearTimeline(frameCount);
|
||||
else {
|
||||
timeline = new spine.TranslateTimeline(frameCount);
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.IkConstraintTimeline(frameCount);
|
||||
timeline.ikConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readByte(), input.readBoolean(), input.readBoolean());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.TransformConstraintTimeline(frameCount);
|
||||
timeline.transformConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var data = skeletonData.pathConstraints[index];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.PATH_POSITION:
|
||||
case SkeletonBinary.PATH_SPACING: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.PATH_SPACING) {
|
||||
timeline = new spine.PathConstraintSpacingTimeline(frameCount);
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
else {
|
||||
timeline = new spine.PathConstraintPositionTimeline(frameCount);
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.PATH_MIX: {
|
||||
var timeline = new spine.PathConstraintMixTimeline(frameCount);
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var skin = skeletonData.skins[input.readInt(true)];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
|
||||
var attachment = skin.getAttachment(slotIndex, input.readStringRef());
|
||||
var weighted = attachment.bones != null;
|
||||
var vertices = attachment.vertices;
|
||||
var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.DeformTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
timeline.attachment = attachment;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
var deform = void 0;
|
||||
var end = input.readInt(true);
|
||||
if (end == 0)
|
||||
deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
|
||||
else {
|
||||
deform = spine.Utils.newFloatArray(deformLength);
|
||||
var start = input.readInt(true);
|
||||
end += start;
|
||||
if (scale == 1) {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat() * scale;
|
||||
}
|
||||
if (!weighted) {
|
||||
for (var v = 0, vn = deform.length; v < vn; v++)
|
||||
deform[v] += vertices[v];
|
||||
}
|
||||
}
|
||||
timeline.setFrame(frameIndex, time, deform);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
var drawOrderCount = input.readInt(true);
|
||||
if (drawOrderCount > 0) {
|
||||
var timeline = new spine.DrawOrderTimeline(drawOrderCount);
|
||||
var slotCount = skeletonData.slots.length;
|
||||
for (var i = 0; i < drawOrderCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var offsetCount = input.readInt(true);
|
||||
var drawOrder = spine.Utils.newArray(slotCount, 0);
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
drawOrder[ii] = -1;
|
||||
var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0);
|
||||
var originalIndex = 0, unchangedIndex = 0;
|
||||
for (var ii = 0; ii < offsetCount; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
while (originalIndex != slotIndex)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
|
||||
}
|
||||
while (originalIndex < slotCount)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
if (drawOrder[ii] == -1)
|
||||
drawOrder[ii] = unchanged[--unchangedIndex];
|
||||
timeline.setFrame(i, time, drawOrder);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
|
||||
}
|
||||
var eventCount = input.readInt(true);
|
||||
if (eventCount > 0) {
|
||||
var timeline = new spine.EventTimeline(eventCount);
|
||||
for (var i = 0; i < eventCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var eventData = skeletonData.events[input.readInt(true)];
|
||||
var event_4 = new spine.Event(time, eventData);
|
||||
event_4.intValue = input.readInt(false);
|
||||
event_4.floatValue = input.readFloat();
|
||||
event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
|
||||
if (event_4.data.audioPath != null) {
|
||||
event_4.volume = input.readFloat();
|
||||
event_4.balance = input.readFloat();
|
||||
}
|
||||
timeline.setFrame(i, event_4);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[eventCount - 1]);
|
||||
}
|
||||
return new spine.Animation(name, timelines, duration);
|
||||
};
|
||||
SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) {
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frameIndex);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
break;
|
||||
}
|
||||
};
|
||||
SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
|
||||
timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
|
||||
};
|
||||
SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6];
|
||||
SkeletonBinary.TransformModeValues = [spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection];
|
||||
SkeletonBinary.PositionModeValues = [spine.PositionMode.Fixed, spine.PositionMode.Percent];
|
||||
SkeletonBinary.SpacingModeValues = [spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent];
|
||||
SkeletonBinary.RotateModeValues = [spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale];
|
||||
SkeletonBinary.BlendModeValues = [spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen];
|
||||
SkeletonBinary.BONE_ROTATE = 0;
|
||||
SkeletonBinary.BONE_TRANSLATE = 1;
|
||||
SkeletonBinary.BONE_SCALE = 2;
|
||||
SkeletonBinary.BONE_SHEAR = 3;
|
||||
SkeletonBinary.SLOT_ATTACHMENT = 0;
|
||||
SkeletonBinary.SLOT_COLOR = 1;
|
||||
SkeletonBinary.SLOT_TWO_COLOR = 2;
|
||||
SkeletonBinary.PATH_POSITION = 0;
|
||||
SkeletonBinary.PATH_SPACING = 1;
|
||||
SkeletonBinary.PATH_MIX = 2;
|
||||
SkeletonBinary.CURVE_LINEAR = 0;
|
||||
SkeletonBinary.CURVE_STEPPED = 1;
|
||||
SkeletonBinary.CURVE_BEZIER = 2;
|
||||
return SkeletonBinary;
|
||||
}());
|
||||
spine.SkeletonBinary = SkeletonBinary;
|
||||
var BinaryInput = (function () {
|
||||
function BinaryInput(data, strings, index, buffer) {
|
||||
if (strings === void 0) { strings = new Array(); }
|
||||
if (index === void 0) { index = 0; }
|
||||
if (buffer === void 0) { buffer = new DataView(data.buffer); }
|
||||
this.strings = strings;
|
||||
this.index = index;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
BinaryInput.prototype.readByte = function () {
|
||||
return this.buffer.getInt8(this.index++);
|
||||
};
|
||||
BinaryInput.prototype.readShort = function () {
|
||||
var value = this.buffer.getInt16(this.index);
|
||||
this.index += 2;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt32 = function () {
|
||||
var value = this.buffer.getInt32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt = function (optimizePositive) {
|
||||
var b = this.readByte();
|
||||
var result = b & 0x7F;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 7;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 14;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 21;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
|
||||
};
|
||||
BinaryInput.prototype.readStringRef = function () {
|
||||
var index = this.readInt(true);
|
||||
return index == 0 ? null : this.strings[index - 1];
|
||||
};
|
||||
BinaryInput.prototype.readString = function () {
|
||||
var byteCount = this.readInt(true);
|
||||
switch (byteCount) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return "";
|
||||
}
|
||||
byteCount--;
|
||||
var chars = "";
|
||||
var charCount = 0;
|
||||
for (var i = 0; i < byteCount;) {
|
||||
var b = this.readByte();
|
||||
switch (b >> 4) {
|
||||
case 12:
|
||||
case 13:
|
||||
chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
|
||||
i += 2;
|
||||
break;
|
||||
case 14:
|
||||
chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
|
||||
i += 3;
|
||||
break;
|
||||
default:
|
||||
chars += String.fromCharCode(b);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
BinaryInput.prototype.readFloat = function () {
|
||||
var value = this.buffer.getFloat32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readBoolean = function () {
|
||||
return this.readByte() != 0;
|
||||
};
|
||||
return BinaryInput;
|
||||
}());
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
var Vertices = (function () {
|
||||
function Vertices(bones, vertices) {
|
||||
if (bones === void 0) { bones = null; }
|
||||
if (vertices === void 0) { vertices = null; }
|
||||
this.bones = bones;
|
||||
this.vertices = vertices;
|
||||
}
|
||||
return Vertices;
|
||||
}());
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBounds = (function () {
|
||||
function SkeletonBounds() {
|
||||
@ -4528,9 +5353,9 @@ var spine;
|
||||
throw new Error("eventDataName cannot be null.");
|
||||
var events = this.events;
|
||||
for (var i = 0, n = events.length; i < n; i++) {
|
||||
var event_4 = events[i];
|
||||
if (event_4.name == eventDataName)
|
||||
return event_4;
|
||||
var event_5 = events[i];
|
||||
if (event_5.name == eventDataName)
|
||||
return event_5;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@ -4617,14 +5442,14 @@ var spine;
|
||||
if (root.bones) {
|
||||
for (var i = 0; i < root.bones.length; i++) {
|
||||
var boneMap = root.bones[i];
|
||||
var parent_2 = null;
|
||||
var parent_5 = null;
|
||||
var parentName = this.getValue(boneMap, "parent", null);
|
||||
if (parentName != null) {
|
||||
parent_2 = skeletonData.findBone(parentName);
|
||||
if (parent_2 == null)
|
||||
parent_5 = skeletonData.findBone(parentName);
|
||||
if (parent_5 == null)
|
||||
throw new Error("Parent bone not found: " + parentName);
|
||||
}
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2);
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5);
|
||||
data.length = this.getValue(boneMap, "length", 0) * scale;
|
||||
data.x = this.getValue(boneMap, "x", 0) * scale;
|
||||
data.y = this.getValue(boneMap, "y", 0) * scale;
|
||||
@ -4806,11 +5631,11 @@ var spine;
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_6 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_6);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
@ -4883,9 +5708,9 @@ var spine;
|
||||
mesh.color.setFromString(color);
|
||||
mesh.width = this.getValue(map, "width", 0) * scale;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
var parent_7 = this.getValue(map, "parent", null);
|
||||
if (parent_7 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5264,15 +6089,15 @@ var spine;
|
||||
var eventData = skeletonData.findEvent(eventMap.name);
|
||||
if (eventData == null)
|
||||
throw new Error("Event not found: " + eventMap.name);
|
||||
var event_5 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_5.data.audioPath != null) {
|
||||
event_5.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_5.balance = this.getValue(eventMap, "balance", 0);
|
||||
var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_6.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_6.data.audioPath != null) {
|
||||
event_6.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_6.balance = this.getValue(eventMap, "balance", 0);
|
||||
}
|
||||
timeline.setFrame(frameIndex++, event_5);
|
||||
timeline.setFrame(frameIndex++, event_6);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
|
||||
@ -5478,10 +6303,10 @@ var spine;
|
||||
for (var i = 0; i < this.attachments.length; i++) {
|
||||
var slotAttachments = this.attachments[i];
|
||||
if (slotAttachments) {
|
||||
for (var name_2 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_2];
|
||||
for (var name_4 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_4];
|
||||
if (attachment)
|
||||
entries.push(new SkinEntry(i, name_2, attachment));
|
||||
entries.push(new SkinEntry(i, name_4, attachment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5490,10 +6315,10 @@ var spine;
|
||||
Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) {
|
||||
var slotAttachments = this.attachments[slotIndex];
|
||||
if (slotAttachments) {
|
||||
for (var name_3 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_3];
|
||||
for (var name_5 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_5];
|
||||
if (attachment)
|
||||
attachments.push(new SkinEntry(slotIndex, name_3, attachment));
|
||||
attachments.push(new SkinEntry(slotIndex, name_5, attachment));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6394,6 +7219,17 @@ var spine;
|
||||
this.a = 1;
|
||||
return this;
|
||||
};
|
||||
Color.rgba8888ToColor = function (color, value) {
|
||||
color.r = ((value & 0xff000000) >>> 24) / 255;
|
||||
color.g = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.b = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.a = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.rgb888ToColor = function (color, value) {
|
||||
color.r = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.b = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.WHITE = new Color(1, 1, 1, 1);
|
||||
Color.RED = new Color(1, 0, 0, 1);
|
||||
Color.GREEN = new Color(0, 1, 0, 1);
|
||||
@ -6810,6 +7646,7 @@ var spine;
|
||||
AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
|
||||
AttachmentType[AttachmentType["Path"] = 4] = "Path";
|
||||
AttachmentType[AttachmentType["Point"] = 5] = "Point";
|
||||
AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping";
|
||||
})(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
|
||||
File diff suppressed because one or more lines are too long
43
spine-ts/build/spine-player.d.ts
vendored
43
spine-ts/build/spine-player.d.ts
vendored
@ -384,6 +384,7 @@ declare module spine {
|
||||
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
|
||||
private static downloadText(url, success, error);
|
||||
private static downloadBinary(url, success, error);
|
||||
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
|
||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
@ -481,6 +482,7 @@ declare module spine {
|
||||
shearY: number;
|
||||
transformMode: TransformMode;
|
||||
skinRequired: boolean;
|
||||
color: Color;
|
||||
constructor(index: number, name: string, parent: BoneData);
|
||||
}
|
||||
enum TransformMode {
|
||||
@ -680,6 +682,42 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBinary {
|
||||
static AttachmentTypeValues: number[];
|
||||
static TransformModeValues: TransformMode[];
|
||||
static PositionModeValues: PositionMode[];
|
||||
static SpacingModeValues: SpacingMode[];
|
||||
static RotateModeValues: RotateMode[];
|
||||
static BlendModeValues: BlendMode[];
|
||||
static BONE_ROTATE: number;
|
||||
static BONE_TRANSLATE: number;
|
||||
static BONE_SCALE: number;
|
||||
static BONE_SHEAR: number;
|
||||
static SLOT_ATTACHMENT: number;
|
||||
static SLOT_COLOR: number;
|
||||
static SLOT_TWO_COLOR: number;
|
||||
static PATH_POSITION: number;
|
||||
static PATH_SPACING: number;
|
||||
static PATH_MIX: number;
|
||||
static CURVE_LINEAR: number;
|
||||
static CURVE_STEPPED: number;
|
||||
static CURVE_BEZIER: number;
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale: number;
|
||||
private linkedMeshes;
|
||||
constructor(attachmentLoader: AttachmentLoader);
|
||||
readSkeletonData(binary: Uint8Array): SkeletonData;
|
||||
private readSkin(input, skeletonData, defaultSkin, nonessential);
|
||||
private readAttachment(input, skeletonData, skin, slotIndex, attachmentName, nonessential);
|
||||
private readVertices(input, vertexCount);
|
||||
private readFloatArray(input, n, scale);
|
||||
private readShortArray(input);
|
||||
private readAnimation(input, name, skeletonData);
|
||||
private readCurve(input, frameIndex, timeline);
|
||||
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBounds {
|
||||
minX: number;
|
||||
@ -742,6 +780,7 @@ declare module spine {
|
||||
hash: string;
|
||||
fps: number;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
findBone(boneName: string): BoneData;
|
||||
findBoneIndex(boneName: string): number;
|
||||
findSlot(slotName: string): SlotData;
|
||||
@ -997,6 +1036,8 @@ declare module spine {
|
||||
setFromString(hex: string): this;
|
||||
add(r: number, g: number, b: number, a: number): this;
|
||||
clamp(): this;
|
||||
static rgba8888ToColor(color: Color, value: number): void;
|
||||
static rgb888ToColor(color: Color, value: number): void;
|
||||
}
|
||||
class MathUtils {
|
||||
static PI: number;
|
||||
@ -1132,6 +1173,7 @@ declare module spine {
|
||||
LinkedMesh = 3,
|
||||
Path = 4,
|
||||
Point = 5,
|
||||
Clipping = 6,
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -1729,6 +1771,7 @@ declare module spine {
|
||||
}
|
||||
interface SpinePlayerConfig {
|
||||
jsonUrl: string;
|
||||
skelUrl: string;
|
||||
atlasUrl: string;
|
||||
animation: string;
|
||||
animations: string[];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
42
spine-ts/build/spine-threejs.d.ts
vendored
42
spine-ts/build/spine-threejs.d.ts
vendored
@ -384,6 +384,7 @@ declare module spine {
|
||||
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
|
||||
private static downloadText(url, success, error);
|
||||
private static downloadBinary(url, success, error);
|
||||
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
|
||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
@ -481,6 +482,7 @@ declare module spine {
|
||||
shearY: number;
|
||||
transformMode: TransformMode;
|
||||
skinRequired: boolean;
|
||||
color: Color;
|
||||
constructor(index: number, name: string, parent: BoneData);
|
||||
}
|
||||
enum TransformMode {
|
||||
@ -680,6 +682,42 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBinary {
|
||||
static AttachmentTypeValues: number[];
|
||||
static TransformModeValues: TransformMode[];
|
||||
static PositionModeValues: PositionMode[];
|
||||
static SpacingModeValues: SpacingMode[];
|
||||
static RotateModeValues: RotateMode[];
|
||||
static BlendModeValues: BlendMode[];
|
||||
static BONE_ROTATE: number;
|
||||
static BONE_TRANSLATE: number;
|
||||
static BONE_SCALE: number;
|
||||
static BONE_SHEAR: number;
|
||||
static SLOT_ATTACHMENT: number;
|
||||
static SLOT_COLOR: number;
|
||||
static SLOT_TWO_COLOR: number;
|
||||
static PATH_POSITION: number;
|
||||
static PATH_SPACING: number;
|
||||
static PATH_MIX: number;
|
||||
static CURVE_LINEAR: number;
|
||||
static CURVE_STEPPED: number;
|
||||
static CURVE_BEZIER: number;
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale: number;
|
||||
private linkedMeshes;
|
||||
constructor(attachmentLoader: AttachmentLoader);
|
||||
readSkeletonData(binary: Uint8Array): SkeletonData;
|
||||
private readSkin(input, skeletonData, defaultSkin, nonessential);
|
||||
private readAttachment(input, skeletonData, skin, slotIndex, attachmentName, nonessential);
|
||||
private readVertices(input, vertexCount);
|
||||
private readFloatArray(input, n, scale);
|
||||
private readShortArray(input);
|
||||
private readAnimation(input, name, skeletonData);
|
||||
private readCurve(input, frameIndex, timeline);
|
||||
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBounds {
|
||||
minX: number;
|
||||
@ -742,6 +780,7 @@ declare module spine {
|
||||
hash: string;
|
||||
fps: number;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
findBone(boneName: string): BoneData;
|
||||
findBoneIndex(boneName: string): number;
|
||||
findSlot(slotName: string): SlotData;
|
||||
@ -997,6 +1036,8 @@ declare module spine {
|
||||
setFromString(hex: string): this;
|
||||
add(r: number, g: number, b: number, a: number): this;
|
||||
clamp(): this;
|
||||
static rgba8888ToColor(color: Color, value: number): void;
|
||||
static rgb888ToColor(color: Color, value: number): void;
|
||||
}
|
||||
class MathUtils {
|
||||
static PI: number;
|
||||
@ -1132,6 +1173,7 @@ declare module spine {
|
||||
LinkedMesh = 3,
|
||||
Path = 4,
|
||||
Point = 5,
|
||||
Clipping = 6,
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -2181,6 +2181,26 @@ var spine;
|
||||
};
|
||||
request.send();
|
||||
};
|
||||
AssetManager.prototype.loadBinary = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
if (error === void 0) { error = null; }
|
||||
path = this.pathPrefix + path;
|
||||
this.toLoad++;
|
||||
AssetManager.downloadBinary(path, function (data) {
|
||||
_this.assets[path] = data;
|
||||
if (success)
|
||||
success(path, data);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
}, function (state, responseText) {
|
||||
_this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
|
||||
if (error)
|
||||
error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
});
|
||||
};
|
||||
AssetManager.prototype.loadText = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
@ -2691,6 +2711,7 @@ var spine;
|
||||
this.shearY = 0;
|
||||
this.transformMode = TransformMode.Normal;
|
||||
this.skinRequired = false;
|
||||
this.color = new spine.Color();
|
||||
if (index < 0)
|
||||
throw new Error("index must be >= 0.");
|
||||
if (name == null)
|
||||
@ -3999,6 +4020,810 @@ var spine;
|
||||
spine.Skeleton = Skeleton;
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBinary = (function () {
|
||||
function SkeletonBinary(attachmentLoader) {
|
||||
this.scale = 1;
|
||||
this.linkedMeshes = new Array();
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
}
|
||||
SkeletonBinary.prototype.readSkeletonData = function (binary) {
|
||||
var scale = this.scale;
|
||||
var skeletonData = new spine.SkeletonData();
|
||||
skeletonData.name = "";
|
||||
var input = new BinaryInput(binary);
|
||||
skeletonData.hash = input.readString();
|
||||
skeletonData.version = input.readString();
|
||||
skeletonData.x = input.readFloat();
|
||||
skeletonData.y = input.readFloat();
|
||||
skeletonData.width = input.readFloat();
|
||||
skeletonData.height = input.readFloat();
|
||||
var nonessential = input.readBoolean();
|
||||
if (nonessential) {
|
||||
skeletonData.fps = input.readFloat();
|
||||
skeletonData.imagesPath = input.readString();
|
||||
skeletonData.audioPath = input.readString();
|
||||
}
|
||||
var n = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
input.strings.push(input.readString());
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var name_2 = input.readString();
|
||||
var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.BoneData(i, name_2, parent_2);
|
||||
data.rotation = input.readFloat();
|
||||
data.x = input.readFloat() * scale;
|
||||
data.y = input.readFloat() * scale;
|
||||
data.scaleX = input.readFloat();
|
||||
data.scaleY = input.readFloat();
|
||||
data.shearX = input.readFloat();
|
||||
data.shearY = input.readFloat();
|
||||
data.length = input.readFloat() * scale;
|
||||
data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
|
||||
data.skinRequired = input.readBoolean();
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
skeletonData.bones.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var slotName = input.readString();
|
||||
var boneData = skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.SlotData(i, slotName, boneData);
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
var darkColor = input.readInt32();
|
||||
if (darkColor != -1)
|
||||
spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor);
|
||||
data.attachmentName = input.readStringRef();
|
||||
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.IkConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.mix = input.readFloat();
|
||||
data.bendDirection = input.readByte();
|
||||
data.compress = input.readBoolean();
|
||||
data.stretch = input.readBoolean();
|
||||
data.uniform = input.readBoolean();
|
||||
skeletonData.ikConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.TransformConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.local = input.readBoolean();
|
||||
data.relative = input.readBoolean();
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.offsetX = input.readFloat() * scale;
|
||||
data.offsetY = input.readFloat() * scale;
|
||||
data.offsetScaleX = input.readFloat();
|
||||
data.offsetScaleY = input.readFloat();
|
||||
data.offsetShearY = input.readFloat();
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
data.scaleMix = input.readFloat();
|
||||
data.shearMix = input.readFloat();
|
||||
skeletonData.transformConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.PathConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.slots[input.readInt(true)];
|
||||
data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
|
||||
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
|
||||
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.position = input.readFloat();
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
data.position *= scale;
|
||||
data.spacing = input.readFloat();
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
data.spacing *= scale;
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
skeletonData.pathConstraints.push(data);
|
||||
}
|
||||
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
|
||||
if (defaultSkin != null) {
|
||||
skeletonData.defaultSkin = defaultSkin;
|
||||
skeletonData.skins.push(defaultSkin);
|
||||
}
|
||||
{
|
||||
var i = skeletonData.skins.length;
|
||||
spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
|
||||
for (; i < n; i++)
|
||||
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
|
||||
}
|
||||
n = this.linkedMeshes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var linkedMesh = this.linkedMeshes[i];
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var data = new spine.EventData(input.readStringRef());
|
||||
data.intValue = input.readInt(false);
|
||||
data.floatValue = input.readFloat();
|
||||
data.stringValue = input.readString();
|
||||
data.audioPath = input.readString();
|
||||
if (data.audioPath != null) {
|
||||
data.volume = input.readFloat();
|
||||
data.balance = input.readFloat();
|
||||
}
|
||||
skeletonData.events.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
|
||||
return skeletonData;
|
||||
};
|
||||
SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) {
|
||||
var skin = new spine.Skin(defaultSkin ? "default" : input.readStringRef());
|
||||
if (!defaultSkin) {
|
||||
skin.bones.length = input.readInt(true);
|
||||
for (var i = 0, n = skin.bones.length; i < n; i++)
|
||||
skin.bones[i] = skeletonData.bones[input.readInt(true)];
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var name_3 = input.readStringRef();
|
||||
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential);
|
||||
if (attachment != null)
|
||||
skin.setAttachment(slotIndex, name_3, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
};
|
||||
SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
|
||||
var scale = this.scale;
|
||||
var name = input.readStringRef();
|
||||
if (name == null)
|
||||
name = attachmentName;
|
||||
var typeIndex = input.readByte();
|
||||
var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
|
||||
switch (type) {
|
||||
case spine.AttachmentType.Region: {
|
||||
var path = input.readStringRef();
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var scaleX = input.readFloat();
|
||||
var scaleY = input.readFloat();
|
||||
var width = input.readFloat();
|
||||
var height = input.readFloat();
|
||||
var color = input.readInt32();
|
||||
if (path == null)
|
||||
path = name;
|
||||
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
|
||||
if (region == null)
|
||||
return null;
|
||||
region.path = path;
|
||||
region.x = x * scale;
|
||||
region.y = y * scale;
|
||||
region.scaleX = scaleX;
|
||||
region.scaleY = scaleY;
|
||||
region.rotation = rotation;
|
||||
region.width = width * scale;
|
||||
region.height = height * scale;
|
||||
spine.Color.rgba8888ToColor(region.color, color);
|
||||
region.updateOffset();
|
||||
return region;
|
||||
}
|
||||
case spine.AttachmentType.BoundingBox: {
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
|
||||
if (box == null)
|
||||
return null;
|
||||
box.worldVerticesLength = vertexCount << 1;
|
||||
box.vertices = vertices.vertices;
|
||||
box.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(box.color, color);
|
||||
return box;
|
||||
}
|
||||
case spine.AttachmentType.Mesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var vertexCount = input.readInt(true);
|
||||
var uvs = this.readFloatArray(input, vertexCount << 1, 1);
|
||||
var triangles = this.readShortArray(input);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var hullLength = input.readInt(true);
|
||||
var edges = null;
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
edges = this.readShortArray(input);
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
mesh.bones = vertices.bones;
|
||||
mesh.vertices = vertices.vertices;
|
||||
mesh.worldVerticesLength = vertexCount << 1;
|
||||
mesh.triangles = triangles;
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.updateUVs();
|
||||
mesh.hullLength = hullLength << 1;
|
||||
if (nonessential) {
|
||||
mesh.edges = edges;
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.LinkedMesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var skinName = input.readStringRef();
|
||||
var parent_4 = input.readStringRef();
|
||||
var inheritDeform = input.readBoolean();
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
if (nonessential) {
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.Path: {
|
||||
var closed_1 = input.readBoolean();
|
||||
var constantSpeed = input.readBoolean();
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var lengths = spine.Utils.newArray(vertexCount / 3, 0);
|
||||
for (var i = 0, n = lengths.length; i < n; i++)
|
||||
lengths[i] = input.readFloat() * scale;
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var path = this.attachmentLoader.newPathAttachment(skin, name);
|
||||
if (path == null)
|
||||
return null;
|
||||
path.closed = closed_1;
|
||||
path.constantSpeed = constantSpeed;
|
||||
path.worldVerticesLength = vertexCount << 1;
|
||||
path.vertices = vertices.vertices;
|
||||
path.bones = vertices.bones;
|
||||
path.lengths = lengths;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(path.color, color);
|
||||
return path;
|
||||
}
|
||||
case spine.AttachmentType.Point: {
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var point = this.attachmentLoader.newPointAttachment(skin, name);
|
||||
if (point == null)
|
||||
return null;
|
||||
point.x = x * scale;
|
||||
point.y = y * scale;
|
||||
point.rotation = rotation;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(point.color, color);
|
||||
return point;
|
||||
}
|
||||
case spine.AttachmentType.Clipping: {
|
||||
var endSlotIndex = input.readInt(true);
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null)
|
||||
return null;
|
||||
clip.endSlot = skeletonData.slots[endSlotIndex];
|
||||
clip.worldVerticesLength = vertexCount << 1;
|
||||
clip.vertices = vertices.vertices;
|
||||
clip.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(clip.color, color);
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
SkeletonBinary.prototype.readVertices = function (input, vertexCount) {
|
||||
var verticesLength = vertexCount << 1;
|
||||
var vertices = new Vertices();
|
||||
var scale = this.scale;
|
||||
if (!input.readBoolean()) {
|
||||
vertices.vertices = this.readFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
var weights = new Array();
|
||||
var bonesArray = new Array();
|
||||
for (var i = 0; i < vertexCount; i++) {
|
||||
var boneCount = input.readInt(true);
|
||||
bonesArray.push(boneCount);
|
||||
for (var ii = 0; ii < boneCount; ii++) {
|
||||
bonesArray.push(input.readInt(true));
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat());
|
||||
}
|
||||
}
|
||||
vertices.vertices = spine.Utils.toFloatArray(weights);
|
||||
vertices.bones = bonesArray;
|
||||
return vertices;
|
||||
};
|
||||
SkeletonBinary.prototype.readFloatArray = function (input, n, scale) {
|
||||
var array = new Array(n);
|
||||
if (scale == 1) {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat() * scale;
|
||||
}
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readShortArray = function (input) {
|
||||
var n = input.readInt(true);
|
||||
var array = new Array(n);
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readShort();
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) {
|
||||
var timelines = new Array();
|
||||
var scale = this.scale;
|
||||
var duration = 0;
|
||||
var tempColor1 = new spine.Color();
|
||||
var tempColor2 = new spine.Color();
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.SLOT_ATTACHMENT: {
|
||||
var timeline = new spine.AttachmentTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_COLOR: {
|
||||
var timeline = new spine.ColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_TWO_COLOR: {
|
||||
var timeline = new spine.TwoColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
spine.Color.rgb888ToColor(tempColor2, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var boneIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.BONE_ROTATE: {
|
||||
var timeline = new spine.RotateTimeline(frameCount);
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.BONE_TRANSLATE:
|
||||
case SkeletonBinary.BONE_SCALE:
|
||||
case SkeletonBinary.BONE_SHEAR: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.BONE_SCALE)
|
||||
timeline = new spine.ScaleTimeline(frameCount);
|
||||
else if (timelineType == SkeletonBinary.BONE_SHEAR)
|
||||
timeline = new spine.ShearTimeline(frameCount);
|
||||
else {
|
||||
timeline = new spine.TranslateTimeline(frameCount);
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.IkConstraintTimeline(frameCount);
|
||||
timeline.ikConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readByte(), input.readBoolean(), input.readBoolean());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.TransformConstraintTimeline(frameCount);
|
||||
timeline.transformConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var data = skeletonData.pathConstraints[index];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.PATH_POSITION:
|
||||
case SkeletonBinary.PATH_SPACING: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.PATH_SPACING) {
|
||||
timeline = new spine.PathConstraintSpacingTimeline(frameCount);
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
else {
|
||||
timeline = new spine.PathConstraintPositionTimeline(frameCount);
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.PATH_MIX: {
|
||||
var timeline = new spine.PathConstraintMixTimeline(frameCount);
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var skin = skeletonData.skins[input.readInt(true)];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
|
||||
var attachment = skin.getAttachment(slotIndex, input.readStringRef());
|
||||
var weighted = attachment.bones != null;
|
||||
var vertices = attachment.vertices;
|
||||
var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.DeformTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
timeline.attachment = attachment;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
var deform = void 0;
|
||||
var end = input.readInt(true);
|
||||
if (end == 0)
|
||||
deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
|
||||
else {
|
||||
deform = spine.Utils.newFloatArray(deformLength);
|
||||
var start = input.readInt(true);
|
||||
end += start;
|
||||
if (scale == 1) {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat() * scale;
|
||||
}
|
||||
if (!weighted) {
|
||||
for (var v = 0, vn = deform.length; v < vn; v++)
|
||||
deform[v] += vertices[v];
|
||||
}
|
||||
}
|
||||
timeline.setFrame(frameIndex, time, deform);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
var drawOrderCount = input.readInt(true);
|
||||
if (drawOrderCount > 0) {
|
||||
var timeline = new spine.DrawOrderTimeline(drawOrderCount);
|
||||
var slotCount = skeletonData.slots.length;
|
||||
for (var i = 0; i < drawOrderCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var offsetCount = input.readInt(true);
|
||||
var drawOrder = spine.Utils.newArray(slotCount, 0);
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
drawOrder[ii] = -1;
|
||||
var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0);
|
||||
var originalIndex = 0, unchangedIndex = 0;
|
||||
for (var ii = 0; ii < offsetCount; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
while (originalIndex != slotIndex)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
|
||||
}
|
||||
while (originalIndex < slotCount)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
if (drawOrder[ii] == -1)
|
||||
drawOrder[ii] = unchanged[--unchangedIndex];
|
||||
timeline.setFrame(i, time, drawOrder);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
|
||||
}
|
||||
var eventCount = input.readInt(true);
|
||||
if (eventCount > 0) {
|
||||
var timeline = new spine.EventTimeline(eventCount);
|
||||
for (var i = 0; i < eventCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var eventData = skeletonData.events[input.readInt(true)];
|
||||
var event_4 = new spine.Event(time, eventData);
|
||||
event_4.intValue = input.readInt(false);
|
||||
event_4.floatValue = input.readFloat();
|
||||
event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
|
||||
if (event_4.data.audioPath != null) {
|
||||
event_4.volume = input.readFloat();
|
||||
event_4.balance = input.readFloat();
|
||||
}
|
||||
timeline.setFrame(i, event_4);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[eventCount - 1]);
|
||||
}
|
||||
return new spine.Animation(name, timelines, duration);
|
||||
};
|
||||
SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) {
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frameIndex);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
break;
|
||||
}
|
||||
};
|
||||
SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
|
||||
timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
|
||||
};
|
||||
SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6];
|
||||
SkeletonBinary.TransformModeValues = [spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection];
|
||||
SkeletonBinary.PositionModeValues = [spine.PositionMode.Fixed, spine.PositionMode.Percent];
|
||||
SkeletonBinary.SpacingModeValues = [spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent];
|
||||
SkeletonBinary.RotateModeValues = [spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale];
|
||||
SkeletonBinary.BlendModeValues = [spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen];
|
||||
SkeletonBinary.BONE_ROTATE = 0;
|
||||
SkeletonBinary.BONE_TRANSLATE = 1;
|
||||
SkeletonBinary.BONE_SCALE = 2;
|
||||
SkeletonBinary.BONE_SHEAR = 3;
|
||||
SkeletonBinary.SLOT_ATTACHMENT = 0;
|
||||
SkeletonBinary.SLOT_COLOR = 1;
|
||||
SkeletonBinary.SLOT_TWO_COLOR = 2;
|
||||
SkeletonBinary.PATH_POSITION = 0;
|
||||
SkeletonBinary.PATH_SPACING = 1;
|
||||
SkeletonBinary.PATH_MIX = 2;
|
||||
SkeletonBinary.CURVE_LINEAR = 0;
|
||||
SkeletonBinary.CURVE_STEPPED = 1;
|
||||
SkeletonBinary.CURVE_BEZIER = 2;
|
||||
return SkeletonBinary;
|
||||
}());
|
||||
spine.SkeletonBinary = SkeletonBinary;
|
||||
var BinaryInput = (function () {
|
||||
function BinaryInput(data, strings, index, buffer) {
|
||||
if (strings === void 0) { strings = new Array(); }
|
||||
if (index === void 0) { index = 0; }
|
||||
if (buffer === void 0) { buffer = new DataView(data.buffer); }
|
||||
this.strings = strings;
|
||||
this.index = index;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
BinaryInput.prototype.readByte = function () {
|
||||
return this.buffer.getInt8(this.index++);
|
||||
};
|
||||
BinaryInput.prototype.readShort = function () {
|
||||
var value = this.buffer.getInt16(this.index);
|
||||
this.index += 2;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt32 = function () {
|
||||
var value = this.buffer.getInt32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt = function (optimizePositive) {
|
||||
var b = this.readByte();
|
||||
var result = b & 0x7F;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 7;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 14;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 21;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
|
||||
};
|
||||
BinaryInput.prototype.readStringRef = function () {
|
||||
var index = this.readInt(true);
|
||||
return index == 0 ? null : this.strings[index - 1];
|
||||
};
|
||||
BinaryInput.prototype.readString = function () {
|
||||
var byteCount = this.readInt(true);
|
||||
switch (byteCount) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return "";
|
||||
}
|
||||
byteCount--;
|
||||
var chars = "";
|
||||
var charCount = 0;
|
||||
for (var i = 0; i < byteCount;) {
|
||||
var b = this.readByte();
|
||||
switch (b >> 4) {
|
||||
case 12:
|
||||
case 13:
|
||||
chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
|
||||
i += 2;
|
||||
break;
|
||||
case 14:
|
||||
chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
|
||||
i += 3;
|
||||
break;
|
||||
default:
|
||||
chars += String.fromCharCode(b);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
BinaryInput.prototype.readFloat = function () {
|
||||
var value = this.buffer.getFloat32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readBoolean = function () {
|
||||
return this.readByte() != 0;
|
||||
};
|
||||
return BinaryInput;
|
||||
}());
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
var Vertices = (function () {
|
||||
function Vertices(bones, vertices) {
|
||||
if (bones === void 0) { bones = null; }
|
||||
if (vertices === void 0) { vertices = null; }
|
||||
this.bones = bones;
|
||||
this.vertices = vertices;
|
||||
}
|
||||
return Vertices;
|
||||
}());
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBounds = (function () {
|
||||
function SkeletonBounds() {
|
||||
@ -4528,9 +5353,9 @@ var spine;
|
||||
throw new Error("eventDataName cannot be null.");
|
||||
var events = this.events;
|
||||
for (var i = 0, n = events.length; i < n; i++) {
|
||||
var event_4 = events[i];
|
||||
if (event_4.name == eventDataName)
|
||||
return event_4;
|
||||
var event_5 = events[i];
|
||||
if (event_5.name == eventDataName)
|
||||
return event_5;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@ -4617,14 +5442,14 @@ var spine;
|
||||
if (root.bones) {
|
||||
for (var i = 0; i < root.bones.length; i++) {
|
||||
var boneMap = root.bones[i];
|
||||
var parent_2 = null;
|
||||
var parent_5 = null;
|
||||
var parentName = this.getValue(boneMap, "parent", null);
|
||||
if (parentName != null) {
|
||||
parent_2 = skeletonData.findBone(parentName);
|
||||
if (parent_2 == null)
|
||||
parent_5 = skeletonData.findBone(parentName);
|
||||
if (parent_5 == null)
|
||||
throw new Error("Parent bone not found: " + parentName);
|
||||
}
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2);
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5);
|
||||
data.length = this.getValue(boneMap, "length", 0) * scale;
|
||||
data.x = this.getValue(boneMap, "x", 0) * scale;
|
||||
data.y = this.getValue(boneMap, "y", 0) * scale;
|
||||
@ -4806,11 +5631,11 @@ var spine;
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_6 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_6);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
@ -4883,9 +5708,9 @@ var spine;
|
||||
mesh.color.setFromString(color);
|
||||
mesh.width = this.getValue(map, "width", 0) * scale;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
var parent_7 = this.getValue(map, "parent", null);
|
||||
if (parent_7 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5264,15 +6089,15 @@ var spine;
|
||||
var eventData = skeletonData.findEvent(eventMap.name);
|
||||
if (eventData == null)
|
||||
throw new Error("Event not found: " + eventMap.name);
|
||||
var event_5 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_5.data.audioPath != null) {
|
||||
event_5.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_5.balance = this.getValue(eventMap, "balance", 0);
|
||||
var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_6.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_6.data.audioPath != null) {
|
||||
event_6.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_6.balance = this.getValue(eventMap, "balance", 0);
|
||||
}
|
||||
timeline.setFrame(frameIndex++, event_5);
|
||||
timeline.setFrame(frameIndex++, event_6);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
|
||||
@ -5478,10 +6303,10 @@ var spine;
|
||||
for (var i = 0; i < this.attachments.length; i++) {
|
||||
var slotAttachments = this.attachments[i];
|
||||
if (slotAttachments) {
|
||||
for (var name_2 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_2];
|
||||
for (var name_4 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_4];
|
||||
if (attachment)
|
||||
entries.push(new SkinEntry(i, name_2, attachment));
|
||||
entries.push(new SkinEntry(i, name_4, attachment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5490,10 +6315,10 @@ var spine;
|
||||
Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) {
|
||||
var slotAttachments = this.attachments[slotIndex];
|
||||
if (slotAttachments) {
|
||||
for (var name_3 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_3];
|
||||
for (var name_5 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_5];
|
||||
if (attachment)
|
||||
attachments.push(new SkinEntry(slotIndex, name_3, attachment));
|
||||
attachments.push(new SkinEntry(slotIndex, name_5, attachment));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6394,6 +7219,17 @@ var spine;
|
||||
this.a = 1;
|
||||
return this;
|
||||
};
|
||||
Color.rgba8888ToColor = function (color, value) {
|
||||
color.r = ((value & 0xff000000) >>> 24) / 255;
|
||||
color.g = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.b = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.a = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.rgb888ToColor = function (color, value) {
|
||||
color.r = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.b = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.WHITE = new Color(1, 1, 1, 1);
|
||||
Color.RED = new Color(1, 0, 0, 1);
|
||||
Color.GREEN = new Color(0, 1, 0, 1);
|
||||
@ -6810,6 +7646,7 @@ var spine;
|
||||
AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
|
||||
AttachmentType[AttachmentType["Path"] = 4] = "Path";
|
||||
AttachmentType[AttachmentType["Point"] = 5] = "Point";
|
||||
AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping";
|
||||
})(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
|
||||
File diff suppressed because one or more lines are too long
42
spine-ts/build/spine-webgl.d.ts
vendored
42
spine-ts/build/spine-webgl.d.ts
vendored
@ -384,6 +384,7 @@ declare module spine {
|
||||
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
|
||||
private static downloadText(url, success, error);
|
||||
private static downloadBinary(url, success, error);
|
||||
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
|
||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
||||
@ -481,6 +482,7 @@ declare module spine {
|
||||
shearY: number;
|
||||
transformMode: TransformMode;
|
||||
skinRequired: boolean;
|
||||
color: Color;
|
||||
constructor(index: number, name: string, parent: BoneData);
|
||||
}
|
||||
enum TransformMode {
|
||||
@ -680,6 +682,42 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBinary {
|
||||
static AttachmentTypeValues: number[];
|
||||
static TransformModeValues: TransformMode[];
|
||||
static PositionModeValues: PositionMode[];
|
||||
static SpacingModeValues: SpacingMode[];
|
||||
static RotateModeValues: RotateMode[];
|
||||
static BlendModeValues: BlendMode[];
|
||||
static BONE_ROTATE: number;
|
||||
static BONE_TRANSLATE: number;
|
||||
static BONE_SCALE: number;
|
||||
static BONE_SHEAR: number;
|
||||
static SLOT_ATTACHMENT: number;
|
||||
static SLOT_COLOR: number;
|
||||
static SLOT_TWO_COLOR: number;
|
||||
static PATH_POSITION: number;
|
||||
static PATH_SPACING: number;
|
||||
static PATH_MIX: number;
|
||||
static CURVE_LINEAR: number;
|
||||
static CURVE_STEPPED: number;
|
||||
static CURVE_BEZIER: number;
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale: number;
|
||||
private linkedMeshes;
|
||||
constructor(attachmentLoader: AttachmentLoader);
|
||||
readSkeletonData(binary: Uint8Array): SkeletonData;
|
||||
private readSkin(input, skeletonData, defaultSkin, nonessential);
|
||||
private readAttachment(input, skeletonData, skin, slotIndex, attachmentName, nonessential);
|
||||
private readVertices(input, vertexCount);
|
||||
private readFloatArray(input, n, scale);
|
||||
private readShortArray(input);
|
||||
private readAnimation(input, name, skeletonData);
|
||||
private readCurve(input, frameIndex, timeline);
|
||||
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
class SkeletonBounds {
|
||||
minX: number;
|
||||
@ -742,6 +780,7 @@ declare module spine {
|
||||
hash: string;
|
||||
fps: number;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
findBone(boneName: string): BoneData;
|
||||
findBoneIndex(boneName: string): number;
|
||||
findSlot(slotName: string): SlotData;
|
||||
@ -997,6 +1036,8 @@ declare module spine {
|
||||
setFromString(hex: string): this;
|
||||
add(r: number, g: number, b: number, a: number): this;
|
||||
clamp(): this;
|
||||
static rgba8888ToColor(color: Color, value: number): void;
|
||||
static rgb888ToColor(color: Color, value: number): void;
|
||||
}
|
||||
class MathUtils {
|
||||
static PI: number;
|
||||
@ -1132,6 +1173,7 @@ declare module spine {
|
||||
LinkedMesh = 3,
|
||||
Path = 4,
|
||||
Point = 5,
|
||||
Clipping = 6,
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
|
||||
@ -2181,6 +2181,26 @@ var spine;
|
||||
};
|
||||
request.send();
|
||||
};
|
||||
AssetManager.prototype.loadBinary = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
if (error === void 0) { error = null; }
|
||||
path = this.pathPrefix + path;
|
||||
this.toLoad++;
|
||||
AssetManager.downloadBinary(path, function (data) {
|
||||
_this.assets[path] = data;
|
||||
if (success)
|
||||
success(path, data);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
}, function (state, responseText) {
|
||||
_this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
|
||||
if (error)
|
||||
error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
|
||||
_this.toLoad--;
|
||||
_this.loaded++;
|
||||
});
|
||||
};
|
||||
AssetManager.prototype.loadText = function (path, success, error) {
|
||||
var _this = this;
|
||||
if (success === void 0) { success = null; }
|
||||
@ -2691,6 +2711,7 @@ var spine;
|
||||
this.shearY = 0;
|
||||
this.transformMode = TransformMode.Normal;
|
||||
this.skinRequired = false;
|
||||
this.color = new spine.Color();
|
||||
if (index < 0)
|
||||
throw new Error("index must be >= 0.");
|
||||
if (name == null)
|
||||
@ -3999,6 +4020,810 @@ var spine;
|
||||
spine.Skeleton = Skeleton;
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBinary = (function () {
|
||||
function SkeletonBinary(attachmentLoader) {
|
||||
this.scale = 1;
|
||||
this.linkedMeshes = new Array();
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
}
|
||||
SkeletonBinary.prototype.readSkeletonData = function (binary) {
|
||||
var scale = this.scale;
|
||||
var skeletonData = new spine.SkeletonData();
|
||||
skeletonData.name = "";
|
||||
var input = new BinaryInput(binary);
|
||||
skeletonData.hash = input.readString();
|
||||
skeletonData.version = input.readString();
|
||||
skeletonData.x = input.readFloat();
|
||||
skeletonData.y = input.readFloat();
|
||||
skeletonData.width = input.readFloat();
|
||||
skeletonData.height = input.readFloat();
|
||||
var nonessential = input.readBoolean();
|
||||
if (nonessential) {
|
||||
skeletonData.fps = input.readFloat();
|
||||
skeletonData.imagesPath = input.readString();
|
||||
skeletonData.audioPath = input.readString();
|
||||
}
|
||||
var n = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
input.strings.push(input.readString());
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var name_2 = input.readString();
|
||||
var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.BoneData(i, name_2, parent_2);
|
||||
data.rotation = input.readFloat();
|
||||
data.x = input.readFloat() * scale;
|
||||
data.y = input.readFloat() * scale;
|
||||
data.scaleX = input.readFloat();
|
||||
data.scaleY = input.readFloat();
|
||||
data.shearX = input.readFloat();
|
||||
data.shearY = input.readFloat();
|
||||
data.length = input.readFloat() * scale;
|
||||
data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
|
||||
data.skinRequired = input.readBoolean();
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
skeletonData.bones.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var slotName = input.readString();
|
||||
var boneData = skeletonData.bones[input.readInt(true)];
|
||||
var data = new spine.SlotData(i, slotName, boneData);
|
||||
spine.Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
var darkColor = input.readInt32();
|
||||
if (darkColor != -1)
|
||||
spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor);
|
||||
data.attachmentName = input.readStringRef();
|
||||
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.IkConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.mix = input.readFloat();
|
||||
data.bendDirection = input.readByte();
|
||||
data.compress = input.readBoolean();
|
||||
data.stretch = input.readBoolean();
|
||||
data.uniform = input.readBoolean();
|
||||
skeletonData.ikConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.TransformConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.local = input.readBoolean();
|
||||
data.relative = input.readBoolean();
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.offsetX = input.readFloat() * scale;
|
||||
data.offsetY = input.readFloat() * scale;
|
||||
data.offsetScaleX = input.readFloat();
|
||||
data.offsetScaleY = input.readFloat();
|
||||
data.offsetShearY = input.readFloat();
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
data.scaleMix = input.readFloat();
|
||||
data.shearMix = input.readFloat();
|
||||
skeletonData.transformConstraints.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0, nn = void 0; i < n; i++) {
|
||||
var data = new spine.PathConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (var ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.slots[input.readInt(true)];
|
||||
data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
|
||||
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
|
||||
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.position = input.readFloat();
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
data.position *= scale;
|
||||
data.spacing = input.readFloat();
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
data.spacing *= scale;
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
skeletonData.pathConstraints.push(data);
|
||||
}
|
||||
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
|
||||
if (defaultSkin != null) {
|
||||
skeletonData.defaultSkin = defaultSkin;
|
||||
skeletonData.skins.push(defaultSkin);
|
||||
}
|
||||
{
|
||||
var i = skeletonData.skins.length;
|
||||
spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
|
||||
for (; i < n; i++)
|
||||
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
|
||||
}
|
||||
n = this.linkedMeshes.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var linkedMesh = this.linkedMeshes[i];
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var data = new spine.EventData(input.readStringRef());
|
||||
data.intValue = input.readInt(false);
|
||||
data.floatValue = input.readFloat();
|
||||
data.stringValue = input.readString();
|
||||
data.audioPath = input.readString();
|
||||
if (data.audioPath != null) {
|
||||
data.volume = input.readFloat();
|
||||
data.balance = input.readFloat();
|
||||
}
|
||||
skeletonData.events.push(data);
|
||||
}
|
||||
n = input.readInt(true);
|
||||
for (var i = 0; i < n; i++)
|
||||
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
|
||||
return skeletonData;
|
||||
};
|
||||
SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) {
|
||||
var skin = new spine.Skin(defaultSkin ? "default" : input.readStringRef());
|
||||
if (!defaultSkin) {
|
||||
skin.bones.length = input.readInt(true);
|
||||
for (var i = 0, n = skin.bones.length; i < n; i++)
|
||||
skin.bones[i] = skeletonData.bones[input.readInt(true)];
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var name_3 = input.readStringRef();
|
||||
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential);
|
||||
if (attachment != null)
|
||||
skin.setAttachment(slotIndex, name_3, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
};
|
||||
SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
|
||||
var scale = this.scale;
|
||||
var name = input.readStringRef();
|
||||
if (name == null)
|
||||
name = attachmentName;
|
||||
var typeIndex = input.readByte();
|
||||
var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
|
||||
switch (type) {
|
||||
case spine.AttachmentType.Region: {
|
||||
var path = input.readStringRef();
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var scaleX = input.readFloat();
|
||||
var scaleY = input.readFloat();
|
||||
var width = input.readFloat();
|
||||
var height = input.readFloat();
|
||||
var color = input.readInt32();
|
||||
if (path == null)
|
||||
path = name;
|
||||
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
|
||||
if (region == null)
|
||||
return null;
|
||||
region.path = path;
|
||||
region.x = x * scale;
|
||||
region.y = y * scale;
|
||||
region.scaleX = scaleX;
|
||||
region.scaleY = scaleY;
|
||||
region.rotation = rotation;
|
||||
region.width = width * scale;
|
||||
region.height = height * scale;
|
||||
spine.Color.rgba8888ToColor(region.color, color);
|
||||
region.updateOffset();
|
||||
return region;
|
||||
}
|
||||
case spine.AttachmentType.BoundingBox: {
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
|
||||
if (box == null)
|
||||
return null;
|
||||
box.worldVerticesLength = vertexCount << 1;
|
||||
box.vertices = vertices.vertices;
|
||||
box.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(box.color, color);
|
||||
return box;
|
||||
}
|
||||
case spine.AttachmentType.Mesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var vertexCount = input.readInt(true);
|
||||
var uvs = this.readFloatArray(input, vertexCount << 1, 1);
|
||||
var triangles = this.readShortArray(input);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var hullLength = input.readInt(true);
|
||||
var edges = null;
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
edges = this.readShortArray(input);
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
mesh.bones = vertices.bones;
|
||||
mesh.vertices = vertices.vertices;
|
||||
mesh.worldVerticesLength = vertexCount << 1;
|
||||
mesh.triangles = triangles;
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.updateUVs();
|
||||
mesh.hullLength = hullLength << 1;
|
||||
if (nonessential) {
|
||||
mesh.edges = edges;
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.LinkedMesh: {
|
||||
var path = input.readStringRef();
|
||||
var color = input.readInt32();
|
||||
var skinName = input.readStringRef();
|
||||
var parent_4 = input.readStringRef();
|
||||
var inheritDeform = input.readBoolean();
|
||||
var width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
if (path == null)
|
||||
path = name;
|
||||
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
mesh.path = path;
|
||||
spine.Color.rgba8888ToColor(mesh.color, color);
|
||||
if (nonessential) {
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
|
||||
return mesh;
|
||||
}
|
||||
case spine.AttachmentType.Path: {
|
||||
var closed_1 = input.readBoolean();
|
||||
var constantSpeed = input.readBoolean();
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var lengths = spine.Utils.newArray(vertexCount / 3, 0);
|
||||
for (var i = 0, n = lengths.length; i < n; i++)
|
||||
lengths[i] = input.readFloat() * scale;
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var path = this.attachmentLoader.newPathAttachment(skin, name);
|
||||
if (path == null)
|
||||
return null;
|
||||
path.closed = closed_1;
|
||||
path.constantSpeed = constantSpeed;
|
||||
path.worldVerticesLength = vertexCount << 1;
|
||||
path.vertices = vertices.vertices;
|
||||
path.bones = vertices.bones;
|
||||
path.lengths = lengths;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(path.color, color);
|
||||
return path;
|
||||
}
|
||||
case spine.AttachmentType.Point: {
|
||||
var rotation = input.readFloat();
|
||||
var x = input.readFloat();
|
||||
var y = input.readFloat();
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var point = this.attachmentLoader.newPointAttachment(skin, name);
|
||||
if (point == null)
|
||||
return null;
|
||||
point.x = x * scale;
|
||||
point.y = y * scale;
|
||||
point.rotation = rotation;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(point.color, color);
|
||||
return point;
|
||||
}
|
||||
case spine.AttachmentType.Clipping: {
|
||||
var endSlotIndex = input.readInt(true);
|
||||
var vertexCount = input.readInt(true);
|
||||
var vertices = this.readVertices(input, vertexCount);
|
||||
var color = nonessential ? input.readInt32() : 0;
|
||||
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null)
|
||||
return null;
|
||||
clip.endSlot = skeletonData.slots[endSlotIndex];
|
||||
clip.worldVerticesLength = vertexCount << 1;
|
||||
clip.vertices = vertices.vertices;
|
||||
clip.bones = vertices.bones;
|
||||
if (nonessential)
|
||||
spine.Color.rgba8888ToColor(clip.color, color);
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
SkeletonBinary.prototype.readVertices = function (input, vertexCount) {
|
||||
var verticesLength = vertexCount << 1;
|
||||
var vertices = new Vertices();
|
||||
var scale = this.scale;
|
||||
if (!input.readBoolean()) {
|
||||
vertices.vertices = this.readFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
var weights = new Array();
|
||||
var bonesArray = new Array();
|
||||
for (var i = 0; i < vertexCount; i++) {
|
||||
var boneCount = input.readInt(true);
|
||||
bonesArray.push(boneCount);
|
||||
for (var ii = 0; ii < boneCount; ii++) {
|
||||
bonesArray.push(input.readInt(true));
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat());
|
||||
}
|
||||
}
|
||||
vertices.vertices = spine.Utils.toFloatArray(weights);
|
||||
vertices.bones = bonesArray;
|
||||
return vertices;
|
||||
};
|
||||
SkeletonBinary.prototype.readFloatArray = function (input, n, scale) {
|
||||
var array = new Array(n);
|
||||
if (scale == 1) {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readFloat() * scale;
|
||||
}
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readShortArray = function (input) {
|
||||
var n = input.readInt(true);
|
||||
var array = new Array(n);
|
||||
for (var i = 0; i < n; i++)
|
||||
array[i] = input.readShort();
|
||||
return array;
|
||||
};
|
||||
SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) {
|
||||
var timelines = new Array();
|
||||
var scale = this.scale;
|
||||
var duration = 0;
|
||||
var tempColor1 = new spine.Color();
|
||||
var tempColor2 = new spine.Color();
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.SLOT_ATTACHMENT: {
|
||||
var timeline = new spine.AttachmentTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_COLOR: {
|
||||
var timeline = new spine.ColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_TWO_COLOR: {
|
||||
var timeline = new spine.TwoColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
spine.Color.rgb888ToColor(tempColor2, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var boneIndex = input.readInt(true);
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.BONE_ROTATE: {
|
||||
var timeline = new spine.RotateTimeline(frameCount);
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.BONE_TRANSLATE:
|
||||
case SkeletonBinary.BONE_SCALE:
|
||||
case SkeletonBinary.BONE_SHEAR: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.BONE_SCALE)
|
||||
timeline = new spine.ScaleTimeline(frameCount);
|
||||
else if (timelineType == SkeletonBinary.BONE_SHEAR)
|
||||
timeline = new spine.ShearTimeline(frameCount);
|
||||
else {
|
||||
timeline = new spine.TranslateTimeline(frameCount);
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.IkConstraintTimeline(frameCount);
|
||||
timeline.ikConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readByte(), input.readBoolean(), input.readBoolean());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.TransformConstraintTimeline(frameCount);
|
||||
timeline.transformConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var index = input.readInt(true);
|
||||
var data = skeletonData.pathConstraints[index];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var timelineType = input.readByte();
|
||||
var frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.PATH_POSITION:
|
||||
case SkeletonBinary.PATH_SPACING: {
|
||||
var timeline = void 0;
|
||||
var timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.PATH_SPACING) {
|
||||
timeline = new spine.PathConstraintSpacingTimeline(frameCount);
|
||||
if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
else {
|
||||
timeline = new spine.PathConstraintPositionTimeline(frameCount);
|
||||
if (data.positionMode == spine.PositionMode.Fixed)
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.PATH_MIX: {
|
||||
var timeline = new spine.PathConstraintMixTimeline(frameCount);
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, n = input.readInt(true); i < n; i++) {
|
||||
var skin = skeletonData.skins[input.readInt(true)];
|
||||
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
|
||||
var attachment = skin.getAttachment(slotIndex, input.readStringRef());
|
||||
var weighted = attachment.bones != null;
|
||||
var vertices = attachment.vertices;
|
||||
var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
|
||||
var frameCount = input.readInt(true);
|
||||
var timeline = new spine.DeformTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
timeline.attachment = attachment;
|
||||
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
var time = input.readFloat();
|
||||
var deform = void 0;
|
||||
var end = input.readInt(true);
|
||||
if (end == 0)
|
||||
deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
|
||||
else {
|
||||
deform = spine.Utils.newFloatArray(deformLength);
|
||||
var start = input.readInt(true);
|
||||
end += start;
|
||||
if (scale == 1) {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat();
|
||||
}
|
||||
else {
|
||||
for (var v = start; v < end; v++)
|
||||
deform[v] = input.readFloat() * scale;
|
||||
}
|
||||
if (!weighted) {
|
||||
for (var v = 0, vn = deform.length; v < vn; v++)
|
||||
deform[v] += vertices[v];
|
||||
}
|
||||
}
|
||||
timeline.setFrame(frameIndex, time, deform);
|
||||
if (frameIndex < frameCount - 1)
|
||||
this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
var drawOrderCount = input.readInt(true);
|
||||
if (drawOrderCount > 0) {
|
||||
var timeline = new spine.DrawOrderTimeline(drawOrderCount);
|
||||
var slotCount = skeletonData.slots.length;
|
||||
for (var i = 0; i < drawOrderCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var offsetCount = input.readInt(true);
|
||||
var drawOrder = spine.Utils.newArray(slotCount, 0);
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
drawOrder[ii] = -1;
|
||||
var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0);
|
||||
var originalIndex = 0, unchangedIndex = 0;
|
||||
for (var ii = 0; ii < offsetCount; ii++) {
|
||||
var slotIndex = input.readInt(true);
|
||||
while (originalIndex != slotIndex)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
|
||||
}
|
||||
while (originalIndex < slotCount)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
for (var ii = slotCount - 1; ii >= 0; ii--)
|
||||
if (drawOrder[ii] == -1)
|
||||
drawOrder[ii] = unchanged[--unchangedIndex];
|
||||
timeline.setFrame(i, time, drawOrder);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
|
||||
}
|
||||
var eventCount = input.readInt(true);
|
||||
if (eventCount > 0) {
|
||||
var timeline = new spine.EventTimeline(eventCount);
|
||||
for (var i = 0; i < eventCount; i++) {
|
||||
var time = input.readFloat();
|
||||
var eventData = skeletonData.events[input.readInt(true)];
|
||||
var event_4 = new spine.Event(time, eventData);
|
||||
event_4.intValue = input.readInt(false);
|
||||
event_4.floatValue = input.readFloat();
|
||||
event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
|
||||
if (event_4.data.audioPath != null) {
|
||||
event_4.volume = input.readFloat();
|
||||
event_4.balance = input.readFloat();
|
||||
}
|
||||
timeline.setFrame(i, event_4);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[eventCount - 1]);
|
||||
}
|
||||
return new spine.Animation(name, timelines, duration);
|
||||
};
|
||||
SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) {
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frameIndex);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
break;
|
||||
}
|
||||
};
|
||||
SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
|
||||
timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
|
||||
};
|
||||
SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6];
|
||||
SkeletonBinary.TransformModeValues = [spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection];
|
||||
SkeletonBinary.PositionModeValues = [spine.PositionMode.Fixed, spine.PositionMode.Percent];
|
||||
SkeletonBinary.SpacingModeValues = [spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent];
|
||||
SkeletonBinary.RotateModeValues = [spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale];
|
||||
SkeletonBinary.BlendModeValues = [spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen];
|
||||
SkeletonBinary.BONE_ROTATE = 0;
|
||||
SkeletonBinary.BONE_TRANSLATE = 1;
|
||||
SkeletonBinary.BONE_SCALE = 2;
|
||||
SkeletonBinary.BONE_SHEAR = 3;
|
||||
SkeletonBinary.SLOT_ATTACHMENT = 0;
|
||||
SkeletonBinary.SLOT_COLOR = 1;
|
||||
SkeletonBinary.SLOT_TWO_COLOR = 2;
|
||||
SkeletonBinary.PATH_POSITION = 0;
|
||||
SkeletonBinary.PATH_SPACING = 1;
|
||||
SkeletonBinary.PATH_MIX = 2;
|
||||
SkeletonBinary.CURVE_LINEAR = 0;
|
||||
SkeletonBinary.CURVE_STEPPED = 1;
|
||||
SkeletonBinary.CURVE_BEZIER = 2;
|
||||
return SkeletonBinary;
|
||||
}());
|
||||
spine.SkeletonBinary = SkeletonBinary;
|
||||
var BinaryInput = (function () {
|
||||
function BinaryInput(data, strings, index, buffer) {
|
||||
if (strings === void 0) { strings = new Array(); }
|
||||
if (index === void 0) { index = 0; }
|
||||
if (buffer === void 0) { buffer = new DataView(data.buffer); }
|
||||
this.strings = strings;
|
||||
this.index = index;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
BinaryInput.prototype.readByte = function () {
|
||||
return this.buffer.getInt8(this.index++);
|
||||
};
|
||||
BinaryInput.prototype.readShort = function () {
|
||||
var value = this.buffer.getInt16(this.index);
|
||||
this.index += 2;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt32 = function () {
|
||||
var value = this.buffer.getInt32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readInt = function (optimizePositive) {
|
||||
var b = this.readByte();
|
||||
var result = b & 0x7F;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 7;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 14;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 21;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
|
||||
};
|
||||
BinaryInput.prototype.readStringRef = function () {
|
||||
var index = this.readInt(true);
|
||||
return index == 0 ? null : this.strings[index - 1];
|
||||
};
|
||||
BinaryInput.prototype.readString = function () {
|
||||
var byteCount = this.readInt(true);
|
||||
switch (byteCount) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return "";
|
||||
}
|
||||
byteCount--;
|
||||
var chars = "";
|
||||
var charCount = 0;
|
||||
for (var i = 0; i < byteCount;) {
|
||||
var b = this.readByte();
|
||||
switch (b >> 4) {
|
||||
case 12:
|
||||
case 13:
|
||||
chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
|
||||
i += 2;
|
||||
break;
|
||||
case 14:
|
||||
chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
|
||||
i += 3;
|
||||
break;
|
||||
default:
|
||||
chars += String.fromCharCode(b);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
BinaryInput.prototype.readFloat = function () {
|
||||
var value = this.buffer.getFloat32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
};
|
||||
BinaryInput.prototype.readBoolean = function () {
|
||||
return this.readByte() != 0;
|
||||
};
|
||||
return BinaryInput;
|
||||
}());
|
||||
var LinkedMesh = (function () {
|
||||
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
return LinkedMesh;
|
||||
}());
|
||||
var Vertices = (function () {
|
||||
function Vertices(bones, vertices) {
|
||||
if (bones === void 0) { bones = null; }
|
||||
if (vertices === void 0) { vertices = null; }
|
||||
this.bones = bones;
|
||||
this.vertices = vertices;
|
||||
}
|
||||
return Vertices;
|
||||
}());
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
(function (spine) {
|
||||
var SkeletonBounds = (function () {
|
||||
function SkeletonBounds() {
|
||||
@ -4528,9 +5353,9 @@ var spine;
|
||||
throw new Error("eventDataName cannot be null.");
|
||||
var events = this.events;
|
||||
for (var i = 0, n = events.length; i < n; i++) {
|
||||
var event_4 = events[i];
|
||||
if (event_4.name == eventDataName)
|
||||
return event_4;
|
||||
var event_5 = events[i];
|
||||
if (event_5.name == eventDataName)
|
||||
return event_5;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@ -4617,14 +5442,14 @@ var spine;
|
||||
if (root.bones) {
|
||||
for (var i = 0; i < root.bones.length; i++) {
|
||||
var boneMap = root.bones[i];
|
||||
var parent_2 = null;
|
||||
var parent_5 = null;
|
||||
var parentName = this.getValue(boneMap, "parent", null);
|
||||
if (parentName != null) {
|
||||
parent_2 = skeletonData.findBone(parentName);
|
||||
if (parent_2 == null)
|
||||
parent_5 = skeletonData.findBone(parentName);
|
||||
if (parent_5 == null)
|
||||
throw new Error("Parent bone not found: " + parentName);
|
||||
}
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2);
|
||||
var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5);
|
||||
data.length = this.getValue(boneMap, "length", 0) * scale;
|
||||
data.x = this.getValue(boneMap, "x", 0) * scale;
|
||||
data.y = this.getValue(boneMap, "y", 0) * scale;
|
||||
@ -4806,11 +5631,11 @@ var spine;
|
||||
var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null)
|
||||
throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_3 == null)
|
||||
var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent_6 == null)
|
||||
throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_3);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent_6);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
@ -4883,9 +5708,9 @@ var spine;
|
||||
mesh.color.setFromString(color);
|
||||
mesh.width = this.getValue(map, "width", 0) * scale;
|
||||
mesh.height = this.getValue(map, "height", 0) * scale;
|
||||
var parent_4 = this.getValue(map, "parent", null);
|
||||
if (parent_4 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4, this.getValue(map, "deform", true)));
|
||||
var parent_7 = this.getValue(map, "parent", null);
|
||||
if (parent_7 != null) {
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
var uvs = map.uvs;
|
||||
@ -5264,15 +6089,15 @@ var spine;
|
||||
var eventData = skeletonData.findEvent(eventMap.name);
|
||||
if (eventData == null)
|
||||
throw new Error("Event not found: " + eventMap.name);
|
||||
var event_5 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_5.data.audioPath != null) {
|
||||
event_5.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_5.balance = this.getValue(eventMap, "balance", 0);
|
||||
var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
|
||||
event_6.intValue = this.getValue(eventMap, "int", eventData.intValue);
|
||||
event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
|
||||
event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
|
||||
if (event_6.data.audioPath != null) {
|
||||
event_6.volume = this.getValue(eventMap, "volume", 1);
|
||||
event_6.balance = this.getValue(eventMap, "balance", 0);
|
||||
}
|
||||
timeline.setFrame(frameIndex++, event_5);
|
||||
timeline.setFrame(frameIndex++, event_6);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
|
||||
@ -5478,10 +6303,10 @@ var spine;
|
||||
for (var i = 0; i < this.attachments.length; i++) {
|
||||
var slotAttachments = this.attachments[i];
|
||||
if (slotAttachments) {
|
||||
for (var name_2 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_2];
|
||||
for (var name_4 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_4];
|
||||
if (attachment)
|
||||
entries.push(new SkinEntry(i, name_2, attachment));
|
||||
entries.push(new SkinEntry(i, name_4, attachment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5490,10 +6315,10 @@ var spine;
|
||||
Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) {
|
||||
var slotAttachments = this.attachments[slotIndex];
|
||||
if (slotAttachments) {
|
||||
for (var name_3 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_3];
|
||||
for (var name_5 in slotAttachments) {
|
||||
var attachment = slotAttachments[name_5];
|
||||
if (attachment)
|
||||
attachments.push(new SkinEntry(slotIndex, name_3, attachment));
|
||||
attachments.push(new SkinEntry(slotIndex, name_5, attachment));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -6394,6 +7219,17 @@ var spine;
|
||||
this.a = 1;
|
||||
return this;
|
||||
};
|
||||
Color.rgba8888ToColor = function (color, value) {
|
||||
color.r = ((value & 0xff000000) >>> 24) / 255;
|
||||
color.g = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.b = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.a = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.rgb888ToColor = function (color, value) {
|
||||
color.r = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.b = ((value & 0x000000ff)) / 255;
|
||||
};
|
||||
Color.WHITE = new Color(1, 1, 1, 1);
|
||||
Color.RED = new Color(1, 0, 0, 1);
|
||||
Color.GREEN = new Color(0, 1, 0, 1);
|
||||
@ -6810,6 +7646,7 @@ var spine;
|
||||
AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
|
||||
AttachmentType[AttachmentType["Path"] = 4] = "Path";
|
||||
AttachmentType[AttachmentType["Point"] = 5] = "Point";
|
||||
AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping";
|
||||
})(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
|
||||
})(spine || (spine = {}));
|
||||
var spine;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -74,6 +74,25 @@ module spine {
|
||||
request.send();
|
||||
}
|
||||
|
||||
loadBinary(path: string,
|
||||
success: (path: string, binary: Uint8Array) => void = null,
|
||||
error: (path: string, error: string) => void = null) {
|
||||
path = this.pathPrefix + path;
|
||||
this.toLoad++;
|
||||
|
||||
AssetManager.downloadBinary(path, (data: Uint8Array): void => {
|
||||
this.assets[path] = data;
|
||||
if (success) success(path, data);
|
||||
this.toLoad--;
|
||||
this.loaded++;
|
||||
}, (state: number, responseText: string): void => {
|
||||
this.errors[path] = `Couldn't load binary ${path}: status ${status}, ${responseText}`;
|
||||
if (error) error(path, `Couldn't load binary ${path}: status ${status}, ${responseText}`);
|
||||
this.toLoad--;
|
||||
this.loaded++;
|
||||
});
|
||||
}
|
||||
|
||||
loadText(path: string,
|
||||
success: (path: string, text: string) => void = null,
|
||||
error: (path: string, error: string) => void = null) {
|
||||
|
||||
@ -37,6 +37,8 @@ module spine {
|
||||
transformMode = TransformMode.Normal;
|
||||
skinRequired = false;
|
||||
|
||||
color = new Color();
|
||||
|
||||
constructor (index: number, name: string, parent: BoneData) {
|
||||
if (index < 0) throw new Error("index must be >= 0.");
|
||||
if (name == null) throw new Error("name cannot be null.");
|
||||
|
||||
881
spine-ts/core/src/SkeletonBinary.ts
Normal file
881
spine-ts/core/src/SkeletonBinary.ts
Normal file
@ -0,0 +1,881 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated May 1, 2019. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2019, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
|
||||
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
module spine {
|
||||
export class SkeletonBinary {
|
||||
static AttachmentTypeValues = [ 0 /*AttachmentType.Region*/, 1/*AttachmentType.BoundingBox*/, 2/*AttachmentType.Mesh*/, 3/*AttachmentType.LinkedMesh*/, 4/*AttachmentType.Path*/, 5/*AttachmentType.Point*/, 6/*AttachmentType.Clipping*/ ];
|
||||
static TransformModeValues = [TransformMode.Normal, TransformMode.OnlyTranslation, TransformMode.NoRotationOrReflection, TransformMode.NoScale, TransformMode.NoScaleOrReflection];
|
||||
static PositionModeValues = [ PositionMode.Fixed, PositionMode.Percent ];
|
||||
static SpacingModeValues = [ SpacingMode.Length, SpacingMode.Fixed, SpacingMode.Percent];
|
||||
static RotateModeValues = [ RotateMode.Tangent, RotateMode.Chain, RotateMode.ChainScale ];
|
||||
static BlendModeValues = [ BlendMode.Normal, BlendMode.Additive, BlendMode.Multiply, BlendMode.Screen];
|
||||
|
||||
static BONE_ROTATE = 0;
|
||||
static BONE_TRANSLATE = 1;
|
||||
static BONE_SCALE = 2;
|
||||
static BONE_SHEAR = 3;
|
||||
|
||||
static SLOT_ATTACHMENT = 0;
|
||||
static SLOT_COLOR = 1;
|
||||
static SLOT_TWO_COLOR = 2;
|
||||
|
||||
static PATH_POSITION = 0;
|
||||
static PATH_SPACING = 1;
|
||||
static PATH_MIX = 2;
|
||||
|
||||
static CURVE_LINEAR = 0;
|
||||
static CURVE_STEPPED = 1;
|
||||
static CURVE_BEZIER = 2;
|
||||
|
||||
attachmentLoader: AttachmentLoader;
|
||||
scale = 1;
|
||||
private linkedMeshes = new Array<LinkedMesh>();
|
||||
|
||||
constructor (attachmentLoader: AttachmentLoader) {
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
}
|
||||
|
||||
readSkeletonData (binary: Uint8Array): SkeletonData {
|
||||
let scale = this.scale;
|
||||
|
||||
let skeletonData = new SkeletonData();
|
||||
skeletonData.name = ""; // BOZO
|
||||
|
||||
let input = new BinaryInput(binary);
|
||||
|
||||
skeletonData.hash = input.readString();
|
||||
skeletonData.version = input.readString();
|
||||
skeletonData.x = input.readFloat();
|
||||
skeletonData.y = input.readFloat();
|
||||
skeletonData.width = input.readFloat();
|
||||
skeletonData.height = input.readFloat();
|
||||
|
||||
let nonessential = input.readBoolean();
|
||||
if (nonessential) {
|
||||
skeletonData.fps = input.readFloat();
|
||||
|
||||
skeletonData.imagesPath = input.readString();
|
||||
skeletonData.audioPath = input.readString();
|
||||
}
|
||||
|
||||
let n = 0;
|
||||
// Strings.
|
||||
n = input.readInt(true)
|
||||
for (let i = 0; i < n; i++)
|
||||
input.strings.push(input.readString());
|
||||
|
||||
// Bones.
|
||||
n = input.readInt(true)
|
||||
for (let i = 0; i < n; i++) {
|
||||
let name = input.readString();
|
||||
let parent = i == 0 ? null : skeletonData.bones[input.readInt(true)];
|
||||
let data = new BoneData(i, name, parent);
|
||||
data.rotation = input.readFloat();
|
||||
data.x = input.readFloat() * scale;
|
||||
data.y = input.readFloat() * scale;
|
||||
data.scaleX = input.readFloat();
|
||||
data.scaleY = input.readFloat();
|
||||
data.shearX = input.readFloat();
|
||||
data.shearY = input.readFloat();
|
||||
data.length = input.readFloat() * scale;
|
||||
data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
|
||||
data.skinRequired = input.readBoolean();
|
||||
if (nonessential) Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
skeletonData.bones.push(data);
|
||||
}
|
||||
|
||||
// Slots.
|
||||
n = input.readInt(true);
|
||||
for (let i = 0; i < n; i++) {
|
||||
let slotName = input.readString();
|
||||
let boneData = skeletonData.bones[input.readInt(true)];
|
||||
let data = new SlotData(i, slotName, boneData);
|
||||
Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
|
||||
let darkColor = input.readInt32();
|
||||
if (darkColor != -1) Color.rgb888ToColor(data.darkColor = new Color(), darkColor);
|
||||
|
||||
data.attachmentName = input.readStringRef();
|
||||
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
|
||||
// IK constraints.
|
||||
n = input.readInt(true);
|
||||
for (let i = 0, nn; i < n; i++) {
|
||||
let data = new IkConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (let ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.mix = input.readFloat();
|
||||
data.bendDirection = input.readByte();
|
||||
data.compress = input.readBoolean();
|
||||
data.stretch = input.readBoolean();
|
||||
data.uniform = input.readBoolean();
|
||||
skeletonData.ikConstraints.push(data);
|
||||
}
|
||||
|
||||
// Transform constraints.
|
||||
n = input.readInt(true);
|
||||
for (let i = 0, nn; i < n; i++) {
|
||||
let data = new TransformConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (let ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.bones[input.readInt(true)];
|
||||
data.local = input.readBoolean();
|
||||
data.relative = input.readBoolean();
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.offsetX = input.readFloat() * scale;
|
||||
data.offsetY = input.readFloat() * scale;
|
||||
data.offsetScaleX = input.readFloat();
|
||||
data.offsetScaleY = input.readFloat();
|
||||
data.offsetShearY = input.readFloat();
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
data.scaleMix = input.readFloat();
|
||||
data.shearMix = input.readFloat();
|
||||
skeletonData.transformConstraints.push(data);
|
||||
}
|
||||
|
||||
// Path constraints.
|
||||
n = input.readInt(true);
|
||||
for (let i = 0, nn; i < n; i++) {
|
||||
let data = new PathConstraintData(input.readString());
|
||||
data.order = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
nn = input.readInt(true);
|
||||
for (let ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.slots[input.readInt(true)];
|
||||
data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
|
||||
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
|
||||
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.position = input.readFloat();
|
||||
if (data.positionMode == PositionMode.Fixed) data.position *= scale;
|
||||
data.spacing = input.readFloat();
|
||||
if (data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed) data.spacing *= scale;
|
||||
data.rotateMix = input.readFloat();
|
||||
data.translateMix = input.readFloat();
|
||||
skeletonData.pathConstraints.push(data);
|
||||
}
|
||||
|
||||
// Default skin.
|
||||
let defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
|
||||
if (defaultSkin != null) {
|
||||
skeletonData.defaultSkin = defaultSkin;
|
||||
skeletonData.skins.push(defaultSkin);
|
||||
}
|
||||
|
||||
// Skins.
|
||||
{
|
||||
let i = skeletonData.skins.length;
|
||||
Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
|
||||
for (; i < n; i++)
|
||||
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
|
||||
}
|
||||
|
||||
// Linked meshes.
|
||||
n = this.linkedMeshes.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
let linkedMesh = this.linkedMeshes[i];
|
||||
let skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
|
||||
if (skin == null) throw new Error("Skin not found: " + linkedMesh.skin);
|
||||
let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent == null) throw new Error("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent as VertexAttachment : linkedMesh.mesh;
|
||||
linkedMesh.mesh.setParentMesh(parent as MeshAttachment);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
this.linkedMeshes.length = 0;
|
||||
|
||||
// Events.
|
||||
n = input.readInt(true);
|
||||
for (let i = 0; i < n; i++) {
|
||||
let data = new EventData(input.readStringRef());
|
||||
data.intValue = input.readInt(false);
|
||||
data.floatValue = input.readFloat();
|
||||
data.stringValue = input.readString();
|
||||
data.audioPath = input.readString();
|
||||
if (data.audioPath != null) {
|
||||
data.volume = input.readFloat();
|
||||
data.balance = input.readFloat();
|
||||
}
|
||||
skeletonData.events.push(data);
|
||||
}
|
||||
|
||||
// Animations.
|
||||
n = input.readInt(true);
|
||||
for (let i = 0; i < n; i++)
|
||||
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
|
||||
return skeletonData;
|
||||
}
|
||||
|
||||
private readSkin (input: BinaryInput, skeletonData: SkeletonData, defaultSkin: boolean, nonessential: boolean): Skin {
|
||||
let skin = new Skin(defaultSkin ? "default" : input.readStringRef());
|
||||
|
||||
if (!defaultSkin) {
|
||||
skin.bones.length = input.readInt(true);
|
||||
for (let i = 0, n = skin.bones.length; i < n; i++)
|
||||
skin.bones[i] = skeletonData.bones[input.readInt(true)];
|
||||
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++)
|
||||
skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
|
||||
}
|
||||
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let slotIndex = input.readInt(true);
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
let name = input.readStringRef();
|
||||
let attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name, nonessential);
|
||||
if (attachment != null) skin.setAttachment(slotIndex, name, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
}
|
||||
|
||||
private readAttachment(input: BinaryInput, skeletonData: SkeletonData, skin: Skin, slotIndex: number, attachmentName: string, nonessential: boolean): Attachment {
|
||||
let scale = this.scale;
|
||||
|
||||
let name = input.readStringRef();
|
||||
if (name == null) name = attachmentName;
|
||||
|
||||
let typeIndex = input.readByte();
|
||||
let type = SkeletonBinary.AttachmentTypeValues[typeIndex];
|
||||
switch (type) {
|
||||
case AttachmentType.Region: {
|
||||
let path = input.readStringRef();
|
||||
let rotation = input.readFloat();
|
||||
let x = input.readFloat();
|
||||
let y = input.readFloat();
|
||||
let scaleX = input.readFloat();
|
||||
let scaleY = input.readFloat();
|
||||
let width = input.readFloat();
|
||||
let height = input.readFloat();
|
||||
let color = input.readInt32();
|
||||
|
||||
if (path == null) path = name;
|
||||
let region = this.attachmentLoader.newRegionAttachment(skin, name, path);
|
||||
if (region == null) return null;
|
||||
region.path = path;
|
||||
region.x = x * scale;
|
||||
region.y = y * scale;
|
||||
region.scaleX = scaleX;
|
||||
region.scaleY = scaleY;
|
||||
region.rotation = rotation;
|
||||
region.width = width * scale;
|
||||
region.height = height * scale;
|
||||
Color.rgba8888ToColor(region.color, color);
|
||||
region.updateOffset();
|
||||
return region;
|
||||
}
|
||||
case AttachmentType.BoundingBox: {
|
||||
let vertexCount = input.readInt(true);
|
||||
let vertices = this.readVertices(input, vertexCount);
|
||||
let color = nonessential ? input.readInt32() : 0;
|
||||
|
||||
let box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
|
||||
if (box == null) return null;
|
||||
box.worldVerticesLength = vertexCount << 1;
|
||||
box.vertices = vertices.vertices;
|
||||
box.bones = vertices.bones;
|
||||
if (nonessential) Color.rgba8888ToColor(box.color, color);
|
||||
return box;
|
||||
}
|
||||
case AttachmentType.Mesh: {
|
||||
let path = input.readStringRef();
|
||||
let color = input.readInt32();
|
||||
let vertexCount = input.readInt(true);
|
||||
let uvs = this.readFloatArray(input, vertexCount << 1, 1);
|
||||
let triangles = this.readShortArray(input);
|
||||
let vertices = this.readVertices(input, vertexCount);
|
||||
let hullLength = input.readInt(true);
|
||||
let edges = null;
|
||||
let width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
edges = this.readShortArray(input);
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
|
||||
if (path == null) path = name;
|
||||
let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null) return null;
|
||||
mesh.path = path;
|
||||
Color.rgba8888ToColor(mesh.color, color);
|
||||
mesh.bones = vertices.bones;
|
||||
mesh.vertices = vertices.vertices;
|
||||
mesh.worldVerticesLength = vertexCount << 1;
|
||||
mesh.triangles = triangles;
|
||||
mesh.regionUVs = uvs;
|
||||
mesh.updateUVs();
|
||||
mesh.hullLength = hullLength << 1;
|
||||
if (nonessential) {
|
||||
mesh.edges = edges;
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
return mesh;
|
||||
}
|
||||
case AttachmentType.LinkedMesh: {
|
||||
let path = input.readStringRef();
|
||||
let color = input.readInt32();
|
||||
let skinName = input.readStringRef();
|
||||
let parent = input.readStringRef();
|
||||
let inheritDeform = input.readBoolean();
|
||||
let width = 0, height = 0;
|
||||
if (nonessential) {
|
||||
width = input.readFloat();
|
||||
height = input.readFloat();
|
||||
}
|
||||
|
||||
if (path == null) path = name;
|
||||
let mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
|
||||
if (mesh == null) return null;
|
||||
mesh.path = path;
|
||||
Color.rgba8888ToColor(mesh.color, color);
|
||||
if (nonessential) {
|
||||
mesh.width = width * scale;
|
||||
mesh.height = height * scale;
|
||||
}
|
||||
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent, inheritDeform));
|
||||
return mesh;
|
||||
}
|
||||
case AttachmentType.Path: {
|
||||
let closed = input.readBoolean();
|
||||
let constantSpeed = input.readBoolean();
|
||||
let vertexCount = input.readInt(true);
|
||||
let vertices = this.readVertices(input, vertexCount);
|
||||
let lengths = Utils.newArray(vertexCount / 3, 0);
|
||||
for (let i = 0, n = lengths.length; i < n; i++)
|
||||
lengths[i] = input.readFloat() * scale;
|
||||
let color = nonessential ? input.readInt32() : 0;
|
||||
|
||||
let path = this.attachmentLoader.newPathAttachment(skin, name);
|
||||
if (path == null) return null;
|
||||
path.closed = closed;
|
||||
path.constantSpeed = constantSpeed;
|
||||
path.worldVerticesLength = vertexCount << 1;
|
||||
path.vertices = vertices.vertices;
|
||||
path.bones = vertices.bones;
|
||||
path.lengths = lengths;
|
||||
if (nonessential) Color.rgba8888ToColor(path.color, color);
|
||||
return path;
|
||||
}
|
||||
case AttachmentType.Point: {
|
||||
let rotation = input.readFloat();
|
||||
let x = input.readFloat();
|
||||
let y = input.readFloat();
|
||||
let color = nonessential ? input.readInt32() : 0;
|
||||
|
||||
let point = this.attachmentLoader.newPointAttachment(skin, name);
|
||||
if (point == null) return null;
|
||||
point.x = x * scale;
|
||||
point.y = y * scale;
|
||||
point.rotation = rotation;
|
||||
if (nonessential) Color.rgba8888ToColor(point.color, color);
|
||||
return point;
|
||||
}
|
||||
case AttachmentType.Clipping: {
|
||||
let endSlotIndex = input.readInt(true);
|
||||
let vertexCount = input.readInt(true);
|
||||
let vertices = this.readVertices(input, vertexCount);
|
||||
let color = nonessential ? input.readInt32() : 0;
|
||||
|
||||
let clip = this.attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null) return null;
|
||||
clip.endSlot = skeletonData.slots[endSlotIndex];
|
||||
clip.worldVerticesLength = vertexCount << 1;
|
||||
clip.vertices = vertices.vertices;
|
||||
clip.bones = vertices.bones;
|
||||
if (nonessential) Color.rgba8888ToColor(clip.color, color);
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private readVertices (input: BinaryInput, vertexCount: number): Vertices {
|
||||
let verticesLength = vertexCount << 1;
|
||||
let vertices = new Vertices();
|
||||
let scale = this.scale;
|
||||
if (!input.readBoolean()) {
|
||||
vertices.vertices = this.readFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
let weights = new Array<number>();
|
||||
let bonesArray = new Array<number>();
|
||||
for (let i = 0; i < vertexCount; i++) {
|
||||
let boneCount = input.readInt(true);
|
||||
bonesArray.push(boneCount);
|
||||
for (let ii = 0; ii < boneCount; ii++) {
|
||||
bonesArray.push(input.readInt(true));
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat() * scale);
|
||||
weights.push(input.readFloat());
|
||||
}
|
||||
}
|
||||
vertices.vertices = Utils.toFloatArray(weights);
|
||||
vertices.bones = bonesArray;
|
||||
return vertices;
|
||||
}
|
||||
|
||||
private readFloatArray (input: BinaryInput, n: number, scale: number): number[] {
|
||||
let array = new Array<number>(n);
|
||||
if (scale == 1) {
|
||||
for (let i = 0; i < n; i++)
|
||||
array[i] = input.readFloat();
|
||||
} else {
|
||||
for (let i = 0; i < n; i++)
|
||||
array[i] = input.readFloat() * scale;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private readShortArray (input: BinaryInput): number[] {
|
||||
let n = input.readInt(true);
|
||||
let array = new Array<number>(n);
|
||||
for (let i = 0; i < n; i++)
|
||||
array[i] = input.readShort();
|
||||
return array;
|
||||
}
|
||||
|
||||
private readAnimation (input: BinaryInput, name: string, skeletonData: SkeletonData): Animation {
|
||||
let timelines = new Array<Timeline>();
|
||||
let scale = this.scale;
|
||||
let duration = 0;
|
||||
let tempColor1 = new Color();
|
||||
let tempColor2 = new Color();
|
||||
|
||||
// Slot timelines.
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let slotIndex = input.readInt(true);
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
let timelineType = input.readByte();
|
||||
let frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.SLOT_ATTACHMENT: {
|
||||
let timeline = new AttachmentTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++)
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_COLOR: {
|
||||
let timeline = new ColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
let time = input.readFloat();
|
||||
Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * ColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_TWO_COLOR: {
|
||||
let timeline = new TwoColorTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
let time = input.readFloat();
|
||||
Color.rgba8888ToColor(tempColor1, input.readInt32());
|
||||
Color.rgb888ToColor(tempColor2, input.readInt32());
|
||||
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r,
|
||||
tempColor2.g, tempColor2.b);
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TwoColorTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bone timelines.
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let boneIndex = input.readInt(true);
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
let timelineType = input.readByte();
|
||||
let frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.BONE_ROTATE: {
|
||||
let timeline = new RotateTimeline(frameCount);
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * RotateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.BONE_TRANSLATE:
|
||||
case SkeletonBinary.BONE_SCALE:
|
||||
case SkeletonBinary.BONE_SHEAR: {
|
||||
let timeline;
|
||||
let timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.BONE_SCALE)
|
||||
timeline = new ScaleTimeline(frameCount);
|
||||
else if (timelineType == SkeletonBinary.BONE_SHEAR)
|
||||
timeline = new ShearTimeline(frameCount);
|
||||
else {
|
||||
timeline = new TranslateTimeline(frameCount);
|
||||
timelineScale = scale;
|
||||
}
|
||||
timeline.boneIndex = boneIndex;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale,
|
||||
input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TranslateTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IK constraint timelines.
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let index = input.readInt(true);
|
||||
let frameCount = input.readInt(true);
|
||||
let timeline = new IkConstraintTimeline(frameCount);
|
||||
timeline.ikConstraintIndex = index;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readByte(), input.readBoolean(),
|
||||
input.readBoolean());
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * IkConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
|
||||
// Transform constraint timelines.
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let index = input.readInt(true);
|
||||
let frameCount = input.readInt(true);
|
||||
let timeline = new TransformConstraintTimeline(frameCount);
|
||||
timeline.transformConstraintIndex = index;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(),
|
||||
input.readFloat());
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TransformConstraintTimeline.ENTRIES]);
|
||||
}
|
||||
|
||||
// Path constraint timelines.
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let index = input.readInt(true);
|
||||
let data = skeletonData.pathConstraints[index];
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
let timelineType = input.readByte();
|
||||
let frameCount = input.readInt(true);
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.PATH_POSITION:
|
||||
case SkeletonBinary.PATH_SPACING: {
|
||||
let timeline;
|
||||
let timelineScale = 1;
|
||||
if (timelineType == SkeletonBinary.PATH_SPACING) {
|
||||
timeline = new PathConstraintSpacingTimeline(frameCount);
|
||||
if (data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed) timelineScale = scale;
|
||||
} else {
|
||||
timeline = new PathConstraintPositionTimeline(frameCount);
|
||||
if (data.positionMode == PositionMode.Fixed) timelineScale = scale;
|
||||
}
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintPositionTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.PATH_MIX: {
|
||||
let timeline = new PathConstraintMixTimeline(frameCount);
|
||||
timeline.pathConstraintIndex = index;
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintMixTimeline.ENTRIES]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deform timelines.
|
||||
for (let i = 0, n = input.readInt(true); i < n; i++) {
|
||||
let skin = skeletonData.skins[input.readInt(true)];
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
let slotIndex = input.readInt(true);
|
||||
for (let iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
|
||||
let attachment = skin.getAttachment(slotIndex, input.readStringRef()) as VertexAttachment;
|
||||
let weighted = attachment.bones != null;
|
||||
let vertices = attachment.vertices;
|
||||
let deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
|
||||
|
||||
let frameCount = input.readInt(true);
|
||||
let timeline = new DeformTimeline(frameCount);
|
||||
timeline.slotIndex = slotIndex;
|
||||
timeline.attachment = attachment;
|
||||
|
||||
for (let frameIndex = 0; frameIndex < frameCount; frameIndex++) {
|
||||
let time = input.readFloat();
|
||||
let deform;
|
||||
let end = input.readInt(true);
|
||||
if (end == 0)
|
||||
deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
|
||||
else {
|
||||
deform = Utils.newFloatArray(deformLength);
|
||||
let start = input.readInt(true);
|
||||
end += start;
|
||||
if (scale == 1) {
|
||||
for (let v = start; v < end; v++)
|
||||
deform[v] = input.readFloat();
|
||||
} else {
|
||||
for (let v = start; v < end; v++)
|
||||
deform[v] = input.readFloat() * scale;
|
||||
}
|
||||
if (!weighted) {
|
||||
for (let v = 0, vn = deform.length; v < vn; v++)
|
||||
deform[v] += vertices[v];
|
||||
}
|
||||
}
|
||||
|
||||
timeline.setFrame(frameIndex, time, deform);
|
||||
if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[frameCount - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw order timeline.
|
||||
let drawOrderCount = input.readInt(true);
|
||||
if (drawOrderCount > 0) {
|
||||
let timeline = new DrawOrderTimeline(drawOrderCount);
|
||||
let slotCount = skeletonData.slots.length;
|
||||
for (let i = 0; i < drawOrderCount; i++) {
|
||||
let time = input.readFloat();
|
||||
let offsetCount = input.readInt(true);
|
||||
let drawOrder = Utils.newArray(slotCount, 0);
|
||||
for (let ii = slotCount - 1; ii >= 0; ii--)
|
||||
drawOrder[ii] = -1;
|
||||
let unchanged = Utils.newArray(slotCount - offsetCount, 0);
|
||||
let originalIndex = 0, unchangedIndex = 0;
|
||||
for (let ii = 0; ii < offsetCount; ii++) {
|
||||
let slotIndex = input.readInt(true);
|
||||
// Collect unchanged items.
|
||||
while (originalIndex != slotIndex)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
// Set changed items.
|
||||
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
|
||||
}
|
||||
// Collect remaining unchanged items.
|
||||
while (originalIndex < slotCount)
|
||||
unchanged[unchangedIndex++] = originalIndex++;
|
||||
// Fill in unchanged items.
|
||||
for (let ii = slotCount - 1; ii >= 0; ii--)
|
||||
if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex];
|
||||
timeline.setFrame(i, time, drawOrder);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
|
||||
}
|
||||
|
||||
// Event timeline.
|
||||
let eventCount = input.readInt(true);
|
||||
if (eventCount > 0) {
|
||||
let timeline = new EventTimeline(eventCount);
|
||||
for (let i = 0; i < eventCount; i++) {
|
||||
let time = input.readFloat();
|
||||
let eventData = skeletonData.events[input.readInt(true)];
|
||||
let event = new Event(time, eventData);
|
||||
event.intValue = input.readInt(false);
|
||||
event.floatValue = input.readFloat();
|
||||
event.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
|
||||
if (event.data.audioPath != null) {
|
||||
event.volume = input.readFloat();
|
||||
event.balance = input.readFloat();
|
||||
}
|
||||
timeline.setFrame(i, event);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[eventCount - 1]);
|
||||
}
|
||||
|
||||
return new Animation(name, timelines, duration);
|
||||
}
|
||||
|
||||
private readCurve (input: BinaryInput, frameIndex: number, timeline: CurveTimeline) {
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frameIndex);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setCurve (timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number) {
|
||||
timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
|
||||
}
|
||||
}
|
||||
|
||||
class BinaryInput {
|
||||
constructor(data: Uint8Array, public strings = new Array<string>(), private index: number = 0, private buffer = new DataView(data.buffer)) {
|
||||
|
||||
}
|
||||
|
||||
readByte(): number {
|
||||
return this.buffer.getInt8(this.index++);
|
||||
}
|
||||
|
||||
readShort(): number {
|
||||
let value = this.buffer.getInt16(this.index);
|
||||
this.index += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
readInt32(): number {
|
||||
let value = this.buffer.getInt32(this.index)
|
||||
this.index += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
readInt(optimizePositive: boolean) {
|
||||
let b = this.readByte();
|
||||
let result = b & 0x7F;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 7;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 14;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 21;
|
||||
if ((b & 0x80) != 0) {
|
||||
b = this.readByte();
|
||||
result |= (b & 0x7F) << 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
|
||||
}
|
||||
|
||||
readStringRef (): string {
|
||||
let index = this.readInt(true);
|
||||
return index == 0 ? null : this.strings[index - 1];
|
||||
}
|
||||
|
||||
readString (): string {
|
||||
let byteCount = this.readInt(true);
|
||||
switch (byteCount) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return "";
|
||||
}
|
||||
byteCount--;
|
||||
let chars = "";
|
||||
let charCount = 0;
|
||||
for (let i = 0; i < byteCount;) {
|
||||
let b = this.readByte();
|
||||
switch (b >> 4) {
|
||||
case 12:
|
||||
case 13:
|
||||
chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
|
||||
i += 2;
|
||||
break;
|
||||
case 14:
|
||||
chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
|
||||
i += 3;
|
||||
break;
|
||||
default:
|
||||
chars += String.fromCharCode(b);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
}
|
||||
|
||||
readFloat (): number {
|
||||
let value = this.buffer.getFloat32(this.index);
|
||||
this.index += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
readBoolean (): boolean {
|
||||
return this.readByte() != 0;
|
||||
}
|
||||
}
|
||||
|
||||
class LinkedMesh {
|
||||
parent: string; skin: string;
|
||||
slotIndex: number;
|
||||
mesh: MeshAttachment;
|
||||
inheritDeform: boolean;
|
||||
|
||||
constructor (mesh: MeshAttachment, skin: string, slotIndex: number, parent: string, inheritDeform: boolean) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
}
|
||||
|
||||
class Vertices {
|
||||
constructor(public bones: Array<number> = null, public vertices: Array<number> | Float32Array = null) { }
|
||||
}
|
||||
}
|
||||
@ -45,6 +45,7 @@ module spine {
|
||||
// Nonessential
|
||||
fps = 0;
|
||||
imagesPath: string;
|
||||
audioPath: string;
|
||||
|
||||
findBone (boneName: string) {
|
||||
if (boneName == null) throw new Error("boneName cannot be null.");
|
||||
|
||||
@ -121,6 +121,19 @@ module spine {
|
||||
else if (this.a > 1) this.a = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
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) {
|
||||
color.r = ((value & 0x00ff0000) >>> 16) / 255;
|
||||
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.b = ((value & 0x000000ff)) / 255;
|
||||
}
|
||||
}
|
||||
|
||||
export class MathUtils {
|
||||
|
||||
@ -29,6 +29,6 @@
|
||||
|
||||
module spine {
|
||||
export enum AttachmentType {
|
||||
Region, BoundingBox, Mesh, LinkedMesh, Path, Point
|
||||
Region, BoundingBox, Mesh, LinkedMesh, Path, Point, Clipping
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/player/example/assets/spineboy-pro.skel
Normal file
BIN
spine-ts/player/example/assets/spineboy-pro.skel
Normal file
Binary file not shown.
@ -22,7 +22,7 @@ body {
|
||||
// Creates a new spine player. The debugRender option enables
|
||||
// rendering of viewports and padding for debugging purposes.
|
||||
new spine.SpinePlayer("container", {
|
||||
jsonUrl: "assets/spineboy-pro.json",
|
||||
skelUrl: "assets/spineboy-pro.skel",
|
||||
atlasUrl: "assets/spineboy-pma.atlas",
|
||||
animation: "run",
|
||||
premultipliedAlpha: true,
|
||||
|
||||
@ -43,6 +43,9 @@ module spine {
|
||||
/* the URL of the skeleton .json file */
|
||||
jsonUrl: string
|
||||
|
||||
/* the URL of the skeleton .skel file */
|
||||
skelUrl: string
|
||||
|
||||
/* the URL of the skeleton .atlas file. Atlas page images are automatically resolved. */
|
||||
atlasUrl: string
|
||||
|
||||
@ -319,7 +322,7 @@ module spine {
|
||||
|
||||
validateConfig(config: SpinePlayerConfig): SpinePlayerConfig {
|
||||
if (!config) throw new Error("Please pass a configuration to new.spine.SpinePlayer().");
|
||||
if (!config.jsonUrl) throw new Error("Please specify the URL of the skeleton JSON file.");
|
||||
if (!config.jsonUrl && !config.skelUrl) throw new Error("Please specify the URL of the skeleton JSON or .skel file.");
|
||||
if (!config.atlasUrl) throw new Error("Please specify the URL of the atlas file.");
|
||||
if (!config.alpha) config.alpha = false;
|
||||
if (!config.backgroundColor) config.backgroundColor = "#000000";
|
||||
@ -418,7 +421,8 @@ module spine {
|
||||
|
||||
// Load the assets
|
||||
this.assetManager = new spine.webgl.AssetManager(this.context);
|
||||
this.assetManager.loadText(config.jsonUrl);
|
||||
if (config.jsonUrl) this.assetManager.loadText(config.jsonUrl);
|
||||
else this.assetManager.loadBinary(config.skelUrl);
|
||||
this.assetManager.loadTextureAtlas(config.atlasUrl);
|
||||
if (config.backgroundImage && config.backgroundImage.url)
|
||||
this.assetManager.loadTexture(config.backgroundImage.url);
|
||||
@ -842,14 +846,25 @@ module spine {
|
||||
}
|
||||
|
||||
let atlas = this.assetManager.get(this.config.atlasUrl);
|
||||
let jsonText = this.assetManager.get(this.config.jsonUrl);
|
||||
let json = new SkeletonJson(new AtlasAttachmentLoader(atlas));
|
||||
let skeletonData: SkeletonData;
|
||||
try {
|
||||
skeletonData = json.readSkeletonData(jsonText);
|
||||
} catch (e) {
|
||||
this.showError("Error: could not load skeleton .json.<br><br>" + escapeHtml(JSON.stringify(e)));
|
||||
return;
|
||||
if (this.config.jsonUrl) {
|
||||
let jsonText = this.assetManager.get(this.config.jsonUrl);
|
||||
let json = new SkeletonJson(new AtlasAttachmentLoader(atlas));
|
||||
try {
|
||||
skeletonData = json.readSkeletonData(jsonText);
|
||||
} catch (e) {
|
||||
this.showError("Error: could not load skeleton .json.<br><br>" + escapeHtml(JSON.stringify(e)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
let binaryData = this.assetManager.get(this.config.skelUrl);
|
||||
let binary = new SkeletonBinary(new AtlasAttachmentLoader(atlas));
|
||||
try {
|
||||
skeletonData = binary.readSkeletonData(binaryData);
|
||||
} catch (e) {
|
||||
this.showError("Error: could not load skeleton .skel.<br><br>" + escapeHtml(JSON.stringify(e)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.skeleton = new Skeleton(skeletonData);
|
||||
let stateData = new AnimationStateData(skeletonData);
|
||||
|
||||
@ -1,179 +0,0 @@
|
||||
{
|
||||
"skeleton": {
|
||||
"hash": "UAXc6AgX0g45vxO38bHIVx5jbNo",
|
||||
"spine": "3.8.14-beta",
|
||||
"x": -152.5,
|
||||
"y": -151,
|
||||
"width": 305,
|
||||
"height": 302,
|
||||
"images": "./images/",
|
||||
"audio": "C:/Program Files (x86)/Spine/examples/coin-new"
|
||||
},
|
||||
"bones": [
|
||||
{ "name": "root" },
|
||||
{ "name": "coin-front", "parent": "root" },
|
||||
{ "name": "clipping", "parent": "coin-front" },
|
||||
{ "name": "coin-sides", "parent": "root" },
|
||||
{ "name": "coin-side-round", "parent": "coin-sides" },
|
||||
{ "name": "coin-side-straight", "parent": "coin-sides" },
|
||||
{ "name": "shine", "parent": "root", "x": 243.14 }
|
||||
],
|
||||
"slots": [
|
||||
{ "name": "coin-side", "bone": "coin-side-straight", "color": "ffdb2fff", "attachment": "coin-side-straight" },
|
||||
{ "name": "coin-side-round", "bone": "coin-side-round", "color": "ffdb2fff", "attachment": "coin-side-round" },
|
||||
{ "name": "coin-front-texture", "bone": "coin-front", "color": "868686ff", "attachment": "coin-front-logo" },
|
||||
{ "name": "coin-front-shine", "bone": "coin-front", "color": "888888ff", "dark": "000000", "attachment": "coin-front-shine-logo", "blend": "additive" },
|
||||
{ "name": "clipping", "bone": "clipping", "attachment": "clipping" },
|
||||
{ "name": "shine", "bone": "shine", "color": "ffffff60", "attachment": "shine", "blend": "additive" }
|
||||
],
|
||||
"skins": [
|
||||
{
|
||||
"name": "default",
|
||||
"attachments": {
|
||||
"clipping": {
|
||||
"clipping": {
|
||||
"type": "clipping",
|
||||
"end": "clipping",
|
||||
"vertexCount": 39,
|
||||
"vertices": [ 0.1, 140.26, -26.4, 138.14, -50.51, 131.25, -75.42, 119.06, -98.21, 101.04, -115.44, 82.22, -127.63, 62.08, -136.11, 39.03, -140.08, 19.68, -141.41, -0.19, -140.08, -22.98, -134.78, -45.5, -125.24, -66.44, -113.32, -84.19, -98.21, -101.95, -80.46, -116.52, -61.38, -127.39, -38.92, -134.81, -18.22, -139.27, -0.14, -140.58, 24.23, -138.48, 45.45, -132.46, 67.98, -122.5, 86.58, -110.19, 102.56, -95.25, 115.4, -78.75, 125.36, -61.72, 134, -42.33, 138.46, -22.15, 139.24, -0.15, 138.46, 20.29, 133.48, 39.94, 127.19, 58.54, 117.5, 76.1, 104.4, 92.86, 88.42, 108.32, 69.03, 121.42, 50.43, 130.85, 26.32, 137.4 ],
|
||||
"color": "ce3a3aff"
|
||||
}
|
||||
},
|
||||
"coin-front-shine": {
|
||||
"coin-front-shine-logo": { "width": 282, "height": 282 },
|
||||
"coin-front-shine-spineboy": { "width": 282, "height": 282 }
|
||||
},
|
||||
"coin-front-texture": {
|
||||
"coin-front-logo": { "width": 305, "height": 302 },
|
||||
"coin-front-spineboy": { "width": 305, "height": 302 }
|
||||
},
|
||||
"coin-side": {
|
||||
"coin-side-straight": { "x": 0.5, "width": 17, "height": 282 }
|
||||
},
|
||||
"coin-side-round": {
|
||||
"coin-side-round": { "x": -69.43, "width": 144, "height": 282 }
|
||||
},
|
||||
"shine": {
|
||||
"shine": { "y": 0.5, "scaleX": 1.6004, "scaleY": 1.6004, "width": 72, "height": 245 }
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"animations": {
|
||||
"animation": {
|
||||
"slots": {
|
||||
"coin-front-shine": {
|
||||
"twoColor": [
|
||||
{ "light": "7d7d7dff", "dark": "000000" },
|
||||
{ "time": 0.2667, "light": "000000ff", "dark": "7e7e7e" },
|
||||
{ "time": 0.664, "light": "000000ff", "dark": "000000" },
|
||||
{ "time": 1.0333, "light": "7f7f7fff", "dark": "000000" },
|
||||
{ "time": 1.3333, "light": "404040ff", "dark": "000000" },
|
||||
{ "time": 1.6, "light": "000000ff", "dark": "7e7e7e" },
|
||||
{ "time": 2.0022, "light": "000000ff", "dark": "000000" },
|
||||
{ "time": 2.4, "light": "7f7f7fff", "dark": "000000" },
|
||||
{ "time": 2.6667, "light": "7d7d7dff", "dark": "000000" }
|
||||
],
|
||||
"attachment": [
|
||||
{ "time": 0.6667, "name": "coin-front-shine-spineboy" },
|
||||
{ "time": 2, "name": "coin-front-shine-logo" }
|
||||
]
|
||||
},
|
||||
"coin-front-texture": {
|
||||
"color": [
|
||||
{ "color": "858585ff" },
|
||||
{ "time": 0.4, "color": "ffffffff" },
|
||||
{ "time": 0.6696, "color": "858585ff", "curve": 0.188, "c2": 0.15, "c3": 0.75 },
|
||||
{ "time": 0.9667, "color": "ffffffff" },
|
||||
{ "time": 1.3318, "color": "858585ff", "curve": "stepped" },
|
||||
{ "time": 1.3333, "color": "858585ff" },
|
||||
{ "time": 1.7333, "color": "ffffffff" },
|
||||
{ "time": 1.9982, "color": "858585ff", "curve": "stepped" },
|
||||
{ "time": 2.0022, "color": "858585ff" },
|
||||
{ "time": 2.3, "color": "ffffffff" },
|
||||
{ "time": 2.6667, "color": "858585ff" }
|
||||
],
|
||||
"attachment": [
|
||||
{ "time": 0.6667, "name": "coin-front-spineboy" },
|
||||
{ "time": 2, "name": "coin-front-logo" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"bones": {
|
||||
"coin-front": {
|
||||
"translate": [
|
||||
{},
|
||||
{ "time": 0.664, "x": 8.3, "curve": "stepped" },
|
||||
{ "time": 0.6696, "x": -8.3, "curve": 0.188, "c2": 0.15, "c3": 0.75 },
|
||||
{ "time": 1.3333 },
|
||||
{ "time": 1.9982, "x": 8.3, "curve": "stepped" },
|
||||
{ "time": 2.0022, "x": -8.3 },
|
||||
{ "time": 2.6667 }
|
||||
],
|
||||
"scale": [
|
||||
{ "curve": 0.247, "c3": 0.729, "c4": 0.91 },
|
||||
{ "time": 0.664, "x": 0, "curve": "stepped" },
|
||||
{ "time": 0.6696, "x": 0.003, "curve": 0.175, "c2": 0.15, "c3": 0.75 },
|
||||
{ "time": 1.3333, "curve": 0.163, "c2": 0.01, "c3": 0.789, "c4": 0.9 },
|
||||
{ "time": 1.9982, "x": 0.003, "curve": "stepped" },
|
||||
{ "time": 2.0022, "x": 0.003, "curve": 0.182, "c2": 0.15, "c3": 0.75 },
|
||||
{ "time": 2.6667 }
|
||||
]
|
||||
},
|
||||
"coin-side-round": {
|
||||
"translate": [
|
||||
{},
|
||||
{ "time": 0.664, "x": -6.75, "curve": "stepped" },
|
||||
{ "time": 0.6696, "x": 7.03, "curve": 0.188, "c2": 0.15, "c3": 0.75 },
|
||||
{ "time": 1.3333 },
|
||||
{ "time": 1.9982, "x": -6.75, "curve": "stepped" },
|
||||
{ "time": 2.0022, "x": 7.03 },
|
||||
{ "time": 2.6667 }
|
||||
],
|
||||
"scale": [
|
||||
{ "curve": 0.254, "c3": 0.621, "c4": 0.47 },
|
||||
{ "time": 0.3333, "x": 0.555, "curve": 0.349, "c2": 0.38, "c3": 0.707, "c4": 0.8 },
|
||||
{ "time": 0.664, "x": 0.014, "curve": "stepped" },
|
||||
{ "time": 0.6696, "x": -0.028, "curve": 0.163, "c2": 0.17, "c3": 0.59, "c4": 0.58 },
|
||||
{ "time": 1, "x": -0.609, "curve": 0.158, "c2": 0.43, "c3": 0.875, "c4": 0.99 },
|
||||
{ "time": 1.3318, "x": -1, "curve": "stepped" },
|
||||
{ "time": 1.3333, "curve": 0.306, "c2": 0.02, "c3": 0.636, "c4": 0.41 },
|
||||
{ "time": 1.5, "x": 0.852, "curve": 0.212, "c2": 0.19, "c3": 0.678, "c4": 0.64 },
|
||||
{ "time": 1.8, "x": 0.315, "curve": 0.366, "c2": 0.62, "c3": 0.942 },
|
||||
{ "time": 1.9982, "x": 0.014, "curve": "stepped" },
|
||||
{ "time": 2.0022, "x": -0.028, "curve": 0.184, "c2": 0.13, "c3": 0.604, "c4": 0.63 },
|
||||
{ "time": 2.2018, "x": -0.365, "curve": 0.34, "c2": 0.4, "c3": 0.683, "c4": 0.74 },
|
||||
{ "time": 2.4, "x": -0.731, "curve": 0.399, "c2": 0.52, "c3": 0.754, "c4": 0.86 },
|
||||
{ "time": 2.6592, "x": -1, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 2.6667 }
|
||||
]
|
||||
},
|
||||
"shine": {
|
||||
"translate": [
|
||||
{ "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 0.6667, "x": -473.39, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 1.3333, "x": -33.16, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 2, "x": -473.39, "curve": 0.25, "c3": 0.75 },
|
||||
{ "time": 2.6667 }
|
||||
]
|
||||
}
|
||||
},
|
||||
"drawOrder": [
|
||||
{
|
||||
"time": 0.6667,
|
||||
"offsets": [
|
||||
{ "slot": "coin-side", "offset": 2 }
|
||||
]
|
||||
},
|
||||
{ "time": 0.6696 },
|
||||
{
|
||||
"time": 1.9982,
|
||||
"offsets": [
|
||||
{ "slot": "coin-side", "offset": 2 }
|
||||
]
|
||||
},
|
||||
{ "time": 2.0022 }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
spine-ts/webgl/example/assets/coin-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/coin-pro.skel
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/webgl/example/assets/goblins-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/goblins-pro.skel
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
spine-ts/webgl/example/assets/owl-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/owl-pro.skel
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
spine-ts/webgl/example/assets/raptor-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/raptor-pro.skel
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/webgl/example/assets/spineboy-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/spineboy-pro.skel
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
spine-ts/webgl/example/assets/stretchyman-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/stretchyman-pro.skel
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
spine-ts/webgl/example/assets/stretchyman-stretchy-ik-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/stretchyman-stretchy-ik-pro.skel
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/webgl/example/assets/tank-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/tank-pro.skel
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
spine-ts/webgl/example/assets/vine-pro.skel
Normal file
BIN
spine-ts/webgl/example/assets/vine-pro.skel
Normal file
Binary file not shown.
@ -64,22 +64,22 @@ function init () {
|
||||
shapes = new spine.webgl.ShapeRenderer(gl);
|
||||
assetManager = new spine.webgl.AssetManager(gl);
|
||||
|
||||
// Tell AssetManager to load the resources for each model, including the exported .json file, the .atlas file and the .png
|
||||
// Tell AssetManager to load the resources for each model, including the exported .skel file, the .atlas file and the .png
|
||||
// file for the atlas. We then wait until all resources are loaded in the load() method.
|
||||
assetManager.loadText("assets/spineboy-pro.json");
|
||||
assetManager.loadBinary("assets/spineboy-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/spineboy-pma.atlas");
|
||||
assetManager.loadText("assets/raptor-pro.json");
|
||||
assetManager.loadBinary("assets/raptor-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/raptor-pma.atlas");
|
||||
assetManager.loadText("assets/tank-pro.json");
|
||||
assetManager.loadBinary("assets/tank-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/tank-pma.atlas");
|
||||
assetManager.loadText("assets/goblins-pro.json");
|
||||
assetManager.loadBinary("assets/goblins-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/goblins-pma.atlas");
|
||||
assetManager.loadText("assets/vine-pro.json");
|
||||
assetManager.loadBinary("assets/vine-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/vine-pma.atlas");
|
||||
assetManager.loadText("assets/stretchyman-pro.json");
|
||||
assetManager.loadBinary("assets/stretchyman-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/stretchyman-pma.atlas");
|
||||
assetManager.loadText("assets/stretchyman-stretchy-ik-pro.json");
|
||||
assetManager.loadText("assets/coin-pro.json");
|
||||
assetManager.loadBinary("assets/stretchyman-stretchy-ik-pro.skel");
|
||||
assetManager.loadBinary("assets/coin-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/coin-pma.atlas");
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
@ -111,11 +111,11 @@ function loadSkeleton (name, initialAnimation, premultipliedAlpha, skin) {
|
||||
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||
atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||
|
||||
// Create a SkeletonJson instance for parsing the .json file.
|
||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||
// Create a SkeletonBinary instance for parsing the .skel file.
|
||||
var skeletonBinary = new spine.SkeletonBinary(atlasLoader);
|
||||
|
||||
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||
var skeletonData = skeletonJson.readSkeletonData(assetManager.get("assets/" + name + ".json"));
|
||||
var skeletonData = skeletonBinary.readSkeletonData(assetManager.get("assets/" + name + ".skel"));
|
||||
var skeleton = new spine.Skeleton(skeletonData);
|
||||
skeleton.setSkinByName(skin);
|
||||
var bounds = calculateBounds(skeleton);
|
||||
|
||||
118
spine-ts/webgl/tests/test-binary.html
Normal file
118
spine-ts/webgl/tests/test-binary.html
Normal file
@ -0,0 +1,118 @@
|
||||
<html>
|
||||
<script src="../../build/spine-webgl.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; }
|
||||
body, html { height: 100% }
|
||||
canvas { position: absolute; width: 100% ;height: 100%; }
|
||||
</style>
|
||||
<body>
|
||||
<div id="label" style="position: absolute; top: 0; left: 0; color: #fff; z-index: 10"></div>
|
||||
<canvas id="canvas" style="background: red;"></canvas>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
var FILE = "spineboy-pro";
|
||||
var ANIMATION = "walk";
|
||||
var SCALE = 0.5;
|
||||
|
||||
var canvas, context, gl, renderer, input, assetManager;
|
||||
var skeletons = [];
|
||||
var timeKeeper;
|
||||
var label = document.getElementById("label");
|
||||
var updateMean = new spine.WindowedMean();
|
||||
var renderMean = new spine.WindowedMean();
|
||||
|
||||
function init() {
|
||||
canvas = document.getElementById("canvas");
|
||||
canvas.width = canvas.clientWidth; canvas.height = canvas.clientHeight;
|
||||
context = new spine.webgl.ManagedWebGLRenderingContext(canvas, { alpha: false });
|
||||
gl = context.gl;
|
||||
|
||||
renderer = new spine.webgl.SceneRenderer(canvas, context);
|
||||
assetManager = new spine.webgl.AssetManager(context, "../example/assets/");
|
||||
input = new spine.webgl.Input(canvas);
|
||||
|
||||
assetManager.loadTextureAtlas(FILE.replace("-pro", "").replace("-ess", "") + "-pma.atlas");
|
||||
assetManager.loadBinary(FILE + ".skel");
|
||||
assetManager.loadText(FILE + ".json");
|
||||
|
||||
timeKeeper = new spine.TimeKeeper();
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
|
||||
var run = true;
|
||||
|
||||
function load() {
|
||||
timeKeeper.update();
|
||||
if (assetManager.isLoadingComplete()) {
|
||||
var atlas = assetManager.get(FILE.replace("-pro", "").replace("-ess", "") + "-pma.atlas");
|
||||
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||
var skeletonBinary = new spine.SkeletonBinary(atlasLoader);
|
||||
skeletonBinary.scale = SCALE;
|
||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||
skeletonJson.scale = SCALE;
|
||||
var skeletonData = null;
|
||||
var skeletonJsonData = null;
|
||||
|
||||
var time = new spine.TimeKeeper()
|
||||
for (var i = 0; i < 1; i++)
|
||||
skeletonData = skeletonBinary.readSkeletonData(assetManager.get(FILE + ".skel"));
|
||||
time.update();
|
||||
console.log("Binary: " + time.totalTime);
|
||||
|
||||
/*time = new spine.TimeKeeper()
|
||||
for (var i = 0; i < 1; i++)
|
||||
skeletonData = skeletonJson.readSkeletonData(assetManager.get(FILE + ".json"));
|
||||
time.update();
|
||||
console.log("Json: " + time.totalTime);*/
|
||||
|
||||
skeleton = new spine.Skeleton(skeletonData);
|
||||
var stateData = new spine.AnimationStateData(skeleton.data);
|
||||
state = new spine.AnimationState(stateData);
|
||||
stateData.defaultMix = 0;
|
||||
|
||||
state.setAnimation(0, ANIMATION, true);
|
||||
skeletons.push({ skeleton: skeleton, state: state });
|
||||
|
||||
requestAnimationFrame(render);
|
||||
} else {
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
var start = Date.now()
|
||||
timeKeeper.update();
|
||||
var delta = 0.016; // timeKeeper.delta;
|
||||
|
||||
for (var i = 0; i < skeletons.length; i++) {
|
||||
var state = skeletons[i].state;
|
||||
var skeleton = skeletons[i].skeleton;
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.updateWorldTransform();
|
||||
}
|
||||
updateMean.addValue(Date.now() - start);
|
||||
start = Date.now();
|
||||
|
||||
gl.clearColor(0.2, 0.2, 0.2, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
renderer.resize(spine.webgl.ResizeMode.Fit);
|
||||
renderer.begin();
|
||||
for (var i = 0; i < skeletons.length; i++) {
|
||||
var skeleton = skeletons[i].skeleton;
|
||||
renderer.drawSkeleton(skeleton, true);
|
||||
}
|
||||
renderer.end();
|
||||
|
||||
requestAnimationFrame(render)
|
||||
renderMean.addValue(Date.now() - start);
|
||||
label.innerHTML = ("Update time: " + Number(updateMean.getMean()).toFixed(2) + " ms\n" +
|
||||
"Render time: " + Number(renderMean.getMean()).toFixed(2) + " ms\n");
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user