What do to if can't use imports

I was using three J’s in high school 2021 I change a lot. So I’m used to three.js I’m a offline coder I can download stuff using my phone. But now I can’t figure how to do it. Can you still do it the same like using a file on the computer or not.

The recent versions of threejs all use “import” but you should still be able to use it offline. You just can’t load any files. . And you have to have an “import map” script in your HTML to point “three” to the path you have it.

You might also run into CORS problems if you don’t run a web server or at least a simple node script locally to serve the files.

The only way I know of is using unpkg.com. For instance:

import * as THREE from “https://unpkg.com/three@latest/build/three.module.js?module”;
import { VertexNormalsHelper } from “https://unpkg.com/three@latest/examples/jsm/helpers/VertexNormalsHelper.js?module”;
import { OBJLoader } from “https://unpkg.com/three@latest/examples/jsm/loaders/OBJLoader.js?module”;
import { OBJLoader } from “https://unpkg.com/three@latest/examples/jsm/controls/OrbitControls.js?module”;

However, I would stick with import maps …

The usage of unpkg.com has shown to have become unreliable.

You may want to see this thread

for alternatives.

1 Like

Sorry, I misunderstood the question. I thought he wanted to avoid import maps, and that is why I mentioned unpkg.com

For just an offline usage, he can download threejs from github or install an npm and use import map to point the appropriate location.

I totally agree with you that unpkg.com is not a reliable service.