[SOLVED] How to create an Asset from file content stored in variable?

There’s a lot of demos and code that show how to load a file from URL or by using Json Parser, but none of these methods answer to my needs.

I have the content of a GLTF file, stored in a variable. The file itself doesn’t exist.
Pasting the variable into a .gltf file and loading it is a solution but not my goal here.

I’m trying to do something similar to this, but I’m not sure how the load method is trying to load and open a file. It’s not loading only the content given.

app.loader.load(gltf_in_variable, "binary", function (err, asset) {
     var asset = new pc.Asset('gltf', 'model', {
         url: ''

     asset.resource = res.model;
     asset.loaded = true;


Thank you for your help.

You would have to convert it to a data blob and load that.


The binary data is in glbBinAsset.resource

1 Like

Yes, this project is a good example! This is working as expected. :slight_smile: