cancel
Showing results for 
Search instead for 
Did you mean: 

Scale component has no effect on SceneObject stored in an Entity

waynecochran
Explorer

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.

1 ACCEPTED SOLUTION

Accepted Solutions

dav-s
Meta Employee

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!

View solution in original post

3 REPLIES 3

dav-s
Meta Employee

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!

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

I am still not sure how the sceneObject gets fully linked to the ECS system.
Something must be done in the lambda below that associates sceneObject with fooEntity ... what does the complete () function do in this case? i.e. what is suppose to be done in the code marked XXXX below?


val
fooEntity = Entity.create(
listOf(
TransformParent(fooParentEntity),
identityScale,
identityPose
)
)
val sceneObject = SceneObject(scene, fooMesh, "foo", entity = fooEntity)
sceneObjectSystem.addSceneObject(
fooEntity,
CompletableFuture<SceneObject>.apply {
                // XXXX sceneObject XXXX
}
)