@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
69 lines (68 loc) • 3.01 kB
TypeScript
import { AnimationAction, AnimationClip, AnimationMixer, Object3D, Vector3Like } from "three";
import type { Context } from "./engine_context.js";
import { IAnimationComponent, Model } from "./engine_types.js";
/**
* Registry for animation related data. Use {@link registerAnimationMixer} to register an animation mixer instance.
* Can be accessed from {@link Context.animations} and is used internally e.g. when exporting GLTF files.
* @category Animation
*/
export declare class AnimationsRegistry {
readonly context: Context;
readonly mixers: AnimationMixer[];
constructor(context: Context);
/** @hidden @internal */
onDestroy(): void;
/**
* Register an animation mixer instance.
*/
registerAnimationMixer(mixer: AnimationMixer): void;
/**
* Unregister an animation mixer instance.
*/
unregisterAnimationMixer(mixer: AnimationMixer | null | undefined): void;
}
/**
* Utility class for working with animations.
*/
export declare class AnimationUtils {
/**
* Tests if the root object of an AnimationAction can be animated. Objects where matrixAutoUpdate or matrixWorldAutoUpdate is set to false may not animate correctly.
* @param action The AnimationAction to test
* @param allowLog Whether to allow logging warnings. Default is false, which only allows logging in development environments.
* @returns True if the root object can be animated, false otherwise
*/
static testIfRootCanAnimate(action: AnimationAction, allowLog?: boolean): boolean;
/**
* Tries to get the animation actions from an animation mixer.
* @param mixer The animation mixer to get the actions from
* @returns The actions or null if the mixer is invalid
*/
static tryGetActionsFromMixer(mixer: AnimationMixer): Array<AnimationAction> | null;
static tryGetAnimationClipsFromObjectHierarchy(obj: Object3D, target?: Array<AnimationClip>): Array<AnimationClip>;
/**
* Assigns animations from a GLTF file to the objects in the scene.
* This method will look for objects in the scene that have animations and assign them to the correct objects.
* @param file The GLTF file to assign the animations from
*/
static autoplayAnimations(file: Object3D | Pick<Model, "animations" | "scene">): Array<IAnimationComponent> | null;
static emptyClip(): AnimationClip;
static createScaleClip(options?: ScaleClipOptions): AnimationClip;
}
/**
* Type of scale animation to create.
* - "linear": Simple linear scale up animation.
* - "spring": Spring-like scale animation with overshoot and settling.
*/
export type ScaleClipType = "linear" | "spring";
type ScaleClipOptions = {
/**
* Type of scale animation to create.
* - "linear": Simple linear scale up animation.
* - "spring": Spring-like scale animation with overshoot and settling.
*/
type?: ScaleClipType;
duration?: number;
scale?: number | Vector3Like;
scaleFactor?: number;
};
export {};