Contents

addByCameraDistance(to:levels:)

Adds Level of Detail configuration using distance-based switching to an entity .

Declaration

static func addByCameraDistance(to entity: Entity, levels: [(entities: LevelOfDetailComponent.DetailLevel, maxDistance: Float)])

Parameters

  • levels:

    An array of levels, where each level specifies the entities to display and the maximum camera distance at which they are visible.

Discussion

Each level pairs a set of entities with a maximum camera distance threshold. Entities within a level are shown or hidden together. Thresholds must be in ascending order; the last threshold is typically .infinity.

Each entity in the provided levels is added as a child of the entity the component will be added to. Children not included in any level are unaffected by LOD switching.

See Also

Creating a component