Jump to content

onPointerDown distinguish from moving camera


babbleon
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

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