Frontend
[Three] Three.js 프로젝트 시작하기
Rayi
2025. 1. 12. 02:44
방법1. npm 사용
※ node.js가 필요합니다.
Three.js를 사용하고자 하는 프로젝트 경로에 들어가 아래 명령어를 이용해 설치합니다.
npm install --save three
만약 추가적인 빌드 툴이 없다면, 함께 설치할 수 있습니다. (예시 - vite)
npm install --save-dev vite
방법2. CDN 사용
npm과 빌드 툴을 이용해 패키지를 설치하는 대신, html 파일에 직접 어디서 패키지를 가져올 것인지 명시해주는 방법입니다.
html 파일의 <head> 태그 바로 다음에 아래 태그를 추가합니다.
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@[버전]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@[버전]/examples/jsm/"
}
}
</script>
728x90