Aframe: User camera not honored anymore and default one injected anyways

Created on 16 Dec 2018  Â·  16Comments  Â·  Source: aframevr/aframe

<a-scene>
  <a-entity camera></a-entity>
</a-scene>

With the above a default camera is injected incorrectly

help wanted (easy)

Most helpful comment

I narrowed it down further. Just the presence of a script tag before the entity with camera is enough. But you'd use that inside the assets element to define a template.

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>3D Model (glTF)</title>
    <meta name="description" content="3D Model (glTF) — A-Frame">
    <script src="../dist/aframe-v0.9.0.js"></script>
</head>

<body>
    <a-scene>
        <script></script>
        <a-camera></a-camera>
    </a-scene>
</body>

</html>

All 16 comments

I cannot reproduce this anymore.

I just had this issue after updating to aframe 0.9.0. I had the camera nested in a rig and on a sphere component.

<a-scene>
  <a-entity position="0 10 0">
    <a-sphere camera look-controls>
    </a-sphere>
  </a-entity>
</a-scene>

A default camera was injected. I found a work-around by switching to a a-camera component

<a-scene>
  <a-entity position="0 10 0">
    <a-camera geometry="primitive:sphere" look-controls>
    </a-camera>
  </a-entity>
</a-scene>

The default camera was no longer injected.

The setupInitialCamera function of the camera system is called when the scene element has no other children than the a-canvas and a-loader-title. Therefore the sceneEl.querySelectorAll('a-camera, [camera]') returns an empty list.

Could this issue be re-opened?

There must be more to this bug. I tried the below on master and v0.9.0 from the dist folder running the below out of examples. I made the assumption that contents of the element would not have been present yet, but everything is indeed present in the DOM and the a-sphere is returned as expected. Wondering if browser version/capabilities has anything to do with the issue?

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>3D Model (glTF)</title>
    <meta name="description" content="3D Model (glTF) — A-Frame">
    <script src="../dist/aframe-v0.9.0.js"></script>
</head>

<body>
    <a-scene>
        <a-entity position="0 10 0">
            <a-sphere camera look-controls>
            </a-sphere>
        </a-entity>
    </a-scene>
</body>

</html>

I'm seeing it on com.oculus.browser (OculusBrowser/5.7.6.141460824 SamsungBrowser/4.0 Chrome/66.0.3359.203), but also on Chrome 72. I try to reproduce in glitch.

@DigiTec you were right. It has to do with there being a template present. Please find a minimal repro here https://glitch.com/~neon-canopy

I narrowed it down further. Just the presence of a script tag before the entity with camera is enough. But you'd use that inside the assets element to define a template.

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>3D Model (glTF)</title>
    <meta name="description" content="3D Model (glTF) — A-Frame">
    <script src="../dist/aframe-v0.9.0.js"></script>
</head>

<body>
    <a-scene>
        <script></script>
        <a-camera></a-camera>
    </a-scene>
</body>

</html>

What about if you don’t use primitives at all? Only a-entitys tags

<a-entity camera></a-entity> makes no difference. https://glitch.com/~neon-canopy

Yeah I reproduced this as well on my own project which also uses the template component. A workaround is to move the camera element up higher on the page (above assets for example)

Yeah I reproduced this as well on my own project which also uses the template component. A workaround is to move the camera element up higher on the page (above assets for example)

This is the best answer so far...and the same problem still exists in the latest version which is 1.0.4

@mzpq01 steps to reproduce?

Yeah, seems like <a-entity camera></a-entity> or <a-camera></a-camera> are working for me to prevent the default camera from getting injected.

It’s sort of an interesting behavior when i’m trying to register/track and add my own camera component though.

P.S. Thanks for everything dmarcos!

For posterity, I was having this problem. I then realized my camera component was outside of my a-scene after shuffling components around trying to appease render order and transparency. Hopefully, this will save someone some time!

Was this page helpful?
0 / 5 - 0 ratings