Download model as glb

I am attempting to download a 3d object from Sketchfab within a React application.

I call the url to download a specific 3d object: https://api.sketchfab.com/v3/models/${itemId}/download

This returns urls that point to Amazon AWS, and there are three urls, one called glb, one called gltf and one called usdz.

If I access the object on Amazon using the gltf url, I get a response in the form of a zip file. If I unzip the file, I get the files associated with the gltf format. All good.

If however I access the object on Amazon using the glb url, the response appears not to be a zip file. It appears that I must have received the glb file, but it isn’t in a format that can be added to the canvas - see below. It seems to be an array buffer with multiple sections. Is there some additional processing needed on the glb response, in order to extract a glb file from it? Alternatively, how does this get added to the scene?

Array Buffer: ArrayBuffer(4255132)byteLength: 4255132
[[Prototype]]: ArrayBufferbyteLength: (…)constructor: ƒ ArrayBuffer()slice: ƒ slice()Symbol(Symbol.toStringTag): "ArrayBuffer"get byteLength: ƒ byteLength()
[[Prototype]]: Object[[Int8Array]]: Int8Array(4255132)
[[Uint8Array]]: Uint8Array(4255132)
[[Int16Array]]: Int16Array(2127566)
[[Int32Array]]: Int32Array(1063783)
[[ArrayBufferByteLength]]: 4255132[[ArrayBufferData]]: 6141

Hi @damienaruvr,

The GLB endpoint gives access to a glb asset that corresponds to the binary version of glTF format as it is described in the glTF specification. There is nothing special to do except consumming the downloaded asset as a glb file directly.

I’m not familiar with the technology you are using but loading glb assets is something very common in web applications so I’m pretty sure you can get it working easily.

Here is an example of an app that is able to load a glb: https://gltf-viewer.donmccurdy.com/

I hope it helps,
Aurélien

@waleguene is the glb asset a standard member of the downloadable files? Or is it only available if it was the originally uploaded file?

Hi there,

Thanks for getting back to me. I am getting the file directly from the sketchfab download api. First I get a number of urls that point to S3 buckets on AWS. These are authenticated urls that give access for a few seconds. There are three different urls. When I make an axios request to the gltf version, I get a zip file returned and I can unzip it and get at the assets. I can see an array of files that includes the gltf file and the other associated files.
However, I have been asked to access the assets in glb format. What is returned by the axios call on the glb url doesn’t seem to be in a format that I can directly add to the canvas. It is in the format of an array buffer and I am not sure how to process this and unpack the contents.
I am quite new to accessing this type of 3d asset, so I am pretty sure there is a simple way to get the binary in a form that I can just stick in the scene.