How to import OrbitControls? I'm having trouble importing it!

I’m getting this error Uncaught TypeError: Failed to resolve module specifier “three”. Relative references must start with either “/”, “./”, or “…/”.

how did you import it?

the correct way is:

import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'

but that can only work with a bundler. if you use script tags you need something like skypack or unpkg, which are cdn bundlers.

1 Like

See Module Import / Usage

and the BeginnerExample from the Collection of examples from

Read the documents at bottom of *

1 Like

Thank you! I was using npm and installed modules and now it is solved after using cdn!

Thanks for sharing it helped me documentation is really good!!