Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rotateByLine ( mesh, from, to ){
- var
- up = new THREE.Vector3(0, 1, 0),
- tangent = new THREE.Vector3().subVectors(from, to).normalize().negate(),
- radians = Math.acos(up.dot(tangent)),
- axis = new THREE.Vector3().crossVectors(up, tangent).normalize();
- mesh.position.copy( from.lerp( to, 0.5 ) );
- mesh.quaternion.setFromAxisAngle( axis, radians );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement