@safe-engine/pixi 8.4.1 → 8.4.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.
Files changed (71) hide show
  1. package/dist/app.js +1 -1
  2. package/dist/base/index.d.ts +8 -0
  3. package/dist/base/index.d.ts.map +1 -1
  4. package/dist/base/utils.d.ts.map +1 -1
  5. package/dist/box2d-wasm/PhysicsSystem.d.ts +2 -1
  6. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  7. package/dist/box2d-wasm/PhysicsSystem.js +6 -5
  8. package/dist/box2d-wasm/debugDraw.d.ts +1 -1
  9. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
  10. package/dist/box2d-wasm/debugDraw.js +7 -7
  11. package/dist/components/NodeComp.d.ts +10 -8
  12. package/dist/components/NodeComp.d.ts.map +1 -1
  13. package/dist/components/NodeComp.js +17 -11
  14. package/dist/core/Vec2.d.ts +30 -0
  15. package/dist/core/Vec2.d.ts.map +1 -0
  16. package/dist/core/Vec2.js +88 -0
  17. package/dist/core/index.d.ts +6 -0
  18. package/dist/core/index.d.ts.map +1 -0
  19. package/dist/core/index.js +6 -0
  20. package/dist/core/loader.d.ts +3 -0
  21. package/dist/core/loader.d.ts.map +1 -0
  22. package/dist/core/loader.js +21 -0
  23. package/dist/core/math.d.ts +1 -0
  24. package/dist/core/math.d.ts.map +1 -1
  25. package/dist/core/math.js +9 -0
  26. package/dist/gui/GUISystem.d.ts.map +1 -1
  27. package/dist/gui/GUISystem.js +4 -4
  28. package/dist/index.d.ts +2 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +2 -5
  31. package/dist/norender/NoRenderComponent.d.ts +2 -2
  32. package/dist/norender/NoRenderComponent.d.ts.map +1 -1
  33. package/dist/norender/NoRenderSystem.d.ts.map +1 -1
  34. package/dist/norender/NoRenderSystem.js +7 -6
  35. package/dist/norender/Touch.d.ts +32 -0
  36. package/dist/norender/Touch.d.ts.map +1 -0
  37. package/dist/norender/Touch.js +32 -0
  38. package/dist/render/RenderComponent.d.ts +3 -3
  39. package/dist/render/RenderComponent.d.ts.map +1 -1
  40. package/dist/render/RenderComponent.js +18 -28
  41. package/dist/render/RenderSystem.d.ts.map +1 -1
  42. package/dist/render/RenderSystem.js +1 -1
  43. package/package.json +2 -1
  44. package/src/app.ts +2 -2
  45. package/src/base/index.ts +11 -0
  46. package/src/base/utils.ts +4 -4
  47. package/src/box2d-wasm/PhysicsSystem.ts +45 -48
  48. package/src/box2d-wasm/debugDraw.ts +80 -88
  49. package/src/components/NodeComp.ts +30 -30
  50. package/src/core/Vec2.ts +108 -0
  51. package/src/core/index.ts +6 -0
  52. package/src/core/loader.ts +12 -0
  53. package/src/core/math.ts +9 -0
  54. package/src/gui/GUISystem.ts +15 -9
  55. package/src/index.ts +3 -5
  56. package/src/norender/NoRenderComponent.ts +2 -2
  57. package/src/norender/NoRenderSystem.ts +12 -11
  58. package/src/norender/Touch.ts +37 -0
  59. package/src/render/RenderComponent.ts +35 -41
  60. package/src/render/RenderSystem.ts +3 -7
  61. package/dist/helper/html-text-parser.d.ts +0 -20
  62. package/dist/helper/html-text-parser.d.ts.map +0 -1
  63. package/dist/helper/html-text-parser.js +0 -64
  64. package/dist/spine/lib/assets/atlasLoader.d.ts +0 -34
  65. package/dist/spine/lib/assets/atlasLoader.d.ts.map +0 -1
  66. package/dist/spine/lib/assets/atlasLoader.js +0 -122
  67. package/dist/spine/lib/assets/skeletonLoader.d.ts +0 -30
  68. package/dist/spine/lib/assets/skeletonLoader.d.ts.map +0 -1
  69. package/dist/spine/lib/assets/skeletonLoader.js +0 -70
  70. package/src/spine/lib/assets/atlasLoader.ts +0 -158
  71. package/src/spine/lib/assets/skeletonLoader.ts +0 -81
