@galacean/engine-spine 0.0.0-experimental-6d3110b4d9-20240531 → 0.0.0-experimental-c21bcd627b-20240711
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/dist/browser.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1 -0
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/package.json +6 -3
- package/types/SpineAnimation.d.ts +114 -19
- package/types/SpineGenerator.d.ts +40 -0
- package/types/core/SpineGenerator.d.ts +1 -2
- package/types/core/SpinePrimitive.d.ts +1 -9
- package/types/index.d.ts +2 -2
- package/types/loader/EditorSkeletonDataLoader.d.ts +3 -3
- package/types/loader/LoaderUtils.d.ts +4 -3
- package/types/loader/SkeletonDataResource.d.ts +12 -0
- package/types/loader/SpineLoader.d.ts +11 -4
- package/types/util/BlendMode.d.ts +4 -0
- package/types/util/BufferReader.d.ts +10 -0
- package/types/util/Cache.d.ts +19 -0
- package/types/util/ClearablePool.d.ts +8 -0
- package/types/util/ReturnablePool.d.ts +8 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.0-experimental-
|
|
2
|
+
"version": "0.0.0-experimental-c21bcd627b-20240711",
|
|
3
3
|
"description": "galacean spine runtime",
|
|
4
4
|
"name": "@galacean/engine-spine",
|
|
5
5
|
"main": "dist/main.js",
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
"@rollup/plugin-terser": "^0.4.3",
|
|
30
30
|
"@swc/core": "^1.3.32",
|
|
31
31
|
"@swc/helpers": "^0.5",
|
|
32
|
+
"@vitejs/plugin-basic-ssl": "^1.1.0",
|
|
32
33
|
"cross-env": "^5.2.0",
|
|
33
34
|
"dat.gui": "^0.7.9",
|
|
35
|
+
"floss": "^5.0.1",
|
|
34
36
|
"react": "^16.14.0",
|
|
35
37
|
"react-dom": "^16.14.0",
|
|
36
38
|
"rollup": "^2.32.0",
|
|
@@ -53,8 +55,9 @@
|
|
|
53
55
|
],
|
|
54
56
|
"scripts": {
|
|
55
57
|
"example": "vite",
|
|
56
|
-
"test": "
|
|
57
|
-
"test-
|
|
58
|
+
"test": "cross-env TS_NODE_PROJECT=tsconfig.tests.json floss --path tests -r ts-node/register",
|
|
59
|
+
"test-debug": "cross-env TS_NODE_PROJECT=tsconfig.tests.json floss --path tests -r ts-node/register --debug",
|
|
60
|
+
"test-cov": "cross-env TS_NODE_PROJECT=tsconfig.tests.json IS_COV=1 nyc --reporter=lcov floss --path tests -r ts-node/register",
|
|
58
61
|
"dev": "rollup -cw",
|
|
59
62
|
"build": "npm run b:types && cross-env BUILD_TYPE=ALL rollup -c",
|
|
60
63
|
"build:watch": "npm run b:types && cross-env BUILD_TYPE=ALL rollup -c --watch",
|
|
@@ -1,37 +1,79 @@
|
|
|
1
|
-
import { Skeleton, SkeletonData, AnimationState } from "@esotericsoftware/spine-core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Skeleton, SkeletonData, AnimationState, AnimationStateData } from "@esotericsoftware/spine-core";
|
|
2
|
+
import { Buffer, Renderer, Entity, Material, Engine, BoundingBox, Primitive, SubPrimitive } from "@galacean/engine";
|
|
3
|
+
import { SkeletonDataResource } from "./loader/SkeletonDataResource";
|
|
4
|
+
declare module '@esotericsoftware/spine-core' {
|
|
5
|
+
interface SkeletonData {
|
|
6
|
+
refCount: number;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
6
9
|
interface InitialState {
|
|
7
10
|
animationName: string;
|
|
8
11
|
skinName: string;
|
|
9
12
|
loop: boolean;
|
|
10
13
|
scale: number;
|
|
11
14
|
}
|
|
15
|
+
export type SpineRenderSetting = {
|
|
16
|
+
useClipping: boolean;
|
|
17
|
+
zSpacing: number;
|
|
18
|
+
};
|
|
12
19
|
export declare class SpineAnimation extends Renderer {
|
|
13
20
|
private static _defaultMaterial;
|
|
14
|
-
private static
|
|
15
|
-
private static
|
|
16
|
-
private static
|
|
17
|
-
private static
|
|
18
|
-
|
|
21
|
+
private static _spineGenerator;
|
|
22
|
+
private static positionVertexElement;
|
|
23
|
+
private static colorVertexElement;
|
|
24
|
+
private static uvVertexElement;
|
|
25
|
+
static materialCache: Map<string, Material>;
|
|
26
|
+
static animationDataCache: Map<SkeletonData, AnimationStateData>;
|
|
19
27
|
static getDefaultMaterial(engine: Engine): Material;
|
|
28
|
+
/** Render setting for spine rendering. */
|
|
20
29
|
setting: SpineRenderSetting;
|
|
30
|
+
/** Initial spine animation and skin state. */
|
|
21
31
|
initialState: InitialState;
|
|
32
|
+
/** @internal */
|
|
22
33
|
_primitive: Primitive;
|
|
34
|
+
/** @internal */
|
|
23
35
|
_subPrimitives: SubPrimitive[];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
/** @internal */
|
|
37
|
+
_indexBuffer: Buffer;
|
|
38
|
+
/** @internal */
|
|
39
|
+
_vertexBuffer: Buffer;
|
|
40
|
+
/** @internal */
|
|
41
|
+
_vertices: Float32Array;
|
|
42
|
+
/** @internal */
|
|
43
|
+
_indices: Uint16Array;
|
|
44
|
+
/** @internal */
|
|
45
|
+
_needResizeBuffer: boolean;
|
|
46
|
+
/** @internal */
|
|
47
|
+
_vertexCount: number;
|
|
48
|
+
/** @internal */
|
|
49
|
+
_resource: SkeletonDataResource;
|
|
50
|
+
private _skeleton;
|
|
51
|
+
private _state;
|
|
52
|
+
/**
|
|
53
|
+
* Setting `skeletonData` initializes a new Spine animation with the provided data.
|
|
54
|
+
* This property allows you to switch between different animations at runtime.
|
|
55
|
+
*/
|
|
56
|
+
set resource(value: SkeletonDataResource);
|
|
57
|
+
/**
|
|
58
|
+
* Provides access to `AnimationState` which controls animation playback on a skeleton.
|
|
59
|
+
* You can use its API to manage, blend, and transition between multiple simultaneous animations effectively.
|
|
60
|
+
*/
|
|
28
61
|
get state(): AnimationState;
|
|
62
|
+
/**
|
|
63
|
+
* Provides access to `Skeleton`, which defines the structure of a Spine model.
|
|
64
|
+
* Through its API, users can manipulate bone positions, rotations, scaling
|
|
65
|
+
* and change spine attachment to customize character appearances dynamically during runtime.
|
|
66
|
+
*/
|
|
29
67
|
get skeleton(): Skeleton;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
get engine(): Engine;
|
|
30
72
|
constructor(entity: Entity);
|
|
31
73
|
/**
|
|
32
74
|
* @internal
|
|
33
75
|
*/
|
|
34
|
-
|
|
76
|
+
_onEnable(): void;
|
|
35
77
|
/**
|
|
36
78
|
* Separate slot by slot name. This will add a new sub primitive, and new materials.
|
|
37
79
|
*/
|
|
@@ -47,18 +89,71 @@ export declare class SpineAnimation extends Renderer {
|
|
|
47
89
|
/**
|
|
48
90
|
* @internal
|
|
49
91
|
*/
|
|
50
|
-
|
|
92
|
+
_render(context: any): void;
|
|
93
|
+
/**
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
_updateBounds(worldBounds: BoundingBox): void;
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
_calculateGeneratorBounds(worldBounds: BoundingBox): void;
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
_cloneTo(target: SpineAnimation): void;
|
|
51
105
|
/**
|
|
52
106
|
* @internal
|
|
53
107
|
*/
|
|
54
|
-
|
|
108
|
+
_onDestroy(): void;
|
|
55
109
|
/**
|
|
56
110
|
* @internal
|
|
57
111
|
*/
|
|
58
|
-
|
|
112
|
+
_createBuffer(vertexCount: number): void;
|
|
59
113
|
/**
|
|
60
114
|
* @internal
|
|
61
115
|
*/
|
|
62
|
-
|
|
116
|
+
_addSubPrimitive(subPrimitive: SubPrimitive): void;
|
|
117
|
+
/**
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
_clearSubPrimitives(): void;
|
|
121
|
+
/**
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
_isContainDirtyFlag(type: number): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
_setDirtyFlagFalse(type: number): void;
|
|
129
|
+
/**
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
_onAnimationStart(): void;
|
|
133
|
+
/**
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
_onTransformChanged(): void;
|
|
137
|
+
private onAnimationStart;
|
|
138
|
+
private onAnimationComplete;
|
|
139
|
+
private _clearMaterialCache;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
export declare enum SpineAnimationUpdateFlags {
|
|
145
|
+
/** On World Transform Changed */
|
|
146
|
+
TransformVolume = 1,
|
|
147
|
+
/** On Animation start play */
|
|
148
|
+
AnimationVolume = 2,
|
|
149
|
+
/** On skeleton data asset changed */
|
|
150
|
+
AssetVolume = 4
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
export declare enum RendererUpdateFlags {
|
|
156
|
+
/** Include world position and world bounds. */
|
|
157
|
+
WorldVolume = 1
|
|
63
158
|
}
|
|
64
159
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Texture2D, SubPrimitive, Vector3 } from "@galacean/engine";
|
|
2
|
+
import { Skeleton, Color, BlendMode, SkeletonData } from "@esotericsoftware/spine-core";
|
|
3
|
+
import { SpineAnimation } from "./SpineAnimation";
|
|
4
|
+
import { AdaptiveTexture } from "./loader/LoaderUtils";
|
|
5
|
+
import { ReturnablePool } from "./util/ReturnablePool";
|
|
6
|
+
import { ClearablePool } from "./util/ClearablePool";
|
|
7
|
+
declare class SubRenderItem {
|
|
8
|
+
subPrimitive: SubPrimitive;
|
|
9
|
+
blendMode: BlendMode;
|
|
10
|
+
texture: any;
|
|
11
|
+
slotName?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class SpineGenerator {
|
|
14
|
+
static QUAD_TRIANGLES: number[];
|
|
15
|
+
static VERTEX_SIZE: number;
|
|
16
|
+
static VERTEX_STRIDE: number;
|
|
17
|
+
static tempDark: Color;
|
|
18
|
+
static tempColor: Color;
|
|
19
|
+
static tempVerts: any[];
|
|
20
|
+
static tempBlendMode: BlendMode | null;
|
|
21
|
+
static tempTexture: AdaptiveTexture | null;
|
|
22
|
+
static subPrimitivePool: ReturnablePool<SubPrimitive>;
|
|
23
|
+
static subRenderItemPool: ClearablePool<SubRenderItem>;
|
|
24
|
+
bounds: {
|
|
25
|
+
min: Vector3;
|
|
26
|
+
max: Vector3;
|
|
27
|
+
};
|
|
28
|
+
private _clipper;
|
|
29
|
+
private _subRenderItems;
|
|
30
|
+
private _separateSlots;
|
|
31
|
+
private _separateSlotTextureMap;
|
|
32
|
+
getMaxVertexCount(skeletonData: SkeletonData): number;
|
|
33
|
+
buildPrimitive(skeleton: Skeleton, renderer: SpineAnimation): void;
|
|
34
|
+
addSeparateSlot(slotName: string): void;
|
|
35
|
+
addSeparateSlotTexture(slotName: string, texture: Texture2D): void;
|
|
36
|
+
private createMaterialForTexture;
|
|
37
|
+
private expandByPoint;
|
|
38
|
+
private getSkinVertexCount;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Engine, Texture2D } from "@galacean/engine";
|
|
1
|
+
import { Engine, Texture2D, SubPrimitive } from "@galacean/engine";
|
|
2
2
|
import { Skeleton, SkeletonData, Color, BlendMode } from "@esotericsoftware/spine-core";
|
|
3
|
-
import { SubPrimitive } from "./SpinePrimitive";
|
|
4
3
|
import { SpineRenderSetting } from "../types";
|
|
5
4
|
import { AdaptiveTexture } from "../loader/LoaderUtils";
|
|
6
5
|
import { SpineAnimation } from "../SpineAnimation";
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { Engine, Buffer,
|
|
2
|
-
export declare class SubPrimitive {
|
|
3
|
-
/** Start drawing offset. */
|
|
4
|
-
start: number;
|
|
5
|
-
/** Drawing count. */
|
|
6
|
-
count: number;
|
|
7
|
-
/** Drawing topology. */
|
|
8
|
-
topology?: MeshTopology;
|
|
9
|
-
}
|
|
1
|
+
import { Engine, Buffer, SubPrimitive } from '@galacean/engine';
|
|
10
2
|
export declare class SpinePrimitive {
|
|
11
3
|
private _primitive;
|
|
12
4
|
private _subPrimitive;
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./loader/SpineLoader";
|
|
2
|
-
import "./loader/EditorSkeletonDataLoader";
|
|
3
2
|
import "./loader/EditorSpineAtlasLoader";
|
|
4
3
|
export { SpineAnimation } from "./SpineAnimation";
|
|
4
|
+
export { SkeletonDataResource } from "./loader/SkeletonDataResource";
|
|
5
|
+
export { createTextureAtlas } from "./loader/LoaderUtils";
|
|
5
6
|
export * from "@esotericsoftware/spine-core";
|
|
6
|
-
export { generateTextureAtlas } from "./loader/LoaderUtils";
|
|
7
7
|
export declare const version = "__buildVersion";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetPromise, Loader, LoadItem, ResourceManager } from "@galacean/engine";
|
|
2
|
-
import {
|
|
3
|
-
declare class EditorSkeletonDataLoader extends Loader<
|
|
4
|
-
load(item: LoadItem, resourceManager: ResourceManager): AssetPromise<
|
|
2
|
+
import { SkeletonDataResource } from "./SkeletonDataResource";
|
|
3
|
+
declare class EditorSkeletonDataLoader extends Loader<SkeletonDataResource> {
|
|
4
|
+
load(item: LoadItem, resourceManager: ResourceManager): AssetPromise<SkeletonDataResource>;
|
|
5
5
|
}
|
|
6
6
|
export { EditorSkeletonDataLoader };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Engine, Texture2D } from "@galacean/engine";
|
|
2
2
|
import { TextureAtlas, SkeletonData, Texture, TextureFilter, TextureWrap } from "@esotericsoftware/spine-core";
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
export declare function createSkeletonData(textureAtlas: TextureAtlas, skeletonTextData: string | ArrayBuffer, skeletonFileType: 'json' | 'skel'): SkeletonData;
|
|
4
|
+
export declare function loadTexturesByPath(imagePaths: string[], imageExtensions: string[], engine: Engine): Promise<Texture2D[]>;
|
|
5
|
+
export declare function loadTextureAtlas(atlasPath: string, engine: Engine): Promise<TextureAtlas>;
|
|
6
|
+
export declare function createTextureAtlas(atlasText: string, textures: Texture2D[]): TextureAtlas;
|
|
6
7
|
export declare function getBaseUrl(url: string): string;
|
|
7
8
|
export declare class AdaptiveTexture extends Texture {
|
|
8
9
|
texture: Texture2D;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SkeletonData } from "@esotericsoftware/spine-core";
|
|
2
|
+
import { Engine, ReferResource, Texture2D } from "@galacean/engine";
|
|
3
|
+
export declare class SkeletonDataResource extends ReferResource {
|
|
4
|
+
readonly textures: Texture2D[];
|
|
5
|
+
private _skeletonData;
|
|
6
|
+
get skeletonData(): SkeletonData;
|
|
7
|
+
constructor(engine: Engine, skeletonData: SkeletonData);
|
|
8
|
+
protected _onDestroy(): void;
|
|
9
|
+
private _disassociationSuperResource;
|
|
10
|
+
private _associationTextureInSkeletonData;
|
|
11
|
+
private _clearAttachmentTextures;
|
|
12
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AssetPromise, Loader, LoadItem, ResourceManager } from "@galacean/engine";
|
|
2
|
-
import {
|
|
2
|
+
import { SkeletonDataResource } from "./SkeletonDataResource";
|
|
3
3
|
export type SpineAssetBundle = {
|
|
4
4
|
skeletonPath: string;
|
|
5
5
|
skeletonExtension: string;
|
|
6
|
+
skeletonTextData?: string | ArrayBuffer;
|
|
6
7
|
atlasPath: string;
|
|
7
8
|
imagePaths: string[];
|
|
8
9
|
imageExtensions: string[];
|
|
@@ -13,9 +14,15 @@ type SpineLoaderParams = {
|
|
|
13
14
|
type SpineLoadItem = LoadItem & {
|
|
14
15
|
params?: SpineLoaderParams;
|
|
15
16
|
};
|
|
16
|
-
declare class SpineLoader extends Loader<
|
|
17
|
+
export declare class SpineLoader extends Loader<SkeletonDataResource> {
|
|
17
18
|
static imageExtensions: string[];
|
|
18
19
|
static skeletonExtensions: string[];
|
|
19
|
-
|
|
20
|
+
static parseAndAssignSpineAsset(url: string, fileExtension: string | null, bundle: SpineAssetBundle): void;
|
|
21
|
+
static deriveAndAssignSpineAsset(url: string, fileExtension: string | null, bundle: SpineAssetBundle): void;
|
|
22
|
+
static verifyFileExtensions(fileExtensions: string | string[], expectArray: boolean): string | string[] | null;
|
|
23
|
+
load(item: SpineLoadItem, resourceManager: ResourceManager): AssetPromise<SkeletonDataResource>;
|
|
24
|
+
private _handleEditorAsset;
|
|
25
|
+
private _handleOriginAsset;
|
|
26
|
+
private determineSkeletonDataType;
|
|
20
27
|
}
|
|
21
|
-
export {
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class BufferReader {
|
|
2
|
+
data: Uint8Array;
|
|
3
|
+
private _dataView;
|
|
4
|
+
private _position;
|
|
5
|
+
constructor(data: Uint8Array, byteOffset?: number, byteLength?: number);
|
|
6
|
+
nextUint16(): number;
|
|
7
|
+
nextStr(): string;
|
|
8
|
+
nextImageData(): Uint8Array;
|
|
9
|
+
private decodeText;
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SkeletonData, AnimationStateData } from "@esotericsoftware/spine-core";
|
|
2
|
+
import { Material } from "@galacean/engine";
|
|
3
|
+
declare class Cache<K, V> {
|
|
4
|
+
protected _cache: Map<K, V>;
|
|
5
|
+
get(key: K): V;
|
|
6
|
+
set(key: K, value: V): void;
|
|
7
|
+
clear(keys?: K[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class AnimationStateDataCache extends Cache<SkeletonData, AnimationStateData> {
|
|
10
|
+
private static _instance;
|
|
11
|
+
static get instance(): AnimationStateDataCache;
|
|
12
|
+
getAnimationStateData(skeletonData: SkeletonData): AnimationStateData;
|
|
13
|
+
}
|
|
14
|
+
export declare class MaterialCache extends Cache<string, Material> {
|
|
15
|
+
private static _instance;
|
|
16
|
+
static get instance(): MaterialCache;
|
|
17
|
+
getMaterial(key: string): Material;
|
|
18
|
+
}
|
|
19
|
+
export {};
|