Wondering why derived classes share functionality that's missing in base classes

I wish to understand more about babylonjs so that I don’t misunderstand it and can, as a result, work with it more easily.

I’ve found that several classes, e.g. Camera, AbstractMesh, Control, are missing member variables or functions common to all their derived classes.

The GUI Control, for example, doesn’t have an addControl() even though every class that extends it, as far as I know, does. Is it to account for things like the GUI Grid having an unique addControl()?

In the case of AbstractMesh, both InstancedMesh and Mesh implement createInstance().

1 Like

Only containers implement addControl, not all controls. For eg, Checkbox and Image don’t have a addControl method.

Regarding createInstance, there are only two classes that extend AbstractMesh, so it’s difficult to say that creating instances should be a common behavior of all abstract meshes. Maybe we could have a class extending AbstractMesh in the future that won’t be able to support instancing… But maybe not, we may decide at some point to move createInstance to the base class!