1
0
Fork 0
mirror of https://github.com/haselkern/Minecraft-ArmorStand.git synced 2025-05-17 15:05:33 +00:00

Make convertRotation more concise

This commit is contained in:
Lars Martens 2021-08-20 22:12:06 +02:00
parent f05e8a383c
commit b5e6e7f18a

View file

@ -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 },