Default values of Material.dispose() arguments

It has three optional arguments.
However, docs do not mention the default values currently.
What are they?
It would be nice to include it in the signature.

Also what happens to the disposed entity, whether it is a node, mesh, skeleton, texture, or material?There is a method called isDisposed, can it be used to define an undo feature to bring the dispsed entity back to the scene? If the entity is disposed how to put it back?

If you refer to the mesh, you can find the function here:

both are false (technically, first is undefined, second is false).

No, I mean the Material.dispose().

It has the signature:
dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void

All undefined per default (you can see that from the signature). So, no force effect dispose, no force texture dispose, and expect the material to be bound to (a) mesh(es).

A rule of thumb is to expect the variables to be automatically false (thou it is not 100% consistent, I have to admit). This is why the name of the variables are formulated this way.

Sorry I did not understand the third argument itself. What does it mean? Does it mean dispose only if it is not bound to a mesh?

I see. Still I would like a signature syntax to be there for the defaults :slight_smile:

However I have checked and I can no more find the disposed mesh, or was it a noode I forgot now, by chcking the scene.rootNodes by filtering it.
How to make an undo by using BJS? I can keep the disposed entity while disposing it in a function I use in from debugLayer's extensibility option. Can I use this enti,tiy back directly with scene.addMesh.

It means that babylon will expect the material to be attached to a mesh and will detach it. It it doesn’t, it will leave all meshes as they are and will simply free the resources.

Dispose will get rid of the mesh, completely remove it form the scene. If you want undo and redo you can disable the meshes instead of disposing.

If it does not detach the materail from the scene is material of any use? Will it be unnecessary to keep it still attached to the mesh like that?

If I use disable instad of dispose, will it be inside the scene and rendered when the scene is exported and imported again back?

Also what is the use of isDisposed() of an entity since it is completely disposed so programmatically out of scope absolutely?

No, but you can create a material that is not attached to any mesh.

Yes, it will stay, no, it will not render. Win win!

Dispose does not delete the variable. You can dispose a mesh, but still have the JavaScript object in your code. That’s the use of this function.


I got it.

The easiest way is using isEnabled then. However this means it adds to the scene size hence all exports.

Thanks a lot I know get it. The method is on the object to be asked if. Originally I misunderstood as it is on scene and the object is the arg, my bad.

1 Like