registerOnClick function works fine locally, but in our use case which has varying unconventional resolutions it seems that the “clickable” area is mapped in a wrong place, so that clicking around the object we want to click triggers the registerOnClick event. Is there a way to trigger the calculation of the clickable area after the scene is loaded?
This topic was modified 1 year, 4 months ago by dragosburian.
It happens across all platforms, but it would be extremely tricky to produce an example, my question would be whether there is a function maybe that can trigger a re-calculation of the clickable zone, if that is how the click function works.
There’s no special function for that. The calculations are quite straight-forward: when you click somewhere in the scene, the code obtains the current mouse/touch coordinates and casts a ray from that point inside the scene to check if there’s any intersections with the scene’s objects.
This scheme works most of the time, but in some unusual cases related to canvas positioning, offsets or css 2d/3d transformations there can be issues with obtaining mouse/touch coordinates.
I can reproduce the behavior similar to what you described here only if I rotate the canvas element via css transforms (e.g. transform: rotate(45deg);) and it happens only on mobile.
It can look like this:
– the clickable area in such case can be a bit wider than it should be, i.e. misplaced or stretched.
So, your issue may be a bug or may happen due to some tricky case that we just didn’t bother to support when we implemented this feature.