Search code examples
aframe

Can A-frame 'look-at' component look at the default camera?


Is it possible to get the a-frame look-at component to look at the default camera? Since it does not have an ID or a class by default I don't know how to target it.

I have tried adding [camera] as the selector value as per the docs like so;

    <a-text 
      value="Look at test"
      look-at="[camera]">
    </a-text>

but it does not seem to work for me. I feel I am missing something obvious here.

Any help appreciated


Solution

  • What you are doing is correct, but at the time the look-at component is initialized, the camera is not yet on the scene.

    Try creating a component, which will wait until the scene is loaded,

    this.el.sceneEl.addEventListener("loaded", (e)=>{....
    

    or at least for window.onload.

    Check it out here.