The using of Quaternion.setFromBasis()

Hi community!

Recently, just out of curiousity, I tried to bend a hollow cylinder along a curve, applying a quaternion, getting with .setFromBasis() method, to vertices.

And here is the result.


Demo: https://codepen.io/prisoner849/full/LEEXaPw

So, the question is: do I use this method wrong, or do I do something wrong in general?
@hofk, any advice? :slight_smile:

PS Using of quaternion’s .setFromUnitVectors() gives the expected result


Demo: https://codepen.io/prisoner849/full/oggQPWo

2 Likes

Try different order of the basis vectors (normal->binormal->tangent):

new THREE.Quaternion().setFromBasis(
        tbn.normals[qIdx],
        tbn.binormals[qIdx],
        tbn.tangents[qIdx],
      );
5 Likes

That’s why I like our community :slight_smile:
Thanks :slight_smile:

PS Should’ve thought about it myself though :sweat_smile:

2 Likes

I’m probably too late to look at that. But I’ve fallen for it myself before and just had the wrong order. It took me a while to finally realize that. :face_with_spiral_eyes:

2 Likes