calculateMouseOver()

in web/frontend/libs/@deltix/vizceral/src/vizceral.js [712:759]


  calculateMouseOver(immediate) {
    if (this.currentGraph) {
      this.raycaster.params.Line.threshold = this.currentGraph.linePrecision || 1;
      const intersects = this.raycaster.intersectObjects(this.currentGraph.view.getInteractiveChildren());
      let userData = {};
      if (intersects.length > 0) {
        if (intersects[0].object.userData.object) {
          ({userData} = intersects[0].object);
          userData = (userData.object && userData.object.loaded && (userData.object.isInteractive() || (this.options.allowDraggingOfNodes && userData.object.isDraggable()))) ? userData : {};
        } else {
          Console.warn('Mouse cursor intersected with a visible object that does not have an associated object model. The object should be set at userData.object');
        }
      }
      if (userData.object && userData.object.isClickable()) {
        this.renderer.domElement.style.cursor = 'pointer';
      } else {
        this.renderer.domElement.style.cursor = 'auto';
      }
      
      // Changed hovered object
      if (this.objectToSwitch !== userData.object) {
        this.objectToSwitch = userData.object;
        if (this.currentGraph.intersectedObject) {
          // If an object was previously moused over, clear the context
          this.currentGraph.setContext(undefined);
        }
        
        // if waiting for a hover effect on something else, clear it before moving on
        if (this.mouseOverTimer) {
          clearTimeout(this.mouseOverTimer);
        }
        
        if (!immediate && userData.object && !(this.currentGraph && this.currentGraph.highlightedObject)) {
          // if switching to an object and nothing is highlighted, set a timeout to perform the hover effect
          this.mouseOverTimer = setTimeout(() => {
            this.currentGraph.setIntersectedObject(this.objectToSwitch);
          }, 100);
        } else {
          // if removing a hover effect, or there is a highlighted object, do it immediately
          this.currentGraph.setIntersectedObject(userData.object);
        }
      }
      
      if (this.currentGraph && this.currentGraph.context !== userData.context) {
        this.currentGraph.setContext(userData.context);
      }
    }
  }