I really appreciate Thanks
I delayed posting this a bit since I wanted to handle different scaling as well, instead of just different positioning, so that all 3 transformations, i.e. rotation, translation and scaling, are covered.
I did that in this fiddle … except that because of #3845, non uniform scaling on the parent object (group
, in your case) is not supported, and it took me a while to realize that. You can see the effects by uncommenting the scaling on group
and notice how the plane doesn’t include the object anymore; the alternative of using the outer
’s world quaternion instead of its world direction fares better, but it isn’t precise either. It will only work if group
has an uniform scale applied to it, e.g. group.scale.set(2, 2, 2);
, group.scale.set(3, 3, 3);
, etc.
So, in the end, it turns out I don’t like quaternions that much anymore. Especially when using them prevents other things in Three.js to function correctly.
Wow but honestly look like it works see this fiddle. I think that in you version the fact that the child object “outer” is not uniformely scaled triggers this behavior. Honestly for the moment I don’t really understand your whole code and you are maybe right for the ways to improve it but at this point I’ll test it in my app and see if I get good results.
Many thanks again,
In your fiddle, it works because you deleted the rotation and scale on the child object (aka outer
). Add those back and you’ll see that it doesn’t precisely follow the correct angle on the object. The scale on the child doesn’t matter, it’s the one on the parent that causes problems when it’s not uniform.
By the way, you changed some things in your fiddle and now it won’t work even after setting an uniform scale on the parent (aka group
). Compare it with my last fiddle to see the corrections needed. My guess is that is because you’re using the parent as a reference - it should be the child, because it’s on the child object you compute the angle on.
P.S. Adding rotations, positioning and scaling to both the child and the parent was only for testing purposes, since I wanted this to work for all cases. They are not mandatory, obviously.