GearVRf icon indicating copy to clipboard operation
GearVRf copied to clipboard

Rotate virtual object around the Y axis to face the device's Camera

Open itanbp opened this issue 6 years ago • 3 comments

Hi, I intending to use GearVRf for rendering the virtual objects in an ARCore project.

I'm trying to make an anchored virtual object to always face the Camera, giving the user the feeling the virtual object is always looking at him.

following @thomasflynn suggestion, I thought to use GVRBillboard.

I would appreciate any general direction for how this can be achieved. Thanks!

itanbp avatar Apr 24 '18 19:04 itanbp

@sushantojal can help you with billboards. sushant, care to give a quick example of how to use it?

thomasflynn avatar Apr 24 '18 20:04 thomasflynn

Hi @itanbp , GVRBillboards can be added as components to scene objects. Using it on a sceneobject is as simple as:

sceneObject.attachComponent(new GVRBillboard(gvrContext));

where sceneObject is a GVRSceneObject.

This will rotate the scene object about the Y axis, in such a way that it always faces the camera. You can even specify your custom vector in such a way that the object is only constrained to rotate around that vector while facing the camera. For example,

sceneObject.attachComponent(new GVRBillboard(gvrContext, new Vector3f(1.0f, 0.0f, 0.0f)));

sushantojal avatar Apr 24 '18 20:04 sushantojal

@sushantojal @thomasflynn thanks. Your support is truly appreciated!

itanbp avatar Apr 25 '18 08:04 itanbp