Modulizing OrbitController

I am modulizing my project and trying to set up my camera/render/canvas settings in a separate controller. When declaring my OrbitController it says it’s “not a constructor”.

This is the error im getting

This my app.js

This is my controller

What am I doing wrong?

Try importing OrbitControls from the same CDN as three.module.js. So:

You should never import three.js modules from different sources (and releases).

Still no difference…

117 is very old, i think that was even before classes were introduced. try using latest.

i am also not sure if jsdeliver is the right tool. you need a bundler to use modules. there are online bundlers like unpkg. but you have to use shims and import maps, but this stuff gets super awkward again.

i would recommend that you use a real bundler, all these problems will go away. you’re up and running in seconds with something like vite. install node, open console, type npm create vite follow the steps, npm install three, run the server npm run dev, open your editor and type:

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

I haven’t factorized the orbitController yet,but you’re answer helped me modulize other parts of the script! Thanks!