This is a website I will be stealing ideas from!!!
// before the loop
let stepQuat = new THREE.Quaternion();
// at end of loop body
stepQuat.multiply(slerp);
Sorry if this was discussed in the article already.It’s particularly helpful when you want smooth, rotation-aware transitions (like gliding across a sphere’s surface) without relying solely on angles or coordinate systems. Could be interesting to try a similar traversal heuristic in a Three.js context using Quaternion.slerp().
Now why is it again we are not using threejs pervasively?
[edit to remove two "wells" in one sentence]
It really is just a simple interpolation between two quaternions on the sphere surface in sphere relative space. You can use the squad interpolation function with two quaternions and just reconstruct back into sphere space. It is like 15 lines of code in one function.
In more detail:
Given you want the same side of the mesh touching at the start and end, we can just convert the matrices to be relative to the sphere center using the sphere coordinate space, and then extract their relative quaternions and translations. The orientation towards the center should be the same for both relative to the quaternion orientation. Thus we really just need to interpolate the quaternion using squad interpolation (https://github.com/AcademySoftwareFoundation/Imath/blob/8456...) while reconstructing the sphere-coordinate matrix at each step and using the quaternion-relative orientation.
This is a lot simpler and faster than the proposed multi-step algorithm.
Source: I made it up.
Animats•1d ago
[1] https://www.youtube.com/shorts/CpaXi9ije2k
hoseja•1d ago