Load a .obj from a byte stream (web request)

Godot Version

v4.5.1.stable.official [f62fdbde1]

Question

looking for a way in GDScript to take the PackedByteArray of a .obj file or a .glb file i have to load into a mesh so i can view in a 3D scene.

the plan is to not have 3D models stored with the build here and to serve certain assets over the net, ideally they get streamed in directly and godot simply parses them.

does anyone know a good way of doing this without having to implement my own parser?

Why not just stream the .obj or .glb file and then load it? What’s the benefit of turning it into a PackedByteArray?

You will have to do some runtime parsing, but Godot’s GLTFDocument class will handle the majority of glb/gltf parsing. In your case using .append_from_buffer, read through the docs linked below

I don’t think there’s a built-in way of loading an obj at runtime. You’ll need to write the parser yourself. The editor imports them with a ResourceImporterOBJ. You can see how it parses them here: