Thanks Allan for your reply.
I've got the Accelerometer working. I'm talking about the OrientationSensor API.
I'm trying this as there also seem to be problems with the Gyroscope as well.
Best AnswerSame happens to me:
const orientationSensor = new OrientationSensor();
setInterval(() => {
console.log(orientationSensor.readings);
if (orientationSensor.readings) {
const { quaternion } = orientationSensor.readings;
console.log(quaternion);
if (quaternion) {
console.log(quaternion.join());
}
}
}, 1000);Prints forever:
[22:06:21]undefined app/index.js:28,1 [22:06:22]undefined app/index.js:28,1 [22:06:23]undefined app/index.js:28,1 [22:06:24]undefined app/index.js:28,1 [22:06:25]undefined app/index.js:28,1 [22:06:26]undefined app/index.js:28,1 [22:06:27]undefined app/index.js:28,1 [22:06:28]undefined app/index.js:28,1 [22:06:29]undefined app/index.js:28,1 [22:06:31]undefined app/index.js:28,1 [22:06:32]undefined app/index.js:28,1 [22:06:33]undefined app/index.js:28,1 [22:06:34]undefined app/index.js:28,1 [22:06:35]undefined app/index.js:28,1 [22:06:36]undefined app/index.js:28,1 [22:06:37]undefined app/index.js:28,1 [22:06:38]undefined app/index.js:28,1 [22:06:39]undefined app/index.js:28,1 [22:06:40]undefined app/index.js:28,1 [22:06:41]undefined app/index.js:28,1 [22:06:43]undefined
Best AnswerHi Sergius,
Sorry for taking so long to respond, busy days.
I'm working on the orientation sensor these days. Once I have more information I'll share here.
Eddie
Best AnswerHave you tried the example in the sensor guide?
It uses onreading plus it starts the sensor orientation.start() which it needs for operation otherwise you are just reading an empty record. Also it sets the interval so you should not need to use setInterval().
import { OrientationSensor } from "orientation";
let orientation = new OrientationSensor({ frequency: 60 });
orientation.onreading = function() {
console.log("Orientation Sensor Reading: " +
"timestamp: " + orientation.timestamp,
"quaternion[0]: " + orientation.quaternion[0],
"quaternion[1]: " + orientation.quaternion[1],
"quaternion[2]: " + orientation.quaternion[2],
"quaternion[3]: " + orientation.quaternion[3]);
}
orientation.start();
Best Answer