Click event not working as it should

(Shaderbytes) #1

Hey there

I discovered a bug that you can click in a empty space in the scene , keep the mouse button down , rotate the scene around so that the pointer is over an object ( any amount of time can be used here ) , when you release the mouse button it generates a click event for the object under the pointer.

This breaks the known rules of defining a “click” event , where the mouse down and mouse up both have to happen over the same object. Also a threshold for timing between mouse up and down is also used as well as a threshold for drag.

So a valid click/touch should be :

Mouse down and mouse up must occur on the same target.
Threshold for time between mouse down and mouse up, realistically a click is a fast action.
Threshold for drag, If the mouse moves to much between mouse down and mouse up , it should be considered a drag gesture , not a click.

using viewer 1.3.0 , I still need to see if this is still a problem with the new viewer , i will check and let you know.

Thanks Gents


Sorry about that. It should be fixed now.

By the way, version 1.4.2 implements proper stable nodes so it should make picking events better.

(Shaderbytes) #3

Thanks James , is this only fixed in the later versions? , I was testing on my click code pen example I did a while back so it still uses 1.3.0 , I just cleared cached and tried again and I still get click events if I mouse down on an empty part of the scene , drag the scene until a object is under the pointer then release.

I will look for some time soon to update all examples to use the latest api and the utility will be updated if needed.

Im not sure if the stable node thing will make any difference to how I manage clicks. My utility makes it that you never have to deal with instanceID’s and rather object names. So with the click event I wrapped it and I bubble the graph until i find the first instance of a object of type MatrixTransform and also Group and add those references to the returned event.

For example if an artist creates a house with two doors named “backdoor” and “frontdoor” then when using the api utility and he wants to add click events to the doors then he can expect those exact object names returned by the utility abstracted click event.


function objectClicked(event){   
    if(event.parentMatrixTransform !== null && event.parentMatrixTransform !== undefined){
     currentObjectKey =;
    .. .   


ps. tested with 1.4.2 and it is fixed in that version

pps “parentGroup” and “parentMatrixTransform” are bad name choices for my event variables , as the reference might not be a direct parent … it would rather be a first ancestor of type etc… it should rather be “firstAncestorOfTypeMatrixTransform”
I will change that soon , I do version my utility now so if people want older behaviour they can use an older version as well :wink:



@paul_sketch can probably speak best to the differences between versions.

(Paul Sketch) #5

yes, can confirm that the click change/fix is only after 1.4.
We try to not break previous version behaviour, so that if any applications is based on that behaviour doesn’t break