I’m using BoneLookController to rotate bones in YBot skeleton (dummy3.babylon),
but I’m having issues with bones “flipping” orientation on their own depending on small changes in target Vector.
For example, see attached image - same everything only X coordinate of target vector is different by few pixels and bone orientation flipped (facing back in first image and facing front in second image).
I can control the flip by having complex “adjust” rules like this:
I’ve tried BabylonJS 4.2.1 and 5.0.0.beta4 and behavior seems the same to me
I have no issues with BoneLookController other than this strange bone “flip”
A bit more details - seems like flip happens when delta of bone position vs target vectors switches between positive to negative, even if its a trivial change like from -0.001 to +0.001.
@jeremy-coleman there is not a word there about upAxis, its only visible in API docs and even there it’s just listed as existing (and that is auto-generated from TypeDocs, which means it’s not even documented in the code). Nothing else. Ask is to document it.
I did look at the code. And that didn’t really help
(I’d need to digest entire logic of BoneLookController to make sense of it)
Default is Vector3.Up() which is [0, 1, 0]
Its sometimes normalized: upAxis.normalize()
Its used by many ops: Vector3.TransformCoordinatesToRef, Bone.getDirectionToRef, Vector3.Cross, Matrix.FromXYZAxesToRef (and others)
Ah, just sharing what i know. Maybe helpful, maybe useless. Anyway here is a pg search. Searching the playgrounds for the class name im having trouble with is something i do frequently.
The docs on the look controller say its from v2.5 which was forever ago. A lot of the classes accept a handedness argument. Maybe upAxis is direction of your thumb in the way a lot of people think about
Maybe the switch is expected. The docs say “The BoneLookController class is used to make a bone look toward a point in space.” If x’s sign changes that should maybe be expected to cause a flip in look direction? Sorry im likely not much help here
If I remember correctly, up axis is to help set the roll of the bone. If the bone is rolling around or flipping, then it’s likely that your bone is looking close to the direction of the up axis.
It could also be looking close to the opposite direction of the up axis.
@adam based on my observations, flipping occurs when bone is looking close to the opposite direction of upAxis. if upAxis is set correctly, then flipping does not occur.
But default value of [0, 1, 0] is ok only for bones belonging to center of the body.
For bones that are either left or right, better defaults are [-1, 1, 1] for left-handed bones and [1, 1, 1] for right-handed bones.
And then flip x and z if body is facing backwards.
@carolhmj plenty of questions in general as i’m still learning babylon, but this topic is clear - i’m seriously amazed by level of help provided here! my bad that i haven’t selected a solution, done now.