@galacean/engine-spine 1.2.0 → 2.0.0-alpha.52

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 (88) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +158 -44
  3. package/dist/browser.js +2139 -1
  4. package/dist/browser.js.map +1 -0
  5. package/dist/browser.min.js +2 -0
  6. package/dist/browser.min.js.map +1 -0
  7. package/dist/main.js +2134 -1
  8. package/dist/main.js.map +1 -1
  9. package/dist/module.js +2117 -1
  10. package/dist/module.js.map +1 -1
  11. package/package.json +30 -55
  12. package/types/SpineAnimation.d.ts +4 -44
  13. package/types/SpineAnimationState.d.ts +32 -0
  14. package/types/SpineAnimationStateData.d.ts +10 -0
  15. package/types/SpineAnimationStateListener.d.ts +20 -0
  16. package/types/SpineBone.d.ts +28 -0
  17. package/types/SpineConstant.d.ts +12 -0
  18. package/types/SpinePhysics.d.ts +17 -0
  19. package/types/SpinePhysicsConstraint.d.ts +22 -0
  20. package/types/SpineSkeleton.d.ts +31 -0
  21. package/types/SpineSkeletonData.d.ts +18 -0
  22. package/types/SpineSkin.d.ts +7 -0
  23. package/types/SpineSlot.d.ts +13 -0
  24. package/types/SpineTrackEntry.d.ts +44 -0
  25. package/types/enums/SpineBlendMode.d.ts +14 -0
  26. package/types/index.d.ts +15 -9
  27. package/types/loader/LoaderUtils.d.ts +1 -0
  28. package/types/loader/SpineLoader.d.ts +21 -0
  29. package/types/loader/SpineResource.d.ts +37 -0
  30. package/types/loader/SpineVersion.d.ts +2 -0
  31. package/types/loader/index.d.ts +2 -0
  32. package/types/renderer/SpineAnimationRenderer.d.ts +142 -0
  33. package/types/renderer/SpineGeometry.d.ts +1 -0
  34. package/types/renderer/SpineMaterial.d.ts +10 -0
  35. package/types/renderer/index.d.ts +2 -0
  36. package/types/runtime/ISpineRuntime.d.ts +4 -0
  37. package/types/AntGSpineLoader.d.ts +0 -22
  38. package/types/SpineLoader.d.ts +0 -32
  39. package/types/SpineMaterial.d.ts +0 -6
  40. package/types/SpineRenderer.d.ts +0 -38
  41. package/types/core/MeshGenerator.d.ts +0 -43
  42. package/types/core/SpineMesh.d.ts +0 -11
  43. package/types/spine-core/Animation.d.ts +0 -378
  44. package/types/spine-core/AnimationState.d.ts +0 -365
  45. package/types/spine-core/AnimationStateData.d.ts +0 -23
  46. package/types/spine-core/AssetManager.d.ts +0 -36
  47. package/types/spine-core/AtlasAttachmentLoader.d.ts +0 -23
  48. package/types/spine-core/BlendMode.d.ts +0 -7
  49. package/types/spine-core/Bone.d.ts +0 -110
  50. package/types/spine-core/BoneData.d.ts +0 -44
  51. package/types/spine-core/ConstraintData.d.ts +0 -7
  52. package/types/spine-core/Event.d.ts +0 -16
  53. package/types/spine-core/EventData.d.ts +0 -13
  54. package/types/spine-core/IkConstraint.d.ts +0 -38
  55. package/types/spine-core/IkConstraintData.d.ts +0 -26
  56. package/types/spine-core/PathConstraint.d.ts +0 -46
  57. package/types/spine-core/PathConstraintData.d.ts +0 -52
  58. package/types/spine-core/SharedAssetManager.d.ts +0 -19
  59. package/types/spine-core/Skeleton.d.ts +0 -134
  60. package/types/spine-core/SkeletonBinary.d.ts +0 -49
  61. package/types/spine-core/SkeletonBounds.d.ts +0 -48
  62. package/types/spine-core/SkeletonClipping.d.ts +0 -22
  63. package/types/spine-core/SkeletonData.d.ts +0 -89
  64. package/types/spine-core/SkeletonJson.d.ts +0 -34
  65. package/types/spine-core/Skin.d.ts +0 -43
  66. package/types/spine-core/Slot.d.ts +0 -42
  67. package/types/spine-core/SlotData.d.ts +0 -23
  68. package/types/spine-core/Texture.d.ts +0 -46
  69. package/types/spine-core/TextureAtlas.d.ts +0 -30
  70. package/types/spine-core/TransformConstraint.d.ts +0 -36
  71. package/types/spine-core/TransformConstraintData.d.ts +0 -34
  72. package/types/spine-core/Triangulator.d.ts +0 -14
  73. package/types/spine-core/Updatable.d.ts +0 -9
  74. package/types/spine-core/Utils.d.ts +0 -124
  75. package/types/spine-core/VertexEffect.d.ts +0 -7
  76. package/types/spine-core/attachments/Attachment.d.ts +0 -43
  77. package/types/spine-core/attachments/AttachmentLoader.d.ts +0 -25
  78. package/types/spine-core/attachments/AttachmentType.d.ts +0 -9
  79. package/types/spine-core/attachments/BoundingBoxAttachment.d.ts +0 -12
  80. package/types/spine-core/attachments/ClippingAttachment.d.ts +0 -14
  81. package/types/spine-core/attachments/MeshAttachment.d.ts +0 -46
  82. package/types/spine-core/attachments/PathAttachment.d.ts +0 -19
  83. package/types/spine-core/attachments/PointAttachment.d.ts +0 -20
  84. package/types/spine-core/attachments/RegionAttachment.d.ts +0 -88
  85. package/types/spine-core/polyfills.d.ts +0 -3
  86. package/types/spine-core/vertexeffects/JitterEffect.d.ts +0 -11
  87. package/types/spine-core/vertexeffects/SwirlEffect.d.ts +0 -16
  88. package/types/types.d.ts +0 -4
