Short stupid question… when working with the backend API of ShapeDiver I do not know how to fetch the GLB geometry output out of a session response. Could anyone assist me by pointing me to the method that I am suppose to use as an href.
const res = await sdk.session.init(ticket)
// sample first item of response
const url = Object.values(Object.values(response.outputs)[0].content)[0].href;
fetch(url, {
mode: "no-cors",
}).then((response) => {
console.log(response);
//returns a status = 0 | response.ok = false
});
Please note that your model most probably exposes several outputs. You might want to select the one you are looking for by its name. Related reading (there is also a video): Outputs on the API
As an example, this code would iterate through all the outputs and get the href to the first glb found:
let href = "";
for (const outputId in response.outputs) {
const output = response.outputs[outputId];
if (!output.content) continue;
for (const item of output.content) {
if (item.format === "glb") {
href = item.href;
break;
}
}
if (href) break;
}