Hello forum!
I’m new to babylon.js. I would like to move the camera around an object through device orientation inputs.
The ArcRotateCamera has the radius property. Is there a way to add the radius property to the DeviceOrientationCamera?
Or the other way around, is there a way to activate device orientation for the ArcRotateCamera?
I could not find any example for something like this.
This is complicated as the DeviceOrientationCamera uses system info (like tilt, ya, pitch, etc…) and it does not simply map to an ArcRotateCamera.
but it is still possible to start your scene with an ArcRotateCamera and then switch to a DeviceOrientationCamera (the constructor will give you the opportunity to set the position and you can manually set the rotationQuaternion to determine original rotation)
Thanks for the quick answer. I’m still not that fit with Javascript. I’m usually developing in Unity. Unity does not know that many different predefined cameras. There I would do it as follows.
I would put an empty GameObject to the scene, centered 0,0,0. It’s an object like a cube or a sphere, but simply empty, which means without any mesh data. Then I would take the camera and make it a child of that object. It means I would attach it to that object, so that the camera would react as it would be a part of it. Positioning data would be now local or related to the position of the parent object. I would give the camera a position of for example 0, -5, 0, pointing into the direction of the center of the parent. Next I would simply animate the parent object and voila the arc rotation is managed.
In Unity it’s as simple and quick as counting one, two, three. Is that an option in Babylon.js as well? Is there a basic camera-type that I can simply attach as a child to a parent object?
Hi, I also need this function for ArcRotateCamera addDeviceOrientation() or any alternative solution. As if you are aiming your Phone around the object. I am not so talented on this, I can’t figure out how to do it.
I can manage to do the spinning from the sides thru browser window.event listener’s device orientation and map the alpha to the y position. As if you are revolving in a single plane and walk thru the object capturing all the sides.
My problem is, i also want to capture the other axis as if you move around from top to bottom or bottom to top. So i want to see the top or the bottom of the mesh object when you tilt your phone up and down. If i incorporate the x and z position to the beta and gamma event of the browser’s device orientation, it will turn and spin differently.
I only want the object to spin left/right if you walk around to the object (i already did this), then top/bottom when you tilt your phone top/bottom accordingly. It is optional or I dont need to capture the diagonal orientation.
Any ideas how to do this, i dont really understand parenting cameras. Thank you.