@@ -1,13 +1,13 @@
1
- import { FederatedPointerEvent } from 'pixi.js'
2
1
  import { NoRenderComponentX } from '../components/BaseComponent'
3
2
  import { EventCallbackType, EventMap, NodeComp } from '../components/NodeComp'
3
+ import { Touch } from './Touch'
4
4
 
5
5
  // export class Touch extends FederatedPointerEvent {
6
6
  // declare getLocation: () => Vec2
7
7
  // declare getDelta: () => Vec2
8
8
  // }
9
9
 
10
- export type TouchEventCallback = (touch?: FederatedPointerEvent, node?: NodeComp) => void
10
+ export type TouchEventCallback = (touch?: Touch, node?: NodeComp) => void
11
11
 
12
12
  export class EventRegister extends NoRenderComponentX {
13
13
  events: EventMap = {}
@@ -1,13 +1,14 @@
1
1
  import { EventManager, EventTypes, System } from 'entityx-ts'
2
-
3
2
  // import { Touch } from '../../polyfills'
4
3
  import { Container } from 'pixi.js'
4
+
5
5
  import { NodeComp } from '../components/NodeComp'
6
6
  import { ExtraDataComp, TouchEventRegister } from './NoRenderComponent'
7
+ import { Touch } from './Touch'
7
8
 
8
9
  export class NoRenderSystem implements System {
9
10
  configure(event_manager: EventManager) {
10
- event_manager.subscribe(EventTypes.ComponentAdded, ExtraDataComp, ({ entity, component }) => {
11
+ event_manager.subscribe(EventTypes.ComponentAdded, ExtraDataComp, ({ component }) => {
11
12
  const { key, value } = component.props
12
13
  component.data[key] = value
13
14
  })
@@ -19,26 +20,26 @@ export class NoRenderSystem implements System {
19
20
  const container: Container = nodeComp.instance
20
21
  if (touchComp.props.onTouchStart) {
21
22
  container.on('pointerdown', (event) => {
22
- touchComp.props.onTouchStart(event, nodeComp)
23
- });
23
+ touchComp.props.onTouchStart(new Touch(event), nodeComp)
24
+ })
24
25
  }
25
26
  if (touchComp.props.onTouchMove) {
26
27
  container.on('pointermove', (event) => {
27
- touchComp.props.onTouchMove(event, nodeComp)
28
- });
28
+ touchComp.props.onTouchMove(new Touch(event), nodeComp)
29
+ })
29
30
  }
30
31
  if (touchComp.props.onTouchEnd) {
31
32
  container.on('pointerup', (event) => {
32
- touchComp.props.onTouchEnd(event, nodeComp)
33
- });
33
+ touchComp.props.onTouchEnd(new Touch(event), nodeComp)
34
+ })
34
35
  }
35
36
  if (touchComp.props.onTouchEnd) {
36
37
  container.on('pointercancel', (event) => {
37
- touchComp.props.onTouchEnd(event, nodeComp)
38
- });
38
+ touchComp.props.onTouchEnd(new Touch(event), nodeComp)
39
+ })
39
40
  }
40
41
  })
