Reputation: 1263
I am starting a project in Three.js and I have correctly imported the library OrbitControls.js
, but when I open the console to test it, I see the following error:
Cannot read property 'prototype' of undefined
And it is related to the following line code inside OrbitConstrols.js:
THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
I found similar examples that research a solution for this problem, like this one, but it is made for Typescript.
Do you know a possible way to solve this issue? Or it is simply a bug of the library and even if I get an error, the object will be properly rendered?
Upvotes: 0
Views: 1849
Reputation: 742
I don't know how you are adding this in your HTML but the order matters when adding OrbitControls as it needs certain things from Three.js.
It should be
<script src="../build/three.min.js"></script>
<script src="js/controls/OrbitControls.js"></script>
The examples are the best way to figure out what is wrong - threejs.org/examples/misc_controls_orbit.html
Upvotes: 2