ArcRotateCamera loses animated target

I am trying to make camera to track animated (rigged) object from constant position
(i.e. the same way as live human would track moving stuff)

The targeting kinda works, but the object disappears out of view at some edge positions (and it’s not near/far but sideways).

The code of targeting is simplified to bare minimum.
Using the built-in setTarget does not help.

When animation is topped from inspector, rotating camera around reveals target under some angle, but under some other angle it lost again.

cc @georgie

1 Like

If tweak camera.fov a bit the whole animation seems to work correctly, without disappearing - https://playground.babylonjs.com/?inspectorv2=true#H0IYZJ#9

Another way is to increase camera radius a bit - https://playground.babylonjs.com/?inspectorv2=true#H0IYZJ#13

1 Like

Ok, here is update with debugging cockpit.

The issue is that while the target node changes it’s location following rig animation, original mesh retains its “rest position”.
Camera checks visibility of the object by its rest position, unaffected by animation.

Also, Babylon creates 2 items with the same name for original gltf mesh-node: a mesh and a transformnode.
Neither of them are affected by animations.
Camera only checks the ‘Mesh’ item.

Another playground with all 3 items:

Thank you! I’ll take a look, apologies for any delay as I work through various investigations

There was the related discussion - Ray picking in SkinnedMesh

I believe it is enough just to add to your retarget function
(mesh as BABYLON.Mesh).refreshBoundingInfo(true)

Example - https://playground.babylonjs.com/?inspectorv2=true#H0IYZJ#18

1 Like

The documentation states:

To satisfy this requirement from glTF, the glTF loader loads the skinned mesh without its own transform and parents the skinned mesh as a sibling of the skeleton root node. For the CesiumMan model, this is at the same location, but for other cases, it might not be in the same location in the scene hierarchy. Furthermore, the skinned mesh is allowed to have child nodes that have meshes or additional hierarchies. Thus, in additional to creating a skinned mesh, the glTF loader also creates a node that represents the glTF node with the skinned mesh, in case this node is animated or has additional child nodes.

So, it seems like the asset is loaded quite correctly, and the mesh aerobatic_plane.2 is parented to the root bone root.4.

Maybe, the issue is that in this particular asset, motion of the whole object affects not root bone, but its ancestor body_joint.5, while root bone/node stays still. This is somewhat strange rigging, but im not an expert.

@bghgary it seems like you’ve been working on the skinning/parenting stuff back in 2018, and you’re indeed an expert. Could you please clarify, if there’s an issue with the asset, or with camera, or there’s some better way to make such tracking work?

Nice! Thanks!

Yet it still looks somewhat weird it’s not updated automatically.

I assume it would also affect many other aspect such as collisions or highlightin or something.

1 Like

Highlight seems to be OK - https://playground.babylonjs.com/?inspectorv2=true#H0IYZJ#19

For collisions refreshBoundingInfo(true) also should work.

alwaysSelectAsActiveMesh is simpler and faster since refreshBoundingInfo is a cpu-heavy operation if the requirement is to view it.

3 Likes

Good idea! Thanks!

In my usecase of product visualization (~1 object) it even makes sense to turn it on peranently.

1 Like