Orbit Control is not defined

Hi orbit control is showing following error:

Uncaught ReferenceError: OrbitControls is not defined

When i try to define it as
var controls = new THREE.OrbitControls( camera, renderer.domElement );

it shows following error:
Uncaught TypeError: THREE.OrbitControls is not a constructor

Is it possible for you to share your complete code as a GitHub repository?

Hey i am facing some difficulties while making a repository. Can i share my code here?

It’s important to share your project. Posting the files directly here is no good idea.

If you can’t share your project at GitHub, consider to share the project with e.g. Google Drive.


Okay, you are using the global script version of OrbitControls. So you definitely have to use this approach:

var controls = new THREE.OrbitControls( camera, renderer.domElement );

However, I’m not able to help any further since your project is based on Python/Django which I’m not familiar with. Hence, I could not test your app locally. But I suspect something goes wrong when importing OrbitControls. Instead of doing this:

<script type="module" src="{% static 'js/OrbitControls.js' %}"></script>

try it with this code:

<script src="{% static 'js/OrbitControls.js' %}"></script>

type="module" does not make sense here. If this does not work, check your browser console for 404 errors. There might be a problem how the path to OrbitControls.js is generated.


Thanks man my scene is back but but my controls are not working, i cant zoom or rotate the scene. And it is not showing any error in console. :tired_face:

Can you host your app somewhere?