ボタンを押すまでA-Frameの描画開始を遅れさせてみたいサンプル。
Last active
October 29, 2018 18:06
-
-
Save sounisi5011/a7e9dc6928e784a6f4305c2994ee1db0 to your computer and use it in GitHub Desktop.
A-Frame Async Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang=en> | |
<meta charset=utf-8> | |
<meta name=viewport content="width=device-width,initial-scale=1"> | |
<meta name=format-detection content="telephone=no,email=no,address=no"> | |
<title>A-Frame Async Test</title> | |
<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script> | |
<body> | |
<script src="./main.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init(evt) { | |
var startButtonElem = evt.currentTarget; | |
startButtonElem.hidden = true; | |
var aSceneElem = document.createElement('a-scene'); | |
var aBoxElem = document.createElement('a-box'); | |
var aSphereElem = document.createElement('a-sphere'); | |
var aCylinderElem = document.createElement('a-cylinder'); | |
var aPlaneElem = document.createElement('a-plane'); | |
var aSkyElem = document.createElement('a-sky'); | |
aBoxElem.setAttribute('position', '-1 0.5 -3'); | |
aBoxElem.setAttribute('rotation', '0 45 0'); | |
aBoxElem.setAttribute('color', '#4CC3D9'); | |
aSceneElem.appendChild(aBoxElem); | |
aSphereElem.setAttribute('position', '0 1.25 -5'); | |
aSphereElem.setAttribute('radius', '1.25'); | |
aSphereElem.setAttribute('color', '#EF2D5E'); | |
aSceneElem.appendChild(aSphereElem); | |
aCylinderElem.setAttribute('position', '1 0.75 -3'); | |
aCylinderElem.setAttribute('radius', '0.5'); | |
aCylinderElem.setAttribute('height', '1.5'); | |
aCylinderElem.setAttribute('color', '#FFC65D'); | |
aSceneElem.appendChild(aCylinderElem); | |
aPlaneElem.setAttribute('position', '0 0 -4'); | |
aPlaneElem.setAttribute('rotation', '-90 0 0'); | |
aPlaneElem.setAttribute('width', '4'); | |
aPlaneElem.setAttribute('height', '4'); | |
aPlaneElem.setAttribute('color', '#7BC8A4'); | |
aSceneElem.appendChild(aPlaneElem); | |
aSkyElem.setAttribute('color', '#ECECEC'); | |
aSceneElem.appendChild(aSkyElem); | |
document.body.appendChild(aSceneElem); | |
} | |
var startButtonElem = document.createElement('button'); | |
startButtonElem.type = 'button'; | |
startButtonElem.textContent = 'Start!'; | |
startButtonElem.addEventListener('click', init, false); | |
document.body.appendChild(startButtonElem); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment