Click outside call function

In my project I use script for hotspots (like this tutorial). And when user click I check if hit area is intersects using intersectsRay(). I want to call function if the user click on hotspot and another function if click not on the hotspot


PartHotspot.prototype.isIntersect = function (event) {, event.y,, this.ray.direction); 

    return this.hitArea.intersectsRay(this.ray);

PartHotspot.prototype.onMouseDown = function (event) {
    var isCanvas = === "application-canvas";
    if (!isCanvas) return false;
    if (this.isIntersect(event)) {
       return true;
    return false;

Problem: If user click not on hotspot - all works fine. But if click on hotspot - one script call funcA(), other funcB(). I understand why this happens, but I don’t know how to fix it. How I can check is click target are one of hotspots?

Why are you calling funcB if it’s not the hotspot that the user has clicked on?

I want to have the following functionality:

  • If user click on hotspot - show UI
  • If user click and the target isn’t hotspot - hide UI

Rather than having each hotspot manage it’s own input, you would want a manager script that handles the input and checks against all the hotspots. If it doesn’t hit any on of the hotspots, then hide the UI.

Okey, can you provide simple example?

I did it with this tutorial