0

I'm trying to add a click handler to a 3d model in aframe. Only a few small regions in the model trigger the click event. Can someone help me figure out why the raycaster is not hitting the object most of the time? I've added a snippet of my Angular2 template with the aframe scene. I'm using Aframe version 0.8.2.

<div
  #sceneContainer
  id="sceneContainer"
  oncontextmenu="return false;"
  (mousedown)="onMouseDown($event)"
  (touchstart)="onTouchStart($event)"
  (mousemove)="onMouseMove($event)"
  (touchmove)="onTouchMove($event)"
  [ngClass]="{invisible: !config['model']}"
  style="width: 100%; height:100%; cursor:pointer;">
  <a-scene id="scene" embedded vr-mode-ui="enabled: false" cursor="rayOrigin: mouse">
    <a-entity id="camera" camera></a-entity>
    <a-sky src="assets/sky.jpg" rotation="-20 0 0"></a-sky>
    <a-plane color="#CCC" height="2" width="2" position="0 -0.5 0" rotation="-90 0 0"></a-plane>
    <a-entity id="model" position="0 0 -1" (click)="modelClicked.emit($event)">
      <a-entity gltf-model="https://s3.us-east-1.amazonaws.com/me.seek-ar.media.staging/53a6ebba-995d-4a75-b017-c75986807beb/a7cdb785-fcc3-41c9-9c6a-0c21ebcb0e27.glb"></a-entity>
    </a-entity>
  </a-scene>
</div>

Any help would be appreciated!

UPDATE:

I've found the cause of the issue. See aframe embeded scene with cursor mouse ray-origin

Scrolling or moving the scene container does not seem to update the raycaster. Does anybody have a workaround for this?

  • You may want to try A-Frame 0.8.2, there were some related fixes in that release: https://github.com/aframevr/aframe/pull/3070 – Don McCurdy Jul 19 '18 at 15:43
  • I've updated to 0.8.2 but I'm getting the same problem. When I move the scene container or scroll the page the raycaster is off by the amount the container moved. – viperphase1 Jul 19 '18 at 23:38
  • This sounds like the bug reported here: https://github.com/aframevr/aframe/issues/3410 – Don McCurdy Jul 20 '18 at 04:07
  • Yeah that's the one. It's actually a one-line fix. I'll see if I can get in touch with the aframe people to make it happen. – viperphase1 Jul 20 '18 at 18:06

0 Answers0