행동 실행
디지털 휴먼이 특정 애니메이션 액션을 실행하도록 합니다.
메서드
executeAction(actionId)
지정된 액션 ID에 해당하는 애니메이션을 실행합니다.
public executeAction(actionId: string): void
매개변수
actionId(string): 실행할 액션 ID (예:"JOB_001")
사용법
JavaScript/TypeScript
import { KleverOneClient } from "@klever-one/web-sdk/core";
const client = new KleverOneClient({
apiKey: "your-api-key",
container: document.getElementById("streaming-container"),
});
// 연결 후 액션 실행
await client.connect();
// 예시 액션 실행
client.executeAction("JOB_001");
React Hook
"use client";
import { useRef, useEffect, useMemo } from "react";
import { useKleverOneClient } from "@klever-one/web-sdk/react";
function ActionControl() {
const containerRef = useRef<HTMLDivElement>(null);
const tempContainer = useMemo(() => {
if (typeof document !== "undefined") {
return document.createElement("div");
}
return {} as HTMLDivElement;
}, []);
const client = useKleverOneClient({
apiKey: "your-api-key",
container: containerRef.current || tempContainer,
callbacks: {
onReady: () => console.log("디지털 휴먼 준비 완료!"),
},
});
useEffect(() => {
return () => {
if (client.client) {
client.disconnect();
}
};
}, [client.client]);
const handleExecuteAction = (actionId: string) => {
if (client.client) {
client.executeAction(actionId);
}
};
return (
<div>
<div
ref={containerRef}
className="h-[400px] w-[800px] bg-black rounded-lg"
></div>
<div className="action-controls">
<button
onClick={() => handleExecuteAction("JOB_001")}
disabled={client.state.connection !== "connected"}
>
행동 실행
</button>
</div>
</div>
);
}
사용 가능한 액션 ID
일반 동작 (Normal Actions)
| 행동 | ID | 시간(초) |
|---|---|---|
| 차렷 | NOR_001 | 21.70 |
| 손인사 | NOR_002 | 4.93 |
| 긍정 | NOR_003 | 4.77 |
| 팔짱 | NOR_004 | 9.73 |
| 주시 | NOR_005 | 9.73 |
| 지적 | NOR_006 | 5.37 |
| 거만 | NOR_007 | 5.20 |
| 고민 | NOR_008 | 9.60 |
| OK | NOR_009 | 4.33 |
| 경고 | NOR_010 | 5.87 |
| 감사 | NOR_011 | 7.90 |
강의 동작 (Gesture Actions)
| 행동 | ID | 시간(초) |
|---|---|---|
| 강의1 | JOB_001 | 8.77 |
| 강의2 | JOB_002 | 5.53 |
| 강의3 | JOB_003 | 5.87 |
| 강의4 | JOB_004 | 6.97 |
| 강의5 | JOB_005 | 7.60 |
| 강의6 | JOB_006 | 6.53 |
| 강의7 | JOB_007 | 6.93 |
| 강의8 | JOB_008 | 9.23 |
| 강의9 | JOB_009 | 7.67 |
감정 표현 (Emotion Actions)
| 행동 | ID | 시간(초) |
|---|---|---|
| 짜증 | EMO_001 | 6.70 |
| 거부 | EMO_002 | 6.87 |
| 쭈글 | EMO_003 | 6.03 |
| 다짐 | EMO_004 | 4.53 |
| 안심 | EMO_005 | 6.37 |
| 삐짐 | EMO_006 | 6.37 |
| 미안 | EMO_007 | 4.77 |
| 놀람 | EMO_008 | 3.43 |
| 힘내 | EMO_009 | 3.70 |
| 하트 | EMO_010 | 4.97 |
댄스 (Dance Actions)
| 행동 | ID | 시간(초) |
|---|---|---|
| Faz o M | DNC_001 | 18.21 |
| Smurf | DNC_002 | 12.20 |
| SodaPop | DNC_003 | 18.30 |
| Cheerleader | DNC_004 | 17.97 |
| PomPom | DNC_005 | 16.63 |
| Doremi | DNC_006 | 24.93 |
| HipDance | DNC_007 | 16.43 |
| GonDance | DNC_008 | 19.93 |
| JapanTrendy | DNC_009 | 22.83 |