Вопрос

i am developing an augmented reality application with my team. we decided to choose phonegap as framework for developing it as a webapp. We use the Three.js framework to draw the augmented reality into the canvas.

My problem is to get the camera rotation working based on the phone movement. i searched through the internet for a few days but can't get it. the actual idea was to use the getRotationMatrix() method out of the android SDK and rewrite it to javascript. but the problem is to get the x, y, z data from the compass. phonegap only provides heading relative to the geographic north pole in degrees (0 .. 360) but the getRotationMatrix() method uses the x, y, z values.

is it possible to refract the axis values out of the heading value or get them directly?

do you have other ideas to calculate the camera rotation on all three axis?

thank you so much for any hints!

Это было полезно?

Решение

You can use html5 deviceorientation. It works great

I add a tutorial about it: http://html5rocks.com/en/tutorials/device/orientation

Другие советы

The compass will give you a heading but the accelerometer will give you the devices x,y,z values. See the example in our docs:

http://docs.phonegap.com/en/1.6.1/cordova_accelerometer_accelerometer.md.html#accelerometer.getCurrentAcceleration

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top