Skip to content

Commit

Permalink
fixed issue with creation of default ar-camera
Browse files Browse the repository at this point in the history
  • Loading branch information
blairmacintyre committed Sep 14, 2016
1 parent 1d3e91c commit 5c667c0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 31 deletions.
34 changes: 24 additions & 10 deletions dist/argon-aframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,31 @@
this.addEventListener('loaded', function () {
if (this.renderStarted) { return; }


// if there are any cameras aside from the AR-CAMERA loaded,
// make them inactive.
this.addEventListener('camera-set-active', function () {
var fixCamera = function () {
var arCameraEl = null;
var cameraEls = this.querySelectorAll('[camera]');
var cameraEls = self.querySelectorAll('[camera]');
for (i = 0; i < cameraEls.length; i++) {
cameraEl = cameraEls[i];
if (cameraEl.tagName === "AR-CAMERA") {
arCameraEl = cameraEl;
continue;
}
cameraEl.setAttribute('camera', 'active', false);
cameraEl.pause();

// work around the issue where if this entity was added during
// this sequence of loaded listeners, it will not yet have had
// it's attachedCallback called, which means sceneEl won't yet
// have been added in a-node.js. When it's eventually added,
// a-node will fire nodeready.
if (cameraEl.sceneEl) {
cameraEl.setAttribute('camera', 'active', false);
cameraEl.pause();
} else {
var cameraToDeactivate = cameraEl;
cameraEl.addEventListener('nodeready', function() {
cameraToDeactivate.setAttribute('camera', 'active', false);
cameraToDeactivate.pause();
});
}
}

if (arCameraEl == null) {
Expand All @@ -204,9 +215,12 @@
defaultCameraEl.setAttribute(constants.AFRAME_INJECTED, '');
self.appendChild(defaultCameraEl);
}
});


}
// if there are any cameras aside from the AR-CAMERA loaded,
// make them inactive.
this.addEventListener('camera-set-active', fixCamera);
fixCamera();

if (this.argonApp) {
self.addEventListeners();
} else {
Expand Down
Loading

0 comments on commit 5c667c0

Please sign in to comment.