-
Notifications
You must be signed in to change notification settings - Fork 4
/
snowmen.html
42 lines (41 loc) · 1.78 KB
/
snowmen.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html><html><head>
<title>glb-viewer</title>
<script src="https://aframe.io/releases/1.1.0/aframe.min.js"></script>
<script src="https://rawgit.com/fernandojsg/aframe-teleport-controls/master/dist/aframe-teleport-controls.min.js"></script>
</head>
<script type="module">
onload = () => {
const putSnowman = (pos, th) => {
const obj = document.createElement("a-entity");
obj.setAttribute("gltf-model", "#snowman");
obj.setAttribute("position", pos);
obj.setAttribute("rotation", { x: 0, y: th, z: 0 });
scene.appendChild(obj);
};
const n = 8;
for (let i = 0; i < n; i++) {
const th = Math.PI * 2 / n * i;
const x = Math.cos(th) * 2;
const y = 0;
const z = Math.sin(th) * 2;
putSnowman({ x, y, z }, -th / Math.PI * 180 + 90 );
}
};
</script>
<body>
<a-scene id="scene" background="color: #333" renderer="colorManagement: true">
<a-assets timeout="10000">
<a-asset-item id="snowman" src="./snowman.glb"></a-asset-item>
</a-assets>
<a-entity light="type: ambient; color: #FFF"></a-entity>
<a-entity light="type: directional; color: #FFF; intensity: 1" position="-0 2 1"></a-entity>
<a-entity light="type: directional; color: #FFF; intensity: 1" position="-0 1 .5"></a-entity>
<a-plane color="#555" height="300" width="300" rotation="-90 0 0"></a-plane>
<a-entity id="cameraRig">
<a-entity id="head" camera position="0 1.7 0" wasd-controls look-controls></a-entity>
<a-entity oculus-touch-controls="hand:left" teleport-controls="button:trigger; collisionEntities:.collidable; cameraRig:#cameraRig; teleportOrigin:#head;"></a-entity>
<a-entity oculus-touch-controls="hand:right" teleport-controls="button:trigger; collisionEntities:.collidable; cameraRig:#cameraRig; teleportOrigin:#head;"></a-entity>
</a-entity>
</a-scene>
</body>
</html>