Reputation: 460
I am working on a project where I need to develop a simple 1 HTML web application with 3D graphics. I decided to use Three.js, but there is a problem, I am really confused about how to make imports. While running examples everything seems to work, but when I try to implement the same ideas in my code I keep getting all sorts of errors.
My problem is that I am not willing to use tons of different frameworks and additional libraries, I want to keep things simple and use just node js and express for the webserver and pure HTML, CSS, and JS (with Three.js) for the front end, for Three.js I found this public CDN.
So now where the problem comes in, in code I am trying importing Three.js things like that:
import * as THREE from "https://unpkg.com/[email protected]/build/three.module.js";
import { OrbitControls } from "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js";
and code works absolutly fine with older versions (< 0.128.0) but after 0.127.0 release for some reason imports are no longer relative:
Older version (0.127.0):
// https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js
import {
...
} from '../../../build/three.module.js';
Newest version (0.130.0):
// https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js
import {
...
} from 'three';
and with newer versions I get following error:
TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".
What am I doing wrong and is it even possible to use these new version with CDN?
Comple code can be found here
Upvotes: 0
Views: 522
Reputation: 157
https://github.com/mrdoob/three.js/wiki/Migration-Guide#127--128
Upvotes: 1