Skip to main content

줌 제어

디지털 휴먼 화면을 확대하거나 축소합니다.

메서드

sendZoomIn()

화면을 줌 인합니다.

public sendZoomIn(): void

sendZoomOut()

화면을 줌 아웃합니다.

public sendZoomOut(): 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.sendZoomIn();

// 줌 아웃 실행
client.sendZoomOut();

React Hook

"use client";

import { useRef, useEffect, useMemo } from "react";
import { useKleverOneClient } from "@klever-one/web-sdk/react";

function ZoomControls() {
const containerRef = useRef(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 handleZoomIn = () => {
if (client.client) {
client.sendZoomIn();
}
};

const handleZoomOut = () => {
if (client.client) {
client.sendZoomOut();
}
};

return (
<div>
<div
ref={containerRef}
className="h-[400px] w-[800px] bg-black rounded-lg"
></div>

<div className="zoom-controls">
<button
onClick={handleZoomIn}
disabled={client.state.connection !== "connected"}
>
+ 줌 인
</button>
<button
onClick={handleZoomOut}
disabled={client.state.connection !== "connected"}
>
- 줌 아웃
</button>
</div>
</div>
);
}

관련 기능