@galacean/engine-spine 0.0.0-experimental-engine-spine-20241117 → 0.0.0-experimental-engine-spine-caifu.0

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/package.json CHANGED
@@ -1,69 +1,69 @@
1
1
  {
2
- "version": "0.0.0-experimental-engine-spine-20241117",
2
+ "version": "0.0.0-experimental-engine-spine-caifu.0",
3
3
  "description": "galacean spine runtime",
4
4
  "name": "@galacean/engine-spine",
5
5
  "main": "dist/main.js",
6
6
  "browser": "dist/browser.js",
7
7
  "module": "dist/module.js",
8
8
  "dependencies": {
9
- "@esotericsoftware/spine-core": "~4.2.1"
9
+ "@esotericsoftware/spine-core": "~4.2.66"
10
10
  },
11
11
  "peerDependencies": {
12
- "@galacean/engine": ">=1.3.20"
12
+ "@galacean/engine": ">=1.3.0-alpha.0"
13
13
  },
14
14
  "devDependencies": {
15
- "@babel/core": "^7.22.5",
16
- "@babel/plugin-proposal-class-properties": "^7.12.1",
17
- "@babel/plugin-proposal-decorators": "^7.12.1",
18
- "@babel/plugin-proposal-optional-chaining": "^7.12.1",
19
- "@babel/plugin-transform-class-properties": "^7.24.7",
20
- "@babel/plugin-transform-object-assign": "^7.12.1",
21
- "@babel/preset-env": "^7.24.8",
22
- "@babel/preset-typescript": "^7.24.7",
23
- "@galacean/engine": "^1.3.0-alpha.3",
15
+ "@babel/core": "^7.26.0",
16
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
17
+ "@babel/plugin-proposal-decorators": "^7.25.9",
18
+ "@babel/plugin-proposal-optional-chaining": "^7.21.0",
19
+ "@babel/plugin-transform-class-properties": "^7.25.9",
20
+ "@babel/plugin-transform-object-assign": "^7.25.9",
21
+ "@babel/preset-env": "^7.26.0",
22
+ "@babel/preset-typescript": "^7.26.0",
23
+ "@galacean/engine": "^1.3.11",
24
24
  "@galacean/engine-toolkit": "beta",
25
- "@rollup/plugin-babel": "^5.2.1",
25
+ "@rollup/plugin-babel": "^5.3.1",
26
26
  "@rollup/plugin-commonjs": "^16.0.0",
27
- "@rollup/plugin-inject": "^4.0.2",
27
+ "@rollup/plugin-inject": "^4.0.4",
28
28
  "@rollup/plugin-node-resolve": "^10.0.0",
29
- "@rollup/plugin-replace": "^2.3.4",
30
- "@rollup/plugin-terser": "^0.4.3",
31
- "@swc/core": "^1.3.32",
32
- "@swc/helpers": "^0.5",
33
- "@types/chai": "^4.3.16",
34
- "@types/jest": "^29.5.12",
35
- "@types/node": "^20.14.10",
36
- "@vitejs/plugin-basic-ssl": "^1.1.0",
29
+ "@rollup/plugin-replace": "^2.4.2",
30
+ "@rollup/plugin-terser": "^0.4.4",
31
+ "@swc/core": "^1.9.3",
32
+ "@swc/helpers": "^0.5.15",
33
+ "@types/chai": "^4.3.20",
34
+ "@types/jest": "^29.5.14",
35
+ "@types/node": "^20.17.9",
36
+ "@vitejs/plugin-basic-ssl": "^1.2.0",
37
37
  "babel-core": "^6.26.3",
38
38
  "babel-jest": "^29.7.0",
39
- "chai": "^4.3.6",
40
- "chai-spies": "^1.0.0",
39
+ "chai": "^4.5.0",
40
+ "chai-spies": "^1.1.0",
41
41
  "cross-env": "^5.2.1",
42
- "cypress": "^13.13.0",
42
+ "cypress": "^13.16.0",
43
43
  "cypress-recurse": "^1.35.3",
44
44
  "dat.gui": "^0.7.9",
45
45
  "jest": "^29.7.0",
46
46
  "jest-environment-jsdom": "^29.7.0",
47
47
  "jest-webgl-canvas-mock": "^2.5.3",
48
- "nock": "^13.5.4",
49
- "odiff-bin": "^3.0.1",
48
+ "nock": "^13.5.6",
49
+ "odiff-bin": "^3.2.0",
50
50
  "react": "^16.14.0",
51
51
  "react-dom": "^16.14.0",
52
52
  "regenerator-runtime": "^0.14.1",
53
- "rollup": "^2.32.0",
54
- "rollup-plugin-glslify": "^1.2.0",
53
+ "rollup": "^2.79.2",
54
+ "rollup-plugin-glslify": "^1.3.1",
55
55
  "rollup-plugin-modify": "^3.0.0",
56
- "rollup-plugin-serve": "^1.1.0",
57
- "rollup-plugin-swc3": "^0.8.0",
56
+ "rollup-plugin-serve": "^1.1.1",
57
+ "rollup-plugin-swc3": "^0.8.2",
58
58
  "rollup-plugin-terser": "^7.0.2",
59
59
  "rollup-plugin-version-injector": "^1.3.3",
60
- "sass": "^1.77.8",
61
- "sinon": "^18.0.0",
62
- "ts-jest": "^29.2.2",
60
+ "sass": "^1.81.1",
61
+ "sinon": "^18.0.1",
62
+ "ts-jest": "^29.2.5",
63
63
  "ts-node": "^10.9.2",
64
64
  "tsconfig-paths": "^4.2.0",
65
- "typescript": "^5.5.3",
66
- "vite": "^5.3.4"
65
+ "typescript": "^5.7.2",
66
+ "vite": "^5.4.11"
67
67
  },
68
68
  "ci": {
69
69
  "type": "aci",
@@ -1,6 +1,6 @@
1
- import { Skeleton, AnimationState } from "@esotericsoftware/spine-core";
1
+ import { Skeleton, SkeletonData, AnimationState, AnimationStateData } from "@esotericsoftware/spine-core";
2
2
  import { Buffer, Renderer, Entity, Material, Engine, BoundingBox, Primitive, SubPrimitive } from "@galacean/engine";
3
- import { SpineResource } from "./loader/SpineResource";
3
+ import { SkeletonDataResource } from "./loader/SkeletonDataResource";
4
4
  /**
5
5
  * Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
6
6
  */
@@ -13,20 +13,17 @@ export declare class SpineAnimationRenderer extends Renderer {
13
13
  /** @internal */
14
14
  static _materialCache: Map<string, Material>;
15
15
  /** @internal */
16
+ static _animationDataCache: Map<SkeletonData, AnimationStateData>;
17
+ /** @internal */
16
18
  static _getDefaultMaterial(engine: Engine): Material;
17
- /**
18
- * The spacing between z layers.
19
- */
20
- zSpacing: number;
21
- /**
22
- * Whether to premultiplied alpha for texture.
23
- */
24
- premultipliedAlpha: boolean;
19
+ /** Render setting for spine rendering. */
20
+ setting: SpineRenderSetting;
25
21
  /**
26
22
  * Default state for spine animation.
27
- * Contains the default animation name to be played, whether this animation should loop, the default skin name.
23
+ * Contains the default animation name to be played, whether this animation should loop,
24
+ * the default skin name, and the default scale of the skeleton.
28
25
  */
29
- readonly defaultConfig: SpineAnimationDefaultConfig;
26
+ defaultState: DefaultState;
30
27
  /** @internal */
31
28
  _primitive: Primitive;
32
29
  /** @internal */
@@ -44,18 +41,22 @@ export declare class SpineAnimationRenderer extends Renderer {
44
41
  /** @internal */
45
42
  _vertexCount: number;
46
43
  /** @internal */
47
- _resource: SpineResource;
44
+ _resource: SkeletonDataResource;
48
45
  private _skeleton;
49
46
  private _state;
50
- private _needsInitialize;
51
47
  /**
52
- * The Spine.AnimationState object of this SpineAnimationRenderer.
53
- * Manage, blend, and transition between multiple simultaneous animations effectively.
48
+ * Spine resource of current spine animation.This property allows you to switch between different animations at runtime.
49
+ */
50
+ get resource(): SkeletonDataResource;
51
+ set resource(value: SkeletonDataResource);
52
+ /**
53
+ * Provides access to `AnimationState` which controls animation playback on a skeleton.
54
+ * You can use its API to manage, blend, and transition between multiple simultaneous animations effectively.
54
55
  */
55
56
  get state(): AnimationState;
56
57
  /**
57
- * The Spine.Skeleton object of this SpineAnimationRenderer.
58
- * Manipulate bone positions, rotations, scaling
58
+ * Provides access to `Skeleton`, which defines the structure of a Spine model.
59
+ * Through its API, users can manipulate bone positions, rotations, scaling
59
60
  * and change spine attachment to customize character appearances dynamically during runtime.
60
61
  */
61
62
  get skeleton(): Skeleton;
@@ -63,6 +64,10 @@ export declare class SpineAnimationRenderer extends Renderer {
63
64
  * @internal
64
65
  */
65
66
  constructor(entity: Entity);
67
+ /**
68
+ * Separate slot by slot name. This will add a new sub primitive, and new materials.
69
+ */
70
+ addSeparateSlot(slotName: string): void;
66
71
  /**
67
72
  * @internal
68
73
  */
@@ -83,14 +88,6 @@ export declare class SpineAnimationRenderer extends Renderer {
83
88
  * @internal
84
89
  */
85
90
  _calculateGeneratorBounds(worldBounds: BoundingBox): void;
86
- /**
87
- * @internal
88
- */
89
- _setSkeleton(skeleton: Skeleton): void;
90
- /**
91
- * @internal
92
- */
93
- _setState(state: AnimationState): void;
94
91
  /**
95
92
  * @internal
96
93
  */
@@ -102,7 +99,7 @@ export declare class SpineAnimationRenderer extends Renderer {
102
99
  /**
103
100
  * @internal
104
101
  */
105
- _createAndBindBuffer(vertexCount: number): void;
102
+ _createBuffer(vertexCount: number): void;
106
103
  /**
107
104
  * @internal
108
105
  */
@@ -123,23 +120,10 @@ export declare class SpineAnimationRenderer extends Renderer {
123
120
  * @internal
124
121
  */
125
122
  _onWorldVolumeChanged(): void;
126
- private _initialize;
127
123
  private _onAnimationStart;
128
124
  private _onAnimationComplete;
129
125
  private _clearMaterialCache;
130
- private _applyDefaultConfig;
131
- /**
132
- * * @deprecated This property is deprecated and will be removed in future releases.
133
- * Spine resource of current spine animation.
134
- */
135
- get resource(): SpineResource;
136
- /**
137
- * * @deprecated This property is deprecated and will be removed in future releases.
138
- * Sets the Spine resource for the current animation. This property allows switching to a different `SpineResource`.
139
- *
140
- * @param value - The new `SpineResource` to be used for the current animation
141
- */
142
- set resource(value: SpineResource);
126
+ private _initializeDefaultState;
143
127
  }
144
128
  /**
145
129
  * @internal
@@ -159,12 +143,41 @@ export declare enum RendererUpdateFlags {
159
143
  /** Include world position and world bounds. */
160
144
  WorldVolume = 1
161
145
  }
146
+ /**
147
+ * Render setting for spine rendering.
148
+ */
149
+ export declare class SpineRenderSetting {
150
+ /**
151
+ * The spacing between z layers @defaultValue `0.01`
152
+ */
153
+ zSpacing: number;
154
+ /**
155
+ * Whether to use clipping @defaultValue `true`
156
+ */
157
+ useClipping: boolean;
158
+ /**
159
+ * Creates an instance of SpineRenderSetting.
160
+ */
161
+ constructor(
162
+ /**
163
+ * The spacing between z layers @defaultValue `0.01`
164
+ */
165
+ zSpacing?: number,
166
+ /**
167
+ * Whether to use clipping @defaultValue `true`
168
+ */
169
+ useClipping?: boolean);
170
+ }
162
171
  /**
163
172
  * Default state for spine animation.
164
173
  * Contains the default animation name to be played, whether this animation should loop,
165
174
  * the default skin name, and the default scale of the skeleton.
166
175
  */
167
- export declare class SpineAnimationDefaultConfig {
176
+ export declare class DefaultState {
177
+ /**
178
+ * The default scale of the animation @defaultValue `1`
179
+ */
180
+ scale: number;
168
181
  /**
169
182
  * Whether the default animation should loop @defaultValue `true. The default animation should loop`
170
183
  */
@@ -178,9 +191,13 @@ export declare class SpineAnimationDefaultConfig {
178
191
  */
179
192
  skinName: string;
180
193
  /**
181
- * Creates an instance of default config
194
+ * Creates an instance of DefaultState
182
195
  */
183
196
  constructor(
197
+ /**
198
+ * The default scale of the animation @defaultValue `1`
199
+ */
200
+ scale?: number,
184
201
  /**
185
202
  * Whether the default animation should loop @defaultValue `true. The default animation should loop`
186
203
  */
@@ -1,5 +1,5 @@
1
1
  import { Texture2D, SubPrimitive, BoundingBox } from "@galacean/engine";
2
- import { Skeleton, Color, BlendMode } from "@esotericsoftware/spine-core";
2
+ import { Skeleton, Color, BlendMode, SkeletonData } from "@esotericsoftware/spine-core";
3
3
  import { SpineAnimationRenderer } from "./SpineAnimationRenderer";
4
4
  import { AdaptiveTexture } from "./loader/LoaderUtils";
5
5
  import { ReturnablePool } from "./util/ReturnablePool";
@@ -26,10 +26,13 @@ export declare class SpineGenerator {
26
26
  private _subRenderItems;
27
27
  private _separateSlots;
28
28
  private _separateSlotTextureMap;
29
+ getMaxVertexCount(skeletonData: SkeletonData): number;
29
30
  buildPrimitive(skeleton: Skeleton, renderer: SpineAnimationRenderer): void;
30
31
  addSeparateSlot(slotName: string): void;
31
32
  addSeparateSlotTexture(slotName: string, texture: Texture2D): void;
32
33
  private _createMaterialForTexture;
33
34
  private _expandByPoint;
35
+ private _collectUniqueAttachments;
36
+ private _calculateTotalVertexCount;
34
37
  }
35
38
  export {};
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./loader/SpineLoader";
2
2
  import "./loader/EditorSpineAtlasLoader";
3
3
  export { SpineAnimationRenderer } from "./SpineAnimationRenderer";
4
- export { SpineResource } from "./loader/SpineResource";
4
+ export { SkeletonDataResource } from "./loader/SkeletonDataResource";
5
5
  export { createTextureAtlas } from "./loader/LoaderUtils";
6
6
  export * from "@esotericsoftware/spine-core";
7
7
  export declare const version = "__buildVersion";
@@ -1,4 +1,4 @@
1
- import { SkeletonData } from "../spine-core";
1
+ import { SkeletonData } from "@esotericsoftware/spine-core";
2
2
  import { Engine, ReferResource, Texture2D } from "@galacean/engine";
3
3
  export declare class SkeletonDataResource extends ReferResource {
4
4
  readonly textures: Texture2D[];
@@ -1,5 +1,5 @@
1
1
  import { AssetPromise, Loader, LoadItem, ResourceManager } from "@galacean/engine";
2
- import { SpineResource } from "./SpineResource";
2
+ import { SkeletonDataResource } from "./SkeletonDataResource";
3
3
  export type SpineAssetBundle = {
4
4
  skeletonPath: string;
5
5
  skeletonExtension: string;
@@ -14,16 +14,14 @@ type SpineLoaderParams = {
14
14
  type SpineLoadItem = LoadItem & {
15
15
  params?: SpineLoaderParams;
16
16
  };
17
- export declare class SpineLoader extends Loader<SpineResource> {
17
+ export declare class SpineLoader extends Loader<SkeletonDataResource> {
18
18
  static imageExtensions: string[];
19
19
  static skeletonExtensions: string[];
20
20
  static parseAndAssignSpineAsset(url: string, fileExtension: string | null, bundle: SpineAssetBundle): void;
21
21
  static deriveAndAssignSpineAsset(url: string, fileExtension: string | null, bundle: SpineAssetBundle): void;
22
22
  static verifyFileExtensions(fileExtensions: string | string[], expectArray: boolean): string | string[] | null;
23
23
  static getUrlExtension(url: string, fileExtension: string): string | null;
24
- private _bufferReader;
25
- private _decoder;
26
- load(item: SpineLoadItem, resourceManager: ResourceManager): AssetPromise<SpineResource>;
24
+ load(item: SpineLoadItem, resourceManager: ResourceManager): AssetPromise<SkeletonDataResource>;
27
25
  private _handleEditorAsset;
28
26
  private _handleOriginAsset;
29
27
  private _determineSkeletonDataType;
@@ -0,0 +1,22 @@
1
+ import { Attachment, MeshAttachment, RegionAttachment, TextureAtlasRegion } from "@esotericsoftware/spine-core";
2
+ /**
3
+ * Creates a new `RegionAttachment` from a specified texture atlas region.
4
+ *
5
+ * @param region - The texture atlas region used to create the attachment.
6
+ * @param attachmentName - The name of the new attachment.
7
+ * @param scale - A scaling factor applied to the attachment's dimensions (default is 1).
8
+ * @param rotation - The rotation angle of the attachment in degrees (default is 0).
9
+ * @returns The created `RegionAttachment` with the passed in region.
10
+ */
11
+ export declare function createAttachmentFromRegion(region: TextureAtlasRegion, attachmentName: string, scale?: number, rotation?: number): RegionAttachment;
12
+ /**
13
+ * Clones an attachment (`RegionAttachment` or `MeshAttachment`) and applies a new texture atlas region.
14
+ *
15
+ * @param attachment - The attachment to clone (either `RegionAttachment` or `MeshAttachment`).
16
+ * @param atlasRegion - The new texture atlas region to associate with the cloned attachment.
17
+ * @param useOriginalRegionSize - Whether to retain the original region's size for the cloned attachment (default is `false`).
18
+ * @param scale - A scaling factor applied to the dimensions of the cloned attachment (default is 1).
19
+ * @param cloneMeshAsLinked - If `true`, clones a `MeshAttachment` as a linked mesh (default is `true`).
20
+ * @returns The cloned attachment with the specified properties and the new texture region.
21
+ */
22
+ export declare function cloneAttachmentWithRegion(attachment: RegionAttachment | MeshAttachment, atlasRegion: TextureAtlasRegion, useOriginalRegionSize?: boolean, scale?: number, cloneMeshAsLinked?: boolean): Attachment;
@@ -1,4 +1,4 @@
1
1
  import { BlendMode } from "@esotericsoftware/spine-core";
2
2
  import { Material } from "@galacean/engine";
3
- export declare function setBlendMode(material: Material, blendMode: BlendMode, premultipliedAlpha: boolean): void;
3
+ export declare function setBlendMode(material: Material, blendMode: BlendMode): void;
4
4
  export declare function getBlendMode(material: Material): BlendMode;
@@ -1,10 +1,8 @@
1
1
  export declare class BufferReader {
2
+ data: Uint8Array;
2
3
  private _dataView;
3
4
  private _position;
4
- private _data;
5
- constructor(data?: Uint8Array, byteOffset?: number, byteLength?: number);
6
- init(data: Uint8Array, byteOffset?: number, byteLength?: number): void;
7
- reset(): void;
5
+ constructor(data: Uint8Array, byteOffset?: number, byteLength?: number);
8
6
  nextUint16(): number;
9
7
  nextStr(): string;
10
8
  nextImageData(): Uint8Array;