<title> Changing Sky Source</title>

  <!--  --------- IMPORTED LIBRARIES  ------>

  <script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script>



  <a-scene> <!-- Creating scene -->

    <!--  --------- ASSETS  --------- -->

    <!-- Asset links. -->

      <img id="background_inside_house" crossorigin="anonymous" src="https://cdn.glitch.com/e6225ccd-c32e-4cf8-b039-e78814a8cb78%2Fbg-3.jpg?1498128817274">
 <img id="chinese_temple" crossorigin="anonymous" src="https://cdn.glitch.com/e6225ccd-c32e-4cf8-b039-e78814a8cb78%2Fbg-1.jpg?1498129063299">

    <!--  --------- SKY  --------- -->

    <a-sky id="background-img" src="#background_inside_house" theta-length="130"></a-sky>
      You can use the keys W,A,S,D to move around
      But for that you need to change Theta length (cylinder radius)
      This will create a "hole" in the floor of the image --> 
  <a-plane id="btn_trigger" position="3 3 -9" height="2" width="5" rotation="0 0 0" color="#e21d2d"> 
    <!-- a-plane is like a rectangle. 
         I use them as buttons only to keep some of the usual UI conventions. Even though you are on a new medium, if you want users to understand your applocation/website you need to use some of the expected norms and rules of UI/UX

The a-plane tag  has a lot of possibilities in terms of properties, check them out here https://aframe.io/docs/0.6.0/primitives/a-plane.html--> 
          <a-text value="Trip to China" position="0 0 0" scale="2 2 2" align="center" ></a-text> <!--Since this is inside the plane, the text position is relative to the plain's position
If you use the property align wisely, you don't need to experiment with position

Text documentation: https://aframe.io/docs/0.6.0/primitives/a-text.html--> 
 <!--  --------- CAMERA AND CURSOR  --------- -->  
<a-camera  look-controls-enabled wasd-controls-enabled position="0 1 4"> 
  <!--Enabling gaze controls = look-controls-enabled
      Enabling key control=  wasd-controls-enabled
      You can use the keys W,A,S,D to move around--> 
    <a-cursor position="0 0 -3"
              geometry="primitive: ring; radiusOuter: 0.030; radiusInner: 0.020;" 
              material="color: #11d8c4; shader: flat"
              fuse="true" timeout="10">  <!--Giving our cursor properties--> 
               <!--The timeout defines how long it'll take to trigger something on fuse--> 
        <a-animation begin="click" easing="ease-in" attribute="color" 
               fill="backwards" from="#11d8c4" to="#ffffff"></a-animation>  <!--Animating the cursor while you click--> 

        <a-animation begin="cursor-hovering" easing="ease-in" attribute="scale"
               fill="forwards" from="1 1 1" to="0.5 0.5 0.5"></a-animation>  <!--Animating the cursor while you hover--> 
    </a-cursor> <!--These animations serve for the purposes of debugging and better UX
                    If there is something you want to be followed by the cursor, draw it below--> 


  <!-- Closing scene -->

 <!--  --------- JAVASCRIPT  --------- -->     
//--  --------- CHANGE BG ON BUTTON HOVER JS  ---------  
       function ChangeBackground() { //Using full JS in order to keep the code tidy and understandable
         //Jquery is good as well, but I have a tendency to mix it with Js, so that creates a few errors
          var trigger = document.getElementById("btn_trigger"); // <a-plane id="btn_trigger">
          var sky = document.getElementById("background-img");  // <a-sky id="background-img">
          trigger.addEventListener('mouseenter', function () {//open  event listener
            //here we change the sky src IF the mouse has entered the plane with the id btn_trigger 
          }); // Close  event listener
          trigger.addEventListener('mouseleave', function () { //open  event listener
             //here we change the sky src back to the original image once mouse has left the plane with the id btn_trigger 
            //in case you don't want to change back to the original image, just remove the whole mouseleave event
          }); // Close  event listener
         }//Close function
       ChangeBackground(); //calling the function 
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.