41
- event_manager.subscribe(EventTypes.ComponentRemoved, TouchEventRegister, ({ entity, component }) => {
42
+ event_manager.subscribe(EventTypes.ComponentRemoved, TouchEventRegister, ({ component }) => {
42
43
  console.log('ComponentRemovedEvent TouchEventRegister', event)
43
44
  // const ett = event.entity
44
45
  // const nodeComp = ett.getComponent(NodeComp)
@@ -0,0 +1,37 @@
1
+ import { FederatedPointerEvent } from 'pixi.js'
2
+
3
+ import { Vec2 } from '..'
4
+
5
+ export class Touch {
6
+ private event: FederatedPointerEvent
7
+ constructor(event) {
8
+ this.event = event
9
+ }
10
+
11
+ getLocation() {
12
+ return this.event.global
13
+ }
14
+ getLocationX() {
15
+ return this.event.globalX
16
+ }
17
+ getLocationY() {
18
+ return this.event.globalY
19
+ }
20
+ getDelta() {
21
+ return Vec2(this.event.movementX, this.event.movementY)
22
+ }
23
+ getDeltaX() {
24
+ return this.event.movementX
25
+ }
26
+ getDeltaY() {
27
+ return this.event.movementY
28
+ }
29
+ getLocationInView(view: any) {
30
+ const { x, y } = this.event.global
31
+ return view.toLocal({ x, y })
32
+ }
33
+ getLocationInNode(node: any) {
34
+ const { x, y } = this.event.global
35
+ return node.toLocal({ x, y })
36
+ }
37
+ }
@@ -1,4 +1,4 @@
1
- import { Graphics, Point, Sprite, Texture } from 'pixi.js'
1
+ import { Graphics, Sprite, Texture } from 'pixi.js'
2
2
 
3
3
  import { Color4B, Vec2 } from '..'
4
4
  import { ComponentX } from '../components/BaseComponent'
@@ -59,22 +59,17 @@ export class SpriteRender extends ComponentX<SpriteRenderProps & { $ref?: Sprite
59
59
  enum PointType {
60
60
  Circle,
61
61
  Rect,
62
- };
62
+ }
63
63
  interface GraphicsRenderProps {
64
64
  lineWidth?: number
65
65
  strokeColor?: Color4B
66
66
  fillColor?: Color4B
67
67
  }
68
68
  export class GraphicsRender extends ComponentX<GraphicsRenderProps & { $ref?: GraphicsRender }, Graphics> {
69
-
70
- drawPoint(position: Vec2, pointSize: Float, color: Color4B, pointType = PointType.Rect) {
71
-
72
- }
69
+ drawPoint(position: Vec2, pointSize: Float, color: Color4B, pointType = PointType.Rect) {}
73
70
  // drawPoints(points: Vec2[], color: Color4B) {
74
71
  // }
75
- drawLine(origin: Vec2, destination: Vec2, color: Color4B, thickness: Float) {
76
-
77
- }
72
+ drawLine(origin: Vec2, destination: Vec2, color: Color4B, thickness: Float) {}
78
73
  drawRect(origin: Vec2, destination: Vec2, color: Color4B) {
79
74
  const { x, y } = origin
80
75
  const width = destination.x - x
@@ -82,44 +77,43 @@ export class GraphicsRender extends ComponentX<GraphicsRenderProps & { $ref?: Gr
82
77
  this.node.instance.rect(x, y, width, height)
83
78
  this.node.instance.fill(color)
84
79
  }
85
- drawSolidRect(origin: Vec2, destination: Vec2, color: Color4B) {
86
-
87
- }
88
- drawCircle(center: Vec2, radius: Float, angle?: Float, segments?: Integer, drawLineToCenter?: boolean, scaleX?: Float, scaleY?: Float, color?: Color4B, thickness?: Float) {
80
+ drawSolidRect(origin: Vec2, destination: Vec2, color: Color4B) {}
81
+ drawCircle(
82
+ center: Vec2,
83
+ radius: Float,
84
+ angle?: Float,
85
+ segments?: Integer,
86
+ drawLineToCenter?: boolean,
87
+ scaleX?: Float,
88
+ scaleY?: Float,
89
+ color?: Color4B,
90
+ thickness?: Float,
91
+ ) {
89
92
  const { x, y } = center
90
93
  this.node.instance.circle(x, y, radius)
91
94
  this.node.instance.fill(color)
92
95
  }
93
- drawSolidCircle(origin: Vec2, destination: Vec2, color: Color4B) {
94
-
95
- }
96
- drawQuadBezier(origin: Vec2, destination: Vec2, color: Color4B) {
97
-
98
- }
99
- drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B) {
100
-
101
- }
102
- drawCardinalSpline(points: Vec2[], color: Color4B) {
103
- }
104
- drawCatmullRom(points: Vec2[], color: Color4B) {
105
- }
106
- drawPoly(points: Vec2[], closedPolygon: boolean, color: Color4B, thickness?: Float) {
107
- this.node.instance.poly(points, closedPolygon)
108
- this.node.instance.fill(color)
109
- }
110
- drawSolidPoly(points: Vec2[], color: Color4B) {
111
- }
112
- drawDot(points: Vec2[], color: Color4B) {
113
- }
114
- drawSegment(from: Point, to: Point, color?: Color4B) {
115
- this.node.instance.moveTo(from.x, from.y);
116
- this.node.instance.lineTo(to.x, to.y);
96
+ drawSolidCircle(origin: Vec2, destination: Vec2, color: Color4B) {}
97
+ drawQuadBezier(origin: Vec2, destination: Vec2, color: Color4B) {}
98
+ drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B) {}
99
+ drawCardinalSpline(points: Vec2[], color: Color4B) {}
100
+ drawCatmullRom(points: Vec2[], color: Color4B) {}
101
+ drawPoly(points: Vec2[], color?: Color4B, thickness?: Float) {
102
+ this.node.instance.poly(points, true)
103
+ this.node.instance.fill(color || this.props.fillColor)
104
+ }
105
+ drawSolidPoly(points: Vec2[], color: Color4B) {}
106
+ drawDot(points: Vec2[], color: Color4B) {}
107
+ drawSegment(from: Vec2, to: Vec2, thickness?: Float, color?: Color4B) {
108
+ this.node.instance.moveTo(from.x, from.y)
109
+ this.node.instance.lineTo(to.x, to.y)
117
110
  this.node.instance.strokeStyle = {
118
- cap: 'round', join: 'round',
119
- width: this.props.lineWidth || 36,
111
+ cap: 'round',
112
+ join: 'round',
113
+ width: thickness || this.props.lineWidth || 36,
120
114
  color: color || this.props.strokeColor,
121
115
  }
122
- this.node.instance.stroke();
116
+ this.node.instance.stroke()
123
117
  }
124
118
  drawTriangle(p1: Vec2, p2: Vec2, p3: Vec2, color: Color4B) {
125
119
  this.node.instance.poly([p1, p2, p3], true)
@@ -135,4 +129,4 @@ interface MaskRenderProps {
135
129
  segments?: number
136
130
  inverted?: boolean
137
131
  }
138
- export class MaskRender extends ComponentX<MaskRenderProps> { }
132
+ export class MaskRender extends ComponentX<MaskRenderProps> {}
@@ -1,8 +1,4 @@
1
- import {
2
- EventManager,
3
- EventTypes,
4
- System
5
- } from 'entityx-ts'
1
+ import { EventManager, EventTypes, System } from 'entityx-ts'
6
2
  import { Container, Graphics, Sprite } from 'pixi.js'
7
3
 
8
4
  import { NodeComp } from '..'
@@ -42,14 +38,14 @@ export class RenderSystem implements System {
42
38
  // component.node.anchorY = 0.5
43
39
  })
44
40
  event_manager.subscribe(EventTypes.ComponentAdded, MaskRender, ({ component }) => {
45
- console.log('MaskRender', component);
41
+ console.log('MaskRender', component)
46
42
  // const { type, segments, inverted } = maskComp
47
43
  // const node = new cc.ClippingNode()
48
44
  // node.setInverted(inverted)
49
45
  // maskComp.node = ett.assign(new NodeComp(node, ett))
50
46
  })
51
47
  event_manager.subscribe(EventTypes.ComponentAdded, GraphicsRender, ({ entity, component }) => {
52
- // const { lineWidth, strokeColor, fillColor } = component
48
+ // const { lineWidth, strokeColor, fillColor } = component.props
53
49
  // console.log('GraphicsRender', component);
54
50
  const node = new Graphics()
55
51
  component.node = entity.assign(new NodeComp(node, entity))
@@ -1,20 +0,0 @@
1
- interface FontTag {
2
- color?: string;
3
- size?: number;
4
- text: string;
5
- }
6
- type ParsedResult = FontTag[];
7
- type StyledElement = {
8
- tag?: string;
9
- style?: {
10
- color?: string;
11
- size?: number;
12
- };
13
- text: string;
14
- };
15
- export declare function parseFontString(input: string): ParsedResult;
16
- export declare function transformToStyledElements(parsed: ParsedResult): StyledElement[];
17
- export declare function generateStringFromStyledElements(elements: StyledElement[]): string;
18
- export declare function generateStylesFromStyledElements(elements: StyledElement[]): {};
19
- export {};
20
- //# sourceMappingURL=html-text-parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"html-text-parser.d.ts","sourceRoot":"","sources":["../../src/helper/html-text-parser.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,YAAY,GAAG,OAAO,EAAE,CAAC;AAE9B,KAAK,aAAa,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAiC3D;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,EAAE,CAa/E;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CASlF;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,aAAa,EAAE,MAWzE"}
@@ -1,64 +0,0 @@
1
- export function parseFontString(input) {
2
- const regex = /<font\s+color=['"](#?[0-9a-fA-F]{6})['"](?:\s+size=(\d+))?>(.*?)<\/font>/gi;
3
- const results = [];
4
- let lastIndex = 0;
5
- let match;
6
- while ((match = regex.exec(input)) !== null) {
7
- // Add plain text before the match if it exists
8
- if (match.index > lastIndex) {
9
- const plainText = input.slice(lastIndex, match.index);
10
- if (plainText) {
11
- results.push({ text: plainText });
12
- }
13
- }
14
- const color = match[1];
15
- const size = match[2] ? parseInt(match[2], 10) : undefined;
16
- const text = match[3];
17
- results.push({ color, size, text });
18
- lastIndex = regex.lastIndex;
19
- }
20
- // Add remaining plain text after the last match
21
- if (lastIndex < input.length) {
22
- const plainText = input.slice(lastIndex);
23
- if (plainText) {
24
- results.push({ text: plainText });
25
- }
26
- }
27
- return results;
28
- }
29
- export function transformToStyledElements(parsed) {
30
- return parsed.map((item, index) => {
31
- if (item.color || item.size) {
32
- return {
33
- tag: `b${index + 1}`,
34
- style: { color: item.color, size: item.size },
35
- text: item.text,
36
- };
37
- }
38
- return {
39
- text: item.text,
40
- };
41
- });
42
- }
43
- export function generateStringFromStyledElements(elements) {
44
- return elements
45
- .map((element) => {
46
- if (!element.tag) {
47
- return element.text;
48
- }
49
- return `<${element.tag}>${element.text}</${element.tag}>`;
50
- })
51
- .join('');
52
- }
53
- export function generateStylesFromStyledElements(elements) {
54
- const styles = {};
55
- elements
56
- .forEach((element) => {
57
- const { tag, style } = element;
58
- if (!tag) {
59
- return;
60
- }
61
- styles[element.tag] = style;
62
- });
63
- return styles;
64
- }
@@ -1,34 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- import { TextureSource } from 'pixi.js';
30
- export interface ISpineAtlasMetadata {
31
- imageMetadata?: any;
32
- images?: TextureSource | string | Record<string, TextureSource | string>;
33
- }
34
- //# sourceMappingURL=atlasLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atlasLoader.d.ts","sourceRoot":"","sources":["../../../../src/spine/lib/assets/atlasLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E;AAE/E,OAAO,EAQN,aAAa,EACb,MAAM,SAAS,CAAC;AAiHjB,MAAM,WAAW,mBAAmB;IAEnC,aAAa,CAAC,EAAE,GAAG,CAAC;IAGpB,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,CAAC;CACzE"}
@@ -1,122 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
- return new (P || (P = Promise))(function (resolve, reject) {
32
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
- step((generator = generator.apply(thisArg, _arguments || [])).next());
36
- });
37
- };
38
- import { checkExtension, DOMAdapter, extensions, ExtensionType, LoaderParserPriority, path, Resolver, TextureSource } from 'pixi.js';
39
- import { SpineTexture } from '../SpineTexture.js';
40
- import { TextureAtlas } from '@esotericsoftware/spine-core';
41
- const spineTextureAtlasLoader = {
42
- extension: ExtensionType.Asset,
43
- resolver: {
44
- test: (value) => checkExtension(value, ".atlas"),
45
- parse: (value) => {
46
- var _a, _b, _c;
47
- const split = value.split('.');
48
- return {
49
- resolution: parseFloat((_c = (_b = (_a = Resolver.RETINA_PREFIX) === null || _a === void 0 ? void 0 : _a.exec(value)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : '1'),
50
- format: split[split.length - 2],
51
- src: value,
52
- };
53
- },
54
- },
55
- loader: {
56
- extension: {
57
- type: ExtensionType.LoadParser,
58
- priority: LoaderParserPriority.Normal,
59
- name: 'spineTextureAtlasLoader',
60
- },
61
- test(url) {
62
- return checkExtension(url, '.atlas');
63
- },
64
- load(url) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const response = yield DOMAdapter.get().fetch(url);
67
- const txt = yield response.text();
68
- return txt;
69
- });
70
- },
71
- testParse(asset, options) {
72
- const isExtensionRight = checkExtension(options.src, '.atlas');
73
- const isString = typeof asset === 'string';
74
- return Promise.resolve(isExtensionRight && isString);
75
- },
76
- unload(atlas) {
77
- atlas.dispose();
78
- },
79
- parse(asset, options, loader) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const metadata = options.data || {};
82
- let basePath = path.dirname(options.src);
83
- if (basePath && basePath.lastIndexOf('/') !== basePath.length - 1) {
84
- basePath += '/';
85
- }
86
- // Retval is going to be a texture atlas. However we need to wait for it's callback to resolve this promise.
87
- const retval = new TextureAtlas(asset);
88
- // If the user gave me only one texture, that one is assumed to be the "first" texture in the atlas
89
- if (metadata.images instanceof TextureSource || typeof metadata.images === 'string') {
90
- const pixiTexture = metadata.images;
91
- metadata.images = {};
92
- metadata.images[retval.pages[0].name] = pixiTexture;
93
- }
94
- // we will wait for all promises for the textures at the same time at the end.
95
- const textureLoadingPromises = [];
96
- // fill the pages
97
- for (const page of retval.pages) {
98
- const pageName = page.name;
99
- const providedPage = (metadata === null || metadata === void 0 ? void 0 : metadata.images) ? metadata.images[pageName] : undefined;
100
- if (providedPage instanceof TextureSource) {
101
- page.setTexture(SpineTexture.from(providedPage));
102
- }
103
- else {
104
- // eslint-disable-next-line max-len
105
- const url = providedPage !== null && providedPage !== void 0 ? providedPage : path.normalize([...basePath.split(path.sep), pageName].join(path.sep));
106
- const assetsToLoadIn = {
107
- src: url,
108
- data: Object.assign(Object.assign({}, metadata.imageMetadata), { alphaMode: page.pma ? 'premultiplied-alpha' : 'premultiply-alpha-on-upload' })
109
- };
110
- const pixiPromise = loader.load(assetsToLoadIn).then((texture) => {
111
- page.setTexture(SpineTexture.from(texture.source));
112
- });
113
- textureLoadingPromises.push(pixiPromise);
114
- }
115
- }
116
- yield Promise.all(textureLoadingPromises);
117
- return retval;
118
- });
119
- },
120
- },
121
- };
122
- extensions.add(spineTextureAtlasLoader);
@@ -1,30 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- export {};
30
- //# sourceMappingURL=skeletonLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skeletonLoader.d.ts","sourceRoot":"","sources":["../../../../src/spine/lib/assets/skeletonLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E"}
@@ -1,70 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
- return new (P || (P = Promise))(function (resolve, reject) {
32
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
- step((generator = generator.apply(thisArg, _arguments || [])).next());
36
- });
37
- };
38
- import { checkExtension, DOMAdapter, extensions, ExtensionType, LoaderParserPriority } from 'pixi.js';
39
- function isJson(resource) {
40
- return Object.prototype.hasOwnProperty.call(resource, 'bones');
41
- }
42
- function isBuffer(resource) {
43
- return resource instanceof Uint8Array;
44
- }
45
- const spineLoaderExtension = {
46
- extension: ExtensionType.Asset,
47
- loader: {
48
- extension: {
49
- type: ExtensionType.LoadParser,
50
- priority: LoaderParserPriority.Normal,
51
- name: 'spineSkeletonLoader',
52
- },
53
- test(url) {
54
- return checkExtension(url, '.skel');
55
- },
56
- load(url) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const response = yield DOMAdapter.get().fetch(url);
59
- const buffer = new Uint8Array(yield response.arrayBuffer());
60
- return buffer;
61
- });
62
- },
63
- testParse(asset, options) {
64
- const isJsonSpineModel = checkExtension(options.src, '.json') && isJson(asset);
65
- const isBinarySpineModel = checkExtension(options.src, '.skel') && isBuffer(asset);
66
- return Promise.resolve(isJsonSpineModel || isBinarySpineModel);
67
- },
68
- },
69
- };
70
- extensions.add(spineLoaderExtension);