Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


  <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 
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.