Hi, I’m a beginner in using Three.js.
I was consulting the GLTF loader documentation and saw that the example given only renders a GLTF using the link where it is. In my case, gltf is a response to a request and when trying to pass this request to load it does not allow it. I needed help figuring out how to make this work, since I can’t change the backend logic, so it will always return gltf as a response.
// Edit
GLTF has a separate texture that is also a response to a request.
// Edit 2
I tried using load.parse, passing the GLTF as ArrayBufer and the texture as DataURL, but this was the result:
// MY CODE
loader.parse(
await gltfBlob.arrayBuffer(),
'',
// called when the resource is loaded
function (gltf) {
gltf.scene.traverse(function (node) {
if (node.isMesh) {
mesh = node;
// console.log(currentTexture)
const textureLoader = new THREE.TextureLoader();
const newTexture = textureLoader.load(URL.createObjectURL(new Blob([textureArrayBuffer])));
newTexture.flipY = false;
mesh.material.map = newTexture;
mesh.material.needsUpdate = true;
Result using gltfBlog.arrayBuffer and texture as dataURL