This repository has been archived by the owner on Apr 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
85 lines (74 loc) · 2.75 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html>
<body>
<input type=button value="Enter XR" onclick="document.getElementById('xr-engine').enterXr();">
<script type=module src="https://web.exokit.org/ew.js"></script>
<script src="js/three.js"></script>
<template is=xr-engine-template>
<html>
<body>
<xr-site>
<xr-iframe position="7 0 7" extents="[0 0 15 15]" load-distance=0 src="app1.html"></xr-iframe>
<xr-iframe position="16 0 16" extents="[16 16 29 29]" load-distance=0 src="app2.html"></xr-iframe>
<xr-iframe position="16 0 0" extents="[16 0 28 15] 29 15" load-distance=0 src="app2.html"></xr-iframe>
<xr-iframe position="29 0 0" extents="[29 0 29 14]" load-distance=0 src="app2.html"></xr-iframe>
<xr-iframe position="0 0 16" extents="[0 16 15 29]" load-distance=0 src="app2.html"></xr-iframe>
</xr-site>
<!-- <script src="js/three.js"></script>
<script src="js/GLTFLoader.js"></script>
<script>
(async () => {
const xrSite = document.querySelector('xr-site');
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.sortObjects = false;
// renderer.shadowMap.enabled = true;
// renderer.shadowMap.type = THREE.PCFShadowMap;
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.matrixAutoUpdate = false;
const camera = new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight, 0.1, 1000);
scene.add(camera);
const ambientLight = new THREE.AmbientLight(0x808080, 1);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xFFFFFF, 1);
directionalLight.position.set(1, 1, 1);
scene.add(directionalLight);
const cubeMesh = (() => {
const geometry = new THREE.BoxBufferGeometry(0.1, 10, 0.1)
.applyMatrix(new THREE.Matrix4().makeTranslation(0, 10/2, 0));
const materials = new THREE.MeshPhongMaterial({
color: 0x808080,
});
const mesh = new THREE.Mesh(geometry, materials);
return mesh;
})();
scene.add(cubeMesh);
const session = await xrSite.requestSession();
xrSite.layers.push(renderer.domElement);
renderer.vr.setSession(session, {
frameOfReferenceType: 'stage',
});
renderer.setSize(xrSite.width, xrSite.height);
renderer.setPixelRatio(1);
renderer.vr.enabled = true;
renderer.vr.setAnimationLoop(animate);
function animate() {
/* const f = (Date.now() % 30000) / 30000;
camera.position.set(Math.cos(f*Math.PI*2)*5, 5, Math.sin(f*Math.PI*2)*5);
camera.lookAt(new THREE.Vector3());
xrSite.cameraPosition = camera.position.toArray();
xrSite.cameraOrientation = camera.quaternion.toArray(); */
renderer.render(scene, camera);
}
})();
</script> -->
</body>
</html>
</template>
</body>
</html>