Diving into the specifics, I am trying to import code from a JS file called GLTFLoader for Three.js. The goal is to parse a .GLB file and render a Teapot.
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
Three.js #1
</title>
<style>
body{margin: 0;}
</style>
</head>
<body>
<script src="js/three.js"></script> // A dependecy.
<script src="js/cube.js"></script> // The main script.
<script src="js/loaders/GLTFLoader.mjs"></script> // The module I am trying to import code
</body> // from.
</html>
The Import code and code requiring the import. Can upload full code if need be.
import {GTLFLoader} from "js/loaders/GLTFLoader.mjs"
// Create a mesh.
const loader = new GLTFLoader(); // Instantiate loader.
loader.load("assets/models/utahteapot.glb", function (gltf) { // Load the model.
scene.add(gltf.scene); // Add the loaded model to scene.
}, undefined, function (error) { // Return an error if there is one.
console.error(error);
});
I have tried using the "type="module"" tag within the script tag, I have tried uploading the Loader code straight from the url source, I have tried importing the code within the HTML file, and I even tried creating a local server to host these files. I wasn't doing that before, and I still am now. I have ran out of ideas; I can't find a solution. EDIT: Forgot to mention, the file GLTFLoader extension is .MJS because of an unrelated error I had along this error.