Statics Posted July 30, 2015 Share Posted July 30, 2015 Hey, is there any way to get the arrow heads in this demo to align with the body of the arrow? I can get the rotation right for some of the sectors such as +x,+y, and +z but the other sectors don't work. I'm fairly new to babylon and I don't know if there is a function to do this. I realize it might be possible to do with multiple if statements but I would prefer not to do it that way. http://www.babylonjs-playground.com/#XPA7I#1 Please let me know if there is any way to do this, Thanks Quote Link to comment Share on other sites More sharing options...
Gerente Posted July 30, 2015 Share Posted July 30, 2015 Your Link is not working, here is fixed:http://www.babylonjs-playground.com/#XPA7I#1 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 30, 2015 Share Posted July 30, 2015 If you know the final orientation in terms of axis (or vectors) but you don't know what rotation to apply to your cylinder to align it with one of these final vectors, you could use the static RotationFromAxis() method.Documented here ("Generating a rotation from a target system" part ) : http://doc.babylonjs.com/page.php?p=22411 iiceman 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted July 31, 2015 Share Posted July 31, 2015 It also seems to work with lookAt:var vector = new BABYLON.Vector3(magx, magy, magz)var draw_vector = BABYLON.Mesh.CreateLines("lines", [new BABYLON.Vector3(0, 0, 0),vector], scene);var head1 = BABYLON.Mesh.CreateCylinder("head1", 3, 0, 2, 10, 1, scene);head1.position = vector;head1.lookAt(vector.scale(2), 0, -Math.PI/2, 0);http://www.babylonjs-playground.com/#XPA7I#2 Statics and MarianG 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 31, 2015 Share Posted July 31, 2015 yeplookAt() rotates the mesh by aligning its local z axis (if I remember well) to the target RotationFromAxis(axis1, axis2, axis3) creates a angle triplet (pitch, yaw, roll) what can be used to rotate then a mesh and to align it with axis1, axis2 and axis3 along its own local x, y and z axis Quote Link to comment Share on other sites More sharing options...
Statics Posted July 31, 2015 Author Share Posted July 31, 2015 Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.