Having trouble implementing OrbitControls with requirejs.
Here's my configuration:
I attempted to follow guidance from this post on Stack Overflow RequireJS and THREE.js Orbit Controls, but it's not working.
requirejs.config({
baseUrl: './js',
deps: ['main'],
paths: {
threejs: 'three/three.min',
orbitControls: 'three/controls/OrbitControls',
},
shim: {
'threejs': {
exports: 'THREE'
},
'orbitControls': {
deps: ['threejs']
}
}
});
Next, I define THREE in main.js I also referenced a GitHub post at https://github.com/mrdoob/three.js/issues/9602
define('threejs', function ( THREE ) {
window.THREE = THREE;
return THREE;
});
Then I'm trying to use OrbitControls in my scene
var controls = new THREE.OrbitControls(this.camera, this.renderer.domElement);
But I'm encountering an error:
Uncaught TypeError: THREE.OrbitControls is not a constructor
I'm uncertain if I need to include orbitControls in the define section of my class
define(['orbitControls'], function() {
var controls = new THREE.OrbitControls(this.camera, this.renderer.domElement);
})
However, attempting this results in an error:
Uncaught ReferenceError: THREE is not defined
Despite the rest of the scene rendering correctly with THREE defined.
If anyone has successfully configured this and could offer some guidance, I would greatly appreciate it.