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:
parent
f05e8a383c
commit
b5e6e7f18a
1 changed files with 5 additions and 6 deletions
|
@ -125,13 +125,12 @@ export default {
|
||||||
convertRotation(mcRotation) {
|
convertRotation(mcRotation) {
|
||||||
const DEG2RAD = Math.PI / 180
|
const DEG2RAD = Math.PI / 180
|
||||||
|
|
||||||
let matX = new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), mcRotation.x * DEG2RAD)
|
let rotationMatrix = new Matrix4()
|
||||||
let matY = new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), -mcRotation.y * DEG2RAD)
|
.multiply(new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), -mcRotation.z * DEG2RAD))
|
||||||
matY.multiply(matX)
|
.multiply(new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), -mcRotation.y * DEG2RAD))
|
||||||
let matZ = new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), -mcRotation.z * DEG2RAD)
|
.multiply(new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), mcRotation.x * DEG2RAD))
|
||||||
matZ.multiply(matY)
|
|
||||||
|
|
||||||
return new Euler().setFromRotationMatrix(matZ).toVector3()
|
return new Euler().setFromRotationMatrix(rotationMatrix).toVector3()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { Box, Camera, LambertMaterial, Renderer, Scene, Object3D },
|
components: { Box, Camera, LambertMaterial, Renderer, Scene, Object3D },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue