How to load .obj/.gltf file in container field using three.js
Hi, does anyone play around with three.js? I am struggling with loading a .obj/.gltf file in a container field. I have tried loading the base64 data directly, converting it to blob, converting it to URL. None of them is working. Does anyone know the right method?
Here is my code. Thanks.
window.loadObject = (json) => {
// load the data in base64 format
// convert the data from base64 to blob
const data = b64toBlob(json, "text/plain");
// convert the data to url
const url = URL.createObjectURL( data );
// initialize the object loader
const objLoader = new ObjectLoader();
// try to parrse the url
//const mod = objLoader.parse(url);
objLoader.load(url, (root) => {
scene.add(root);
});
}