Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>

<head>
  <title> Changing Sky Source</title>

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

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

</head>

<body>

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


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

    <!-- Asset links. -->
    <a-assets>

      <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">
    </a-assets>


    <!--  --------- 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--> 
          
        </a-plane>
    
    
 <!--  --------- 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--> 

</a-camera> 
    
      

  </a-scene>
  <!-- Closing scene -->
  
</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                 <!--  --------- 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 
   
              sky.setAttribute('src','#chinese_temple');
                
          }); // 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
   
              sky.setAttribute('src','#background_inside_house');
                
          }); // Close  event listener
      
         }//Close function
       
        
       
       ChangeBackground(); //calling the function 
       
       
              
            
!
999px

Console