@safe-engine/pixi 8.1.3 → 8.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.
- package/@types/index.d.ts +2 -0
- package/@types/safex.d.ts +168 -0
- package/README.md +9 -3
- package/dist/app.d.ts +1 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +25 -24
- package/dist/base/EnhancedComponent.d.ts +25 -0
- package/dist/base/EnhancedComponent.d.ts.map +1 -0
- package/dist/base/EnhancedComponent.js +26 -0
- package/dist/base/gworld.d.ts +8 -0
- package/dist/base/gworld.d.ts.map +1 -0
- package/dist/base/gworld.js +16 -0
- package/dist/base/index.d.ts +4 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +3 -0
- package/dist/base/utils.d.ts +6 -0
- package/dist/base/utils.d.ts.map +1 -0
- package/dist/base/utils.js +3 -0
- package/dist/collider/CollideComponent.d.ts +63 -0
- package/dist/collider/CollideComponent.d.ts.map +1 -0
- package/dist/collider/CollideComponent.js +238 -0
- package/dist/collider/CollideSystem.d.ts +26 -0
- package/dist/collider/CollideSystem.d.ts.map +1 -0
- package/dist/collider/CollideSystem.js +159 -0
- package/dist/collider/helper/Intersection.d.ts +7 -0
- package/dist/collider/helper/Intersection.d.ts.map +1 -0
- package/dist/collider/helper/Intersection.js +111 -0
- package/dist/collider/helper/utils.d.ts +3 -0
- package/dist/collider/helper/utils.d.ts.map +1 -0
- package/dist/collider/helper/utils.js +11 -0
- package/dist/collider/index.d.ts +3 -0
- package/dist/collider/index.d.ts.map +1 -0
- package/dist/collider/index.js +2 -0
- package/dist/components/BaseComponent.d.ts +6 -5
- package/dist/components/BaseComponent.d.ts.map +1 -1
- package/dist/components/BaseComponent.js +7 -9
- package/dist/components/NodeComp.d.ts +13 -13
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +34 -30
- package/dist/components/Scene.d.ts +2 -3
- package/dist/components/Scene.d.ts.map +1 -1
- package/dist/components/Scene.js +6 -10
- package/dist/core/Color.d.ts +1 -0
- package/dist/core/Color.d.ts.map +1 -1
- package/dist/core/Color.js +3 -6
- package/dist/core/LoadingBar.js +10 -15
- package/dist/core/NodePool.d.ts +9 -0
- package/dist/core/NodePool.d.ts.map +1 -0
- package/dist/core/NodePool.js +24 -0
- package/dist/core/Size.js +1 -4
- package/dist/core/director.d.ts +3 -0
- package/dist/core/director.d.ts.map +1 -0
- package/dist/core/director.js +7 -0
- package/dist/core/math.d.ts +4 -0
- package/dist/core/math.d.ts.map +1 -0
- package/dist/core/math.js +10 -0
- package/dist/dragonbones/DragonBonesComponent.d.ts +17 -0
- package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -0
- package/dist/dragonbones/DragonBonesComponent.js +18 -0
- package/dist/dragonbones/DragonBonesSystem.d.ts +6 -0
- package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -0
- package/dist/dragonbones/DragonBonesSystem.js +29 -0
- package/dist/dragonbones/index.d.ts +3 -0
- package/dist/dragonbones/index.d.ts.map +1 -0
- package/dist/dragonbones/index.js +2 -0
- package/dist/{components → gui}/GUIComponent.d.ts +29 -23
- package/dist/gui/GUIComponent.d.ts.map +1 -0
- package/dist/gui/GUIComponent.js +123 -0
- package/dist/{systems → gui}/GUISystem.d.ts +1 -1
- package/dist/gui/GUISystem.d.ts.map +1 -0
- package/dist/gui/GUISystem.js +100 -0
- package/dist/helper/html-text-parser.d.ts +19 -29
- package/dist/helper/html-text-parser.d.ts.map +1 -1
- package/dist/helper/html-text-parser.js +57 -346
- package/dist/helper/utils.d.ts +2 -3
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +18 -23
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -28
- package/dist/norender/NoRenderComponent.d.ts +35 -0
- package/dist/norender/NoRenderComponent.d.ts.map +1 -0
- package/dist/norender/NoRenderComponent.js +53 -0
- package/dist/norender/NoRenderSystem.d.ts +5 -0
- package/dist/norender/NoRenderSystem.d.ts.map +1 -0
- package/dist/norender/NoRenderSystem.js +57 -0
- package/dist/planck/PhysicsComponent.d.ts +37 -0
- package/dist/planck/PhysicsComponent.d.ts.map +1 -0
- package/dist/planck/PhysicsComponent.js +52 -0
- package/dist/planck/PhysicsSprite.d.ts +16 -0
- package/dist/planck/PhysicsSprite.d.ts.map +1 -0
- package/dist/planck/PhysicsSprite.js +31 -0
- package/dist/planck/PhysicsSystem.d.ts +20 -0
- package/dist/planck/PhysicsSystem.d.ts.map +1 -0
- package/dist/planck/PhysicsSystem.js +187 -0
- package/dist/planck/index.d.ts +4 -0
- package/dist/planck/index.d.ts.map +1 -0
- package/dist/planck/index.js +3 -0
- package/dist/render/RenderComponent.d.ts +52 -0
- package/dist/render/RenderComponent.d.ts.map +1 -0
- package/dist/render/RenderComponent.js +104 -0
- package/dist/render/RenderSystem.d.ts.map +1 -0
- package/dist/render/RenderSystem.js +65 -0
- package/dist/spine/SpineComponent.d.ts +10 -0
- package/dist/spine/SpineComponent.d.ts.map +1 -0
- package/dist/spine/SpineComponent.js +3 -0
- package/dist/spine/SpineSystem.d.ts +5 -0
- package/dist/spine/SpineSystem.d.ts.map +1 -0
- package/dist/spine/SpineSystem.js +25 -0
- package/dist/spine/index.d.ts +3 -0
- package/dist/spine/index.d.ts.map +1 -0
- package/dist/spine/index.js +2 -0
- package/dist/spine/lib/BatchableSpineSlot.d.ts +59 -0
- package/dist/spine/lib/BatchableSpineSlot.d.ts.map +1 -0
- package/dist/spine/lib/BatchableSpineSlot.js +86 -0
- package/dist/spine/lib/Spine.d.ts +239 -0
- package/dist/spine/lib/Spine.d.ts.map +1 -0
- package/dist/spine/lib/Spine.js +628 -0
- package/dist/spine/lib/SpineDebugRenderer.d.ts +109 -0
- package/dist/spine/lib/SpineDebugRenderer.d.ts.map +1 -0
- package/dist/spine/lib/SpineDebugRenderer.js +474 -0
- package/dist/spine/lib/SpinePipe.d.ts +49 -0
- package/dist/spine/lib/SpinePipe.d.ts.map +1 -0
- package/dist/spine/lib/SpinePipe.js +148 -0
- package/dist/spine/lib/SpineTexture.d.ts +45 -0
- package/dist/spine/lib/SpineTexture.d.ts.map +1 -0
- package/dist/spine/lib/SpineTexture.js +114 -0
- package/dist/spine/lib/assets/atlasLoader.d.ts +34 -0
- package/dist/spine/lib/assets/atlasLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/atlasLoader.js +122 -0
- package/dist/spine/lib/assets/skeletonLoader.d.ts +30 -0
- package/dist/spine/lib/assets/skeletonLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/skeletonLoader.js +70 -0
- package/dist/spine/lib/darktint/DarkTintBatchGeometry.d.ts +33 -0
- package/dist/spine/lib/darktint/DarkTintBatchGeometry.d.ts.map +1 -0
- package/dist/spine/lib/darktint/DarkTintBatchGeometry.js +84 -0
- package/dist/spine/lib/darktint/DarkTintBatcher.d.ts +50 -0
- package/dist/spine/lib/darktint/DarkTintBatcher.d.ts.map +1 -0
- package/dist/spine/lib/darktint/DarkTintBatcher.js +131 -0
- package/dist/spine/lib/darktint/DarkTintShader.d.ts +33 -0
- package/dist/spine/lib/darktint/DarkTintShader.d.ts.map +1 -0
- package/dist/spine/lib/darktint/DarkTintShader.js +59 -0
- package/dist/spine/lib/darktint/darkTintBit.d.ts +51 -0
- package/dist/spine/lib/darktint/darkTintBit.d.ts.map +1 -0
- package/dist/spine/lib/darktint/darkTintBit.js +75 -0
- package/dist/spine/lib/index.d.ts +42 -0
- package/dist/spine/lib/index.d.ts.map +1 -0
- package/dist/spine/lib/index.js +41 -0
- package/dist/spine/lib/require-shim.d.ts +34 -0
- package/dist/spine/lib/require-shim.d.ts.map +1 -0
- package/dist/spine/lib/require-shim.js +38 -0
- package/package.json +12 -9
- package/dist/components/GUIComponent.d.ts.map +0 -1
- package/dist/components/GUIComponent.js +0 -126
- package/dist/components/RenderComponent.d.ts +0 -29
- package/dist/components/RenderComponent.d.ts.map +0 -1
- package/dist/components/RenderComponent.js +0 -58
- package/dist/systems/GUISystem.d.ts.map +0 -1
- package/dist/systems/GUISystem.js +0 -90
- package/dist/systems/RenderSystem.d.ts.map +0 -1
- package/dist/systems/RenderSystem.js +0 -67
- /package/dist/{systems → render}/RenderSystem.d.ts +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
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 { Container, Graphics } from 'pixi.js';
|
|
30
|
+
import { Spine } from './Spine.js';
|
|
31
|
+
import type { AnimationStateListener } from '@esotericsoftware/spine-core';
|
|
32
|
+
/**
|
|
33
|
+
* Make a class that extends from this interface to create your own debug renderer.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export interface ISpineDebugRenderer {
|
|
37
|
+
/**
|
|
38
|
+
* This will be called every frame, after the spine has been updated.
|
|
39
|
+
*/
|
|
40
|
+
renderDebug: (spine: Spine) => void;
|
|
41
|
+
/**
|
|
42
|
+
* This is called when the `spine.debug` object is set to null or when the spine is destroyed.
|
|
43
|
+
*/
|
|
44
|
+
unregisterSpine: (spine: Spine) => void;
|
|
45
|
+
/**
|
|
46
|
+
* This is called when the `spine.debug` object is set to a new instance of a debug renderer.
|
|
47
|
+
*/
|
|
48
|
+
registerSpine: (spine: Spine) => void;
|
|
49
|
+
}
|
|
50
|
+
type DebugDisplayObjects = {
|
|
51
|
+
bones: Container;
|
|
52
|
+
skeletonXY: Graphics;
|
|
53
|
+
regionAttachmentsShape: Graphics;
|
|
54
|
+
meshTrianglesLine: Graphics;
|
|
55
|
+
meshHullLine: Graphics;
|
|
56
|
+
clippingPolygon: Graphics;
|
|
57
|
+
boundingBoxesRect: Graphics;
|
|
58
|
+
boundingBoxesCircle: Graphics;
|
|
59
|
+
boundingBoxesPolygon: Graphics;
|
|
60
|
+
pathsCurve: Graphics;
|
|
61
|
+
pathsLine: Graphics;
|
|
62
|
+
parentDebugContainer: Container;
|
|
63
|
+
eventText: Container;
|
|
64
|
+
eventCallback: AnimationStateListener;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* This is a debug renderer that uses PixiJS Graphics under the hood.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare class SpineDebugRenderer implements ISpineDebugRenderer {
|
|
71
|
+
private readonly registeredSpines;
|
|
72
|
+
drawMeshHull: boolean;
|
|
73
|
+
drawMeshTriangles: boolean;
|
|
74
|
+
drawBones: boolean;
|
|
75
|
+
drawPaths: boolean;
|
|
76
|
+
drawBoundingBoxes: boolean;
|
|
77
|
+
drawClipping: boolean;
|
|
78
|
+
drawRegionAttachments: boolean;
|
|
79
|
+
drawEvents: boolean;
|
|
80
|
+
lineWidth: number;
|
|
81
|
+
regionAttachmentsColor: number;
|
|
82
|
+
meshHullColor: number;
|
|
83
|
+
meshTrianglesColor: number;
|
|
84
|
+
clippingPolygonColor: number;
|
|
85
|
+
boundingBoxesRectColor: number;
|
|
86
|
+
boundingBoxesPolygonColor: number;
|
|
87
|
+
boundingBoxesCircleColor: number;
|
|
88
|
+
pathsCurveColor: number;
|
|
89
|
+
pathsLineColor: number;
|
|
90
|
+
skeletonXYColor: number;
|
|
91
|
+
bonesColor: number;
|
|
92
|
+
eventFontSize: number;
|
|
93
|
+
eventFontColor: number;
|
|
94
|
+
/**
|
|
95
|
+
* The debug is attached by force to each spine object.
|
|
96
|
+
* So we need to create it inside the spine when we get the first update
|
|
97
|
+
*/
|
|
98
|
+
registerSpine(spine: Spine): void;
|
|
99
|
+
renderDebug(spine: Spine): void;
|
|
100
|
+
private drawBonesFunc;
|
|
101
|
+
private drawRegionAttachmentsFunc;
|
|
102
|
+
private drawMeshHullAndMeshTriangles;
|
|
103
|
+
drawClippingFunc(spine: Spine, debugDisplayObjects: DebugDisplayObjects, lineWidth: number): void;
|
|
104
|
+
drawBoundingBoxesFunc(spine: Spine, debugDisplayObjects: DebugDisplayObjects, lineWidth: number): void;
|
|
105
|
+
private drawPathsFunc;
|
|
106
|
+
unregisterSpine(spine: Spine): void;
|
|
107
|
+
}
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=SpineDebugRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpineDebugRenderer.d.ts","sourceRoot":"","sources":["../../../src/spine/lib/SpineDebugRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E;AAE/E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAQ,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEpC;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAExC;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtC;AAED,KAAK,mBAAmB,GAAG;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,QAAQ,CAAC;IACrB,sBAAsB,EAAE,QAAQ,CAAC;IACjC,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,YAAY,EAAE,QAAQ,CAAC;IACvB,eAAe,EAAE,QAAQ,CAAC;IAC1B,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,mBAAmB,EAAE,QAAQ,CAAC;IAC9B,oBAAoB,EAAE,QAAQ,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC;IACrB,SAAS,EAAE,QAAQ,CAAC;IACpB,oBAAoB,EAAE,SAAS,CAAC;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,sBAAsB,CAAC;CACtC,CAAC;AAEF;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IAC7D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA8C;IAExE,YAAY,UAAQ;IACpB,iBAAiB,UAAQ;IACzB,SAAS,UAAQ;IACjB,SAAS,UAAQ;IACjB,iBAAiB,UAAQ;IACzB,YAAY,UAAQ;IACpB,qBAAqB,UAAQ;IAC7B,UAAU,UAAQ;IAElB,SAAS,SAAK;IACd,sBAAsB,SAAY;IAClC,aAAa,SAAY;IACzB,kBAAkB,SAAY;IAC9B,oBAAoB,SAAY;IAChC,sBAAsB,SAAY;IAClC,yBAAyB,SAAY;IACrC,wBAAwB,SAAY;IACpC,eAAe,SAAY;IAC3B,cAAc,SAAY;IAC1B,eAAe,SAAY;IAC3B,UAAU,SAAY;IACtB,aAAa,SAAM;IACnB,cAAc,SAAO;IAE5B;;;OAGG;IACI,aAAa,CAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAyElC,WAAW,CAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IA+DvC,OAAO,CAAC,aAAa;IAyGrB,OAAO,CAAC,yBAAyB;IA2BjC,OAAO,CAAC,4BAA4B;IA4DpC,gBAAgB,CAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IA8BlG,qBAAqB,CAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAuDvG,OAAO,CAAC,aAAa;IAwEd,eAAe,CAAE,KAAK,EAAE,KAAK,GAAG,IAAI;CAe3C"}
|
|
@@ -0,0 +1,474 @@
|
|
|
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 { Container, Graphics, Text } from 'pixi.js';
|
|
30
|
+
import { ClippingAttachment, MeshAttachment, PathAttachment, RegionAttachment, SkeletonBounds } from '@esotericsoftware/spine-core';
|
|
31
|
+
/**
|
|
32
|
+
* This is a debug renderer that uses PixiJS Graphics under the hood.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export class SpineDebugRenderer {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.registeredSpines = new Map();
|
|
38
|
+
this.drawMeshHull = true;
|
|
39
|
+
this.drawMeshTriangles = true;
|
|
40
|
+
this.drawBones = true;
|
|
41
|
+
this.drawPaths = true;
|
|
42
|
+
this.drawBoundingBoxes = true;
|
|
43
|
+
this.drawClipping = true;
|
|
44
|
+
this.drawRegionAttachments = true;
|
|
45
|
+
this.drawEvents = true;
|
|
46
|
+
this.lineWidth = 1;
|
|
47
|
+
this.regionAttachmentsColor = 0x0078ff;
|
|
48
|
+
this.meshHullColor = 0x0078ff;
|
|
49
|
+
this.meshTrianglesColor = 0xffcc00;
|
|
50
|
+
this.clippingPolygonColor = 0xff00ff;
|
|
51
|
+
this.boundingBoxesRectColor = 0x00ff00;
|
|
52
|
+
this.boundingBoxesPolygonColor = 0x00ff00;
|
|
53
|
+
this.boundingBoxesCircleColor = 0x00ff00;
|
|
54
|
+
this.pathsCurveColor = 0xff0000;
|
|
55
|
+
this.pathsLineColor = 0xff00ff;
|
|
56
|
+
this.skeletonXYColor = 0xff0000;
|
|
57
|
+
this.bonesColor = 0x00eecc;
|
|
58
|
+
this.eventFontSize = 24;
|
|
59
|
+
this.eventFontColor = 0x0;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The debug is attached by force to each spine object.
|
|
63
|
+
* So we need to create it inside the spine when we get the first update
|
|
64
|
+
*/
|
|
65
|
+
registerSpine(spine) {
|
|
66
|
+
if (this.registeredSpines.has(spine)) {
|
|
67
|
+
console.warn('SpineDebugRenderer.registerSpine() - this spine is already registered!', spine);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const debugDisplayObjects = {
|
|
71
|
+
parentDebugContainer: new Container(),
|
|
72
|
+
bones: new Container(),
|
|
73
|
+
skeletonXY: new Graphics(),
|
|
74
|
+
regionAttachmentsShape: new Graphics(),
|
|
75
|
+
meshTrianglesLine: new Graphics(),
|
|
76
|
+
meshHullLine: new Graphics(),
|
|
77
|
+
clippingPolygon: new Graphics(),
|
|
78
|
+
boundingBoxesRect: new Graphics(),
|
|
79
|
+
boundingBoxesCircle: new Graphics(),
|
|
80
|
+
boundingBoxesPolygon: new Graphics(),
|
|
81
|
+
pathsCurve: new Graphics(),
|
|
82
|
+
pathsLine: new Graphics(),
|
|
83
|
+
eventText: new Container(),
|
|
84
|
+
eventCallback: {
|
|
85
|
+
event: (_, event) => {
|
|
86
|
+
if (this.drawEvents) {
|
|
87
|
+
const scale = Math.abs(spine.scale.x || spine.scale.y || 1);
|
|
88
|
+
const text = new Text({
|
|
89
|
+
text: event.data.name,
|
|
90
|
+
style: {
|
|
91
|
+
fontSize: this.eventFontSize / scale,
|
|
92
|
+
fill: this.eventFontColor,
|
|
93
|
+
fontFamily: 'monospace'
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
text.scale.x = Math.sign(spine.scale.x);
|
|
97
|
+
text.anchor.set(0.5);
|
|
98
|
+
debugDisplayObjects.eventText.addChild(text);
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
if (!text.destroyed) {
|
|
101
|
+
text.destroy();
|
|
102
|
+
}
|
|
103
|
+
}, 250);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.bones);
|
|
109
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.skeletonXY);
|
|
110
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.regionAttachmentsShape);
|
|
111
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.meshTrianglesLine);
|
|
112
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.meshHullLine);
|
|
113
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.clippingPolygon);
|
|
114
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesRect);
|
|
115
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesCircle);
|
|
116
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesPolygon);
|
|
117
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.pathsCurve);
|
|
118
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.pathsLine);
|
|
119
|
+
debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.eventText);
|
|
120
|
+
debugDisplayObjects.parentDebugContainer.zIndex = 9999999;
|
|
121
|
+
// Disable screen reader and mouse input on debug objects.
|
|
122
|
+
debugDisplayObjects.parentDebugContainer.accessibleChildren = false;
|
|
123
|
+
debugDisplayObjects.parentDebugContainer.eventMode = 'none';
|
|
124
|
+
debugDisplayObjects.parentDebugContainer.interactiveChildren = false;
|
|
125
|
+
spine.addChild(debugDisplayObjects.parentDebugContainer);
|
|
126
|
+
spine.state.addListener(debugDisplayObjects.eventCallback);
|
|
127
|
+
this.registeredSpines.set(spine, debugDisplayObjects);
|
|
128
|
+
}
|
|
129
|
+
renderDebug(spine) {
|
|
130
|
+
if (!this.registeredSpines.has(spine)) {
|
|
131
|
+
// This should never happen. Spines are registered when you assign spine.debug
|
|
132
|
+
this.registerSpine(spine);
|
|
133
|
+
}
|
|
134
|
+
const debugDisplayObjects = this.registeredSpines.get(spine);
|
|
135
|
+
if (!debugDisplayObjects) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
spine.addChild(debugDisplayObjects.parentDebugContainer);
|
|
139
|
+
debugDisplayObjects.skeletonXY.clear();
|
|
140
|
+
debugDisplayObjects.regionAttachmentsShape.clear();
|
|
141
|
+
debugDisplayObjects.meshTrianglesLine.clear();
|
|
142
|
+
debugDisplayObjects.meshHullLine.clear();
|
|
143
|
+
debugDisplayObjects.clippingPolygon.clear();
|
|
144
|
+
debugDisplayObjects.boundingBoxesRect.clear();
|
|
145
|
+
debugDisplayObjects.boundingBoxesCircle.clear();
|
|
146
|
+
debugDisplayObjects.boundingBoxesPolygon.clear();
|
|
147
|
+
debugDisplayObjects.pathsCurve.clear();
|
|
148
|
+
debugDisplayObjects.pathsLine.clear();
|
|
149
|
+
for (let len = debugDisplayObjects.bones.children.length; len > 0; len--) {
|
|
150
|
+
debugDisplayObjects.bones.children[len - 1].destroy({ children: true, texture: true, textureSource: true });
|
|
151
|
+
}
|
|
152
|
+
const scale = Math.abs(spine.scale.x || spine.scale.y || 1);
|
|
153
|
+
const lineWidth = this.lineWidth / scale;
|
|
154
|
+
if (this.drawBones) {
|
|
155
|
+
this.drawBonesFunc(spine, debugDisplayObjects, lineWidth, scale);
|
|
156
|
+
}
|
|
157
|
+
if (this.drawPaths) {
|
|
158
|
+
this.drawPathsFunc(spine, debugDisplayObjects, lineWidth);
|
|
159
|
+
}
|
|
160
|
+
if (this.drawBoundingBoxes) {
|
|
161
|
+
this.drawBoundingBoxesFunc(spine, debugDisplayObjects, lineWidth);
|
|
162
|
+
}
|
|
163
|
+
if (this.drawClipping) {
|
|
164
|
+
this.drawClippingFunc(spine, debugDisplayObjects, lineWidth);
|
|
165
|
+
}
|
|
166
|
+
if (this.drawMeshHull || this.drawMeshTriangles) {
|
|
167
|
+
this.drawMeshHullAndMeshTriangles(spine, debugDisplayObjects, lineWidth);
|
|
168
|
+
}
|
|
169
|
+
if (this.drawRegionAttachments) {
|
|
170
|
+
this.drawRegionAttachmentsFunc(spine, debugDisplayObjects, lineWidth);
|
|
171
|
+
}
|
|
172
|
+
if (this.drawEvents) {
|
|
173
|
+
for (const child of debugDisplayObjects.eventText.children) {
|
|
174
|
+
child.alpha -= 0.05;
|
|
175
|
+
child.y -= 2;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
drawBonesFunc(spine, debugDisplayObjects, lineWidth, scale) {
|
|
180
|
+
const skeleton = spine.skeleton;
|
|
181
|
+
const skeletonX = skeleton.x;
|
|
182
|
+
const skeletonY = skeleton.y;
|
|
183
|
+
const bones = skeleton.bones;
|
|
184
|
+
debugDisplayObjects.skeletonXY.strokeStyle = { width: lineWidth, color: this.skeletonXYColor };
|
|
185
|
+
for (let i = 0, len = bones.length; i < len; i++) {
|
|
186
|
+
const bone = bones[i];
|
|
187
|
+
const boneLen = bone.data.length;
|
|
188
|
+
const starX = skeletonX + bone.worldX;
|
|
189
|
+
const starY = skeletonY + bone.worldY;
|
|
190
|
+
const endX = skeletonX + (boneLen * bone.a) + bone.worldX;
|
|
191
|
+
const endY = skeletonY + (boneLen * bone.b) + bone.worldY;
|
|
192
|
+
if (bone.data.name === 'root' || bone.data.parent === null) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const w = Math.abs(starX - endX);
|
|
196
|
+
const h = Math.abs(starY - endY);
|
|
197
|
+
// a = w, // side length a
|
|
198
|
+
const a2 = Math.pow(w, 2); // square root of side length a
|
|
199
|
+
const b = h; // side length b
|
|
200
|
+
const b2 = Math.pow(h, 2); // square root of side length b
|
|
201
|
+
const c = Math.sqrt(a2 + b2); // side length c
|
|
202
|
+
const c2 = Math.pow(c, 2); // square root of side length c
|
|
203
|
+
const rad = Math.PI / 180;
|
|
204
|
+
// A = Math.acos([a2 + c2 - b2] / [2 * a * c]) || 0, // Angle A
|
|
205
|
+
// C = Math.acos([a2 + b2 - c2] / [2 * a * b]) || 0, // C angle
|
|
206
|
+
const B = Math.acos((c2 + b2 - a2) / (2 * b * c)) || 0; // angle of corner B
|
|
207
|
+
if (c === 0) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const gp = new Graphics();
|
|
211
|
+
debugDisplayObjects.bones.addChild(gp);
|
|
212
|
+
// draw bone
|
|
213
|
+
const refRation = c / 50 / scale;
|
|
214
|
+
gp.context
|
|
215
|
+
.poly([0, 0, 0 - refRation, c - (refRation * 3), 0, c - refRation, 0 + refRation, c - (refRation * 3)])
|
|
216
|
+
.fill(this.bonesColor);
|
|
217
|
+
gp.x = starX;
|
|
218
|
+
gp.y = starY;
|
|
219
|
+
gp.pivot.y = c;
|
|
220
|
+
// Calculate bone rotation angle
|
|
221
|
+
let rotation = 0;
|
|
222
|
+
if (starX < endX && starY < endY) {
|
|
223
|
+
// bottom right
|
|
224
|
+
rotation = -B + (180 * rad);
|
|
225
|
+
}
|
|
226
|
+
else if (starX > endX && starY < endY) {
|
|
227
|
+
// bottom left
|
|
228
|
+
rotation = (180 * rad) + B;
|
|
229
|
+
}
|
|
230
|
+
else if (starX > endX && starY > endY) {
|
|
231
|
+
// top left
|
|
232
|
+
rotation = -B;
|
|
233
|
+
}
|
|
234
|
+
else if (starX < endX && starY > endY) {
|
|
235
|
+
// bottom left
|
|
236
|
+
rotation = B;
|
|
237
|
+
}
|
|
238
|
+
else if (starY === endY && starX < endX) {
|
|
239
|
+
// To the right
|
|
240
|
+
rotation = 90 * rad;
|
|
241
|
+
}
|
|
242
|
+
else if (starY === endY && starX > endX) {
|
|
243
|
+
// go left
|
|
244
|
+
rotation = -90 * rad;
|
|
245
|
+
}
|
|
246
|
+
else if (starX === endX && starY < endY) {
|
|
247
|
+
// down
|
|
248
|
+
rotation = 180 * rad;
|
|
249
|
+
}
|
|
250
|
+
else if (starX === endX && starY > endY) {
|
|
251
|
+
// up
|
|
252
|
+
rotation = 0;
|
|
253
|
+
}
|
|
254
|
+
gp.rotation = rotation;
|
|
255
|
+
// Draw the starting rotation point of the bone
|
|
256
|
+
gp.circle(0, c, refRation * 1.2)
|
|
257
|
+
.fill({ color: 0x000000, alpha: 0.6 })
|
|
258
|
+
.stroke({ width: lineWidth + refRation / 2.4, color: this.bonesColor });
|
|
259
|
+
}
|
|
260
|
+
// Draw the skeleton starting point "X" form
|
|
261
|
+
const startDotSize = lineWidth * 3;
|
|
262
|
+
debugDisplayObjects.skeletonXY.context
|
|
263
|
+
.moveTo(skeletonX - startDotSize, skeletonY - startDotSize)
|
|
264
|
+
.lineTo(skeletonX + startDotSize, skeletonY + startDotSize)
|
|
265
|
+
.moveTo(skeletonX + startDotSize, skeletonY - startDotSize)
|
|
266
|
+
.lineTo(skeletonX - startDotSize, skeletonY + startDotSize)
|
|
267
|
+
.stroke();
|
|
268
|
+
}
|
|
269
|
+
drawRegionAttachmentsFunc(spine, debugDisplayObjects, lineWidth) {
|
|
270
|
+
const skeleton = spine.skeleton;
|
|
271
|
+
const slots = skeleton.slots;
|
|
272
|
+
for (let i = 0, len = slots.length; i < len; i++) {
|
|
273
|
+
const slot = slots[i];
|
|
274
|
+
const attachment = slot.getAttachment();
|
|
275
|
+
if (attachment === null || !(attachment instanceof RegionAttachment)) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const regionAttachment = attachment;
|
|
279
|
+
const vertices = new Float32Array(8);
|
|
280
|
+
regionAttachment.computeWorldVertices(slot, vertices, 0, 2);
|
|
281
|
+
debugDisplayObjects.regionAttachmentsShape.poly(Array.from(vertices.slice(0, 8)));
|
|
282
|
+
}
|
|
283
|
+
debugDisplayObjects.regionAttachmentsShape.stroke({
|
|
284
|
+
color: this.regionAttachmentsColor,
|
|
285
|
+
width: lineWidth
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
drawMeshHullAndMeshTriangles(spine, debugDisplayObjects, lineWidth) {
|
|
289
|
+
const skeleton = spine.skeleton;
|
|
290
|
+
const slots = skeleton.slots;
|
|
291
|
+
for (let i = 0, len = slots.length; i < len; i++) {
|
|
292
|
+
const slot = slots[i];
|
|
293
|
+
if (!slot.bone.active) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const attachment = slot.getAttachment();
|
|
297
|
+
if (attachment === null || !(attachment instanceof MeshAttachment)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const meshAttachment = attachment;
|
|
301
|
+
const vertices = new Float32Array(meshAttachment.worldVerticesLength);
|
|
302
|
+
const triangles = meshAttachment.triangles;
|
|
303
|
+
let hullLength = meshAttachment.hullLength;
|
|
304
|
+
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, vertices, 0, 2);
|
|
305
|
+
// draw the skinned mesh (triangle)
|
|
306
|
+
if (this.drawMeshTriangles) {
|
|
307
|
+
for (let i = 0, len = triangles.length; i < len; i += 3) {
|
|
308
|
+
const v1 = triangles[i] * 2;
|
|
309
|
+
const v2 = triangles[i + 1] * 2;
|
|
310
|
+
const v3 = triangles[i + 2] * 2;
|
|
311
|
+
debugDisplayObjects.meshTrianglesLine.context
|
|
312
|
+
.moveTo(vertices[v1], vertices[v1 + 1])
|
|
313
|
+
.lineTo(vertices[v2], vertices[v2 + 1])
|
|
314
|
+
.lineTo(vertices[v3], vertices[v3 + 1]);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// draw skin border
|
|
318
|
+
if (this.drawMeshHull && hullLength > 0) {
|
|
319
|
+
hullLength = (hullLength >> 1) * 2;
|
|
320
|
+
let lastX = vertices[hullLength - 2];
|
|
321
|
+
let lastY = vertices[hullLength - 1];
|
|
322
|
+
for (let i = 0, len = hullLength; i < len; i += 2) {
|
|
323
|
+
const x = vertices[i];
|
|
324
|
+
const y = vertices[i + 1];
|
|
325
|
+
debugDisplayObjects.meshHullLine.context
|
|
326
|
+
.moveTo(x, y)
|
|
327
|
+
.lineTo(lastX, lastY);
|
|
328
|
+
lastX = x;
|
|
329
|
+
lastY = y;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
debugDisplayObjects.meshHullLine.stroke({ width: lineWidth, color: this.meshHullColor });
|
|
334
|
+
debugDisplayObjects.meshTrianglesLine.stroke({ width: lineWidth, color: this.meshTrianglesColor });
|
|
335
|
+
}
|
|
336
|
+
drawClippingFunc(spine, debugDisplayObjects, lineWidth) {
|
|
337
|
+
const skeleton = spine.skeleton;
|
|
338
|
+
const slots = skeleton.slots;
|
|
339
|
+
for (let i = 0, len = slots.length; i < len; i++) {
|
|
340
|
+
const slot = slots[i];
|
|
341
|
+
if (!slot.bone.active) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const attachment = slot.getAttachment();
|
|
345
|
+
if (attachment === null || !(attachment instanceof ClippingAttachment)) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
const clippingAttachment = attachment;
|
|
349
|
+
const nn = clippingAttachment.worldVerticesLength;
|
|
350
|
+
const world = new Float32Array(nn);
|
|
351
|
+
clippingAttachment.computeWorldVertices(slot, 0, nn, world, 0, 2);
|
|
352
|
+
debugDisplayObjects.clippingPolygon.poly(Array.from(world));
|
|
353
|
+
}
|
|
354
|
+
debugDisplayObjects.clippingPolygon.stroke({
|
|
355
|
+
width: lineWidth, color: this.clippingPolygonColor, alpha: 1
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
drawBoundingBoxesFunc(spine, debugDisplayObjects, lineWidth) {
|
|
359
|
+
// draw the total outline of the bounding box
|
|
360
|
+
const bounds = new SkeletonBounds();
|
|
361
|
+
bounds.update(spine.skeleton, true);
|
|
362
|
+
if (bounds.minX !== Infinity) {
|
|
363
|
+
debugDisplayObjects.boundingBoxesRect
|
|
364
|
+
.rect(bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight())
|
|
365
|
+
.stroke({ width: lineWidth, color: this.boundingBoxesRectColor });
|
|
366
|
+
}
|
|
367
|
+
const polygons = bounds.polygons;
|
|
368
|
+
const drawPolygon = (polygonVertices, _offset, count) => {
|
|
369
|
+
if (count < 3) {
|
|
370
|
+
throw new Error('Polygon must contain at least 3 vertices');
|
|
371
|
+
}
|
|
372
|
+
const paths = [];
|
|
373
|
+
const dotSize = lineWidth * 2;
|
|
374
|
+
for (let i = 0, len = polygonVertices.length; i < len; i += 2) {
|
|
375
|
+
const x1 = polygonVertices[i];
|
|
376
|
+
const y1 = polygonVertices[i + 1];
|
|
377
|
+
// draw the bounding box node
|
|
378
|
+
debugDisplayObjects.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor);
|
|
379
|
+
debugDisplayObjects.boundingBoxesCircle.drawCircle(x1, y1, dotSize);
|
|
380
|
+
debugDisplayObjects.boundingBoxesCircle.fill(0);
|
|
381
|
+
debugDisplayObjects.boundingBoxesCircle
|
|
382
|
+
.circle(x1, y1, dotSize)
|
|
383
|
+
.fill({ color: this.boundingBoxesCircleColor });
|
|
384
|
+
paths.push(x1, y1);
|
|
385
|
+
}
|
|
386
|
+
// draw the bounding box area
|
|
387
|
+
debugDisplayObjects.boundingBoxesPolygon
|
|
388
|
+
.poly(paths)
|
|
389
|
+
.fill({
|
|
390
|
+
color: this.boundingBoxesPolygonColor,
|
|
391
|
+
alpha: 0.1
|
|
392
|
+
})
|
|
393
|
+
.stroke({
|
|
394
|
+
width: lineWidth,
|
|
395
|
+
color: this.boundingBoxesPolygonColor
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
for (let i = 0, len = polygons.length; i < len; i++) {
|
|
399
|
+
const polygon = polygons[i];
|
|
400
|
+
drawPolygon(polygon, 0, polygon.length);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
drawPathsFunc(spine, debugDisplayObjects, lineWidth) {
|
|
404
|
+
const skeleton = spine.skeleton;
|
|
405
|
+
const slots = skeleton.slots;
|
|
406
|
+
for (let i = 0, len = slots.length; i < len; i++) {
|
|
407
|
+
const slot = slots[i];
|
|
408
|
+
if (!slot.bone.active) {
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const attachment = slot.getAttachment();
|
|
412
|
+
if (attachment === null || !(attachment instanceof PathAttachment)) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
const pathAttachment = attachment;
|
|
416
|
+
let nn = pathAttachment.worldVerticesLength;
|
|
417
|
+
const world = new Float32Array(nn);
|
|
418
|
+
pathAttachment.computeWorldVertices(slot, 0, nn, world, 0, 2);
|
|
419
|
+
let x1 = world[2];
|
|
420
|
+
let y1 = world[3];
|
|
421
|
+
let x2 = 0;
|
|
422
|
+
let y2 = 0;
|
|
423
|
+
if (pathAttachment.closed) {
|
|
424
|
+
const cx1 = world[0];
|
|
425
|
+
const cy1 = world[1];
|
|
426
|
+
const cx2 = world[nn - 2];
|
|
427
|
+
const cy2 = world[nn - 1];
|
|
428
|
+
x2 = world[nn - 4];
|
|
429
|
+
y2 = world[nn - 3];
|
|
430
|
+
// curve
|
|
431
|
+
debugDisplayObjects.pathsCurve.moveTo(x1, y1);
|
|
432
|
+
debugDisplayObjects.pathsCurve.bezierCurveTo(cx1, cy1, cx2, cy2, x2, y2);
|
|
433
|
+
// handle
|
|
434
|
+
debugDisplayObjects.pathsLine.moveTo(x1, y1);
|
|
435
|
+
debugDisplayObjects.pathsLine.lineTo(cx1, cy1);
|
|
436
|
+
debugDisplayObjects.pathsLine.moveTo(x2, y2);
|
|
437
|
+
debugDisplayObjects.pathsLine.lineTo(cx2, cy2);
|
|
438
|
+
}
|
|
439
|
+
nn -= 4;
|
|
440
|
+
for (let ii = 4; ii < nn; ii += 6) {
|
|
441
|
+
const cx1 = world[ii];
|
|
442
|
+
const cy1 = world[ii + 1];
|
|
443
|
+
const cx2 = world[ii + 2];
|
|
444
|
+
const cy2 = world[ii + 3];
|
|
445
|
+
x2 = world[ii + 4];
|
|
446
|
+
y2 = world[ii + 5];
|
|
447
|
+
// curve
|
|
448
|
+
debugDisplayObjects.pathsCurve.moveTo(x1, y1);
|
|
449
|
+
debugDisplayObjects.pathsCurve.bezierCurveTo(cx1, cy1, cx2, cy2, x2, y2);
|
|
450
|
+
// handle
|
|
451
|
+
debugDisplayObjects.pathsLine.moveTo(x1, y1);
|
|
452
|
+
debugDisplayObjects.pathsLine.lineTo(cx1, cy1);
|
|
453
|
+
debugDisplayObjects.pathsLine.moveTo(x2, y2);
|
|
454
|
+
debugDisplayObjects.pathsLine.lineTo(cx2, cy2);
|
|
455
|
+
x1 = x2;
|
|
456
|
+
y1 = y2;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
debugDisplayObjects.pathsCurve.stroke({ width: lineWidth, color: this.pathsCurveColor });
|
|
460
|
+
debugDisplayObjects.pathsLine.stroke({ width: lineWidth, color: this.pathsLineColor });
|
|
461
|
+
}
|
|
462
|
+
unregisterSpine(spine) {
|
|
463
|
+
if (!this.registeredSpines.has(spine)) {
|
|
464
|
+
console.warn('SpineDebugRenderer.unregisterSpine() - spine is not registered, can\'t unregister!', spine);
|
|
465
|
+
}
|
|
466
|
+
const debugDisplayObjects = this.registeredSpines.get(spine);
|
|
467
|
+
if (!debugDisplayObjects) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
spine.state.removeListener(debugDisplayObjects.eventCallback);
|
|
471
|
+
debugDisplayObjects.parentDebugContainer.destroy({ textureSource: true, children: true, texture: true });
|
|
472
|
+
this.registeredSpines.delete(spine);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { ExtensionType, InstructionSet, type Renderer, type RenderPipe } from 'pixi.js';
|
|
30
|
+
import { Spine } from './Spine.js';
|
|
31
|
+
export declare class SpinePipe implements RenderPipe<Spine> {
|
|
32
|
+
/** @ignore */
|
|
33
|
+
static extension: {
|
|
34
|
+
readonly type: readonly [ExtensionType.WebGLPipes, ExtensionType.WebGPUPipes, ExtensionType.CanvasPipes];
|
|
35
|
+
readonly name: "spine";
|
|
36
|
+
};
|
|
37
|
+
renderer: Renderer;
|
|
38
|
+
private gpuSpineData;
|
|
39
|
+
private readonly _destroyRenderableBound;
|
|
40
|
+
constructor(renderer: Renderer);
|
|
41
|
+
validateRenderable(spine: Spine): boolean;
|
|
42
|
+
addRenderable(spine: Spine, instructionSet: InstructionSet): void;
|
|
43
|
+
updateRenderable(spine: Spine): void;
|
|
44
|
+
destroyRenderable(spine: Spine): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
private _getSpineData;
|
|
47
|
+
private _initMeshData;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=SpinePipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpinePipe.d.ts","sourceRoot":"","sources":["../../../src/spine/lib/SpinePipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E;AAE/E,OAAO,EAEM,aAAa,EACzB,cAAc,EAGd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAanC,qBAAa,SAAU,YAAW,UAAU,CAAC,KAAK,CAAC;IAClD,cAAc;IACd,MAAM,CAAC,SAAS;;;MAOL;IAEX,QAAQ,EAAE,QAAQ,CAAC;IAEnB,OAAO,CAAC,YAAY,CAA2C;IAC/D,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAwE;gBAEnG,QAAQ,EAAE,QAAQ;IAI/B,kBAAkB,CAAE,KAAK,EAAE,KAAK,GAAG,OAAO;IAoC1C,aAAa,CAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc;IA+C3D,gBAAgB,CAAE,KAAK,EAAE,KAAK;IA0B9B,iBAAiB,CAAE,KAAK,EAAE,KAAK;IAK/B,OAAO;IAKP,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;CAKrB"}
|