sandai-react
Version:
React components and utilities for the Sandai 3D AI Characters.
90 lines • 3.85 kB
TypeScript
import { LoopType, MotionExpression } from "@davidcks/r3f-vrm";
import { AICharacterManager } from "../AICharacterManager";
import { VialbeEmotionType } from "../repo/animations/AnimationMetadataType";
import { FaceExpression } from "@davidcks/r3f-vrm/src/utils/FaceExpressionManager";
export interface PreparedChain extends Chain {
next: PreparedChain | null;
manager: AICharacterManager;
motionExpression: MotionExpression;
faceExpression: FaceExpression;
}
/**
* A chain of animations.
* @typedef {Object} Chain
* @property {string} motionAnimationName - The name of the motion animation.
* @property {Chain|null} [next] - The next chain item or null.
* @property {AICharacterManager} [manager] - The character manager.
* @property {VialbeEmotionType} [emotion] - The emotion to be applied. It should be one of the following values:
* 'love', 'joy', 'gratitude', 'caring', 'excitement', 'admiration',
* 'optimism', 'pride', 'amusement', 'relief', 'approval', 'desire',
* 'curiosity', 'surprise', 'realization', 'neutral', 'confusion',
* 'embarrassment', 'nervousness', 'annoyance', 'disapproval', 'remorse',
* 'fear', 'disappointment', 'sadness', 'anger', 'grief', 'disgust'.
* @property {number} [duration] - The duration in milliseconds.
* @property {number} [intensity] - The intensity as a number between 0 and 1.
* @property {LoopType} [loop] - The loop type. Can be LoopType.Repeat, LoopType.Once, or LoopType.FastForward.
*
* @example
* // Define a chain
* const chain = {
* motionAnimationName: 'walk',
* next: null,
* manager: myAICharacterManager,
* loop: LoopType.FastForward,
* };
*
* // Prepare the chain
* const preparedChain = await prepareChain(chain);
*
* // Play the prepared chain
* await playPreparedChain(preparedChain);
*/
export type Chain = {
motionAnimationName: string;
next: Chain | null;
manager?: AICharacterManager;
emotion?: VialbeEmotionType;
duration?: number;
intensity?: number;
loop?: LoopType;
};
export declare class ChainManager {
private _manager;
private _animationsByName;
constructor(manager: AICharacterManager);
/**
* Prepares a chain of animations by resolving motion expressions and recursively processing the next chain items.
*
* @param {Chain} item - The chain item to prepare.
* @returns {Promise<PreparedChain>} A promise that resolves to the prepared chain.
*
* @typedef {Object} Chain
* @property {string} motionAnimationName - The name of the motion animation.
* @property {Chain|null} [next] - The next chain item or null.
* @property {AICharacterManager} [manager] - The character manager.
* @property {LoopType} [loop] - The loop type.
*
* @typedef {Object} PreparedChain
* @property {string} motionAnimationName - The name of the motion animation.
* @property {MotionExpression} motionExpression - The prepared motion expression.
* @property {PreparedChain|null} [next] - The next prepared chain item or null.
* @property {AICharacterManager} manager - The character manager.
* @property {LoopType} [loop] - The loop type.
*
* @example
* // Define a chain
* const chain = {
* motionAnimationName: 'walk',
* next: null,
* manager: myAICharacterManager,
* loop: LoopType.FastForward,
* };
*
* // Prepare the chain
* const preparedChain = await prepareChain(chain);
*/
prepareChain(item: Chain): Promise<PreparedChain>;
playPreparedChain(chain: PreparedChain, loop?: LoopType): Promise<unknown>;
playChain(chain: Chain, loop?: LoopType): Promise<void>;
}
//# sourceMappingURL=ChainManager.d.ts.map