|
1 | 1 | 'use strict';
|
2 |
| -/*global chrome,GUI,TABS,nwdialog,$*/ |
| 2 | +/*global chrome,GUI,BOARD_ALIGNMENT,TABS,nwdialog,$*/ |
3 | 3 |
|
4 | 4 | TABS.magnetometer = {};
|
5 | 5 |
|
@@ -28,6 +28,7 @@ TABS.magnetometer.initialize = function (callback) {
|
28 | 28 |
|
29 | 29 | var loadChain = [
|
30 | 30 | mspHelper.loadMixerConfig,
|
| 31 | + mspHelper.loadBoardAlignment, |
31 | 32 | mspHelper.loadSensorAlignment,
|
32 | 33 | // Pitch and roll must be inverted
|
33 | 34 | function (callback) {
|
@@ -219,6 +220,7 @@ TABS.magnetometer.initialize = function (callback) {
|
219 | 220 | elementToShow.change(function () {
|
220 | 221 | const value = parseInt($(this).val());
|
221 | 222 | self.showMagnetometer = (value == 0);
|
| 223 | + self.render3D(); |
222 | 224 | });
|
223 | 225 |
|
224 | 226 | function clamp(input, min, max) {
|
@@ -390,8 +392,17 @@ TABS.magnetometer.initialize3D = function () {
|
390 | 392 |
|
391 | 393 | gps.visible = self.showMagnetometer;
|
392 | 394 | xyz.visible = !self.showMagnetometer;
|
393 |
| - gps.rotation.set(-THREE.Math.degToRad(self.alignmentConfig.pitch), THREE.Math.degToRad(-180 - self.alignmentConfig.yaw), THREE.Math.degToRad(self.alignmentConfig.roll), 'YXZ'); |
394 |
| - xyz.rotation.set(-THREE.Math.degToRad(self.alignmentConfig.pitch), THREE.Math.degToRad(-180 - self.alignmentConfig.yaw), THREE.Math.degToRad(self.alignmentConfig.roll), 'YXZ'); |
| 395 | + |
| 396 | + var magRotation = new THREE.Euler(-THREE.Math.degToRad(self.alignmentConfig.pitch), THREE.Math.degToRad(-180 - self.alignmentConfig.yaw), THREE.Math.degToRad(self.alignmentConfig.roll), 'YXZ'); |
| 397 | + var matrix = (new THREE.Matrix4()).makeRotationFromEuler(magRotation); |
| 398 | + |
| 399 | + var boardRotation = new THREE.Euler( THREE.Math.degToRad( -BOARD_ALIGNMENT.pitch / 10.0 ), THREE.Math.degToRad( -BOARD_ALIGNMENT.yaw / 10.0 ), THREE.Math.degToRad( -BOARD_ALIGNMENT.roll / 10.0 ), 'YXZ'); |
| 400 | + var matrix1 = (new THREE.Matrix4()).makeRotationFromEuler(boardRotation); |
| 401 | + |
| 402 | + matrix.multiply(matrix1); |
| 403 | + |
| 404 | + gps.rotation.setFromRotationMatrix(matrix); |
| 405 | + xyz.rotation.setFromRotationMatrix(matrix); |
395 | 406 |
|
396 | 407 | // draw
|
397 | 408 | if (camera != null)
|
|
0 commit comments