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:
- Is the primary purpose of
Addons.js
to serve as an alias for importing these modules? - Is it conventionally acceptable to use this file for imports?
- 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.