@safe-engine/pixi 8.4.3 → 8.4.6

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.
Files changed (55) hide show
  1. package/dist/app.d.ts +2 -2
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/base/EnhancedComponent.d.ts +3 -2
  4. package/dist/base/EnhancedComponent.d.ts.map +1 -1
  5. package/dist/base/EnhancedComponent.js +1 -1
  6. package/dist/components/NodeComp.d.ts +1 -0
  7. package/dist/components/NodeComp.d.ts.map +1 -1
  8. package/dist/components/NodeComp.js +10 -0
  9. package/dist/core/loader.d.ts +2 -1
  10. package/dist/core/loader.d.ts.map +1 -1
  11. package/dist/core/loader.js +2 -3
  12. package/dist/gui/GUIComponent.d.ts +17 -15
  13. package/dist/gui/GUIComponent.d.ts.map +1 -1
  14. package/dist/gui/GUIComponent.js +2 -9
  15. package/dist/gui/GUISystem.d.ts.map +1 -1
  16. package/dist/gui/GUISystem.js +13 -10
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +0 -1
  20. package/dist/norender/Touch.d.ts +2 -20
  21. package/dist/norender/Touch.d.ts.map +1 -1
  22. package/dist/norender/Touch.js +1 -1
  23. package/dist/render/RenderComponent.d.ts +6 -10
  24. package/dist/render/RenderComponent.d.ts.map +1 -1
  25. package/dist/richtext/RichTextComp.d.ts +2 -1
  26. package/dist/richtext/RichTextComp.d.ts.map +1 -1
  27. package/dist/richtext/RichTextComp.js +1 -1
  28. package/dist/spine/SpineComponent.d.ts +5 -3
  29. package/dist/spine/SpineComponent.d.ts.map +1 -1
  30. package/dist/spine/SpineComponent.js +1 -1
  31. package/dist/spine/lib/Spine.d.ts +2 -2
  32. package/dist/spine/lib/Spine.d.ts.map +1 -1
  33. package/dist/spine/lib/Spine.js +19 -20
  34. package/package.json +5 -5
  35. package/src/app.ts +2 -2
  36. package/src/base/EnhancedComponent.ts +4 -3
  37. package/src/components/NodeComp.ts +8 -0
  38. package/src/core/loader.ts +7 -5
  39. package/src/gui/GUIComponent.ts +31 -35
  40. package/src/gui/GUISystem.ts +12 -9
  41. package/src/index.ts +0 -2
  42. package/src/norender/Touch.ts +3 -3
  43. package/src/render/RenderComponent.ts +17 -17
  44. package/src/richtext/RichTextComp.ts +10 -6
  45. package/src/spine/SpineComponent.ts +5 -5
  46. package/src/spine/lib/Spine.ts +313 -329
  47. package/dist/spine/lib/assets/atlasLoader.d.ts +0 -34
  48. package/dist/spine/lib/assets/atlasLoader.d.ts.map +0 -1
  49. package/dist/spine/lib/assets/atlasLoader.js +0 -122
  50. package/dist/spine/lib/assets/skeletonLoader.d.ts +0 -30
  51. package/dist/spine/lib/assets/skeletonLoader.d.ts.map +0 -1
  52. package/dist/spine/lib/assets/skeletonLoader.js +0 -70
  53. package/src/@types/safex.d.ts +0 -15
  54. package/src/spine/lib/assets/atlasLoader.ts +0 -158
  55. package/src/spine/lib/assets/skeletonLoader.ts +0 -81
@@ -49,12 +49,13 @@ import {
49
49
  type TextureAtlas,
50
50
  TrackEntry,
51
51
  Vector2,
52
- } from '@esotericsoftware/spine-core';
52
+ } from '@esotericsoftware/spine-core'
53
53
  import {
54
54
  Assets,
55
55
  Bounds,
56
56
  Cache,
57
57
  Container,
58
+ ContainerChild,
58
59
  ContainerOptions,
59
60
  DEG_TO_RAD,
60
61
  DestroyOptions,
@@ -64,90 +65,90 @@ import {
64
65
  Texture,
65
66
  Ticker,
66
67
  ViewContainer,
67
- } from 'pixi.js';
68
- import { ISpineDebugRenderer } from './SpineDebugRenderer.js';
68
+ } from 'pixi.js'
69
+ import { ISpineDebugRenderer } from './SpineDebugRenderer.js'
69
70
 
70
71
  /**
71
72
  * Options to create a {@link Spine} using {@link Spine.from}.
72
73
  */
73
74
  export interface SpineFromOptions {
74
75
  /** the asset name for the skeleton `.skel` or `.json` file previously loaded into the Assets */
75
- skeleton: string;
76
+ skeleton: string
76
77
 
77
78
  /** the asset name for the atlas file previously loaded into the Assets */
78
- atlas: string;
79
+ atlas: string
79
80
 
80
81
  /** The value passed to the skeleton reader. If omitted, 1 is passed. See {@link SkeletonBinary.scale} for details. */
81
- scale?: number;
82
+ scale?: number
82
83
 
83
84
  /** Set the {@link Spine.autoUpdate} value. If omitted, it is set to `true`. */
84
- autoUpdate?: boolean;
85
+ autoUpdate?: boolean
85
86
 
86
87
  /**
87
88
  * If `true`, use the dark tint renderer to render the skeleton
88
89
  * If `false`, use the default pixi renderer to render the skeleton
89
90
  * If `undefined`, use the dark tint renderer if at least one slot has tint black
90
91
  */
91
- darkTint?: boolean;
92
- };
92
+ darkTint?: boolean
93
+ }
93
94
 
94
- const vectorAux = new Vector2();
95
+ const vectorAux = new Vector2()
95
96
 
96
- Skeleton.yDown = true;
97
+ Skeleton.yDown = true
97
98
 
98
- const clipper = new SkeletonClipping();
99
+ const clipper = new SkeletonClipping()
99
100
 
100
101
  export interface SpineOptions extends ContainerOptions {
101
102
  /** the {@link SkeletonData} used to instantiate the skeleton */
102
- skeletonData: SkeletonData;
103
+ skeletonData: SkeletonData
103
104
 
104
105
  /** See {@link SpineFromOptions.autoUpdate}. */
105
- autoUpdate?: boolean;
106
+ autoUpdate?: boolean
106
107
 
107
108
  /** See {@link SpineFromOptions.darkTint}. */
108
- darkTint?: boolean;
109
+ darkTint?: boolean
109
110
  }
110
111
 
111
112
  /**
112
113
  * AnimationStateListener {@link https://en.esotericsoftware.com/spine-api-reference#AnimationStateListener events} exposed for Pixi.
113
114
  */
