Importing Three.js Modules
Video Lecture
Description
The core of Three.js is focused on the most important components of the 3D engine. For example, that is classes related to managing the scene graph, cameras, renderers, primitive geometries, textures, lighting, shadows and more.
To keep the core small and manageable to quickly download, many modules, such as 3D model loaders, controls and other utilities can be downloaded as addons
from the examples/jsm
folder.
If we want to use these extra modules in our projects, then we can import them separately.
The ./node_modules/three/examples/jsm/
directory, which was installed as part of Threejs library, contains many useful extra modules that we can use in our Threejs projects.
In this lesson, I will show you how to import the OrbitControls into the existing TypeScript project.
Lesson Script
./src/main.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
If your project is not currently running,
npm run dev
and visit http://localhost:5173/