Using three/examples/jsm/Addons.js for Imports: Best Practices and Future Stability

While working with Three.js, I usually import modules such as OrbitControls, TextGeometry, and FontLoader from their specific paths within node_modules/three/examples/jsm/, like this:

import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
// ...

However, today I accidentally selected an auto-suggestion in my IDE that imported from a different path: three/examples/jsm/Addons.js. When I opened this file, I found that it exports all the addons available in three/examples/jsm. I updated my import statements to:

import {
  OrbitControls,
  FontLoader,
  TextGeometry,
} from 'three/examples/jsm/Addons.js';

This approach works without any issues. My questions are:

  1. Is the primary purpose of Addons.js to serve as an alias for importing these modules?
  2. Is it conventionally acceptable to use this file for imports?
  3. Is there a chance that this method could change in future releases?

I personally prefer this approach for its simplicity but want to ensure it’s reliable for long-term use.

2 Likes

wow that’s handy!

I’m gonna use that until it breaks. :smiley:

edit: I wouldn’t worry about it going away… it’s gonna be pinned to whatever version of three you’re importing.
If it does go away, you can probably just copy it over locally and use it. I don’t see why it would go away either, it looks super handy! Definitely gonna try it out…

3 Likes

You’re right, copying it locally as a backup is a great idea. Thanks for the input and for helping out :heart:!