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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

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 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.


                <!DOCTYPE html>
    <title>Hello, WebVR! - A-Frame</title>
    <meta name="description" content="Hello, WebVR! - A-Frame">
    <script src=""></script>
    <a-scene vr-mode-ui="enabled: false">

      <a-camera look-controls-enabled="false">
        <a-cursor color="#fff" scale="2.5 2.5 2.5">
      <a-box id="box01" position="0 1.5 -2" rotation="0 45 0" color="#FF0000"></a-box>
          position="-1 1 2">
      <a-sky color="#ECECEC"></a-sky>


                * {
  margin: 0;
  padding: 0;
  border: 0;

body {
  background: #fdf;
  font: 30px sans-serif;


                // forked from siouxcitizen's "A-Frame Practice 10 カメラを固定 & VRボタンを非表示にしてみました "
// どこをクリックしても、常にBoxをクリックしたと認識されてしまっている
// look-controls-enabled="false" としていると常にBoxがクリックされているとみなされるようです
// カメラを固定していると、カーソルも常にBoxの正面に位置していると認識されているから?
//JavaScriptでVRコンテンツを面白く - スマホブラウザでお手軽VR 第4回-

var sceneEl;

var box01;
var boxColor = 1; //1:赤 → 2:青 → 3:緑 → 1:赤へもどる

var camera;
var cursor;

var isMouseDown = false;

function init() {

    sceneEl = document.querySelector("a-scene");
    box01 = sceneEl.querySelector("#box01"); 
    // マウス、タッチ処理を呼び出すイベントリスナーをセット
    document.addEventListener("mousedown", onMouseDown);
    document.addEventListener("touchstart", onMouseDown);
    document.addEventListener("mouseup", onMouseUp);
    document.addEventListener("touchend", onMouseUp);
    document.addEventListener("mousemove", onMouseMove);
    document.addEventListener("touchmove", onMouseMove);

    box01.addEventListener("click", onMouseClick);


function render() {
// マウスをクリックしたとき
function onMouseClick(event) {
    if (boxColor == 1) {//Boxの色を赤から青に変えます

       box01.setAttribute("color", "#0000FF");
       boxColor = 2; 
    } else if (boxColor == 2) {//Boxの色を青から緑に変えます

       box01.setAttribute("color", "#00FF00");
       boxColor = 3; 
    } else if (boxColor == 3) {//Boxの色を緑から赤に変えます 

       box01.setAttribute("color", "#FF0000");
       boxColor = 1;


// マウスを押したとき
function onMouseDown(event) {
    isMouseDown = true;

// マウスを動かした時
function onMouseMove(event) {
    if (isMouseDown) {
        // 3DモデルをX軸とY軸方向に回転させます       
        if ( box01 )            
		    box01.setAttribute("rotation", (getMouseX(event)*2)+" "+(getMouseY(event)*2)+" 0");

// マウスを離したとき
function onMouseUp(event) {
    isMouseDown = false;

function getMouseX(event) {
    if (event.type.indexOf("touch") == -1)
        return event.clientX;
        return event.touches[0].clientX;

function getMouseY(event) {
    if (event.type.indexOf("touch") == -1)
        return event.clientY;
        return event.touches[0].clientY;

window.onload = function() {