114
115
  export interface SpineEvents {
115
- complete: [trackEntry: TrackEntry];
116
- dispose: [trackEntry: TrackEntry];
117
- end: [trackEntry: TrackEntry];
118
- event: [trackEntry: TrackEntry, event: Event];
119
- interrupt: [trackEntry: TrackEntry];
120
- start: [trackEntry: TrackEntry];
116
+ complete: [trackEntry: TrackEntry]
117
+ dispose: [trackEntry: TrackEntry]
118
+ end: [trackEntry: TrackEntry]
119
+ event: [trackEntry: TrackEntry, event: Event]
120
+ interrupt: [trackEntry: TrackEntry]
121
+ start: [trackEntry: TrackEntry]
121
122
  }
122
123
 
123
124
  export interface AttachmentCacheData {
124
- id: string;
125
- clipped: boolean;
126
- vertices: Float32Array;
127
- uvs: Float32Array;
128
- indices: number[];
129
- color: Color;
130
- darkColor: Color;
131
- darkTint: boolean;
132
- skipRender: boolean;
133
- texture: Texture;
125
+ id: string
126
+ clipped: boolean
127
+ vertices: Float32Array
128
+ uvs: Float32Array
129
+ indices: number[]
130
+ color: Color
131
+ darkColor: Color
132
+ darkTint: boolean
133
+ skipRender: boolean
134
+ texture: Texture
134
135
  clippedData?: {
135
- vertices: Float32Array;
136
- uvs: Float32Array;
137
- indices: Uint16Array;
138
- vertexCount: number;
139
- indicesCount: number;
140
- };
136
+ vertices: Float32Array
137
+ uvs: Float32Array
138
+ indices: Uint16Array
139
+ vertexCount: number
140
+ indicesCount: number
141
+ }
141
142
  }
142
143
 
143
144
  interface SlotsToClipping {
144
- slot: Slot,
145
- mask?: Graphics,
146
- maskComputed?: boolean,
147
- vertices: Array<number>,
148
- };
145
+ slot: Slot
146
+ mask?: Graphics
147
+ maskComputed?: boolean
148
+ vertices: Array<number>
149
+ }
149
150
 
150
- const maskPool = new Pool<Graphics>(() => new Graphics);
151
+ const maskPool = new Pool<Graphics>(() => new Graphics())
151
152
 
152
153
  /**
153
154
  * The class to instantiate a {@link Spine} game object in Pixi.
@@ -155,49 +156,53 @@ const maskPool = new Pool<Graphics>(() => new Graphics);
155
156
  */
156
157
  export class Spine extends ViewContainer {
157
158
  // Pixi properties
158
- public batched = true;
159
- public buildId = 0;
160
- public override readonly renderPipeId = 'spine';
161
- public _didSpineUpdate = false;
159
+ public batched = true
160
+ public buildId = 0
161
+ public override readonly renderPipeId = 'spine'
162
+ public _didSpineUpdate = false
162
163
 
163
- public beforeUpdateWorldTransforms: (object: Spine) => void = () => { /** */ };
164
- public afterUpdateWorldTransforms: (object: Spine) => void = () => { /** */ };
164
+ public beforeUpdateWorldTransforms: (object: Spine) => void = () => {
165
+ /** */
166
+ }
167
+ public afterUpdateWorldTransforms: (object: Spine) => void = () => {
168
+ /** */
169
+ }
165
170
 
166
171
  // Spine properties
167
172
  /** The skeleton for this Spine game object. */
168
- public skeleton: Skeleton;
173
+ public skeleton: Skeleton
169
174
  /** The animation state for this Spine game object. */
170
- public state: AnimationState;
171
- public skeletonBounds?: SkeletonBounds;
175
+ public state: AnimationState
176
+ public skeletonBounds?: SkeletonBounds
172
177
 
173
- private darkTint = false;
174
- private _debug?: ISpineDebugRenderer | undefined = undefined;
178
+ private darkTint = false
179
+ private _debug?: ISpineDebugRenderer | undefined = undefined
175
180
 
176
- readonly _slotsObject: Record<string, { slot: Slot, container: Container } | null> = Object.create(null);
177
- private clippingSlotToPixiMasks: Record<string, SlotsToClipping> = Object.create(null);
181
+ readonly _slotsObject: Record<string, { slot: Slot; container: Container } | null> = Object.create(null)
182
+ private clippingSlotToPixiMasks: Record<string, SlotsToClipping> = Object.create(null)
178
183
 
179
184
  private getSlotFromRef(slotRef: number | string | Slot): Slot {
180
- let slot: Slot | null;
185
+ let slot: Slot | null
181
186
 
182
- if (typeof slotRef === 'number') slot = this.skeleton.slots[slotRef];
183
- else if (typeof slotRef === 'string') slot = this.skeleton.findSlot(slotRef);
184
- else slot = slotRef;
187
+ if (typeof slotRef === 'number') slot = this.skeleton.slots[slotRef]
188
+ else if (typeof slotRef === 'string') slot = this.skeleton.findSlot(slotRef)
189
+ else slot = slotRef
185
190
 
186
- if (!slot) throw new Error(`No slot found with the given slot reference: ${slotRef}`);
191
+ if (!slot) throw new Error(`No slot found with the given slot reference: ${slotRef}`)
187
192
 
188
- return slot;
193
+ return slot
189
194
  }
190
195
 
191
- public spineAttachmentsDirty = true;
192
- public spineTexturesDirty = true;
196
+ public spineAttachmentsDirty = true
197
+ public spineTexturesDirty = true
193
198
 
194
- private _lastAttachments: Attachment[] = [];
199
+ private _lastAttachments: Attachment[] = []
195
200
 
196
- private _stateChanged = true;
197
- private attachmentCacheData: Record<string, AttachmentCacheData>[] = [];
201
+ private _stateChanged = true
202
+ private attachmentCacheData: Record<string, AttachmentCacheData>[] = []
198
203
 
199
204
  public get debug(): ISpineDebugRenderer | undefined {
200
- return this._debug;
205
+ return this._debug
201
206
  }
202
207
 
203
208
  /** Pass a {@link SpineDebugRenderer} or create your own {@link ISpineDebugRenderer} to render bones, meshes, ...
@@ -205,75 +210,73 @@ export class Spine extends ViewContainer {
205
210
  */
206
211
  public set debug(value: ISpineDebugRenderer | undefined) {
207
212
  if (this._debug) {
208
- this._debug.unregisterSpine(this);
213
+ this._debug.unregisterSpine(this)
209
214
  }
210
215
  if (value) {
211
- value.registerSpine(this);
216
+ value.registerSpine(this)
212
217
  }
213
- this._debug = value;
218
+ this._debug = value
214
219
  }
215
220
 
216
- private _autoUpdate = true;
221
+ private _autoUpdate = true
217
222
 
218
223
  public get autoUpdate(): boolean {
219
- return this._autoUpdate;
224
+ return this._autoUpdate
220
225
  }
221
226
  /** When `true`, the Spine AnimationState and the Skeleton will be automatically updated using the {@link Ticker.shared} instance. */
222
227
  public set autoUpdate(value: boolean) {
223
228
  if (value) {
224
- Ticker.shared.add(this.internalUpdate, this);
229
+ Ticker.shared.add(this.internalUpdate, this)
225
230
  } else {
226
- Ticker.shared.remove(this.internalUpdate, this);
231
+ Ticker.shared.remove(this.internalUpdate, this)
227
232
  }
228
233
 
229
- this._autoUpdate = value;
234
+ this._autoUpdate = value
230
235
  }
231
236
 
232
- private hasNeverUpdated = true;
237
+ private hasNeverUpdated = true
233
238
  constructor(options: SpineOptions | SkeletonData) {
234
239
  if (options instanceof SkeletonData) {
235
240
  options = {
236
241
  skeletonData: options,
237
- };
242
+ }
238
243
  }
239
244
 
240
- super(options);
245
+ super(options)
241
246
 
242
- const skeletonData = options instanceof SkeletonData ? options : options.skeletonData;
247
+ const skeletonData = options instanceof SkeletonData ? options : options.skeletonData
243
248
 
244
- this.skeleton = new Skeleton(skeletonData);
245
- this.state = new AnimationState(new AnimationStateData(skeletonData));
246
- this.autoUpdate = options?.autoUpdate ?? true;
249
+ this.skeleton = new Skeleton(skeletonData)
250
+ this.state = new AnimationState(new AnimationStateData(skeletonData))
251
+ this.autoUpdate = options?.autoUpdate ?? true
247
252
 
248
253
  // dark tint can be enabled by options, otherwise is enable if at least one slot has tint black
249
- this.darkTint = options?.darkTint === undefined
250
- ? this.skeleton.slots.some(slot => !!slot.data.darkColor)
251
- : options?.darkTint;
254
+ this.darkTint = options?.darkTint === undefined ? this.skeleton.slots.some((slot) => !!slot.data.darkColor) : options?.darkTint
252
255
 
253
- const slots = this.skeleton.slots;
256
+ const slots = this.skeleton.slots
254
257
 
255
258
  for (let i = 0; i < slots.length; i++) {
256
- this.attachmentCacheData[i] = Object.create(null);
259
+ this.attachmentCacheData[i] = Object.create(null)
257
260
  }
258
261
  }
