UNPKG

babylon-mmd

Version:
145 lines (144 loc) 4.71 kB
import type { IEasingFunction } from "@babylonjs/core/Animations/easing"; import { Observable } from "@babylonjs/core/Misc/observable"; import type { Nullable } from "@babylonjs/core/types"; import type { IMmdAnimation } from "../../Loader/Animation/IMmdAnimation"; import type { IMmdBindableCameraAnimation, IMmdBindableModelAnimation } from "./IMmdBindableAnimation"; import type { IMmdRuntimeModelAnimationWithBindingInfo } from "./IMmdRuntimeAnimation"; type MmdBindableAnimation = IMmdBindableCameraAnimation | IMmdBindableModelAnimation<IMmdRuntimeModelAnimationWithBindingInfo>; /** * Represents a slice of an MMD animation */ export declare class MmdAnimationSpan { /** * The animation that this span uses */ readonly animation: MmdBindableAnimation; /** * Start frame of the span (default: animation.startFrame) * * You can slice the desired range by the difference from the starting point of the original animation */ startFrame: number; /** * End frame of the span (default: animation.endFrame) * * You can slice the desired range by the difference from the starting point of the original animation */ endFrame: number; /** * Offset of the span (default: 0) * * Determines at what point in the `MmdCompositeAnimation` the span will be played */ offset: number; /** * Animation weight (default: 1) * * Internally, it is normalized and treated as a value between 0 and 1 on evaluation */ weight: number; /** * easing function of the span (default: null) */ easingFunction: Nullable<IEasingFunction>; /** * Ease in frame time of the span (default: 0) */ easeInFrameTime: number; /** * Ease out frame time of the span (default: 0) */ easeOutFrameTime: number; /** * Create a new span * @param animation Bindable animation, which typically means `MmdAnimation` * @param startFrame Start frame of the span (default: animation.startFrame) * @param endFrame End frame of the span (default: animation.endFrame) * @param offset Offset of the span (default: 0) * @param weight Animation weight (default: 1) */ constructor(animation: MmdBindableAnimation, startFrame?: number, endFrame?: number, offset?: number, weight?: number); /** * Name of the animation */ get name(): string; /** * Whether the frame time is in the span * @param frameTime frame time in composite animation * @returns Returns true if the frame time is in the span */ isInSpan(frameTime: number): boolean; /** * Get the frame time in this span * @param frameTime frame time in composite animation * @returns Returns the frame time in this span */ getFrameTime(frameTime: number): number; /** * Get the eased weight of this span * @param frameTime frame time in this span * @returns Returns the eased weight of this span */ getEasedWeight(frameTime: number): number; } /** * Combine multiple animations into a single animation * * Good for uses like QTE sequences where animation blending is determined at runtime */ export declare class MmdCompositeAnimation implements IMmdAnimation { /** * Observable that is triggered when a span is added */ readonly onSpanAddedObservable: Observable<MmdAnimationSpan>; /** * Observable that is triggered when a span is removed */ readonly onSpanRemovedObservable: Observable<number>; /** * Animation name for identification */ readonly name: string; private _startFrame; private _endFrame; private readonly _spans; /** * Create a new composite animation * @param name Animation name */ constructor(name: string); /** * Add a span to the animation * * animation will be pushed to the end of the `spans` array * @param span Span to add */ addSpan(span: MmdAnimationSpan): void; /** * Remove a span from the animation * * If the span does not exist, do nothing * @param span Span to remove */ removeSpan(span: MmdAnimationSpan): void; /** * Remove a span from the animation * * If index is out of range, do nothing * @param index Index of the span to remove */ removeSpanFromIndex(index: number): void; /** * The start frame of this animation */ get startFrame(): number; /** * The end frame of this animation */ get endFrame(): number; /** * The spans of this animation */ get spans(): readonly MmdAnimationSpan[]; } export {};