You can set properties on the material like you do and then when you set all of them, you call material.update() (like you do). Then to set the material on a model you need to set it on all its mesh instances. So something like this:
var meshInstances = this.entity.model.meshInstances;
for (var i = 0; i < meshInstances.length; i++) {
meshInstances[i].material = material;
}
That’s only needed initially when you want to assign a new material to a model. In general if you’re creating stuff like materials programmatically you don’t need to mess with assets.
PS: The context does not exist anymore it’s legacy code. If you are using the new scripts you should use this.app instead - so if you want to access the asset registry you’d do this.app.assets instead of context.assets .