Vanilla JavaScript 환경에서 VRISM Viewer SDK를 커스터마이징하는 방법을 소개합니다.
const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id',
config: {
ui: {
// 배경색 변경
viewerBackgroundColor: '#f8f9fa',
// UI 요소 제어
gestureGuide: true, // 제스처 가이드 표시
fullscreenButton: true, // 전체화면 버튼 표시
userGuide: true, // 사용자 가이드 표시
vtoControl: true, // VTO 컨트롤 표시
// 로더 커스터마이징
loader: {
type: 'circle', // 'circle' 또는 'bar'
size: 'medium', // 'small', 'medium', 'large'
loaderFillColor: '#007bff', // 로더 색상
loaderPlaceholderColor: '#e9ecef'
}
}
}
});const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id',
config: {
camera: {
// 자동 회전
autoRotation: -2,
// 사용자 조작 제어
controls: {
enableZoom: true, // 줌 허용
enablePan: true, // 팬(이동) 허용
enableRotate: true // 회전 허용
},
// 데스크톱 초기 위치
desktop: {
angle: { x: 0.2, y: 0.1 },
zoom: 1.5,
limits: {
angleUp: 1.5,
angleDown: -1.5,
zoomMin: 0.5,
zoomMax: 3.0
}
}
}
}
});ℹ️ 카메라 설정의
desktop/mobile분기는 뷰포트 너비 769px을 기준으로 자동 적용됩니다.
/* styles.css */
.my-viewer {
/* 전체화면 버튼 */
--fullscreenBtnBgColor: #007bff;
--fullscreenIconColor: white;
--fullscreenBtnSize: 48px;
--fullscreenBtnRight: 20px;
--fullscreenBtnBottom: 20px;
/* 사용자 가이드 버튼 */
--guideBtnBgColor: #ffffff;
--guideBtnIconColor: #333333;
--guideBtnSize: 48px;
--guideIconSize: 28px;
--guideBtnRight: 28px;
--guideBtnBottom: 80px;
/* VTO 버튼 */
--vtoBtnBgColor: #28a745;
--vtoBtnColor: white;
--vtoFontSize: 16px;
--vtoIconSize: 28px;
--vtoBtnLeft: 20px;
--vtoBtnBottom: 20px;
/* 제스처 가이드 */
--gestureGuideIconSize: 48px;
}<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<script src="https://unpkg.com/@vrism/viewer-sdk@0.1.0/dist/vanilla/umd.js"></script>
</head>
<body>
<div id="viewer-container" class="my-viewer" style="width: 100%; height: 500px;"></div>
<script>
const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id',
config: {
ui: {
fullscreenButton: true,
userGuide: true,
vtoControl: true
}
}
});
</script>
</body>
</html><!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/@vrism/viewer-sdk@0.1.0/dist/vanilla/umd.js"></script>
<style>
.brand-viewer {
/* 브랜드 컬러로 버튼 통일 */
--fullscreenBtnBgColor: #ff6b35;
--fullscreenIconColor: white;
--guideBtnBgColor: #ff6b35;
--guideBtnIconColor: white;
--vtoBtnBgColor: #ff6b35;
/* 버튼들을 더 크게 */
--fullscreenBtnSize: 56px;
--guideBtnSize: 56px;
/* 버튼 위치 조정 */
--fullscreenBtnRight: 24px;
--fullscreenBtnBottom: 24px;
--guideBtnRight: 24px;
--guideBtnBottom: 88px;
}
</style>
</head>
<body>
<div id="viewer-container" class="brand-viewer" style="width: 100%; height: 500px;"></div>
<script>
const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id',
config: {
ui: {
viewerBackgroundColor: '#f8f9fa',
fullscreenButton: true,
userGuide: true,
vtoControl: true
}
}
});
</script>
</body>
</html>const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id',
config: {
ui: {
step: {
enabled: true, // 스텝 기능 활성화
stepControls: true, // 이전/다음 버튼 표시
stepDots: true, // 스텝 도트 네비게이션 표시
stepAnnotation: false // 🎯 마커만 끄기
}
}
}
});<div>
<!-- 커스텀 스텝 네비게이션 -->
<div class="custom-nav">
<button onclick="goToStep(0)">전체 뷰</button>
<button onclick="goToStep(1)">측면 뷰</button>
<button onclick="goToStep(2)">상세 뷰</button>
</div>
<div id="viewer-container" style="width: 100%; height: 500px;"></div>
</div>
<script>
const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id',
config: {
ui: {
step: {
enabled: true, // 스텝 기능 활성화
stepControls: false, // 기본 이전/다음 버튼 숨김
stepDots: false, // 기본 도트 네비게이션 숨김
stepAnnotation: false // 마커 숨김
}
}
},
onStepChange: (options) => {
console.log('스텝 변경:', options.step, options.direction);
currentStep = options.step || 0;
}
});
let currentStep = 0;
// 커스텀 네비게이션 함수
window.goToStep = (step) => {
viewer.setStep(step);
currentStep = step;
};
</script><div>
<button onclick="changeBackground('#ffffff')">흰색 배경</button>
<button onclick="changeBackground('#000000')">검은색 배경</button>
<button onclick="changeBackground('#f8f9fa')">회색 배경</button>
</div>
<div id="viewer-container" style="width: 100%; height: 500px;"></div>
<script>
const viewer = VrismSDK.VrismViewer.init('viewer-container', {
token: 'your-token-here',
contentId: 'your-content-id'
});
window.changeBackground = (color) => {
// 부분 설정 업데이트로 즉시 반영
viewer.setConfig({
ui: { viewerBackgroundColor: color }
});
};
</script>