babylon-mmd
Version:
babylon.js mmd loader and runtime
124 lines (123 loc) • 5.04 kB
TypeScript
import { Camera } from "@babylonjs/core/Cameras/camera";
import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector";
import { Observable } from "@babylonjs/core/Misc/observable";
import type { Scene } from "@babylonjs/core/scene";
import type { Nullable } from "@babylonjs/core/types";
import type { IMmdBindableCameraAnimation } from "./Animation/IMmdBindableAnimation";
import type { IMmdRuntimeCameraAnimation } from "./Animation/IMmdRuntimeAnimation";
import type { MmdCompositeRuntimeCameraAnimation } from "./Animation/mmdCompositeRuntimeCameraAnimation";
import type { MmdRuntimeCameraAnimation } from "./Animation/mmdRuntimeCameraAnimation";
import type { MmdRuntimeCameraAnimationContainer } from "./Animation/mmdRuntimeCameraAnimationContainer";
import type { IMmdCamera } from "./IMmdCamera";
import type { MmdRuntimeAnimationHandle } from "./mmdRuntimeAnimationHandle";
type RuntimeCameraAnimation = MmdRuntimeCameraAnimation | MmdRuntimeCameraAnimationContainer | MmdCompositeRuntimeCameraAnimation | IMmdRuntimeCameraAnimation;
/**
* MMD camera
*
* The MMD camera is a type of Arc Rotate Camera that determines the transform of the camera by the center position, rotation(yaw pitch roll), and distance parameters
*/
export declare class MmdCamera extends Camera implements IMmdCamera {
/**
* Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera
*/
ignoreParentScaling: boolean;
/**
* Define the current rotation of the camera
*/
rotation: Vector3;
/**
* Define the current distance of the camera from its target (default: -45)
*/
distance: number;
private readonly _viewMatrix;
private readonly _tmpUpVector;
private readonly _tmpTargetVector;
/**
* Observable triggered when the current animation is changed
*
* Value is 30fps frame time duration of the animation
*/
readonly onAnimationDurationChangedObservable: Observable<number>;
private readonly _animationHandleMap;
private _currentAnimation;
/**
* Creates a new MMD camera
* @param name Defines the name of the camera in the scene
* @param position Defines the position of the camera
* @param scene Defines the scene the camera belongs too
* @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
*/
constructor(name: string, position?: Vector3, scene?: Scene, setActiveOnSceneIfNoneActive?: boolean);
/**
* Bind the animation to the camera and return a handle to the runtime animation
* @param animation MMD animation or MMD camera animation group to add
* @returns A handle to the runtime animation
*/
createRuntimeAnimation(animation: IMmdBindableCameraAnimation): MmdRuntimeAnimationHandle;
/**
* Destroy a runtime animation by its handle
* @param handle The handle of the runtime animation to destroy
* @returns True if the animation was destroyed, false if it was not found
*/
destroyRuntimeAnimation(handle: MmdRuntimeAnimationHandle): boolean;
/**
* Set the current animation of the camera
*
* If handle is null, the current animation will be cleared
*
* @param handle The handle of the animation to set as current
* @throws {Error} if the animation with the handle is not found
*/
setRuntimeAnimation(handle: Nullable<MmdRuntimeAnimationHandle>): void;
/**
* Get the runtime animation map of the camera
*/
get runtimeAnimations(): ReadonlyMap<MmdRuntimeAnimationHandle, RuntimeCameraAnimation>;
/**
* Get the current animation of the camera
*/
get currentAnimation(): Nullable<RuntimeCameraAnimation>;
/**
* Duration of the animation in 30fps frame time
*/
get animationFrameTimeDuration(): number;
/**
* Animate the camera
* @param frameTime The 30fps frame time
*/
animate(frameTime: number): void;
private _storedPosition;
private _storedRotation;
private _storedDistance;
/**
* Store current camera state of the camera (fov, position, rotation, etc..)
* @returns the camera
*/
storeState(): Camera;
/**
* Restored camera state. You must call storeState() first
* @returns whether it was successful or not
* @internal
*/
_restoreStateValues(): boolean;
/** @internal */
_initCache(): void;
/**
* @internal
*/
_updateCache(ignoreParentClass?: boolean): void;
/** @internal */
_isSynchronizedViewMatrix(): boolean;
private static readonly _RotationMatrix;
private static readonly _CameraEyePosition;
private static readonly _UpVector;
private static readonly _TargetVector;
/** @internal */
_getViewMatrix(): Matrix;
/**
* Gets the current object class name.
* @returns the class name
*/
getClassName(): string;
}
export {};