๋๋ ๋ฒ ๋ค๋ฌ๋ก webpack์ ์ฌ์ฉํ๋ Angular ํ๋ก์ ํธ์์ three.js๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
GLTF ํ์ผ์๋ก๋ํ๋ ค๊ณ ํ ๋ ReferenceError๊ฐ ๋ฐ์ํฉ๋๋ค.
ERROR Error: Uncaught (in promise): ReferenceError: THREE is not defined
ReferenceError: THREE is not defined at GLTFLoader.js:2715
์ด ์ฝ๋ ์ค์ ์ฐธ์กฐํ์ญ์์ค.
TypeScript ์ฝ๋์์ ๋ค์๊ณผ ๊ฐ์ด ๋ก๋๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
import { GLTFLoader} from 'three/examples/jsm/loaders/GLTFLoader';
_BufferGeometryUtils_๋ฅผ _three.module.js_๋ก ๋ด๋ณด๋ด๊ฑฐ๋ ์ ์ญ _THREE_ ๊ฐ์ฒด๊ฐ ์ ์๋์ง ์์์ผ๋ฏ๋ก ์ฝ๋ ๋ธ๋ก์ GLTFLoader์ jsm ๋ฒ์ ์์ ์ ๊ฑฐํด์ผํฉ๋๋ค.
๋ํ _BufferGeometryUtils_๊ฐ _modularize_ ์คํฌ๋ฆฝํธ์์ ์์ธ๋ผ๋ ๊ฒ์ ๋ฐ๊ฒฌํ์ต๋๋ค.
์ํ๊น๊ฒ๋ examples/jsm
๋ชจ๋์ ์์ง ์์ ํ ์๋ํ์ง ์์ต๋๋ค. ์์ง ์์
์ค์
๋๋ค.
๋ค๋ฅธ ์ฌ์ฉ์๊ฐ ์ฌ๊ธฐ์์ ๋์ผํ ๋ฌธ์ ๋ฅผ๋ณด๊ณ ํ์ต๋๋ค.
# 15582๋ฅผ ๋ณํฉํ๋ฉด์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ ๋ ๊ฒ์ ๋๋ค.
๋๋ dev ๋ธ๋์น์์ ์
๋ฐ์ดํธ ๋ GLTFLoader๋ฅผ ์๋ํด ๋ณด์๊ณ , ๋ฆด๋ฆฌ์ค๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ฉด์ ์ ์๋ํ๊ณ ์์ต๋๋ค.
์์ ํด ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค!
๊ธด๊ธ ์์ ์ด ํ์ํ ์ฌ๋์ 'three-gltf-loader'npm ํจํค์ง๋ฅผ ์ฌ์ฉํ์ธ์.
import GLTFLoader from 'three-gltf-loader';
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๋ dev ๋ธ๋์น์์ ์ ๋ฐ์ดํธ ๋ GLTFLoader๋ฅผ ์๋ํด ๋ณด์๊ณ , ๋ฆด๋ฆฌ์ค๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ฉด์ ์ ์๋ํ๊ณ ์์ต๋๋ค.
์์ ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
๊ธด๊ธ ์์ ์ด ํ์ํ ์ฌ๋์ 'three-gltf-loader'npm ํจํค์ง๋ฅผ ์ฌ์ฉํ์ธ์.
import GLTFLoader from 'three-gltf-loader';