I'm trying to add a threejs scene to my gatsby project.
After some spilled blood I got it working properly in development and building also succeeds but when serving the app I get 3 times the following error:
TypeError: (void 0) is not a constructor
I identified with logs that the error appears on using the OBJLoader constructor. How can I get it working?
This is how I basically set it up:
import React from "react";
import * as THREE from "three";
import * as OBJLoader from "three-obj-loader"
OBJLoader(THREE);
const SceneComponent = (}) => {
const manager = new THREE.LoadingManager();
manager.onLoad = () => {
animate()
};
const loader = new THREE.OBJLoader(manager).load(`PATH`, (spoon) => {
scene.add(spoon)
}
...
}
If anybody is interested: I solved this issue by switching to 'three-gltf-loader' and converting the mesh to ".glb", this seems to be best practice as it also halfs the file size.