Skip main navigation

Alternative Options [CodePen/Github.io]

Another option if you are not able to use Glitch
18.3
In this session, we’re going to learn how to use codepen.io to host our virtual worlds. And the fun stuff with AR and VR often occurs when you access your application via a smartphone or another device like a VR headset. Let’s explore codepen.io and see how it’s being used. Start by navigating to the CodePen web page and create an account. I already have one created. But once you’ve created yours and logged in, you should see an interface just like this. Now select Create Pen from the left hand side menu. The CodePen page consists of three sections HTML, CSS and JavaScript. As you notice over here we have the HTML tab, CSS tab, and JS tab.
62.2
Now, we actually won’t be using CSS in our activities. So we can go ahead and collapse it here. You can write the code straight into Pen, or you can copy across code written in your favourite editor. Here, I’m going to copy across code that I’ve already written. The file, like a normal HTML file, has a header and body section which will transfer into CodePen. Now, CodePen organises the header and body a bit differently. Notice that there is no visible menu to add our header. So we can access the head section in CodePen by clicking the Open HTML Settings button close to the HTML tab. Select the code that’s between the two head tags and copy it.
101.2
Now go back to our CodePen web page and paste this code in the head section. Now we can click Save and Close. Now let us copy the actual body to add in the scene. In CodePen the HTML tab is where the body of the page is defined. So let’s copy across everything between the body tags from our HTML file. The moment we start to do this, the scene starts to upload.
126.4
If you want to see what the virtual world application looks like in full mode, we can enter the VR mode. And you can actually move around in this as well, as shown here. We can now come out of full mode. Now, this will work most of the time when you’re not using Assets. But if you are using Assets, then these are loaded from a different location. And CodePen doesn’t allow the uploading of these assets unless you get premium. Glitch.me does, as we have discussed in the previous session. Instead we’re going to use GitHub Pages. GitHub Pages has install instructions telling you how to set up your pages, creates a repository, and save your files. I have done this for myself.
165.8
And this is my github.io page. I’ve already created a folder called Assets. And within that folder is a file called spacepano.jpg. We can access this image by editing the path as seen here. And this will then display in our github.io. If I want to access this file on CodePen, then I just need to copy the URL address or file path and paste it into my CodePen after the scene, as seen here. If I want to use assets, an AFrame requires that I declare these in advance. So let’s go to the scene section and add all the assets code immediately after the scene background, as shown here.
204.4
The moment we do that, we can see that the scene will start updating itself. And we can also view this in full VR mode by clicking on the VR icon in the scene’s right hand corner. So this is how we can use assets copied from your GitHub into your CodePen code, and how you can use github.io pages to serve up assets that you can use in your virtual world. Now to exit the full screen VR mode, right click on the page and select Exit Full Screen. The advantage of this approach is that Pen is accessible from anywhere using its unique URL. You can create an unlimited number of Pens, but you have to be careful to reduce the clutter.
242.1
Now you should be able to use codepen.io to create simple AFrame scenes, use github.io to host your assets like images and objects, access those assets to use in your own scenes, and access the pens across other devices too.
CodePen & Github.io

In this step, we show you another alternative to Glitch to deploy you virtual world applications. There are step-by-step instructions on how you could use CodePen and Github.io web-based platforms to display your virtual world applications (or VR web-app).

Glitch and Codepen are not the only options. You could also deploy your own server (local or public) to host your VR web-app. The choice depends on what is available at hand.

This article is from the free online

Construct a Virtual Reality Experience

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education