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
Code:
PartHotspot.prototype.isIntersect = function (event) {
this.camera.camera.screenToWorld(event.x, event.y, this.camera.camera.farClip, this.ray.direction);
this.ray.origin.copy(this.camera.getPosition());
this.ray.direction.sub(this.ray.origin).normalize();
return this.hitArea.intersectsRay(this.ray);
};
PartHotspot.prototype.onMouseDown = function (event) {
var isCanvas = event.element.id === "application-canvas";
if (!isCanvas) return false;
if (this.isIntersect(event)) {
funcA();
return true;
}
funcB();
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?