simon_bg Posted July 13, 2017 Share Posted July 13, 2017 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! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 15, 2017 Share Posted July 15, 2017 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. sable and simon_bg 2 Quote Link to comment Share on other sites More sharing options...
sable Posted July 16, 2017 Share Posted July 16, 2017 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. Wingnut and simon_bg 2 Quote Link to comment Share on other sites More sharing options...
simon_bg Posted July 26, 2017 Author Share Posted July 26, 2017 Sorry for the late response. This is perfect, you guys are the best!! It works real nice. Wingnut 1 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.