2d game logic vs 3d rendering
HTML
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"></script>
</head>
</html>
JavaScript
// yields [1, 0] (north -> east)
console.log(vec2.str(
vec2.rotate(
vec2.create(),
[0, -1],
[0, 0],
Math.PI / 2,
)
))
// yields [1, 0] (north -> east)
console.log(vec3.str(
vec3.transformQuat(
vec3.create(),
[0, -1, 0],
quat.rotateZ(quat.create(), quat.create(), Math.PI / 2)
)
))
// yields [-1, 0] (north -> west)
//
// Manchester does 2D rotations in game logic on the XY plane;
// positive rotations are right-handed rotations around cross(+X, +Y).
// However, rendering occurs on the XZ plane; positive rotations
// are right-handed rotations around cross(+X, -Z). This is why we have
// to negate transform orientations in the renderer.
console.log(vec3.str(
vec3.transformQuat(
vec3.create(),
[0, 0, -1],
quat.rotateY(quat.create(), quat.create(), Math.PI / 2)
)
))