The bee flies so something more natural. But sometimes upside down.
function animate() {
fraction += 0.001;
if ( fraction > 1 ) fraction = 0;
char.position.copy( curve.getPoint( fraction ) );
tangent = curve.getTangent( fraction );
char.quaternion.setFromUnitVectors ( axisX, tangent );
requestAnimationFrame( animate );
renderer.render( scene, camera );
};
And so there is then a backward flight in between.
const axisX = new THREE.Vector3( 1, 0 , 0 );
const axisXneg = new THREE.Vector3( -1, 0 , 0 );
.
function animate() {
requestAnimationFrame( animate );
fraction += 0.001;
if ( fraction > 1 ) fraction = 0;
char.position.copy( curve.getPoint( fraction ) );
tangent = curve.getTangent( fraction );
if ( tangent.x < 0 ) {
char.quaternion.setFromUnitVectors( axisXneg, tangent );
} else {
char.quaternion.setFromUnitVectors( axisX, tangent );
}
renderer.render( scene, camera );
};
see MoveAlongCurve04
It looks more elegant that way.
see MoveAlongCurve05
I do not yet succeed in the complete forward flight. Quaternions are not so easy.