Load a Local glTF Model

Three.js lessons
/

Load a Local glTF Model

Intermediate

Assets & scale

Lesson 11 of 15

Module project

Load a real project asset with GLTFLoader and organize module code across files.

Import GLTFLoader, load a self-authored pyramid from the project, and reuse a color from a local JavaScript module.

How this scene works

Module mode uses explicit imports from @playground/runtime and the supported three/addons paths. The relative ./palette.js import is another editable project file. assetUrl resolves assets/pyramid.gltf to a local project URL. This glTF 2.0 fixture contains its geometry in a data URI, so it has no network dependency. GLTFLoader also accepts binary .glb assets; change the filename after uploading one. The loader is awaited before the run becomes ready, and the loaded Scene is added as a child of the playground Scene.

Included project files

palette.jsassets/pyramid.gltf

Load a Local glTF Model

Ready to run

ES modules · Three.js 0.183.1 · WebGL

Loading draft

3 files · local only

Ctrl/Cmd+Enter: run · Ctrl/Cmd+F: find · Tab: leave editor
Run your code to start the scene.
Drag to orbit, scroll to zoom, right-drag to pan.
Drag: orbit · Scroll: zoom · Right-drag: pan

Make it your own

Edit accent in palette.js, then change the pyramid material's roughness. Upload your own self-contained .glb, update assetUrl, and inspect its hierarchy before adjusting the camera.

Change one thing, run the scene, and compare. Pause animation to inspect the result; reset the example to return to its original code and files.

FAQ