OrbitControls.js URL relocated?

I have been using OrbitControls.js in a web-based project (MCX Cloud - A Web-based Monte Carlo Photon Simulator). The URL I embedded in my webpage is https://threejs.org/examples/js/controls/OrbitControls.js.

In the past month, I found that my web app no longer works, complaining the OrbitControls.js can not be found. I found the URL was changed to https://threejs.org/examples/jsm/controls/OrbitControls.js

however, updating the URL in my code still triggers an JS error, complaining Uncaught TypeError: THREE.OrbitControls is not a constructor.

I want to understand what happened to the old OrbitControls.js - I suppose jsm is for module based JS? is there a non-modular OrbitControls.js, like the previous URL that one can include?

thanks, please let know how to to fix this issue.

@fangq

The examples/js folder is gone since r148. This is a step towards a modern and a better manageable Three.js ecosystem. Using OrbitControls.js from examples/jsm in a non-module project will not work as it is. My suggestion is to upload OrbitControls.js to Demoduler and it will try to convert it to the non-module version, that you can use.

Demoduler is here: https://boytchev.github.io/demoduler/

– Pavel

1 Like

Just for reference, it is frowned upon to import resources directly from the three.js domain and you should refrain from doing so, consider using a cdn such as cdnjs.com or hosting a local copy of the required files on your server!

You can find all previous releases of three on their github page, you could download the required files and serve as suggested above…

1 Like

agreed, lesson learned. among the nearly 10 external libraries I used, OrbitControls.js is the only one I could not find on cdnjs/jsdelivr and alike. I thought the upstream website would be a more stable provider, but it turned out I was wrong.

I have extracted the js/OrbitControls.js from previous releases and uploaded to my site, problem solved. thanks

1 Like