Viro: How to make object always look at / rotate towards camera?

Created on 24 Apr 2019  路  3Comments  路  Source: viromedia/viro

Hi I am new to react-native / functional programming and just started using Viro. I have experience using the Unity game engine and manipulating vectors.

I have some ViroText objects that are instantiated upon scanning an ViroARImageMarker, so their positions are local to that marker.

I want to have those Text objects always rotated towards the camera.
I saw that .getCameraOrientationAsync() is used to get the camera position.

But can I have some suggestions on how to go about doing this?
My current idea for a approach is to...
1) Get global position of viro-text object
2) Get position of camera
3) Manually calculate the rotation of the viro-text object with vector math in relation to the camera's position
4) apply the rotation to the viro-text object

Please help thanks

Most helpful comment

You can use the transformBehaviors -> billboard prop to have you component always face the camera

All 3 comments

You can use the transformBehaviors -> billboard prop to have you component always face the camera

Great thanks, I was not aware of the billboard property that is really useful.

However the viro-text objects are children of the ViroARImage marker. When I apply billboard they follow the camera but their rotation is skewed because their position is LOCAL to the marker it's not global to the ARcamera.

Is there a workaround to this?
Is there a way to make the VIROtext objects global?

Thanks

I'm also working on this... I'll post here. Setting a camera on the node worked partially. I'm trying to have an object move with the camera (without exactly setting that as the camera). Basically an interactive UI bar at the bottom of the screen that is actually a Viro component.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krishanjangir picture krishanjangir  路  4Comments

slycoder picture slycoder  路  4Comments

funkyfourier picture funkyfourier  路  3Comments

dimegusew picture dimegusew  路  3Comments

nishantdande picture nishantdande  路  6Comments