I'm Using Node 12 (experimental-modules) and three (npm) and i cant get Imports to work for OrbitControls.js. I have index.js as "script: module".
Neither of these ES6 imports work
I tried copying the OrbitControls.js file out of the js folder (from the root folder of three) and placing it adjacent to index.js then adding
import {OrbitControls} from "./OrbitControls.js"
It did not work i receive the error
Uncaught SyntaxError: The requested module './OrbitControls.js' does not provide an export named 'OrbitControls'
So I also tried to use the three library
import {OrbitControls} from "/three/examples/jsm/controls/OrbitControls";
returns 404 error, so i tried relative imports
import {OrbitControls} from "../../node_modules/three/examples/jsm/controls/OrbitControls.js";
got the 404 error again.
Ive also tried (something another user reccommended) const OrbitControls = new THREE.OrbitControls but the error seems happen from the ES6 import alone.
I haven't used experimental-modules, but your second example should read
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
without the /
before three
;
If that doesn't work, you could try copy-pasting the OrbitControls.js source code from here to your own folder.
import { OrbitControls } from "./myFolder/OrbitControls";
If this works, then it might be a problem with your node_modules
installation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.