@esotericsoftware/spine-webgl 4.2.1 → 4.2.2

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.
@@ -555,7 +555,7 @@ var spine = (() => {
555
555
  super(name);
556
556
  this.id = _VertexAttachment.nextID++;
557
557
  this.bones = null;
558
- this.vertices = null;
558
+ this.vertices = [];
559
559
  this.worldVerticesLength = 0;
560
560
  this.timelineAttahment = this;
561
561
  }
@@ -626,8 +626,7 @@ var spine = (() => {
626
626
  if (this.vertices) {
627
627
  attachment.vertices = Utils.newFloatArray(this.vertices.length);
628
628
  Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
629
- } else
630
- attachment.vertices = null;
629
+ }
631
630
  attachment.worldVerticesLength = this.worldVerticesLength;
632
631
  attachment.timelineAttahment = this.timelineAttahment;
633
632
  }
@@ -701,8 +700,8 @@ var spine = (() => {
701
700
  // spine-core/src/Animation.ts
702
701
  var Animation = class {
703
702
  constructor(name, timelines, duration) {
704
- this.timelines = null;
705
- this.timelineIds = null;
703
+ this.timelines = [];
704
+ this.timelineIds = new StringSet();
706
705
  if (!name)
707
706
  throw new Error("name cannot be null.");
708
707
  this.name = name;
@@ -713,7 +712,7 @@ var spine = (() => {
713
712
  if (!timelines)
714
713
  throw new Error("timelines cannot be null.");
715
714
  this.timelines = timelines;
716
- this.timelineIds = new StringSet();
715
+ this.timelineIds.clear();
717
716
  for (var i = 0; i < timelines.length; i++)
718
717
  this.timelineIds.addAll(timelines[i].getPropertyIds());
719
718
  }
@@ -772,8 +771,6 @@ var spine = (() => {
772
771
  };
773
772
  var Timeline = class {
774
773
  constructor(frameCount, propertyIds) {
775
- this.propertyIds = null;
776
- this.frames = null;
777
774
  this.propertyIds = propertyIds;
778
775
  this.frames = Utils.newFloatArray(frameCount * this.getFrameEntries());
779
776
  }
@@ -807,7 +804,6 @@ var spine = (() => {
807
804
  var CurveTimeline = class extends Timeline {
808
805
  constructor(frameCount, bezierCount, propertyIds) {
809
806
  super(frameCount, propertyIds);
810
- this.curves = null;
811
807
  this.curves = Utils.newFloatArray(frameCount + bezierCount * 18);
812
808
  this.curves[frameCount - 1] = 1;
813
809
  }
@@ -1867,8 +1863,6 @@ var spine = (() => {
1867
1863
  Property.deform + "|" + slotIndex + "|" + attachment.id
1868
1864
  ]);
1869
1865
  this.slotIndex = 0;
1870
- this.attachment = null;
1871
- this.vertices = null;
1872
1866
  this.slotIndex = slotIndex;
1873
1867
  this.attachment = attachment;
1874
1868
  this.vertices = new Array(frameCount);
@@ -1931,6 +1925,8 @@ var spine = (() => {
1931
1925
  if (!slot.bone.active)
1932
1926
  return;
1933
1927
  let slotAttachment = slot.getAttachment();
1928
+ if (!slotAttachment)
1929
+ return;
1934
1930
  if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != this.attachment)
1935
1931
  return;
1936
1932
  let deform = slot.deform;
@@ -2085,7 +2081,6 @@ var spine = (() => {
2085
2081
  var _EventTimeline = class extends Timeline {
2086
2082
  constructor(frameCount) {
2087
2083
  super(frameCount, _EventTimeline.propertyIds);
2088
- this.events = null;
2089
2084
  this.events = new Array(frameCount);
2090
2085
  }
2091
2086
  getFrameCount() {
@@ -2128,7 +2123,6 @@ var spine = (() => {
2128
2123
  var _DrawOrderTimeline = class extends Timeline {
2129
2124
  constructor(frameCount) {
2130
2125
  super(frameCount, _DrawOrderTimeline.propertyIds);
2131
- this.drawOrders = null;
2132
2126
  this.drawOrders = new Array(frameCount);
2133
2127
  }
2134
2128
  getFrameCount() {
@@ -2149,7 +2143,8 @@ var spine = (() => {
2149
2143
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2150
2144
  return;
2151
2145
  }
2152
- let drawOrderToSetupIndex = this.drawOrders[Timeline.search1(this.frames, time)];
2146
+ let idx = Timeline.search1(this.frames, time);
2147
+ let drawOrderToSetupIndex = this.drawOrders[idx];
2153
2148
  if (!drawOrderToSetupIndex)
2154
2149
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2155
2150
  else {
@@ -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,9 +3830,8 @@ 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
3836
  copy.timelineAttahment = this.timelineAttahment;
3838
3837
  copy.setParentMesh(this.parentMesh ? this.parentMesh : this);
@@ -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++;
@@ -4420,10 +4417,28 @@ var spine = (() => {
4420
4417
  if (callback)
4421
4418
  callback(path, message);
4422
4419
  }
4420
+ loadAll() {
4421
+ let promise = new Promise((resolve, reject) => {
4422
+ let check = () => {
4423
+ if (this.isLoadingComplete()) {
4424
+ if (this.hasErrors())
4425
+ reject(this.errors);
4426
+ else
4427
+ resolve(this);
4428
+ return;
4429
+ }
4430
+ requestAnimationFrame(check);
4431
+ };
4432
+ requestAnimationFrame(check);
4433
+ });
4434
+ return promise;
4435
+ }
4423
4436
  setRawDataURI(path, data) {
4424
4437
  this.downloader.rawDataUris[this.pathPrefix + path] = data;
4425
4438
  }
4426
- loadBinary(path, success = null, error = null) {
4439
+ loadBinary(path, success = () => {
4440
+ }, error = () => {
4441
+ }) {
4427
4442
  path = this.start(path);
4428
4443
  this.downloader.downloadBinary(path, (data) => {
4429
4444
  this.success(success, path, data);
@@ -4431,7 +4446,9 @@ var spine = (() => {
4431
4446
  this.error(error, path, `Couldn't load binary ${path}: status ${status}, ${responseText}`);
4432
4447
  });
4433
4448
  }
4434
- loadText(path, success = null, error = null) {
4449
+ loadText(path, success = () => {
4450
+ }, error = () => {
4451
+ }) {
4435
4452
  path = this.start(path);
4436
4453
  this.downloader.downloadText(path, (data) => {
4437
4454
  this.success(success, path, data);
@@ -4439,7 +4456,9 @@ var spine = (() => {
4439
4456
  this.error(error, path, `Couldn't load text ${path}: status ${status}, ${responseText}`);
4440
4457
  });
4441
4458
  }
4442
- loadJson(path, success = null, error = null) {
4459
+ loadJson(path, success = () => {
4460
+ }, error = () => {
4461
+ }) {
4443
4462
  path = this.start(path);
4444
4463
  this.downloader.downloadJson(path, (data) => {
4445
4464
  this.success(success, path, data);
@@ -4447,7 +4466,9 @@ var spine = (() => {
4447
4466
  this.error(error, path, `Couldn't load JSON ${path}: status ${status}, ${responseText}`);
4448
4467
  });
4449
4468
  }
4450
- loadTexture(path, success = null, error = null) {
4469
+ loadTexture(path, success = () => {
4470
+ }, error = () => {
4471
+ }) {
4451
4472
  path = this.start(path);
4452
4473
  let isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document);
4453
4474
  let isWebWorker = !isBrowser;
@@ -4477,7 +4498,9 @@ var spine = (() => {
4477
4498
  image.src = path;
4478
4499
  }
4479
4500
  }
4480
- loadTextureAtlas(path, success = null, error = null, fileAlias = null) {
4501
+ loadTextureAtlas(path, success = () => {
4502
+ }, error = () => {
4503
+ }, fileAlias) {
4481
4504
  let index = path.lastIndexOf("/");
4482
4505
  let parent = index >= 0 ? path.substring(0, index + 1) : "";
4483
4506
  path = this.start(path);
@@ -4486,7 +4509,7 @@ var spine = (() => {
4486
4509
  let atlas = new TextureAtlas(atlasText);
4487
4510
  let toLoad = atlas.pages.length, abort = false;
4488
4511
  for (let page of atlas.pages) {
4489
- this.loadTexture(fileAlias == null ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4512
+ this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4490
4513
  if (!abort) {
4491
4514
  page.setTexture(texture);
4492
4515
  if (--toLoad == 0)
@@ -4663,7 +4686,6 @@ var spine = (() => {
4663
4686
  // spine-core/src/Event.ts
4664
4687
  var Event = class {
4665
4688
  constructor(time, data) {
4666
- this.data = null;
4667
4689
  this.intValue = 0;
4668
4690
  this.floatValue = 0;
4669
4691
  this.stringValue = null;
@@ -4680,7 +4702,6 @@ var spine = (() => {
4680
4702
  // spine-core/src/EventData.ts
4681
4703
  var EventData = class {
4682
4704
  constructor(name) {
4683
- this.name = null;
4684
4705
  this.intValue = 0;
4685
4706
  this.floatValue = 0;
4686
4707
  this.stringValue = null;
@@ -4694,9 +4715,6 @@ var spine = (() => {
4694
4715
  // spine-core/src/IkConstraint.ts
4695
4716
  var IkConstraint = class {
4696
4717
  constructor(data, skeleton) {
4697
- this.data = null;
4698
- this.bones = null;
4699
- this.target = null;
4700
4718
  this.bendDirection = 0;
4701
4719
  this.compress = false;
4702
4720
  this.stretch = false;
@@ -4714,9 +4732,16 @@ var spine = (() => {
4714
4732
  this.compress = data.compress;
4715
4733
  this.stretch = data.stretch;
4716
4734
  this.bones = new Array();
4717
- for (let i = 0; i < data.bones.length; i++)
4718
- this.bones.push(skeleton.findBone(data.bones[i].name));
4719
- 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;
4720
4745
  }
4721
4746
  isActive() {
4722
4747
  return this.active;
@@ -4737,6 +4762,8 @@ var spine = (() => {
4737
4762
  }
4738
4763
  apply1(bone, targetX, targetY, compress, stretch, uniform, alpha) {
4739
4764
  let p = bone.parent;
4765
+ if (!p)
4766
+ throw new Error("IK bone must have parent.");
4740
4767
  let pa = p.a, pb = p.b, pc = p.c, pd = p.d;
4741
4768
  let rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0;
4742
4769
  switch (bone.data.transformMode) {
@@ -4814,6 +4841,8 @@ var spine = (() => {
4814
4841
  cwy = c * cx + d * cy + parent.worldY;
4815
4842
  }
4816
4843
  let pp = parent.parent;
4844
+ if (!pp)
4845
+ throw new Error("IK parent must itself have a parent.");
4817
4846
  a = pp.a;
4818
4847
  b = pp.b;
4819
4848
  c = pp.c;
@@ -4935,7 +4964,7 @@ var spine = (() => {
4935
4964
  constructor(name) {
4936
4965
  super(name, 0, false);
4937
4966
  this.bones = new Array();
4938
- this.target = null;
4967
+ this._target = null;
4939
4968
  this.bendDirection = 1;
4940
4969
  this.compress = false;
4941
4970
  this.stretch = false;
@@ -4943,6 +4972,15 @@ var spine = (() => {
4943
4972
  this.mix = 1;
4944
4973
  this.softness = 0;
4945
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
+ }
4946
4984
  };
4947
4985
 
4948
4986
  // spine-core/src/PathConstraintData.ts
@@ -4950,10 +4988,10 @@ var spine = (() => {
4950
4988
  constructor(name) {
4951
4989
  super(name, 0, false);
4952
4990
  this.bones = new Array();
4953
- this.target = null;
4954
- this.positionMode = null;
4955
- this.spacingMode = null;
4956
- this.rotateMode = null;
4991
+ this._target = null;
4992
+ this.positionMode = PositionMode.Fixed;
4993
+ this.spacingMode = SpacingMode.Fixed;
4994
+ this.rotateMode = RotateMode.Chain;
4957
4995
  this.offsetRotation = 0;
4958
4996
  this.position = 0;
4959
4997
  this.spacing = 0;
@@ -4961,6 +4999,15 @@ var spine = (() => {
4961
4999
  this.mixX = 0;
4962
5000
  this.mixY = 0;
4963
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
+ }
4964
5011
  };
4965
5012
  var PositionMode;
4966
5013
  (function(PositionMode2) {
@@ -4984,9 +5031,6 @@ var spine = (() => {
4984
5031
  // spine-core/src/PathConstraint.ts
4985
5032
  var _PathConstraint = class {
4986
5033
  constructor(data, skeleton) {
4987
- this.data = null;
4988
- this.bones = null;
4989
- this.target = null;
4990
5034
  this.position = 0;
4991
5035
  this.spacing = 0;
4992
5036
  this.mixRotate = 0;
@@ -5005,9 +5049,16 @@ var spine = (() => {
5005
5049
  throw new Error("skeleton cannot be null.");
5006
5050
  this.data = data;
5007
5051
  this.bones = new Array();
5008
- for (let i = 0, n = data.bones.length; i < n; i++)
5009
- this.bones.push(skeleton.findBone(data.bones[i].name));
5010
- 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;
5011
5062
  this.position = data.position;
5012
5063
  this.spacing = data.spacing;
5013
5064
  this.mixRotate = data.mixRotate;
@@ -5028,7 +5079,7 @@ var spine = (() => {
5028
5079
  let tangents = data.rotateMode == RotateMode.Tangent, scale = data.rotateMode == RotateMode.ChainScale;
5029
5080
  let bones = this.bones;
5030
5081
  let boneCount = bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
5031
- 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) : [];
5032
5083
  let spacing = this.spacing;
5033
5084
  switch (data.spacingMode) {
5034
5085
  case SpacingMode.Percent:
@@ -5149,7 +5200,7 @@ var spine = (() => {
5149
5200
  computeWorldPositions(path, spacesCount, tangents) {
5150
5201
  let target = this.target;
5151
5202
  let position = this.position;
5152
- 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;
5153
5204
  let closed2 = path.closed;
5154
5205
  let verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = _PathConstraint.NONE;
5155
5206
  if (!path.constantSpeed) {
@@ -5406,12 +5457,10 @@ var spine = (() => {
5406
5457
  // spine-core/src/Slot.ts
5407
5458
  var Slot = class {
5408
5459
  constructor(data, bone) {
5409
- this.data = null;
5410
- this.bone = null;
5411
- this.color = null;
5412
5460
  this.darkColor = null;
5413
5461
  this.attachment = null;
5414
5462
  this.attachmentState = 0;
5463
+ this.sequenceIndex = -1;
5415
5464
  this.deform = new Array();
5416
5465
  if (!data)
5417
5466
  throw new Error("data cannot be null.");
@@ -5454,9 +5503,6 @@ var spine = (() => {
5454
5503
  // spine-core/src/TransformConstraint.ts
5455
5504
  var TransformConstraint = class {
5456
5505
  constructor(data, skeleton) {
5457
- this.data = null;
5458
- this.bones = null;
5459
- this.target = null;
5460
5506
  this.mixRotate = 0;
5461
5507
  this.mixX = 0;
5462
5508
  this.mixY = 0;
@@ -5477,9 +5523,16 @@ var spine = (() => {
5477
5523
  this.mixScaleY = data.mixScaleY;
5478
5524
  this.mixShearY = data.mixShearY;
5479
5525
  this.bones = new Array();
5480
- for (let i = 0; i < data.bones.length; i++)
5481
- this.bones.push(skeleton.findBone(data.bones[i].name));
5482
- 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;
5483
5536
  }
5484
5537
  isActive() {
5485
5538
  return this.active;
@@ -5664,16 +5717,8 @@ var spine = (() => {
5664
5717
  // spine-core/src/Skeleton.ts
5665
5718
  var Skeleton = class {
5666
5719
  constructor(data) {
5667
- this.data = null;
5668
- this.bones = null;
5669
- this.slots = null;
5670
- this.drawOrder = null;
5671
- this.ikConstraints = null;
5672
- this.transformConstraints = null;
5673
- this.pathConstraints = null;
5674
5720
  this._updateCache = new Array();
5675
5721
  this.skin = null;
5676
- this.color = null;
5677
5722
  this.scaleX = 1;
5678
5723
  this.scaleY = 1;
5679
5724
  this.x = 0;
@@ -5868,6 +5913,8 @@ var spine = (() => {
5868
5913
  }
5869
5914
  }
5870
5915
  sortBone(bone) {
5916
+ if (!bone)
5917
+ return;
5871
5918
  if (bone.sorted)
5872
5919
  return;
5873
5920
  let parent = bone.parent;
@@ -5904,6 +5951,8 @@ var spine = (() => {
5904
5951
  }
5905
5952
  updateWorldTransformWith(parent) {
5906
5953
  let rootBone = this.getRootBone();
5954
+ if (!rootBone)
5955
+ throw new Error("Root bone must not be null.");
5907
5956
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
5908
5957
  rootBone.worldX = pa * this.x + pb * this.y + parent.worldX;
5909
5958
  rootBone.worldY = pc * this.x + pd * this.y + parent.worldY;
@@ -6024,7 +6073,10 @@ var spine = (() => {
6024
6073
  this.updateCache();
6025
6074
  }
6026
6075
  getAttachmentByName(slotName, attachmentName) {
6027
- 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);
6028
6080
  }
6029
6081
  getAttachment(slotIndex, attachmentName) {
6030
6082
  if (!attachmentName)
@@ -6090,6 +6142,12 @@ var spine = (() => {
6090
6142
  }
6091
6143
  return null;
6092
6144
  }
6145
+ getBoundsRect() {
6146
+ let offset = new Vector2();
6147
+ let size = new Vector2();
6148
+ this.getBounds(offset, size);
6149
+ return { x: offset.x, y: offset.y, width: size.x, height: size.y };
6150
+ }
6093
6151
  getBounds(offset, size, temp = new Array(2)) {
6094
6152
  if (!offset)
6095
6153
  throw new Error("offset cannot be null.");
@@ -6244,7 +6302,7 @@ var spine = (() => {
6244
6302
 
6245
6303
  // spine-core/src/Skin.ts
6246
6304
  var SkinEntry = class {
6247
- constructor(slotIndex = 0, name = null, attachment = null) {
6305
+ constructor(slotIndex = 0, name, attachment) {
6248
6306
  this.slotIndex = slotIndex;
6249
6307
  this.name = name;
6250
6308
  this.attachment = attachment;
@@ -6252,7 +6310,6 @@ var spine = (() => {
6252
6310
  };
6253
6311
  var Skin = class {
6254
6312
  constructor(name) {
6255
- this.name = null;
6256
6313
  this.attachments = new Array();
6257
6314
  this.bones = Array();
6258
6315
  this.constraints = new Array();
@@ -6347,7 +6404,7 @@ var spine = (() => {
6347
6404
  removeAttachment(slotIndex, name) {
6348
6405
  let dictionary = this.attachments[slotIndex];
6349
6406
  if (dictionary)
6350
- dictionary[name] = null;
6407
+ delete dictionary[name];
6351
6408
  }
6352
6409
  getAttachments() {
6353
6410
  let entries = new Array();
@@ -6404,12 +6461,10 @@ var spine = (() => {
6404
6461
  var SlotData = class {
6405
6462
  constructor(index, name, boneData) {
6406
6463
  this.index = 0;
6407
- this.name = null;
6408
- this.boneData = null;
6409
6464
  this.color = new Color(1, 1, 1, 1);
6410
6465
  this.darkColor = null;
6411
6466
  this.attachmentName = null;
6412
- this.blendMode = null;
6467
+ this.blendMode = BlendMode.Normal;
6413
6468
  if (index < 0)
6414
6469
  throw new Error("index must be >= 0.");
6415
6470
  if (!name)
@@ -6434,7 +6489,7 @@ var spine = (() => {
6434
6489
  constructor(name) {
6435
6490
  super(name, 0, false);
6436
6491
  this.bones = new Array();
6437
- this.target = null;
6492
+ this._target = null;
6438
6493
  this.mixRotate = 0;
6439
6494
  this.mixX = 0;
6440
6495
  this.mixY = 0;
@@ -6450,13 +6505,21 @@ var spine = (() => {
6450
6505
  this.relative = false;
6451
6506
  this.local = false;
6452
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
+ }
6453
6517
  };
6454
6518
 
6455
6519
  // spine-core/src/SkeletonBinary.ts
6456
6520
  var SkeletonBinary = class {
6457
6521
  constructor(attachmentLoader) {
6458
6522
  this.scale = 1;
6459
- this.attachmentLoader = null;
6460
6523
  this.linkedMeshes = new Array();
6461
6524
  this.attachmentLoader = attachmentLoader;
6462
6525
  }
@@ -6481,11 +6544,17 @@ var spine = (() => {
6481
6544
  }
6482
6545
  let n = 0;
6483
6546
  n = input.readInt(true);
6484
- for (let i = 0; i < n; i++)
6485
- 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
+ }
6486
6553
  n = input.readInt(true);
6487
6554
  for (let i = 0; i < n; i++) {
6488
6555
  let name = input.readString();
6556
+ if (!name)
6557
+ throw new Error("Bone name must not be null.");
6489
6558
  let parent = i == 0 ? null : skeletonData.bones[input.readInt(true)];
6490
6559
  let data = new BoneData(i, name, parent);
6491
6560
  data.rotation = input.readFloat();
@@ -6505,6 +6574,8 @@ var spine = (() => {
6505
6574
  n = input.readInt(true);
6506
6575
  for (let i = 0; i < n; i++) {
6507
6576
  let slotName = input.readString();
6577
+ if (!slotName)
6578
+ throw new Error("Slot name must not be null.");
6508
6579
  let boneData = skeletonData.bones[input.readInt(true)];
6509
6580
  let data = new SlotData(i, slotName, boneData);
6510
6581
  Color.rgba8888ToColor(data.color, input.readInt32());
@@ -6517,7 +6588,10 @@ var spine = (() => {
6517
6588
  }
6518
6589
  n = input.readInt(true);
6519
6590
  for (let i = 0, nn; i < n; i++) {
6520
- 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);
6521
6595
  data.order = input.readInt(true);
6522
6596
  data.skinRequired = input.readBoolean();
6523
6597
  nn = input.readInt(true);
@@ -6534,7 +6608,10 @@ var spine = (() => {
6534
6608
  }
6535
6609
  n = input.readInt(true);
6536
6610
  for (let i = 0, nn; i < n; i++) {
6537
- 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);
6538
6615
  data.order = input.readInt(true);
6539
6616
  data.skinRequired = input.readBoolean();
6540
6617
  nn = input.readInt(true);
@@ -6559,7 +6636,10 @@ var spine = (() => {
6559
6636
  }
6560
6637
  n = input.readInt(true);
6561
6638
  for (let i = 0, nn; i < n; i++) {
6562
- 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);
6563
6643
  data.order = input.readInt(true);
6564
6644
  data.skinRequired = input.readBoolean();
6565
6645
  nn = input.readInt(true);
@@ -6589,14 +6669,24 @@ var spine = (() => {
6589
6669
  {
6590
6670
  let i = skeletonData.skins.length;
6591
6671
  Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
6592
- for (; i < n; i++)
6593
- 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
+ }
6594
6678
  }
6595
6679
  n = this.linkedMeshes.length;
6596
6680
  for (let i = 0; i < n; i++) {
6597
6681
  let linkedMesh = this.linkedMeshes[i];
6598
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");
6599
6687
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
6688
+ if (!parent)
6689
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
6600
6690
  linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6601
6691
  linkedMesh.mesh.setParentMesh(parent);
6602
6692
  if (linkedMesh.mesh.region != null)
@@ -6605,7 +6695,10 @@ var spine = (() => {
6605
6695
  this.linkedMeshes.length = 0;
6606
6696
  n = input.readInt(true);
6607
6697
  for (let i = 0; i < n; i++) {
6608
- let data = new EventData(input.readStringRef());
6698
+ let eventName = input.readStringRef();
6699
+ if (!eventName)
6700
+ throw new Error();
6701
+ let data = new EventData(eventName);
6609
6702
  data.intValue = input.readInt(false);
6610
6703
  data.floatValue = input.readFloat();
6611
6704
  data.stringValue = input.readString();
@@ -6617,8 +6710,12 @@ var spine = (() => {
6617
6710
  skeletonData.events.push(data);
6618
6711
  }
6619
6712
  n = input.readInt(true);
6620
- for (let i = 0; i < n; i++)
6621
- 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
+ }
6622
6719
  return skeletonData;
6623
6720
  }
6624
6721
  readSkin(input, skeletonData, defaultSkin, nonessential) {
@@ -6630,7 +6727,10 @@ var spine = (() => {
6630
6727
  return null;
6631
6728
  skin = new Skin("default");
6632
6729
  } else {
6633
- 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);
6634
6734
  skin.bones.length = input.readInt(true);
6635
6735
  for (let i = 0, n = skin.bones.length; i < n; i++)
6636
6736
  skin.bones[i] = skeletonData.bones[input.readInt(true)];
@@ -6646,6 +6746,8 @@ var spine = (() => {
6646
6746
  let slotIndex = input.readInt(true);
6647
6747
  for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
6648
6748
  let name = input.readStringRef();
6749
+ if (!name)
6750
+ throw new Error("Attachment name must not be null");
6649
6751
  let attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name, nonessential);
6650
6752
  if (attachment)
6651
6753
  skin.setAttachment(slotIndex, name, attachment);
@@ -6712,7 +6814,7 @@ var spine = (() => {
6712
6814
  let vertices = this.readVertices(input, vertexCount);
6713
6815
  let hullLength = input.readInt(true);
6714
6816
  let sequence = this.readSequence(input);
6715
- let edges = null;
6817
+ let edges = [];
6716
6818
  let width = 0, height = 0;
6717
6819
  if (nonessential) {
6718
6820
  edges = this.readShortArray(input);
@@ -7214,6 +7316,8 @@ var spine = (() => {
7214
7316
  let slotIndex = input.readInt(true);
7215
7317
  for (let iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
7216
7318
  let attachmentName = input.readStringRef();
7319
+ if (!attachmentName)
7320
+ throw new Error("attachmentName must not be null.");
7217
7321
  let attachment = skin.getAttachment(slotIndex, attachmentName);
7218
7322
  let timelineType = input.readByte();
7219
7323
  let frameCount = input.readInt(true);
@@ -7388,7 +7492,7 @@ var spine = (() => {
7388
7492
  let chars = "";
7389
7493
  let charCount = 0;
7390
7494
  for (let i = 0; i < byteCount; ) {
7391
- let b = this.readByte();
7495
+ let b = this.readUnsignedByte();
7392
7496
  switch (b >> 4) {
7393
7497
  case 12:
7394
7498
  case 13:
@@ -7889,6 +7993,8 @@ var spine = (() => {
7889
7993
  this.clippedVertices = new Array();
7890
7994
  this.clippedTriangles = new Array();
7891
7995
  this.scratch = new Array();
7996
+ this.clipAttachment = null;
7997
+ this.clippingPolygons = null;
7892
7998
  }
7893
7999
  clipStart(slot, clip) {
7894
8000
  if (this.clipAttachment)
@@ -7928,7 +8034,7 @@ var spine = (() => {
7928
8034
  let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
7929
8035
  let clippedTriangles = this.clippedTriangles;
7930
8036
  let polygons = this.clippingPolygons;
7931
- let polygonsCount = this.clippingPolygons.length;
8037
+ let polygonsCount = polygons.length;
7932
8038
  let vertexSize = twoColor ? 12 : 8;
7933
8039
  let index = 0;
7934
8040
  clippedVertices.length = 0;
@@ -8060,7 +8166,7 @@ var spine = (() => {
8060
8166
  clip(x1, y1, x2, y2, x3, y3, clippingArea, output) {
8061
8167
  let originalOutput = output;
8062
8168
  let clipped = false;
8063
- let input = null;
8169
+ let input;
8064
8170
  if (clippingArea.length % 4 >= 2) {
8065
8171
  input = output;
8066
8172
  output = this.scratch;
@@ -8168,7 +8274,6 @@ var spine = (() => {
8168
8274
  // spine-core/src/SkeletonJson.ts
8169
8275
  var SkeletonJson = class {
8170
8276
  constructor(attachmentLoader) {
8171
- this.attachmentLoader = null;
8172
8277
  this.scale = 1;
8173
8278
  this.linkedMeshes = new Array();
8174
8279
  this.attachmentLoader = attachmentLoader;
@@ -8216,6 +8321,8 @@ var spine = (() => {
8216
8321
  for (let i = 0; i < root.slots.length; i++) {
8217
8322
  let slotMap = root.slots[i];
8218
8323
  let boneData = skeletonData.findBone(slotMap.bone);
8324
+ if (!boneData)
8325
+ throw new Error(`Couldn't find bone ${slotMap.bone} for slot ${slotMap.name}`);
8219
8326
  let data = new SlotData(skeletonData.slots.length, slotMap.name, boneData);
8220
8327
  let color = getValue(slotMap, "color", null);
8221
8328
  if (color)
@@ -8234,9 +8341,17 @@ var spine = (() => {
8234
8341
  let data = new IkConstraintData(constraintMap.name);
8235
8342
  data.order = getValue(constraintMap, "order", 0);
8236
8343
  data.skinRequired = getValue(constraintMap, "skin", false);
8237
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8238
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8239
- 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;
8240
8355
  data.mix = getValue(constraintMap, "mix", 1);
8241
8356
  data.softness = getValue(constraintMap, "softness", 0) * scale;
8242
8357
  data.bendDirection = getValue(constraintMap, "bendPositive", true) ? 1 : -1;
@@ -8252,10 +8367,18 @@ var spine = (() => {
8252
8367
  let data = new TransformConstraintData(constraintMap.name);
8253
8368
  data.order = getValue(constraintMap, "order", 0);
8254
8369
  data.skinRequired = getValue(constraintMap, "skin", false);
8255
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8256
- 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
+ }
8257
8377
  let targetName = constraintMap.target;
8258
- 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;
8259
8382
  data.local = getValue(constraintMap, "local", false);
8260
8383
  data.relative = getValue(constraintMap, "relative", false);
8261
8384
  data.offsetRotation = getValue(constraintMap, "rotation", 0);
@@ -8279,10 +8402,18 @@ var spine = (() => {
8279
8402
  let data = new PathConstraintData(constraintMap.name);
8280
8403
  data.order = getValue(constraintMap, "order", 0);
8281
8404
  data.skinRequired = getValue(constraintMap, "skin", false);
8282
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8283
- 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
+ }
8284
8412
  let targetName = constraintMap.target;
8285
- 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;
8286
8417
  data.positionMode = Utils.enumValue(PositionMode, getValue(constraintMap, "positionMode", "Percent"));
8287
8418
  data.spacingMode = Utils.enumValue(SpacingMode, getValue(constraintMap, "spacingMode", "Length"));
8288
8419
  data.rotateMode = Utils.enumValue(RotateMode, getValue(constraintMap, "rotateMode", "Tangent"));
@@ -8304,23 +8435,45 @@ var spine = (() => {
8304
8435
  let skinMap = root.skins[i];
8305
8436
  let skin = new Skin(skinMap.name);
8306
8437
  if (skinMap.bones) {
8307
- for (let ii = 0; ii < skinMap.bones.length; ii++)
8308
- 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
+ }
8309
8445
  }
8310
8446
  if (skinMap.ik) {
8311
- for (let ii = 0; ii < skinMap.ik.length; ii++)
8312
- 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
+ }
8313
8454
  }
8314
8455
  if (skinMap.transform) {
8315
- for (let ii = 0; ii < skinMap.transform.length; ii++)
8316
- 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
+ }
8317
8463
  }
8318
8464
  if (skinMap.path) {
8319
- for (let ii = 0; ii < skinMap.path.length; ii++)
8320
- 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
+ }
8321
8472
  }
8322
8473
  for (let slotName in skinMap.attachments) {
8323
8474
  let slot = skeletonData.findSlot(slotName);
8475
+ if (!slot)
8476
+ throw new Error(`Couldn't find slot ${slotName} for skin ${skinMap.name}.`);
8324
8477
  let slotMap = skinMap.attachments[slotName];
8325
8478
  for (let entryName in slotMap) {
8326
8479
  let attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
@@ -8336,7 +8489,11 @@ var spine = (() => {
8336
8489
  for (let i = 0, n = this.linkedMeshes.length; i < n; i++) {
8337
8490
  let linkedMesh = this.linkedMeshes[i];
8338
8491
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
8492
+ if (!skin)
8493
+ throw new Error(`Skin not found: ${linkedMesh.skin}`);
8339
8494
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
8495
+ if (!parent)
8496
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
8340
8497
  linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
8341
8498
  linkedMesh.mesh.setParentMesh(parent);
8342
8499
  if (linkedMesh.mesh.region != null)
@@ -8520,7 +8677,10 @@ var spine = (() => {
8520
8677
  if (map.slots) {
8521
8678
  for (let slotName in map.slots) {
8522
8679
  let slotMap = map.slots[slotName];
8523
- 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;
8524
8684
  for (let timelineName in slotMap) {
8525
8685
  let timelineMap = slotMap[timelineName];
8526
8686
  if (!timelineMap)
@@ -8656,7 +8816,10 @@ var spine = (() => {
8656
8816
  if (map.bones) {
8657
8817
  for (let boneName in map.bones) {
8658
8818
  let boneMap = map.bones[boneName];
8659
- 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;
8660
8823
  for (let timelineName in boneMap) {
8661
8824
  let timelineMap = boneMap[timelineName];
8662
8825
  let frames = timelineMap.length;
@@ -8702,6 +8865,8 @@ var spine = (() => {
8702
8865
  if (!keyMap)
8703
8866
  continue;
8704
8867
  let constraint = skeletonData.findIkConstraint(constraintName);
8868
+ if (!constraint)
8869
+ throw new Error("IK Constraint not found: " + constraintName);
8705
8870
  let constraintIndex = skeletonData.ikConstraints.indexOf(constraint);
8706
8871
  let timeline = new IkConstraintTimeline(constraintMap.length, constraintMap.length << 1, constraintIndex);
8707
8872
  let time = getValue(keyMap, "time", 0);
@@ -8737,6 +8902,8 @@ var spine = (() => {
8737
8902
  if (!keyMap)
8738
8903
  continue;
8739
8904
  let constraint = skeletonData.findTransformConstraint(constraintName);
8905
+ if (!constraint)
8906
+ throw new Error("Transform constraint not found: " + constraintName);
8740
8907
  let constraintIndex = skeletonData.transformConstraints.indexOf(constraint);
8741
8908
  let timeline = new TransformConstraintTimeline(timelineMap.length, timelineMap.length * 6, constraintIndex);
8742
8909
  let time = getValue(keyMap, "time", 0);
@@ -8785,6 +8952,8 @@ var spine = (() => {
8785
8952
  for (let constraintName in map.path) {
8786
8953
  let constraintMap = map.path[constraintName];
8787
8954
  let constraint = skeletonData.findPathConstraint(constraintName);
8955
+ if (!constraint)
8956
+ throw new Error("Path constraint not found: " + constraintName);
8788
8957
  let constraintIndex = skeletonData.pathConstraints.indexOf(constraint);
8789
8958
  for (let timelineName in constraintMap) {
8790
8959
  let timelineMap = constraintMap[timelineName];
@@ -8836,9 +9005,14 @@ var spine = (() => {
8836
9005
  for (let attachmentsName in map.attachments) {
8837
9006
  let attachmentsMap = map.attachments[attachmentsName];
8838
9007
  let skin = skeletonData.findSkin(attachmentsName);
9008
+ if (!skin)
9009
+ throw new Error("Skin not found: " + attachmentsName);
8839
9010
  for (let slotMapName in attachmentsMap) {
8840
9011
  let slotMap = attachmentsMap[slotMapName];
8841
- 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;
8842
9016
  for (let attachmentMapName in slotMap) {
8843
9017
  let attachmentMap = slotMap[attachmentMapName];
8844
9018
  let attachment = skin.getAttachment(slotIndex, attachmentMapName);
@@ -8918,7 +9092,10 @@ var spine = (() => {
8918
9092
  let originalIndex = 0, unchangedIndex = 0;
8919
9093
  for (let ii = 0; ii < offsets.length; ii++) {
8920
9094
  let offsetMap = offsets[ii];
8921
- 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;
8922
9099
  while (originalIndex != slotIndex)
8923
9100
  unchanged[unchangedIndex++] = originalIndex++;
8924
9101
  drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
@@ -8939,6 +9116,8 @@ var spine = (() => {
8939
9116
  for (let i = 0; i < map.events.length; i++, frame++) {
8940
9117
  let eventMap = map.events[i];
8941
9118
  let eventData = skeletonData.findEvent(eventMap.name);
9119
+ if (!eventData)
9120
+ throw new Error("Event not found: " + eventMap.name);
8942
9121
  let event = new Event(Utils.toSinglePrecision(getValue(eventMap, "time", 0)), eventData);
8943
9122
  event.intValue = getValue(eventMap, "int", eventData.intValue);
8944
9123
  event.floatValue = getValue(eventMap, "float", eventData.floatValue);
@@ -9098,26 +9277,24 @@ var spine = (() => {
9098
9277
  var ManagedWebGLRenderingContext = class {
9099
9278
  constructor(canvasOrContext, contextConfig = { alpha: "true" }) {
9100
9279
  this.restorables = new Array();
9101
- if (!(canvasOrContext instanceof WebGLRenderingContext || typeof WebGL2RenderingContext !== "undefined" && canvasOrContext instanceof WebGL2RenderingContext))
9102
- this.setupCanvas(canvasOrContext, contextConfig);
9103
- else {
9280
+ if (!(canvasOrContext instanceof WebGLRenderingContext || typeof WebGL2RenderingContext !== "undefined" && canvasOrContext instanceof WebGL2RenderingContext)) {
9281
+ let canvas = canvasOrContext;
9282
+ this.gl = canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig);
9283
+ this.canvas = canvas;
9284
+ canvas.addEventListener("webglcontextlost", (e) => {
9285
+ let event = e;
9286
+ if (e)
9287
+ e.preventDefault();
9288
+ });
9289
+ canvas.addEventListener("webglcontextrestored", (e) => {
9290
+ for (let i = 0, n = this.restorables.length; i < n; i++)
9291
+ this.restorables[i].restore();
9292
+ });
9293
+ } else {
9104
9294
  this.gl = canvasOrContext;
9105
9295
  this.canvas = this.gl.canvas;
9106
9296
  }
9107
9297
  }
9108
- setupCanvas(canvas, contextConfig) {
9109
- this.gl = canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig);
9110
- this.canvas = canvas;
9111
- canvas.addEventListener("webglcontextlost", (e) => {
9112
- let event = e;
9113
- if (e)
9114
- e.preventDefault();
9115
- });
9116
- canvas.addEventListener("webglcontextrestored", (e) => {
9117
- for (let i = 0, n = this.restorables.length; i < n; i++)
9118
- this.restorables[i].restore();
9119
- });
9120
- }
9121
9298
  addRestorable(restorable) {
9122
9299
  this.restorables.push(restorable);
9123
9300
  }
@@ -9254,7 +9431,7 @@ var spine = (() => {
9254
9431
 
9255
9432
  // spine-webgl/src/AssetManager.ts
9256
9433
  var AssetManager = class extends AssetManagerBase {
9257
- constructor(context, pathPrefix = "", downloader = null) {
9434
+ constructor(context, pathPrefix = "", downloader = new Downloader()) {
9258
9435
  super((image) => {
9259
9436
  return new GLTexture(context, image);
9260
9437
  }, pathPrefix, downloader);
@@ -9563,7 +9740,6 @@ var spine = (() => {
9563
9740
  return this.set(this.temp);
9564
9741
  }
9565
9742
  lookAt(position, direction, up) {
9566
- _Matrix4.initTemps();
9567
9743
  let xAxis = _Matrix4.xAxis, yAxis = _Matrix4.yAxis, zAxis = _Matrix4.zAxis;
9568
9744
  zAxis.setFrom(direction).normalize();
9569
9745
  xAxis.setFrom(direction).normalize();
@@ -9587,19 +9763,11 @@ var spine = (() => {
9587
9763
  this.multiply(_Matrix4.tmpMatrix);
9588
9764
  return this;
9589
9765
  }
9590
- static initTemps() {
9591
- if (_Matrix4.xAxis === null)
9592
- _Matrix4.xAxis = new Vector3();
9593
- if (_Matrix4.yAxis === null)
9594
- _Matrix4.yAxis = new Vector3();
9595
- if (_Matrix4.zAxis === null)
9596
- _Matrix4.zAxis = new Vector3();
9597
- }
9598
9766
  };
9599
9767
  var Matrix42 = _Matrix4;
9600
- Matrix42.xAxis = null;
9601
- Matrix42.yAxis = null;
9602
- Matrix42.zAxis = null;
9768
+ Matrix42.xAxis = new Vector3();
9769
+ Matrix42.yAxis = new Vector3();
9770
+ Matrix42.zAxis = new Vector3();
9603
9771
  Matrix42.tmpMatrix = new _Matrix4();
9604
9772
 
9605
9773
  // spine-webgl/src/Camera.ts
@@ -9736,6 +9904,8 @@ var spine = (() => {
9736
9904
  if (!this.touch0 || !this.touch1) {
9737
9905
  var touches = ev.changedTouches;
9738
9906
  let nativeTouch = touches.item(0);
9907
+ if (!nativeTouch)
9908
+ return;
9739
9909
  let rect = element.getBoundingClientRect();
9740
9910
  let x = nativeTouch.clientX - rect.left;
9741
9911
  let y = nativeTouch.clientY - rect.top;
@@ -9956,7 +10126,11 @@ var spine = (() => {
9956
10126
  let gl = this.context.gl;
9957
10127
  try {
9958
10128
  this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);
10129
+ if (!this.vs)
10130
+ throw new Error("Couldn't compile vertex shader.");
9959
10131
  this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);
10132
+ if (!this.fs)
10133
+ throw new Error("Couldn#t compile fragment shader.");
9960
10134
  this.program = this.compileProgram(this.vs, this.fs);
9961
10135
  } catch (e) {
9962
10136
  this.dispose();
@@ -9966,6 +10140,8 @@ var spine = (() => {
9966
10140
  compileShader(type, source) {
9967
10141
  let gl = this.context.gl;
9968
10142
  let shader = gl.createShader(type);
10143
+ if (!shader)
10144
+ throw new Error("Couldn't create shader.");
9969
10145
  gl.shaderSource(shader, source);
9970
10146
  gl.compileShader(shader);
9971
10147
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
@@ -9979,6 +10155,8 @@ var spine = (() => {
9979
10155
  compileProgram(vs, fs) {
9980
10156
  let gl = this.context.gl;
9981
10157
  let program = gl.createProgram();
10158
+ if (!program)
10159
+ throw new Error("Couldn't compile program.");
9982
10160
  gl.attachShader(program, vs);
9983
10161
  gl.attachShader(program, fs);
9984
10162
  gl.linkProgram(program);
@@ -10031,6 +10209,8 @@ var spine = (() => {
10031
10209
  }
10032
10210
  getUniformLocation(uniform) {
10033
10211
  let gl = this.context.gl;
10212
+ if (!this.program)
10213
+ throw new Error("Shader not compiled.");
10034
10214
  let location = gl.getUniformLocation(this.program, uniform);
10035
10215
  if (!location && !gl.isContextLost())
10036
10216
  throw new Error(`Couldn't find location for uniform ${uniform}`);
@@ -10038,6 +10218,8 @@ var spine = (() => {
10038
10218
  }
10039
10219
  getAttributeLocation(attribute) {
10040
10220
  let gl = this.context.gl;
10221
+ if (!this.program)
10222
+ throw new Error("Shader not compiled.");
10041
10223
  let location = gl.getAttribLocation(this.program, attribute);
10042
10224
  if (location == -1 && !gl.isContextLost())
10043
10225
  throw new Error(`Couldn't find location for attribute ${attribute}`);
@@ -10169,8 +10351,10 @@ var spine = (() => {
10169
10351
  var Mesh = class {
10170
10352
  constructor(context, attributes, maxVertices, maxIndices) {
10171
10353
  this.attributes = attributes;
10354
+ this.verticesBuffer = null;
10172
10355
  this.verticesLength = 0;
10173
10356
  this.dirtyVertices = false;
10357
+ this.indicesBuffer = null;
10174
10358
  this.indicesLength = 0;
10175
10359
  this.dirtyIndices = false;
10176
10360
  this.elementsPerVertex = 0;
@@ -10345,11 +10529,13 @@ var spine = (() => {
10345
10529
  // spine-webgl/src/PolygonBatcher.ts
10346
10530
  var PolygonBatcher = class {
10347
10531
  constructor(context, twoColorTint = true, maxVertices = 10920) {
10532
+ this.drawCalls = 0;
10348
10533
  this.isDrawing = false;
10349
10534
  this.shader = null;
10350
10535
  this.lastTexture = null;
10351
10536
  this.verticesLength = 0;
10352
10537
  this.indicesLength = 0;
10538
+ this.cullWasEnabled = false;
10353
10539
  if (maxVertices > 10920)
10354
10540
  throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
10355
10541
  this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context);
@@ -10370,6 +10556,9 @@ var spine = (() => {
10370
10556
  let gl = this.context.gl;
10371
10557
  gl.enable(gl.BLEND);
10372
10558
  gl.blendFuncSeparate(this.srcColorBlend, this.dstBlend, this.srcAlphaBlend, this.dstBlend);
10559
+ this.cullWasEnabled = gl.isEnabled(gl.CULL_FACE);
10560
+ if (this.cullWasEnabled)
10561
+ gl.disable(gl.CULL_FACE);
10373
10562
  }
10374
10563
  setBlendMode(srcColorBlend, srcAlphaBlend, dstBlend) {
10375
10564
  if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend)
@@ -10403,6 +10592,10 @@ var spine = (() => {
10403
10592
  flush() {
10404
10593
  if (this.verticesLength == 0)
10405
10594
  return;
10595
+ if (!this.lastTexture)
10596
+ throw new Error("No texture set.");
10597
+ if (!this.shader)
10598
+ throw new Error("No shader set.");
10406
10599
  this.lastTexture.bind();
10407
10600
  this.mesh.draw(this.shader, this.context.gl.TRIANGLES);
10408
10601
  this.verticesLength = 0;
@@ -10421,6 +10614,8 @@ var spine = (() => {
10421
10614
  this.isDrawing = false;
10422
10615
  let gl = this.context.gl;
10423
10616
  gl.disable(gl.BLEND);
10617
+ if (this.cullWasEnabled)
10618
+ gl.enable(gl.CULL_FACE);
10424
10619
  }
10425
10620
  getDrawCalls() {
10426
10621
  return this.drawCalls;
@@ -10436,6 +10631,7 @@ var spine = (() => {
10436
10631
  this.isDrawing = false;
10437
10632
  this.shapeType = ShapeType.Filled;
10438
10633
  this.color = new Color(1, 1, 1, 1);
10634
+ this.shader = null;
10439
10635
  this.vertexIndex = 0;
10440
10636
  this.tmp = new Vector2();
10441
10637
  if (maxVertices > 10920)
@@ -10473,30 +10669,30 @@ var spine = (() => {
10473
10669
  setColorWith(r, g, b, a) {
10474
10670
  this.color.set(r, g, b, a);
10475
10671
  }
10476
- point(x, y, color = null) {
10672
+ point(x, y, color) {
10477
10673
  this.check(ShapeType.Point, 1);
10478
- if (color === null)
10674
+ if (!color)
10479
10675
  color = this.color;
10480
10676
  this.vertex(x, y, color);
10481
10677
  }
10482
- line(x, y, x2, y2, color = null) {
10678
+ line(x, y, x2, y2, color) {
10483
10679
  this.check(ShapeType.Line, 2);
10484
10680
  let vertices = this.mesh.getVertices();
10485
10681
  let idx = this.vertexIndex;
10486
- if (color === null)
10682
+ if (!color)
10487
10683
  color = this.color;
10488
10684
  this.vertex(x, y, color);
10489
10685
  this.vertex(x2, y2, color);
10490
10686
  }
10491
- triangle(filled, x, y, x2, y2, x3, y3, color = null, color2 = null, color3 = null) {
10687
+ triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3) {
10492
10688
  this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
10493
10689
  let vertices = this.mesh.getVertices();
10494
10690
  let idx = this.vertexIndex;
10495
- if (color === null)
10691
+ if (!color)
10496
10692
  color = this.color;
10497
- if (color2 === null)
10693
+ if (!color2)
10498
10694
  color2 = this.color;
10499
- if (color3 === null)
10695
+ if (!color3)
10500
10696
  color3 = this.color;
10501
10697
  if (filled) {
10502
10698
  this.vertex(x, y, color);
@@ -10511,17 +10707,17 @@ var spine = (() => {
10511
10707
  this.vertex(x, y, color2);
10512
10708
  }
10513
10709
  }
10514
- quad(filled, x, y, x2, y2, x3, y3, x4, y4, color = null, color2 = null, color3 = null, color4 = null) {
10710
+ quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
10515
10711
  this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
10516
10712
  let vertices = this.mesh.getVertices();
10517
10713
  let idx = this.vertexIndex;
10518
- if (color === null)
10714
+ if (!color)
10519
10715
  color = this.color;
10520
- if (color2 === null)
10716
+ if (!color2)
10521
10717
  color2 = this.color;
10522
- if (color3 === null)
10718
+ if (!color3)
10523
10719
  color3 = this.color;
10524
- if (color4 === null)
10720
+ if (!color4)
10525
10721
  color4 = this.color;
10526
10722
  if (filled) {
10527
10723
  this.vertex(x, y, color);
@@ -10541,12 +10737,12 @@ var spine = (() => {
10541
10737
  this.vertex(x, y, color);
10542
10738
  }
10543
10739
  }
10544
- rect(filled, x, y, width, height, color = null) {
10740
+ rect(filled, x, y, width, height, color) {
10545
10741
  this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);
10546
10742
  }
10547
- rectLine(filled, x1, y1, x2, y2, width, color = null) {
10743
+ rectLine(filled, x1, y1, x2, y2, width, color) {
10548
10744
  this.check(filled ? ShapeType.Filled : ShapeType.Line, 8);
10549
- if (color === null)
10745
+ if (!color)
10550
10746
  color = this.color;
10551
10747
  let t = this.tmp.set(y2 - y1, x1 - x2);
10552
10748
  t.normalize();
@@ -10575,11 +10771,11 @@ var spine = (() => {
10575
10771
  this.line(x - size, y - size, x + size, y + size);
10576
10772
  this.line(x - size, y + size, x + size, y - size);
10577
10773
  }
10578
- polygon(polygonVertices, offset, count, color = null) {
10774
+ polygon(polygonVertices, offset, count, color) {
10579
10775
  if (count < 3)
10580
10776
  throw new Error("Polygon must contain at least 3 vertices");
10581
10777
  this.check(ShapeType.Line, count * 2);
10582
- if (color === null)
10778
+ if (color)
10583
10779
  color = this.color;
10584
10780
  let vertices = this.mesh.getVertices();
10585
10781
  let idx = this.vertexIndex;
@@ -10604,12 +10800,12 @@ var spine = (() => {
10604
10800
  this.vertex(x2, y2, color);
10605
10801
  }
10606
10802
  }
10607
- circle(filled, x, y, radius, color = null, segments = 0) {
10608
- if (segments === 0)
10803
+ circle(filled, x, y, radius, color, segments = 0) {
10804
+ if (segments == 0)
10609
10805
  segments = Math.max(1, 6 * MathUtils.cbrt(radius) | 0);
10610
10806
  if (segments <= 0)
10611
10807
  throw new Error("segments must be > 0.");
10612
- if (color === null)
10808
+ if (!color)
10613
10809
  color = this.color;
10614
10810
  let angle = 2 * MathUtils.PI / segments;
10615
10811
  let cos = Math.cos(angle);
@@ -10644,9 +10840,9 @@ var spine = (() => {
10644
10840
  cy = 0;
10645
10841
  this.vertex(x + cx, y + cy, color);
10646
10842
  }
10647
- curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color = null) {
10843
+ curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
10648
10844
  this.check(ShapeType.Line, segments * 2 + 2);
10649
- if (color === null)
10845
+ if (color)
10650
10846
  color = this.color;
10651
10847
  let subdiv_step = 1 / segments;
10652
10848
  let subdiv_step2 = subdiv_step * subdiv_step;
@@ -10702,6 +10898,8 @@ var spine = (() => {
10702
10898
  flush() {
10703
10899
  if (this.vertexIndex == 0)
10704
10900
  return;
10901
+ if (!this.shader)
10902
+ throw new Error("No shader set.");
10705
10903
  this.mesh.setVerticesLength(this.vertexIndex);
10706
10904
  this.mesh.draw(this.shader, this.shapeType);
10707
10905
  this.vertexIndex = 0;
@@ -10756,7 +10954,7 @@ var spine = (() => {
10756
10954
  this.vertices = Utils.newFloatArray(2 * 1024);
10757
10955
  this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context);
10758
10956
  }
10759
- draw(shapes, skeleton, ignoredBones = null) {
10957
+ draw(shapes, skeleton, ignoredBones) {
10760
10958
  let skeletonX = skeleton.x;
10761
10959
  let skeletonY = skeleton.y;
10762
10960
  let gl = this.context.gl;
@@ -10938,7 +11136,7 @@ var spine = (() => {
10938
11136
  this.tempColor2 = new Color();
10939
11137
  this.vertexSize = 2 + 2 + 4;
10940
11138
  this.twoColorTint = false;
10941
- this.renderable = new Renderable(null, 0, 0);
11139
+ this.renderable = new Renderable([], 0, 0);
10942
11140
  this.clipper = new SkeletonClipping();
10943
11141
  this.temp = new Vector2();
10944
11142
  this.temp2 = new Vector2();
@@ -10959,10 +11157,10 @@ var spine = (() => {
10959
11157
  let tempLight = this.temp3;
10960
11158
  let tempDark = this.temp4;
10961
11159
  let renderable = this.renderable;
10962
- let uvs = null;
10963
- let triangles = null;
11160
+ let uvs;
11161
+ let triangles;
10964
11162
  let drawOrder = skeleton.drawOrder;
10965
- let attachmentColor = null;
11163
+ let attachmentColor;
10966
11164
  let skeletonColor = skeleton.color;
10967
11165
  let vertexSize = twoColorTint ? 12 : 8;
10968
11166
  let inRange = false;
@@ -10986,7 +11184,7 @@ var spine = (() => {
10986
11184
  inRange = false;
10987
11185
  }
10988
11186
  let attachment = slot.getAttachment();
10989
- let texture = null;
11187
+ let texture;
10990
11188
  if (attachment instanceof RegionAttachment) {
10991
11189
  let region = attachment;
10992
11190
  renderable.vertices = this.vertices;
@@ -11220,6 +11418,7 @@ var spine = (() => {
11220
11418
  var SceneRenderer = class {
11221
11419
  constructor(canvas, context, twoColorTint = true) {
11222
11420
  this.twoColorTint = false;
11421
+ this.activeRenderer = null;
11223
11422
  this.canvas = canvas;
11224
11423
  this.context = context instanceof ManagedWebGLRenderingContext ? context : new ManagedWebGLRenderingContext(context);
11225
11424
  this.twoColorTint = twoColorTint;
@@ -11247,14 +11446,14 @@ var spine = (() => {
11247
11446
  this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
11248
11447
  this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);
11249
11448
  }
11250
- drawSkeletonDebug(skeleton, premultipliedAlpha = false, ignoredBones = null) {
11449
+ drawSkeletonDebug(skeleton, premultipliedAlpha = false, ignoredBones) {
11251
11450
  this.enableRenderer(this.shapes);
11252
11451
  this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;
11253
11452
  this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);
11254
11453
  }
11255
- drawTexture(texture, x, y, width, height, color = null) {
11454
+ drawTexture(texture, x, y, width, height, color) {
11256
11455
  this.enableRenderer(this.batcher);
11257
- if (color === null)
11456
+ if (!color)
11258
11457
  color = WHITE;
11259
11458
  var i = 0;
11260
11459
  quad[i++] = x;
@@ -11315,9 +11514,9 @@ var spine = (() => {
11315
11514
  }
11316
11515
  this.batcher.draw(texture, quad, QUAD_TRIANGLES);
11317
11516
  }
11318
- drawTextureUV(texture, x, y, width, height, u, v, u2, v2, color = null) {
11517
+ drawTextureUV(texture, x, y, width, height, u, v, u2, v2, color) {
11319
11518
  this.enableRenderer(this.batcher);
11320
- if (color === null)
11519
+ if (!color)
11321
11520
  color = WHITE;
11322
11521
  var i = 0;
11323
11522
  quad[i++] = x;
@@ -11378,9 +11577,9 @@ var spine = (() => {
11378
11577
  }
11379
11578
  this.batcher.draw(texture, quad, QUAD_TRIANGLES);
11380
11579
  }
11381
- drawTextureRotated(texture, x, y, width, height, pivotX, pivotY, angle, color = null) {
11580
+ drawTextureRotated(texture, x, y, width, height, pivotX, pivotY, angle, color) {
11382
11581
  this.enableRenderer(this.batcher);
11383
- if (color === null)
11582
+ if (!color)
11384
11583
  color = WHITE;
11385
11584
  let worldOriginX = x + pivotX;
11386
11585
  let worldOriginY = y + pivotY;
@@ -11492,9 +11691,9 @@ var spine = (() => {
11492
11691
  }
11493
11692
  this.batcher.draw(texture, quad, QUAD_TRIANGLES);
11494
11693
  }
11495
- drawRegion(region, x, y, width, height, color = null) {
11694
+ drawRegion(region, x, y, width, height, color) {
11496
11695
  this.enableRenderer(this.batcher);
11497
- if (color === null)
11696
+ if (!color)
11498
11697
  color = WHITE;
11499
11698
  var i = 0;
11500
11699
  quad[i++] = x;
@@ -11555,35 +11754,35 @@ var spine = (() => {
11555
11754
  }
11556
11755
  this.batcher.draw(region.page.texture, quad, QUAD_TRIANGLES);
11557
11756
  }
11558
- line(x, y, x2, y2, color = null, color2 = null) {
11757
+ line(x, y, x2, y2, color, color2) {
11559
11758
  this.enableRenderer(this.shapes);
11560
11759
  this.shapes.line(x, y, x2, y2, color);
11561
11760
  }
11562
- triangle(filled, x, y, x2, y2, x3, y3, color = null, color2 = null, color3 = null) {
11761
+ triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3) {
11563
11762
  this.enableRenderer(this.shapes);
11564
11763
  this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);
11565
11764
  }
11566
- quad(filled, x, y, x2, y2, x3, y3, x4, y4, color = null, color2 = null, color3 = null, color4 = null) {
11765
+ quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
11567
11766
  this.enableRenderer(this.shapes);
11568
11767
  this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);
11569
11768
  }
11570
- rect(filled, x, y, width, height, color = null) {
11769
+ rect(filled, x, y, width, height, color) {
11571
11770
  this.enableRenderer(this.shapes);
11572
11771
  this.shapes.rect(filled, x, y, width, height, color);
11573
11772
  }
11574
- rectLine(filled, x1, y1, x2, y2, width, color = null) {
11773
+ rectLine(filled, x1, y1, x2, y2, width, color) {
11575
11774
  this.enableRenderer(this.shapes);
11576
11775
  this.shapes.rectLine(filled, x1, y1, x2, y2, width, color);
11577
11776
  }
11578
- polygon(polygonVertices, offset, count, color = null) {
11777
+ polygon(polygonVertices, offset, count, color) {
11579
11778
  this.enableRenderer(this.shapes);
11580
11779
  this.shapes.polygon(polygonVertices, offset, count, color);
11581
11780
  }
11582
- circle(filled, x, y, radius, color = null, segments = 0) {
11781
+ circle(filled, x, y, radius, color, segments = 0) {
11583
11782
  this.enableRenderer(this.shapes);
11584
11783
  this.shapes.circle(filled, x, y, radius, color, segments);
11585
11784
  }
11586
- curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color = null) {
11785
+ curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
11587
11786
  this.enableRenderer(this.shapes);
11588
11787
  this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);
11589
11788
  }
@@ -11679,8 +11878,9 @@ var spine = (() => {
11679
11878
  }
11680
11879
  }
11681
11880
  dispose() {
11682
- this.logo.dispose();
11683
- this.spinner.dispose();
11881
+ var _a, _b;
11882
+ (_a = this.logo) == null ? void 0 : _a.dispose();
11883
+ (_b = this.spinner) == null ? void 0 : _b.dispose();
11684
11884
  }
11685
11885
  draw(complete = false) {
11686
11886
  if (loaded < 2 || complete && this.fadeOut > FADE_OUT)
@@ -11726,7 +11926,8 @@ var spine = (() => {
11726
11926
  renderer.camera.zoom = Math.max(1, spinnerSize / canvas.height);
11727
11927
  renderer.begin();
11728
11928
  renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, tempColor);
11729
- renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerSize) / 2, (canvas.height - spinnerSize) / 2, spinnerSize, spinnerSize, spinnerSize / 2, spinnerSize / 2, this.angle, tempColor);
11929
+ if (this.spinner)
11930
+ renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerSize) / 2, (canvas.height - spinnerSize) / 2, spinnerSize, spinnerSize, spinnerSize / 2, spinnerSize / 2, this.angle, tempColor);
11730
11931
  renderer.end();
11731
11932
  }
11732
11933
  };
@@ -11737,9 +11938,9 @@ var spine = (() => {
11737
11938
  var SpineCanvas = class {
11738
11939
  constructor(canvas, config) {
11739
11940
  this.time = new TimeKeeper();
11740
- if (config.pathPrefix === void 0)
11941
+ if (!config.pathPrefix)
11741
11942
  config.pathPrefix = "";
11742
- if (config.app === void 0)
11943
+ if (!config.app)
11743
11944
  config.app = {
11744
11945
  loadAssets: () => {
11745
11946
  },
@@ -11752,7 +11953,7 @@ var spine = (() => {
11752
11953
  error: () => {
11753
11954
  }
11754
11955
  };
11755
- if (config.webglConfig === void 0)
11956
+ if (config.webglConfig)
11756
11957
  config.webglConfig = { alpha: true };
11757
11958
  this.htmlCanvas = canvas;
11758
11959
  this.context = new ManagedWebGLRenderingContext(canvas, config.webglConfig);
@@ -11760,19 +11961,24 @@ var spine = (() => {
11760
11961
  this.gl = this.context.gl;
11761
11962
  this.assetManager = new AssetManager(this.context, config.pathPrefix);
11762
11963
  this.input = new Input(canvas);
11763
- config.app.loadAssets(this);
11964
+ if (config.app.loadAssets)
11965
+ config.app.loadAssets(this);
11764
11966
  let loop = () => {
11765
11967
  requestAnimationFrame(loop);
11766
11968
  this.time.update();
11767
- config.app.update(this, this.time.delta);
11768
- config.app.render(this);
11969
+ if (config.app.update)
11970
+ config.app.update(this, this.time.delta);
11971
+ if (config.app.render)
11972
+ config.app.render(this);
11769
11973
  };
11770
11974
  let waitForAssets = () => {
11771
11975
  if (this.assetManager.isLoadingComplete()) {
11772
11976
  if (this.assetManager.hasErrors()) {
11773
- config.app.error(this, this.assetManager.getErrors());
11977
+ if (config.app.error)
11978
+ config.app.error(this, this.assetManager.getErrors());
11774
11979
  } else {
11775
- config.app.initialize(this);
11980
+ if (config.app.initialize)
11981
+ config.app.initialize(this);
11776
11982
  loop();
11777
11983
  }
11778
11984
  return;