Danthony
Danthony

Reputation: 5

Aframe, Can not get a reference to the cameras THREE.js object3D

AFRAME.registerComponent('temp', {

      init: function () {

        var el = this.el;
        var camera = this.el.getObject3D('camera');

        console.log("CAMERA: "+camera);
      }

    });

I have an aframe scene with just a box and an a-camera object. I am trying to get a reference to the camera's object3D however, whenever I try, I am getting an undefined object. In addition to above, I have tried doing document.querySelector("#camera").object3D and that does not work either.

Upvotes: 0

Views: 1483

Answers (1)

Diego Marcos
Diego Marcos

Reputation: 4585

This is what you are trying to accomplish on one of the A-Frame examples (https://aframe.io/aframe/examples/boilerplate/hello-world/):

document.querySelector("[camera]").getObject3D('camera')

example

Upvotes: 5

Related Questions