I've been attempting to incorporate OrbitControls into my three.js project, but when I try to instantiate the constructor, I encounter an error stating "THREE.OrbitControls is not a constructor". Despite my efforts to find a solution by importing the file explicitly, the error persists. Here's my code:
<script src="JS/three.js"></script>
<scirpt src="JS/OrbitControls.js"></scirpt>
<script src="JS/Models/ModelLoader.js"></script>
<script>
var scene = new THREE.Scene( );
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.01, 10000 );
var renderer = new THREE.WebGLRenderer( );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
camera.position.z = 3;
var controls = new THREE.OrbitControls(camera, renderer.domElement);//issue arises here
var pointLight = new THREE.PointLight(0,2);
pointLight.position.z = 2;
scene.add(pointLight);
// Game Logic
var update = function( ){
}
// Draw Scene
var render = function( ){
renderer.render( scene, camera );
}
var testLoad = function(){
var modelLoader = new ModelLoader();
var obj = modelLoader.loadObj("/Res/Models/Characters/char1.obj", "/Res/Models/Characters/char1.mtl");
scene.add(obj);
}
// Main Game Loop(update, render, repeat)
var gameLoop = function( ){
requestAnimationFrame( gameLoop );
update( );
render( );
}
gameLoop();
The ModelLoader represents a custom class used for loading obj files.
If anyone has insights on what may have gone wrong, your assistance is greatly appreciated!