[SOLVED] Angles of DeviceOrientationEvent are null

https://playcanvas.com/project/524134/settings I have this project. I use this script because it worked well on my device to move an entity in 3 axes … There are no errors in the release but there are some errors when pressing play in the editor … I try to move the camera in xyyz using this script. I do not know how to fix error "can not read property of null

The scrip with error is. tray_move.js

The arguments for your event handler (alpha, beta, gamma) are null. You need to debug to see why your DeviceOrtientationEvent has alpha, beta and gamma all set to null. This isn’t a PlayCanvas problem, TBH.

A little more info. If you read the DeviceOrientation API spec, it says:

Implementations that are unable to provide all three angles must set the values of the unknown angles to null.

So updating your code to preprocess the values seems sensible. Something like:

var alpha = event.alpha === null ? 0 : event.alpha;
var beta = event.beta === null ? 0 : event.beta;
var gamma = event.gamma === null ? 0 : event.gamma;