@@ -0,0 +1,142 @@
1
+ import { SpineSkeleton } from "../SpineSkeleton";
2
+ import { SpineSlot } from "../SpineSlot";
3
+ import { SpineAnimationState } from "../SpineAnimationState";
4
+ import type { SpinePhysicsSupport } from "../SpinePhysics";
5
+ import { Material, Renderer, Signal } from "@galacean/engine";
6
+ import { SpineResource } from "../loader/SpineResource";
7
+ /**
8
+ * Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
9
+ */
10
+ export declare class SpineAnimationRenderer extends Renderer {
11
+ private static _defaultMaterials;
12
+ private static _textureProperty;
13
+ private static _sourceColorProperty;
14
+ private static _destinationColorProperty;
15
+ private static _sourceAlphaProperty;
16
+ private static _destinationAlphaProperty;
17
+ private static _positionVertexElement;
18
+ private static _lightColorVertexElement;
19
+ private static _uvVertexElement;
20
+ private static _darkColorVertexElement;
21
+ /** Called after time advances, before animations are applied. Use to prepare the base pose. */
22
+ readonly onBeforeApply: Signal<[SpineAnimationRenderer]>;
23
+ /** Called after animations are applied, before world transforms are solved. Use to edit local bone values. */
24
+ readonly onUpdateLocal: Signal<[SpineAnimationRenderer]>;
25
+ /**
26
+ * Called with evaluated world transforms, before the final constraint and physics solve.
27
+ * Use to edit local bone values based on world values. A listener enables an additional pose solve;
28
+ * physics simulation still advances only once per update.
29
+ */
30
+ readonly onUpdateWorld: Signal<[SpineAnimationRenderer]>;
31
+ /** Called after the final bone transforms are solved, before geometry is built. Use to read the final pose. */
32
+ readonly onUpdateComplete: Signal<[SpineAnimationRenderer]>;
33
+ /**
34
+ * Time multiplier for both animation playback and skeleton physics. Defaults to 1.
35
+ * Zero stops time advancement while still applying the pose and rendering.
36
+ * AnimationState and TrackEntry time scales multiply animation time independently.
37
+ */
38
+ timeScale: number;
39
+ /**
40
+ * The spacing between z layers in world units.
41
+ */
42
+ zSpacing: number;
43
+ private _tintBlack;
44
+ /**
45
+ * Whether to enable tint black feature for dark color tinting.
46
+ *
47
+ * @remarks Should be enabled when using "Tint Black" feature in Spine editor.
48
+ */
49
+ get tintBlack(): boolean;
50
+ set tintBlack(value: boolean);
51
+ /**
52
+ * Default state for spine animation.
53
+ * Contains the default animation name to be played, whether this animation should loop, the default skin name.
54
+ */
55
+ readonly defaultConfig: SpineAnimationDefaultConfig;
56
+ private _slotMaterials;
57
+ private _slotMaterialsDirty;
58
+ private _geometry;
59
+ private _batchShaderData;
60
+ private _skeleton;
61
+ private _state;
62
+ private _runtime;
63
+ private _physics;
64
+ private _publicSkeleton;
65
+ private _publicState;
66
+ /** Physics support for the bound skeleton, or null before an asset is assigned. */
67
+ get physics(): SpinePhysicsSupport | null;
68
+ /**
69
+ * The animation playback state of this renderer.
70
+ * Manage, blend, and transition between multiple simultaneous animations effectively.
71
+ */
72
+ get state(): SpineAnimationState;
73
+ /**
74
+ * The skeleton pose of this renderer.
75
+ * Manipulate bone positions, rotations, scaling
76
+ * and change spine attachment to customize character appearances dynamically during runtime.
77
+ */
78
+ get skeleton(): SpineSkeleton;
79
+ /** Set the default material used by slots without an override. */
80
+ setMaterial(material: Material | null): void;
81
+ /** Set a renderer material by index. Spine uses index 0 as its default material. */
82
+ setMaterial(index: number, material: Material | null): void;
83
+ /** Override a slot's material, or pass null to restore the renderer's default material. */
84
+ setMaterial(slot: SpineSlot, material: Material | null): void;
85
+ getMaterial(): Material | null;
86
+ getMaterial(index: number): Material | null;
87
+ /** Get a slot's effective material, including the renderer's default when no override is set. */
88
+ getMaterial(slot: SpineSlot): Material | null;
89
+ private _isCurrentState;
90
+ private _uploadGeometry;
91
+ private _getSlotIndex;
92
+ private _clearSlotMaterials;
93
+ private _buildGeometry;
94
+ private _clearBatchTextures;
95
+ private _setBatchBlend;
96
+ private _applyDefaultConfig;
97
+ /**
98
+ * Spine resource of this renderer, or null when unbound.
99
+ */
100
+ get resource(): SpineResource | null;
101
+ /**
102
+ * Bind a Spine resource, or assign null to clear its pose and playback.
103
+ *
104
+ * @param value - The resource to use, or null to unbind
105
+ */
106
+ set resource(value: SpineResource | null);
107
+ }
108
+ /**
109
+ * Default state for spine animation.
110
+ * Contains the default animation name to be played, whether this animation should loop,
111
+ * the default skin name, and the default scale of the skeleton.
112
+ */
113
+ export declare class SpineAnimationDefaultConfig {
114
+ /**
115
+ * Whether the default animation should loop @defaultValue `true. The default animation should loop`
116
+ */
117
+ loop: boolean;
118
+ /**
119
+ * The name of the default animation @defaultValue `null. Do not play any animation by default`
120
+ */
121
+ animationName: string | null;
122
+ /**
123
+ * The name of the default skin @defaultValue `default`
124
+ */
125
+ skinName: string;
126
+ /**
127
+ * Creates an instance of default config
128
+ */
129
+ constructor(
130
+ /**
131
+ * Whether the default animation should loop @defaultValue `true. The default animation should loop`
132
+ */
133
+ loop?: boolean,
134
+ /**
135
+ * The name of the default animation @defaultValue `null. Do not play any animation by default`
136
+ */
137
+ animationName?: string | null,
138
+ /**
139
+ * The name of the default skin @defaultValue `default`
140
+ */
141
+ skinName?: string);
142
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { Engine, Material, Shader } from "@galacean/engine";
2
+ /**
3
+ * Material for Spine rendering. Defaults to the built-in `2D/Spine` shader.
4
+ * Texture and blend inputs are supplied per draw batch; tint is a renderer input.
5
+ * Inputs use straight alpha; the shader premultiplies its final linear output for the supplied blend factors.
6
+ */
7
+ export declare class SpineMaterial extends Material {
8
+ constructor(engine: Engine, shader?: Shader);
9
+ clone(): SpineMaterial;
10
+ }
@@ -0,0 +1,2 @@
1
+ export { SpineAnimationRenderer } from "./SpineAnimationRenderer";
2
+ export { SpineMaterial } from "./SpineMaterial";
@@ -0,0 +1,4 @@
1
+ import type { ISpineRuntime as ISpineRuntimeContract } from "@galacean/engine-design";
2
+ import type { Texture2D } from "@galacean/engine";
3
+ /** Backend contract specialized for engine textures. */
4
+ export type ISpineRuntime = ISpineRuntimeContract<Texture2D>;
@@ -1,22 +0,0 @@
1
- import { AssetPromise, Loader, LoadItem, ResourceManager, TextureWrapMode, Texture2D, Engine, Entity } from '@galacean/engine';
2
- import { AssetManager } from './spine-core/AssetManager';
3
- import { Texture } from './spine-core/Texture';
4
- type SpineOpt = {
5
- scale: number;
6
- };
7
- type SpineLoadItem = LoadItem & SpineOpt;
8
- declare class SpineLoader extends Loader<Entity> {
9
- load(item: SpineLoadItem, resourceManager: ResourceManager): AssetPromise<Entity>;
10
- textureAssetPicker(assetManager: AssetManager, textureFile: string): any;
11
- createAdaptiveTexture(img: any, engine: any): AdaptiveTexture;
12
- checkUrl(url: string): boolean;
13
- getExtFromUrl(url: string): string;
14
- }
15
- export declare class AdaptiveTexture extends Texture {
16
- texture: Texture2D;
17
- constructor(data: HTMLImageElement, engine: Engine);
18
- setFilters(minFilter: any, magFilter: any): void;
19
- setWraps(uWrap: TextureWrapMode, vWrap: TextureWrapMode): void;
20
- dispose(): void;
21
- }
22
- export { SpineLoader };
@@ -1,32 +0,0 @@
1
- import { AssetPromise, Loader, LoadItem, ResourceManager, TextureWrapMode, Texture2D, Entity, AssetType } from "@galacean/engine";
2
- import { AssetManager } from "./spine-core/AssetManager";
3
- import { Texture } from "./spine-core/Texture";
4
- type SpineResouce = {
5
- skeletonFile: string;
6
- atlasFile: string;
7
- textureFile?: string;
8
- textureType?: AssetType;
9
- };
10
- type SpineOpt = {
11
- scale: number;
12
- };
13
- type SpineLoadItem = LoadItem & SpineOpt;
14
- declare class SpineLoader extends Loader<Entity> {
15
- load(item: SpineLoadItem, resourceManager: ResourceManager): AssetPromise<Entity>;
16
- handleResource(resourceManager: ResourceManager, item: SpineLoadItem, resource: SpineResouce, resolve: any, reject: any): void;
17
- textureAssetPicker(assetManager: AssetManager, textureFile: string): any;
18
- createAdaptiveTexture(texture: Texture2D): AdaptiveTexture;
19
- isBinFile(url: string): boolean;
20
- checkUrl(url: string): boolean;
21
- getResouceFromUrl(url: any): SpineResouce;
22
- checkUrls(urls: string[]): boolean;
23
- getResouceFromUrls(urls: string[], type?: AssetType): SpineResouce;
24
- getExtFromUrl(url: string): string;
25
- }
26
- export declare class AdaptiveTexture extends Texture {
27
- constructor(texture: Texture2D);
28
- setFilters(minFilter: any, magFilter: any): void;
29
- setWraps(uWrap: TextureWrapMode, vWrap: TextureWrapMode): void;
30
- dispose(): void;
31
- }
32
- export { SpineLoader };
@@ -1,6 +0,0 @@
1
- import { Engine, Material } from "@galacean/engine";
2
- export declare class SpineMaterial extends Material {
3
- private static _spineVS;
4
- private static _spineFS;
5
- constructor(engine: Engine);
6
- }
@@ -1,38 +0,0 @@
1
- import { Script, Entity } from "@galacean/engine";
2
- import { SpineAnimation } from "./SpineAnimation";
3
- export declare class SpineRenderer extends Script {
4
- private _priority;
5
- private _resource;
6
- private _animationName;
7
- private _loop;
8
- private _paused;
9
- private _autoPlay;
10
- private _skinName;
11
- private _scale;
12
- private _spineAnimation;
13
- /** @internal */
14
- _animationNames: Array<string>;
15
- /** @internal */
16
- _skinNames: Array<string>;
17
- get priority(): number;
18
- set priority(value: number);
19
- get resource(): Entity | null;
20
- set resource(value: Entity | null);
21
- get animationName(): string;
22
- set animationName(name: string);
23
- get loop(): boolean;
24
- set loop(value: boolean);
25
- get paused(): boolean;
26
- set paused(value: boolean);
27
- get autoPlay(): boolean;
28
- set autoPlay(value: boolean);
29
- get skinName(): string;
30
- set skinName(name: string);
31
- get scale(): number;
32
- set scale(value: number);
33
- get spineAnimation(): SpineAnimation;
34
- onDestroy(): void;
35
- play(name?: string, loop?: boolean): void;
36
- _cloneTo(target: SpineRenderer): void;
37
- private _removeResource;
38
- }
@@ -1,43 +0,0 @@
1
- import { Engine, Entity, SubMesh, Texture2D } from "@galacean/engine";
2
- import { Skeleton } from "../spine-core/Skeleton";
3
- import { SkeletonData } from "../spine-core/SkeletonData";
4
- import { Color } from "../spine-core/Utils";
5
- import { SpineRenderSetting } from "../types";
6
- import { BlendMode } from "../spine-core/BlendMode";
7
- type SubMeshItem = {
8
- subMesh: SubMesh;
9
- blendMode: BlendMode;
10
- texture: any;
11
- slotName?: string;
12
- };
13
- export declare class MeshGenerator {
14
- static QUAD_TRIANGLES: number[];
15
- static VERTEX_SIZE: number;
16
- static VERTEX_STRIDE: number;
17
- static tempColor: Color;
18
- static tempBlendMode: BlendMode | null;
19
- private _setting;
20
- private _engine;
21
- private _entity;
22
- private _clipper;
23
- private _spineMesh;
24
- private _vertexCount;
25
- private _vertices;
26
- private _verticesWithZ;
27
- private _indices;
28
- private _needResize;
29
- private _meshRenderer;
30
- private _subMeshItems;
31
- readonly separateSlots: string[];
32
- readonly separateSlotTextureMap: Map<string, Texture2D>;
33
- get mesh(): import("@galacean/engine").BufferMesh;
34
- get subMeshItems(): SubMeshItem[];
35
- constructor(engine: Engine, entity: Entity);
36
- initialize(skeletonData: SkeletonData, setting?: SpineRenderSetting): void;
37
- buildMesh(skeleton: Skeleton): void;
38
- addSeparateSlot(slotName: string): void;
39
- addSeparateSlotTexture(slotName: string, texture: Texture2D): void;
40
- private _prepareBufferData;
41
- private setBlendMode;
42
- }
43
- export {};
@@ -1,11 +0,0 @@
1
- import { BufferMesh, Engine, Buffer } from '@galacean/engine';
2
- export declare class SpineMesh {
3
- private _mesh;
4
- private _indexBuffer;
5
- private _vertexBuffer;
6
- get mesh(): BufferMesh;
7
- get indexBuffer(): Buffer;
8
- get vertexBuffer(): Buffer;
9
- initialize(engine: Engine, vertexCount: number): void;
10
- changeBuffer(engine: Engine, vertexCount: number): void;
11
- }