How to open gltf by string

Hello.

I’m trying to hide gltf information from development network tab in browser.

As I am using next js now so I want to try to get gltf file from server side to hide it from network tab.

I finally can get the gltf file string but. I can’t get to next step.

I got glb file string from this code

    const { data } = await client().get(
        `https:// ~s3 link for glb~~`,
    );
    return data;

The data looks like this.

I tried JSON parse but it shows error(SyntaxError: Unexpected token ‘g’, “glTFȊ+”… is not valid JSON).

I think i have to do something to parse gltf but I don’t have any idea.

Can you help me please?

plus I used draco compression for my glb file.

This string not a valid encoding of the glTF content, you won’t be able to parse that. When transmitting a binary file (like .glb) as a string, you must be very careful about convert first to a specific known string encoding (like Base64) and then back to binary before parsing.

Is there some way you can transmit the binary contents, instead of a string? This would depend on your server/client framework. Any string encoding will add at least +33% to the file size, compared to binary.

I have to find other way to get gltf data from s3 url

Is there something you can recommand for next js?

Now im just use the url link for gltf files parse from server

Is await client().get('https:// ~s3 link for glb~~') a Next.js API? Or some S3-related client library?

I’ve never used Next.js, sorry. Possibly they have a help site where you can ask how to transmit binary data from the server to the client, or to make sure a particular file is interpreted as binary? It shouldn’t matter in particular that the binary content happens to be a glTF file.

1 Like

You may be getting a bit complex to “hide” your gltf assets here, there’s a lot of conversations on this forum such as here, here and here plus many more if you Google the approach you are trying, effectively, once a model has been rendered to the screen its practically open and loaded on the client side and with a little determination the webgl renderer buffers can be scraped to grab the model if someone really was keen to get a copy of your models, from what I understand.

I just give up that server bring file and gives front way. I can’t find the way to get binary file in next js but also, my colleague saids it could be inefficient for the loading time.

Any way thanks for the reply :slight_smile:

@Lawrence3DPK
Thanks for the answer especially this article just persuade me…:sob: