From b5e6e7f18a6a8b0fc83ca6a9d05e93788103a9c5 Mon Sep 17 00:00:00 2001 From: Lars Martens Date: Fri, 20 Aug 2021 22:12:06 +0200 Subject: [PATCH] Make convertRotation more concise --- src/Scene.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Scene.vue b/src/Scene.vue index d3077a9..26cbb60 100644 --- a/src/Scene.vue +++ b/src/Scene.vue @@ -125,13 +125,12 @@ export default { convertRotation(mcRotation) { const DEG2RAD = Math.PI / 180 - let matX = new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), mcRotation.x * DEG2RAD) - let matY = new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), -mcRotation.y * DEG2RAD) - matY.multiply(matX) - let matZ = new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), -mcRotation.z * DEG2RAD) - matZ.multiply(matY) + let rotationMatrix = new Matrix4() + .multiply(new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), -mcRotation.z * DEG2RAD)) + .multiply(new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), -mcRotation.y * DEG2RAD)) + .multiply(new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), mcRotation.x * DEG2RAD)) - return new Euler().setFromRotationMatrix(matZ).toVector3() + return new Euler().setFromRotationMatrix(rotationMatrix).toVector3() } }, components: { Box, Camera, LambertMaterial, Renderer, Scene, Object3D },