I am currently attempting to load an OBJ file from a blob using Three.js. After referring to this resource and successfully loading STL files, I encountered an issue with loading OBJ files. The error message I received is as follows:
TypeError: text.indexOf is not a function
at OBJLoader.parse (OBJLoader.js:482:13)
Below is the relevant section of my code:
// Loading OBJ file - this section throws an error
async loadObj(blob) {
var loader = new OBJLoader();
const arrayBuffer = await blob.arrayBuffer();
const geometry = loader.parse(arrayBuffer);
const material = new THREE.MeshPhysicalMaterial({});
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
}
// Loading STL file - this section works fine
async loadStl(blob) {
const loader = new STLLoader();
const arrayBuffer = await blob.arrayBuffer();
const geometry = loader.parse(arrayBuffer);
const material = new THREE.MeshPhysicalMaterial({});
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
}