I'm a beginner in Javascript and I'm currently working on a project that involves displaying a 3D model in a modal. Everything was running smoothly until I attempted to include an import statement. Once I added the line
import {GLTFLoader} from "three/addons/loaders/GLTFLoader.js";
into my code, I started encountering a reference error that claimed any function I tried to call was undefined. This issue persisted regardless of where I placed the import statement within the code. I even experimented with loading the import in different sections, but that only led to more errors. Strangely, the error persisted even when the import statement was included within a function that wasn't being called. Does anyone have any insights on where I might be going wrong? Below is a snippet of my code for reference.
import {GLTFLoader} from "three/addons/loaders/GLTFLoader.js";
var soupbowl = soupbowl || {}; //Establishing a namespace
/*
Setting up the canvas for a 2D soup animation
*/
soupbowl.twod = function() {
var canvasDiv = document.getElementById('soupcanvas');
canvas = document.createElement('canvas');
// Determining the canvas dimensions
let width = canvas.offsetWidth; // Scene width
let height = canvas.offsetHeight; // Scene height
canvas.setAttribute('width', 600);
canvas.setAttribute('height', 600);
canvas.setAttribute('id', 'canvas');
canvasDiv.appendChild(canvas);
if(typeof G_vmlCanvasManager != 'undefined') {
canvas = G_vmlCanvasManager.initElement(canvas);
}
ctx = canvas.getContext("2d");
//Creating the soupplate
soupbowl.createPlate();
}
Appreciate any help!