Loadin and create model

Hello. I will have a model loaded in my project. Right now my code looks like this

PreloadModel.prototype.fetchModel = function(){
    .then(res=>res.blob()).then(blb => {
        let files  = new File([blb], 'new_model.obj')

PreloadModel.prototype.createAssetModel = function(file){
    const asset = new pc.Asset('newModel','model',{file})

Next, I want to create a model from the asset. But so far I have nothing in my asset. I guess I’m not writing the parameters for asset correctly. Tell me how to create an asset correctly in my case.

Asset Registry can do it for you and has convenience methods for such cases:


1 Like

Thanks. But on a remote resource, I have a file with the .obj extension, and when I upload it to playcanvas with my hands, it is converted to .a glb model that I can insert into the scene. And when I load the model .obj via loadFromUrl, here’s what I see that the resources:null field, the file name is correctly pulled up, but there seems to be nothing inside. Maybe there is another way to load obj containers?


There is a runtime OBJ loader http://playcanvas.github.io/#loaders/loader-obj.html

Parser here: https://github.com/playcanvas/playcanvas.github.io/blob/master/scripts/parsers/obj-model.js

However, it probably would be better to convert the OBJs to GLBs first (if you can).


Thank you very much. One more question. How to properly connect the parser inside the editor? Where to attach the parser and where to register it.

You can have the ‘glue’ code in global space. Eg: https://playcanvas.com/project/790341/overview/obj-parser

1 Like
  • Hello again. Is there a parser for glft?

The engine has a support for binary GLTF (ie GLBs). Example here: http://playcanvas.github.io/#graphics/model-asset.html