A component that orients an entity instance so that it continuously points toward
the active camera.
The `BillboardComponent` automatically adjusts an entity's orientation so
that its z-axis keeps pointing in the direction of the main camera in a
RealityKit scene.
Add a `BillboardComponent` to any entity by passing it to an entity's
``Entity/ComponentSet/set(_:)-8sii2`` method.
```swift
entity.components.set(BillboardComponent())
```
The entity immediately reorients itself so that it faces the scene's active
camera.
| Without `BillboardComponent` | With `BillboardComponent` |
|:-:|:-:|
|||
- Important: An entity with `BillboardComponent` doesn't provide access to its end orientation.
Requesting the entity's orientation through its transform returns only the unaltered orientation.
For an example of how to animate ``blendFactor``, see ``BillboardAction``.
Members (3)
get · iOS 18.0+
blendFactor
TypeScript
get blendFactor(): number
Swift declaration
var blendFactor: Float
The degree at which the entity rotates toward the camera.
The `blendFactor` property is a floating-point number in the range `[0.0, 1.0]`.
- When `blendFactor` is `1.0`, the entity fully faces the camera.
This is the default behavior.
- When `blendFactor` is `0.0`, the entity doesn't rotate at all.
- When `blendFactor` is between `0.0` and `1.0`, the entity partially rotates toward the camera.
The following example configures the entity to rotate by half the angle it needs
to directly face the camera by setting the `blendFactor` to `0.5`:
```swift
var billboard = BillboardComponent()
billboard.blendFactor = 0.5
entity.components.set(billboard)
```
For example, here's how a few different `blendFactor` values affect the orientation:
| 0 | 0.25 | 0.5 | 1 |
|:-:|:-:|:-:|:-:|
|||||
For an example of how to animate `blendFactor`, see ``BillboardAction``.
set · iOS 18.0+
blendFactor
TypeScript
set blendFactor(value: number)
Swift declaration
var blendFactor: Float
The degree at which the entity rotates toward the camera.
The `blendFactor` property is a floating-point number in the range `[0.0, 1.0]`.
- When `blendFactor` is `1.0`, the entity fully faces the camera.
This is the default behavior.
- When `blendFactor` is `0.0`, the entity doesn't rotate at all.
- When `blendFactor` is between `0.0` and `1.0`, the entity partially rotates toward the camera.
The following example configures the entity to rotate by half the angle it needs
to directly face the camera by setting the `blendFactor` to `0.5`:
```swift
var billboard = BillboardComponent()
billboard.blendFactor = 0.5
entity.components.set(billboard)
```
For example, here's how a few different `blendFactor` values affect the orientation:
| 0 | 0.25 | 0.5 | 1 |
|:-:|:-:|:-:|:-:|
|||||
For an example of how to animate `blendFactor`, see ``BillboardAction``.
init · iOS 18.0+
init
TypeScript
static init(): BillboardComponent
Swift declaration
init()
Creates a billboard component that points an entity's
positive z-axis directly toward the active camera.