Hey i was working on a react project and i wanted to use the three js gltf loader to showcase a gltf file i have, however after adding the gltf file in the gltf loader the error message Unexpected token ‘:’ (at scene.gltf?import:2:14) pops up. ive checked to make sure the gltf file itself is not the issue and it seems to work perfectly fine in other software. below i will provide the react js code.
import { GLTFLoader } from “three/examples/jsm/loaders/GLTFLoader”;
import rolexmodelgltf from “./assets/scene.gltf”;
yes when i drag the folder which containes the gltf model into a gltf veiwer it works perfectly fine, however would it be possible that the three js gltf loader must also load the textures file that comes with the scene.gltf file?
gltfs are (often) not self contained and way too big. use glb.
also react thee fiber, wouldn’t putting three into react like that loose you all integration? it goes against the point of react, to express imperative systems declaratively.
Yes if you’re using the gltf format all associated textures need to be in the same directory as the gltf file, the loader will handle these fine, I think you just need to load the model through it’s path rather than trying to import it first…
//remove this
import rolexmodelgltf from “”;
//load directly through the path
const glftLoader = new GLTFLoader();
glftLoader.load("./assets/scene.gltf", (gltfScene) => {
test.scene.add( gltfScene.scene );
});