How to add OrbitControls

how do i add my OrbitControls into seperate js file

my html
import * as THREE from ‘https://threejsfundamentals.org/threejs/resources/threejs/r122/build/three.module.js’;

import {OrbitControls} from 'https://threejsfundamentals.org/threejs/resources/threejs/r122/examples/jsm/controls/OrbitControls.js';

js file


const orbitControl = new OrbitControls(camera,renderer.domElement);
orbitControl.update();

this giving me not defined

Well, it’s possible your file structure is messed. If you insist on using ES6 modules without a bundler, and splitting the code in any way, it may be easier to use /js files instead of /jsm. Take a look how orbit controls are imported for example here (imported in HTML, used in JS via a global THREE scope.)

Here’s an equivalent with jsm files - just remember to import the controls in the same script as you’re planning to use them in.