Skip to main content
Participant
February 21, 2025
Solved

Scale component has no effect on SceneObject stored in an Entity

  • February 21, 2025
  • 3 replies
  • 942 views

I am able to create SceneObject's that end up being contained within a specific entity as follows

val fooObject = SceneObject(scene, fooMesh, "foo", entity = fooEntity)

I am able to call setPosition(), setRotationQuat(), and setScale() on fooObject and get the desired effect.
When I try to set these transforms on fooEntity only the Transform component works  but fooScale is ignored:

fooEntity?.setComponent(Scale(fooScale))            // seemingly ignored
fooEntity?.setComponent(Transform(fooPose))  // works

If I replace setting the Scale component and directly set the scale on the SceneObject this works:

fooObject?.setScale(fooScale)

This work around is fine as long as stick with only uniform scales and compose the transformations by hand. But I have use cases where I have a hierarchy of transformations that do not have uniform scales.

Is there some other ingredient I need for the Scale component to work? It obviously works with Entities containing other model payloads.

    This topic has been closed for replies.
    Best answer by davs

    Hi!

    Apologies for the confusion. One thing you need to make sure you do (which is often omitted from our custom SceneObject examples) is attaching it to the SceneObjectSystem. This makes it fully linked in the ECS and other Kotlin systems can grab the SceneObject (like controlling the Visible or Scale components). 

    systemManager
    .findSystem<SceneObjectSystem>()
    .addSceneObject(
    fooEntity,
    CompletableFuture<SceneObject>().apply { complete(fooObject) })

    We use a future here to allow you to do async loading or waiting on object loads.

    Hope this helps!

    3 replies

    davsAnswer
    Meta Employee
    February 21, 2025

    Hi!

    Apologies for the confusion. One thing you need to make sure you do (which is often omitted from our custom SceneObject examples) is attaching it to the SceneObjectSystem. This makes it fully linked in the ECS and other Kotlin systems can grab the SceneObject (like controlling the Visible or Scale components). 

    systemManager
    .findSystem<SceneObjectSystem>()
    .addSceneObject(
    fooEntity,
    CompletableFuture<SceneObject>().apply { complete(fooObject) })

    We use a future here to allow you to do async loading or waiting on object loads.

    Hope this helps!

    Participant
    February 21, 2025

    Ok -- I'll give it a go.
    Why does adding Transform(Pose) component work but adding a Scale component does not?