Recent change to OrbitControls breaks some projects

Hey

Some projects that used to successfully use OrbitControls are now throwing an error. When included with https://threejs.org/examples/js/controls/OrbitControls.js the following error is printed in the console:

TypeError: THREE.TOUCH is undefined[Learn More] OrbitControls.js:82:19
OrbitControls https://threejs.org/examples/js/controls/OrbitControls.js:82

This is not the case if OrbitControls is included with, for example https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/controls/OrbitControls.js

Error example: https://codepen.io/anon/pen/vomjZV
Working example: https://codepen.io/anon/pen/wVdjdV

What is the new correct way to include OrbitControls in a project?

The documentation says:

When using code from the examples directory, it’s important that all files match the version of your three.js main file. For example, it’s not acceptable to use GLTFLoader and OrbitControls from R96 together with three.js R103.

So the solution is to update three.js to the latest version R107.

3 Likes

Thank you for the reply. Is including three.js with https://threejs.org/build/three.js a safe way to keep a project linked to the latest version or should updates always be manual by specifying the version number (e.g. r107)?

Correct, this link provides the latest version of three.js.

2 Likes