Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing relative path to three in examples #21853

Closed
derCodemeister opened this issue May 18, 2021 · 3 comments
Closed

Missing relative path to three in examples #21853

derCodemeister opened this issue May 18, 2021 · 3 comments
Labels

Comments

@derCodemeister
Copy link

when instaling r128 with npm the files in examples/jsm/ seem to import like this:
import {
....
} from 'three';
instead of a relative path (../../../build/three.modules.js) (as it is done in r127)
Hence Browsers complain, that three is not a relative path and do not load anything.

However, I cannot find the problem in the current code base on github - which uses the relative path. I checked out the master-branch, and it also uses the relative path.

However, if I use npm install three, the relative path is replace by "three" in files which were moved to ES6 class syntax.
My specific case was with "examples/jsm/curves/NURBSCurve.js", but the problem seems to permate many more files.

Platform:

  • Device: Desktop
  • OS: Linux (Windows)
  • Browser: checked with Vivaldi (Chrome based), Firefox
  • Three.js version: r128
@Mugen87
Copy link
Collaborator

Mugen87 commented May 18, 2021

This is actually intended. It was changed with r128, see #21654.

The change was done in order to solve #17482. Also read #21707 for more information.

@Mugen87 Mugen87 closed this as completed May 18, 2021
@mrdoob mrdoob changed the title Missing rel. path to three in examples Missing relative path to three in examples May 19, 2021
@kbarros
Copy link

kbarros commented Nov 22, 2021

Javascript newbie here. I spent a lot of time confused by this, so maybe it will help others to document my current understanding. Per #22008 (comment), the answer seems to be "loading modules in web apps from node_modules is not supported anymore." Looking at the migration guide, it is suggested to use https://cdn.skypack.dev to load modules. For example, this seems to work:

import * as THREE from 'https://cdn.skypack.dev/three';
import { OrbitControls } from 'https://cdn.skypack.dev/three/examples/jsm/controls/OrbitControls';

As far as I can tell, there is no way to get npm install --save three to work without using a bundler (one of: Webpack, Rollup, ...), and the bundler setup seems to be quite complicated.

Without a bundler this complains:

import * as THREE from './node_modules/three/build/three.module.js.; // OK
import { OrbitControls } from './node_modules/three/examples/jsm/controls/OrbitControls.js'; // Fails

As the original commenter says, the problem is that OrbitControls.js tries to load from the three module directly, but that doesn't work because three hasn't been bundled.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 22, 2021

Please use the forum is you need help regarding your development process and module usage.

Repository owner locked as off-topic and limited conversation to collaborators Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants