I'm running a three.js phonegap project on a iPhone 5s, which rotates the camera according to the compass heading readout.
All works as it should, but for the freezing of the compass readout after 10 seconds. The app continues to work fine, but the function rotateCameraWithCompass isn't called anymore. Also there is no call to compassError. The watchHeading method seems to have frozen.
function rotateCameraWithCompass( heading ) {
camera.rotation.y = -1 * Math.toRad( heading.magneticHeading );
}
function compassError( compassError ) { console.log( 'Compass error: ' + compassError.code ); }
var watchID = navigator.compass.watchHeading( rotateCameraWithCompass, compassError, { frequency: 30 } );
I lowered the frequency down to from 30 ms to 100ms, but it still freezes after about 10 seconds. It seems such a light request, so I can't imagine why if freezes.
Can the watchHeading method be used for continuous live AR camera rotating? If not, does that mean that AR on PhoneGap iOS is impossible?
Only onewatchHeading
can be in effect at one time in iOS. If awatchHeading
uses a filter, callinggetCurrentHeading
orwatchHeading
uses the existing filter value to specify heading changes. Watching heading changes with a filter is more efficient than with time intervals.