bryik
bryik

Reputation: 146

How to access the default camera from a component?

A component I'm making needs the default camera, but this.el.sceneEl.camera returns undefined.

Simplified example:

AFRAME.registerComponent('test', {
  init: function () {
    console.log(this.el.sceneEl.camera)
  }
});

How can I retrieve the camera?

Upvotes: 2

Views: 611

Answers (1)

ngokevin
ngokevin

Reputation: 13233

Might have to wait for the camera to be set? Need to document this, but there's an event:

this.el.sceneEl.addEventListener('camera-set-active', function (evt) {
  console.log(evt.detail.cameraEl); 
});

Upvotes: 4

Related Questions