Search code examples
aframe

A-Frame version 8 to version 9 unable to move model or camera from within inspector


Issue upgrading from A-FRAME 8 to 9 with a project. The reason for the upgrade was due to inconsistent mouse clicks from registered components using addEventListener. It was just not consistent however moving to verison 9 seemed to correct that issue but at the cost of breaking the rest of the project.

Animations are not working, I am unable to move objects or cameras when in inspector mode yet elements do appear in inspector mode, you just cannot select the xyz arrows to move them.

I'm wondering if anyone else has experienced similar issues as described above when migrating from version 8 to 9 of A-FRAME?

The closest example of this is the code below. If you change it to version 9 of A-FRAME nothing works yet it is ok with version 8. I could not find any glaring differences between my markup and the A-FRAME documentation. Anyone else?

Re-creating every element seems to work however camera positioning within the inspector is not functional, unable to spectate to see what the camera angle would look like, and adding objects with OBJ and MTL files only shows an outline of the object whereas with version 8 everything worked 100%.

                <script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
                <script>
                AFRAME.registerComponent('cursor-hotpsot-1', {
                init: function () {
                    var COLORS = ['purple', 'green', 'blue'];
                    this.el.addEventListener('click', function (evt) {
                    var randomIndex = Math.floor(Math.random() * COLORS.length);
                    this.setAttribute('material', 'color', COLORS[randomIndex]);
                    console.log('Clicked:' + this);
                    });
                }
                });
                </script>



                <a-scene class="fullscreen" 
                    inspector=""
                    keyboard-shortcuts=""
                    screenshot="" 
                    vr-mode-ui="enabled: false"
                    cursor="rayOrigin: mouse">

                <!--
                <a-camera active="true" spectator="true"
                        wasd-controls="wsEnabled:false;enabled:false"
                        look-controls="enabled: false"
                        zoom="2.4"
                        position="0.3 0.0 -1.8"
                        rotation="0.0 132.5 0.0"
                        camera="zoom:1.5"
                        look-controls=""
                        camera="active:true"
                        data-aframe-inspector-original-camera=""
                        look-controls="enabled: false"></a-camera>
                        -->


                <a-obj-model id="diagram" 
                        position="-0.8 0 -3.5"
                        scale="0.2 0.2 0.2" 
                        shadow=""
                        rotation="-90 180 0" 
                        material="metalness: .5; src: #issTexture; src: #issTexture; " obj-model="" 
                        wasd-controls="wsEnabled:false;enabled:false"
                        look-controls="enabled: false">
                <!-- CURSOR HOTSPOTS -->
                        <!-- TOP RIGHT -->
                        <a-sphere geometry="primitive: sphere" 
                                cursor-hotpsot-1 sphere="2"
                                position="-3.5 0.1 2.0"
                                scale="0.250 0.250 0.250"
                                color="red"
                                id="hotspot_tr"></a-sphere>
                        <!-- BOTTOM LEFT -->
                        <a-sphere geometry="primitive: sphere"
                                cursor-hotpsot-1 sphere="2"
                                position="3.3 0.1 -2.3"
                                scale="0.250 0.250 0.250"
                                color="green"
                                id="hotspot_bl"></a-sphere>
                        <!-- CENTER TOP -->
                        <a-sphere geometry="primitive: sphere"
                                cursor-hotpsot-1 sphere="2"
                                position="-0.040 0.1 0.1"
                                scale="0.250 0.250 0.250"
                                color="blue"
                                id="hotspot_ct"></a-sphere>

                        </a-obj-model>     

                        <a-camera active="true" spectator="true"
                        wasd-controls="wsEnabled:false;enabled:false"
                        look-controls="enabled: false"
                        zoom="2.4" position="0.28042 0.01891 -1.85751"
                        camera="zoom:1.5" 
                        look-controls=""
                        camera="active:true"
                        data-aframe-inspector-original-camera=""
                        look-controls="enabled: false">

                        <a-animation attribute="position"
                            dur="2500"
                            fill="forwards"
                            from="0.2058 0.29058 -1.96409"
                            to="0 0 -1.5"
                            repeat="0">
                        </a-animation>

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

