Server-Side USDZ Export Support in Babylon.js?

Hi,

I’m wondering if there are any plans to make the USDZ exporter in Babylon.js work in a server-side / Node.js environment.

The GLB exporter can be adapted to run outside the browser using NullEngine and Node.js, but the USDZ exporter seems to be much more tightly coupled to WebGL and the canvas context - specifically the “bitmaprenderer” mode used inside:

@babylonjs/core/Misc/dumpTools.js”

Which causes this error:

”USDZ export failed: Error: DumpData: No WebGL or bitmap rendering context available. Cannot dump data.”

I tried to work around this using node-canvas and NullEngine, but no luck so far - the exporter fails. I am able to export only a model but without the textures.

Is there any plan on the Babylon.js roadmap to make the USDZ exporter independent from the browser context (so it could run on a server)?
Or has anyone in the community managed to find a workaround for this limitation?

Thanks in advance for any info or hints!

cc @alexchuber

Actually, both the glTF and USDZ exporters rely on the same dumpTools function. The reason the glTF exporter works in your setup is likely due to this optimization, which could also be applied to the USDZ exporter. If anyone wants to contribute a PR for this, that would be awesome! :smiley: