MorphTarget destroy & reload?

Is there a way to bring back into memory, a morphTarget that I destroyed earlier during runtime?
For example, I have an model that has 5 morph targets

At a point in runtime I delete from memory the last 2 morph targets to save memory:
this.entity.model.model.morphInstances[0].morph.getTarget(4).destroy();
this.entity.model.model.morphInstances[0].morph.getTarget(3).destroy();

What do I do if I want to reload these morph targets back into memory at a later time to reuse it when necessary.

I’m wondering if morph targets are assets? Because I will be able to just figure out the asset id and reload it, but I doubt these are assets.

Hi @Anton_Gunaratnam_s_S,

I think they are part of the model asset, so if you reload the asset that will most likely put them in place (without requiring to redownload):

const modelAsset = this.app.assets.get(assetId);
this.app.assets.load(modelAsset);

I tried it, unfortunately this does not work:

   this.entity.model.model.morphInstances[0].morph.getTarget(4).destroy();
   this.entity.model.model.morphInstances[0].morph.getTarget(3).destroy();


   const modelAsset = this.app.assets.get('52904025');
    this.app.assets.load(modelAsset);
    
    modelAsset.ready(function (asset) {
        // do something with asset.resource
        this.entity.model.model = asset.resource;
    }.bind(this));

my mistake, It works

1 Like