Save an asset of a model generated on editor

Hello, I’m developing a extension using the editor api.

I’m generating a model based on some examples that i found here in the forum and docs.

this is the result so far

i’ve started to look on how to Save this model that is being generated in runtime.
when i say “save” i mean create an asset in the project, something similar when you upload a model, this way i can use it without the need to generate the same model every time the application runs.

as i mentioned i generated it base in some examples/docs
so along with all the code at the end i’m doing this

// .... rest of implementation
const normals = pc.calculateNormals(positions, indices);

    _mesh.setPositions(positions);
    _mesh.setIndices(indices);
    _mesh.setNormals(normals);
    _mesh.setUvs(0, uvs);
    _mesh.update(pc.PRIMITIVE_TRIANGLES);

    _instance.node = view;
    _model.graph = view;
    _model.meshInstances = [_instance];

    app.scene.addModel(_model);

is there any example or doc on how to create and model asset that i can look at it or any idea where can i start ?

i took a look on pcx.GltfExporter but couldnt go far.
any attempt to save (using this function or not) i’m saving a file


but of course… the content is not correct :smiley:

@mvaligursky ?

I read it, and I’m not sure to be honest. We can save the glb file, but not sure about the import side. I looked at REST API, but the asset upload does not support glb files.

@yak32 @slimbuck - any thoughts here?

maybe even @KPal - could you have a look at what the Editor itself does when we drag & drop glb into the assets panel?

@slimbuck reckons that the REST API Assets - Create asset | PlayCanvas Developer Site might work even for glb, even though not documented.