Jump to content

Camera stumbling while dragging


simon_bg
 Share

Recommended Posts

Hi folks, 

I've made a little playground here http://www.babylonjs-playground.com/#5QBZT0, which is based on the drag&drop example. I changed the camera behavior a little bit: when dragging the ground, the camera is actually the one that moves along the XZ plane. 
The problem is that the movement is not smooth, it stumbles. Does anyone know how to fix it?

Also, how could I add some inertia to the dragging movement?

Thanks a lot! :)

Link to comment
Share on other sites

Hiya Simon.  Sorry for slow replies.

I've been doing some testing.  [link pg #3]

SOME progress, but... hmm. 

I am printing diff to console @ line 125.  Open console and do slow drag on ground.  See diff alternating negative/positive?

I think that is the problem, but I'm not sure WHY it is happening, yet.  I'll keep thinking/testing.  Others may have ideas/fixes, too.  Stay tuned.

Update: [link pg #4]  There we go.  Line 141 was causing problems.  Nopped it out, life got better.  hmm. 

You can remove lines 136, 137, too.  They are not necessary.  Party on.

Link to comment
Share on other sites

Building on the above, for inertial movement you could use the built in inertial panning offsets (having changed the panning axis to 1,0,1), pg, see lines 113, 141, 142. But this has issues when beta is close to zero (looking straight down).

You could instead roll your own inertia by just extracting the relative bits from the camera source, like so.

Also if you want to be able to pan the camera like this without needing a ground mesh to do hit tests against, it's possible to project the mouse coordinates to an arbitrary plane in 3d space. For example the plane at y = 0, pg. Of course for your use case there might always be a ground mesh there in which case this doesn't matter too much.

Link to comment
Share on other sites

  • 2 weeks later...

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...