Search code examples
aframe

Desktop version getting error while moving mouse (cursor.js)


I'm taking a version of our VR experience (repo here: https://github.com/EFForg/spot_the_surveillance) and making a purely desktop version for demonstration purposes.

I've added cursor="rayOrigin: mouse" to and some changed some mouseenter events to click events. Everything is mostly working except that as I mouse over the scene, I repeatedly getting this error: "Uncaught TypeError: t is null", which refers to the following code in cursor.js.

// Ignore events further away than active intersection.
if (this.intersectedEl) {
  currentIntersection = this.el.components.raycaster.getIntersection(this.intersectedEl);
  if (currentIntersection.distance <= intersection.distance) { return; }
}

How do I resolve this error? It causes a significant lag time in the experience.

Thank you!


Solution

  • Looking at the Mouse Click Example linked from this page was a good place to start: https://aframe.io/docs/1.0.0/components/cursor.html#intersection-data

    Unfortunately the example is using aframe 0.7.0, so I had to read through the animations documention for 1.0.4 and adapt accordingly: https://aframe.io/docs/1.0.0/components/animation.html

    I also had to update the version of aframe-event-set-component.js I was using.

    Between those two sources of information and the version updates, I was able to get things working.