3

This maybe a skool boi error, but I'm getting a 404 for a file that does exist:

http://localhost:8000/Desktop/Skeletor/js/build/three.module.js net::ERR_ABORTED 404 (File not found)

it should say

http://localhost:8000/Desktop/Skeletor/MYPROJECT/js/build/three.module.js

So I'm running a directory short and I can't see why or where I'm going wrong. Yes, I changed from

../build/three.module.js

to

./build/three.module.js

intentionally.

Here's the js in the index.html copied from the three.js webgl loader example

<script type="module">

import * as THREE from './build/three.module.js';

import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { GLTFLoader } from './jsm/loaders/GLTFLoader.js';

The directory structure is this:

MyProject/
    index.html
    .DS_Store
    styles.css
    obj/
        dime_low.glb
    textures/
        00.jpg
    build/
        three.module.js
        .DS_Store
    jsm/
        .DS_Store
        controls/
            .DS_Store
            OrbitControls.js
        loaders/
            .DS_Store
            RGBELoader.js
            GLTFLoader.js

Everything is running locally using a simple HTTP server via Python

Go easy on me, I'm meant to be doing colouring-in today not learning three.js :)

Ghoul Fool
  • 6,249
  • 10
  • 67
  • 125
  • 1
    Can you please share your directory structure? It's important to know where your HTML file is located and the respective JS files. – Mugen87 Jan 21 '20 at 14:38
  • 1
    It seems you missed `jsm` before `build` so it should be `import * as THREE from './jsm/build/three.module.js';` – Zydnar Jan 21 '20 at 16:21
  • 1
    @Zydnar In the official repository, the build files are not located in the `jsm` directory. – Mugen87 Jan 21 '20 at 20:19
  • What are you using to serve your files in `localhost`? It might be an issue with the config file, maybe pointing one folder too high. – M - Jan 21 '20 at 20:19
  • Just using python 2.7 with `python -m SimpleHTTPServer` – Ghoul Fool Jan 21 '20 at 21:42
  • OrbitControls and the loaders too as modules, assume a specific folder structure in order themselves to import from three: `../../../build/three.module.js`(see https://github.com/mrdoob/three.js/blob/dev/examples/jsm/controls/OrbitControls.js). So you either change your dir structure to match that, or change the source code of all the modules to compensate – adatzer Jan 22 '20 at 07:48
  • @Zydnar my reporting of the folder structure was incorrect. I've since corrected it thanks to [this question](https://stackoverflow.com/questions/9727673/list-directory-tree-structure-in-python). – Ghoul Fool Jan 22 '20 at 08:57
  • @GhoulFool how you run the index.HTML `http://localhost:8000/Desktop/Skeletor/MYPROJECT/` suggest `./ ` does NOT mean it's root of MYPROJECT – Zydnar Jan 22 '20 at 12:25
  • 1
    @Zydnar I see it now! I see where I've gone wrong! D'oh :) – Ghoul Fool Jan 23 '20 at 16:11

1 Answers1

1

the build folder must be one folder outside, jsm and build must not be in same directory, try this enter image description here