/////////////////////////////////////////////////

                <script src="https://aframe.io/releases/0.9.0/aframe.min.js"></script>
                <script>
                AFRAME.registerComponent('cursor-hotpsot-1', {
                init: function () {
                    var COLORS = ['purple', 'green', 'blue'];
                    this.el.addEventListener('click', function (evt) {
                    var randomIndex = Math.floor(Math.random() * COLORS.length);
                    this.setAttribute('material', 'color', COLORS[randomIndex]);
                    console.log('Clicked:' + this);
                    });
                }
                });
                </script>



                <a-scene class="fullscreen" 
                    inspector=""
                    keyboard-shortcuts=""
                    screenshot="" 
                    vr-mode-ui="enabled: false"
                    cursor="rayOrigin: mouse">

                <!--
                <a-camera active="true" spectator="true"
                        wasd-controls="wsEnabled:false;enabled:false"
                        look-controls="enabled: false"
                        zoom="2.4"
                        position="0.3 0.0 -1.8"
                        rotation="0.0 132.5 0.0"
                        camera="zoom:1.5"
                        look-controls=""
                        camera="active:true"
                        data-aframe-inspector-original-camera=""
                        look-controls="enabled: false"></a-camera>
                        -->


                <a-obj-model id="diagram" 
                        position="-0.8 0 -3.5"
                        scale="0.2 0.2 0.2" 
                        shadow=""
                        rotation="-90 180 0" 
                        material="metalness: .5; src: #issTexture; src: #issTexture; " obj-model="" 
                        wasd-controls="wsEnabled:false;enabled:false"
                        look-controls="enabled: false">
                <!-- CURSOR HOTSPOTS -->
                        <!-- TOP RIGHT -->
                        <a-sphere geometry="primitive: sphere" 
                                cursor-hotpsot-1 sphere="2"
                                position="-3.5 0.1 2.0"
                                scale="0.250 0.250 0.250"
                                color="red"
                                id="hotspot_tr"></a-sphere>
                        <!-- BOTTOM LEFT -->
                        <a-sphere geometry="primitive: sphere"
                                cursor-hotpsot-1 sphere="2"
                                position="3.3 0.1 -2.3"
                                scale="0.250 0.250 0.250"
                                color="green"
                                id="hotspot_bl"></a-sphere>
                        <!-- CENTER TOP -->
                        <a-sphere geometry="primitive: sphere"
                                cursor-hotpsot-1 sphere="2"
                                position="-0.040 0.1 0.1"
                                scale="0.250 0.250 0.250"
                                color="blue"
                                id="hotspot_ct"></a-sphere>

                        </a-obj-model>     

                        <a-camera active="true" spectator="true"
                        wasd-controls="wsEnabled:false;enabled:false"
                        look-controls="enabled: false"
                        zoom="2.4" position="0.28042 0.01891 -1.85751"
                        camera="zoom:1.5" 
                        look-controls=""
                        camera="active:true"
                        data-aframe-inspector-original-camera=""
                        look-controls="enabled: false">

                        <a-animation attribute="position"
                            dur="2500"
                            fill="forwards"
                            from="0.2058 0.29058 -1.96409"
                            to="0 0 -1.5"
                            repeat="0">
                        </a-animation>

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

Viewing the example with version 8 of A-FRAME will show three spheres that will appear towards the lower left screen. Version 9 will show nothing. I would expect version 9 to work as version 8 did.


Solution

  • a-animation has been deprecated in A-Frame 0.9.0 in favor of the animation component:

    https://aframe.io/docs/0.9.0/components/animation.html#sidebar

    The camera actualy moves but the visual representation remains in place. I filed a bug to to cover it:

    https://github.com/aframevr/aframe-inspector/issues/582