assistant-robot
Version:
An assistant widget, have a 3D robot which can interact with user, have a simple LLM which can chat with user.
60 lines (59 loc) • 2.02 kB
TypeScript
import { PerspectiveCamera, Scene, WebGL1Renderer, Object3D, AnimationMixer, AnimationClip, AnimationAction, Clock } from "three";
import type { TRobotModelConfig, IModelConfig, IActionConfig } from "./type";
/**
* assistant robot's 3d model manager.
* include the inition of the scene and the 3d model.
* include the methods to make the 3d model play an action or speek something
*/
export declare class AssistantModel {
clock: Clock;
container: Element;
tip: HTMLElement;
scene: Scene;
renderer: WebGL1Renderer | undefined;
model: Object3D | undefined;
camera: PerspectiveCamera | undefined;
mixer: AnimationMixer | undefined;
clips: AnimationClip[] | undefined;
timer: number | undefined;
options: TRobotModelConfig;
idleAction: AnimationAction | undefined;
constructor(container: Element, options: TRobotModelConfig);
/**
* init the 3d scene an 3d model for the robot
* @param options configs
*/
init(options?: TRobotModelConfig): void;
/**
* to load the 3d model
* @param modelUrl the url to load 3d model, default to use MR Potato
* @param param1 the config for the 3d model
*/
loadModel(modelUrl: string, { position, rotation }?: Partial<IModelConfig>): void;
startIdleAction(): void;
/**
* halt idle action
* @param duration how long time to halt
*/
haltIdleAction(duration: number): void;
hello(): void;
/**
* make the robot play a action
* @param name name of the action
* @param config config of the action
*/
play(name: string, { loop, weight, timeScale, repetitions, }?: IActionConfig): void;
hideTip(): void;
/**
* make the robot say something
* @param text what the robot should say
*/
say(text: string): void;
animate(): void;
/**
* make the robot rotate
* @param x the rotate angle on x axis
* @param y the rotate angle on y axis
*/
rotate(x?: number, y?: number): void;
}