Jump to content

Rotate an object with the mouse


pco38
 Share

Recommended Posts

Hello,

I'am starting with babylon and I have a simple question.

Is somebody could explain me or had an example that explains how to rotate an object by drag&drop the mouse?

Thanks for your help...

Link to comment
Share on other sites

Hi pco38, welcome to the forum!  Your question might be simple, but the solution is not so simple.  Keep in mind that you can rotate on 3 different axes.  Would you consider...

 

standard drag = rotate around Y axis

SHIFTED-drag = rotate around X axis

CONTROL-drag = rotate around Z axis

 

Thoughts?

 

I did a little testing last night, using our Playground Drag Demo.  Still testing various modified onPointerMove funcs.

 

Stay tuned.  And tell me what you think about the shifted-drag and control-drag stuff. 

 

You can also use a "gizmo".... a little tool that can pop-up near the mesh, and you can drag-rotate on IT. The nearby mesh "follows" the dragging done on the gizmo.  (this is seen in modelers such as Blender and Max).  *shrug*  Talk soon, and welcome again.

Link to comment
Share on other sites

Hi Wingut,

 

Thank you for your answer.

 

I will try to test a solution based on the PlayGround Drag demo.

 

To complete my question, my problem is to rotate a flat object like a disk on it's perpendicular axis. To control the opening or the closing of a valve for instance.

 

Another question, Is there a function to convert 3D coordinate to screen coordinate ? 

 

Congratulation for the babylon developers that have done a very good !

Link to comment
Share on other sites

Hi again!  :)

http://playground.babylonjs.com/#1HXY4E

This is a "drag-scrub" rotater.  Click on a mesh and hold the button down, then move the mouse around (scrub).  The mesh rotates... in one direction.  Not a very good drag-rotater, eh?  I agree.  Maybe it will work for your need.

I will keep trying to think of better ways.  I might try leftButton-hold to rotate left, rightButton-hold to rotate right (when done atop a mesh). 

Or, maybe not.  :)

Maybe others will have ideas, too.  Be well.

Link to comment
Share on other sites

  • 7 months later...
On 5/8/2015 at 8:52 PM, Wingnut said:

http://playground.babylonjs.com/#1HXY4E

This is a "drag-scrub" rotater.  Click on a mesh and hold the button down, then move the mouse around (scrub).  The mesh rotates... in one direction.  Not a very good drag-rotater, eh?  I agree.  Maybe it will work for your need.

Hello there, if anyone needs rotating 3D objects in both directions, here it is:

http://playground.babylonjs.com/#1HXY4E#3

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...