Contents

BillboardAction

An action that animates the blend factor of an entity’s billboard component.

Declaration

struct BillboardAction

Overview

This action animates the blendFactor value of an entity’s BillboardComponent.

Over its duration, the action updates the blendFactor property to 1.0. If you provide a transitionIn configuration, the action interpolates the value of the component’s current value for blendFactor towards 1.0. If you provide a transitionOut configuration, the action interpolates the component’s blendFactor value from 1.0 to its original value for that component.

The example below creates a three-part animation that:

// Load a robot model from a resource file.
let robotModel = try await ModelEntity(named: "vintage_robot")

// A billboard component for the robot model entity.
var billboardComponent = BillboardComponent()

// Disable the billboard at the beginning by setting its blend factor to zero.
billboardComponent.blendFactor = 0.0

// Add the component to the entity.
await robotModel.components.set(billboardComponent)

// A transition that lasts one second.
let billboardTransition = BillboardAction.Transition(
    duration: 1.0,
    timingFunction: .easeInOut
)

// An action that starts and ends with a one second transition.
let billboardAction = BillboardAction(transitionIn: billboardTransition,
                                      transitionOut: billboardTransition)

// A three second animation that adjusts the blend factor twice.
//
// This animation includes a one second pause between both of the action's
// one second transitions in and out by setting the duration one second
// longer than action's total time.
let billboardAnimation = try AnimationResource
    .makeActionAnimation(for: billboardAction,
                         duration: 3.0,
                         bindTarget: .billboardBlendFactor)

// Play the three second billboard animation that adjusts the blend factor.
robotModel.playAnimation(billboardAnimation)

Ensure the action can transition back to a non-billboard state by adding the component to the entity and check the blendFactor property has a value that you expect.

Topics

Structures

Initializers

Instance Properties

See Also

Built-in actions