배경 이미지 설정
디지털 휴먼 환경의 배경 이미지를 변경하거나 초기화합니다.
메서드
sendPlaceBackgroundChange(id)
배경 이미지를 변경합니다.
public sendPlaceBackgroundChange(id: string): void
매개변수
id(string): 배경 이미지 ID
sendBackgroundPlaceReset()
배경 이미지를 기본값으로 초기화합니다.
public sendBackgroundPlaceReset(): void
사용법
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.sendPlaceBackgroundChange("WORLD_01");
// 배경 이미지 초기화
client.sendBackgroundPlaceReset();
React Hook
"use client";
import { useRef, useMemo } from "react";
import { useKleverOneClient } from "@klever-one/web-sdk/react";
function BackgroundPlaceControl() {
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,
});
const handleChangeBackground = (backgroundId: string) => {
if (client.client) {
client.sendPlaceBackgroundChange(backgroundId);
}
};
const handleResetBackground = () => {
if (client.client) {
client.sendBackgroundPlaceReset();
}
};
return (
<div>
<div
ref={containerRef}
className="h-[400px] w-[800px] bg-black rounded-lg"
></div>
<div className="controls">
<button
onClick={() => handleChangeBackground("WORLD_01")}
disabled={client.state.connection !== "connected"}
>
배경 1
</button>
<button
onClick={() => handleChangeBackground("WORLD_04")}
disabled={client.state.connection !== "connected"}
>
배경 2
</button>
<button
onClick={handleResetBackground}
disabled={client.state.connection !== "connected"}
>
기본 배경
</button>
</div>
</div>
);
}
사용 가능한 배경 ID
| 장소명 | ID |
|---|---|
| 스튜디오 | WORLD_01 |
| 경복궁 | WORLD_04 |
| 남산타워 | WORLD_09 |
| 달 | WORLD_13 |
| 동대문역사문화공원 | WORLD_14 |
| 메디나 아자하라 | WORLD_16 |
| 무대C | WORLD_19 |
| 술탄 카부스 대모스크 | WORLD_21 |
| 아야 소피아 | WORLD_22 |
| 카툰A | WORLD_24 |
| 큐티 | WORLD_28 |
| 하트 | WORLD_30 |
| 해변 | WORLD_31 |
| 향원정 | WORLD_32 |
| 헬스장 | WORLD_33 |
주의사항
- 배경 이미지 변경은 연결 상태에서만 가능합니다.