@galacean/engine-design 2.0.0-alpha.51 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-design",
3
- "version": "2.0.0-alpha.51",
3
+ "version": "2.0.0-alpha.52",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "types": "types/index.d.ts",
19
19
  "dependencies": {
20
- "@galacean/engine-math": "2.0.0-alpha.51"
20
+ "@galacean/engine-math": "2.0.0-alpha.52"
21
21
  },
22
22
  "scripts": {
23
23
  "b:types": "tsc"
package/types/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from "./physics/index";
4
4
  export * from "./renderingHardwareInterface/index";
5
5
  export * from "./shader-compiler/index";
6
6
  export * from "./xr/index";
7
+ export * from "./spine/index";
@@ -0,0 +1,4 @@
1
+ export interface ISpineAnimation {
2
+ readonly name: string;
3
+ readonly duration: number;
4
+ }
@@ -0,0 +1,17 @@
1
+ import type { ISpineAnimationStateData } from "./ISpineAnimationStateData";
2
+ import type { ISpineAnimationStateListener } from "./ISpineAnimationStateListener";
3
+ import type { ISpineTrackEntry } from "./ISpineTrackEntry";
4
+ export interface ISpineAnimationState {
5
+ readonly data: ISpineAnimationStateData;
6
+ timeScale: number;
7
+ setAnimation(track: number, name: string, loop: boolean): ISpineTrackEntry;
8
+ addAnimation(track: number, name: string, loop: boolean, delay: number): ISpineTrackEntry;
9
+ setEmptyAnimation(track: number, mixDuration: number): ISpineTrackEntry;
10
+ addEmptyAnimation(track: number, mixDuration: number, delay: number): ISpineTrackEntry;
11
+ setEmptyAnimations(mixDuration: number): void;
12
+ getCurrent(track: number): ISpineTrackEntry | null;
13
+ clearTrack(track: number): void;
14
+ clearTracks(): void;
15
+ addListener(listener: ISpineAnimationStateListener): void;
16
+ clearListeners(): void;
17
+ }
@@ -0,0 +1,5 @@
1
+ /** Shared mixing configuration. */
2
+ export interface ISpineAnimationStateData {
3
+ defaultMix: number;
4
+ setMix(from: string, to: string, duration: number): void;
5
+ }
@@ -0,0 +1,10 @@
1
+ import type { ISpineEvent } from "./ISpineEvent";
2
+ import type { ISpineTrackEntry } from "./ISpineTrackEntry";
3
+ export interface ISpineAnimationStateListener {
4
+ start?(entry: ISpineTrackEntry): void;
5
+ interrupt?(entry: ISpineTrackEntry): void;
6
+ end?(entry: ISpineTrackEntry): void;
7
+ dispose?(entry: ISpineTrackEntry): void;
8
+ complete?(entry: ISpineTrackEntry): void;
9
+ event?(entry: ISpineTrackEntry, event: ISpineEvent): void;
10
+ }
@@ -0,0 +1,21 @@
1
+ import type { ISpineBoneData } from "./ISpineBoneData";
2
+ export interface ISpineBone {
3
+ readonly data: ISpineBoneData;
4
+ /** Local pose, before constraints. */
5
+ x: number;
6
+ y: number;
7
+ rotation: number;
8
+ scaleX: number;
9
+ scaleY: number;
10
+ shearX: number;
11
+ shearY: number;
12
+ /** Evaluated world transform. */
13
+ readonly a: number;
14
+ readonly b: number;
15
+ readonly c: number;
16
+ readonly d: number;
17
+ readonly worldX: number;
18
+ readonly worldY: number;
19
+ isActive(): boolean;
20
+ setToSetupPose(): void;
21
+ }
@@ -0,0 +1,3 @@
1
+ export interface ISpineBoneData {
2
+ readonly name: string;
3
+ }
@@ -0,0 +1,5 @@
1
+ import type { ISpineConstraintData } from "./ISpineConstraintData";
2
+ export interface ISpineConstraint {
3
+ readonly data: ISpineConstraintData;
4
+ isActive(): boolean;
5
+ }
@@ -0,0 +1,3 @@
1
+ export interface ISpineConstraintData {
2
+ readonly name: string;
3
+ }
@@ -0,0 +1,9 @@
1
+ export interface ISpineEvent {
2
+ readonly data: {
3
+ readonly name: string;
4
+ };
5
+ readonly time: number;
6
+ intValue: number;
7
+ floatValue: number;
8
+ stringValue: string | null;
9
+ }
@@ -0,0 +1,17 @@
1
+ /** Receives CPU geometry synchronously from a backend, in skeleton draw order.
2
+ * The shared renderer owns the output buffers and batches. Backends may reuse their input arrays after append returns.
3
+ */
4
+ export interface ISpineGeometry<TTexture> {
5
+ readonly tintBlack: boolean;
6
+ /** Append one drawable attachment after world vertex calculation and clipping.
7
+ * Input vertices contain x, y, r, g, b, a, u, v, followed by dark r, g, b, a when tintBlack is enabled.
8
+ * Colors are unassociated (straight) sRGB values; the shared shader converts RGB to linear.
9
+ * Textures use straight alpha, validated at the asset boundary.
10
+ * Only vertexCount vertices and indexCount indices are consumed; indices are local to this attachment.
11
+ * drawOrder is the slot's index in the skeleton draw order, including slots without geometry.
12
+ * slotIndex is its stable index in Skeleton.slots, independent of animated draw order.
13
+ * Blend modes: normal=0, additive=1, multiply=2, screen=3.
14
+ * The input arrays are copied during this call and are not retained.
15
+ */
16
+ append(vertices: ArrayLike<number>, vertexCount: number, indices: ArrayLike<number>, indexCount: number, texture: TTexture, blendMode: 0 | 1 | 2 | 3, drawOrder: number, slotIndex: number): void;
17
+ }
@@ -0,0 +1,7 @@
1
+ import type { ISpinePhysicsConstraint } from "./ISpinePhysicsConstraint";
2
+ /** Physics participates in the skeleton's ordered constraint evaluation, not a separate simulation. */
3
+ export interface ISpinePhysics {
4
+ readonly physicsConstraints: readonly ISpinePhysicsConstraint[];
5
+ physicsTranslate(x: number, y: number): void;
6
+ physicsRotate(x: number, y: number, degrees: number): void;
7
+ }
@@ -0,0 +1,11 @@
1
+ import type { ISpineConstraint } from "./ISpineConstraint";
2
+ export interface ISpinePhysicsConstraint extends ISpineConstraint {
3
+ inertia: number;
4
+ strength: number;
5
+ damping: number;
6
+ massInverse: number;
7
+ wind: number;
8
+ gravity: number;
9
+ mix: number;
10
+ reset(): void;
11
+ }
@@ -0,0 +1,52 @@
1
+ import type { ISpineGeometry } from "./ISpineGeometry";
2
+ import type { ISpineSkin } from "./ISpineSkin";
3
+ import type { ISpineSkeletonData } from "./ISpineSkeletonData";
4
+ import type { ISpineSkeleton } from "./ISpineSkeleton";
5
+ import type { ISpineAnimationStateData } from "./ISpineAnimationStateData";
6
+ import type { ISpineAnimationState } from "./ISpineAnimationState";
7
+ import type { SpineCapability } from "./SpineCapability";
8
+ import type { ISpinePhysics } from "./ISpinePhysics";
9
+ import type { ISpineTextureAtlas } from "./ISpineTextureAtlas";
10
+ /**
11
+ * The version-specific spine runtime backend.
12
+ *
13
+ * @remarks
14
+ * Parses assets, creates animation objects, updates poses and builds geometry for one Spine version.
15
+ * The texture type is supplied by the integration layer.
16
+ */
17
+ export interface ISpineRuntime<TTexture> {
18
+ /** Export major.minor supported by this backend. */
19
+ readonly version: string;
20
+ /** All textures referenced by attachments, including inactive skins and sequences. */
21
+ getTextures(skeletonData: ISpineSkeletonData): TTexture[];
22
+ /** Query once when an instance is created; no per-frame wrapper allocation. */
23
+ getPhysics(skeleton: ISpineSkeleton): SpineCapability<ISpinePhysics>;
24
+ /** Create an empty skin for composition using attachments from this resource. */
25
+ createSkin(name: string): ISpineSkin;
26
+ /**
27
+ * Build an atlas from canonical straight-alpha textures in atlas page order.
28
+ * The shared loader resolves page names and validates straight-alpha input before calling the backend.
29
+ */
30
+ createTextureAtlas(atlasText: string, textures: TTexture[]): ISpineTextureAtlas;
31
+ /** Parse skeleton data (json or binary) against an atlas. */
32
+ createSkeletonData(skeletonRawData: string | ArrayBuffer, textureAtlas: ISpineTextureAtlas, skeletonDataScale: number): ISpineSkeletonData;
33
+ /** Create the shared animation state data for a skeleton data. */
34
+ createAnimationStateData(skeletonData: ISpineSkeletonData): ISpineAnimationStateData;
35
+ /** Create a skeleton instance. */
36
+ createSkeleton(skeletonData: ISpineSkeletonData): ISpineSkeleton;
37
+ /** Create an animation state instance. */
38
+ createAnimationState(stateData: ISpineAnimationStateData): ISpineAnimationState;
39
+ /** Finish a playback command before dispatching its events. Nested calls preserve the current dispatch. */
40
+ batchAnimationStateEvents<T>(state: ISpineAnimationState, command: () => T): T;
41
+ /** Advance animation and skeleton time without applying the animation or solving the pose. */
42
+ advanceState(skeleton: ISpineSkeleton, state: ISpineAnimationState, delta: number): void;
43
+ /** Apply the current animation to the skeleton's local pose. */
44
+ applyState(skeleton: ISpineSkeleton, state: ISpineAnimationState): void;
45
+ /**
46
+ * Solve bone world transforms and constraints. When advancePhysics is false, apply the existing
47
+ * physics pose without advancing the simulation; this permits world-space-driven pose edits.
48
+ */
49
+ updateWorldTransform(skeleton: ISpineSkeleton, advancePhysics: boolean): void;
50
+ /** Write CPU geometry for the current pose. GPU resources remain owned by the shared renderer. */
51
+ buildGeometry(skeleton: ISpineSkeleton, target: ISpineGeometry<TTexture>): void;
52
+ }
@@ -0,0 +1,21 @@
1
+ import type { ISpineBone } from "./ISpineBone";
2
+ import type { ISpineSkin } from "./ISpineSkin";
3
+ import type { ISpineSkeletonData } from "./ISpineSkeletonData";
4
+ import type { ISpineSlot } from "./ISpineSlot";
5
+ /** Per-instance pose. World-transform evaluation is owned by the backend. */
6
+ export interface ISpineSkeleton {
7
+ readonly data: ISpineSkeletonData;
8
+ readonly bones: readonly ISpineBone[];
9
+ readonly slots: readonly ISpineSlot[];
10
+ readonly skin?: ISpineSkin | null;
11
+ x: number;
12
+ y: number;
13
+ scaleX: number;
14
+ scaleY: number;
15
+ setSkinByName(name: string): void;
16
+ setSkin(skin: ISpineSkin | null): void;
17
+ setAttachment(slotName: string, attachmentName: string | null): void;
18
+ setToSetupPose(): void;
19
+ setBonesToSetupPose(): void;
20
+ setSlotsToSetupPose(): void;
21
+ }
@@ -0,0 +1,15 @@
1
+ import type { ISpineSkin } from "./ISpineSkin";
2
+ import type { ISpineAnimation } from "./ISpineAnimation";
3
+ /** Shared setup pose, skins and animations. */
4
+ export interface ISpineSkeletonData {
5
+ readonly name?: string | null;
6
+ readonly version?: string | null;
7
+ readonly skins: readonly ISpineSkin[];
8
+ readonly animations: readonly ISpineAnimation[];
9
+ readonly defaultSkin?: ISpineSkin | null;
10
+ readonly x: number;
11
+ readonly y: number;
12
+ readonly width: number;
13
+ readonly height: number;
14
+ findSkin(name: string): ISpineSkin | null;
15
+ }
@@ -0,0 +1,5 @@
1
+ /** Shared skin definitions. Mutations affect every instance using this skin. */
2
+ export interface ISpineSkin {
3
+ readonly name: string;
4
+ addSkin(skin: ISpineSkin): void;
5
+ }
@@ -0,0 +1,9 @@
1
+ import type { ISpineBone } from "./ISpineBone";
2
+ /** Per-instance attachment slot. Materials are owned by the renderer. */
3
+ export interface ISpineSlot {
4
+ readonly data: {
5
+ readonly name: string;
6
+ };
7
+ readonly bone: ISpineBone;
8
+ setToSetupPose(): void;
9
+ }
@@ -0,0 +1,6 @@
1
+ /** Backend-owned atlas handle; it is never interpreted by the shared renderer. */
2
+ export interface ISpineTextureAtlas {
3
+ readonly pages: readonly {
4
+ readonly name: string;
5
+ }[];
6
+ }
@@ -0,0 +1,23 @@
1
+ import type { ISpineAnimation } from "./ISpineAnimation";
2
+ import type { ISpineAnimationStateListener } from "./ISpineAnimationStateListener";
3
+ /** A playback entry is pooled by the runtime. Do not retain it after its dispose event. */
4
+ export interface ISpineTrackEntry {
5
+ readonly animation: ISpineAnimation | null;
6
+ readonly trackIndex: number;
7
+ readonly next?: ISpineTrackEntry | null;
8
+ readonly mixingFrom?: ISpineTrackEntry | null;
9
+ readonly mixingTo?: ISpineTrackEntry | null;
10
+ listener?: ISpineAnimationStateListener | null;
11
+ loop: boolean;
12
+ delay: number;
13
+ trackTime: number;
14
+ trackEnd: number;
15
+ timeScale: number;
16
+ alpha: number;
17
+ animationStart: number;
18
+ animationEnd: number;
19
+ mixTime: number;
20
+ mixDuration: number;
21
+ getAnimationTime(): number;
22
+ isComplete(): boolean;
23
+ }
@@ -0,0 +1,8 @@
1
+ /** Version-specific capabilities are explicit, including on versions that do not support them. */
2
+ export type SpineCapability<T> = {
3
+ readonly supported: true;
4
+ readonly value: T;
5
+ } | {
6
+ readonly supported: false;
7
+ readonly reason: string;
8
+ };
@@ -0,0 +1,21 @@
1
+ /** Version-independent Spine contracts. Shared data and per-instance state have separate interfaces. */
2
+ export type { ISpineBoneData } from "./ISpineBoneData";
3
+ export type { ISpineBone } from "./ISpineBone";
4
+ export type { ISpineSlot } from "./ISpineSlot";
5
+ export type { ISpineSkin } from "./ISpineSkin";
6
+ export type { ISpineAnimation } from "./ISpineAnimation";
7
+ export type { ISpineConstraintData } from "./ISpineConstraintData";
8
+ export type { ISpineConstraint } from "./ISpineConstraint";
9
+ export type { ISpineSkeletonData } from "./ISpineSkeletonData";
10
+ export type { ISpineSkeleton } from "./ISpineSkeleton";
11
+ export type { ISpineAnimationStateData } from "./ISpineAnimationStateData";
12
+ export type { ISpineEvent } from "./ISpineEvent";
13
+ export type { ISpineAnimationStateListener } from "./ISpineAnimationStateListener";
14
+ export type { ISpineTrackEntry } from "./ISpineTrackEntry";
15
+ export type { ISpineAnimationState } from "./ISpineAnimationState";
16
+ export type { SpineCapability } from "./SpineCapability";
17
+ export type { ISpinePhysicsConstraint } from "./ISpinePhysicsConstraint";
18
+ export type { ISpinePhysics } from "./ISpinePhysics";
19
+ export type { ISpineTextureAtlas } from "./ISpineTextureAtlas";
20
+ export type { ISpineRuntime } from "./ISpineRuntime";
21
+ export type { ISpineGeometry } from "./ISpineGeometry";