@galacean/engine-design 2.0.0-alpha.51 → 2.0.0-alpha.53
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/main.js +1094 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +1081 -0
- package/dist/module.js.map +1 -0
- package/package.json +3 -2
- package/types/index.d.ts +1 -0
- package/types/physics/ICollider.d.ts +4 -3
- package/types/physics/IPhysicsScene.d.ts +81 -36
- package/types/physics/shape/IColliderShape.d.ts +5 -0
- package/types/shader-compiler/ICondition.d.ts +88 -7
- package/types/shader-compiler/IShaderCompiler.d.ts +17 -9
- package/types/shader-compiler/IShaderProgramSource.d.ts +5 -0
- package/types/shader-compiler/PreprocessorExpression.d.ts +174 -0
- package/types/shader-compiler/ShaderIncludePath.d.ts +7 -0
- package/types/shader-compiler/index.d.ts +8 -6
- package/types/shader-compiler/shaderSource/IShaderPassSource.d.ts +21 -0
- package/types/spine/ISpineAnimation.d.ts +4 -0
- package/types/spine/ISpineAnimationState.d.ts +17 -0
- package/types/spine/ISpineAnimationStateData.d.ts +5 -0
- package/types/spine/ISpineAnimationStateListener.d.ts +10 -0
- package/types/spine/ISpineBone.d.ts +21 -0
- package/types/spine/ISpineBoneData.d.ts +3 -0
- package/types/spine/ISpineConstraint.d.ts +5 -0
- package/types/spine/ISpineConstraintData.d.ts +3 -0
- package/types/spine/ISpineEvent.d.ts +9 -0
- package/types/spine/ISpineGeometry.d.ts +17 -0
- package/types/spine/ISpinePhysics.d.ts +7 -0
- package/types/spine/ISpinePhysicsConstraint.d.ts +11 -0
- package/types/spine/ISpineRuntime.d.ts +52 -0
- package/types/spine/ISpineSkeleton.d.ts +21 -0
- package/types/spine/ISpineSkeletonData.d.ts +15 -0
- package/types/spine/ISpineSkin.d.ts +5 -0
- package/types/spine/ISpineSlot.d.ts +9 -0
- package/types/spine/ISpineTextureAtlas.d.ts +6 -0
- package/types/spine/ISpineTrackEntry.d.ts +23 -0
- package/types/spine/SpineCapability.d.ts +8 -0
- package/types/spine/index.d.ts +21 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { Condition } from "./ICondition";
|
|
2
|
+
/**
|
|
3
|
+
* Location and certainty of a preprocessor-expression parse failure.
|
|
4
|
+
*/
|
|
5
|
+
export interface PreprocessorExpressionParseError {
|
|
6
|
+
/** Human-readable syntax error. */
|
|
7
|
+
readonly message: string;
|
|
8
|
+
/** Zero-based start offset in the expression. */
|
|
9
|
+
readonly start: number;
|
|
10
|
+
/** Zero-based exclusive end offset in the expression. */
|
|
11
|
+
readonly end: number;
|
|
12
|
+
/** Whether macro expansion cannot make the expression valid. */
|
|
13
|
+
readonly certain: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Successful preprocessor-expression parse.
|
|
17
|
+
*/
|
|
18
|
+
export interface ParsedPreprocessorExpression {
|
|
19
|
+
readonly ok: true;
|
|
20
|
+
/** Serializable expression tree. */
|
|
21
|
+
readonly condition: Condition;
|
|
22
|
+
/** Whether evaluation depends on macro replacement text. */
|
|
23
|
+
readonly hasExpandableIdentifier: boolean;
|
|
24
|
+
/** Definite evaluation failure that is independent of macro state. */
|
|
25
|
+
readonly evaluationError?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Failed preprocessor-expression parse.
|
|
29
|
+
*/
|
|
30
|
+
export interface InvalidPreprocessorExpression {
|
|
31
|
+
readonly ok: false;
|
|
32
|
+
/** Structured parse failure. */
|
|
33
|
+
readonly error: PreprocessorExpressionParseError;
|
|
34
|
+
/** Whether an identifier may expand into missing syntax. */
|
|
35
|
+
readonly hasExpandableIdentifier: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of parsing a preprocessor expression.
|
|
39
|
+
*/
|
|
40
|
+
export type PreprocessorExpressionParseResult = ParsedPreprocessorExpression | InvalidPreprocessorExpression;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves identifiers and macro-definition checks while evaluating an expression tree.
|
|
43
|
+
*/
|
|
44
|
+
export interface PreprocessorExpressionContext {
|
|
45
|
+
/**
|
|
46
|
+
* Resolves an identifier to a signed 32-bit integer.
|
|
47
|
+
* @param name - Macro identifier.
|
|
48
|
+
* @returns Resolved integer value; undefined identifiers return zero.
|
|
49
|
+
*/
|
|
50
|
+
resolveIdentifier(name: string): number;
|
|
51
|
+
/**
|
|
52
|
+
* Tests whether a macro exists.
|
|
53
|
+
* @param name - Macro identifier.
|
|
54
|
+
* @returns Whether the identifier is defined.
|
|
55
|
+
*/
|
|
56
|
+
isDefined(name: string): boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the subset of macro state known during source preprocessing.
|
|
60
|
+
*
|
|
61
|
+
* `undefined` means that the caller must preserve both possibilities. This keeps include
|
|
62
|
+
* reachability conservative when a macro may be supplied by the runtime configuration.
|
|
63
|
+
*/
|
|
64
|
+
export interface PartiallyKnownPreprocessorExpressionContext {
|
|
65
|
+
/**
|
|
66
|
+
* Resolves an identifier against known source macro state.
|
|
67
|
+
* @param name - Macro identifier.
|
|
68
|
+
* @returns Known value, definite error, or an empty result when the value depends on external macro state.
|
|
69
|
+
*/
|
|
70
|
+
resolveIdentifier(name: string): PartiallyKnownPreprocessorExpressionResult;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves whether a macro is defined.
|
|
73
|
+
* @param name - Macro identifier.
|
|
74
|
+
* @returns Known definition state, or `undefined` when supplied externally.
|
|
75
|
+
*/
|
|
76
|
+
isDefined(name: string): boolean | undefined;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Result of evaluating an expression against incomplete macro state.
|
|
80
|
+
*/
|
|
81
|
+
export interface PartiallyKnownPreprocessorExpressionResult {
|
|
82
|
+
/** Known signed 32-bit value, absent when external macro state still matters. */
|
|
83
|
+
readonly value?: number;
|
|
84
|
+
/** Definite failure reached without assuming an external macro value. */
|
|
85
|
+
readonly error?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* One object-like or function-like shader macro.
|
|
89
|
+
*/
|
|
90
|
+
export interface PreprocessorExpressionMacro {
|
|
91
|
+
/** Replacement-list source before parameter substitution. */
|
|
92
|
+
readonly body: string;
|
|
93
|
+
/** Function parameters; absent for an object-like macro. */
|
|
94
|
+
readonly parameters?: readonly string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Result of token-aware preprocessor-expression macro expansion.
|
|
98
|
+
*/
|
|
99
|
+
export interface PreprocessorExpressionExpansionResult {
|
|
100
|
+
/** Comment-free, token-normalized expanded expression. */
|
|
101
|
+
readonly expression: string;
|
|
102
|
+
/** Deterministic expansion failure. */
|
|
103
|
+
readonly error?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Result of shader source macro expansion, including a deterministic failure when expansion stops.
|
|
107
|
+
*/
|
|
108
|
+
export interface ShaderMacroExpansionResult {
|
|
109
|
+
/** Expanded source with preprocessing token boundaries and comments preserved. */
|
|
110
|
+
readonly source: string;
|
|
111
|
+
/** Deterministic expansion failure. */
|
|
112
|
+
readonly error?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Parses the complete integer-expression grammar used by `#if` and `#elif`.
|
|
116
|
+
* @param expression - Text after the preprocessor directive.
|
|
117
|
+
* @returns A serializable tree or a structured parse failure.
|
|
118
|
+
*/
|
|
119
|
+
export declare function parsePreprocessorExpression(expression: string): PreprocessorExpressionParseResult;
|
|
120
|
+
/**
|
|
121
|
+
* Resolves `defined` operators and removes comments with the expression parser's tokenization rules.
|
|
122
|
+
* @param expression - Expression before ordinary macro replacement.
|
|
123
|
+
* @param isDefined - Resolves whether one macro name is defined, or returns `undefined` when external state decides.
|
|
124
|
+
* @returns Token-normalized expression with every known `defined` operator replaced by `0` or `1`.
|
|
125
|
+
*/
|
|
126
|
+
export declare function resolvePreprocessorDefinedOperators(expression: string, isDefined: (name: string) => boolean | undefined): string;
|
|
127
|
+
/**
|
|
128
|
+
* Expands object-like and function-like macros with the expression parser's tokenization rules.
|
|
129
|
+
* @param expression - Expression after any caller-owned `defined` resolution.
|
|
130
|
+
* @param resolveMacro - Resolves source or runtime macro definitions by name.
|
|
131
|
+
* @returns Token-normalized expansion or a deterministic depth error.
|
|
132
|
+
*/
|
|
133
|
+
export declare function expandPreprocessorExpressionMacros(expression: string, resolveMacro: (name: string) => PreprocessorExpressionMacro | undefined): PreprocessorExpressionExpansionResult;
|
|
134
|
+
/**
|
|
135
|
+
* Expands shader macros using the same argument prescan and rescan rules as conditional expressions.
|
|
136
|
+
* @param source - Shader text without macro definition or conditional directives.
|
|
137
|
+
* @param resolveMacro - Resolves the macro state active at this source location.
|
|
138
|
+
* @returns Expanded shader source, or a deterministic expansion-limit error.
|
|
139
|
+
*/
|
|
140
|
+
export declare function expandShaderMacros(source: string, resolveMacro: (name: string) => PreprocessorExpressionMacro | undefined): ShaderMacroExpansionResult;
|
|
141
|
+
/**
|
|
142
|
+
* Evaluates an expression whose result is independent of macro state.
|
|
143
|
+
* @param expression - Complete preprocessor expression text.
|
|
144
|
+
* @returns 32-bit result, or `undefined` when the expression is invalid, state-dependent, or unevaluable.
|
|
145
|
+
*/
|
|
146
|
+
export declare function evaluateContextFreePreprocessorExpression(expression: string): number | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Evaluates a parsed condition whose result is independent of macro state.
|
|
149
|
+
* @param condition - Parsed preprocessor expression tree.
|
|
150
|
+
* @returns 32-bit result, or `undefined` when macro state or an invalid operation affects the result.
|
|
151
|
+
*/
|
|
152
|
+
export declare function evaluateContextFreePreprocessorCondition(condition: Condition): number | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Evaluates the part of a preprocessor expression determined by known source macro state.
|
|
155
|
+
* @param condition - Parsed preprocessor expression tree.
|
|
156
|
+
* @param context - Partially known macro values and definition states.
|
|
157
|
+
* @returns 32-bit result, or `undefined` when any reachable input remains unknown.
|
|
158
|
+
*/
|
|
159
|
+
export declare function evaluatePartiallyKnownPreprocessorCondition(condition: Condition, context: PartiallyKnownPreprocessorExpressionContext): number | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Evaluates the known portion of an expression while preserving definite evaluation failures.
|
|
162
|
+
* @param condition - Parsed preprocessor expression tree.
|
|
163
|
+
* @param context - Partially known macro values and definition states.
|
|
164
|
+
* @returns Known value, definite error, or an empty result when external state still matters.
|
|
165
|
+
*/
|
|
166
|
+
export declare function evaluatePartiallyKnownPreprocessorConditionResult(condition: Condition, context: PartiallyKnownPreprocessorExpressionContext): PartiallyKnownPreprocessorExpressionResult;
|
|
167
|
+
/**
|
|
168
|
+
* Evaluates a parsed preprocessor expression with signed 32-bit arithmetic matching ANGLE's preprocessor.
|
|
169
|
+
* @param condition - Serializable expression tree.
|
|
170
|
+
* @param context - Active macro value and definition resolver.
|
|
171
|
+
* @returns Signed 32-bit result; nonzero values are true.
|
|
172
|
+
* @throws Error when an active expression divides by zero or contains a deferred node.
|
|
173
|
+
*/
|
|
174
|
+
export declare function evaluatePreprocessorExpression(condition: Condition, context: PreprocessorExpressionContext): number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a registered shader-include key to its canonical lookup form.
|
|
3
|
+
* @param includeKey - Logical project path, project-root path, or absolute URL.
|
|
4
|
+
* @returns Canonical registry key without the virtual shader-root prefix.
|
|
5
|
+
* @throws Error when the key is empty or an absolute URL is malformed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeShaderIncludeKey(includeKey: string): string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export type { IShaderCompiler } from "./IShaderCompiler";
|
|
2
|
-
export type { Condition, DefinedCondition, NotDefinedCondition, CompareCondition, BoolCondition, ShaderInstruction } from "./ICondition";
|
|
2
|
+
export type { Condition, DefinedCondition, NotDefinedCondition, CompareCondition, BoolCondition, NumericCondition, IdentifierCondition, UnaryCondition, BinaryCondition, DeferredCondition, ShaderInstruction } from "./ICondition";
|
|
3
|
+
export * from "./PreprocessorExpression";
|
|
4
|
+
export * from "./ShaderIncludePath";
|
|
3
5
|
export type { IPrecompiledShader, IPrecompiledSubShader, IPrecompiledPass } from "./IPrecompiledShader";
|
|
4
6
|
export type { IShaderProgramSource as IShaderInfo } from "./IShaderProgramSource";
|
|
5
|
-
export { IRenderStates } from "./shaderSource/IRenderStates";
|
|
6
|
-
export { IShaderPassSource } from "./shaderSource/IShaderPassSource";
|
|
7
|
-
export { IShaderPosition } from "./shaderSource/IShaderPosition";
|
|
7
|
+
export type { IRenderStates } from "./shaderSource/IRenderStates";
|
|
8
|
+
export type { IShaderPassSource } from "./shaderSource/IShaderPassSource";
|
|
9
|
+
export type { IShaderPosition } from "./shaderSource/IShaderPosition";
|
|
8
10
|
export type { IShaderSource } from "./shaderSource/IShaderSource";
|
|
9
|
-
export { IStatement } from "./shaderSource/IStatement";
|
|
10
|
-
export { ISubShaderSource } from "./shaderSource/ISubShaderSource";
|
|
11
|
+
export type { IStatement } from "./shaderSource/IStatement";
|
|
12
|
+
export type { ISubShaderSource } from "./shaderSource/ISubShaderSource";
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { IRenderStates } from "./IRenderStates";
|
|
2
|
+
import { IShaderPosition } from "./IShaderPosition";
|
|
2
3
|
import { IStatement } from "./IStatement";
|
|
4
|
+
/** Parsed ShaderLab pass structure before backend generation. */
|
|
3
5
|
export interface IShaderPassSource {
|
|
6
|
+
/** Pass name. */
|
|
4
7
|
name: string;
|
|
8
|
+
/** ShaderLab statements inherited by or declared on the pass. */
|
|
5
9
|
pendingContents: IStatement[];
|
|
10
|
+
/** Whether the pass references another pass through `UsePass`. */
|
|
6
11
|
isUsePass: boolean;
|
|
12
|
+
/** User-defined pass tags. */
|
|
7
13
|
tags?: Record<string, number | string | boolean>;
|
|
14
|
+
/** Parsed render-state constants and variables. */
|
|
8
15
|
renderStates: IRenderStates;
|
|
9
16
|
/** Shader source code. */
|
|
10
17
|
contents: string;
|
|
18
|
+
/** Start offsets of Shader, SubShader, and Pass content layers in `contents`. */
|
|
19
|
+
contentScopeStarts: readonly number[];
|
|
20
|
+
/** Vertex entry-point name. */
|
|
11
21
|
vertexEntry: string;
|
|
22
|
+
/** Fragment entry-point name. */
|
|
12
23
|
fragmentEntry: string;
|
|
24
|
+
/** Source range of the vertex entry-point name. */
|
|
25
|
+
vertexEntryLocation?: {
|
|
26
|
+
start: IShaderPosition;
|
|
27
|
+
end: IShaderPosition;
|
|
28
|
+
};
|
|
29
|
+
/** Source range of the fragment entry-point name. */
|
|
30
|
+
fragmentEntryLocation?: {
|
|
31
|
+
start: IShaderPosition;
|
|
32
|
+
end: IShaderPosition;
|
|
33
|
+
};
|
|
13
34
|
}
|
|
@@ -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,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,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,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,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";
|