JavaScript runtime.

Untested and there is no rendering.
This commit is contained in:
NathanSweet 2013-05-06 11:51:59 +02:00
parent ab54939e9b
commit ee9b65a6cc
2 changed files with 965 additions and 192 deletions

View File

@ -1 +1,803 @@
<script src="spine.js"></script>
<html>
<head>
<meta charset="UTF-8">
<title>spine-js</title>
<script src="spine.js" language="JavaScript"></script>
</head>
<body>
<script>
var json = new spine.SkeletonJson(function (skin, type, name) {
return new spine.RegionAttachment();
});
var skeletonData = json.readSkeletonData({
"bones": [
{ "name": "root" },
{ "name": "hip", "parent": "root", "x": 0.64, "y": 114.41 },
{ "name": "left upper leg", "parent": "hip", "length": 50.39, "x": 14.45, "y": 2.81, "rotation": -89.09 },
{ "name": "left lower leg", "parent": "left upper leg", "length": 56.45, "x": 51.78, "y": 3.46, "rotation": -16.65 },
{ "name": "left foot", "parent": "left lower leg", "length": 46.5, "x": 64.02, "y": -8.67, "rotation": 102.43 },
{ "name": "right upper leg", "parent": "hip", "length": 45.76, "x": -18.27, "rotation": -101.13 },
{ "name": "right lower leg", "parent": "right upper leg", "length": 58.52, "x": 50.21, "y": 0.6, "rotation": -10.7 },
{ "name": "right foot", "parent": "right lower leg", "length": 45.45, "x": 64.88, "y": 0.04, "rotation": 110.3 },
{ "name": "torso", "parent": "hip", "length": 85.82, "x": -6.42, "y": 1.97, "rotation": 94.95 },
{ "name": "neck", "parent": "torso", "length": 18.38, "x": 83.64, "y": -1.78, "rotation": 0.9 },
{ "name": "head", "parent": "neck", "length": 68.28, "x": 19.09, "y": 6.97, "rotation": -8.94 },
{ "name": "right shoulder", "parent": "torso", "length": 49.95, "x": 81.9, "y": 6.79, "rotation": 130.6 },
{ "name": "right arm", "parent": "right shoulder", "length": 36.74, "x": 49.95, "y": -0.12, "rotation": 40.12 },
{ "name": "right hand", "parent": "right arm", "length": 15.32, "x": 36.9, "y": 0.34, "rotation": 2.35 },
{ "name": "left shoulder", "parent": "torso", "length": 44.19, "x": 78.96, "y": -15.75, "rotation": -156.96 },
{ "name": "left arm", "parent": "left shoulder", "length": 35.62, "x": 44.19, "y": -0.01, "rotation": 28.16 },
{ "name": "left hand", "parent": "left arm", "length": 11.52, "x": 35.62, "y": 0.07, "rotation": 2.7 },
{ "name": "pelvis", "parent": "hip", "x": 1.41, "y": -6.57 }
],
"slots": [
{ "name": "left shoulder", "bone": "left shoulder", "attachment": "left-shoulder" },
{ "name": "left arm", "bone": "left arm", "attachment": "left-arm" },
{ "name": "left hand", "bone": "left hand", "attachment": "left-hand" },
{ "name": "left foot", "bone": "left foot", "attachment": "left-foot" },
{ "name": "left lower leg", "bone": "left lower leg", "attachment": "left-lower-leg" },
{ "name": "left upper leg", "bone": "left upper leg", "attachment": "left-upper-leg" },
{ "name": "pelvis", "bone": "pelvis", "attachment": "pelvis" },
{ "name": "right foot", "bone": "right foot", "attachment": "right-foot" },
{ "name": "right lower leg", "bone": "right lower leg", "attachment": "right-lower-leg" },
{ "name": "right upper leg", "bone": "right upper leg", "attachment": "right-upper-leg" },
{ "name": "torso", "bone": "torso", "attachment": "torso" },
{ "name": "neck", "bone": "neck", "attachment": "neck" },
{ "name": "head", "bone": "head", "attachment": "head" },
{ "name": "eyes", "bone": "head", "attachment": "eyes" },
{ "name": "right shoulder", "bone": "right shoulder", "attachment": "right-shoulder" },
{ "name": "right arm", "bone": "right arm", "attachment": "right-arm" },
{ "name": "right hand", "bone": "right hand", "attachment": "right-hand" }
],
"skins": {
"default": {
"left shoulder": {
"left-shoulder": { "x": 23.74, "y": 0.11, "rotation": 62.01, "width": 34, "height": 53 }
},
"left arm": {
"left-arm": { "x": 15.11, "y": -0.44, "rotation": 33.84, "width": 35, "height": 29 }
},
"left hand": {
"left-hand": { "x": 0.75, "y": 1.86, "rotation": 31.14, "width": 35, "height": 38 }
},
"left foot": {
"left-foot": { "x": 24.35, "y": 8.88, "rotation": 3.32, "width": 65, "height": 30 }
},
"left lower leg": {
"left-lower-leg": { "x": 24.55, "y": -1.92, "rotation": 105.75, "width": 49, "height": 64 }
},
"left upper leg": {
"left-upper-leg": { "x": 26.12, "y": -1.85, "rotation": 89.09, "width": 33, "height": 67 }
},
"pelvis": {
"pelvis": { "x": -4.83, "y": 10.62, "width": 63, "height": 47 }
},
"right foot": {
"right-foot": { "x": 19.02, "y": 8.47, "rotation": 1.52, "width": 67, "height": 30 }
},
"right lower leg": {
"right-lower-leg": { "x": 23.28, "y": -2.59, "rotation": 111.83, "width": 51, "height": 64 }
},
"right upper leg": {
"right-upper-leg": { "x": 23.03, "y": 0.25, "rotation": 101.13, "width": 44, "height": 70 }
},
"torso": {
"torso": { "x": 44.57, "y": -7.08, "rotation": -94.95, "width": 68, "height": 92 }
},
"neck": {
"neck": { "x": 9.42, "y": -3.66, "rotation": -100.15, "width": 34, "height": 28 }
},
"head": {
"head": { "x": 53.94, "y": -5.75, "rotation": -86.9, "width": 121, "height": 132 }
},
"eyes": {
"eyes": { "x": 28.94, "y": -32.92, "rotation": -86.9, "width": 34, "height": 27 },
"eyes-closed": { "x": 28.77, "y": -32.86, "rotation": -86.9, "width": 34, "height": 27 }
},
"right shoulder": {
"right-shoulder": { "x": 25.86, "y": 0.03, "rotation": 134.44, "width": 52, "height": 51 }
},
"right arm": {
"right-arm": { "x": 18.34, "y": -2.64, "rotation": 94.32, "width": 21, "height": 45 }
},
"right hand": {
"right-hand": { "x": 6.82, "y": 1.25, "rotation": 91.96, "width": 32, "height": 32 }
}
}
},
"animations": {
"walk": {
"bones": {
"left upper leg": {
"rotate": [
{ "time": 0, "angle": -26.55 },
{ "time": 0.1333, "angle": -8.78 },
{ "time": 0.2666, "angle": 9.51 },
{ "time": 0.4, "angle": 30.74 },
{ "time": 0.5333, "angle": 25.33 },
{ "time": 0.6666, "angle": 26.11 },
{ "time": 0.8, "angle": -7.7 },
{ "time": 0.9333, "angle": -21.19 },
{ "time": 1.0666, "angle": -26.55 }
],
"translate": [
{ "time": 0, "x": -3, "y": -2.25 },
{ "time": 0.4, "x": -2.18, "y": -2.25 },
{ "time": 1.0666, "x": -3, "y": -2.25 }
]
},
"right upper leg": {
"rotate": [
{ "time": 0, "angle": 42.45 },
{ "time": 0.1333, "angle": 52.1 },
{ "time": 0.2666, "angle": 5.96 },
{ "time": 0.5333, "angle": -16.93 },
{ "time": 0.6666, "angle": 1.89 },
{
"time": 0.8,
"angle": 28.06,
"curve": [ 0.462, 0.11, 1, 1 ]
},
{
"time": 0.9333,
"angle": 58.68,
"curve": [ 0.5, 0.02, 1, 1 ]
},
{ "time": 1.0666, "angle": 42.45 }
],
"translate": [
{ "time": 0, "x": 8.11, "y": -2.36 },
{ "time": 0.1333, "x": 10.03, "y": -2.56 },
{ "time": 0.4, "x": 2.76, "y": -2.97 },
{ "time": 0.5333, "x": 2.76, "y": -2.81 },
{ "time": 0.9333, "x": 8.67, "y": -2.54 },
{ "time": 1.0666, "x": 8.11, "y": -2.36 }
]
},
"left lower leg": {
"rotate": [
{ "time": 0, "angle": -10.21 },
{ "time": 0.1333, "angle": -55.64 },
{ "time": 0.2666, "angle": -68.12 },
{ "time": 0.5333, "angle": 5.11 },
{ "time": 0.6666, "angle": -28.29 },
{ "time": 0.8, "angle": 4.08 },
{ "time": 0.9333, "angle": 3.53 },
{ "time": 1.0666, "angle": -10.21 }
]
},
"left foot": {
"rotate": [
{ "time": 0, "angle": -3.69 },
{ "time": 0.1333, "angle": -10.42 },
{ "time": 0.2666, "angle": -17.14 },
{ "time": 0.4, "angle": -2.83 },
{ "time": 0.5333, "angle": -3.87 },
{ "time": 0.6666, "angle": 2.78 },
{ "time": 0.8, "angle": 1.68 },
{ "time": 0.9333, "angle": -8.54 },
{ "time": 1.0666, "angle": -3.69 }
]
},
"right shoulder": {
"rotate": [
{
"time": 0,
"angle": 20.89,
"curve": [ 0.264, 0, 0.75, 1 ]
},
{
"time": 0.1333,
"angle": 3.72,
"curve": [ 0.272, 0, 0.841, 1 ]
},
{ "time": 0.6666, "angle": -278.28 },
{ "time": 1.0666, "angle": 20.89 }
],
"translate": [
{ "time": 0, "x": -7.84, "y": 7.19 },
{ "time": 0.1333, "x": -6.36, "y": 6.42 },
{ "time": 0.6666, "x": -11.07, "y": 5.25 },
{ "time": 1.0666, "x": -7.84, "y": 7.19 }
]
},
"right arm": {
"rotate": [
{
"time": 0,
"angle": -4.02,
"curve": [ 0.267, 0, 0.804, 0.99 ]
},
{
"time": 0.1333,
"angle": -13.99,
"curve": [ 0.341, 0, 1, 1 ]
},
{
"time": 0.6666,
"angle": 36.54,
"curve": [ 0.307, 0, 0.787, 0.99 ]
},
{ "time": 1.0666, "angle": -4.02 }
]
},
"right hand": {
"rotate": [
{ "time": 0, "angle": 22.92 },
{ "time": 0.4, "angle": -8.97 },
{ "time": 0.6666, "angle": 0.51 },
{ "time": 1.0666, "angle": 22.92 }
]
},
"left shoulder": {
"rotate": [
{ "time": 0, "angle": -1.47 },
{ "time": 0.1333, "angle": 13.6 },
{ "time": 0.6666, "angle": 280.74 },
{ "time": 1.0666, "angle": -1.47 }
],
"translate": [
{ "time": 0, "x": -1.76, "y": 0.56 },
{ "time": 0.6666, "x": -2.47, "y": 8.14 },
{ "time": 1.0666, "x": -1.76, "y": 0.56 }
]
},
"left hand": {
"rotate": [
{
"time": 0,
"angle": 11.58,
"curve": [ 0.169, 0.37, 0.632, 1.55 ]
},
{
"time": 0.1333,
"angle": 28.13,
"curve": [ 0.692, 0, 0.692, 0.99 ]
},
{
"time": 0.6666,
"angle": -27.42,
"curve": [ 0.117, 0.41, 0.738, 1.76 ]
},
{ "time": 0.8, "angle": -36.32 },
{ "time": 1.0666, "angle": 11.58 }
]
},
"left arm": {
"rotate": [
{ "time": 0, "angle": -8.27 },
{ "time": 0.1333, "angle": 18.43 },
{ "time": 0.6666, "angle": 0.88 },
{ "time": 1.0666, "angle": -8.27 }
]
},
"torso": {
"rotate": [
{ "time": 0, "angle": -10.28 },
{
"time": 0.1333,
"angle": -15.38,
"curve": [ 0.545, 0, 1, 1 ]
},
{
"time": 0.4,
"angle": -9.78,
"curve": [ 0.58, 0.17, 1, 1 ]
},
{ "time": 0.6666, "angle": -15.75 },
{ "time": 0.9333, "angle": -7.06 },
{ "time": 1.0666, "angle": -10.28 }
],
"translate": [
{ "time": 0, "x": -3.67, "y": 1.68 },
{ "time": 0.1333, "x": -3.67, "y": 0.68 },
{ "time": 0.4, "x": -3.67, "y": 1.97 },
{ "time": 0.6666, "x": -3.67, "y": -0.14 },
{ "time": 1.0666, "x": -3.67, "y": 1.68 }
]
},
"right foot": {
"rotate": [
{ "time": 0, "angle": -5.25 },
{ "time": 0.2666, "angle": -4.08 },
{ "time": 0.4, "angle": -6.45 },
{ "time": 0.5333, "angle": -5.39 },
{ "time": 0.8, "angle": -11.68 },
{ "time": 0.9333, "angle": 0.46 },
{ "time": 1.0666, "angle": -5.25 }
]
},
"right lower leg": {
"rotate": [
{ "time": 0, "angle": -3.39 },
{ "time": 0.1333, "angle": -45.53 },
{ "time": 0.2666, "angle": -2.59 },
{ "time": 0.5333, "angle": -19.53 },
{ "time": 0.6666, "angle": -64.8 },
{
"time": 0.8,
"angle": -82.56,
"curve": [ 0.557, 0.18, 1, 1 ]
},
{ "time": 1.0666, "angle": -3.39 }
]
},
"hip": {
"rotate": [
{ "time": 0, "angle": 0, "curve": "stepped" },
{ "time": 1.0666, "angle": 0 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0 },
{
"time": 0.1333,
"x": 0,
"y": -7.61,
"curve": [ 0.272, 0.86, 1, 1 ]
},
{ "time": 0.4, "x": 0, "y": 8.7 },
{ "time": 0.5333, "x": 0, "y": -0.41 },
{
"time": 0.6666,
"x": 0,
"y": -7.05,
"curve": [ 0.235, 0.89, 1, 1 ]
},
{ "time": 0.8, "x": 0, "y": 2.92 },
{ "time": 0.9333, "x": 0, "y": 6.78 },
{ "time": 1.0666, "x": 0, "y": 0 }
]
},
"neck": {
"rotate": [
{ "time": 0, "angle": 3.6 },
{ "time": 0.1333, "angle": 17.49 },
{ "time": 0.2666, "angle": 6.1 },
{ "time": 0.4, "angle": 3.45 },
{ "time": 0.5333, "angle": 5.17 },
{ "time": 0.6666, "angle": 18.36 },
{ "time": 0.8, "angle": 6.09 },
{ "time": 0.9333, "angle": 2.28 },
{ "time": 1.0666, "angle": 3.6 }
]
},
"head": {
"rotate": [
{
"time": 0,
"angle": 3.6,
"curve": [ 0, 0, 0.704, 1.61 ]
},
{ "time": 0.1666, "angle": -0.2 },
{ "time": 0.2666, "angle": 6.1 },
{ "time": 0.4, "angle": 3.45 },
{
"time": 0.5333,
"angle": 5.17,
"curve": [ 0, 0, 0.704, 1.61 ]
},
{ "time": 0.7, "angle": 1.1 },
{ "time": 0.8, "angle": 6.09 },
{ "time": 0.9333, "angle": 2.28 },
{ "time": 1.0666, "angle": 3.6 }
]
}
}
},
"jump": {
"bones": {
"hip": {
"rotate": [
{ "time": 0, "angle": 0, "curve": "stepped" },
{ "time": 0.9333, "angle": 0, "curve": "stepped" },
{ "time": 1.3666, "angle": 0 }
],
"translate": [
{ "time": 0, "x": -11.57, "y": -3 },
{ "time": 0.2333, "x": -16.2, "y": -19.43 },
{
"time": 0.3333,
"x": 7.66,
"y": -8.48,
"curve": [ 0.057, 0.06, 0.712, 1 ]
},
{ "time": 0.3666, "x": 15.38, "y": 5.01 },
{ "time": 0.4666, "x": -7.84, "y": 57.22 },
{
"time": 0.6,
"x": -10.81,
"y": 96.34,
"curve": [ 0.241, 0, 1, 1 ]
},
{ "time": 0.7333, "x": -7.01, "y": 54.7 },
{ "time": 0.8, "x": -10.58, "y": 32.2 },
{ "time": 0.9333, "x": -31.99, "y": 0.45 },
{ "time": 1.0666, "x": -12.48, "y": -29.47 },
{ "time": 1.3666, "x": -11.57, "y": -3 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"left upper leg": {
"rotate": [
{ "time": 0, "angle": 17.13 },
{ "time": 0.2333, "angle": 44.35 },
{ "time": 0.3333, "angle": 16.46 },
{ "time": 0.4, "angle": -9.88 },
{ "time": 0.4666, "angle": -11.42 },
{ "time": 0.5666, "angle": 23.46 },
{ "time": 0.7666, "angle": 71.82 },
{ "time": 0.9333, "angle": 65.53 },
{ "time": 1.0666, "angle": 51.01 },
{ "time": 1.3666, "angle": 17.13 }
],
"translate": [
{ "time": 0, "x": -3, "y": -2.25, "curve": "stepped" },
{ "time": 0.9333, "x": -3, "y": -2.25, "curve": "stepped" },
{ "time": 1.3666, "x": -3, "y": -2.25 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"left lower leg": {
"rotate": [
{ "time": 0, "angle": -16.25 },
{ "time": 0.2333, "angle": -52.21 },
{ "time": 0.4, "angle": 15.04 },
{ "time": 0.4666, "angle": -8.95 },
{ "time": 0.5666, "angle": -39.53 },
{ "time": 0.7666, "angle": -27.27 },
{ "time": 0.9333, "angle": -3.52 },
{ "time": 1.0666, "angle": -61.92 },
{ "time": 1.3666, "angle": -16.25 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"left foot": {
"rotate": [
{ "time": 0, "angle": 0.33 },
{ "time": 0.2333, "angle": 6.2 },
{ "time": 0.3333, "angle": 14.73 },
{ "time": 0.4, "angle": -15.54 },
{ "time": 0.4333, "angle": -21.2 },
{ "time": 0.5666, "angle": -7.55 },
{ "time": 0.7666, "angle": -0.67 },
{ "time": 0.9333, "angle": -0.58 },
{ "time": 1.0666, "angle": 14.64 },
{ "time": 1.3666, "angle": 0.33 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"right upper leg": {
"rotate": [
{ "time": 0, "angle": 25.97 },
{ "time": 0.2333, "angle": 46.43 },
{ "time": 0.3333, "angle": 22.61 },
{ "time": 0.4, "angle": 2.13 },
{
"time": 0.4666,
"angle": 0.04,
"curve": [ 0, 0, 0.637, 0.98 ]
},
{ "time": 0.6, "angle": 65.55 },
{ "time": 0.7666, "angle": 64.93 },
{ "time": 0.9333, "angle": 41.08 },
{ "time": 1.0666, "angle": 66.25 },
{ "time": 1.3666, "angle": 25.97 }
],
"translate": [
{ "time": 0, "x": 5.74, "y": 0.61 },
{ "time": 0.2333, "x": 4.79, "y": 1.79 },
{ "time": 0.3333, "x": 6.05, "y": -4.55 },
{ "time": 0.9333, "x": 4.79, "y": 1.79, "curve": "stepped" },
{ "time": 1.0666, "x": 4.79, "y": 1.79 },
{ "time": 1.3666, "x": 5.74, "y": 0.61 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"right lower leg": {
"rotate": [
{ "time": 0, "angle": -27.46 },
{ "time": 0.2333, "angle": -64.03 },
{ "time": 0.4, "angle": -48.36 },
{ "time": 0.5666, "angle": -76.86 },
{ "time": 0.7666, "angle": -26.89 },
{ "time": 0.9, "angle": -18.97 },
{ "time": 0.9333, "angle": -14.18 },
{ "time": 1.0666, "angle": -80.45 },
{ "time": 1.3666, "angle": -27.46 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"right foot": {
"rotate": [
{ "time": 0, "angle": 1.08 },
{ "time": 0.2333, "angle": 16.02 },
{ "time": 0.3, "angle": 12.94 },
{ "time": 0.3333, "angle": 15.16 },
{ "time": 0.4, "angle": -14.7 },
{ "time": 0.4333, "angle": -12.85 },
{ "time": 0.4666, "angle": -19.18 },
{ "time": 0.5666, "angle": -15.82 },
{ "time": 0.6, "angle": -3.59 },
{ "time": 0.7666, "angle": -3.56 },
{ "time": 0.9333, "angle": 1.86 },
{ "time": 1.0666, "angle": 16.02 },
{ "time": 1.3666, "angle": 1.08 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"torso": {
"rotate": [
{ "time": 0, "angle": -13.35 },
{ "time": 0.2333, "angle": -48.95 },
{ "time": 0.4333, "angle": -35.77 },
{ "time": 0.6, "angle": -4.59 },
{ "time": 0.7666, "angle": 14.61 },
{ "time": 0.9333, "angle": 15.74 },
{ "time": 1.0666, "angle": -32.44 },
{ "time": 1.3666, "angle": -13.35 }
],
"translate": [
{ "time": 0, "x": -3.67, "y": 1.68, "curve": "stepped" },
{ "time": 0.9333, "x": -3.67, "y": 1.68, "curve": "stepped" },
{ "time": 1.3666, "x": -3.67, "y": 1.68 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"neck": {
"rotate": [
{ "time": 0, "angle": 12.78 },
{ "time": 0.2333, "angle": 16.46 },
{ "time": 0.4, "angle": 26.49 },
{ "time": 0.6, "angle": 15.51 },
{ "time": 0.7666, "angle": 1.34 },
{ "time": 0.9333, "angle": 2.35 },
{ "time": 1.0666, "angle": 6.08 },
{ "time": 1.3, "angle": 21.23 },
{ "time": 1.3666, "angle": 12.78 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"head": {
"rotate": [
{ "time": 0, "angle": 5.19 },
{ "time": 0.2333, "angle": 20.27 },
{ "time": 0.4, "angle": 15.27 },
{ "time": 0.6, "angle": -24.69 },
{ "time": 0.7666, "angle": -11.02 },
{ "time": 0.9333, "angle": -24.38 },
{ "time": 1.0666, "angle": 11.99 },
{ "time": 1.3, "angle": 4.86 },
{ "time": 1.3666, "angle": 5.19 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"left shoulder": {
"rotate": [
{
"time": 0,
"angle": 0.05,
"curve": [ 0, 0, 0.62, 1 ]
},
{
"time": 0.2333,
"angle": 279.66,
"curve": [ 0.218, 0.67, 0.66, 0.99 ]
},
{
"time": 0.5,
"angle": 62.27,
"curve": [ 0.462, 0, 0.764, 0.58 ]
},
{ "time": 0.9333, "angle": 28.91 },
{ "time": 1.0666, "angle": -8.62 },
{ "time": 1.1666, "angle": -18.43 },
{ "time": 1.3666, "angle": 0.05 }
],
"translate": [
{ "time": 0, "x": -1.76, "y": 0.56, "curve": "stepped" },
{ "time": 0.9333, "x": -1.76, "y": 0.56, "curve": "stepped" },
{ "time": 1.3666, "x": -1.76, "y": 0.56 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"left hand": {
"rotate": [
{ "time": 0, "angle": 11.58, "curve": "stepped" },
{ "time": 0.9333, "angle": 11.58, "curve": "stepped" },
{ "time": 1.3666, "angle": 11.58 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"left arm": {
"rotate": [
{ "time": 0, "angle": 0.51 },
{ "time": 0.4333, "angle": 12.82 },
{ "time": 0.6, "angle": 47.55 },
{ "time": 0.9333, "angle": 12.82 },
{ "time": 1.1666, "angle": -6.5 },
{ "time": 1.3666, "angle": 0.51 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"right shoulder": {
"rotate": [
{
"time": 0,
"angle": 43.82,
"curve": [ 0, 0, 0.62, 1 ]
},
{
"time": 0.2333,
"angle": -8.74,
"curve": [ 0.304, 0.58, 0.709, 0.97 ]
},
{
"time": 0.5333,
"angle": -208.02,
"curve": [ 0.462, 0, 0.764, 0.58 ]
},
{ "time": 0.9333, "angle": -246.72 },
{ "time": 1.0666, "angle": -307.13 },
{ "time": 1.1666, "angle": 37.15 },
{ "time": 1.3666, "angle": 43.82 }
],
"translate": [
{ "time": 0, "x": -7.84, "y": 7.19, "curve": "stepped" },
{ "time": 0.9333, "x": -7.84, "y": 7.19, "curve": "stepped" },
{ "time": 1.3666, "x": -7.84, "y": 7.19 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"right arm": {
"rotate": [
{ "time": 0, "angle": -4.02 },
{ "time": 0.6, "angle": 17.5 },
{ "time": 0.9333, "angle": -4.02 },
{ "time": 1.1666, "angle": -16.72 },
{ "time": 1.3666, "angle": -4.02 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"right hand": {
"rotate": [
{ "time": 0, "angle": 22.92, "curve": "stepped" },
{ "time": 0.9333, "angle": 22.92, "curve": "stepped" },
{ "time": 1.3666, "angle": 22.92 }
],
"translate": [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 0.9333, "x": 0, "y": 0, "curve": "stepped" },
{ "time": 1.3666, "x": 0, "y": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 0.9333, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
},
"root": {
"rotate": [
{ "time": 0, "angle": 0 },
{ "time": 0.4333, "angle": -14.52 },
{ "time": 0.8, "angle": 9.86 },
{ "time": 1.3666, "angle": 0 }
],
"scale": [
{ "time": 0, "x": 1, "y": 1, "curve": "stepped" },
{ "time": 1.3666, "x": 1, "y": 1 }
]
}
}
}
}
});
</script>
</body>
</html>

View File

@ -120,10 +120,10 @@ spine.Skin = function (name) {
};
spine.Skin.prototype = {
addAttachment: function (slotIndex, name, attachment) {
attachments[slotIndex + ":" + name] = attachment;
this.attachments[slotIndex + ":" + name] = attachment;
},
getAttachment: function (slotIndex, name) {
return attachments[slotIndex + ":" + name];
return this.attachments[slotIndex + ":" + name];
},
_attachAll: function (skeleton, oldSkin) {
for (var key in oldSkin.attachments) {
@ -143,7 +143,7 @@ spine.Animation = function (name, timelines, duration) {
this.name = name;
this.timelines = timelines;
this.duration = duration;
}
};
spine.Animation.prototype = {
apply: function (skeleton, time, loop) {
if (loop && this.duration != 0) time %= this.duration;
@ -170,17 +170,17 @@ spine.binarySearch = function (values, target, step) {
if (low == high) return (low + 1) * step;
current = (low + high) >>> 1;
}
}
};
spine.linearSearch = function (values, target, step) {
for (var i = 0, last = values.length - step; i <= last; i += step)
if (values[i] > target) return i;
return -1;
}
};
spine.Curves = function (frameCount) {
this.curves = []; // dfx, dfy, ddfx, ddfy, dddfx, dddfy, ...
this.curves.length = (frameCount - 1) * 6;
}
};
spine.Curves.prototype = {
setLinear: function (frameIndex) {
this.curves[frameIndex * 6] = 0/*LINEAR*/;
@ -243,13 +243,13 @@ spine.Curves.prototype = {
}
return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1.
}
}
};
spine.RotateTimeline = function (frameCount) {
this.curves = new Curves(frameCount);
this.curves = new spine.Curves(frameCount);
this.frames = []; // time, angle, ...
this.frames.length = frameCount * 2;
}
};
spine.RotateTimeline.prototype = {
boneIndex: 0,
getFrameCount: function () {
@ -295,13 +295,13 @@ spine.RotateTimeline.prototype = {
amount += 360;
bone.rotation += amount * alpha;
}
}
};
spine.TranslateTimeline = function (frameCount) {
this.curves = new Curves(frameCount);
this.curves = new spine.Curves(frameCount);
this.frames = []; // time, x, y, ...
this.frames.length = frameCount * 3;
}
};
spine.TranslateTimeline.prototype = {
boneIndex: 0,
getFrameCount: function () {
@ -336,13 +336,13 @@ spine.TranslateTimeline.prototype = {
bone.x += (bone.data.x + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.x) * alpha;
bone.y += (bone.data.y + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.y) * alpha;
}
}
};
spine.ScaleTimeline = function (frameCount) {
this.curves = new Curves(frameCount);
this.curves = new spine.Curves(frameCount);
this.frames = []; // time, x, y, ...
this.frames.length = frameCount * 3;
}
};
spine.ScaleTimeline.prototype = {
boneIndex: 0,
getFrameCount: function () {
@ -377,13 +377,13 @@ spine.ScaleTimeline.prototype = {
bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.scaleY) * alpha;
}
}
};
spine.ColorTimeline = function (frameCount) {
this.curves = new Curves(frameCount);
this.curves = new spine.Curves(frameCount);
this.frames = []; // time, r, g, b, a, ...
this.frames.length = frameCount * 5;
}
};
spine.ColorTimeline.prototype = {
slotIndex: 0,
getFrameCount: function () {
@ -438,15 +438,15 @@ spine.ColorTimeline.prototype = {
slot.a = a;
}
}
}
};
spine.AttachmentTimeline = function (frameCount) {
this.curves = new Curves(frameCount);
this.curves = new spine.Curves(frameCount);
this.frames = []; // time, ...
this.frames.length = frameCount;
this.attachmentNames = []; // time, ...
this.attachmentNames.length = frameCount;
}
};
spine.AttachmentTimeline.prototype = {
slotIndex: 0,
getFrameCount: function () {
@ -469,28 +469,28 @@ spine.AttachmentTimeline.prototype = {
var attachmentName = this.attachmentNames[frameIndex];
skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
}
}
};
spine.SkeletonData = function () {
this.bones = [];
this.slots = [];
this.skins = [];
this.animations = [];
}
};
spine.SkeletonData.prototype = {
defaultSkin: null,
/** @return May be null. */
findBone: function (boneName) {
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++)
if (bones[i] == boneName) return bones[i];
if (bones[i].name == boneName) return bones[i];
return null;
},
/** @return -1 if the bone was not found. */
findBoneIndex: function (boneName) {
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++)
if (bones[i] == boneName) return i;
if (bones[i].name == boneName) return i;
return -1;
},
/** @return May be null. */
@ -505,7 +505,7 @@ spine.SkeletonData.prototype = {
findSlotIndex: function (slotName) {
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++)
if (slots.get(i).name == slotName) return i;
if (slots[i].name == slotName) return i;
return -1;
},
/** @return May be null. */
@ -522,7 +522,7 @@ spine.SkeletonData.prototype = {
if (animations[i].name == animationName) return animations[i];
return null;
}
}
};
spine.Skeleton = function (skeletonData) {
this.data = skeletonData;
@ -531,7 +531,7 @@ spine.Skeleton = function (skeletonData) {
for (var i = 0, n = skeletonData.bones.length; i < n; i++) {
var boneData = skeletonData.bones[i];
var parent = !boneData.parent ? null : bones[skeletonData.bones.indexOf(boneData.parent)];
bones.push(new Bone(boneData, parent));
bones.push(new spine.Bone(boneData, parent));
}
this.slots = [];
@ -539,11 +539,11 @@ spine.Skeleton = function (skeletonData) {
for (var i = 0, n = skeletonData.slots.length; i < n; i++) {
var slotData = skeletonData.slots[i];
var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)];
var slot = new Slot(slotData, this, bone);
var slot = new spine.Slot(slotData, this, bone);
slots.push(slot);
drawOrder.push(slot);
}
}
};
spine.Skeleton.prototype = {
skin: null,
r: 1, g: 1, b: 1, a: 1,
@ -649,46 +649,24 @@ spine.Skeleton.prototype = {
update: function (delta) {
time += delta;
}
}
};
spine.AttachmentType = {
region: 0
};
public class AttachmentType {
public static const region:AttachmentType = new AttachmentType(0, "region");
public static const regionSequence:AttachmentType = new AttachmentType(1, "regionSequence");
public var ordinal:int;
public var name:String;
public function AttachmentType (ordinal:int, name:String) {
this.ordinal = ordinal;
this.name = name;
}
static public function valueOf (name:String) : AttachmentType {
switch (name) {
case "region":
return region;
case "regionSequence":
return regionSequence;
}
return null;
}
}
spine.RegionAttachment = function () {
this.offset = [];
this.offset.length = 8;
this.uvs = [];
this.uvs.length = 8;
}
};
spine.RegionAttachment.prototype = {
x: 0, y: 0,
rotation: 0,
scaleX: 1, scaleY: 1,
width: 0, height: 0,
texture: null,
rendererObject: null,
regionOffsetX: 0, regionOffsetY: 0,
regionWidth: 0, regionHeight: 0,
regionOriginalWidth: 0, regionOriginalHeight: 0,
@ -714,13 +692,13 @@ spine.RegionAttachment.prototype = {
}
},
updateOffset: function () {
var regionScaleX = this.width / regionOriginalWidth * this.scaleX;
var regionScaleY = this.height / regionOriginalHeight * this.scaleY;
var localX = -this.width / 2 * this.scaleX + regionOffsetX * regionScaleX;
var localY = -this.height / 2 * this.scaleY + regionOffsetY * regionScaleY;
var localX2 = localX + regionWidth * regionScaleX;
var localY2 = localY + regionHeight * regionScaleY;
var radians = rotation * Math.PI / 180;
var regionScaleX = this.width / this.regionOriginalWidth * this.scaleX;
var regionScaleY = this.height / this.regionOriginalHeight * this.scaleY;
var localX = -this.width / 2 * this.scaleX + this.regionOffsetX * regionScaleX;
var localY = -this.height / 2 * this.scaleY + this.regionOffsetY * regionScaleY;
var localX2 = localX + this.regionWidth * regionScaleX;
var localY2 = localY + this.regionHeight * regionScaleY;
var radians = this.rotation * Math.PI / 180;
var cos = Math.cos(radians);
var sin = Math.sin(radians);
var localXCos = localX * cos + this.x;
@ -764,7 +742,7 @@ spine.RegionAttachment.prototype = {
spine.AnimationStateData = function (skeletonData) {
this.skeletonData = skeletonData;
this.animationToMixTime = {};
}
};
spine.AnimationStateData.prototype = {
setMixByName: function (fromName, toName, duration) {
var from = this.skeletonData.findAnimation(fromName);
@ -780,12 +758,12 @@ spine.AnimationStateData.prototype = {
var time = animationToMixTime[from.name + ":" + to.name];
return time ? time : 0;
}
}
};
spine.AnimationState = function (stateData) {
this.data = stateData;
this.queue = [];
}
};
spine.AnimationState.prototype = {
current: null,
previous: null,
@ -881,15 +859,15 @@ spine.AnimationState.prototype = {
isComplete: function () {
return !this.current || this.currentTime >= this.current.duration;
}
}
};
spine.SkeletonJson = function (attachmentLoader) {
this.attachmentLoader = attachmentLoader;
}
};
spine.SkeletonJson.prototype = {
scale: 1,
readSkeletonData: function (json) {
var skeletonData = new SkeletonData();
readSkeletonData: function (root) {
var skeletonData = new spine.SkeletonData();
// Bones.
var bones = root["bones"];
@ -900,7 +878,7 @@ spine.SkeletonJson.prototype = {
parent = skeletonData.findBone(boneMap["parent"]);
if (!parent) throw "Parent bone not found: " + boneMap["parent"];
}
var boneData = new BoneData(boneMap["name"], parent);
var boneData = new spine.BoneData(boneMap["name"], parent);
boneData.length = (boneMap["length"] || 0) * this.scale;
boneData.x = (boneMap["x"] || 0) * this.scale;
boneData.y = (boneMap["y"] || 0) * this.scale;
@ -916,19 +894,19 @@ spine.SkeletonJson.prototype = {
var slotMap = slots[i];
var boneData = skeletonData.findBone(slotMap["bone"]);
if (!boneData) throw "Slot bone not found: " + slotMap["bone"];
var slotData = new SlotData(slotMap["name"], boneData);
var slotData = new spine.SlotData(slotMap["name"], boneData);
var color = slotMap["color"];
if (color) {
slotData.r = toColor(color, 0);
slotData.g = toColor(color, 1);
slotData.b = toColor(color, 2);
slotData.a = toColor(color, 3);
slotData.r = spine.SkeletonJson.toColor(color, 0);
slotData.g = spine.SkeletonJson.toColor(color, 1);
slotData.b = spine.SkeletonJson.toColor(color, 2);
slotData.a = spine.SkeletonJson.toColor(color, 3);
}
slotData.attachmentName = slotMap["attachment"];
skeletonData.addSlot(slotData);
skeletonData.slots.push(slotData);
}
// Skins.
@ -936,14 +914,14 @@ spine.SkeletonJson.prototype = {
for (var skinName in skins) {
if (!skins.hasOwnProperty(skinName)) continue;
var skinMap = skins[skinName];
var skin = new Skin(skinName);
var skin = new spine.Skin(skinName);
for (var slotName in skinMap) {
if (!skinMap.hasOwnProperty(slotName)) continue;
var slotIndex = skeletonData.findSlotIndex(slotName);
var slotEntry = skinMap[slotName];
for (var attachmentName in slotEntry) {
if (!slotEntry.hasOwnProperty(attachmentName)) continue;
var attachment = readAttachment(skin, attachmentName, slotEntry[attachmentName]);
var attachment = this.readAttachment(skin, attachmentName, slotEntry[attachmentName]);
if (attachment != null) skin.addAttachment(slotIndex, attachmentName, attachment);
}
}
@ -955,7 +933,7 @@ spine.SkeletonJson.prototype = {
var animations = root["animations"];
for (var animationName in animations) {
if (!animations.hasOwnProperty(animationName)) continue;
readAnimation(animationName, animations[animationName], skeletonData);
this.readAnimation(animationName, animations[animationName], skeletonData);
}
return skeletonData;
@ -963,142 +941,135 @@ spine.SkeletonJson.prototype = {
readAttachment: function (skin, name, map) {
name = map["name"] || name;
var type = AttachmentType.valueOf(map["type"] || "region");
var attachment:Attachment = attachmentLoader.newAttachment(skin, type, name);
var type = spine.AttachmentType[map["type"] || "region"];
var attachment = this.attachmentLoader(skin, type, name);
if (attachment is RegionAttachment) {
var regionAttachment:RegionAttachment = attachment as RegionAttachment;
regionAttachment.x = (map["x"] || 0) * scale;
regionAttachment.y = (map["y"] || 0) * scale;
regionAttachment.scaleX = map["scaleX"] || 1;
regionAttachment.scaleY = map["scaleY"] || 1;
regionAttachment.rotation = map["rotation"] || 0;
regionAttachment.width = (map["width"] || 32) * scale;
regionAttachment.height = (map["height"] || 32) * scale;
regionAttachment.updateOffset();
if (type == spine.AttachmentType.region) {
attachment.x = (map["x"] || 0) * this.scale;
attachment.y = (map["y"] || 0) * this.scale;
attachment.scaleX = map["scaleX"] || 1;
attachment.scaleY = map["scaleY"] || 1;
attachment.rotation = map["rotation"] || 0;
attachment.width = (map["width"] || 32) * this.scale;
attachment.height = (map["height"] || 32) * this.scale;
attachment.updateOffset();
}
return attachment;
}
},
readAnimation: function (name, map, skeletonData) {
var timelines = [];
var duration = 0;
private function readAnimation (name:String, map:Object, skeletonData:SkeletonData) : void {
var timelines:Vector.<Timeline> = new Vector.<Timeline>();
var duration:Number = 0;
var bones = map["bones"];
for (var boneName in bones) {
if (!bones.hasOwnProperty(boneName)) continue;
var boneIndex = skeletonData.findBoneIndex(boneName);
if (boneIndex == -1) throw "Bone not found: " + boneName;
var boneMap = bones[boneName];
var bones:Object = map["bones"];
for (var boneName:String in bones) {
var boneIndex:int = skeletonData.findBoneIndex(boneName);
if (boneIndex == -1)
throw new Error("Bone not found: " + boneName);
var boneMap:Object = bones[boneName];
for (var timelineName:Object in boneMap) {
var timelineMap:Object = boneMap[timelineName];
if (timelineName == TIMELINE_ROTATE) {
var timeline:RotateTimeline = new RotateTimeline(count(timelineMap));
for (var timelineName in boneMap) {
if (!boneMap.hasOwnProperty(timelineName)) continue;
var values = boneMap[timelineName];
if (timelineName == "rotate") {
var timeline = new spine.RotateTimeline(values.length);
timeline.boneIndex = boneIndex;
var frameIndex:int = 0;
for each (var valueMap:Object in timelineMap) {
var frameIndex = 0;
for (var i = 0, n = values.length; i < n; i++) {
var valueMap = values[i];
timeline.setFrame(frameIndex, valueMap["time"], valueMap["angle"]);
readCurve(timeline, frameIndex, valueMap);
spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.frameCount * 2 - 2]);
} else if (timelineName == TIMELINE_TRANSLATE || timelineName == TIMELINE_SCALE) {
var timeline1:TranslateTimeline;
var timelineScale:Number = 1;
if (timelineName == TIMELINE_SCALE)
timeline1 = new ScaleTimeline(count(timelineMap));
} else if (timelineName == "translate" || timelineName == "scale") {
var timeline;
var timelineScale = 1;
if (timelineName == "scale")
timeline = new spine.ScaleTimeline(values.length);
else {
timeline1 = new TranslateTimeline(count(timelineMap));
timelineScale = scale;
timeline = new spine.TranslateTimeline(values.length);
timelineScale = this.scale;
}
timeline1.boneIndex = boneIndex;
timeline.boneIndex = boneIndex;
var frameIndex1:int = 0;
for each (var valueMap1:Object in timelineMap) {
var x:Number = (valueMap1["x"] || 0) * timelineScale;
var y:Number = (valueMap1["y"] || 0) * timelineScale;
timeline1.setFrame(frameIndex1, valueMap1["time"], x, y);
readCurve(timeline1, frameIndex1, valueMap1);
frameIndex1++;
}
timelines.push(timeline1);
duration = Math.max(duration, timeline1.frames[timeline1.frameCount * 3 - 3]);
} else
throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
}
}
var slots:Object = map["slots"];
for (var slotName:String in slots) {
var slotMap:Object = slots[slotName];
var slotIndex:int = skeletonData.findSlotIndex(slotName);
for (var timelineName2:Object in boneMap) {
var timelineMap2:Object = boneMap[timelineName2];
if (timelineName2 == TIMELINE_COLOR) {
var timeline2:ColorTimeline = new ColorTimeline(count(timelineMap2));
timeline2.slotIndex = slotIndex;
var frameIndex2:int = 0;
for each (var valueMap2:Object in timelineMap2) {
var color:String = valueMap["color"];
var r:Number = toColor(color, 0);
var g:Number = toColor(color, 1);
var b:Number = toColor(color, 2);
var a:Number = toColor(color, 3);
timeline2.setFrame(frameIndex2, valueMap2["time"], r, g, b, a);
readCurve(timeline2, frameIndex2, valueMap);
frameIndex2++;
}
timelines.push(timeline2);
duration = Math.max(duration, timeline2.frames[timeline2.frameCount * 5 - 5]);
} else if (timelineName2 == TIMELINE_ATTACHMENT) {
var timeline3:AttachmentTimeline = new AttachmentTimeline(count(timelineMap2));
timeline3.slotIndex = slotIndex;
var frameIndex3:int = 0;
for each (var valueMap3:Object in timelineMap2) {
timeline3.setFrame(frameIndex3++, valueMap3["time"], valueMap3["name"]);
var frameIndex = 0;
for (var i = 0, n = values.length; i < n; i++) {
var valueMap = values[i];
var x = (valueMap["x"] || 0) * timelineScale;
var y = (valueMap["y"] || 0) * timelineScale;
timeline.setFrame(frameIndex, valueMap["time"], x, y);
spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline3.frames[timeline3.frameCount - 1]);
duration = Math.max(duration, timeline.frames[timeline.frameCount * 3 - 3]);
} else
throw new Error("Invalid timeline type for a slot: " + timelineName2 + " (" + slotName + ")");
throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")";
}
}
skeletonData.addAnimation(new Animation(name, timelines, duration));
}
var slots = map["slots"];
for (var slotName in slots) {
if (!slots.hasOwnProperty(slotName)) continue;
var slotMap = slots[slotName];
var slotIndex = skeletonData.findSlotIndex(slotName);
private function readCurve (timeline:CurveTimeline, frameIndex:int, valueMap:Object) : void {
var curve:Object = valueMap["curve"];
if (curve == null)
return;
if (curve == "stepped")
timeline.setStepped(frameIndex);
else if (curve is Array) {
timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]);
for (var timelineName in boneMap) {
if (!boneMap.hasOwnProperty(timelineName)) continue;
var values = boneMap[timelineName2];
if (timelineName == "color") {
var timeline = new spine.ColorTimeline(values.length);
timeline.slotIndex = slotIndex;
var frameIndex = 0;
for (var i = 0, n = values.length; i < n; i++) {
var valueMap = values[i];
var color = valueMap["color"];
var r = spine.SkeletonJson.toColor(color, 0);
var g = spine.SkeletonJson.toColor(color, 1);
var b = spine.SkeletonJson.toColor(color, 2);
var a = spine.SkeletonJson.toColor(color, 3);
timeline.setFrame(frameIndex, valueMap["time"], r, g, b, a);
spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.frameCount * 5 - 5]);
} else if (timelineName == "attachment") {
var timeline = new spine.AttachmentTimeline(values.length);
timeline.slotIndex = slotIndex;
var frameIndex = 0;
for (var i = 0, n = values.length; i < n; i++) {
var valueMap = values[i];
timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.frameCount - 1]);
} else
throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")";
}
}
}
static private function toColor (hexString:String, colorIndex:int) : Number {
if (hexString.length != 8)
throw new ArgumentError("Color hexidecimal length must be 8, recieved: " + hexString);
return parseInt(hexString.substring(colorIndex * 2, 2), 16) / 255;
skeletonData.animations.push(new spine.Animation(name, timelines, duration));
}
static private function count (map:Object) : int {
var count:int = 0;
for (var key:String in map)
count++;
return count;
}
}
};
spine.SkeletonJson.readCurve = function (timeline, frameIndex, valueMap) {
var curve = valueMap["curve"];
if (!curve) return;
if (curve == "stepped")
timeline.curves.setStepped(frameIndex);
else if (curve instanceof Array)
timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]);
};
spine.SkeletonJson.toColor = function (hexString, colorIndex) {
if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString;
return parseInt(hexString.substring(colorIndex * 2, 2), 16) / 255;
};