Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 3x 3x 3x 3x 3x 3x 3x 2x 2x 2x 3x | /*!
* Copyright 2020 Cognite AS
*/
import { mat4, quat } from 'gl-matrix';
// Roate +Y to -Z
export const DefaultSectorRotationMatrix = mat4.fromValues(1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1);
export const DefaultInverseSectorRotationMatrix = mat4.invert(mat4.create(), DefaultSectorRotationMatrix)!;
export function constructMatrixFromRotation(rotation: [number, number, number] | null): mat4 {
const matrix = mat4.identity(mat4.create());
const quaternion = quat.create();
if (rotation != null) {
rotation = [(180.0 * rotation[0]) / Math.PI, (180.0 * rotation[1]) / Math.PI, (180.0 * rotation[2]) / Math.PI];
quat.fromEuler(quaternion, rotation[0], rotation[1], rotation[2]);
mat4.fromQuat(matrix, quaternion);
}
// TODO 20191018 larsmoa: ThreeJS specific - move to "view".
// Always rotate Z up to Y up as three.js uses this coordinate system.
return mat4.mul(mat4.create(), DefaultSectorRotationMatrix, matrix);
}
|