259
262
 
260
263
  /** If {@link Spine.autoUpdate} is `false`, this method allows to update the AnimationState and the Skeleton with the given delta. */
261
264
  public update(dt: number): void {
262
- this.internalUpdate(0, dt);
265
+ this.internalUpdate(0, dt)
263
266
  }
264
267
 
265
268
  protected internalUpdate(_deltaFrame: any, deltaSeconds?: number): void {
266
269
  // Because reasons, pixi uses deltaFrames at 60fps.
267
270
  // We ignore the default deltaFrames and use the deltaSeconds from pixi ticker.
268
- this._updateAndApplyState(deltaSeconds ?? Ticker.shared.deltaMS / 1000);
271
+ this._updateAndApplyState(deltaSeconds ?? Ticker.shared.deltaMS / 1000)
269
272
  }
270
273
 
271
274
  override get bounds() {
272
275
  if (this._boundsDirty) {
273
- this.updateBounds();
276
+ this.updateBounds()
274
277
  }
275
278
 
276
- return this._bounds;
279
+ return this._bounds
277
280
  }
278
281
 
279
282
  /**
@@ -283,24 +286,23 @@ export class Spine extends ViewContainer {
283
286
  * @throws {Error}: if the given bone is not found in the skeleton, an error is thrown
284
287
  */
285
288
  public setBonePosition(bone: string | Bone, position: PointData): void {
286
- const boneAux = bone;
289
+ const boneAux = bone
287
290
 
288
291
  if (typeof bone === 'string') {
289
- bone = this.skeleton.findBone(bone) as Bone;
292
+ bone = this.skeleton.findBone(bone) as Bone
290
293
  }
291
294
 
292
- if (!bone) throw Error(`Cant set bone position, bone ${String(boneAux)} not found`);
293
- vectorAux.set(position.x, position.y);
295
+ if (!bone) throw Error(`Cant set bone position, bone ${String(boneAux)} not found`)
296
+ vectorAux.set(position.x, position.y)
294
297
 
295
298
  if (bone.parent) {
296
- const aux = bone.parent.worldToLocal(vectorAux);
299
+ const aux = bone.parent.worldToLocal(vectorAux)
297
300
 
298
- bone.x = aux.x;
299
- bone.y = -aux.y;
300
- }
301
- else {
302
- bone.x = vectorAux.x;
303
- bone.y = vectorAux.y;
301
+ bone.x = aux.x
302
+ bone.y = -aux.y
303
+ } else {
304
+ bone.x = vectorAux.x
305
+ bone.y = vectorAux.y
304
306
  }
305
307
  }
306
308
 
