[three-js] exposes real modules now via three/examples/jsm/... For example to import the Orbit, do
is the three.js OrbitControls from official repo examples
To install with npm do
npm install threenpm install three-orbitcontrols
I have just stolen the code and modified to export it as a module so you can do something like
const THREE =const OrbitControls =// ES6 also works, i.e.// import OrbitControls from 'three-orbitcontrols'// Init THREE scene (add your code)const camera = 75 width / height 01 1000camerapositionz = 5const renderer = canvasconst controls = camera rendererdomElementcontrolsenableDamping = truecontrolsdampingFactor = 025controlsenableZoom = false
Please note that:
- You call
OrbitControlsdirectly instead of
- This package does not depend directly on three.js, which is declared as a peer dependency.
See also examples:
- CommonJS example: clone this repo, install deps and launch
npm run example_commonjs.
- TypeScript example: clone this repo, install deps and launch
npm run example_typescript.
Please also note that this repo's minor version equals three.js release number.