First of all, ModelEntity is a child class of main parent nodes' class called Entity.
According to documentation:
An entity represents ‘something’ in a scene. Offsprings like PerspectiveCamera, SpotLight or ModelEntity inherit from Entity class.
class Entity : HasHierarchy, HasSynchronization, HasTransform
ModelEntity (like any other entities) is more specific. It represents a model which is rendered and optionally simulated. It inherits from Entity class and conforms to HasModel and HasPhysics protocols.
class ModelEntity : Entity, HasModel, HasPhysics
Very often two entity classes are interchangeable (when setting components). For example you can use Entity instead of SpotLight class.
Entity().components[SpotLightComponent] = SpotLightComponent(color: .red,
intensity: 2000,
innerAngleInDegrees: 45,
outerAngleInDegrees: 90,
attenuationRadius: 5.0)
vs
SpotLight().components[SpotLightComponent] = SpotLightComponent(color: .red,
intensity: 2000,
innerAngleInDegrees: 45,
outerAngleInDegrees: 90,
attenuationRadius: 5.0)
However, the following example can be given as an exception. You need to exactly use Entity class when downcasting.
arView.installGestures([.all], for: entity as! Entity & HasCollision)