Our previous program rotates the box around the z-axis, but it’s not difficult to rotate around any axis parallel to the z-axis, such as the one that passes through the point (4,1,0).
The code is the same as on the previous page, except for the following version of makeRotatingBox
that translates the box on lines 5 and 6.
function makeRotatingBox() { let geom = new THREE.CubeGeometry(4, 1, 1); let mat = new THREE.MeshLambertMaterial({color: 'blue'}); let box = new THREE.Mesh(geom, mat); box.position.x = 4; box.position.y = 1; box.rps = 0.2; return box; }
Recall the system-based view of transformations: The parent space — the world space in this example — first gets translated, and then rotation occurs in the now-translated space.