mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
spine-js rendering with Turbulenz.
This commit is contained in:
parent
591b21c8ea
commit
67f2b1c306
285
spine-js/data/goblins.atlas
Normal file
285
spine-js/data/goblins.atlas
Normal file
@ -0,0 +1,285 @@
|
||||
|
||||
goblins.png
|
||||
format: RGBA8888
|
||||
filter: Linear,Linear
|
||||
repeat: none
|
||||
spear
|
||||
rotate: false
|
||||
xy: 2, 142
|
||||
size: 22, 368
|
||||
orig: 22, 368
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/head
|
||||
rotate: false
|
||||
xy: 26, 429
|
||||
size: 103, 81
|
||||
orig: 103, 81
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/head
|
||||
rotate: false
|
||||
xy: 26, 361
|
||||
size: 103, 66
|
||||
orig: 103, 66
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/torso
|
||||
rotate: false
|
||||
xy: 131, 414
|
||||
size: 68, 96
|
||||
orig: 68, 96
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/torso
|
||||
rotate: false
|
||||
xy: 26, 263
|
||||
size: 68, 96
|
||||
orig: 68, 96
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
dagger
|
||||
rotate: false
|
||||
xy: 26, 153
|
||||
size: 26, 108
|
||||
orig: 26, 108
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/right-lower-leg
|
||||
rotate: false
|
||||
xy: 201, 434
|
||||
size: 36, 76
|
||||
orig: 36, 76
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/right-lower-leg
|
||||
rotate: false
|
||||
xy: 54, 185
|
||||
size: 36, 76
|
||||
orig: 36, 76
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/left-upper-leg
|
||||
rotate: false
|
||||
xy: 96, 286
|
||||
size: 33, 73
|
||||
orig: 33, 73
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/pelvis
|
||||
rotate: false
|
||||
xy: 131, 369
|
||||
size: 62, 43
|
||||
orig: 62, 43
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/pelvis
|
||||
rotate: false
|
||||
xy: 131, 324
|
||||
size: 62, 43
|
||||
orig: 62, 43
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/right-foot
|
||||
rotate: false
|
||||
xy: 131, 289
|
||||
size: 63, 33
|
||||
orig: 63, 33
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/left-lower-leg
|
||||
rotate: false
|
||||
xy: 2, 70
|
||||
size: 33, 70
|
||||
orig: 33, 70
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/right-upper-leg
|
||||
rotate: false
|
||||
xy: 2, 5
|
||||
size: 34, 63
|
||||
orig: 34, 63
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/left-lower-leg
|
||||
rotate: false
|
||||
xy: 195, 342
|
||||
size: 33, 70
|
||||
orig: 33, 70
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/left-upper-leg
|
||||
rotate: false
|
||||
xy: 37, 81
|
||||
size: 33, 70
|
||||
orig: 33, 70
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/right-upper-leg
|
||||
rotate: false
|
||||
xy: 38, 16
|
||||
size: 34, 63
|
||||
orig: 34, 63
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/eyes-closed
|
||||
rotate: false
|
||||
xy: 38, 2
|
||||
size: 34, 12
|
||||
orig: 34, 12
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/undies
|
||||
rotate: false
|
||||
xy: 54, 154
|
||||
size: 36, 29
|
||||
orig: 36, 29
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/right-arm
|
||||
rotate: false
|
||||
xy: 72, 102
|
||||
size: 23, 50
|
||||
orig: 23, 50
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/left-foot
|
||||
rotate: false
|
||||
xy: 131, 256
|
||||
size: 65, 31
|
||||
orig: 65, 31
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/right-arm
|
||||
rotate: false
|
||||
xy: 196, 290
|
||||
size: 28, 50
|
||||
orig: 28, 50
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/left-shoulder
|
||||
rotate: false
|
||||
xy: 226, 294
|
||||
size: 28, 46
|
||||
orig: 28, 46
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/left-arm
|
||||
rotate: false
|
||||
xy: 198, 253
|
||||
size: 37, 35
|
||||
orig: 37, 35
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/left-foot
|
||||
rotate: false
|
||||
xy: 92, 223
|
||||
size: 65, 31
|
||||
orig: 65, 31
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/right-foot
|
||||
rotate: false
|
||||
xy: 92, 188
|
||||
size: 63, 33
|
||||
orig: 63, 33
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/undie-straps
|
||||
rotate: false
|
||||
xy: 92, 167
|
||||
size: 55, 19
|
||||
orig: 55, 19
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/left-arm
|
||||
rotate: false
|
||||
xy: 159, 219
|
||||
size: 37, 35
|
||||
orig: 37, 35
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/right-shoulder
|
||||
rotate: false
|
||||
xy: 97, 120
|
||||
size: 39, 45
|
||||
orig: 39, 45
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/right-shoulder
|
||||
rotate: false
|
||||
xy: 198, 206
|
||||
size: 39, 45
|
||||
orig: 39, 45
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/left-hand
|
||||
rotate: false
|
||||
xy: 157, 176
|
||||
size: 36, 41
|
||||
orig: 36, 41
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/neck
|
||||
rotate: false
|
||||
xy: 195, 163
|
||||
size: 36, 41
|
||||
orig: 36, 41
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/undie-straps
|
||||
rotate: false
|
||||
xy: 97, 99
|
||||
size: 55, 19
|
||||
orig: 55, 19
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/neck
|
||||
rotate: false
|
||||
xy: 138, 120
|
||||
size: 35, 41
|
||||
orig: 35, 41
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/left-hand
|
||||
rotate: false
|
||||
xy: 175, 121
|
||||
size: 35, 40
|
||||
orig: 35, 40
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/left-shoulder
|
||||
rotate: false
|
||||
xy: 212, 117
|
||||
size: 29, 44
|
||||
orig: 29, 44
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/eyes-closed
|
||||
rotate: false
|
||||
xy: 154, 97
|
||||
size: 37, 21
|
||||
orig: 37, 21
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblin/right-hand
|
||||
rotate: false
|
||||
xy: 193, 78
|
||||
size: 36, 37
|
||||
orig: 36, 37
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/right-hand
|
||||
rotate: false
|
||||
xy: 74, 39
|
||||
size: 36, 37
|
||||
orig: 36, 37
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
goblingirl/undies
|
||||
rotate: false
|
||||
xy: 74, 8
|
||||
size: 36, 29
|
||||
orig: 36, 29
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
499
spine-js/data/goblins.json
Normal file
499
spine-js/data/goblins.json
Normal file
@ -0,0 +1,499 @@
|
||||
{
|
||||
"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": 49.89, "x": 56.34, "y": 0.98, "rotation": -16.65 },
|
||||
{ "name": "left foot", "parent": "left lower leg", "length": 46.5, "x": 58.94, "y": -7.61, "rotation": 102.43 },
|
||||
{ "name": "right upper leg", "parent": "hip", "length": 42.45, "x": -20.07, "y": -6.83, "rotation": -97.49 },
|
||||
{ "name": "right lower leg", "parent": "right upper leg", "length": 58.52, "x": 42.99, "y": -0.61, "rotation": -14.34 },
|
||||
{ "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": 93.92 },
|
||||
{ "name": "neck", "parent": "torso", "length": 18.38, "x": 81.67, "y": -6.34, "rotation": -1.51 },
|
||||
{ "name": "head", "parent": "neck", "length": 68.28, "x": 20.93, "y": 11.59, "rotation": -13.92 },
|
||||
{ "name": "right shoulder", "parent": "torso", "length": 37.24, "x": 76.02, "y": 18.14, "rotation": 133.88 },
|
||||
{ "name": "right arm", "parent": "right shoulder", "length": 36.74, "x": 37.6, "y": 0.31, "rotation": 36.32 },
|
||||
{ "name": "right hand", "parent": "right arm", "length": 15.32, "x": 36.9, "y": 0.34, "rotation": 2.35 },
|
||||
{ "name": "left shoulder", "parent": "torso", "length": 35.43, "x": 74.04, "y": -20.38, "rotation": -156.96 },
|
||||
{ "name": "left arm", "parent": "left shoulder", "length": 35.62, "x": 37.85, "y": -2.34, "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 item", "bone": "left hand", "attachment": "spear" },
|
||||
{ "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": "neck", "bone": "neck", "attachment": "neck" },
|
||||
{ "name": "torso", "bone": "torso", "attachment": "torso" },
|
||||
{ "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": "undie straps", "bone": "pelvis", "attachment": "undie straps" },
|
||||
{ "name": "undies", "bone": "pelvis", "attachment": "undies" },
|
||||
{ "name": "right upper leg", "bone": "right upper leg", "attachment": "right upper leg" },
|
||||
{ "name": "head", "bone": "head", "attachment": "head" },
|
||||
{ "name": "eyes", "bone": "head" },
|
||||
{ "name": "right shoulder", "bone": "right shoulder", "attachment": "right shoulder" },
|
||||
{ "name": "right arm", "bone": "right arm", "attachment": "right arm" },
|
||||
{ "name": "right hand item", "bone": "right hand", "attachment": "dagger" },
|
||||
{ "name": "right hand", "bone": "right hand", "attachment": "right hand" }
|
||||
],
|
||||
"skins": {
|
||||
"default": {
|
||||
"left hand item": {
|
||||
"dagger": { "x": 7.88, "y": -23.45, "rotation": 10.47, "width": 26, "height": 108 },
|
||||
"spear": { "x": -4.55, "y": 39.2, "rotation": 13.04, "width": 22, "height": 368 }
|
||||
},
|
||||
"right hand item": {
|
||||
"dagger": { "x": 6.51, "y": -24.15, "rotation": -8.06, "width": 26, "height": 108 }
|
||||
}
|
||||
},
|
||||
"goblin": {
|
||||
"neck": {
|
||||
"neck": { "name": "goblin/neck", "x": 10.1, "y": 0.42, "rotation": -93.69, "width": 36, "height": 41 }
|
||||
},
|
||||
"undies": {
|
||||
"undies": { "name": "goblin/undies", "x": 6.3, "y": 0.12, "rotation": 0.91, "width": 36, "height": 29 }
|
||||
},
|
||||
"right hand": {
|
||||
"right hand": { "name": "goblin/right-hand", "x": 7.88, "y": 2.78, "rotation": 91.96, "width": 36, "height": 37 }
|
||||
},
|
||||
"right arm": {
|
||||
"right arm": { "name": "goblin/right-arm", "x": 16.44, "y": -1.04, "rotation": 94.32, "width": 23, "height": 50 }
|
||||
},
|
||||
"head": {
|
||||
"head": { "name": "goblin/head", "x": 25.73, "y": 2.33, "rotation": -92.29, "width": 103, "height": 66 }
|
||||
},
|
||||
"left shoulder": {
|
||||
"left shoulder": { "name": "goblin/left-shoulder", "x": 15.56, "y": -2.26, "rotation": 62.01, "width": 29, "height": 44 }
|
||||
},
|
||||
"left arm": {
|
||||
"left arm": {
|
||||
"name": "goblin/left-arm",
|
||||
"x": 16.7,
|
||||
"y": -1.69,
|
||||
"scaleX": 1.057,
|
||||
"scaleY": 1.057,
|
||||
"rotation": 33.84,
|
||||
"width": 37,
|
||||
"height": 35
|
||||
}
|
||||
},
|
||||
"left hand": {
|
||||
"left hand": {
|
||||
"name": "goblin/left-hand",
|
||||
"x": 3.47,
|
||||
"y": 3.41,
|
||||
"scaleX": 0.892,
|
||||
"scaleY": 0.892,
|
||||
"rotation": 31.14,
|
||||
"width": 36,
|
||||
"height": 41
|
||||
}
|
||||
},
|
||||
"right lower leg": {
|
||||
"right lower leg": { "name": "goblin/right-lower-leg", "x": 25.68, "y": -3.15, "rotation": 111.83, "width": 36, "height": 76 }
|
||||
},
|
||||
"right upper leg": {
|
||||
"right upper leg": { "name": "goblin/right-upper-leg", "x": 20.35, "y": 1.47, "rotation": 97.49, "width": 34, "height": 63 }
|
||||
},
|
||||
"pelvis": {
|
||||
"pelvis": { "name": "goblin/pelvis", "x": -5.61, "y": 0.76, "width": 62, "height": 43 }
|
||||
},
|
||||
"left lower leg": {
|
||||
"left lower leg": { "name": "goblin/left-lower-leg", "x": 23.58, "y": -2.06, "rotation": 105.75, "width": 33, "height": 70 }
|
||||
},
|
||||
"left upper leg": {
|
||||
"left upper leg": { "name": "goblin/left-upper-leg", "x": 29.68, "y": -3.87, "rotation": 89.09, "width": 33, "height": 73 }
|
||||
},
|
||||
"torso": {
|
||||
"torso": { "name": "goblin/torso", "x": 38.09, "y": -3.87, "rotation": -94.95, "width": 68, "height": 96 }
|
||||
},
|
||||
"right shoulder": {
|
||||
"right shoulder": { "name": "goblin/right-shoulder", "x": 15.68, "y": -1.03, "rotation": 130.65, "width": 39, "height": 45 }
|
||||
},
|
||||
"right foot": {
|
||||
"right foot": { "name": "goblin/right-foot", "x": 23.56, "y": 9.8, "rotation": 1.52, "width": 63, "height": 33 }
|
||||
},
|
||||
"left foot": {
|
||||
"left foot": { "name": "goblin/left-foot", "x": 24.85, "y": 8.74, "rotation": 3.32, "width": 65, "height": 31 }
|
||||
},
|
||||
"undie straps": {
|
||||
"undie straps": { "name": "goblin/undie-straps", "x": -3.87, "y": 13.1, "scaleX": 1.089, "width": 55, "height": 19 }
|
||||
},
|
||||
"eyes": {
|
||||
"eyes closed": { "name": "goblin/eyes-closed", "x": 32.21, "y": -21.27, "rotation": -88.92, "width": 34, "height": 12 }
|
||||
}
|
||||
},
|
||||
"goblingirl": {
|
||||
"left upper leg": {
|
||||
"left upper leg": { "name": "goblingirl/left-upper-leg", "x": 30.21, "y": -2.95, "rotation": 89.09, "width": 33, "height": 70 }
|
||||
},
|
||||
"left lower leg": {
|
||||
"left lower leg": { "name": "goblingirl/left-lower-leg", "x": 25.02, "y": -0.6, "rotation": 105.75, "width": 33, "height": 70 }
|
||||
},
|
||||
"left foot": {
|
||||
"left foot": { "name": "goblingirl/left-foot", "x": 25.17, "y": 7.92, "rotation": 3.32, "width": 65, "height": 31 }
|
||||
},
|
||||
"right upper leg": {
|
||||
"right upper leg": { "name": "goblingirl/right-upper-leg", "x": 19.69, "y": 2.13, "rotation": 97.49, "width": 34, "height": 63 }
|
||||
},
|
||||
"right lower leg": {
|
||||
"right lower leg": { "name": "goblingirl/right-lower-leg", "x": 26.15, "y": -3.27, "rotation": 111.83, "width": 36, "height": 76 }
|
||||
},
|
||||
"right foot": {
|
||||
"right foot": { "name": "goblingirl/right-foot", "x": 23.46, "y": 9.66, "rotation": 1.52, "width": 63, "height": 33 }
|
||||
},
|
||||
"torso": {
|
||||
"torso": { "name": "goblingirl/torso", "x": 36.28, "y": -5.14, "rotation": -95.74, "width": 68, "height": 96 }
|
||||
},
|
||||
"left shoulder": {
|
||||
"left shoulder": { "name": "goblingirl/left-shoulder", "x": 19.8, "y": -0.42, "rotation": 61.21, "width": 28, "height": 46 }
|
||||
},
|
||||
"left arm": {
|
||||
"left arm": { "name": "goblingirl/left-arm", "x": 19.64, "y": -2.42, "rotation": 33.05, "width": 37, "height": 35 }
|
||||
},
|
||||
"left hand": {
|
||||
"left hand": {
|
||||
"name": "goblingirl/left-hand",
|
||||
"x": 4.34,
|
||||
"y": 2.39,
|
||||
"scaleX": 0.896,
|
||||
"scaleY": 0.896,
|
||||
"rotation": 30.34,
|
||||
"width": 35,
|
||||
"height": 40
|
||||
}
|
||||
},
|
||||
"neck": {
|
||||
"neck": { "name": "goblingirl/neck", "x": 6.16, "y": -3.14, "rotation": -98.86, "width": 35, "height": 41 }
|
||||
},
|
||||
"head": {
|
||||
"head": { "name": "goblingirl/head", "x": 27.71, "y": -4.32, "rotation": -85.58, "width": 103, "height": 81 }
|
||||
},
|
||||
"right shoulder": {
|
||||
"right shoulder": { "name": "goblingirl/right-shoulder", "x": 14.46, "y": 0.45, "rotation": 129.85, "width": 39, "height": 45 }
|
||||
},
|
||||
"right arm": {
|
||||
"right arm": { "name": "goblingirl/right-arm", "x": 16.85, "y": -0.66, "rotation": 93.52, "width": 28, "height": 50 }
|
||||
},
|
||||
"right hand": {
|
||||
"right hand": { "name": "goblingirl/right-hand", "x": 7.21, "y": 3.43, "rotation": 91.16, "width": 36, "height": 37 }
|
||||
},
|
||||
"pelvis": {
|
||||
"pelvis": { "name": "goblingirl/pelvis", "x": -3.87, "y": 3.18, "width": 62, "height": 43 }
|
||||
},
|
||||
"undie straps": {
|
||||
"undie straps": { "name": "goblingirl/undie-straps", "x": -1.51, "y": 14.18, "width": 55, "height": 19 }
|
||||
},
|
||||
"undies": {
|
||||
"undies": { "name": "goblingirl/undies", "x": 5.4, "y": 1.7, "width": 36, "height": 29 }
|
||||
},
|
||||
"eyes": {
|
||||
"eyes closed": { "name": "goblingirl/eyes-closed", "x": 28, "y": -25.54, "rotation": -87.04, "width": 37, "height": 21 }
|
||||
}
|
||||
}
|
||||
},
|
||||
"animations": {
|
||||
"walk": {
|
||||
"bones": {
|
||||
"left upper leg": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": -26.55 },
|
||||
{ "time": 0.1333, "angle": -8.78 },
|
||||
{ "time": 0.2333, "angle": 9.51 },
|
||||
{ "time": 0.3666, "angle": 30.74 },
|
||||
{ "time": 0.5, "angle": 25.33 },
|
||||
{ "time": 0.6333, "angle": 26.11 },
|
||||
{ "time": 0.7333, "angle": -7.7 },
|
||||
{ "time": 0.8666, "angle": -21.19 },
|
||||
{ "time": 1, "angle": -26.55 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": -1.32, "y": 1.7 },
|
||||
{ "time": 0.3666, "x": -0.06, "y": 2.42 },
|
||||
{ "time": 1, "x": -1.32, "y": 1.7 }
|
||||
]
|
||||
},
|
||||
"right upper leg": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": 42.45 },
|
||||
{ "time": 0.1333, "angle": 52.1 },
|
||||
{ "time": 0.2333, "angle": 8.53 },
|
||||
{ "time": 0.5, "angle": -16.93 },
|
||||
{ "time": 0.6333, "angle": 1.89 },
|
||||
{
|
||||
"time": 0.7333,
|
||||
"angle": 28.06,
|
||||
"curve": [ 0.462, 0.11, 1, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.8666,
|
||||
"angle": 58.68,
|
||||
"curve": [ 0.5, 0.02, 1, 1 ]
|
||||
},
|
||||
{ "time": 1, "angle": 42.45 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": 6.23, "y": 0 },
|
||||
{ "time": 0.2333, "x": 2.14, "y": 2.4 },
|
||||
{ "time": 0.5, "x": 2.44, "y": 4.8 },
|
||||
{ "time": 1, "x": 6.23, "y": 0 }
|
||||
]
|
||||
},
|
||||
"left lower leg": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": -22.98 },
|
||||
{ "time": 0.1333, "angle": -63.5 },
|
||||
{ "time": 0.2333, "angle": -73.76 },
|
||||
{ "time": 0.5, "angle": 5.11 },
|
||||
{ "time": 0.6333, "angle": -28.29 },
|
||||
{ "time": 0.7333, "angle": 4.08 },
|
||||
{ "time": 0.8666, "angle": 3.53 },
|
||||
{ "time": 1, "angle": -22.98 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": 0, "y": 0 },
|
||||
{ "time": 0.2333, "x": 2.55, "y": -0.47 },
|
||||
{ "time": 0.5, "x": 0, "y": 0, "curve": "stepped" },
|
||||
{ "time": 1, "x": 0, "y": 0 }
|
||||
]
|
||||
},
|
||||
"left foot": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": -3.69 },
|
||||
{ "time": 0.1333, "angle": -10.42 },
|
||||
{ "time": 0.2333, "angle": -5.01 },
|
||||
{ "time": 0.3666, "angle": 3.87 },
|
||||
{ "time": 0.5, "angle": -3.87 },
|
||||
{ "time": 0.6333, "angle": 2.78 },
|
||||
{ "time": 0.7333, "angle": 1.68 },
|
||||
{ "time": 0.8666, "angle": -8.54 },
|
||||
{ "time": 1, "angle": -3.69 }
|
||||
]
|
||||
},
|
||||
"right shoulder": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": 5.29,
|
||||
"curve": [ 0.264, 0, 0.75, 1 ]
|
||||
},
|
||||
{ "time": 0.6333, "angle": 6.65 },
|
||||
{ "time": 1, "angle": 5.29 }
|
||||
]
|
||||
},
|
||||
"right arm": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": -4.02,
|
||||
"curve": [ 0.267, 0, 0.804, 0.99 ]
|
||||
},
|
||||
{
|
||||
"time": 0.6333,
|
||||
"angle": 19.78,
|
||||
"curve": [ 0.307, 0, 0.787, 0.99 ]
|
||||
},
|
||||
{ "time": 1, "angle": -4.02 }
|
||||
]
|
||||
},
|
||||
"right hand": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": 8.98 },
|
||||
{ "time": 0.6333, "angle": 0.51 },
|
||||
{ "time": 1, "angle": 8.98 }
|
||||
]
|
||||
},
|
||||
"left shoulder": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": 6.25,
|
||||
"curve": [ 0.339, 0, 0.683, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.5,
|
||||
"angle": -11.78,
|
||||
"curve": [ 0.281, 0, 0.686, 0.99 ]
|
||||
},
|
||||
{ "time": 1, "angle": 6.25 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": 1.15, "y": 0.23 }
|
||||
]
|
||||
},
|
||||
"left hand": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": -21.23,
|
||||
"curve": [ 0.295, 0, 0.755, 0.98 ]
|
||||
},
|
||||
{
|
||||
"time": 0.5,
|
||||
"angle": -27.28,
|
||||
"curve": [ 0.241, 0, 0.75, 0.97 ]
|
||||
},
|
||||
{ "time": 1, "angle": -21.23 }
|
||||
]
|
||||
},
|
||||
"left arm": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": 28.37,
|
||||
"curve": [ 0.339, 0, 0.683, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.5,
|
||||
"angle": 60.09,
|
||||
"curve": [ 0.281, 0, 0.686, 0.99 ]
|
||||
},
|
||||
{ "time": 1, "angle": 28.37 }
|
||||
]
|
||||
},
|
||||
"torso": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": -10.28 },
|
||||
{
|
||||
"time": 0.1333,
|
||||
"angle": -15.38,
|
||||
"curve": [ 0.545, 0, 0.818, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.3666,
|
||||
"angle": -9.78,
|
||||
"curve": [ 0.58, 0.17, 0.669, 0.99 ]
|
||||
},
|
||||
{
|
||||
"time": 0.6333,
|
||||
"angle": -15.75,
|
||||
"curve": [ 0.235, 0.01, 0.795, 1 ]
|
||||
},
|
||||
{
|
||||
"time": 0.8666,
|
||||
"angle": -7.06,
|
||||
"curve": [ 0.209, 0, 0.816, 0.98 ]
|
||||
},
|
||||
{ "time": 1, "angle": -10.28 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": -1.29, "y": 1.68 }
|
||||
]
|
||||
},
|
||||
"right foot": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": -5.25 },
|
||||
{ "time": 0.2333, "angle": -1.91 },
|
||||
{ "time": 0.3666, "angle": -6.45 },
|
||||
{ "time": 0.5, "angle": -5.39 },
|
||||
{ "time": 0.7333, "angle": -11.68 },
|
||||
{ "time": 0.8666, "angle": 0.46 },
|
||||
{ "time": 1, "angle": -5.25 }
|
||||
]
|
||||
},
|
||||
"right lower leg": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": -3.39,
|
||||
"curve": [ 0.316, 0.01, 0.741, 0.98 ]
|
||||
},
|
||||
{
|
||||
"time": 0.1333,
|
||||
"angle": -45.53,
|
||||
"curve": [ 0.229, 0, 0.738, 0.97 ]
|
||||
},
|
||||
{ "time": 0.2333, "angle": -4.83 },
|
||||
{ "time": 0.5, "angle": -19.53 },
|
||||
{ "time": 0.6333, "angle": -64.8 },
|
||||
{
|
||||
"time": 0.7333,
|
||||
"angle": -82.56,
|
||||
"curve": [ 0.557, 0.18, 1, 1 ]
|
||||
},
|
||||
{ "time": 1, "angle": -3.39 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
|
||||
{ "time": 0.5, "x": 0, "y": 0 },
|
||||
{ "time": 0.6333, "x": 2.18, "y": 0.21 },
|
||||
{ "time": 1, "x": 0, "y": 0 }
|
||||
]
|
||||
},
|
||||
"hip": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": 0, "curve": "stepped" },
|
||||
{ "time": 1, "angle": 0 }
|
||||
],
|
||||
"translate": [
|
||||
{ "time": 0, "x": 0, "y": -4.16 },
|
||||
{
|
||||
"time": 0.1333,
|
||||
"x": 0,
|
||||
"y": -7.05,
|
||||
"curve": [ 0.359, 0.47, 0.646, 0.74 ]
|
||||
},
|
||||
{ "time": 0.3666, "x": 0, "y": 6.78 },
|
||||
{ "time": 0.5, "x": 0, "y": -6.13 },
|
||||
{
|
||||
"time": 0.6333,
|
||||
"x": 0,
|
||||
"y": -7.05,
|
||||
"curve": [ 0.359, 0.47, 0.646, 0.74 ]
|
||||
},
|
||||
{ "time": 0.8666, "x": 0, "y": 6.78 },
|
||||
{ "time": 1, "x": 0, "y": -4.16 }
|
||||
]
|
||||
},
|
||||
"neck": {
|
||||
"rotate": [
|
||||
{ "time": 0, "angle": 3.6 },
|
||||
{ "time": 0.1333, "angle": 17.49 },
|
||||
{ "time": 0.2333, "angle": 6.1 },
|
||||
{ "time": 0.3666, "angle": 3.45 },
|
||||
{ "time": 0.5, "angle": 5.17 },
|
||||
{ "time": 0.6333, "angle": 18.36 },
|
||||
{ "time": 0.7333, "angle": 6.09 },
|
||||
{ "time": 0.8666, "angle": 2.28 },
|
||||
{ "time": 1, "angle": 3.6 }
|
||||
]
|
||||
},
|
||||
"head": {
|
||||
"rotate": [
|
||||
{
|
||||
"time": 0,
|
||||
"angle": 3.6,
|
||||
"curve": [ 0, 0, 0.704, 1.17 ]
|
||||
},
|
||||
{ "time": 0.1333, "angle": -0.2 },
|
||||
{ "time": 0.2333, "angle": 6.1 },
|
||||
{ "time": 0.3666, "angle": 3.45 },
|
||||
{
|
||||
"time": 0.5,
|
||||
"angle": 5.17,
|
||||
"curve": [ 0, 0, 0.704, 1.61 ]
|
||||
},
|
||||
{ "time": 0.6666, "angle": 1.1 },
|
||||
{ "time": 0.7333, "angle": 6.09 },
|
||||
{ "time": 0.8666, "angle": 2.28 },
|
||||
{ "time": 1, "angle": 3.6 }
|
||||
]
|
||||
}
|
||||
},
|
||||
"slots": {
|
||||
"eyes": {
|
||||
"attachment": [
|
||||
{ "time": 0.7, "name": "eyes closed" },
|
||||
{ "time": 0.8, "name": null }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
spine-js/data/goblins.png
Normal file
BIN
spine-js/data/goblins.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 145 KiB |
166
spine-js/data/spineboy.atlas
Normal file
166
spine-js/data/spineboy.atlas
Normal file
@ -0,0 +1,166 @@
|
||||
|
||||
spineboy.png
|
||||
format: RGBA8888
|
||||
filter: Linear,Linear
|
||||
repeat: none
|
||||
head
|
||||
rotate: false
|
||||
xy: 1, 122
|
||||
size: 121, 132
|
||||
orig: 121, 132
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
torso
|
||||
rotate: false
|
||||
xy: 1, 28
|
||||
size: 68, 92
|
||||
orig: 68, 92
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-pant-bottom
|
||||
rotate: false
|
||||
xy: 1, 4
|
||||
size: 44, 22
|
||||
orig: 44, 22
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-pant-bottom
|
||||
rotate: false
|
||||
xy: 47, 8
|
||||
size: 46, 18
|
||||
orig: 46, 18
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-upper-leg
|
||||
rotate: false
|
||||
xy: 71, 50
|
||||
size: 44, 70
|
||||
orig: 44, 70
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
pelvis
|
||||
rotate: false
|
||||
xy: 95, 1
|
||||
size: 63, 47
|
||||
orig: 63, 47
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-upper-leg
|
||||
rotate: false
|
||||
xy: 117, 53
|
||||
size: 33, 67
|
||||
orig: 33, 67
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-foot
|
||||
rotate: false
|
||||
xy: 160, 224
|
||||
size: 67, 30
|
||||
orig: 67, 30
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-shoulder
|
||||
rotate: false
|
||||
xy: 124, 201
|
||||
size: 34, 53
|
||||
orig: 34, 53
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-ankle
|
||||
rotate: false
|
||||
xy: 229, 222
|
||||
size: 25, 32
|
||||
orig: 25, 32
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-foot
|
||||
rotate: false
|
||||
xy: 160, 192
|
||||
size: 65, 30
|
||||
orig: 65, 30
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
neck
|
||||
rotate: false
|
||||
xy: 124, 171
|
||||
size: 34, 28
|
||||
orig: 34, 28
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-arm
|
||||
rotate: false
|
||||
xy: 124, 124
|
||||
size: 21, 45
|
||||
orig: 21, 45
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-ankle
|
||||
rotate: false
|
||||
xy: 227, 190
|
||||
size: 25, 30
|
||||
orig: 25, 30
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-hand
|
||||
rotate: false
|
||||
xy: 147, 131
|
||||
size: 35, 38
|
||||
orig: 35, 38
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-arm
|
||||
rotate: false
|
||||
xy: 184, 161
|
||||
size: 35, 29
|
||||
orig: 35, 29
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
eyes-closed
|
||||
rotate: false
|
||||
xy: 221, 161
|
||||
size: 34, 27
|
||||
orig: 34, 27
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-lower-leg
|
||||
rotate: false
|
||||
xy: 152, 65
|
||||
size: 51, 64
|
||||
orig: 51, 64
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-foot-idle
|
||||
rotate: false
|
||||
xy: 184, 131
|
||||
size: 53, 28
|
||||
orig: 53, 28
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
left-lower-leg
|
||||
rotate: false
|
||||
xy: 205, 65
|
||||
size: 49, 64
|
||||
orig: 49, 64
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-shoulder
|
||||
rotate: false
|
||||
xy: 160, 12
|
||||
size: 52, 51
|
||||
orig: 52, 51
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
eyes
|
||||
rotate: false
|
||||
xy: 214, 36
|
||||
size: 34, 27
|
||||
orig: 34, 27
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
right-hand
|
||||
rotate: false
|
||||
xy: 214, 2
|
||||
size: 32, 32
|
||||
orig: 32, 32
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
@ -1,16 +1,4 @@
|
||||
<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 },
|
||||
@ -796,8 +784,4 @@ var skeletonData = json.readSkeletonData({
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
BIN
spine-js/data/spineboy.png
Normal file
BIN
spine-js/data/spineboy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
@ -24,6 +24,7 @@ spine.SlotData.prototype = {
|
||||
spine.Bone = function (boneData, parent) {
|
||||
this.data = boneData;
|
||||
this.parent = parent;
|
||||
this.setToSetupPose();
|
||||
};
|
||||
spine.Bone.yDown = false;
|
||||
spine.Bone.prototype = {
|
||||
@ -49,8 +50,9 @@ spine.Bone.prototype = {
|
||||
this.worldScaleY = this.scaleY;
|
||||
this.worldRotation = this.rotation;
|
||||
}
|
||||
var cos = worldRotation * Math.PI / 180;
|
||||
var sin = worldRotation * Math.PI / 180;
|
||||
var radians = this.worldRotation * Math.PI / 180;
|
||||
var cos = Math.cos(radians);
|
||||
var sin = Math.sin(radians);
|
||||
this.m00 = cos * this.worldScaleX;
|
||||
this.m10 = sin * this.worldScaleX;
|
||||
this.m01 = -sin * this.worldScaleY;
|
||||
@ -82,6 +84,7 @@ spine.Slot = function (slotData, skeleton, bone) {
|
||||
this.data = slotData;
|
||||
this.skeleton = skeleton;
|
||||
this.bone = bone;
|
||||
this.setToSetupPose();
|
||||
};
|
||||
spine.Slot.prototype = {
|
||||
r: 1, g: 1, b: 1, a: 1,
|
||||
@ -104,10 +107,10 @@ spine.Slot.prototype = {
|
||||
this.b = data.b;
|
||||
this.a = data.a;
|
||||
|
||||
var slots = this.skeleton.slots;
|
||||
for (var i = 0, n = slots.length; i < n; i++) {
|
||||
if (slots[i] == this) {
|
||||
this.setAttachment(!data.attachmentName ? null : this.skeleton.getAttachment(i, data.attachmentName));
|
||||
var slotDatas = this.skeleton.data.slots;
|
||||
for (var i = 0, n = slotDatas.length; i < n; i++) {
|
||||
if (slotDatas[i] == data) {
|
||||
this.setAttachment(!data.attachmentName ? null : this.skeleton.getAttachmentBySlotIndex(i, data.attachmentName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -131,7 +134,7 @@ spine.Skin.prototype = {
|
||||
var slotIndex = parseInt(key.substring(0, colon));
|
||||
var name = key.substring(colon + 1);
|
||||
var slot = skeleton.slots[slotIndex];
|
||||
if (slot.attachment.name == name) {
|
||||
if (slot.attachment && slot.attachment.name == name) {
|
||||
var attachment = this.getAttachment(slotIndex, name);
|
||||
if (attachment) slot.setAttachment(attachment);
|
||||
}
|
||||
@ -147,11 +150,13 @@ spine.Animation = function (name, timelines, duration) {
|
||||
spine.Animation.prototype = {
|
||||
apply: function (skeleton, time, loop) {
|
||||
if (loop && this.duration != 0) time %= this.duration;
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, time, 1);
|
||||
},
|
||||
mix: function (skeleton, time, loop, alpha) {
|
||||
if (loop && this.duration != 0) time %= this.duration;
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, time, alpha);
|
||||
}
|
||||
@ -217,7 +222,7 @@ spine.Curves.prototype = {
|
||||
var curveIndex = frameIndex * 6;
|
||||
var curves = this.curves;
|
||||
var dfx = curves[curveIndex];
|
||||
if (dfx == 0/*LINEAR*/) return percent;
|
||||
if (!dfx/*LINEAR*/) return percent;
|
||||
if (dfx == -1/*STEPPED*/) return 0;
|
||||
var dfy = curves[curveIndex + 1];
|
||||
var ddfx = curves[curveIndex + 2];
|
||||
@ -467,7 +472,7 @@ spine.AttachmentTimeline.prototype = {
|
||||
frameIndex = spine.binarySearch(frames, time, 1) - 1;
|
||||
|
||||
var attachmentName = this.attachmentNames[frameIndex];
|
||||
skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
|
||||
skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachmentBySlotIndex(this.slotIndex, attachmentName));
|
||||
}
|
||||
};
|
||||
|
||||
@ -530,8 +535,8 @@ spine.Skeleton = function (skeletonData) {
|
||||
this.bones = [];
|
||||
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 spine.Bone(boneData, parent));
|
||||
var parent = !boneData.parent ? null : this.bones[skeletonData.bones.indexOf(boneData.parent)];
|
||||
this.bones.push(new spine.Bone(boneData, parent));
|
||||
}
|
||||
|
||||
this.slots = [];
|
||||
@ -540,8 +545,8 @@ spine.Skeleton = function (skeletonData) {
|
||||
var slotData = skeletonData.slots[i];
|
||||
var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)];
|
||||
var slot = new spine.Slot(slotData, this, bone);
|
||||
slots.push(slot);
|
||||
drawOrder.push(slot);
|
||||
this.slots.push(slot);
|
||||
this.drawOrder.push(slot);
|
||||
}
|
||||
};
|
||||
spine.Skeleton.prototype = {
|
||||
@ -559,8 +564,8 @@ spine.Skeleton.prototype = {
|
||||
},
|
||||
/** Sets the bones and slots to their setup pose values. */
|
||||
setToSetupPose: function () {
|
||||
setBonesToSetupPose();
|
||||
setSlotsToSetupPose();
|
||||
this.setBonesToSetupPose();
|
||||
this.setSlotsToSetupPose();
|
||||
},
|
||||
setBonesToSetupPose: function () {
|
||||
var bones = this.bones;
|
||||
@ -574,7 +579,7 @@ spine.Skeleton.prototype = {
|
||||
},
|
||||
/** @return May return null. */
|
||||
getRootBone: function () {
|
||||
return bones.length == 0 ? null : bones[0];
|
||||
return this.bones.length == 0 ? null : this.bones[0];
|
||||
},
|
||||
/** @return May be null. */
|
||||
findBone: function (boneName) {
|
||||
@ -613,12 +618,12 @@ spine.Skeleton.prototype = {
|
||||
* from the new skin are attached if the corresponding attachment from the old skin was attached.
|
||||
* @param newSkin May be null. */
|
||||
setSkin: function (newSkin) {
|
||||
if (this.skin && newSkin) newSkin._attachAll(this, skin);
|
||||
if (this.skin && newSkin) newSkin._attachAll(this, this.skin);
|
||||
this.skin = newSkin;
|
||||
},
|
||||
/** @return May be null. */
|
||||
getAttachmentBySlotName: function (slotName, attachmentName) {
|
||||
return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName);
|
||||
return this.getAttachmentBySlotIndex(this.data.findSlotIndex(slotName), attachmentName);
|
||||
},
|
||||
/** @return May be null. */
|
||||
getAttachmentBySlotIndex: function (slotIndex, attachmentName) {
|
||||
@ -671,6 +676,7 @@ spine.RegionAttachment.prototype = {
|
||||
regionWidth: 0, regionHeight: 0,
|
||||
regionOriginalWidth: 0, regionOriginalHeight: 0,
|
||||
setUVs: function (u, v, u2, v2, rotate) {
|
||||
var uvs = this.uvs;
|
||||
if (rotate) {
|
||||
uvs[2/*X2*/] = u;
|
||||
uvs[3/*Y2*/] = v2;
|
||||
@ -719,21 +725,20 @@ spine.RegionAttachment.prototype = {
|
||||
offset[6/*X4*/] = localX2Cos - localYSin;
|
||||
offset[7/*Y4*/] = localYCos + localX2Sin;
|
||||
},
|
||||
updateVertices: function (bone, vertices) {
|
||||
computeVertices: function (bone, vertices) {
|
||||
var x = bone.worldX;
|
||||
var y = bone.worldY;
|
||||
var m00 = bone.m00;
|
||||
var m01 = bone.m01;
|
||||
var m10 = bone.m10;
|
||||
var m11 = bone.m11;
|
||||
var vertices = this.vertices;
|
||||
var offset = this.offset;
|
||||
vertices[0/*X1*/] = offset[0/*X1*/] * m00 + offset[1/*Y1*/] * m01 + x;
|
||||
vertices[1/*Y1*/] = offset[0/*X1*/] * m10 + offset[1/*Y1*/] * m11 + y;
|
||||
vertices[2/*X2*/] = offset[2/*X2*/] * m00 + offset[3/*Y2*/] * m01 + x;
|
||||
vertices[3/*Y2*/] = offset[2/*X2*/] * m10 + offset[3/*Y2*/] * m11 + y;
|
||||
vertices[4/*X3*/] = offset[4/*X3*/] * m00 + offset[4/*X3*/] * m01 + x;
|
||||
vertices[4/*X3*/] = offset[4/*X3*/] * m10 + offset[4/*X3*/] * m11 + y;
|
||||
vertices[4/*X3*/] = offset[4/*X3*/] * m00 + offset[5/*X3*/] * m01 + x;
|
||||
vertices[5/*X3*/] = offset[4/*X3*/] * m10 + offset[5/*X3*/] * m11 + y;
|
||||
vertices[6/*X4*/] = offset[6/*X4*/] * m00 + offset[7/*Y4*/] * m01 + x;
|
||||
vertices[7/*Y4*/] = offset[6/*X4*/] * m10 + offset[7/*Y4*/] * m11 + y;
|
||||
}
|
||||
@ -752,10 +757,10 @@ spine.AnimationStateData.prototype = {
|
||||
this.setMix(from, to, duration);
|
||||
},
|
||||
setMix: function (from, to, duration) {
|
||||
animationToMixTime[from.name + ":" + to.name] = duration;
|
||||
this.animationToMixTime[from.name + ":" + to.name] = duration;
|
||||
},
|
||||
getMix: function (from, to) {
|
||||
var time = animationToMixTime[from.name + ":" + to.name];
|
||||
var time = this.animationToMixTime[from.name + ":" + to.name];
|
||||
return time ? time : 0;
|
||||
}
|
||||
};
|
||||
@ -791,12 +796,12 @@ spine.AnimationState.prototype = {
|
||||
if (this.previous) {
|
||||
this.previous.apply(skeleton, this.previousTime, this.previousLoop);
|
||||
var alpha = this.mixTime / this.mixDuration;
|
||||
if (this.alpha >= 1) {
|
||||
this.alpha = 1;
|
||||
if (alpha >= 1) {
|
||||
alpha = 1;
|
||||
this.previous = null;
|
||||
}
|
||||
this.current.mix(skeleton, this.currentTime, this.currentLoop, alpha);
|
||||
} else
|
||||
} else
|
||||
this.current.apply(skeleton, this.currentTime, this.currentLoop);
|
||||
},
|
||||
clearAnimation: function () {
|
||||
@ -844,10 +849,10 @@ spine.AnimationState.prototype = {
|
||||
entry.animation = animation;
|
||||
entry.loop = loop;
|
||||
|
||||
if (delay <= 0) {
|
||||
if (!delay || delay <= 0) {
|
||||
var previousAnimation = this.queue.length == 0 ? this.current : this.queue[this.queue.length - 1].animation;
|
||||
if (previousAnimation != null)
|
||||
delay = previousAnimation.duration - this.data.getMix(previousAnimation, animation) + delay;
|
||||
delay = previousAnimation.duration - this.data.getMix(previousAnimation, animation) + (delay || 0);
|
||||
else
|
||||
delay = 0;
|
||||
}
|
||||
@ -942,7 +947,7 @@ spine.SkeletonJson.prototype = {
|
||||
name = map["name"] || name;
|
||||
|
||||
var type = spine.AttachmentType[map["type"] || "region"];
|
||||
var attachment = this.attachmentLoader(skin, type, name);
|
||||
var attachment = this.attachmentLoader.newAttachment(skin, type, name);
|
||||
|
||||
if (type == spine.AttachmentType.region) {
|
||||
attachment.x = (map["x"] || 0) * this.scale;
|
||||
@ -983,7 +988,7 @@ spine.SkeletonJson.prototype = {
|
||||
frameIndex++;
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.frameCount * 2 - 2]);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]);
|
||||
|
||||
} else if (timelineName == "translate" || timelineName == "scale") {
|
||||
var timeline;
|
||||
@ -1006,7 +1011,7 @@ spine.SkeletonJson.prototype = {
|
||||
frameIndex++;
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.frameCount * 3 - 3]);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 3 - 3]);
|
||||
|
||||
} else
|
||||
throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")";
|
||||
@ -1019,9 +1024,9 @@ spine.SkeletonJson.prototype = {
|
||||
var slotMap = slots[slotName];
|
||||
var slotIndex = skeletonData.findSlotIndex(slotName);
|
||||
|
||||
for (var timelineName in boneMap) {
|
||||
if (!boneMap.hasOwnProperty(timelineName)) continue;
|
||||
var values = boneMap[timelineName2];
|
||||
for (var timelineName in slotMap) {
|
||||
if (!slotMap.hasOwnProperty(timelineName)) continue;
|
||||
var values = slotMap[timelineName];
|
||||
if (timelineName == "color") {
|
||||
var timeline = new spine.ColorTimeline(values.length);
|
||||
timeline.slotIndex = slotIndex;
|
||||
@ -1039,7 +1044,7 @@ spine.SkeletonJson.prototype = {
|
||||
frameIndex++;
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.frameCount * 5 - 5]);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]);
|
||||
|
||||
} else if (timelineName == "attachment") {
|
||||
var timeline = new spine.AttachmentTimeline(values.length);
|
||||
@ -1051,7 +1056,7 @@ spine.SkeletonJson.prototype = {
|
||||
timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
duration = Math.max(duration, timeline.frames[timeline.frameCount - 1]);
|
||||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
|
||||
|
||||
} else
|
||||
throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")";
|
||||
@ -1073,3 +1078,240 @@ 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;
|
||||
};
|
||||
|
||||
spine.Atlas = function (atlasText, textureLoader) {
|
||||
this.textureLoader = textureLoader;
|
||||
this.pages = [];
|
||||
this.regions = [];
|
||||
|
||||
var reader = new spine.AtlasReader(atlasText);
|
||||
var tuple = [];
|
||||
tuple.length = 4;
|
||||
var page = null;
|
||||
while (true) {
|
||||
var line = reader.readLine();
|
||||
if (line == null) break;
|
||||
line = reader.trim(line);
|
||||
if (line.length == 0)
|
||||
page = null;
|
||||
else if (!page) {
|
||||
page = new spine.AtlasPage();
|
||||
page.name = line;
|
||||
|
||||
page.format = spine.Atlas.Format[reader.readValue()];
|
||||
|
||||
reader.readTuple(tuple);
|
||||
page.minFilter = spine.Atlas.TextureFilter[tuple[0]];
|
||||
page.magFilter = spine.Atlas.TextureFilter[tuple[1]];
|
||||
|
||||
var direction = reader.readValue();
|
||||
page.uWrap = spine.Atlas.TextureWrap.clampToEdge;
|
||||
page.vWrap = spine.Atlas.TextureWrap.clampToEdge;
|
||||
if (direction == "x")
|
||||
page.uWrap = spine.Atlas.TextureWrap.repeat;
|
||||
else if (direction == "y")
|
||||
page.vWrap = spine.Atlas.TextureWrap.repeat;
|
||||
else if (direction == "xy")
|
||||
page.uWrap = page.vWrap = spine.Atlas.TextureWrap.repeat;
|
||||
|
||||
textureLoader.load(page, line);
|
||||
|
||||
this.pages.push(page);
|
||||
|
||||
} else {
|
||||
var region = new spine.AtlasRegion();
|
||||
region.name = line;
|
||||
region.page = page;
|
||||
|
||||
region.rotate = reader.readValue() == "true";
|
||||
|
||||
reader.readTuple(tuple);
|
||||
var x = parseInt(tuple[0]);
|
||||
var y = parseInt(tuple[1]);
|
||||
|
||||
reader.readTuple(tuple);
|
||||
var width = parseInt(tuple[0]);
|
||||
var height = parseInt(tuple[1]);
|
||||
|
||||
region.u = x / page.width;
|
||||
region.v = y / page.height;
|
||||
if (region.rotate) {
|
||||
region.u2 = (x + height) / page.width;
|
||||
region.v2 = (y + width) / page.height;
|
||||
} else {
|
||||
region.u2 = (x + width) / page.width;
|
||||
region.v2 = (y + height) / page.height;
|
||||
}
|
||||
region.x = x;
|
||||
region.y = y;
|
||||
region.width = Math.abs(width);
|
||||
region.height = Math.abs(height);
|
||||
|
||||
if (reader.readTuple(tuple) == 4) { // split is optional
|
||||
region.splits = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])];
|
||||
|
||||
if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits
|
||||
region.pads = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])];
|
||||
|
||||
reader.readTuple(tuple);
|
||||
}
|
||||
}
|
||||
|
||||
region.originalWidth = parseInt(tuple[0]);
|
||||
region.originalHeight = parseInt(tuple[1]);
|
||||
|
||||
reader.readTuple(tuple);
|
||||
region.offsetX = parseInt(tuple[0]);
|
||||
region.offsetY = parseInt(tuple[1]);
|
||||
|
||||
region.index = parseInt(reader.readValue());
|
||||
|
||||
this.regions.push(region);
|
||||
}
|
||||
}
|
||||
};
|
||||
spine.Atlas.prototype = {
|
||||
findRegion: function (name) {
|
||||
var regions = this.regions;
|
||||
for (var i = 0, n = regions.length; i < n; i++)
|
||||
if (regions[i].name == name) return regions[i];
|
||||
return null;
|
||||
},
|
||||
dispose: function () {
|
||||
var pages = this.pages;
|
||||
for (var i = 0, n = pages.length; i < n; i++)
|
||||
this.textureLoader.unload(pages[i].rendererObject);
|
||||
},
|
||||
updateUVs: function (page) {
|
||||
var regions = this.regions;
|
||||
for (var i = 0, n = regions.length; i < n; i++) {
|
||||
var region = regions[i];
|
||||
if (region.page != page) continue;
|
||||
region.u = region.x / page.width;
|
||||
region.v = region.y / page.height;
|
||||
if (region.rotate) {
|
||||
region.u2 = (region.x + region.height) / page.width;
|
||||
region.v2 = (region.y + region.width) / page.height;
|
||||
} else {
|
||||
region.u2 = (region.x + region.width) / page.width;
|
||||
region.v2 = (region.y + region.height) / page.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spine.Atlas.Format = {
|
||||
alpha: 0,
|
||||
intensity: 1,
|
||||
luminanceAlpha: 2,
|
||||
rgb565: 3,
|
||||
rgba4444: 4,
|
||||
rgb888: 5,
|
||||
rgba8888: 6
|
||||
};
|
||||
|
||||
spine.Atlas.TextureFilter = {
|
||||
nearest: 0,
|
||||
linear: 1,
|
||||
mipMap: 2,
|
||||
mipMapNearestNearest: 3,
|
||||
mipMapLinearNearest: 4,
|
||||
mipMapNearestLinear: 5,
|
||||
mipMapLinearLinear: 6
|
||||
};
|
||||
|
||||
spine.Atlas.TextureWrap = {
|
||||
mirroredRepeat: 0,
|
||||
clampToEdge: 1,
|
||||
repeat: 2
|
||||
};
|
||||
|
||||
spine.AtlasPage = function () {};
|
||||
spine.AtlasPage.prototype = {
|
||||
name: null,
|
||||
format: null,
|
||||
minFilter: null,
|
||||
magFilter: null,
|
||||
uWrap: null,
|
||||
vWrap: null,
|
||||
rendererObject: null,
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
|
||||
spine.AtlasRegion = function () {};
|
||||
spine.AtlasRegion.prototype = {
|
||||
page: null,
|
||||
name: null,
|
||||
x: 0, y: 0,
|
||||
width: 0, height: 0,
|
||||
u: 0, v: 0, u2: 0, v2: 0,
|
||||
offsetX: 0, offsetY: 0,
|
||||
originalWidth: 0, originalHeight: 0,
|
||||
index: 0,
|
||||
rotate: false,
|
||||
splits: null,
|
||||
pads: null,
|
||||
};
|
||||
|
||||
spine.AtlasReader = function (text) {
|
||||
this.lines = text.split(/\r\n|\r|\n/);
|
||||
};
|
||||
spine.AtlasReader.prototype = {
|
||||
index: 0,
|
||||
trim: function (value) {
|
||||
return value.replace(/^\s+|\s+$/g, "");
|
||||
},
|
||||
readLine: function () {
|
||||
if (this.index >= this.lines.length) return null;
|
||||
return this.lines[this.index++];
|
||||
},
|
||||
readValue: function () {
|
||||
var line = this.readLine();
|
||||
var colon = line.indexOf(":");
|
||||
if (colon == -1) throw "Invalid line: " + line;
|
||||
return this.trim(line.substring(colon + 1));
|
||||
},
|
||||
/** Returns the number of tuple values read (2 or 4). */
|
||||
readTuple: function (tuple) {
|
||||
var line = this.readLine();
|
||||
var colon = line.indexOf(":");
|
||||
if (colon == -1) throw "Invalid line: " + line;
|
||||
var i = 0, lastMatch= colon + 1;
|
||||
for (; i < 3; i++) {
|
||||
var comma = line.indexOf(",", lastMatch);
|
||||
if (comma == -1) {
|
||||
if (i == 0) throw "Invalid line: " + line;
|
||||
break;
|
||||
}
|
||||
tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch));
|
||||
lastMatch = comma + 1;
|
||||
}
|
||||
tuple[i] = this.trim(line.substring(lastMatch));
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
spine.AtlasAttachmentLoader = function (atlas) {
|
||||
this.atlas = atlas;
|
||||
}
|
||||
spine.AtlasAttachmentLoader.prototype = {
|
||||
newAttachment: function (skin, type, name) {
|
||||
switch (type) {
|
||||
case spine.AttachmentType.region:
|
||||
var region = this.atlas.findRegion(name);
|
||||
if (!region) throw "Region not found in atlas: " + name + " (" + type + ")";
|
||||
var attachment = new spine.RegionAttachment(name);
|
||||
attachment.rendererObject = region;
|
||||
attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate);
|
||||
attachment.regionOffsetX = region.offsetX;
|
||||
attachment.regionOffsetY = region.offsetY;
|
||||
attachment.regionWidth = region.width;
|
||||
attachment.regionHeight = region.height;
|
||||
attachment.regionOriginalWidth = region.originalWidth;
|
||||
attachment.regionOriginalHeight = region.originalHeight;
|
||||
return attachment;
|
||||
}
|
||||
throw "Unknown attachment type: " + type;
|
||||
}
|
||||
}
|
||||
|
||||
44
spine-js/turbulenz/SpriteBatch.js
Normal file
44
spine-js/turbulenz/SpriteBatch.js
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
function SpriteBatch (draw2D) {
|
||||
this.draw2D = draw2D;
|
||||
this.buffer = [];
|
||||
}
|
||||
SpriteBatch.prototype = {
|
||||
count: 0,
|
||||
texture: null,
|
||||
begin: function (blendMode, sortMode) {
|
||||
this.draw2D.begin(blendMode, sortMode);
|
||||
},
|
||||
add: function (texture, x1, y1, x2, y2, x3, y3, x4, y4, r, g, b, a, u1, v1, u2, v2) {
|
||||
if (this.texture && this.texture != texture) this.flush();
|
||||
this.texture = texture;
|
||||
var index = this.count++ * 16;
|
||||
var buffer = this.buffer;
|
||||
buffer[index++] = x1;
|
||||
buffer[index++] = y1;
|
||||
buffer[index++] = x2;
|
||||
buffer[index++] = y2;
|
||||
buffer[index++] = x3;
|
||||
buffer[index++] = y3;
|
||||
buffer[index++] = x4;
|
||||
buffer[index++] = y4;
|
||||
buffer[index++] = r;
|
||||
buffer[index++] = g;
|
||||
buffer[index++] = b;
|
||||
buffer[index++] = a;
|
||||
buffer[index++] = u1;
|
||||
buffer[index++] = v1;
|
||||
buffer[index++] = u2;
|
||||
buffer[index] = v2;
|
||||
},
|
||||
flush: function () {
|
||||
if (!this.texture) return;
|
||||
this.draw2D.drawRaw(this.texture, this.buffer, this.count, 0);
|
||||
this.texture = null;
|
||||
this.count = 0;
|
||||
},
|
||||
end: function () {
|
||||
this.flush();
|
||||
this.draw2D.end();
|
||||
}
|
||||
};
|
||||
2380
spine-js/turbulenz/draw2d.js
Normal file
2380
spine-js/turbulenz/draw2d.js
Normal file
File diff suppressed because it is too large
Load Diff
6208
spine-js/turbulenz/graphicsdevice.js
Normal file
6208
spine-js/turbulenz/graphicsdevice.js
Normal file
File diff suppressed because it is too large
Load Diff
153
spine-js/turbulenz/index.html
Normal file
153
spine-js/turbulenz/index.html
Normal file
@ -0,0 +1,153 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>spine-js</title>
|
||||
<script src="../spine.js"></script>
|
||||
<script src="turbulenzengine.js"></script>
|
||||
<script src="graphicsdevice.js"></script>
|
||||
<script src="draw2d.js"></script>
|
||||
<script src="SpriteBatch.js"></script>
|
||||
<style>body, input { font-family: tahoma; font-size: 11pt }</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="message"></div>
|
||||
<div><canvas id="canvas" width="640" height="480"/></div>
|
||||
<br>
|
||||
<input type="button" value="Spineboy" onclick="load('spineboy')">
|
||||
<input type="button" value="Goblins" onclick="load('goblins')">
|
||||
Click above to change the animation (Spineboy) or skin (Goblins).
|
||||
|
||||
<script>
|
||||
var canvas = document.getElementById("canvas");
|
||||
var TurbulenzEngine = WebGLTurbulenzEngine.create({canvas: canvas});
|
||||
var graphicsDevice = TurbulenzEngine.createGraphicsDevice({});
|
||||
var draw2D = Draw2D.create({graphicsDevice: graphicsDevice});
|
||||
|
||||
load("spineboy");
|
||||
//load("goblins");
|
||||
|
||||
var skeletonName;
|
||||
function load (name) {
|
||||
skeletonName = name;
|
||||
TurbulenzEngine.request("../data/" + skeletonName + ".atlas", loadAtlas);
|
||||
}
|
||||
|
||||
var atlas;
|
||||
function loadAtlas (atlasText) {
|
||||
var textureCount = 0;
|
||||
atlas = new spine.Atlas(atlasText, {
|
||||
load: function (page, path) {
|
||||
textureCount++;
|
||||
graphicsDevice.createTexture({
|
||||
src: "../data/" + path,
|
||||
mipmaps: true,
|
||||
onload: function (texture) {
|
||||
page.rendererObject = texture;
|
||||
page.width = texture.width;
|
||||
page.height = texture.height;
|
||||
atlas.updateUVs(page);
|
||||
textureCount--;
|
||||
}
|
||||
});
|
||||
},
|
||||
unload: function (texture) {
|
||||
texture.destroy();
|
||||
}
|
||||
});
|
||||
function waitForTextures () {
|
||||
if (!textureCount)
|
||||
TurbulenzEngine.request("../data/" + skeletonName + ".json", loadSkeletonData);
|
||||
else
|
||||
setTimeout(waitForTextures, 100);
|
||||
}
|
||||
waitForTextures();
|
||||
}
|
||||
|
||||
var skeletonData;
|
||||
function loadSkeletonData (skeletonText) {
|
||||
var json = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas));
|
||||
skeletonData = json.readSkeletonData(JSON.parse(skeletonText));
|
||||
start();
|
||||
}
|
||||
|
||||
function start () {
|
||||
spine.Bone.yDown = true;
|
||||
|
||||
var skeleton = new spine.Skeleton(skeletonData);
|
||||
skeleton.getRootBone().x = 320;
|
||||
skeleton.getRootBone().y = 440;
|
||||
skeleton.updateWorldTransform();
|
||||
|
||||
var stateData = new spine.AnimationStateData(skeletonData);
|
||||
var state = new spine.AnimationState(stateData);
|
||||
|
||||
if (skeletonName == "spineboy") {
|
||||
stateData.setMixByName("walk", "jump", 0.2);
|
||||
stateData.setMixByName("jump", "walk", 0.4);
|
||||
state.setAnimationByName("walk", true);
|
||||
|
||||
canvas.onmousedown = function () {
|
||||
state.setAnimationByName("jump", false);
|
||||
state.addAnimationByName("walk", true);
|
||||
}
|
||||
} else {
|
||||
skeleton.setSkinByName("goblingirl");
|
||||
skeleton.setSlotsToSetupPose();
|
||||
state.setAnimationByName("walk", true);
|
||||
|
||||
canvas.onmousedown = function () {
|
||||
skeleton.setSkinByName(skeleton.skin.name == "goblin" ? "goblingirl" : "goblin");
|
||||
skeleton.setSlotsToSetupPose();
|
||||
}
|
||||
}
|
||||
|
||||
var bgColor = [0.9, 0.9, 0.9, 1.0];
|
||||
var batch = new SpriteBatch(draw2D);
|
||||
var lastTime = TurbulenzEngine.time;
|
||||
function update() {
|
||||
if (!graphicsDevice) return;
|
||||
|
||||
var delta = TurbulenzEngine.time - lastTime;
|
||||
lastTime = TurbulenzEngine.time;
|
||||
state.update(delta);
|
||||
state.apply(skeleton);
|
||||
skeleton.updateWorldTransform();
|
||||
|
||||
graphicsDevice.clear(bgColor, 1.0);
|
||||
batch.begin(draw2D.blend.alpha);
|
||||
drawSkeleton(batch, skeleton);
|
||||
batch.end();
|
||||
graphicsDevice.endFrame();
|
||||
}
|
||||
|
||||
TurbulenzEngine.setInterval(update, 1000 / 60);
|
||||
}
|
||||
|
||||
var vertices = [];
|
||||
function drawSkeleton (batch, skeleton) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
for (var i = 0, n = drawOrder.length; i < n; i++) {
|
||||
var slot = drawOrder[i];
|
||||
var attachment = slot.attachment;
|
||||
if (!(attachment instanceof spine.RegionAttachment)) continue;
|
||||
attachment.computeVertices(slot.bone, vertices);
|
||||
batch.add(
|
||||
attachment.rendererObject.page.rendererObject,
|
||||
vertices[0], vertices[1],
|
||||
vertices[6], vertices[7],
|
||||
vertices[2], vertices[3],
|
||||
vertices[4], vertices[5],
|
||||
skeleton.r * slot.r,
|
||||
skeleton.g * slot.g,
|
||||
skeleton.b * slot.b,
|
||||
skeleton.a * slot.a,
|
||||
attachment.uvs[0], attachment.uvs[1],
|
||||
attachment.uvs[4], attachment.uvs[5]
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
843
spine-js/turbulenz/turbulenzengine.js
Normal file
843
spine-js/turbulenz/turbulenzengine.js
Normal file
@ -0,0 +1,843 @@
|
||||
// Copyright (c) 2011-2012 Turbulenz Limited
|
||||
/*global VMath*/
|
||||
/*global WebGLGraphicsDevice*/
|
||||
/*global WebGLInputDevice*/
|
||||
/*global WebGLSoundDevice*/
|
||||
/*global WebGLPhysicsDevice*/
|
||||
/*global WebGLNetworkDevice*/
|
||||
/*global Float32Array*/
|
||||
/*global console*/
|
||||
/*global window*/
|
||||
"use strict";
|
||||
|
||||
//
|
||||
// WebGLTurbulenzEngine
|
||||
//
|
||||
function WebGLTurbulenzEngine() {}
|
||||
WebGLTurbulenzEngine.prototype = {
|
||||
|
||||
version : '0.24.0.0',
|
||||
|
||||
setInterval: function (f, t)
|
||||
{
|
||||
var that = this;
|
||||
return window.setInterval(function () {
|
||||
that.updateTime();
|
||||
f();
|
||||
}, t);
|
||||
},
|
||||
|
||||
clearInterval: function (i)
|
||||
{
|
||||
return window.clearInterval(i);
|
||||
},
|
||||
|
||||
createGraphicsDevice: function (params)
|
||||
{
|
||||
if (this.graphicsDevice)
|
||||
{
|
||||
this.callOnError('GraphicsDevice already created');
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var graphicsDevice = WebGLGraphicsDevice.create(this.canvas, params);
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
return graphicsDevice;
|
||||
}
|
||||
},
|
||||
|
||||
createPhysicsDevice: function (params)
|
||||
{
|
||||
if (this.physicsDevice)
|
||||
{
|
||||
this.callOnError('PhysicsDevice already created');
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var physicsDevice;
|
||||
var plugin = this.getPluginObject();
|
||||
if (plugin)
|
||||
{
|
||||
physicsDevice = plugin.createPhysicsDevice(params);
|
||||
}
|
||||
else
|
||||
{
|
||||
physicsDevice = WebGLPhysicsDevice.create(params);
|
||||
}
|
||||
this.physicsDevice = physicsDevice;
|
||||
return physicsDevice;
|
||||
}
|
||||
},
|
||||
|
||||
createSoundDevice: function (params)
|
||||
{
|
||||
if (this.soundDevice)
|
||||
{
|
||||
this.callOnError('SoundDevice already created');
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var soundDevice;
|
||||
var plugin = this.getPluginObject();
|
||||
if (plugin)
|
||||
{
|
||||
soundDevice = plugin.createSoundDevice(params);
|
||||
}
|
||||
else
|
||||
{
|
||||
soundDevice = WebGLSoundDevice.create(params);
|
||||
}
|
||||
this.soundDevice = soundDevice;
|
||||
return soundDevice;
|
||||
}
|
||||
},
|
||||
|
||||
createInputDevice: function (params)
|
||||
{
|
||||
if (this.inputDevice)
|
||||
{
|
||||
this.callOnError('InputDevice already created');
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var inputDevice = WebGLInputDevice.create(this.canvas, params);
|
||||
this.inputDevice = inputDevice;
|
||||
return inputDevice;
|
||||
}
|
||||
},
|
||||
|
||||
createNetworkDevice: function (params)
|
||||
{
|
||||
if (this.networkDevice)
|
||||
{
|
||||
throw 'NetworkDevice already created';
|
||||
}
|
||||
else
|
||||
{
|
||||
var networkDevice = WebGLNetworkDevice.create(params);
|
||||
this.networkDevice = networkDevice;
|
||||
return networkDevice;
|
||||
}
|
||||
},
|
||||
|
||||
createMathDevice: function (/* params */)
|
||||
{
|
||||
// Check if the browser supports using apply with Float32Array
|
||||
try
|
||||
{
|
||||
var testVector = new Float32Array([1, 2, 3]);
|
||||
|
||||
VMath.v3Build.apply(VMath, testVector);
|
||||
|
||||
// Clamp FLOAT_MAX
|
||||
testVector[0] = VMath.FLOAT_MAX;
|
||||
VMath.FLOAT_MAX = testVector[0];
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
|
||||
return VMath;
|
||||
},
|
||||
|
||||
createNativeMathDevice: function (/* params */)
|
||||
{
|
||||
return VMath;
|
||||
},
|
||||
|
||||
getGraphicsDevice: function ()
|
||||
{
|
||||
var graphicsDevice = this.graphicsDevice;
|
||||
if (graphicsDevice === null)
|
||||
{
|
||||
this.callOnError("GraphicsDevice not created yet.");
|
||||
}
|
||||
return graphicsDevice;
|
||||
},
|
||||
|
||||
getPhysicsDevice: function ()
|
||||
{
|
||||
return this.physicsDevice;
|
||||
},
|
||||
|
||||
getSoundDevice: function ()
|
||||
{
|
||||
return this.soundDevice;
|
||||
},
|
||||
|
||||
getInputDevice: function ()
|
||||
{
|
||||
return this.inputDevice;
|
||||
},
|
||||
|
||||
getNetworkDevice: function ()
|
||||
{
|
||||
return this.networkDevice;
|
||||
},
|
||||
|
||||
getMathDevice: function ()
|
||||
{
|
||||
return VMath;
|
||||
},
|
||||
|
||||
getNativeMathDevice: function ()
|
||||
{
|
||||
return VMath;
|
||||
},
|
||||
|
||||
flush: function ()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
run: function ()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
encrypt: function (msg)
|
||||
{
|
||||
return msg;
|
||||
},
|
||||
|
||||
decrypt: function (msg)
|
||||
{
|
||||
return msg;
|
||||
},
|
||||
|
||||
generateSignature: function (/* msg */)
|
||||
{
|
||||
return null;
|
||||
},
|
||||
|
||||
verifySignature: function (/* msg, sig */)
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
onerror: function (msg)
|
||||
{
|
||||
console.error(msg);
|
||||
},
|
||||
|
||||
onwarning: function (msg)
|
||||
{
|
||||
console.warn(msg);
|
||||
},
|
||||
|
||||
getSystemInfo: function ()
|
||||
{
|
||||
return this.systemInfo;
|
||||
},
|
||||
|
||||
request: function (url, callback)
|
||||
{
|
||||
var that = this;
|
||||
|
||||
var xhr;
|
||||
if (window.XMLHttpRequest)
|
||||
{
|
||||
xhr = new window.XMLHttpRequest();
|
||||
}
|
||||
else if (window.ActiveXObject)
|
||||
{
|
||||
xhr = new window.ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
else
|
||||
{
|
||||
that.callOnError("No XMLHTTPRequest object could be created");
|
||||
return;
|
||||
}
|
||||
|
||||
function httpRequestCallback()
|
||||
{
|
||||
if (xhr.readyState === 4) /* 4 == complete */
|
||||
{
|
||||
if (!that.isUnloading())
|
||||
{
|
||||
var xhrResponseText = xhr.responseText;
|
||||
var xhrStatus = xhr.status;
|
||||
|
||||
if ("" === xhrResponseText)
|
||||
{
|
||||
xhrResponseText = null;
|
||||
}
|
||||
|
||||
if (null === xhr.getResponseHeader("Content-Type") &&
|
||||
"" === xhr.getAllResponseHeaders())
|
||||
{
|
||||
// Sometimes the browser sets status to 200 OK
|
||||
// when the connection is closed before the
|
||||
// message is sent (weird!). In order to address
|
||||
// this we fail any completely empty responses.
|
||||
// Hopefully, nobody will get a valid response
|
||||
// with no headers and no body!
|
||||
// Except that for cross domain requests getAllResponseHeaders ALWAYS returns an empty string
|
||||
// even for valid responses...
|
||||
callback(null, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fix for loading from file
|
||||
if (xhrStatus === 0 && xhrResponseText && window.location.protocol === "file:")
|
||||
{
|
||||
xhrStatus = 200;
|
||||
}
|
||||
|
||||
// Invoke the callback
|
||||
if (xhrStatus !== 0)
|
||||
{
|
||||
// Under these conditions, we return a null
|
||||
// response text.
|
||||
|
||||
if (404 === xhrStatus)
|
||||
{
|
||||
xhrResponseText = null;
|
||||
}
|
||||
|
||||
callback(xhrResponseText, xhrStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Checking xhr.statusText when xhr.status is
|
||||
// 0 causes a silent error
|
||||
|
||||
callback(xhrResponseText, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// break circular reference
|
||||
xhr.onreadystatechange = null;
|
||||
xhr = null;
|
||||
callback = null;
|
||||
}
|
||||
}
|
||||
|
||||
xhr.open('GET', url, true);
|
||||
if (callback)
|
||||
{
|
||||
xhr.onreadystatechange = httpRequestCallback;
|
||||
}
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
// Internals
|
||||
destroy : function ()
|
||||
{
|
||||
if (this.networkDevice)
|
||||
{
|
||||
delete this.networkDevice;
|
||||
}
|
||||
if (this.inputDevice)
|
||||
{
|
||||
this.inputDevice.destroy();
|
||||
delete this.inputDevice;
|
||||
}
|
||||
if (this.physicsDevice)
|
||||
{
|
||||
delete this.physicsDevice;
|
||||
}
|
||||
if (this.soundDevice)
|
||||
{
|
||||
if (this.soundDevice.destroy)
|
||||
{
|
||||
this.soundDevice.destroy();
|
||||
}
|
||||
delete this.soundDevice;
|
||||
}
|
||||
if (this.graphicsDevice)
|
||||
{
|
||||
this.graphicsDevice.destroy();
|
||||
delete this.graphicsDevice;
|
||||
}
|
||||
if (this.canvas)
|
||||
{
|
||||
delete this.canvas;
|
||||
}
|
||||
if (this.resizeCanvas)
|
||||
{
|
||||
window.removeEventListener('resize', this.resizeCanvas, false);
|
||||
}
|
||||
},
|
||||
|
||||
getPluginObject : function ()
|
||||
{
|
||||
if (!this.plugin &&
|
||||
this.pluginId)
|
||||
{
|
||||
this.plugin = document.getElementById(this.pluginId);
|
||||
}
|
||||
return this.plugin;
|
||||
},
|
||||
|
||||
unload : function ()
|
||||
{
|
||||
if (!this.unloading)
|
||||
{
|
||||
this.unloading = true;
|
||||
if (this.onunload)
|
||||
{
|
||||
this.onunload();
|
||||
}
|
||||
if (this.destroy)
|
||||
{
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isUnloading : function ()
|
||||
{
|
||||
return this.unloading;
|
||||
},
|
||||
|
||||
enableProfiling : function ()
|
||||
{
|
||||
},
|
||||
|
||||
startProfiling : function ()
|
||||
{
|
||||
if (console && console.profile && console.profileEnd)
|
||||
{
|
||||
console.profile("turbulenz");
|
||||
}
|
||||
},
|
||||
|
||||
stopProfiling : function ()
|
||||
{
|
||||
// Chrome and Safari return an object. IE and Firefox print to the console/profile tab.
|
||||
var result;
|
||||
if (console && console.profile && console.profileEnd)
|
||||
{
|
||||
console.profileEnd("turbulenz");
|
||||
if (console.profiles)
|
||||
{
|
||||
result = console.profiles[console.profiles.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
callOnError : function (msg)
|
||||
{
|
||||
var onerror = this.onerror;
|
||||
if (onerror)
|
||||
{
|
||||
onerror(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Constructor function
|
||||
WebGLTurbulenzEngine.create = function webGLTurbulenzEngineFn(params)
|
||||
{
|
||||
var tz = new WebGLTurbulenzEngine();
|
||||
|
||||
var canvas = params.canvas;
|
||||
var fillParent = params.fillParent;
|
||||
|
||||
// To expose unload (the whole interaction needs a re-design)
|
||||
window.TurbulenzEngineCanvas = tz;
|
||||
|
||||
tz.pluginId = params.pluginId;
|
||||
tz.plugin = null;
|
||||
|
||||
// time property
|
||||
var getTime = Date.now;
|
||||
var performance = window.performance;
|
||||
if (performance)
|
||||
{
|
||||
// It seems high resolution "now" requires a proper "this"
|
||||
if (performance.now)
|
||||
{
|
||||
getTime = function getTimeFn()
|
||||
{
|
||||
return performance.now();
|
||||
};
|
||||
}
|
||||
else if (performance.webkitNow)
|
||||
{
|
||||
getTime = function getTimeFn()
|
||||
{
|
||||
return performance.webkitNow();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// To be used by the GraphicsDevice for accurate fps calculations
|
||||
tz.getTime = getTime;
|
||||
|
||||
var baseTime = getTime(); // all in milliseconds (our "time" property is in seconds)
|
||||
|
||||
// Safari 6.0 has broken object property defines.
|
||||
var canUseDefineProperty = true;
|
||||
var navStr = navigator.userAgent;
|
||||
var navVersionIdx = navStr.indexOf("Version/6.0");
|
||||
if (-1 !== navVersionIdx)
|
||||
{
|
||||
if (-1 !== navStr.substring(navVersionIdx).indexOf("Safari/"))
|
||||
{
|
||||
canUseDefineProperty = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canUseDefineProperty && Object.defineProperty)
|
||||
{
|
||||
Object.defineProperty(tz, "time", {
|
||||
get : function () {
|
||||
return ((getTime() - baseTime) * 0.001);
|
||||
},
|
||||
set : function (newValue) {
|
||||
if (typeof newValue === 'number')
|
||||
{
|
||||
// baseTime is in milliseconds, newValue is in seconds
|
||||
baseTime = (getTime() - (newValue * 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
tz.callOnError("Must set 'time' attribute to a number");
|
||||
}
|
||||
},
|
||||
enumerable : false,
|
||||
configurable : false
|
||||
});
|
||||
|
||||
tz.updateTime = function ()
|
||||
{
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
tz.updateTime = function ()
|
||||
{
|
||||
this.time = ((getTime() - baseTime) * 0.001);
|
||||
};
|
||||
}
|
||||
|
||||
// fast zero timeouts
|
||||
if (window.postMessage)
|
||||
{
|
||||
var zeroTimeoutMessageName = "0-timeout-message";
|
||||
var timeouts = [];
|
||||
var timeId = 0;
|
||||
|
||||
var setZeroTimeout = function setZeroTimeoutFn(fn)
|
||||
{
|
||||
timeId += 1;
|
||||
var timeout = {
|
||||
id : timeId,
|
||||
fn : fn
|
||||
};
|
||||
timeouts.push(timeout);
|
||||
window.postMessage(zeroTimeoutMessageName, "*");
|
||||
return timeout;
|
||||
};
|
||||
|
||||
var clearZeroTimeout = function clearZeroTimeoutFn(timeout)
|
||||
{
|
||||
var id = timeout;
|
||||
var numTimeouts = timeouts.length;
|
||||
for (var n = 0; n < numTimeouts; n += 1)
|
||||
{
|
||||
if (timeouts[n].id === id)
|
||||
{
|
||||
timeouts.splice(n, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var handleZeroTimeoutMessages = function handleZeroTimeoutMessagesFn(event)
|
||||
{
|
||||
if (event.source === window &&
|
||||
event.data === zeroTimeoutMessageName)
|
||||
{
|
||||
event.stopPropagation();
|
||||
|
||||
if (timeouts.length && !tz.isUnloading())
|
||||
{
|
||||
var timeout = timeouts.shift();
|
||||
var fn = timeout.fn;
|
||||
fn();
|
||||
}
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", handleZeroTimeoutMessages, true);
|
||||
|
||||
tz.setTimeout = function (f, t)
|
||||
{
|
||||
if (t < 1)
|
||||
{
|
||||
return setZeroTimeout(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
var that = this;
|
||||
return window.setTimeout(function () {
|
||||
that.updateTime();
|
||||
if (!that.isUnloading())
|
||||
{
|
||||
f();
|
||||
}
|
||||
}, t);
|
||||
}
|
||||
};
|
||||
|
||||
tz.clearTimeout = function (i)
|
||||
{
|
||||
if (typeof i === 'object')
|
||||
{
|
||||
return clearZeroTimeout(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
return window.clearTimeout(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
tz.setTimeout = function (f, t)
|
||||
{
|
||||
var that = this;
|
||||
return window.setTimeout(function () {
|
||||
that.updateTime();
|
||||
if (!that.isUnloading())
|
||||
{
|
||||
f();
|
||||
}
|
||||
}, t);
|
||||
};
|
||||
|
||||
tz.clearTimeout = function (i)
|
||||
{
|
||||
return window.clearTimeout(i);
|
||||
};
|
||||
}
|
||||
|
||||
var requestAnimationFrame = (window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame);
|
||||
if (requestAnimationFrame)
|
||||
{
|
||||
tz.setInterval = function (f, t)
|
||||
{
|
||||
var that = this;
|
||||
if (Math.abs(t - (1000 / 60)) <= 1)
|
||||
{
|
||||
var interval = {
|
||||
enabled: true
|
||||
};
|
||||
var wrap1 = function wrap1()
|
||||
{
|
||||
if (interval.enabled)
|
||||
{
|
||||
that.updateTime();
|
||||
if (!that.isUnloading())
|
||||
{
|
||||
f();
|
||||
}
|
||||
requestAnimationFrame(wrap1, that.canvas);
|
||||
}
|
||||
};
|
||||
requestAnimationFrame(wrap1, that.canvas);
|
||||
return interval;
|
||||
}
|
||||
else
|
||||
{
|
||||
var wrap2 = function wrap2()
|
||||
{
|
||||
that.updateTime();
|
||||
if (!that.isUnloading())
|
||||
{
|
||||
f();
|
||||
}
|
||||
};
|
||||
return window.setInterval(wrap2, t);
|
||||
}
|
||||
};
|
||||
|
||||
tz.clearInterval = function (i)
|
||||
{
|
||||
if (typeof i === 'object')
|
||||
{
|
||||
i.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.clearInterval(i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
tz.canvas = canvas;
|
||||
tz.networkDevice = null;
|
||||
tz.inputDevice = null;
|
||||
tz.physicsDevice = null;
|
||||
tz.soundDevice = null;
|
||||
tz.graphicsDevice = null;
|
||||
|
||||
if (fillParent)
|
||||
{
|
||||
// Resize canvas to fill parent
|
||||
tz.resizeCanvas = function ()
|
||||
{
|
||||
canvas.width = canvas.parentNode.clientWidth;
|
||||
canvas.height = canvas.parentNode.clientHeight;
|
||||
};
|
||||
|
||||
tz.resizeCanvas();
|
||||
|
||||
window.addEventListener('resize', tz.resizeCanvas, false);
|
||||
}
|
||||
|
||||
var previousOnBeforeUnload = window.onbeforeunload;
|
||||
window.onbeforeunload = function ()
|
||||
{
|
||||
tz.unload();
|
||||
|
||||
if (previousOnBeforeUnload)
|
||||
{
|
||||
previousOnBeforeUnload.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
tz.time = 0;
|
||||
|
||||
// System info
|
||||
var systemInfo = {
|
||||
architecture: '',
|
||||
cpuDescription: '',
|
||||
cpuVendor: '',
|
||||
numPhysicalCores: 1,
|
||||
numLogicalCores: 1,
|
||||
ramInMegabytes: 0,
|
||||
frequencyInMegaHZ: 0,
|
||||
osVersionMajor: 0,
|
||||
osVersionMinor: 0,
|
||||
osVersionBuild: 0,
|
||||
osName: navigator.platform,
|
||||
userLocale: (navigator.language || navigator.userLanguage).replace('-', '_')
|
||||
};
|
||||
var userAgent = navigator.userAgent;
|
||||
var osIndex = userAgent.indexOf('Windows');
|
||||
if (osIndex !== -1)
|
||||
{
|
||||
systemInfo.osName = 'Windows';
|
||||
if (navigator.platform === 'Win64')
|
||||
{
|
||||
systemInfo.architecture = 'x86_64';
|
||||
}
|
||||
else if (navigator.platform === 'Win32')
|
||||
{
|
||||
systemInfo.architecture = 'x86';
|
||||
}
|
||||
osIndex += 7;
|
||||
if (userAgent.slice(osIndex, (osIndex + 4)) === ' NT ')
|
||||
{
|
||||
osIndex += 4;
|
||||
systemInfo.osVersionMajor = parseInt(userAgent.slice(osIndex, (osIndex + 1)), 10);
|
||||
systemInfo.osVersionMinor = parseInt(userAgent.slice((osIndex + 2), (osIndex + 4)), 10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
osIndex = userAgent.indexOf('Mac OS X');
|
||||
if (osIndex !== -1)
|
||||
{
|
||||
systemInfo.osName = 'Darwin';
|
||||
if (navigator.platform.indexOf('Intel') !== -1)
|
||||
{
|
||||
systemInfo.architecture = 'x86';
|
||||
}
|
||||
osIndex += 9;
|
||||
systemInfo.osVersionMajor = parseInt(userAgent.slice(osIndex, (osIndex + 2)), 10);
|
||||
systemInfo.osVersionMinor = parseInt(userAgent.slice((osIndex + 3), (osIndex + 4)), 10);
|
||||
systemInfo.osVersionBuild = (parseInt(userAgent.slice((osIndex + 5), (osIndex + 6)), 10) || 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
osIndex = userAgent.indexOf('Linux');
|
||||
if (osIndex !== -1)
|
||||
{
|
||||
systemInfo.osName = 'Linux';
|
||||
if (navigator.platform.indexOf('64') !== -1)
|
||||
{
|
||||
systemInfo.architecture = 'x86_64';
|
||||
}
|
||||
else if (navigator.platform.indexOf('x86') !== -1)
|
||||
{
|
||||
systemInfo.architecture = 'x86';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tz.systemInfo = systemInfo;
|
||||
|
||||
var b64ConversionTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split('');
|
||||
|
||||
tz.base64Encode = function base64EncodeFn(bytes)
|
||||
{
|
||||
var output = "";
|
||||
var numBytes = bytes.length;
|
||||
var valueToChar = b64ConversionTable;
|
||||
var n, chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
|
||||
/*jshint bitwise: false*/
|
||||
n = 0;
|
||||
while (n < numBytes)
|
||||
{
|
||||
chr1 = bytes[n];
|
||||
n += 1;
|
||||
|
||||
enc1 = (chr1 >> 2);
|
||||
|
||||
if (n < numBytes)
|
||||
{
|
||||
chr2 = bytes[n];
|
||||
n += 1;
|
||||
|
||||
if (n < numBytes)
|
||||
{
|
||||
chr3 = bytes[n];
|
||||
n += 1;
|
||||
|
||||
enc2 = (((chr1 & 3) << 4) | (chr2 >> 4));
|
||||
enc3 = (((chr2 & 15) << 2) | (chr3 >> 6));
|
||||
enc4 = (chr3 & 63);
|
||||
}
|
||||
else
|
||||
{
|
||||
enc2 = (((chr1 & 3) << 4) | (chr2 >> 4));
|
||||
enc3 = ((chr2 & 15) << 2);
|
||||
enc4 = 64;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
enc2 = ((chr1 & 3) << 4);
|
||||
enc3 = 64;
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output += valueToChar[enc1];
|
||||
output += valueToChar[enc2];
|
||||
output += valueToChar[enc3];
|
||||
output += valueToChar[enc4];
|
||||
}
|
||||
/*jshint bitwise: true*/
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
return tz;
|
||||
};
|
||||
|
||||
window.WebGLTurbulenzEngine = WebGLTurbulenzEngine;
|
||||
Loading…
x
Reference in New Issue
Block a user