@@ -311,26 +313,26 @@ export class Spine extends ViewContainer {
311
313
  * @returns {IPointData | undefined}: the position of the bone, or undefined if no matching bone is found in the skeleton
312
314
  */
313
315
  public getBonePosition(bone: string | Bone, outPos?: PointData): PointData | undefined {
314
- const boneAux = bone;
316
+ const boneAux = bone
315
317
 
316
318
  if (typeof bone === 'string') {
317
- bone = this.skeleton.findBone(bone) as Bone;
319
+ bone = this.skeleton.findBone(bone) as Bone
318
320
  }
319
321
 
320
322
  if (!bone) {
321
- console.error(`Cant set bone position! Bone ${String(boneAux)} not found`);
323
+ console.error(`Cant set bone position! Bone ${String(boneAux)} not found`)
322
324
 
323
- return outPos;
325
+ return outPos
324
326
  }
325
327
 
326
328
  if (!outPos) {
327
- outPos = { x: 0, y: 0 };
329
+ outPos = { x: 0, y: 0 }
328
330
  }
329
331
 
330
- outPos.x = bone.worldX;
331
- outPos.y = bone.worldY;
332
+ outPos.x = bone.worldX
333
+ outPos.y = bone.worldY
332
334
 
333
- return outPos;
335
+ return outPos
334
336
  }
335
337
 
336
338
  /**
@@ -340,26 +342,26 @@ export class Spine extends ViewContainer {
340
342
  * @param time the time at which to set the state
341
343
  */
342
344
  private _updateAndApplyState(time: number) {
343
- this.hasNeverUpdated = false;
345
+ this.hasNeverUpdated = false
344
346
 
345
- this.state.update(time);
346
- this.skeleton.update(time);
347
+ this.state.update(time)
348
+ this.skeleton.update(time)
347
349
 
348
- const { skeleton } = this;
350
+ const { skeleton } = this
349
351
 
350
- this.state.apply(skeleton);
352
+ this.state.apply(skeleton)
351
353
 
352
- this.beforeUpdateWorldTransforms(this);
353
- skeleton.updateWorldTransform(Physics.update);
354
- this.afterUpdateWorldTransforms(this);
354
+ this.beforeUpdateWorldTransforms(this)
355
+ skeleton.updateWorldTransform(Physics.update)
356
+ this.afterUpdateWorldTransforms(this)
355
357
 
356
- this.updateSlotObjects();
358
+ this.updateSlotObjects()
357
359
 
358
- this._stateChanged = true;
360
+ this._stateChanged = true
359
361
 
360
- this._boundsDirty = true;
362
+ this._boundsDirty = true
361
363
 
362
- this.onViewUpdate();
364
+ this.onViewUpdate()
363
365
  }
364
366
 
365
367
  /**
@@ -368,194 +370,182 @@ export class Spine extends ViewContainer {
368
370
  * @internal
369
371
  */
370
372
  _validateAndTransformAttachments() {
371
- if (!this._stateChanged) return;
372
- this._stateChanged = false;
373
+ if (!this._stateChanged) return
374
+ this._stateChanged = false
373
375
 
374
- this.validateAttachments();
376
+ this.validateAttachments()
375
377
 
376
- this.transformAttachments();
378
+ this.transformAttachments()
377
379
  }
378
380
 
379
381
  private validateAttachments() {
382
+ const currentDrawOrder = this.skeleton.drawOrder
380
383
 
381
- const currentDrawOrder = this.skeleton.drawOrder;
382
-
383
- const lastAttachments = this._lastAttachments;
384
+ const lastAttachments = this._lastAttachments
384
385
 
385
- let index = 0;
386
+ let index = 0
386
387
 
387
- let spineAttachmentsDirty = false;
388
+ let spineAttachmentsDirty = false
388
389
 
389
390
  for (let i = 0; i < currentDrawOrder.length; i++) {
390
- const slot = currentDrawOrder[i];
391
- const attachment = slot.getAttachment();
391
+ const slot = currentDrawOrder[i]
392
+ const attachment = slot.getAttachment()
392
393
 
393
394
  if (attachment) {
394
395
  if (attachment !== lastAttachments[index]) {
395
- spineAttachmentsDirty = true;
396
- lastAttachments[index] = attachment;
396
+ spineAttachmentsDirty = true
397
+ lastAttachments[index] = attachment
397
398
  }
398
399
 
399
- index++;
400
+ index++
400
401
  }
401
402
  }
402
403
 
403
404
  if (index !== lastAttachments.length) {
404
- spineAttachmentsDirty = true;
405
- lastAttachments.length = index;
405
+ spineAttachmentsDirty = true
406
+ lastAttachments.length = index
406
407
  }
407
408
 
408
- this.spineAttachmentsDirty ||= spineAttachmentsDirty;
409
+ this.spineAttachmentsDirty ||= spineAttachmentsDirty
409
410
  }
410
411
 
411
412
  private updateAndSetPixiMask(slot: Slot, last: boolean) {
412
413
  // assign/create the currentClippingSlot
413
- const attachment = slot.attachment;
414
+ const attachment = slot.attachment
414
415
  if (attachment && attachment instanceof ClippingAttachment) {
415
- const clip = (this.clippingSlotToPixiMasks[slot.data.name] ||= { slot, vertices: new Array<number>() });
416
- clip.maskComputed = false;
417
- this.currentClippingSlot = this.clippingSlotToPixiMasks[slot.data.name];
418
- return;
416
+ const clip = (this.clippingSlotToPixiMasks[slot.data.name] ||= { slot, vertices: new Array<number>() })
417
+ clip.maskComputed = false
418
+ this.currentClippingSlot = this.clippingSlotToPixiMasks[slot.data.name]
419
+ return
419
420
  }
420
421
 
421
422
  // assign the currentClippingSlot mask to the slot object
422
- let currentClippingSlot = this.currentClippingSlot;
423
- let slotObject = this._slotsObject[slot.data.name];
423
+ const currentClippingSlot = this.currentClippingSlot
424
+ const slotObject = this._slotsObject[slot.data.name]
424
425
  if (currentClippingSlot && slotObject) {
425
- let slotClipping = currentClippingSlot.slot;
426
- let clippingAttachment = slotClipping.attachment as ClippingAttachment;
426
+ const slotClipping = currentClippingSlot.slot
427
+ const clippingAttachment = slotClipping.attachment as ClippingAttachment
427
428
 
428
429
  // create the pixi mask, only the first time and if the clipped slot is the first one clipped by this currentClippingSlot
429
- let mask = currentClippingSlot.mask as Graphics;
430
+ let mask = currentClippingSlot.mask as Graphics
430
431
  if (!mask) {
431
- mask = maskPool.obtain();
432
- currentClippingSlot.mask = mask;
433
- this.addChild(mask);
432
+ mask = maskPool.obtain()
433
+ currentClippingSlot.mask = mask
434
+ this.addChild(mask)
434
435
  }
435
436
 
436
437
  // compute the pixi mask polygon, if the clipped slot is the first one clipped by this currentClippingSlot
437
438
  if (!currentClippingSlot.maskComputed) {
438
- currentClippingSlot.maskComputed = true;
439
- const worldVerticesLength = clippingAttachment.worldVerticesLength;
440
- const vertices = currentClippingSlot.vertices;
441
- clippingAttachment.computeWorldVertices(slotClipping, 0, worldVerticesLength, vertices, 0, 2);
442
- mask.clear().poly(vertices).stroke({ width: 0 }).fill({ alpha: .25 });
439
+ currentClippingSlot.maskComputed = true
440
+ const worldVerticesLength = clippingAttachment.worldVerticesLength
441
+ const vertices = currentClippingSlot.vertices
442
+ clippingAttachment.computeWorldVertices(slotClipping, 0, worldVerticesLength, vertices, 0, 2)
443
+ mask.clear().poly(vertices).stroke({ width: 0 }).fill({ alpha: 0.25 })
443
444
  }
444
- slotObject.container.mask = mask;
445
+ slotObject.container.mask = mask
445
446
  } else if (slotObject?.container.mask) {
446
447
  // remove the mask, if slot object has a mask, but currentClippingSlot is undefined
447
- slotObject.container.mask = null;
448
+ slotObject.container.mask = null
448
449
  }
449
450
 
450
451
  // if current slot is the ending one of the currentClippingSlot mask, set currentClippingSlot to undefined
451
452
  if (currentClippingSlot && (currentClippingSlot.slot.attachment as ClippingAttachment).endSlot == slot.data) {
452
- this.currentClippingSlot = undefined;
453
+ this.currentClippingSlot = undefined
453
454
  }
454
455
 
455
456
  // clean up unused masks
456
457
  if (last) {
457
458
  for (const key in this.clippingSlotToPixiMasks) {
458
- const clippingSlotToPixiMask = this.clippingSlotToPixiMasks[key];
459
- if ((!(clippingSlotToPixiMask.slot.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) && clippingSlotToPixiMask.mask) {
460
- this.removeChild(clippingSlotToPixiMask.mask);
461
- maskPool.free(clippingSlotToPixiMask.mask);
462
- clippingSlotToPixiMask.mask = undefined;
459
+ const clippingSlotToPixiMask = this.clippingSlotToPixiMasks[key]
460
+ if (
461
+ (!(clippingSlotToPixiMask.slot.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) &&
462
+ clippingSlotToPixiMask.mask
463
+ ) {
464
+ this.removeChild(clippingSlotToPixiMask.mask)
465
+ maskPool.free(clippingSlotToPixiMask.mask)
466
+ clippingSlotToPixiMask.mask = undefined
463
467
  }
464
468
  }
465
469
  }
466
470
  }
467
471
 
468
- private currentClippingSlot: SlotsToClipping | undefined;
472
+ private currentClippingSlot: SlotsToClipping | undefined
469
473
  private transformAttachments() {
470
- const currentDrawOrder = this.skeleton.drawOrder;
474
+ const currentDrawOrder = this.skeleton.drawOrder
471
475
 
472
476
  for (let i = 0; i < currentDrawOrder.length; i++) {
473
- const slot = currentDrawOrder[i];
477
+ const slot = currentDrawOrder[i]
474
478
 
475
- this.updateAndSetPixiMask(slot, i === currentDrawOrder.length - 1);
479
+ this.updateAndSetPixiMask(slot, i === currentDrawOrder.length - 1)
476
480
 
477
- const attachment = slot.getAttachment();
481
+ const attachment = slot.getAttachment()
478
482
 
479
483
  if (attachment) {
480
484
  if (attachment instanceof MeshAttachment || attachment instanceof RegionAttachment) {
481
- const cacheData = this._getCachedData(slot, attachment);
485
+ const cacheData = this._getCachedData(slot, attachment)
482
486
 
483
487
  if (attachment instanceof RegionAttachment) {
484
- attachment.computeWorldVertices(slot, cacheData.vertices, 0, 2);
485
- }
486
- else {
487
- attachment.computeWorldVertices(
488
- slot,
489
- 0,
490
- attachment.worldVerticesLength,
491
- cacheData.vertices,
492
- 0,
493
- 2,
494
- );
488
+ attachment.computeWorldVertices(slot, cacheData.vertices, 0, 2)
489
+ } else {
490
+ attachment.computeWorldVertices(slot, 0, attachment.worldVerticesLength, cacheData.vertices, 0, 2)
495
491
  }
496
492
 
497
493
  // sequences uvs are known only after computeWorldVertices is invoked
498
494
  if (cacheData.uvs.length < attachment.uvs.length) {
499
- cacheData.uvs = new Float32Array(attachment.uvs.length);
495
+ cacheData.uvs = new Float32Array(attachment.uvs.length)
500
496
  }
501
497
 
502
498
  // need to copy because attachments uvs are shared among skeletons using the same atlas
503
- fastCopy((attachment.uvs as Float32Array).buffer, cacheData.uvs.buffer);
499
+ fastCopy((attachment.uvs as Float32Array).buffer, cacheData.uvs.buffer)
504
500
 
505
- const skeleton = slot.bone.skeleton;
506
- const skeletonColor = skeleton.color;
507
- const slotColor = slot.color;
501
+ const skeleton = slot.bone.skeleton
502
+ const skeletonColor = skeleton.color
503
+ const slotColor = slot.color
508
504
 
509
- const attachmentColor = attachment.color;
505
+ const attachmentColor = attachment.color
510
506
 
511
507
  cacheData.color.set(
512
508
  skeletonColor.r * slotColor.r * attachmentColor.r,
513
509
  skeletonColor.g * slotColor.g * attachmentColor.g,
514
510
  skeletonColor.b * slotColor.b * attachmentColor.b,
515
511
  skeletonColor.a * slotColor.a * attachmentColor.a,
516
- );
512
+ )
517
513
 
518
514
  if (slot.darkColor) {
519
- cacheData.darkColor.setFromColor(slot.darkColor);
515
+ cacheData.darkColor.setFromColor(slot.darkColor)
520
516
  }
521
517
 
522
- cacheData.skipRender = cacheData.clipped = false;
518
+ cacheData.skipRender = cacheData.clipped = false
523
519
 
524
- const texture = attachment.region?.texture.texture || Texture.EMPTY;
520
+ const texture = attachment.region?.texture.texture || Texture.EMPTY
525
521
 
526
522
  if (cacheData.texture !== texture) {
527
- cacheData.texture = texture;
528
- this.spineTexturesDirty = true;
523
+ cacheData.texture = texture
524
+ this.spineTexturesDirty = true
529
525
  }
530
526
 
531
527
  if (clipper.isClipping()) {
532
- this.updateClippingData(cacheData);
528
+ this.updateClippingData(cacheData)
533
529
  }
534
- }
535
- else if (attachment instanceof ClippingAttachment) {
536
- clipper.clipStart(slot, attachment);
537
- continue;
530
+ } else if (attachment instanceof ClippingAttachment) {
531
+ clipper.clipStart(slot, attachment)
532
+ continue
538
533
  }
539
534
  }
540
- clipper.clipEndWithSlot(slot);
535
+ clipper.clipEndWithSlot(slot)
541
536
  }
542
- clipper.clipEnd();
537
+ clipper.clipEnd()
543
538
  }
544
539
 
545
540
  private updateClippingData(cacheData: AttachmentCacheData) {
546
- cacheData.clipped = true;
541
+ cacheData.clipped = true
547
542
 
548
- clipper.clipTrianglesUnpacked(
549
- cacheData.vertices,
550
- cacheData.indices,
551
- cacheData.indices.length,
552
- cacheData.uvs,
553
- );
543
+ clipper.clipTrianglesUnpacked(cacheData.vertices, cacheData.indices, cacheData.indices.length, cacheData.uvs)
554
544
 
555
- const { clippedVertices, clippedUVs, clippedTriangles } = clipper;
545
+ const { clippedVertices, clippedUVs, clippedTriangles } = clipper
556
546
 
557
- const verticesCount = clippedVertices.length / 2;
558
- const indicesCount = clippedTriangles.length;
547
+ const verticesCount = clippedVertices.length / 2
548
+ const indicesCount = clippedTriangles.length
559
549
 
560
550
  if (!cacheData.clippedData) {
561
551
  cacheData.clippedData = {
@@ -564,51 +554,51 @@ export class Spine extends ViewContainer {
564
554
  vertexCount: verticesCount,
565
555
  indices: new Uint16Array(indicesCount),
566
556
  indicesCount,
567
- };
557
+ }
568
558
 
569
- this.spineAttachmentsDirty = true;
559
+ this.spineAttachmentsDirty = true
570
560
  }
571
561
 
572
- const clippedData = cacheData.clippedData;
562
+ const clippedData = cacheData.clippedData
573
563
 
574
- const sizeChange = clippedData.vertexCount !== verticesCount || indicesCount !== clippedData.indicesCount;
564
+ const sizeChange = clippedData.vertexCount !== verticesCount || indicesCount !== clippedData.indicesCount
575
565
 
576
- cacheData.skipRender = verticesCount === 0;
566
+ cacheData.skipRender = verticesCount === 0
577
567
 
578
568
  if (sizeChange) {
579
- this.spineAttachmentsDirty = true;
569
+ this.spineAttachmentsDirty = true
580
570
 
581
571
  if (clippedData.vertexCount < verticesCount) {
582
572
  // buffer reuse!
583
- clippedData.vertices = new Float32Array(verticesCount * 2);
584
- clippedData.uvs = new Float32Array(verticesCount * 2);
573
+ clippedData.vertices = new Float32Array(verticesCount * 2)
574
+ clippedData.uvs = new Float32Array(verticesCount * 2)
585
575
  }
586
576
 
587
577
  if (clippedData.indices.length < indicesCount) {
588
- clippedData.indices = new Uint16Array(indicesCount);
578
+ clippedData.indices = new Uint16Array(indicesCount)
589
579
  }
590
580
  }
591
581
 
592
- const { vertices, uvs, indices } = clippedData;
582
+ const { vertices, uvs, indices } = clippedData
593
583
 
594
584
  for (let i = 0; i < verticesCount; i++) {
595
- vertices[i * 2] = clippedVertices[i * 2];
596
- vertices[(i * 2) + 1] = clippedVertices[(i * 2) + 1];
585
+ vertices[i * 2] = clippedVertices[i * 2]
586
+ vertices[i * 2 + 1] = clippedVertices[i * 2 + 1]
597
587
 
598
- uvs[i * 2] = clippedUVs[(i * 2)];
599
- uvs[(i * 2) + 1] = clippedUVs[(i * 2) + 1];
588
+ uvs[i * 2] = clippedUVs[i * 2]
589
+ uvs[i * 2 + 1] = clippedUVs[i * 2 + 1]
600
590
  }
601
591
 
602
- clippedData.vertexCount = verticesCount;
592
+ clippedData.vertexCount = verticesCount
603
593
 
604
594
  for (let i = 0; i < indicesCount; i++) {
605
595
  if (indices[i] !== clippedTriangles[i]) {
606
- this.spineAttachmentsDirty = true;
607
- indices[i] = clippedTriangles[i];
596
+ this.spineAttachmentsDirty = true
597
+ indices[i] = clippedTriangles[i]
608
598
  }
609
599
  }
610
600
 
611
- clippedData.indicesCount = indicesCount;
601
+ clippedData.indicesCount = indicesCount
612
602
  }
613
603
 
614
604
  /**
@@ -617,43 +607,43 @@ export class Spine extends ViewContainer {
617
607
  */
618
608
  private updateSlotObjects() {
619
609
  for (const i in this._slotsObject) {
620
- const slotAttachment = this._slotsObject[i];
610
+ const slotAttachment = this._slotsObject[i]
621
611
 
622
- if (!slotAttachment) continue;
612
+ if (!slotAttachment) continue
623
613
 
624
- this.updateSlotObject(slotAttachment);
614
+ this.updateSlotObject(slotAttachment)
625
615
  }
626
616
  }
627
617
 
628
- private updateSlotObject(slotAttachment: { slot: Slot, container: Container }) {
629
- const { slot, container } = slotAttachment;
618
+ private updateSlotObject(slotAttachment: { slot: Slot; container: Container }) {
619
+ const { slot, container } = slotAttachment
630
620
 
631
- container.visible = this.skeleton.drawOrder.includes(slot);
621
+ container.visible = this.skeleton.drawOrder.includes(slot)
632
622
 
633
623
  if (container.visible) {
634
- const bone = slot.bone;
624
+ const bone = slot.bone
635
625
 
636
- container.position.set(bone.worldX, bone.worldY);
626
+ container.position.set(bone.worldX, bone.worldY)
637
627
 
638
- container.scale.x = bone.getWorldScaleX();
639
- container.scale.y = bone.getWorldScaleY();
628
+ container.scale.x = bone.getWorldScaleX()
629
+ container.scale.y = bone.getWorldScaleY()
640
630
 
641
- container.rotation = bone.getWorldRotationX() * DEG_TO_RAD;
631
+ container.rotation = bone.getWorldRotationX() * DEG_TO_RAD
642
632
 
643
- container.alpha = this.skeleton.color.a * slot.color.a;
633
+ container.alpha = this.skeleton.color.a * slot.color.a
644
634
  }
645
635
  }
646
636
 
647
637
  /** @internal */
648
638
  _getCachedData(slot: Slot, attachment: RegionAttachment | MeshAttachment): AttachmentCacheData {
649
- return this.attachmentCacheData[slot.data.index][attachment.name] || this.initCachedData(slot, attachment);
639
+ return this.attachmentCacheData[slot.data.index][attachment.name] || this.initCachedData(slot, attachment)
650
640
  }
651
641
 
652
642
  private initCachedData(slot: Slot, attachment: RegionAttachment | MeshAttachment): AttachmentCacheData {
653
- let vertices: Float32Array;
643
+ let vertices: Float32Array
654
644
 
655
645
  if (attachment instanceof RegionAttachment) {
656
- vertices = new Float32Array(8);
646
+ vertices = new Float32Array(8)
657
647
 
658
648
  this.attachmentCacheData[slot.data.index][attachment.name] = {
659
649
  id: `${slot.data.index}-${attachment.name}`,
@@ -666,10 +656,9 @@ export class Spine extends ViewContainer {
666
656
  darkTint: this.darkTint,
667
657
  skipRender: false,
668
658
  texture: attachment.region?.texture.texture,
669
- };
670
- }
671
- else {
672
- vertices = new Float32Array(attachment.worldVerticesLength);
659
+ }
660
+ } else {
661
+ vertices = new Float32Array(attachment.worldVerticesLength)
673
662
 
674
663
  this.attachmentCacheData[slot.data.index][attachment.name] = {
675
664
  id: `${slot.data.index}-${attachment.name}`,
@@ -682,27 +671,27 @@ export class Spine extends ViewContainer {
682
671
  darkTint: this.darkTint,
683
672
  skipRender: false,
684
673
  texture: attachment.region?.texture.texture,
685
- };
674
+ }
686
675
  }
687
676
 
688
- return this.attachmentCacheData[slot.data.index][attachment.name];
677
+ return this.attachmentCacheData[slot.data.index][attachment.name]
689
678
  }
690
679
 
691
680
  protected onViewUpdate() {
692
681
  // increment from the 12th bit!
693
- this._didViewChangeTick++;
694
- this._boundsDirty = true;
682
+ this._didViewChangeTick++
683
+ this._boundsDirty = true
695
684
 
696
- if (this.didViewUpdate) return;
697
- this.didViewUpdate = true;
685
+ if (this.didViewUpdate) return
686
+ this.didViewUpdate = true
698
687
 
699
- const renderGroup = this.renderGroup || this.parentRenderGroup;
688
+ const renderGroup = this.renderGroup || this.parentRenderGroup
700
689
 
701
690
  if (renderGroup) {
702
- renderGroup.onChildViewUpdate(this);
691
+ renderGroup.onChildViewUpdate(this)
703
692
  }
704
693
 
705
- this.debug?.renderDebug(this);
694
+ this.debug?.renderDebug(this)
706
695
  }
707
696
 
708
697
  /**
@@ -713,26 +702,26 @@ export class Spine extends ViewContainer {
713
702
  * @param slotRef - The slot id or slot to attach to
714
703
  */
715
704
  public addSlotObject(slot: number | string | Slot, container: Container) {
716
- slot = this.getSlotFromRef(slot);
705
+ slot = this.getSlotFromRef(slot)
717
706
 
718
707
  // need to check in on the container too...
719
708
  for (const i in this._slotsObject) {
720
709
  if (this._slotsObject[i]?.container === container) {
721
- this.removeSlotObject(this._slotsObject[i].slot);
710
+ this.removeSlotObject(this._slotsObject[i].slot)
722
711
  }
723
712
  }
724
713
 
725
- this.removeSlotObject(slot);
714
+ this.removeSlotObject(slot)
726
715
 
727
- container.includeInBuild = false;
716
+ container.includeInBuild = false
728
717
 
729
718
  // TODO only add once??
730
- this.addChild(container);
719
+ this.addChild(container)
731
720
 
732
- const slotObject = { container, slot };
733
- this._slotsObject[slot.data.name] = slotObject;
721
+ const slotObject = { container, slot }
722
+ this._slotsObject[slot.data.name] = slotObject
734
723
 
735
- this.updateSlotObject(slotObject);
724
+ this.updateSlotObject(slotObject)
736
725
  }
737
726
 
738
727
  /**
@@ -742,29 +731,28 @@ export class Spine extends ViewContainer {
742
731
  * @param slotOrContainer - The container, slot id or slot to detach from
743
732
  */
744
733
  public removeSlotObject(slotOrContainer: number | string | Slot | Container) {
745
- let containerToRemove: Container | undefined;
734
+ let containerToRemove: Container | undefined
746
735
 
747
736
  if (slotOrContainer instanceof Container) {
748
737
  for (const i in this._slotsObject) {
749
738
  if (this._slotsObject[i]?.container === slotOrContainer) {
750
- this._slotsObject[i] = null;
739
+ this._slotsObject[i] = null
751
740
 
752
- containerToRemove = slotOrContainer;
753
- break;
741
+ containerToRemove = slotOrContainer
742
+ break
754
743
  }
755
744
  }
756
- }
757
- else {
758
- const slot = this.getSlotFromRef(slotOrContainer);
745
+ } else {
746
+ const slot = this.getSlotFromRef(slotOrContainer)
759
747
 
760
- containerToRemove = this._slotsObject[slot.data.name]?.container;
761
- this._slotsObject[slot.data.name] = null;
748
+ containerToRemove = this._slotsObject[slot.data.name]?.container
749
+ this._slotsObject[slot.data.name] = null
762
750
  }
763
751
 
764
752
  if (containerToRemove) {
765
- this.removeChild(containerToRemove);
753
+ this.removeChild(containerToRemove)
766
754
 
767
- containerToRemove.includeInBuild = true;
755
+ containerToRemove.includeInBuild = true
768
756
  }
769
757
  }
770
758
 
@@ -774,56 +762,55 @@ export class Spine extends ViewContainer {
774
762
  * @param slotRef - The slot id or slot to get the attachment from
775
763
  * @returns - The container attached to the slot
776
764
  */
777
- public getSlotObject(slot: number | string | Slot) {
778
- slot = this.getSlotFromRef(slot);
765
+ public getSlotObject(slot: number | string | Slot): Container<ContainerChild> {
766
+ slot = this.getSlotFromRef(slot)
779
767
 
780
- return this._slotsObject[slot.data.name]?.container;
768
+ return this._slotsObject[slot.data.name]?.container
781
769
  }
782
770
 
783
771
  protected updateBounds() {
784
- this._boundsDirty = false;
772
+ this._boundsDirty = false
785
773
 
786
- this.skeletonBounds ||= new SkeletonBounds();
774
+ this.skeletonBounds ||= new SkeletonBounds()
787
775
 
788
- const skeletonBounds = this.skeletonBounds;
776
+ const skeletonBounds = this.skeletonBounds
789
777
 
790
- skeletonBounds.update(this.skeleton, true);
778
+ skeletonBounds.update(this.skeleton, true)
791
779
 
792
780
  if (skeletonBounds.minX === Infinity) {
793
781
  if (this.hasNeverUpdated) {
794
- this._updateAndApplyState(0);
795
- this._boundsDirty = false;
782
+ this._updateAndApplyState(0)
783
+ this._boundsDirty = false
796
784
  }
797
- this._validateAndTransformAttachments();
785
+ this._validateAndTransformAttachments()
798
786
 
799
- const drawOrder = this.skeleton.drawOrder;
800
- const bounds = this._bounds;
787
+ const drawOrder = this.skeleton.drawOrder
788
+ const bounds = this._bounds
801
789
 
802
- bounds.clear();
790
+ bounds.clear()
803
791
 
804
792
  for (let i = 0; i < drawOrder.length; i++) {
805
- const slot = drawOrder[i];
793
+ const slot = drawOrder[i]
806
794
 
807
- const attachment = slot.getAttachment();
795
+ const attachment = slot.getAttachment()
808
796
 
809
797
  if (attachment && (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment)) {
810
- const cacheData = this._getCachedData(slot, attachment);
798
+ const cacheData = this._getCachedData(slot, attachment)
811
799
 
812
- bounds.addVertexData(cacheData.vertices, 0, cacheData.vertices.length);
800
+ bounds.addVertexData(cacheData.vertices, 0, cacheData.vertices.length)
813
801
  }
814
802
  }
815
- }
816
- else {
817
- this._bounds.minX = skeletonBounds.minX;
818
- this._bounds.minY = skeletonBounds.minY;
819
- this._bounds.maxX = skeletonBounds.maxX;
820
- this._bounds.maxY = skeletonBounds.maxY;
803
+ } else {
804
+ this._bounds.minX = skeletonBounds.minX
805
+ this._bounds.minY = skeletonBounds.minY
806
+ this._bounds.maxX = skeletonBounds.maxX
807
+ this._bounds.maxY = skeletonBounds.maxY
821
808
  }
822
809
  }
823
810
 
824
811
  /** @internal */
825
812
  addBounds(bounds: Bounds) {
826
- bounds.addBounds(this.bounds);
813
+ bounds.addBounds(this.bounds)
827
814
  }
828
815
 
829
816
  /**
@@ -834,36 +821,35 @@ export class Spine extends ViewContainer {
834
821
  * @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
835
822
  */
836
823
  public override destroy(options: DestroyOptions = false) {
837
- super.destroy(options);
824
+ super.destroy(options)
838
825
 
839
- Ticker.shared.remove(this.internalUpdate, this);
840
- this.state.clearListeners();
841
- this.debug = undefined;
842
- this.skeleton = null as any;
843
- this.state = null as any;
844
- (this._slotsObject as any) = null;
845
- this._lastAttachments.length = 0;
846
- this.attachmentCacheData = null as any;
826
+ Ticker.shared.remove(this.internalUpdate, this)
827
+ this.state.clearListeners()
828
+ this.debug = undefined
829
+ this.skeleton = null as any
830
+ this.state = null as any
831
+ ;(this._slotsObject as any) = null
832
+ this._lastAttachments.length = 0
833
+ this.attachmentCacheData = null as any
847
834
  }
848
835
 
849
836
  /** Converts a point from the skeleton coordinate system to the Pixi world coordinate system. */
850
837
  public skeletonToPixiWorldCoordinates(point: { x: number; y: number }) {
851
- this.worldTransform.apply(point, point);
838
+ this.worldTransform.apply(point, point)
852
839
  }
853
840
 
854
841
  /** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
855
842
  public pixiWorldCoordinatesToSkeleton(point: { x: number; y: number }) {
856
- this.worldTransform.applyInverse(point, point);
843
+ this.worldTransform.applyInverse(point, point)
857
844
  }
858
845
 
859
846
  /** Converts a point from the Pixi world coordinate system to the bone's local coordinate system. */
860
847
  public pixiWorldCoordinatesToBone(point: { x: number; y: number }, bone: Bone) {
861
- this.pixiWorldCoordinatesToSkeleton(point);
848
+ this.pixiWorldCoordinatesToSkeleton(point)
862
849
  if (bone.parent) {
863
- bone.parent.worldToLocal(point as Vector2);
864
- }
865
- else {
866
- bone.worldToLocal(point as Vector2);
850
+ bone.parent.worldToLocal(point as Vector2)
851
+ } else {
852
+ bone.worldToLocal(point as Vector2)
867
853
  }
868
854
  }
869
855
 
@@ -882,29 +868,27 @@ export class Spine extends ViewContainer {
882
868
  * @returns {Spine} The Spine game object instantiated
883
869
  */
884
870
  static from({ skeleton, atlas, scale = 1, darkTint, autoUpdate = true }: SpineFromOptions) {
885
- const cacheKey = `${skeleton}-${atlas}-${scale}`;
871
+ const cacheKey = `${skeleton}-${atlas}-${scale}`
886
872
 
887
873
  if (Cache.has(cacheKey)) {
888
- return new Spine(Cache.get<SkeletonData>(cacheKey));
874
+ return new Spine(Cache.get<SkeletonData>(cacheKey))
889
875
  }
890
876
 
891
- const skeletonAsset = Assets.get<any | Uint8Array>(skeleton);
877
+ const skeletonAsset = Assets.get<any | Uint8Array>(skeleton)
892
878
 
893
- const atlasAsset = Assets.get<TextureAtlas>(atlas);
894
- const attachmentLoader = new AtlasAttachmentLoader(atlasAsset);
895
- const parser = skeletonAsset instanceof Uint8Array
896
- ? new SkeletonBinary(attachmentLoader)
897
- : new SkeletonJson(attachmentLoader);
879
+ const atlasAsset = Assets.get<TextureAtlas>(atlas)
880
+ const attachmentLoader = new AtlasAttachmentLoader(atlasAsset)
881
+ const parser = skeletonAsset instanceof Uint8Array ? new SkeletonBinary(attachmentLoader) : new SkeletonJson(attachmentLoader)
898
882
 
899
- parser.scale = scale;
900
- const skeletonData = parser.readSkeletonData(skeletonAsset);
883
+ parser.scale = scale
884
+ const skeletonData = parser.readSkeletonData(skeletonAsset)
901
885
 
902
- Cache.set(cacheKey, skeletonData);
886
+ Cache.set(cacheKey, skeletonData)
903
887
 
904
888
  return new Spine({
905
889
  skeletonData,
906
890
  darkTint,
907
891
  autoUpdate,
908
- });
892
+ })
909
893
  }
910
894
  }