@esotericsoftware/spine-webgl 4.1.16 → 4.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,7 +56,6 @@ var spine = (() => {
56
56
  Input: () => Input,
57
57
  IntSet: () => IntSet,
58
58
  Interpolation: () => Interpolation,
59
- JitterEffect: () => JitterEffect,
60
59
  LoadingScreen: () => LoadingScreen,
61
60
  M00: () => M00,
62
61
  M01: () => M01,
@@ -132,7 +131,6 @@ var spine = (() => {
132
131
  SpacingMode: () => SpacingMode,
133
132
  SpineCanvas: () => SpineCanvas,
134
133
  StringSet: () => StringSet,
135
- SwirlEffect: () => SwirlEffect,
136
134
  TexCoordAttribute: () => TexCoordAttribute,
137
135
  Texture: () => Texture,
138
136
  TextureAtlas: () => TextureAtlas,
@@ -555,9 +553,9 @@ var spine = (() => {
555
553
  super(name);
556
554
  this.id = _VertexAttachment.nextID++;
557
555
  this.bones = null;
558
- this.vertices = null;
556
+ this.vertices = [];
559
557
  this.worldVerticesLength = 0;
560
- this.timelineAttahment = this;
558
+ this.timelineAttachment = this;
561
559
  }
562
560
  computeWorldVertices(slot, start, count, worldVertices, offset, stride) {
563
561
  count = offset + (count >> 1) * stride;
@@ -626,10 +624,9 @@ var spine = (() => {
626
624
  if (this.vertices) {
627
625
  attachment.vertices = Utils.newFloatArray(this.vertices.length);
628
626
  Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
629
- } else
630
- attachment.vertices = null;
627
+ }
631
628
  attachment.worldVerticesLength = this.worldVerticesLength;
632
- attachment.timelineAttahment = this.timelineAttahment;
629
+ attachment.timelineAttachment = this.timelineAttachment;
633
630
  }
634
631
  };
635
632
  var VertexAttachment = _VertexAttachment;
@@ -701,8 +698,8 @@ var spine = (() => {
701
698
  // spine-core/src/Animation.ts
702
699
  var Animation = class {
703
700
  constructor(name, timelines, duration) {
704
- this.timelines = null;
705
- this.timelineIds = null;
701
+ this.timelines = [];
702
+ this.timelineIds = new StringSet();
706
703
  if (!name)
707
704
  throw new Error("name cannot be null.");
708
705
  this.name = name;
@@ -713,7 +710,7 @@ var spine = (() => {
713
710
  if (!timelines)
714
711
  throw new Error("timelines cannot be null.");
715
712
  this.timelines = timelines;
716
- this.timelineIds = new StringSet();
713
+ this.timelineIds.clear();
717
714
  for (var i = 0; i < timelines.length; i++)
718
715
  this.timelineIds.addAll(timelines[i].getPropertyIds());
719
716
  }
@@ -772,8 +769,6 @@ var spine = (() => {
772
769
  };
773
770
  var Timeline = class {
774
771
  constructor(frameCount, propertyIds) {
775
- this.propertyIds = null;
776
- this.frames = null;
777
772
  this.propertyIds = propertyIds;
778
773
  this.frames = Utils.newFloatArray(frameCount * this.getFrameEntries());
779
774
  }
@@ -807,7 +802,6 @@ var spine = (() => {
807
802
  var CurveTimeline = class extends Timeline {
808
803
  constructor(frameCount, bezierCount, propertyIds) {
809
804
  super(frameCount, propertyIds);
810
- this.curves = null;
811
805
  this.curves = Utils.newFloatArray(frameCount + bezierCount * 18);
812
806
  this.curves[frameCount - 1] = 1;
813
807
  }
@@ -1867,8 +1861,6 @@ var spine = (() => {
1867
1861
  Property.deform + "|" + slotIndex + "|" + attachment.id
1868
1862
  ]);
1869
1863
  this.slotIndex = 0;
1870
- this.attachment = null;
1871
- this.vertices = null;
1872
1864
  this.slotIndex = slotIndex;
1873
1865
  this.attachment = attachment;
1874
1866
  this.vertices = new Array(frameCount);
@@ -1931,7 +1923,9 @@ var spine = (() => {
1931
1923
  if (!slot.bone.active)
1932
1924
  return;
1933
1925
  let slotAttachment = slot.getAttachment();
1934
- if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != this.attachment)
1926
+ if (!slotAttachment)
1927
+ return;
1928
+ if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttachment != this.attachment)
1935
1929
  return;
1936
1930
  let deform = slot.deform;
1937
1931
  if (deform.length == 0)
@@ -2085,7 +2079,6 @@ var spine = (() => {
2085
2079
  var _EventTimeline = class extends Timeline {
2086
2080
  constructor(frameCount) {
2087
2081
  super(frameCount, _EventTimeline.propertyIds);
2088
- this.events = null;
2089
2082
  this.events = new Array(frameCount);
2090
2083
  }
2091
2084
  getFrameCount() {
@@ -2128,7 +2121,6 @@ var spine = (() => {
2128
2121
  var _DrawOrderTimeline = class extends Timeline {
2129
2122
  constructor(frameCount) {
2130
2123
  super(frameCount, _DrawOrderTimeline.propertyIds);
2131
- this.drawOrders = null;
2132
2124
  this.drawOrders = new Array(frameCount);
2133
2125
  }
2134
2126
  getFrameCount() {
@@ -2149,7 +2141,8 @@ var spine = (() => {
2149
2141
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2150
2142
  return;
2151
2143
  }
2152
- let drawOrderToSetupIndex = this.drawOrders[Timeline.search1(this.frames, time)];
2144
+ let idx = Timeline.search1(this.frames, time);
2145
+ let drawOrderToSetupIndex = this.drawOrders[idx];
2153
2146
  if (!drawOrderToSetupIndex)
2154
2147
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2155
2148
  else {
@@ -2511,7 +2504,7 @@ var spine = (() => {
2511
2504
  let slotAttachment = slot.attachment;
2512
2505
  let attachment = this.attachment;
2513
2506
  if (slotAttachment != attachment) {
2514
- if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != attachment)
2507
+ if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttachment != attachment)
2515
2508
  return;
2516
2509
  }
2517
2510
  let frames = this.frames;
@@ -2524,6 +2517,8 @@ var spine = (() => {
2524
2517
  let before = frames[i];
2525
2518
  let modeAndIndex = frames[i + _SequenceTimeline.MODE];
2526
2519
  let delay = frames[i + _SequenceTimeline.DELAY];
2520
+ if (!this.attachment.sequence)
2521
+ return;
2527
2522
  let index = modeAndIndex >> 4, count = this.attachment.sequence.regions.length;
2528
2523
  let mode = SequenceModeValues[modeAndIndex & 15];
2529
2524
  if (mode != SequenceMode.hold) {
@@ -2537,7 +2532,7 @@ var spine = (() => {
2537
2532
  break;
2538
2533
  case SequenceMode.pingpong: {
2539
2534
  let n = (count << 1) - 2;
2540
- index %= n;
2535
+ index = n == 0 ? 0 : index % n;
2541
2536
  if (index >= count)
2542
2537
  index = n - index;
2543
2538
  break;
@@ -2550,7 +2545,7 @@ var spine = (() => {
2550
2545
  break;
2551
2546
  case SequenceMode.pingpongReverse: {
2552
2547
  let n = (count << 1) - 2;
2553
- index = (index + count - 1) % n;
2548
+ index = n == 0 ? 0 : (index + count - 1) % n;
2554
2549
  if (index >= count)
2555
2550
  index = n - index;
2556
2551
  }
@@ -2565,9 +2560,8 @@ var spine = (() => {
2565
2560
  SequenceTimeline.DELAY = 2;
2566
2561
 
2567
2562
  // spine-core/src/AnimationState.ts
2568
- var AnimationState = class {
2563
+ var _AnimationState = class {
2569
2564
  constructor(data) {
2570
- this.data = null;
2571
2565
  this.tracks = new Array();
2572
2566
  this.timeScale = 1;
2573
2567
  this.unkeyedState = 0;
@@ -2580,9 +2574,7 @@ var spine = (() => {
2580
2574
  this.data = data;
2581
2575
  }
2582
2576
  static emptyAnimation() {
2583
- if (!_emptyAnimation)
2584
- _emptyAnimation = new Animation("<empty>", [], 0);
2585
- return _emptyAnimation;
2577
+ return _AnimationState._emptyAnimation;
2586
2578
  }
2587
2579
  update(delta) {
2588
2580
  delta *= this.timeScale;
@@ -3015,13 +3007,13 @@ var spine = (() => {
3015
3007
  return entry;
3016
3008
  }
3017
3009
  setEmptyAnimation(trackIndex, mixDuration = 0) {
3018
- let entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation(), false);
3010
+ let entry = this.setAnimationWith(trackIndex, _AnimationState.emptyAnimation(), false);
3019
3011
  entry.mixDuration = mixDuration;
3020
3012
  entry.trackEnd = mixDuration;
3021
3013
  return entry;
3022
3014
  }
3023
3015
  addEmptyAnimation(trackIndex, mixDuration = 0, delay = 0) {
3024
- let entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
3016
+ let entry = this.addAnimationWith(trackIndex, _AnimationState.emptyAnimation(), false, delay);
3025
3017
  if (delay <= 0)
3026
3018
  entry.delay += entry.mixDuration - mixDuration;
3027
3019
  entry.mixDuration = mixDuration;
@@ -3160,6 +3152,8 @@ var spine = (() => {
3160
3152
  this.queue.clear();
3161
3153
  }
3162
3154
  };
3155
+ var AnimationState = _AnimationState;
3156
+ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
3163
3157
  var TrackEntry = class {
3164
3158
  constructor() {
3165
3159
  this.animation = null;
@@ -3241,7 +3235,6 @@ var spine = (() => {
3241
3235
  constructor(animState) {
3242
3236
  this.objects = [];
3243
3237
  this.drainDisabled = false;
3244
- this.animState = null;
3245
3238
  this.animState = animState;
3246
3239
  }
3247
3240
  start(entry) {
@@ -3284,45 +3277,57 @@ var spine = (() => {
3284
3277
  case EventType.start:
3285
3278
  if (entry.listener && entry.listener.start)
3286
3279
  entry.listener.start(entry);
3287
- for (let ii = 0; ii < listeners.length; ii++)
3288
- if (listeners[ii].start)
3289
- listeners[ii].start(entry);
3280
+ for (let ii = 0; ii < listeners.length; ii++) {
3281
+ let listener = listeners[ii];
3282
+ if (listener.start)
3283
+ listener.start(entry);
3284
+ }
3290
3285
  break;
3291
3286
  case EventType.interrupt:
3292
3287
  if (entry.listener && entry.listener.interrupt)
3293
3288
  entry.listener.interrupt(entry);
3294
- for (let ii = 0; ii < listeners.length; ii++)
3295
- if (listeners[ii].interrupt)
3296
- listeners[ii].interrupt(entry);
3289
+ for (let ii = 0; ii < listeners.length; ii++) {
3290
+ let listener = listeners[ii];
3291
+ if (listener.interrupt)
3292
+ listener.interrupt(entry);
3293
+ }
3297
3294
  break;
3298
3295
  case EventType.end:
3299
3296
  if (entry.listener && entry.listener.end)
3300
3297
  entry.listener.end(entry);
3301
- for (let ii = 0; ii < listeners.length; ii++)
3302
- if (listeners[ii].end)
3303
- listeners[ii].end(entry);
3298
+ for (let ii = 0; ii < listeners.length; ii++) {
3299
+ let listener = listeners[ii];
3300
+ if (listener.end)
3301
+ listener.end(entry);
3302
+ }
3304
3303
  case EventType.dispose:
3305
3304
  if (entry.listener && entry.listener.dispose)
3306
3305
  entry.listener.dispose(entry);
3307
- for (let ii = 0; ii < listeners.length; ii++)
3308
- if (listeners[ii].dispose)
3309
- listeners[ii].dispose(entry);
3306
+ for (let ii = 0; ii < listeners.length; ii++) {
3307
+ let listener = listeners[ii];
3308
+ if (listener.dispose)
3309
+ listener.dispose(entry);
3310
+ }
3310
3311
  this.animState.trackEntryPool.free(entry);
3311
3312
  break;
3312
3313
  case EventType.complete:
3313
3314
  if (entry.listener && entry.listener.complete)
3314
3315
  entry.listener.complete(entry);
3315
- for (let ii = 0; ii < listeners.length; ii++)
3316
- if (listeners[ii].complete)
3317
- listeners[ii].complete(entry);
3316
+ for (let ii = 0; ii < listeners.length; ii++) {
3317
+ let listener = listeners[ii];
3318
+ if (listener.complete)
3319
+ listener.complete(entry);
3320
+ }
3318
3321
  break;
3319
3322
  case EventType.event:
3320
3323
  let event = objects[i++ + 2];
3321
3324
  if (entry.listener && entry.listener.event)
3322
3325
  entry.listener.event(entry, event);
3323
- for (let ii = 0; ii < listeners.length; ii++)
3324
- if (listeners[ii].event)
3325
- listeners[ii].event(entry, event);
3326
+ for (let ii = 0; ii < listeners.length; ii++) {
3327
+ let listener = listeners[ii];
3328
+ if (listener.event)
3329
+ listener.event(entry, event);
3330
+ }
3326
3331
  break;
3327
3332
  }
3328
3333
  }
@@ -3363,12 +3368,10 @@ var spine = (() => {
3363
3368
  var HOLD_MIX = 4;
3364
3369
  var SETUP = 1;
3365
3370
  var CURRENT = 2;
3366
- var _emptyAnimation = null;
3367
3371
 
3368
3372
  // spine-core/src/AnimationStateData.ts
3369
3373
  var AnimationStateData = class {
3370
3374
  constructor(skeletonData) {
3371
- this.skeletonData = null;
3372
3375
  this.animationToMixTime = {};
3373
3376
  this.defaultMix = 0;
3374
3377
  if (!skeletonData)
@@ -3485,65 +3488,63 @@ var spine = (() => {
3485
3488
  this.regions = new Array();
3486
3489
  let reader = new TextureAtlasReader(atlasText);
3487
3490
  let entry = new Array(4);
3488
- let page = null;
3489
- let region = null;
3490
3491
  let pageFields = {};
3491
- pageFields["size"] = () => {
3492
- page.width = parseInt(entry[1]);
3493
- page.height = parseInt(entry[2]);
3492
+ pageFields["size"] = (page2) => {
3493
+ page2.width = parseInt(entry[1]);
3494
+ page2.height = parseInt(entry[2]);
3494
3495
  };
3495
3496
  pageFields["format"] = () => {
3496
3497
  };
3497
- pageFields["filter"] = () => {
3498
- page.minFilter = Utils.enumValue(TextureFilter, entry[1]);
3499
- page.magFilter = Utils.enumValue(TextureFilter, entry[2]);
3498
+ pageFields["filter"] = (page2) => {
3499
+ page2.minFilter = Utils.enumValue(TextureFilter, entry[1]);
3500
+ page2.magFilter = Utils.enumValue(TextureFilter, entry[2]);
3500
3501
  };
3501
- pageFields["repeat"] = () => {
3502
+ pageFields["repeat"] = (page2) => {
3502
3503
  if (entry[1].indexOf("x") != -1)
3503
- page.uWrap = TextureWrap.Repeat;
3504
+ page2.uWrap = TextureWrap.Repeat;
3504
3505
  if (entry[1].indexOf("y") != -1)
3505
- page.vWrap = TextureWrap.Repeat;
3506
+ page2.vWrap = TextureWrap.Repeat;
3506
3507
  };
3507
- pageFields["pma"] = () => {
3508
- page.pma = entry[1] == "true";
3508
+ pageFields["pma"] = (page2) => {
3509
+ page2.pma = entry[1] == "true";
3509
3510
  };
3510
3511
  var regionFields = {};
3511
- regionFields["xy"] = () => {
3512
+ regionFields["xy"] = (region) => {
3512
3513
  region.x = parseInt(entry[1]);
3513
3514
  region.y = parseInt(entry[2]);
3514
3515
  };
3515
- regionFields["size"] = () => {
3516
+ regionFields["size"] = (region) => {
3516
3517
  region.width = parseInt(entry[1]);
3517
3518
  region.height = parseInt(entry[2]);
3518
3519
  };
3519
- regionFields["bounds"] = () => {
3520
+ regionFields["bounds"] = (region) => {
3520
3521
  region.x = parseInt(entry[1]);
3521
3522
  region.y = parseInt(entry[2]);
3522
3523
  region.width = parseInt(entry[3]);
3523
3524
  region.height = parseInt(entry[4]);
3524
3525
  };
3525
- regionFields["offset"] = () => {
3526
+ regionFields["offset"] = (region) => {
3526
3527
  region.offsetX = parseInt(entry[1]);
3527
3528
  region.offsetY = parseInt(entry[2]);
3528
3529
  };
3529
- regionFields["orig"] = () => {
3530
+ regionFields["orig"] = (region) => {
3530
3531
  region.originalWidth = parseInt(entry[1]);
3531
3532
  region.originalHeight = parseInt(entry[2]);
3532
3533
  };
3533
- regionFields["offsets"] = () => {
3534
+ regionFields["offsets"] = (region) => {
3534
3535
  region.offsetX = parseInt(entry[1]);
3535
3536
  region.offsetY = parseInt(entry[2]);
3536
3537
  region.originalWidth = parseInt(entry[3]);
3537
3538
  region.originalHeight = parseInt(entry[4]);
3538
3539
  };
3539
- regionFields["rotate"] = () => {
3540
+ regionFields["rotate"] = (region) => {
3540
3541
  let value = entry[1];
3541
3542
  if (value == "true")
3542
3543
  region.degrees = 90;
3543
3544
  else if (value != "false")
3544
3545
  region.degrees = parseInt(value);
3545
3546
  };
3546
- regionFields["index"] = () => {
3547
+ regionFields["index"] = (region) => {
3547
3548
  region.index = parseInt(entry[1]);
3548
3549
  };
3549
3550
  let line = reader.readLine();
@@ -3556,6 +3557,7 @@ var spine = (() => {
3556
3557
  break;
3557
3558
  line = reader.readLine();
3558
3559
  }
3560
+ let page = null;
3559
3561
  let names = null;
3560
3562
  let values = null;
3561
3563
  while (true) {
@@ -3565,32 +3567,29 @@ var spine = (() => {
3565
3567
  page = null;
3566
3568
  line = reader.readLine();
3567
3569
  } else if (!page) {
3568
- page = new TextureAtlasPage();
3569
- page.name = line.trim();
3570
+ page = new TextureAtlasPage(line.trim());
3570
3571
  while (true) {
3571
3572
  if (reader.readEntry(entry, line = reader.readLine()) == 0)
3572
3573
  break;
3573
3574
  let field = pageFields[entry[0]];
3574
3575
  if (field)
3575
- field();
3576
+ field(page);
3576
3577
  }
3577
3578
  this.pages.push(page);
3578
3579
  } else {
3579
- region = new TextureAtlasRegion();
3580
- region.page = page;
3581
- region.name = line;
3580
+ let region = new TextureAtlasRegion(page, line);
3582
3581
  while (true) {
3583
3582
  let count = reader.readEntry(entry, line = reader.readLine());
3584
3583
  if (count == 0)
3585
3584
  break;
3586
3585
  let field = regionFields[entry[0]];
3587
3586
  if (field)
3588
- field();
3587
+ field(region);
3589
3588
  else {
3590
- if (!names) {
3589
+ if (!names)
3591
3590
  names = [];
3591
+ if (!values)
3592
3592
  values = [];
3593
- }
3594
3593
  names.push(entry[0]);
3595
3594
  let entryValues = [];
3596
3595
  for (let i = 0; i < count; i++)
@@ -3602,7 +3601,7 @@ var spine = (() => {
3602
3601
  region.originalWidth = region.width;
3603
3602
  region.originalHeight = region.height;
3604
3603
  }
3605
- if (names && names.length > 0) {
3604
+ if (names && names.length > 0 && values && values.length > 0) {
3606
3605
  region.names = names;
3607
3606
  region.values = values;
3608
3607
  names = null;
@@ -3634,14 +3633,14 @@ var spine = (() => {
3634
3633
  page.setTexture(assetManager.get(pathPrefix + page.name));
3635
3634
  }
3636
3635
  dispose() {
3636
+ var _a;
3637
3637
  for (let i = 0; i < this.pages.length; i++) {
3638
- this.pages[i].texture.dispose();
3638
+ (_a = this.pages[i].texture) == null ? void 0 : _a.dispose();
3639
3639
  }
3640
3640
  }
3641
3641
  };
3642
3642
  var TextureAtlasReader = class {
3643
3643
  constructor(text) {
3644
- this.lines = null;
3645
3644
  this.index = 0;
3646
3645
  this.lines = text.split(/\r\n|\r|\n/);
3647
3646
  }
@@ -3674,8 +3673,7 @@ var spine = (() => {
3674
3673
  }
3675
3674
  };
3676
3675
  var TextureAtlasPage = class {
3677
- constructor() {
3678
- this.name = null;
3676
+ constructor(name) {
3679
3677
  this.minFilter = TextureFilter.Nearest;
3680
3678
  this.magFilter = TextureFilter.Nearest;
3681
3679
  this.uWrap = TextureWrap.ClampToEdge;
@@ -3684,6 +3682,7 @@ var spine = (() => {
3684
3682
  this.width = 0;
3685
3683
  this.height = 0;
3686
3684
  this.pma = false;
3685
+ this.name = name;
3687
3686
  }
3688
3687
  setTexture(texture) {
3689
3688
  this.texture = texture;
@@ -3692,10 +3691,8 @@ var spine = (() => {
3692
3691
  }
3693
3692
  };
3694
3693
  var TextureAtlasRegion = class extends TextureRegion {
3695
- constructor() {
3696
- super(...arguments);
3697
- this.page = null;
3698
- this.name = null;
3694
+ constructor(page, name) {
3695
+ super();
3699
3696
  this.x = 0;
3700
3697
  this.y = 0;
3701
3698
  this.offsetX = 0;
@@ -3706,28 +3703,32 @@ var spine = (() => {
3706
3703
  this.degrees = 0;
3707
3704
  this.names = null;
3708
3705
  this.values = null;
3706
+ this.page = page;
3707
+ this.name = name;
3709
3708
  }
3710
3709
  };
3711
3710
 
3712
3711
  // spine-core/src/attachments/MeshAttachment.ts
3713
3712
  var MeshAttachment = class extends VertexAttachment {
3714
- constructor(name) {
3713
+ constructor(name, path) {
3715
3714
  super(name);
3716
3715
  this.region = null;
3717
- this.path = null;
3718
- this.regionUVs = null;
3719
- this.uvs = null;
3720
- this.triangles = null;
3716
+ this.regionUVs = [];
3717
+ this.uvs = [];
3718
+ this.triangles = [];
3721
3719
  this.color = new Color(1, 1, 1, 1);
3722
3720
  this.width = 0;
3723
3721
  this.height = 0;
3724
3722
  this.hullLength = 0;
3725
- this.edges = null;
3723
+ this.edges = [];
3726
3724
  this.parentMesh = null;
3727
3725
  this.sequence = null;
3728
3726
  this.tempColor = new Color(0, 0, 0, 0);
3727
+ this.path = path;
3729
3728
  }
3730
3729
  updateRegion() {
3730
+ if (!this.region)
3731
+ throw new Error("Region not set.");
3731
3732
  let regionUVs = this.regionUVs;
3732
3733
  if (!this.uvs || this.uvs.length != regionUVs.length)
3733
3734
  this.uvs = Utils.newFloatArray(regionUVs.length);
@@ -3803,9 +3804,8 @@ var spine = (() => {
3803
3804
  copy() {
3804
3805
  if (this.parentMesh)
3805
3806
  return this.newLinkedMesh();
3806
- let copy = new MeshAttachment(this.name);
3807
+ let copy = new MeshAttachment(this.name, this.path);
3807
3808
  copy.region = this.region;
3808
- copy.path = this.path;
3809
3809
  copy.color.setFromColor(this.color);
3810
3810
  this.copyTo(copy);
3811
3811
  copy.regionUVs = new Array(this.regionUVs.length);
@@ -3830,11 +3830,10 @@ var spine = (() => {
3830
3830
  super.computeWorldVertices(slot, start, count, worldVertices, offset, stride);
3831
3831
  }
3832
3832
  newLinkedMesh() {
3833
- let copy = new MeshAttachment(this.name);
3833
+ let copy = new MeshAttachment(this.name, this.path);
3834
3834
  copy.region = this.region;
3835
- copy.path = this.path;
3836
3835
  copy.color.setFromColor(this.color);
3837
- copy.timelineAttahment = this.timelineAttahment;
3836
+ copy.timelineAttachment = this.timelineAttachment;
3838
3837
  copy.setParentMesh(this.parentMesh ? this.parentMesh : this);
3839
3838
  if (copy.region != null)
3840
3839
  copy.updateRegion();
@@ -3846,7 +3845,7 @@ var spine = (() => {
3846
3845
  var PathAttachment = class extends VertexAttachment {
3847
3846
  constructor(name) {
3848
3847
  super(name);
3849
- this.lengths = null;
3848
+ this.lengths = [];
3850
3849
  this.closed = false;
3851
3850
  this.constantSpeed = false;
3852
3851
  this.color = new Color(1, 1, 1, 1);
@@ -3895,7 +3894,7 @@ var spine = (() => {
3895
3894
 
3896
3895
  // spine-core/src/attachments/RegionAttachment.ts
3897
3896
  var _RegionAttachment = class extends Attachment {
3898
- constructor(name) {
3897
+ constructor(name, path) {
3899
3898
  super(name);
3900
3899
  this.x = 0;
3901
3900
  this.y = 0;
@@ -3905,15 +3904,17 @@ var spine = (() => {
3905
3904
  this.width = 0;
3906
3905
  this.height = 0;
3907
3906
  this.color = new Color(1, 1, 1, 1);
3908
- this.path = null;
3909
3907
  this.rendererObject = null;
3910
3908
  this.region = null;
3911
3909
  this.sequence = null;
3912
3910
  this.offset = Utils.newFloatArray(8);
3913
3911
  this.uvs = Utils.newFloatArray(8);
3914
3912
  this.tempColor = new Color(1, 1, 1, 1);
3913
+ this.path = path;
3915
3914
  }
3916
3915
  updateRegion() {
3916
+ if (!this.region)
3917
+ throw new Error("Region not set.");
3917
3918
  let region = this.region;
3918
3919
  let regionScaleX = this.width / this.region.originalWidth * this.scaleX;
3919
3920
  let regionScaleY = this.height / this.region.originalHeight * this.scaleY;
@@ -3992,10 +3993,9 @@ var spine = (() => {
3992
3993
  worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
3993
3994
  }
3994
3995
  copy() {
3995
- let copy = new _RegionAttachment(this.name);
3996
+ let copy = new _RegionAttachment(this.name, this.path);
3996
3997
  copy.region = this.region;
3997
3998
  copy.rendererObject = this.rendererObject;
3998
- copy.path = this.path;
3999
3999
  copy.x = this.x;
4000
4000
  copy.y = this.y;
4001
4001
  copy.scaleX = this.scaleX;
@@ -4047,21 +4047,21 @@ var spine = (() => {
4047
4047
  // spine-core/src/AtlasAttachmentLoader.ts
4048
4048
  var AtlasAttachmentLoader = class {
4049
4049
  constructor(atlas) {
4050
- this.atlas = null;
4051
4050
  this.atlas = atlas;
4052
4051
  }
4053
4052
  loadSequence(name, basePath, sequence) {
4054
4053
  let regions = sequence.regions;
4055
4054
  for (let i = 0, n = regions.length; i < n; i++) {
4056
4055
  let path = sequence.getPath(basePath, i);
4057
- regions[i] = this.atlas.findRegion(path);
4058
- regions[i].renderObject = regions[i];
4059
- if (regions[i] == null)
4056
+ let region = this.atlas.findRegion(path);
4057
+ if (region == null)
4060
4058
  throw new Error("Region not found in atlas: " + path + " (sequence: " + name + ")");
4059
+ regions[i] = region;
4060
+ regions[i].renderObject = regions[i];
4061
4061
  }
4062
4062
  }
4063
4063
  newRegionAttachment(skin, name, path, sequence) {
4064
- let attachment = new RegionAttachment(name);
4064
+ let attachment = new RegionAttachment(name, path);
4065
4065
  if (sequence != null) {
4066
4066
  this.loadSequence(name, path, sequence);
4067
4067
  } else {
@@ -4074,7 +4074,7 @@ var spine = (() => {
4074
4074
  return attachment;
4075
4075
  }
4076
4076
  newMeshAttachment(skin, name, path, sequence) {
4077
- let attachment = new MeshAttachment(name);
4077
+ let attachment = new MeshAttachment(name, path);
4078
4078
  if (sequence != null) {
4079
4079
  this.loadSequence(name, path, sequence);
4080
4080
  } else {
@@ -4104,7 +4104,6 @@ var spine = (() => {
4104
4104
  var BoneData = class {
4105
4105
  constructor(index, name, parent) {
4106
4106
  this.index = 0;
4107
- this.name = null;
4108
4107
  this.parent = null;
4109
4108
  this.length = 0;
4110
4109
  this.x = 0;
@@ -4138,8 +4137,6 @@ var spine = (() => {
4138
4137
  // spine-core/src/Bone.ts
4139
4138
  var Bone = class {
4140
4139
  constructor(data, skeleton, parent) {
4141
- this.data = null;
4142
- this.skeleton = null;
4143
4140
  this.parent = null;
4144
4141
  this.children = new Array();
4145
4142
  this.x = 0;
@@ -4392,15 +4389,15 @@ var spine = (() => {
4392
4389
 
4393
4390
  // spine-core/src/AssetManagerBase.ts
4394
4391
  var AssetManagerBase = class {
4395
- constructor(textureLoader, pathPrefix = "", downloader = null) {
4396
- this.pathPrefix = null;
4392
+ constructor(textureLoader, pathPrefix = "", downloader = new Downloader()) {
4393
+ this.pathPrefix = "";
4397
4394
  this.assets = {};
4398
4395
  this.errors = {};
4399
4396
  this.toLoad = 0;
4400
4397
  this.loaded = 0;
4401
4398
  this.textureLoader = textureLoader;
4402
4399
  this.pathPrefix = pathPrefix;
4403
- this.downloader = downloader || new Downloader();
4400
+ this.downloader = downloader;
4404
4401
  }
4405
4402
  start(path) {
4406
4403
  this.toLoad++;
@@ -4439,7 +4436,9 @@ var spine = (() => {
4439
4436
  setRawDataURI(path, data) {
4440
4437
  this.downloader.rawDataUris[this.pathPrefix + path] = data;
4441
4438
  }
4442
- loadBinary(path, success = null, error = null) {
4439
+ loadBinary(path, success = () => {
4440
+ }, error = () => {
4441
+ }) {
4443
4442
  path = this.start(path);
4444
4443
  this.downloader.downloadBinary(path, (data) => {
4445
4444
  this.success(success, path, data);
@@ -4447,7 +4446,9 @@ var spine = (() => {
4447
4446
  this.error(error, path, `Couldn't load binary ${path}: status ${status}, ${responseText}`);
4448
4447
  });
4449
4448
  }
4450
- loadText(path, success = null, error = null) {
4449
+ loadText(path, success = () => {
4450
+ }, error = () => {
4451
+ }) {
4451
4452
  path = this.start(path);
4452
4453
  this.downloader.downloadText(path, (data) => {
4453
4454
  this.success(success, path, data);
@@ -4455,7 +4456,9 @@ var spine = (() => {
4455
4456
  this.error(error, path, `Couldn't load text ${path}: status ${status}, ${responseText}`);
4456
4457
  });
4457
4458
  }
4458
- loadJson(path, success = null, error = null) {
4459
+ loadJson(path, success = () => {
4460
+ }, error = () => {
4461
+ }) {
4459
4462
  path = this.start(path);
4460
4463
  this.downloader.downloadJson(path, (data) => {
4461
4464
  this.success(success, path, data);
@@ -4463,7 +4466,9 @@ var spine = (() => {
4463
4466
  this.error(error, path, `Couldn't load JSON ${path}: status ${status}, ${responseText}`);
4464
4467
  });
4465
4468
  }
4466
- loadTexture(path, success = null, error = null) {
4469
+ loadTexture(path, success = () => {
4470
+ }, error = () => {
4471
+ }) {
4467
4472
  path = this.start(path);
4468
4473
  let isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document);
4469
4474
  let isWebWorker = !isBrowser;
@@ -4493,7 +4498,9 @@ var spine = (() => {
4493
4498
  image.src = path;
4494
4499
  }
4495
4500
  }
4496
- loadTextureAtlas(path, success = null, error = null, fileAlias = null) {
4501
+ loadTextureAtlas(path, success = () => {
4502
+ }, error = () => {
4503
+ }, fileAlias) {
4497
4504
  let index = path.lastIndexOf("/");
4498
4505
  let parent = index >= 0 ? path.substring(0, index + 1) : "";
4499
4506
  path = this.start(path);
@@ -4502,7 +4509,7 @@ var spine = (() => {
4502
4509
  let atlas = new TextureAtlas(atlasText);
4503
4510
  let toLoad = atlas.pages.length, abort = false;
4504
4511
  for (let page of atlas.pages) {
4505
- this.loadTexture(fileAlias == null ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4512
+ this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4506
4513
  if (!abort) {
4507
4514
  page.setTexture(texture);
4508
4515
  if (--toLoad == 0)
@@ -4679,7 +4686,6 @@ var spine = (() => {
4679
4686
  // spine-core/src/Event.ts
4680
4687
  var Event = class {
4681
4688
  constructor(time, data) {
4682
- this.data = null;
4683
4689
  this.intValue = 0;
4684
4690
  this.floatValue = 0;
4685
4691
  this.stringValue = null;
@@ -4696,7 +4702,6 @@ var spine = (() => {
4696
4702
  // spine-core/src/EventData.ts
4697
4703
  var EventData = class {
4698
4704
  constructor(name) {
4699
- this.name = null;
4700
4705
  this.intValue = 0;
4701
4706
  this.floatValue = 0;
4702
4707
  this.stringValue = null;
@@ -4710,9 +4715,6 @@ var spine = (() => {
4710
4715
  // spine-core/src/IkConstraint.ts
4711
4716
  var IkConstraint = class {
4712
4717
  constructor(data, skeleton) {
4713
- this.data = null;
4714
- this.bones = null;
4715
- this.target = null;
4716
4718
  this.bendDirection = 0;
4717
4719
  this.compress = false;
4718
4720
  this.stretch = false;
@@ -4730,9 +4732,16 @@ var spine = (() => {
4730
4732
  this.compress = data.compress;
4731
4733
  this.stretch = data.stretch;
4732
4734
  this.bones = new Array();
4733
- for (let i = 0; i < data.bones.length; i++)
4734
- this.bones.push(skeleton.findBone(data.bones[i].name));
4735
- this.target = skeleton.findBone(data.target.name);
4735
+ for (let i = 0; i < data.bones.length; i++) {
4736
+ let bone = skeleton.findBone(data.bones[i].name);
4737
+ if (!bone)
4738
+ throw new Error(`Couldn't find bone ${data.bones[i].name}`);
4739
+ this.bones.push(bone);
4740
+ }
4741
+ let target = skeleton.findBone(data.target.name);
4742
+ if (!target)
4743
+ throw new Error(`Couldn't find bone ${data.target.name}`);
4744
+ this.target = target;
4736
4745
  }
4737
4746
  isActive() {
4738
4747
  return this.active;
@@ -4753,6 +4762,8 @@ var spine = (() => {
4753
4762
  }
4754
4763
  apply1(bone, targetX, targetY, compress, stretch, uniform, alpha) {
4755
4764
  let p = bone.parent;
4765
+ if (!p)
4766
+ throw new Error("IK bone must have parent.");
4756
4767
  let pa = p.a, pb = p.b, pc = p.c, pd = p.d;
4757
4768
  let rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0;
4758
4769
  switch (bone.data.transformMode) {
@@ -4830,6 +4841,8 @@ var spine = (() => {
4830
4841
  cwy = c * cx + d * cy + parent.worldY;
4831
4842
  }
4832
4843
  let pp = parent.parent;
4844
+ if (!pp)
4845
+ throw new Error("IK parent must itself have a parent.");
4833
4846
  a = pp.a;
4834
4847
  b = pp.b;
4835
4848
  c = pp.c;
@@ -4951,7 +4964,7 @@ var spine = (() => {
4951
4964
  constructor(name) {
4952
4965
  super(name, 0, false);
4953
4966
  this.bones = new Array();
4954
- this.target = null;
4967
+ this._target = null;
4955
4968
  this.bendDirection = 1;
4956
4969
  this.compress = false;
4957
4970
  this.stretch = false;
@@ -4959,6 +4972,15 @@ var spine = (() => {
4959
4972
  this.mix = 1;
4960
4973
  this.softness = 0;
4961
4974
  }
4975
+ set target(boneData) {
4976
+ this._target = boneData;
4977
+ }
4978
+ get target() {
4979
+ if (!this._target)
4980
+ throw new Error("BoneData not set.");
4981
+ else
4982
+ return this._target;
4983
+ }
4962
4984
  };
4963
4985
 
4964
4986
  // spine-core/src/PathConstraintData.ts
@@ -4966,10 +4988,10 @@ var spine = (() => {
4966
4988
  constructor(name) {
4967
4989
  super(name, 0, false);
4968
4990
  this.bones = new Array();
4969
- this.target = null;
4970
- this.positionMode = null;
4971
- this.spacingMode = null;
4972
- this.rotateMode = null;
4991
+ this._target = null;
4992
+ this.positionMode = PositionMode.Fixed;
4993
+ this.spacingMode = SpacingMode.Fixed;
4994
+ this.rotateMode = RotateMode.Chain;
4973
4995
  this.offsetRotation = 0;
4974
4996
  this.position = 0;
4975
4997
  this.spacing = 0;
@@ -4977,6 +4999,15 @@ var spine = (() => {
4977
4999
  this.mixX = 0;
4978
5000
  this.mixY = 0;
4979
5001
  }
5002
+ set target(slotData) {
5003
+ this._target = slotData;
5004
+ }
5005
+ get target() {
5006
+ if (!this._target)
5007
+ throw new Error("SlotData not set.");
5008
+ else
5009
+ return this._target;
5010
+ }
4980
5011
  };
4981
5012
  var PositionMode;
4982
5013
  (function(PositionMode2) {
@@ -5000,9 +5031,6 @@ var spine = (() => {
5000
5031
  // spine-core/src/PathConstraint.ts
5001
5032
  var _PathConstraint = class {
5002
5033
  constructor(data, skeleton) {
5003
- this.data = null;
5004
- this.bones = null;
5005
- this.target = null;
5006
5034
  this.position = 0;
5007
5035
  this.spacing = 0;
5008
5036
  this.mixRotate = 0;
@@ -5021,9 +5049,16 @@ var spine = (() => {
5021
5049
  throw new Error("skeleton cannot be null.");
5022
5050
  this.data = data;
5023
5051
  this.bones = new Array();
5024
- for (let i = 0, n = data.bones.length; i < n; i++)
5025
- this.bones.push(skeleton.findBone(data.bones[i].name));
5026
- this.target = skeleton.findSlot(data.target.name);
5052
+ for (let i = 0, n = data.bones.length; i < n; i++) {
5053
+ let bone = skeleton.findBone(data.bones[i].name);
5054
+ if (!bone)
5055
+ throw new Error(`Couldn't find bone ${data.bones[i].name}.`);
5056
+ this.bones.push(bone);
5057
+ }
5058
+ let target = skeleton.findSlot(data.target.name);
5059
+ if (!target)
5060
+ throw new Error(`Couldn't find target bone ${data.target.name}`);
5061
+ this.target = target;
5027
5062
  this.position = data.position;
5028
5063
  this.spacing = data.spacing;
5029
5064
  this.mixRotate = data.mixRotate;
@@ -5044,7 +5079,7 @@ var spine = (() => {
5044
5079
  let tangents = data.rotateMode == RotateMode.Tangent, scale = data.rotateMode == RotateMode.ChainScale;
5045
5080
  let bones = this.bones;
5046
5081
  let boneCount = bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
5047
- let spaces = Utils.setArraySize(this.spaces, spacesCount), lengths = scale ? this.lengths = Utils.setArraySize(this.lengths, boneCount) : null;
5082
+ let spaces = Utils.setArraySize(this.spaces, spacesCount), lengths = scale ? this.lengths = Utils.setArraySize(this.lengths, boneCount) : [];
5048
5083
  let spacing = this.spacing;
5049
5084
  switch (data.spacingMode) {
5050
5085
  case SpacingMode.Percent:
@@ -5165,7 +5200,7 @@ var spine = (() => {
5165
5200
  computeWorldPositions(path, spacesCount, tangents) {
5166
5201
  let target = this.target;
5167
5202
  let position = this.position;
5168
- let spaces = this.spaces, out = Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null;
5203
+ let spaces = this.spaces, out = Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = this.world;
5169
5204
  let closed2 = path.closed;
5170
5205
  let verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = _PathConstraint.NONE;
5171
5206
  if (!path.constantSpeed) {
@@ -5422,12 +5457,10 @@ var spine = (() => {
5422
5457
  // spine-core/src/Slot.ts
5423
5458
  var Slot = class {
5424
5459
  constructor(data, bone) {
5425
- this.data = null;
5426
- this.bone = null;
5427
- this.color = null;
5428
5460
  this.darkColor = null;
5429
5461
  this.attachment = null;
5430
5462
  this.attachmentState = 0;
5463
+ this.sequenceIndex = -1;
5431
5464
  this.deform = new Array();
5432
5465
  if (!data)
5433
5466
  throw new Error("data cannot be null.");
@@ -5448,7 +5481,7 @@ var spine = (() => {
5448
5481
  setAttachment(attachment) {
5449
5482
  if (this.attachment == attachment)
5450
5483
  return;
5451
- if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || attachment.timelineAttahment != this.attachment.timelineAttahment) {
5484
+ if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || attachment.timelineAttachment != this.attachment.timelineAttachment) {
5452
5485
  this.deform.length = 0;
5453
5486
  }
5454
5487
  this.attachment = attachment;
@@ -5470,9 +5503,6 @@ var spine = (() => {
5470
5503
  // spine-core/src/TransformConstraint.ts
5471
5504
  var TransformConstraint = class {
5472
5505
  constructor(data, skeleton) {
5473
- this.data = null;
5474
- this.bones = null;
5475
- this.target = null;
5476
5506
  this.mixRotate = 0;
5477
5507
  this.mixX = 0;
5478
5508
  this.mixY = 0;
@@ -5493,9 +5523,16 @@ var spine = (() => {
5493
5523
  this.mixScaleY = data.mixScaleY;
5494
5524
  this.mixShearY = data.mixShearY;
5495
5525
  this.bones = new Array();
5496
- for (let i = 0; i < data.bones.length; i++)
5497
- this.bones.push(skeleton.findBone(data.bones[i].name));
5498
- this.target = skeleton.findBone(data.target.name);
5526
+ for (let i = 0; i < data.bones.length; i++) {
5527
+ let bone = skeleton.findBone(data.bones[i].name);
5528
+ if (!bone)
5529
+ throw new Error(`Couldn't find bone ${data.bones[i].name}.`);
5530
+ this.bones.push(bone);
5531
+ }
5532
+ let target = skeleton.findBone(data.target.name);
5533
+ if (!target)
5534
+ throw new Error(`Couldn't find target bone ${data.target.name}.`);
5535
+ this.target = target;
5499
5536
  }
5500
5537
  isActive() {
5501
5538
  return this.active;
@@ -5680,16 +5717,8 @@ var spine = (() => {
5680
5717
  // spine-core/src/Skeleton.ts
5681
5718
  var Skeleton = class {
5682
5719
  constructor(data) {
5683
- this.data = null;
5684
- this.bones = null;
5685
- this.slots = null;
5686
- this.drawOrder = null;
5687
- this.ikConstraints = null;
5688
- this.transformConstraints = null;
5689
- this.pathConstraints = null;
5690
5720
  this._updateCache = new Array();
5691
5721
  this.skin = null;
5692
- this.color = null;
5693
5722
  this.scaleX = 1;
5694
5723
  this.scaleY = 1;
5695
5724
  this.x = 0;
@@ -5884,6 +5913,8 @@ var spine = (() => {
5884
5913
  }
5885
5914
  }
5886
5915
  sortBone(bone) {
5916
+ if (!bone)
5917
+ return;
5887
5918
  if (bone.sorted)
5888
5919
  return;
5889
5920
  let parent = bone.parent;
@@ -5920,6 +5951,8 @@ var spine = (() => {
5920
5951
  }
5921
5952
  updateWorldTransformWith(parent) {
5922
5953
  let rootBone = this.getRootBone();
5954
+ if (!rootBone)
5955
+ throw new Error("Root bone must not be null.");
5923
5956
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
5924
5957
  rootBone.worldX = pa * this.x + pb * this.y + parent.worldX;
5925
5958
  rootBone.worldY = pc * this.x + pd * this.y + parent.worldY;
@@ -6040,7 +6073,10 @@ var spine = (() => {
6040
6073
  this.updateCache();
6041
6074
  }
6042
6075
  getAttachmentByName(slotName, attachmentName) {
6043
- return this.getAttachment(this.data.findSlot(slotName).index, attachmentName);
6076
+ let slot = this.data.findSlot(slotName);
6077
+ if (!slot)
6078
+ throw new Error(`Can't find slot with name ${slotName}`);
6079
+ return this.getAttachment(slot.index, attachmentName);
6044
6080
  }
6045
6081
  getAttachment(slotIndex, attachmentName) {
6046
6082
  if (!attachmentName)
@@ -6266,7 +6302,7 @@ var spine = (() => {
6266
6302
 
6267
6303
  // spine-core/src/Skin.ts
6268
6304
  var SkinEntry = class {
6269
- constructor(slotIndex = 0, name = null, attachment = null) {
6305
+ constructor(slotIndex = 0, name, attachment) {
6270
6306
  this.slotIndex = slotIndex;
6271
6307
  this.name = name;
6272
6308
  this.attachment = attachment;
@@ -6274,7 +6310,6 @@ var spine = (() => {
6274
6310
  };
6275
6311
  var Skin = class {
6276
6312
  constructor(name) {
6277
- this.name = null;
6278
6313
  this.attachments = new Array();
6279
6314
  this.bones = Array();
6280
6315
  this.constraints = new Array();
@@ -6369,7 +6404,7 @@ var spine = (() => {
6369
6404
  removeAttachment(slotIndex, name) {
6370
6405
  let dictionary = this.attachments[slotIndex];
6371
6406
  if (dictionary)
6372
- dictionary[name] = null;
6407
+ delete dictionary[name];
6373
6408
  }
6374
6409
  getAttachments() {
6375
6410
  let entries = new Array();
@@ -6426,12 +6461,10 @@ var spine = (() => {
6426
6461
  var SlotData = class {
6427
6462
  constructor(index, name, boneData) {
6428
6463
  this.index = 0;
6429
- this.name = null;
6430
- this.boneData = null;
6431
6464
  this.color = new Color(1, 1, 1, 1);
6432
6465
  this.darkColor = null;
6433
6466
  this.attachmentName = null;
6434
- this.blendMode = null;
6467
+ this.blendMode = BlendMode.Normal;
6435
6468
  if (index < 0)
6436
6469
  throw new Error("index must be >= 0.");
6437
6470
  if (!name)
@@ -6456,7 +6489,7 @@ var spine = (() => {
6456
6489
  constructor(name) {
6457
6490
  super(name, 0, false);
6458
6491
  this.bones = new Array();
6459
- this.target = null;
6492
+ this._target = null;
6460
6493
  this.mixRotate = 0;
6461
6494
  this.mixX = 0;
6462
6495
  this.mixY = 0;
@@ -6472,13 +6505,21 @@ var spine = (() => {
6472
6505
  this.relative = false;
6473
6506
  this.local = false;
6474
6507
  }
6508
+ set target(boneData) {
6509
+ this._target = boneData;
6510
+ }
6511
+ get target() {
6512
+ if (!this._target)
6513
+ throw new Error("BoneData not set.");
6514
+ else
6515
+ return this._target;
6516
+ }
6475
6517
  };
6476
6518
 
6477
6519
  // spine-core/src/SkeletonBinary.ts
6478
6520
  var SkeletonBinary = class {
6479
6521
  constructor(attachmentLoader) {
6480
6522
  this.scale = 1;
6481
- this.attachmentLoader = null;
6482
6523
  this.linkedMeshes = new Array();
6483
6524
  this.attachmentLoader = attachmentLoader;
6484
6525
  }
@@ -6503,11 +6544,17 @@ var spine = (() => {
6503
6544
  }
6504
6545
  let n = 0;
6505
6546
  n = input.readInt(true);
6506
- for (let i = 0; i < n; i++)
6507
- input.strings.push(input.readString());
6547
+ for (let i = 0; i < n; i++) {
6548
+ let str = input.readString();
6549
+ if (!str)
6550
+ throw new Error("String in string table must not be null.");
6551
+ input.strings.push(str);
6552
+ }
6508
6553
  n = input.readInt(true);
6509
6554
  for (let i = 0; i < n; i++) {
6510
6555
  let name = input.readString();
6556
+ if (!name)
6557
+ throw new Error("Bone name must not be null.");
6511
6558
  let parent = i == 0 ? null : skeletonData.bones[input.readInt(true)];
6512
6559
  let data = new BoneData(i, name, parent);
6513
6560
  data.rotation = input.readFloat();
@@ -6527,6 +6574,8 @@ var spine = (() => {
6527
6574
  n = input.readInt(true);
6528
6575
  for (let i = 0; i < n; i++) {
6529
6576
  let slotName = input.readString();
6577
+ if (!slotName)
6578
+ throw new Error("Slot name must not be null.");
6530
6579
  let boneData = skeletonData.bones[input.readInt(true)];
6531
6580
  let data = new SlotData(i, slotName, boneData);
6532
6581
  Color.rgba8888ToColor(data.color, input.readInt32());
@@ -6539,7 +6588,10 @@ var spine = (() => {
6539
6588
  }
6540
6589
  n = input.readInt(true);
6541
6590
  for (let i = 0, nn; i < n; i++) {
6542
- let data = new IkConstraintData(input.readString());
6591
+ let name = input.readString();
6592
+ if (!name)
6593
+ throw new Error("IK constraint data name must not be null.");
6594
+ let data = new IkConstraintData(name);
6543
6595
  data.order = input.readInt(true);
6544
6596
  data.skinRequired = input.readBoolean();
6545
6597
  nn = input.readInt(true);
@@ -6556,7 +6608,10 @@ var spine = (() => {
6556
6608
  }
6557
6609
  n = input.readInt(true);
6558
6610
  for (let i = 0, nn; i < n; i++) {
6559
- let data = new TransformConstraintData(input.readString());
6611
+ let name = input.readString();
6612
+ if (!name)
6613
+ throw new Error("Transform constraint data name must not be null.");
6614
+ let data = new TransformConstraintData(name);
6560
6615
  data.order = input.readInt(true);
6561
6616
  data.skinRequired = input.readBoolean();
6562
6617
  nn = input.readInt(true);
@@ -6581,7 +6636,10 @@ var spine = (() => {
6581
6636
  }
6582
6637
  n = input.readInt(true);
6583
6638
  for (let i = 0, nn; i < n; i++) {
6584
- let data = new PathConstraintData(input.readString());
6639
+ let name = input.readString();
6640
+ if (!name)
6641
+ throw new Error("Path constraint data name must not be null.");
6642
+ let data = new PathConstraintData(name);
6585
6643
  data.order = input.readInt(true);
6586
6644
  data.skinRequired = input.readBoolean();
6587
6645
  nn = input.readInt(true);
@@ -6611,15 +6669,25 @@ var spine = (() => {
6611
6669
  {
6612
6670
  let i = skeletonData.skins.length;
6613
6671
  Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
6614
- for (; i < n; i++)
6615
- skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
6672
+ for (; i < n; i++) {
6673
+ let skin = this.readSkin(input, skeletonData, false, nonessential);
6674
+ if (!skin)
6675
+ throw new Error("readSkin() should not have returned null.");
6676
+ skeletonData.skins[i] = skin;
6677
+ }
6616
6678
  }
6617
6679
  n = this.linkedMeshes.length;
6618
6680
  for (let i = 0; i < n; i++) {
6619
6681
  let linkedMesh = this.linkedMeshes[i];
6620
6682
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
6683
+ if (!skin)
6684
+ throw new Error("Not skin found for linked mesh.");
6685
+ if (!linkedMesh.parent)
6686
+ throw new Error("Linked mesh parent must not be null");
6621
6687
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
6622
- linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6688
+ if (!parent)
6689
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
6690
+ linkedMesh.mesh.timelineAttachment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6623
6691
  linkedMesh.mesh.setParentMesh(parent);
6624
6692
  if (linkedMesh.mesh.region != null)
6625
6693
  linkedMesh.mesh.updateRegion();
@@ -6627,7 +6695,10 @@ var spine = (() => {
6627
6695
  this.linkedMeshes.length = 0;
6628
6696
  n = input.readInt(true);
6629
6697
  for (let i = 0; i < n; i++) {
6630
- let data = new EventData(input.readStringRef());
6698
+ let eventName = input.readStringRef();
6699
+ if (!eventName)
6700
+ throw new Error();
6701
+ let data = new EventData(eventName);
6631
6702
  data.intValue = input.readInt(false);
6632
6703
  data.floatValue = input.readFloat();
6633
6704
  data.stringValue = input.readString();
@@ -6639,8 +6710,12 @@ var spine = (() => {
6639
6710
  skeletonData.events.push(data);
6640
6711
  }
6641
6712
  n = input.readInt(true);
6642
- for (let i = 0; i < n; i++)
6643
- skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
6713
+ for (let i = 0; i < n; i++) {
6714
+ let animationName = input.readString();
6715
+ if (!animationName)
6716
+ throw new Error("Animatio name must not be null.");
6717
+ skeletonData.animations.push(this.readAnimation(input, animationName, skeletonData));
6718
+ }
6644
6719
  return skeletonData;
6645
6720
  }
6646
6721
  readSkin(input, skeletonData, defaultSkin, nonessential) {
@@ -6652,7 +6727,10 @@ var spine = (() => {
6652
6727
  return null;
6653
6728
  skin = new Skin("default");
6654
6729
  } else {
6655
- skin = new Skin(input.readStringRef());
6730
+ let skinName = input.readStringRef();
6731
+ if (!skinName)
6732
+ throw new Error("Skin name must not be null.");
6733
+ skin = new Skin(skinName);
6656
6734
  skin.bones.length = input.readInt(true);
6657
6735
  for (let i = 0, n = skin.bones.length; i < n; i++)
6658
6736
  skin.bones[i] = skeletonData.bones[input.readInt(true)];
@@ -6668,6 +6746,8 @@ var spine = (() => {
6668
6746
  let slotIndex = input.readInt(true);
6669
6747
  for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
6670
6748
  let name = input.readStringRef();
6749
+ if (!name)
6750
+ throw new Error("Attachment name must not be null");
6671
6751
  let attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name, nonessential);
6672
6752
  if (attachment)
6673
6753
  skin.setAttachment(slotIndex, name, attachment);
@@ -6734,7 +6814,7 @@ var spine = (() => {
6734
6814
  let vertices = this.readVertices(input, vertexCount);
6735
6815
  let hullLength = input.readInt(true);
6736
6816
  let sequence = this.readSequence(input);
6737
- let edges = null;
6817
+ let edges = [];
6738
6818
  let width = 0, height = 0;
6739
6819
  if (nonessential) {
6740
6820
  edges = this.readShortArray(input);
@@ -7236,6 +7316,8 @@ var spine = (() => {
7236
7316
  let slotIndex = input.readInt(true);
7237
7317
  for (let iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
7238
7318
  let attachmentName = input.readStringRef();
7319
+ if (!attachmentName)
7320
+ throw new Error("attachmentName must not be null.");
7239
7321
  let attachment = skin.getAttachment(slotIndex, attachmentName);
7240
7322
  let timelineType = input.readByte();
7241
7323
  let frameCount = input.readInt(true);
@@ -7911,6 +7993,8 @@ var spine = (() => {
7911
7993
  this.clippedVertices = new Array();
7912
7994
  this.clippedTriangles = new Array();
7913
7995
  this.scratch = new Array();
7996
+ this.clipAttachment = null;
7997
+ this.clippingPolygons = null;
7914
7998
  }
7915
7999
  clipStart(slot, clip) {
7916
8000
  if (this.clipAttachment)
@@ -7950,7 +8034,7 @@ var spine = (() => {
7950
8034
  let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
7951
8035
  let clippedTriangles = this.clippedTriangles;
7952
8036
  let polygons = this.clippingPolygons;
7953
- let polygonsCount = this.clippingPolygons.length;
8037
+ let polygonsCount = polygons.length;
7954
8038
  let vertexSize = twoColor ? 12 : 8;
7955
8039
  let index = 0;
7956
8040
  clippedVertices.length = 0;
@@ -8082,7 +8166,7 @@ var spine = (() => {
8082
8166
  clip(x1, y1, x2, y2, x3, y3, clippingArea, output) {
8083
8167
  let originalOutput = output;
8084
8168
  let clipped = false;
8085
- let input = null;
8169
+ let input;
8086
8170
  if (clippingArea.length % 4 >= 2) {
8087
8171
  input = output;
8088
8172
  output = this.scratch;
@@ -8190,7 +8274,6 @@ var spine = (() => {
8190
8274
  // spine-core/src/SkeletonJson.ts
8191
8275
  var SkeletonJson = class {
8192
8276
  constructor(attachmentLoader) {
8193
- this.attachmentLoader = null;
8194
8277
  this.scale = 1;
8195
8278
  this.linkedMeshes = new Array();
8196
8279
  this.attachmentLoader = attachmentLoader;
@@ -8238,6 +8321,8 @@ var spine = (() => {
8238
8321
  for (let i = 0; i < root.slots.length; i++) {
8239
8322
  let slotMap = root.slots[i];
8240
8323
  let boneData = skeletonData.findBone(slotMap.bone);
8324
+ if (!boneData)
8325
+ throw new Error(`Couldn't find bone ${slotMap.bone} for slot ${slotMap.name}`);
8241
8326
  let data = new SlotData(skeletonData.slots.length, slotMap.name, boneData);
8242
8327
  let color = getValue(slotMap, "color", null);
8243
8328
  if (color)
@@ -8256,9 +8341,17 @@ var spine = (() => {
8256
8341
  let data = new IkConstraintData(constraintMap.name);
8257
8342
  data.order = getValue(constraintMap, "order", 0);
8258
8343
  data.skinRequired = getValue(constraintMap, "skin", false);
8259
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8260
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8261
- data.target = skeletonData.findBone(constraintMap.target);
8344
+ for (let ii = 0; ii < constraintMap.bones.length; ii++) {
8345
+ let bone = skeletonData.findBone(constraintMap.bones[ii]);
8346
+ if (!bone)
8347
+ throw new Error(`Couldn't find bone ${constraintMap.bones[ii]} for IK constraint ${constraintMap.name}.`);
8348
+ data.bones.push(bone);
8349
+ }
8350
+ let target = skeletonData.findBone(constraintMap.target);
8351
+ ;
8352
+ if (!target)
8353
+ throw new Error(`Couldn't find target bone ${constraintMap.target} for IK constraint ${constraintMap.name}.`);
8354
+ data.target = target;
8262
8355
  data.mix = getValue(constraintMap, "mix", 1);
8263
8356
  data.softness = getValue(constraintMap, "softness", 0) * scale;
8264
8357
  data.bendDirection = getValue(constraintMap, "bendPositive", true) ? 1 : -1;
@@ -8274,10 +8367,18 @@ var spine = (() => {
8274
8367
  let data = new TransformConstraintData(constraintMap.name);
8275
8368
  data.order = getValue(constraintMap, "order", 0);
8276
8369
  data.skinRequired = getValue(constraintMap, "skin", false);
8277
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8278
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8370
+ for (let ii = 0; ii < constraintMap.bones.length; ii++) {
8371
+ let boneName = constraintMap.bones[ii];
8372
+ let bone = skeletonData.findBone(boneName);
8373
+ if (!bone)
8374
+ throw new Error(`Couldn't find bone ${boneName} for transform constraint ${constraintMap.name}.`);
8375
+ data.bones.push(bone);
8376
+ }
8279
8377
  let targetName = constraintMap.target;
8280
- data.target = skeletonData.findBone(targetName);
8378
+ let target = skeletonData.findBone(targetName);
8379
+ if (!target)
8380
+ throw new Error(`Couldn't find target bone ${targetName} for transform constraint ${constraintMap.name}.`);
8381
+ data.target = target;
8281
8382
  data.local = getValue(constraintMap, "local", false);
8282
8383
  data.relative = getValue(constraintMap, "relative", false);
8283
8384
  data.offsetRotation = getValue(constraintMap, "rotation", 0);
@@ -8301,10 +8402,18 @@ var spine = (() => {
8301
8402
  let data = new PathConstraintData(constraintMap.name);
8302
8403
  data.order = getValue(constraintMap, "order", 0);
8303
8404
  data.skinRequired = getValue(constraintMap, "skin", false);
8304
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8305
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8405
+ for (let ii = 0; ii < constraintMap.bones.length; ii++) {
8406
+ let boneName = constraintMap.bones[ii];
8407
+ let bone = skeletonData.findBone(boneName);
8408
+ if (!bone)
8409
+ throw new Error(`Couldn't find bone ${boneName} for path constraint ${constraintMap.name}.`);
8410
+ data.bones.push(bone);
8411
+ }
8306
8412
  let targetName = constraintMap.target;
8307
- data.target = skeletonData.findSlot(targetName);
8413
+ let target = skeletonData.findSlot(targetName);
8414
+ if (!target)
8415
+ throw new Error(`Couldn't find target slot ${targetName} for path constraint ${constraintMap.name}.`);
8416
+ data.target = target;
8308
8417
  data.positionMode = Utils.enumValue(PositionMode, getValue(constraintMap, "positionMode", "Percent"));
8309
8418
  data.spacingMode = Utils.enumValue(SpacingMode, getValue(constraintMap, "spacingMode", "Length"));
8310
8419
  data.rotateMode = Utils.enumValue(RotateMode, getValue(constraintMap, "rotateMode", "Tangent"));
@@ -8326,23 +8435,45 @@ var spine = (() => {
8326
8435
  let skinMap = root.skins[i];
8327
8436
  let skin = new Skin(skinMap.name);
8328
8437
  if (skinMap.bones) {
8329
- for (let ii = 0; ii < skinMap.bones.length; ii++)
8330
- skin.bones.push(skeletonData.findBone(skinMap.bones[ii]));
8438
+ for (let ii = 0; ii < skinMap.bones.length; ii++) {
8439
+ let boneName = skinMap.bones[ii];
8440
+ let bone = skeletonData.findBone(boneName);
8441
+ if (!bone)
8442
+ throw new Error(`Couldn't find bone ${boneName} for skin ${skinMap.name}.`);
8443
+ skin.bones.push(bone);
8444
+ }
8331
8445
  }
8332
8446
  if (skinMap.ik) {
8333
- for (let ii = 0; ii < skinMap.ik.length; ii++)
8334
- skin.constraints.push(skeletonData.findIkConstraint(skinMap.ik[ii]));
8447
+ for (let ii = 0; ii < skinMap.ik.length; ii++) {
8448
+ let constraintName = skinMap.ik[ii];
8449
+ let constraint = skeletonData.findIkConstraint(constraintName);
8450
+ if (!constraint)
8451
+ throw new Error(`Couldn't find IK constraint ${constraintName} for skin ${skinMap.name}.`);
8452
+ skin.constraints.push(constraint);
8453
+ }
8335
8454
  }
8336
8455
  if (skinMap.transform) {
8337
- for (let ii = 0; ii < skinMap.transform.length; ii++)
8338
- skin.constraints.push(skeletonData.findTransformConstraint(skinMap.transform[ii]));
8456
+ for (let ii = 0; ii < skinMap.transform.length; ii++) {
8457
+ let constraintName = skinMap.transform[ii];
8458
+ let constraint = skeletonData.findTransformConstraint(constraintName);
8459
+ if (!constraint)
8460
+ throw new Error(`Couldn't find transform constraint ${constraintName} for skin ${skinMap.name}.`);
8461
+ skin.constraints.push(constraint);
8462
+ }
8339
8463
  }
8340
8464
  if (skinMap.path) {
8341
- for (let ii = 0; ii < skinMap.path.length; ii++)
8342
- skin.constraints.push(skeletonData.findPathConstraint(skinMap.path[ii]));
8465
+ for (let ii = 0; ii < skinMap.path.length; ii++) {
8466
+ let constraintName = skinMap.path[ii];
8467
+ let constraint = skeletonData.findPathConstraint(constraintName);
8468
+ if (!constraint)
8469
+ throw new Error(`Couldn't find path constraint ${constraintName} for skin ${skinMap.name}.`);
8470
+ skin.constraints.push(constraint);
8471
+ }
8343
8472
  }
8344
8473
  for (let slotName in skinMap.attachments) {
8345
8474
  let slot = skeletonData.findSlot(slotName);
8475
+ if (!slot)
8476
+ throw new Error(`Couldn't find slot ${slotName} for skin ${skinMap.name}.`);
8346
8477
  let slotMap = skinMap.attachments[slotName];
8347
8478
  for (let entryName in slotMap) {
8348
8479
  let attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
@@ -8358,8 +8489,12 @@ var spine = (() => {
8358
8489
  for (let i = 0, n = this.linkedMeshes.length; i < n; i++) {
8359
8490
  let linkedMesh = this.linkedMeshes[i];
8360
8491
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
8492
+ if (!skin)
8493
+ throw new Error(`Skin not found: ${linkedMesh.skin}`);
8361
8494
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
8362
- linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
8495
+ if (!parent)
8496
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
8497
+ linkedMesh.mesh.timelineAttachment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
8363
8498
  linkedMesh.mesh.setParentMesh(parent);
8364
8499
  if (linkedMesh.mesh.region != null)
8365
8500
  linkedMesh.mesh.updateRegion();
@@ -8542,7 +8677,10 @@ var spine = (() => {
8542
8677
  if (map.slots) {
8543
8678
  for (let slotName in map.slots) {
8544
8679
  let slotMap = map.slots[slotName];
8545
- let slotIndex = skeletonData.findSlot(slotName).index;
8680
+ let slot = skeletonData.findSlot(slotName);
8681
+ if (!slot)
8682
+ throw new Error("Slot not found: " + slotName);
8683
+ let slotIndex = slot.index;
8546
8684
  for (let timelineName in slotMap) {
8547
8685
  let timelineMap = slotMap[timelineName];
8548
8686
  if (!timelineMap)
@@ -8678,7 +8816,10 @@ var spine = (() => {
8678
8816
  if (map.bones) {
8679
8817
  for (let boneName in map.bones) {
8680
8818
  let boneMap = map.bones[boneName];
8681
- let boneIndex = skeletonData.findBone(boneName).index;
8819
+ let bone = skeletonData.findBone(boneName);
8820
+ if (!bone)
8821
+ throw new Error("Bone not found: " + boneName);
8822
+ let boneIndex = bone.index;
8682
8823
  for (let timelineName in boneMap) {
8683
8824
  let timelineMap = boneMap[timelineName];
8684
8825
  let frames = timelineMap.length;
@@ -8724,6 +8865,8 @@ var spine = (() => {
8724
8865
  if (!keyMap)
8725
8866
  continue;
8726
8867
  let constraint = skeletonData.findIkConstraint(constraintName);
8868
+ if (!constraint)
8869
+ throw new Error("IK Constraint not found: " + constraintName);
8727
8870
  let constraintIndex = skeletonData.ikConstraints.indexOf(constraint);
8728
8871
  let timeline = new IkConstraintTimeline(constraintMap.length, constraintMap.length << 1, constraintIndex);
8729
8872
  let time = getValue(keyMap, "time", 0);
@@ -8759,6 +8902,8 @@ var spine = (() => {
8759
8902
  if (!keyMap)
8760
8903
  continue;
8761
8904
  let constraint = skeletonData.findTransformConstraint(constraintName);
8905
+ if (!constraint)
8906
+ throw new Error("Transform constraint not found: " + constraintName);
8762
8907
  let constraintIndex = skeletonData.transformConstraints.indexOf(constraint);
8763
8908
  let timeline = new TransformConstraintTimeline(timelineMap.length, timelineMap.length * 6, constraintIndex);
8764
8909
  let time = getValue(keyMap, "time", 0);
@@ -8807,6 +8952,8 @@ var spine = (() => {
8807
8952
  for (let constraintName in map.path) {
8808
8953
  let constraintMap = map.path[constraintName];
8809
8954
  let constraint = skeletonData.findPathConstraint(constraintName);
8955
+ if (!constraint)
8956
+ throw new Error("Path constraint not found: " + constraintName);
8810
8957
  let constraintIndex = skeletonData.pathConstraints.indexOf(constraint);
8811
8958
  for (let timelineName in constraintMap) {
8812
8959
  let timelineMap = constraintMap[timelineName];
@@ -8858,9 +9005,14 @@ var spine = (() => {
8858
9005
  for (let attachmentsName in map.attachments) {
8859
9006
  let attachmentsMap = map.attachments[attachmentsName];
8860
9007
  let skin = skeletonData.findSkin(attachmentsName);
9008
+ if (!skin)
9009
+ throw new Error("Skin not found: " + attachmentsName);
8861
9010
  for (let slotMapName in attachmentsMap) {
8862
9011
  let slotMap = attachmentsMap[slotMapName];
8863
- let slotIndex = skeletonData.findSlot(slotMapName).index;
9012
+ let slot = skeletonData.findSlot(slotMapName);
9013
+ if (!slot)
9014
+ throw new Error("Slot not found: " + slotMapName);
9015
+ let slotIndex = slot.index;
8864
9016
  for (let attachmentMapName in slotMap) {
8865
9017
  let attachmentMap = slotMap[attachmentMapName];
8866
9018
  let attachment = skin.getAttachment(slotIndex, attachmentMapName);
@@ -8940,7 +9092,10 @@ var spine = (() => {
8940
9092
  let originalIndex = 0, unchangedIndex = 0;
8941
9093
  for (let ii = 0; ii < offsets.length; ii++) {
8942
9094
  let offsetMap = offsets[ii];
8943
- let slotIndex = skeletonData.findSlot(offsetMap.slot).index;
9095
+ let slot = skeletonData.findSlot(offsetMap.slot);
9096
+ if (!slot)
9097
+ throw new Error("Slot not found: " + slot);
9098
+ let slotIndex = slot.index;
8944
9099
  while (originalIndex != slotIndex)
8945
9100
  unchanged[unchangedIndex++] = originalIndex++;
8946
9101
  drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
@@ -8961,6 +9116,8 @@ var spine = (() => {
8961
9116
  for (let i = 0; i < map.events.length; i++, frame++) {
8962
9117
  let eventMap = map.events[i];
8963
9118
  let eventData = skeletonData.findEvent(eventMap.name);
9119
+ if (!eventData)
9120
+ throw new Error("Event not found: " + eventMap.name);
8964
9121
  let event = new Event(Utils.toSinglePrecision(getValue(eventMap, "time", 0)), eventData);
8965
9122
  event.intValue = getValue(eventMap, "int", eventData.intValue);
8966
9123
  event.floatValue = getValue(eventMap, "float", eventData.floatValue);
@@ -9064,82 +9221,28 @@ var spine = (() => {
9064
9221
  }
9065
9222
  })();
9066
9223
 
9067
- // spine-core/src/vertexeffects/JitterEffect.ts
9068
- var JitterEffect = class {
9069
- constructor(jitterX, jitterY) {
9070
- this.jitterX = 0;
9071
- this.jitterY = 0;
9072
- this.jitterX = jitterX;
9073
- this.jitterY = jitterY;
9074
- }
9075
- begin(skeleton) {
9076
- }
9077
- transform(position, uv, light, dark) {
9078
- position.x += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
9079
- position.y += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
9080
- }
9081
- end() {
9082
- }
9083
- };
9084
-
9085
- // spine-core/src/vertexeffects/SwirlEffect.ts
9086
- var _SwirlEffect = class {
9087
- constructor(radius) {
9088
- this.centerX = 0;
9089
- this.centerY = 0;
9090
- this.radius = 0;
9091
- this.angle = 0;
9092
- this.worldX = 0;
9093
- this.worldY = 0;
9094
- this.radius = radius;
9095
- }
9096
- begin(skeleton) {
9097
- this.worldX = skeleton.x + this.centerX;
9098
- this.worldY = skeleton.y + this.centerY;
9099
- }
9100
- transform(position, uv, light, dark) {
9101
- let radAngle = this.angle * MathUtils.degreesToRadians;
9102
- let x = position.x - this.worldX;
9103
- let y = position.y - this.worldY;
9104
- let dist = Math.sqrt(x * x + y * y);
9105
- if (dist < this.radius) {
9106
- let theta = _SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
9107
- let cos = Math.cos(theta);
9108
- let sin = Math.sin(theta);
9109
- position.x = cos * x - sin * y + this.worldX;
9110
- position.y = sin * x + cos * y + this.worldY;
9111
- }
9112
- }
9113
- end() {
9114
- }
9115
- };
9116
- var SwirlEffect = _SwirlEffect;
9117
- SwirlEffect.interpolation = new PowOut(2);
9118
-
9119
9224
  // spine-webgl/src/WebGL.ts
9120
9225
  var ManagedWebGLRenderingContext = class {
9121
9226
  constructor(canvasOrContext, contextConfig = { alpha: "true" }) {
9122
9227
  this.restorables = new Array();
9123
- if (!(canvasOrContext instanceof WebGLRenderingContext || typeof WebGL2RenderingContext !== "undefined" && canvasOrContext instanceof WebGL2RenderingContext))
9124
- this.setupCanvas(canvasOrContext, contextConfig);
9125
- else {
9228
+ if (!(canvasOrContext instanceof WebGLRenderingContext || typeof WebGL2RenderingContext !== "undefined" && canvasOrContext instanceof WebGL2RenderingContext)) {
9229
+ let canvas = canvasOrContext;
9230
+ this.gl = canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig);
9231
+ this.canvas = canvas;
9232
+ canvas.addEventListener("webglcontextlost", (e) => {
9233
+ let event = e;
9234
+ if (e)
9235
+ e.preventDefault();
9236
+ });
9237
+ canvas.addEventListener("webglcontextrestored", (e) => {
9238
+ for (let i = 0, n = this.restorables.length; i < n; i++)
9239
+ this.restorables[i].restore();
9240
+ });
9241
+ } else {
9126
9242
  this.gl = canvasOrContext;
9127
9243
  this.canvas = this.gl.canvas;
9128
9244
  }
9129
9245
  }
9130
- setupCanvas(canvas, contextConfig) {
9131
- this.gl = canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig);
9132
- this.canvas = canvas;
9133
- canvas.addEventListener("webglcontextlost", (e) => {
9134
- let event = e;
9135
- if (e)
9136
- e.preventDefault();
9137
- });
9138
- canvas.addEventListener("webglcontextrestored", (e) => {
9139
- for (let i = 0, n = this.restorables.length; i < n; i++)
9140
- this.restorables[i].restore();
9141
- });
9142
- }
9143
9246
  addRestorable(restorable) {
9144
9247
  this.restorables.push(restorable);
9145
9248
  }
@@ -9276,7 +9379,7 @@ var spine = (() => {
9276
9379
 
9277
9380
  // spine-webgl/src/AssetManager.ts
9278
9381
  var AssetManager = class extends AssetManagerBase {
9279
- constructor(context, pathPrefix = "", downloader = null) {
9382
+ constructor(context, pathPrefix = "", downloader = new Downloader()) {
9280
9383
  super((image) => {
9281
9384
  return new GLTexture(context, image);
9282
9385
  }, pathPrefix, downloader);
@@ -9585,7 +9688,6 @@ var spine = (() => {
9585
9688
  return this.set(this.temp);
9586
9689
  }
9587
9690
  lookAt(position, direction, up) {
9588
- _Matrix4.initTemps();
9589
9691
  let xAxis = _Matrix4.xAxis, yAxis = _Matrix4.yAxis, zAxis = _Matrix4.zAxis;
9590
9692
  zAxis.setFrom(direction).normalize();
9591
9693
  xAxis.setFrom(direction).normalize();
@@ -9609,19 +9711,11 @@ var spine = (() => {
9609
9711
  this.multiply(_Matrix4.tmpMatrix);
9610
9712
  return this;
9611
9713
  }
9612
- static initTemps() {
9613
- if (_Matrix4.xAxis === null)
9614
- _Matrix4.xAxis = new Vector3();
9615
- if (_Matrix4.yAxis === null)
9616
- _Matrix4.yAxis = new Vector3();
9617
- if (_Matrix4.zAxis === null)
9618
- _Matrix4.zAxis = new Vector3();
9619
- }
9620
9714
  };
9621
9715
  var Matrix42 = _Matrix4;
9622
- Matrix42.xAxis = null;
9623
- Matrix42.yAxis = null;
9624
- Matrix42.zAxis = null;
9716
+ Matrix42.xAxis = new Vector3();
9717
+ Matrix42.yAxis = new Vector3();
9718
+ Matrix42.zAxis = new Vector3();
9625
9719
  Matrix42.tmpMatrix = new _Matrix4();
9626
9720
 
9627
9721
  // spine-webgl/src/Camera.ts
@@ -9758,6 +9852,8 @@ var spine = (() => {
9758
9852
  if (!this.touch0 || !this.touch1) {
9759
9853
  var touches = ev.changedTouches;
9760
9854
  let nativeTouch = touches.item(0);
9855
+ if (!nativeTouch)
9856
+ return;
9761
9857
  let rect = element.getBoundingClientRect();
9762
9858
  let x = nativeTouch.clientX - rect.left;
9763
9859
  let y = nativeTouch.clientY - rect.top;
@@ -9978,7 +10074,11 @@ var spine = (() => {
9978
10074
  let gl = this.context.gl;
9979
10075
  try {
9980
10076
  this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);
10077
+ if (!this.vs)
10078
+ throw new Error("Couldn't compile vertex shader.");
9981
10079
  this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);
10080
+ if (!this.fs)
10081
+ throw new Error("Couldn#t compile fragment shader.");
9982
10082
  this.program = this.compileProgram(this.vs, this.fs);
9983
10083
  } catch (e) {
9984
10084
  this.dispose();
@@ -9988,6 +10088,8 @@ var spine = (() => {
9988
10088
  compileShader(type, source) {
9989
10089
  let gl = this.context.gl;
9990
10090
  let shader = gl.createShader(type);
10091
+ if (!shader)
10092
+ throw new Error("Couldn't create shader.");
9991
10093
  gl.shaderSource(shader, source);
9992
10094
  gl.compileShader(shader);
9993
10095
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
@@ -10001,6 +10103,8 @@ var spine = (() => {
10001
10103
  compileProgram(vs, fs) {
10002
10104
  let gl = this.context.gl;
10003
10105
  let program = gl.createProgram();
10106
+ if (!program)
10107
+ throw new Error("Couldn't compile program.");
10004
10108
  gl.attachShader(program, vs);
10005
10109
  gl.attachShader(program, fs);
10006
10110
  gl.linkProgram(program);
@@ -10053,6 +10157,8 @@ var spine = (() => {
10053
10157
  }
10054
10158
  getUniformLocation(uniform) {
10055
10159
  let gl = this.context.gl;
10160
+ if (!this.program)
10161
+ throw new Error("Shader not compiled.");
10056
10162
  let location = gl.getUniformLocation(this.program, uniform);
10057
10163
  if (!location && !gl.isContextLost())
10058
10164
  throw new Error(`Couldn't find location for uniform ${uniform}`);
@@ -10060,6 +10166,8 @@ var spine = (() => {
10060
10166
  }
10061
10167
  getAttributeLocation(attribute) {
10062
10168
  let gl = this.context.gl;
10169
+ if (!this.program)
10170
+ throw new Error("Shader not compiled.");
10063
10171
  let location = gl.getAttribLocation(this.program, attribute);
10064
10172
  if (location == -1 && !gl.isContextLost())
10065
10173
  throw new Error(`Couldn't find location for attribute ${attribute}`);
@@ -10191,8 +10299,10 @@ var spine = (() => {
10191
10299
  var Mesh = class {
10192
10300
  constructor(context, attributes, maxVertices, maxIndices) {
10193
10301
  this.attributes = attributes;
10302
+ this.verticesBuffer = null;
10194
10303
  this.verticesLength = 0;
10195
10304
  this.dirtyVertices = false;
10305
+ this.indicesBuffer = null;
10196
10306
  this.indicesLength = 0;
10197
10307
  this.dirtyIndices = false;
10198
10308
  this.elementsPerVertex = 0;
@@ -10367,11 +10477,13 @@ var spine = (() => {
10367
10477
  // spine-webgl/src/PolygonBatcher.ts
10368
10478
  var PolygonBatcher = class {
10369
10479
  constructor(context, twoColorTint = true, maxVertices = 10920) {
10480
+ this.drawCalls = 0;
10370
10481
  this.isDrawing = false;
10371
10482
  this.shader = null;
10372
10483
  this.lastTexture = null;
10373
10484
  this.verticesLength = 0;
10374
10485
  this.indicesLength = 0;
10486
+ this.cullWasEnabled = false;
10375
10487
  if (maxVertices > 10920)
10376
10488
  throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
10377
10489
  this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context);
@@ -10428,6 +10540,10 @@ var spine = (() => {
10428
10540
  flush() {
10429
10541
  if (this.verticesLength == 0)
10430
10542
  return;
10543
+ if (!this.lastTexture)
10544
+ throw new Error("No texture set.");
10545
+ if (!this.shader)
10546
+ throw new Error("No shader set.");
10431
10547
  this.lastTexture.bind();
10432
10548
  this.mesh.draw(this.shader, this.context.gl.TRIANGLES);
10433
10549
  this.verticesLength = 0;
@@ -10463,6 +10579,7 @@ var spine = (() => {
10463
10579
  this.isDrawing = false;
10464
10580
  this.shapeType = ShapeType.Filled;
10465
10581
  this.color = new Color(1, 1, 1, 1);
10582
+ this.shader = null;
10466
10583
  this.vertexIndex = 0;
10467
10584
  this.tmp = new Vector2();
10468
10585
  if (maxVertices > 10920)
@@ -10500,30 +10617,30 @@ var spine = (() => {
10500
10617
  setColorWith(r, g, b, a) {
10501
10618
  this.color.set(r, g, b, a);
10502
10619
  }
10503
- point(x, y, color = null) {
10620
+ point(x, y, color) {
10504
10621
  this.check(ShapeType.Point, 1);
10505
- if (color === null)
10622
+ if (!color)
10506
10623
  color = this.color;
10507
10624
  this.vertex(x, y, color);
10508
10625
  }
10509
- line(x, y, x2, y2, color = null) {
10626
+ line(x, y, x2, y2, color) {
10510
10627
  this.check(ShapeType.Line, 2);
10511
10628
  let vertices = this.mesh.getVertices();
10512
10629
  let idx = this.vertexIndex;
10513
- if (color === null)
10630
+ if (!color)
10514
10631
  color = this.color;
10515
10632
  this.vertex(x, y, color);
10516
10633
  this.vertex(x2, y2, color);
10517
10634
  }
10518
- triangle(filled, x, y, x2, y2, x3, y3, color = null, color2 = null, color3 = null) {
10635
+ triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3) {
10519
10636
  this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
10520
10637
  let vertices = this.mesh.getVertices();
10521
10638
  let idx = this.vertexIndex;
10522
- if (color === null)
10639
+ if (!color)
10523
10640
  color = this.color;
10524
- if (color2 === null)
10641
+ if (!color2)
10525
10642
  color2 = this.color;
10526
- if (color3 === null)
10643
+ if (!color3)
10527
10644
  color3 = this.color;
10528
10645
  if (filled) {
10529
10646
  this.vertex(x, y, color);
@@ -10538,17 +10655,17 @@ var spine = (() => {
10538
10655
  this.vertex(x, y, color2);
10539
10656
  }
10540
10657
  }
10541
- quad(filled, x, y, x2, y2, x3, y3, x4, y4, color = null, color2 = null, color3 = null, color4 = null) {
10658
+ quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
10542
10659
  this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
10543
10660
  let vertices = this.mesh.getVertices();
10544
10661
  let idx = this.vertexIndex;
10545
- if (color === null)
10662
+ if (!color)
10546
10663
  color = this.color;
10547
- if (color2 === null)
10664
+ if (!color2)
10548
10665
  color2 = this.color;
10549
- if (color3 === null)
10666
+ if (!color3)
10550
10667
  color3 = this.color;
10551
- if (color4 === null)
10668
+ if (!color4)
10552
10669
  color4 = this.color;
10553
10670
  if (filled) {
10554
10671
  this.vertex(x, y, color);
@@ -10568,12 +10685,12 @@ var spine = (() => {
10568
10685
  this.vertex(x, y, color);
10569
10686
  }
10570
10687
  }
10571
- rect(filled, x, y, width, height, color = null) {
10688
+ rect(filled, x, y, width, height, color) {
10572
10689
  this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);
10573
10690
  }
10574
- rectLine(filled, x1, y1, x2, y2, width, color = null) {
10691
+ rectLine(filled, x1, y1, x2, y2, width, color) {
10575
10692
  this.check(filled ? ShapeType.Filled : ShapeType.Line, 8);
10576
- if (color === null)
10693
+ if (!color)
10577
10694
  color = this.color;
10578
10695
  let t = this.tmp.set(y2 - y1, x1 - x2);
10579
10696
  t.normalize();
@@ -10602,11 +10719,11 @@ var spine = (() => {
10602
10719
  this.line(x - size, y - size, x + size, y + size);
10603
10720
  this.line(x - size, y + size, x + size, y - size);
10604
10721
  }
10605
- polygon(polygonVertices, offset, count, color = null) {
10722
+ polygon(polygonVertices, offset, count, color) {
10606
10723
  if (count < 3)
10607
10724
  throw new Error("Polygon must contain at least 3 vertices");
10608
10725
  this.check(ShapeType.Line, count * 2);
10609
- if (color === null)
10726
+ if (color)
10610
10727
  color = this.color;
10611
10728
  let vertices = this.mesh.getVertices();
10612
10729
  let idx = this.vertexIndex;
@@ -10631,12 +10748,12 @@ var spine = (() => {
10631
10748
  this.vertex(x2, y2, color);
10632
10749
  }
10633
10750
  }
10634
- circle(filled, x, y, radius, color = null, segments = 0) {
10635
- if (segments === 0)
10751
+ circle(filled, x, y, radius, color, segments = 0) {
10752
+ if (segments == 0)
10636
10753
  segments = Math.max(1, 6 * MathUtils.cbrt(radius) | 0);
10637
10754
  if (segments <= 0)
10638
10755
  throw new Error("segments must be > 0.");
10639
- if (color === null)
10756
+ if (!color)
10640
10757
  color = this.color;
10641
10758
  let angle = 2 * MathUtils.PI / segments;
10642
10759
  let cos = Math.cos(angle);
@@ -10671,9 +10788,9 @@ var spine = (() => {
10671
10788
  cy = 0;
10672
10789
  this.vertex(x + cx, y + cy, color);
10673
10790
  }
10674
- curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color = null) {
10791
+ curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
10675
10792
  this.check(ShapeType.Line, segments * 2 + 2);
10676
- if (color === null)
10793
+ if (color)
10677
10794
  color = this.color;
10678
10795
  let subdiv_step = 1 / segments;
10679
10796
  let subdiv_step2 = subdiv_step * subdiv_step;
@@ -10729,6 +10846,8 @@ var spine = (() => {
10729
10846
  flush() {
10730
10847
  if (this.vertexIndex == 0)
10731
10848
  return;
10849
+ if (!this.shader)
10850
+ throw new Error("No shader set.");
10732
10851
  this.mesh.setVerticesLength(this.vertexIndex);
10733
10852
  this.mesh.draw(this.shader, this.shapeType);
10734
10853
  this.vertexIndex = 0;
@@ -10783,7 +10902,7 @@ var spine = (() => {
10783
10902
  this.vertices = Utils.newFloatArray(2 * 1024);
10784
10903
  this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context);
10785
10904
  }
10786
- draw(shapes, skeleton, ignoredBones = null) {
10905
+ draw(shapes, skeleton, ignoredBones) {
10787
10906
  let skeletonX = skeleton.x;
10788
10907
  let skeletonY = skeleton.y;
10789
10908
  let gl = this.context.gl;
@@ -10960,12 +11079,11 @@ var spine = (() => {
10960
11079
  var _SkeletonRenderer = class {
10961
11080
  constructor(context, twoColorTint = true) {
10962
11081
  this.premultipliedAlpha = false;
10963
- this.vertexEffect = null;
10964
11082
  this.tempColor = new Color();
10965
11083
  this.tempColor2 = new Color();
10966
11084
  this.vertexSize = 2 + 2 + 4;
10967
11085
  this.twoColorTint = false;
10968
- this.renderable = new Renderable(null, 0, 0);
11086
+ this.renderable = new Renderable([], 0, 0);
10969
11087
  this.clipper = new SkeletonClipping();
10970
11088
  this.temp = new Vector2();
10971
11089
  this.temp2 = new Vector2();
@@ -10986,10 +11104,10 @@ var spine = (() => {
10986
11104
  let tempLight = this.temp3;
10987
11105
  let tempDark = this.temp4;
10988
11106
  let renderable = this.renderable;
10989
- let uvs = null;
10990
- let triangles = null;
11107
+ let uvs;
11108
+ let triangles;
10991
11109
  let drawOrder = skeleton.drawOrder;
10992
- let attachmentColor = null;
11110
+ let attachmentColor;
10993
11111
  let skeletonColor = skeleton.color;
10994
11112
  let vertexSize = twoColorTint ? 12 : 8;
10995
11113
  let inRange = false;
@@ -11013,7 +11131,7 @@ var spine = (() => {
11013
11131
  inRange = false;
11014
11132
  }
11015
11133
  let attachment = slot.getAttachment();
11016
- let texture = null;
11134
+ let texture;
11017
11135
  if (attachment instanceof RegionAttachment) {
11018
11136
  let region = attachment;
11019
11137
  renderable.vertices = this.vertices;
@@ -11079,120 +11197,30 @@ var spine = (() => {
11079
11197
  clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
11080
11198
  let clippedVertices = new Float32Array(clipper.clippedVertices);
11081
11199
  let clippedTriangles = clipper.clippedTriangles;
11082
- if (this.vertexEffect) {
11083
- let vertexEffect = this.vertexEffect;
11084
- let verts = clippedVertices;
11085
- if (!twoColorTint) {
11086
- for (let v = 0, n2 = clippedVertices.length; v < n2; v += vertexSize) {
11087
- tempPos.x = verts[v];
11088
- tempPos.y = verts[v + 1];
11089
- tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
11090
- tempUv.x = verts[v + 6];
11091
- tempUv.y = verts[v + 7];
11092
- tempDark.set(0, 0, 0, 0);
11093
- vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
11094
- verts[v] = tempPos.x;
11095
- verts[v + 1] = tempPos.y;
11096
- verts[v + 2] = tempLight.r;
11097
- verts[v + 3] = tempLight.g;
11098
- verts[v + 4] = tempLight.b;
11099
- verts[v + 5] = tempLight.a;
11100
- verts[v + 6] = tempUv.x;
11101
- verts[v + 7] = tempUv.y;
11102
- }
11103
- } else {
11104
- for (let v = 0, n2 = clippedVertices.length; v < n2; v += vertexSize) {
11105
- tempPos.x = verts[v];
11106
- tempPos.y = verts[v + 1];
11107
- tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
11108
- tempUv.x = verts[v + 6];
11109
- tempUv.y = verts[v + 7];
11110
- tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);
11111
- vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
11112
- verts[v] = tempPos.x;
11113
- verts[v + 1] = tempPos.y;
11114
- verts[v + 2] = tempLight.r;
11115
- verts[v + 3] = tempLight.g;
11116
- verts[v + 4] = tempLight.b;
11117
- verts[v + 5] = tempLight.a;
11118
- verts[v + 6] = tempUv.x;
11119
- verts[v + 7] = tempUv.y;
11120
- verts[v + 8] = tempDark.r;
11121
- verts[v + 9] = tempDark.g;
11122
- verts[v + 10] = tempDark.b;
11123
- verts[v + 11] = tempDark.a;
11124
- }
11125
- }
11126
- }
11127
11200
  batcher.draw(texture, clippedVertices, clippedTriangles);
11128
11201
  } else {
11129
11202
  let verts = renderable.vertices;
11130
- if (this.vertexEffect) {
11131
- let vertexEffect = this.vertexEffect;
11132
- if (!twoColorTint) {
11133
- for (let v = 0, u = 0, n2 = renderable.numFloats; v < n2; v += vertexSize, u += 2) {
11134
- tempPos.x = verts[v];
11135
- tempPos.y = verts[v + 1];
11136
- tempUv.x = uvs[u];
11137
- tempUv.y = uvs[u + 1];
11138
- tempLight.setFromColor(finalColor);
11139
- tempDark.set(0, 0, 0, 0);
11140
- vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
11141
- verts[v] = tempPos.x;
11142
- verts[v + 1] = tempPos.y;
11143
- verts[v + 2] = tempLight.r;
11144
- verts[v + 3] = tempLight.g;
11145
- verts[v + 4] = tempLight.b;
11146
- verts[v + 5] = tempLight.a;
11147
- verts[v + 6] = tempUv.x;
11148
- verts[v + 7] = tempUv.y;
11149
- }
11150
- } else {
11151
- for (let v = 0, u = 0, n2 = renderable.numFloats; v < n2; v += vertexSize, u += 2) {
11152
- tempPos.x = verts[v];
11153
- tempPos.y = verts[v + 1];
11154
- tempUv.x = uvs[u];
11155
- tempUv.y = uvs[u + 1];
11156
- tempLight.setFromColor(finalColor);
11157
- tempDark.setFromColor(darkColor);
11158
- vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
11159
- verts[v] = tempPos.x;
11160
- verts[v + 1] = tempPos.y;
11161
- verts[v + 2] = tempLight.r;
11162
- verts[v + 3] = tempLight.g;
11163
- verts[v + 4] = tempLight.b;
11164
- verts[v + 5] = tempLight.a;
11165
- verts[v + 6] = tempUv.x;
11166
- verts[v + 7] = tempUv.y;
11167
- verts[v + 8] = tempDark.r;
11168
- verts[v + 9] = tempDark.g;
11169
- verts[v + 10] = tempDark.b;
11170
- verts[v + 11] = tempDark.a;
11171
- }
11203
+ if (!twoColorTint) {
11204
+ for (let v = 2, u = 0, n2 = renderable.numFloats; v < n2; v += vertexSize, u += 2) {
11205
+ verts[v] = finalColor.r;
11206
+ verts[v + 1] = finalColor.g;
11207
+ verts[v + 2] = finalColor.b;
11208
+ verts[v + 3] = finalColor.a;
11209
+ verts[v + 4] = uvs[u];
11210
+ verts[v + 5] = uvs[u + 1];
11172
11211
  }
11173
11212
  } else {
11174
- if (!twoColorTint) {
11175
- for (let v = 2, u = 0, n2 = renderable.numFloats; v < n2; v += vertexSize, u += 2) {
11176
- verts[v] = finalColor.r;
11177
- verts[v + 1] = finalColor.g;
11178
- verts[v + 2] = finalColor.b;
11179
- verts[v + 3] = finalColor.a;
11180
- verts[v + 4] = uvs[u];
11181
- verts[v + 5] = uvs[u + 1];
11182
- }
11183
- } else {
11184
- for (let v = 2, u = 0, n2 = renderable.numFloats; v < n2; v += vertexSize, u += 2) {
11185
- verts[v] = finalColor.r;
11186
- verts[v + 1] = finalColor.g;
11187
- verts[v + 2] = finalColor.b;
11188
- verts[v + 3] = finalColor.a;
11189
- verts[v + 4] = uvs[u];
11190
- verts[v + 5] = uvs[u + 1];
11191
- verts[v + 6] = darkColor.r;
11192
- verts[v + 7] = darkColor.g;
11193
- verts[v + 8] = darkColor.b;
11194
- verts[v + 9] = darkColor.a;
11195
- }
11213
+ for (let v = 2, u = 0, n2 = renderable.numFloats; v < n2; v += vertexSize, u += 2) {
11214
+ verts[v] = finalColor.r;
11215
+ verts[v + 1] = finalColor.g;
11216
+ verts[v + 2] = finalColor.b;
11217
+ verts[v + 3] = finalColor.a;
11218
+ verts[v + 4] = uvs[u];
11219
+ verts[v + 5] = uvs[u + 1];
11220
+ verts[v + 6] = darkColor.r;
11221
+ verts[v + 7] = darkColor.g;
11222
+ verts[v + 8] = darkColor.b;
11223
+ verts[v + 9] = darkColor.a;
11196
11224
  }
11197
11225
  }
11198
11226
  let view = renderable.vertices.subarray(0, renderable.numFloats);
@@ -11247,6 +11275,7 @@ var spine = (() => {
11247
11275
  var SceneRenderer = class {
11248
11276
  constructor(canvas, context, twoColorTint = true) {
11249
11277
  this.twoColorTint = false;
11278
+ this.activeRenderer = null;
11250
11279
  this.canvas = canvas;
11251
11280
  this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context);
11252
11281
  this.twoColorTint = twoColorTint;
@@ -11274,14 +11303,14 @@ var spine = (() => {
11274
11303
  this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
11275
11304
  this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);
11276
11305
  }
11277
- drawSkeletonDebug(skeleton, premultipliedAlpha = false, ignoredBones = null) {
11306
+ drawSkeletonDebug(skeleton, premultipliedAlpha = false, ignoredBones) {
11278
11307
  this.enableRenderer(this.shapes);
11279
11308
  this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;
11280
11309
  this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);
11281
11310
  }
11282
- drawTexture(texture, x, y, width, height, color = null) {
11311
+ drawTexture(texture, x, y, width, height, color) {
11283
11312
  this.enableRenderer(this.batcher);
11284
- if (color === null)
11313
+ if (!color)
11285
11314
  color = WHITE;
11286
11315
  var i = 0;
11287
11316
  quad[i++] = x;
@@ -11342,9 +11371,9 @@ var spine = (() => {
11342
11371
  }
11343
11372
  this.batcher.draw(texture, quad, QUAD_TRIANGLES);
11344
11373
  }
11345
- drawTextureUV(texture, x, y, width, height, u, v, u2, v2, color = null) {
11374
+ drawTextureUV(texture, x, y, width, height, u, v, u2, v2, color) {
11346
11375
  this.enableRenderer(this.batcher);
11347
- if (color === null)
11376
+ if (!color)
11348
11377
  color = WHITE;
11349
11378
  var i = 0;
11350
11379
  quad[i++] = x;
@@ -11405,9 +11434,9 @@ var spine = (() => {
11405
11434
  }
11406
11435
  this.batcher.draw(texture, quad, QUAD_TRIANGLES);
11407
11436
  }
11408
- drawTextureRotated(texture, x, y, width, height, pivotX, pivotY, angle, color = null) {
11437
+ drawTextureRotated(texture, x, y, width, height, pivotX, pivotY, angle, color) {
11409
11438
  this.enableRenderer(this.batcher);
11410
- if (color === null)
11439
+ if (!color)
11411
11440
  color = WHITE;
11412
11441
  let worldOriginX = x + pivotX;
11413
11442
  let worldOriginY = y + pivotY;
@@ -11519,9 +11548,9 @@ var spine = (() => {
11519
11548
  }
11520
11549
  this.batcher.draw(texture, quad, QUAD_TRIANGLES);
11521
11550
  }
11522
- drawRegion(region, x, y, width, height, color = null) {
11551
+ drawRegion(region, x, y, width, height, color) {
11523
11552
  this.enableRenderer(this.batcher);
11524
- if (color === null)
11553
+ if (!color)
11525
11554
  color = WHITE;
11526
11555
  var i = 0;
11527
11556
  quad[i++] = x;
@@ -11582,35 +11611,35 @@ var spine = (() => {
11582
11611
  }
11583
11612
  this.batcher.draw(region.page.texture, quad, QUAD_TRIANGLES);
11584
11613
  }
11585
- line(x, y, x2, y2, color = null, color2 = null) {
11614
+ line(x, y, x2, y2, color, color2) {
11586
11615
  this.enableRenderer(this.shapes);
11587
11616
  this.shapes.line(x, y, x2, y2, color);
11588
11617
  }
11589
- triangle(filled, x, y, x2, y2, x3, y3, color = null, color2 = null, color3 = null) {
11618
+ triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3) {
11590
11619
  this.enableRenderer(this.shapes);
11591
11620
  this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);
11592
11621
  }
11593
- quad(filled, x, y, x2, y2, x3, y3, x4, y4, color = null, color2 = null, color3 = null, color4 = null) {
11622
+ quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
11594
11623
  this.enableRenderer(this.shapes);
11595
11624
  this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);
11596
11625
  }
11597
- rect(filled, x, y, width, height, color = null) {
11626
+ rect(filled, x, y, width, height, color) {
11598
11627
  this.enableRenderer(this.shapes);
11599
11628
  this.shapes.rect(filled, x, y, width, height, color);
11600
11629
  }
11601
- rectLine(filled, x1, y1, x2, y2, width, color = null) {
11630
+ rectLine(filled, x1, y1, x2, y2, width, color) {
11602
11631
  this.enableRenderer(this.shapes);
11603
11632
  this.shapes.rectLine(filled, x1, y1, x2, y2, width, color);
11604
11633
  }
11605
- polygon(polygonVertices, offset, count, color = null) {
11634
+ polygon(polygonVertices, offset, count, color) {
11606
11635
  this.enableRenderer(this.shapes);
11607
11636
  this.shapes.polygon(polygonVertices, offset, count, color);
11608
11637
  }
11609
- circle(filled, x, y, radius, color = null, segments = 0) {
11638
+ circle(filled, x, y, radius, color, segments = 0) {
11610
11639
  this.enableRenderer(this.shapes);
11611
11640
  this.shapes.circle(filled, x, y, radius, color, segments);
11612
11641
  }
11613
- curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color = null) {
11642
+ curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
11614
11643
  this.enableRenderer(this.shapes);
11615
11644
  this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);
11616
11645
  }
@@ -11706,8 +11735,9 @@ var spine = (() => {
11706
11735
  }
11707
11736
  }
11708
11737
  dispose() {
11709
- this.logo.dispose();
11710
- this.spinner.dispose();
11738
+ var _a, _b;
11739
+ (_a = this.logo) == null ? void 0 : _a.dispose();
11740
+ (_b = this.spinner) == null ? void 0 : _b.dispose();
11711
11741
  }
11712
11742
  draw(complete = false) {
11713
11743
  if (loaded < 2 || complete && this.fadeOut > FADE_OUT)
@@ -11753,7 +11783,8 @@ var spine = (() => {
11753
11783
  renderer.camera.zoom = Math.max(1, spinnerSize / canvas.height);
11754
11784
  renderer.begin();
11755
11785
  renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, tempColor);
11756
- renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerSize) / 2, (canvas.height - spinnerSize) / 2, spinnerSize, spinnerSize, spinnerSize / 2, spinnerSize / 2, this.angle, tempColor);
11786
+ if (this.spinner)
11787
+ renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerSize) / 2, (canvas.height - spinnerSize) / 2, spinnerSize, spinnerSize, spinnerSize / 2, spinnerSize / 2, this.angle, tempColor);
11757
11788
  renderer.end();
11758
11789
  }
11759
11790
  };
@@ -11764,9 +11795,9 @@ var spine = (() => {
11764
11795
  var SpineCanvas = class {
11765
11796
  constructor(canvas, config) {
11766
11797
  this.time = new TimeKeeper();
11767
- if (config.pathPrefix === void 0)
11798
+ if (!config.pathPrefix)
11768
11799
  config.pathPrefix = "";
11769
- if (config.app === void 0)
11800
+ if (!config.app)
11770
11801
  config.app = {
11771
11802
  loadAssets: () => {
11772
11803
  },
@@ -11779,7 +11810,7 @@ var spine = (() => {
11779
11810
  error: () => {
11780
11811
  }
11781
11812
  };
11782
- if (config.webglConfig === void 0)
11813
+ if (config.webglConfig)
11783
11814
  config.webglConfig = { alpha: true };
11784
11815
  this.htmlCanvas = canvas;
11785
11816
  this.context = new ManagedWebGLRenderingContext(canvas, config.webglConfig);
@@ -11787,19 +11818,24 @@ var spine = (() => {
11787
11818
  this.gl = this.context.gl;
11788
11819
  this.assetManager = new AssetManager(this.context, config.pathPrefix);
11789
11820
  this.input = new Input(canvas);
11790
- config.app.loadAssets(this);
11821
+ if (config.app.loadAssets)
11822
+ config.app.loadAssets(this);
11791
11823
  let loop = () => {
11792
11824
  requestAnimationFrame(loop);
11793
11825
  this.time.update();
11794
- config.app.update(this, this.time.delta);
11795
- config.app.render(this);
11826
+ if (config.app.update)
11827
+ config.app.update(this, this.time.delta);
11828
+ if (config.app.render)
11829
+ config.app.render(this);
11796
11830
  };
11797
11831
  let waitForAssets = () => {
11798
11832
  if (this.assetManager.isLoadingComplete()) {
11799
11833
  if (this.assetManager.hasErrors()) {
11800
- config.app.error(this, this.assetManager.getErrors());
11834
+ if (config.app.error)
11835
+ config.app.error(this, this.assetManager.getErrors());
11801
11836
  } else {
11802
- config.app.initialize(this);
11837
+ if (config.app.initialize)
11838
+ config.app.initialize(this);
11803
11839
  loop();
11804
11840
  }
11805
11841
  return;