babbleon Posted February 6, 2018 Share Posted February 6, 2018 Hello, How to I discriminate between a click on the canvas and just a click & drag to move my camera? scene.onPointerDown = function(evt, pickingInfo) { var pickResult = scene.pick(scene.pointerX, scene.pointerY); console.log(pickResult.pickedMesh.material.name); } The above logs to the console when I left click to move my camera which I would like to avoid. Thank you. Quote Link to comment Share on other sites More sharing options...
babbleon Posted February 6, 2018 Author Share Posted February 6, 2018 okay... scene.onPointerPick = function(evt, pickingInfo) { var pickResult = scene.pick(scene.pointerX, scene.pointerY); console.log(pickResult.pickedMesh.material.name); } ...works a little better, but you need to click and drag very carefully. Is there a better option? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 6, 2018 Share Posted February 6, 2018 Hiya Babbleon! I have no solutions. I'm not even sure I understand the issue... but... I did some experiments. https://www.babylonjs-playground.com/#VWUJA6#5 In this PG, you won't know if the pointerDown is a canvas-click, or a camera-drag... until pointerUp. When pointerUp happens, I subtract the pointer locations at pointerDOWN... from the locations at pointerUP. If they are greater-than a certain "threshold" value... I can assume that the camera was dragged. If not, we assume a canvas click only. I don't know if I am on-topic... but this method, and similar... allows you to adjust the sensitivity of canvas-clicks vs. camera-drags. I hope this helps, or leads to something that does. I also have some DOM click code in there... that I was testing. *shrug* Just goofing around... likely aimlessly. babbleon and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
babbleon Posted February 6, 2018 Author Share Posted February 6, 2018 Hi Wingnut, Many thanks, this works perfectly and was exactly what I was looking for. Cheers, 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.