|
@@ -0,0 +1,129 @@
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
+<html lang="en">
|
|
|
|
+ <head>
|
|
|
|
+ <title>three.js webvr - frustum</title>
|
|
|
|
+ <meta charset="utf-8">
|
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
|
|
|
+ <!-- Origin Trial Token, feature = WebVR (For Chrome M62+), origin = https://threejs.org, expires = 2018-09-11 -->
|
|
|
|
+ <meta http-equiv="origin-trial" data-feature="WebVR (For Chrome M62+)" data-expires="2018-09-11" content="AqhFUYKxq/d+E8CDT0fuYRCg8TvlTP52x0Jv7I9t27sLhR30LmcahBRfSwzP89ukjs2+ia99VrrLoRyaFAwJVA0AAABQeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJWUjEuMU02MiIsImV4cGlyeSI6MTUzNjYyNDAwMH0=">
|
|
|
|
+ <!-- Origin Trial Token, feature = WebXR Device API (For Chrome M69+), origin = https://threejs.org, expires = 2018-10-27 -->
|
|
|
|
+ <meta http-equiv="origin-trial" data-feature="WebXR Device API (For Chrome M69+)" data-expires="2018-10-27" content="An4ZYOGvf6kVHNxqZxS02TPAvpZESkmBhcVCM/byViDDuEB2XKvCF43aCJjrAU/R8H3WDlv+1bDGTL/XxstHGgoAAABTeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJYUkRldmljZU02OSIsImV4cGlyeSI6MTU0MDY1NTAyMn0=">
|
|
|
|
+ <!-- Origin Trial Token, feature = WebXR Gamepad Support, origin = https://threejs.org, expires = 2018-10-24 -->
|
|
|
|
+ <meta http-equiv="origin-trial" data-feature="WebXR Gamepad Support" data-expires="2018-10-24" content="Agrr6lZhlwzv5jmv/mpLZA37DIiVcg3HvX8bH8EWB+OBruV3sUJuzDfYz6qs/je+LcH41DkrmPn4k9RaUaqpQAAAAABYeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJYUkdhbWVwYWRTdXBwb3J0IiwiZXhwaXJ5IjoxNTQwMzg4NjI0fQ==">
|
|
|
|
+ <style>
|
|
|
|
+ body {
|
|
|
|
+ font-family: Monospace;
|
|
|
|
+ background-color: #101010;
|
|
|
|
+ color: #fff;
|
|
|
|
+ margin: 0px;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ }
|
|
|
|
+ a {
|
|
|
|
+ color: #f00;
|
|
|
|
+ }
|
|
|
|
+ </style>
|
|
|
|
+ </head>
|
|
|
|
+ <body>
|
|
|
|
+
|
|
|
|
+ <script src="../build/three.js"></script>
|
|
|
|
+ <script src="js/vr/WebVR.js"></script>
|
|
|
|
+ <script src="js/geometries/BoxLineGeometry.js"></script>
|
|
|
|
+
|
|
|
|
+ <script>
|
|
|
|
+
|
|
|
|
+ var size = 10;
|
|
|
|
+
|
|
|
|
+ var container;
|
|
|
|
+ var camera, scene, raycaster, renderer;
|
|
|
|
+
|
|
|
|
+ var room;
|
|
|
|
+
|
|
|
|
+ init();
|
|
|
|
+ animate();
|
|
|
|
+
|
|
|
|
+ function init() {
|
|
|
|
+
|
|
|
|
+ container = document.createElement( 'div' );
|
|
|
|
+ document.body.appendChild( container );
|
|
|
|
+
|
|
|
|
+ var info = document.createElement( 'div' );
|
|
|
|
+ info.style.position = 'absolute';
|
|
|
|
+ info.style.top = '10px';
|
|
|
|
+ info.style.width = '100%';
|
|
|
|
+ info.style.textAlign = 'center';
|
|
|
|
+ info.innerHTML = '<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - interactive cubes';
|
|
|
|
+ container.appendChild( info );
|
|
|
|
+
|
|
|
|
+ scene = new THREE.Scene();
|
|
|
|
+ scene.background = new THREE.Color( 0x505050 );
|
|
|
|
+
|
|
|
|
+ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1, 10 );
|
|
|
|
+ scene.add( camera );
|
|
|
|
+
|
|
|
|
+ room = new THREE.LineSegments(
|
|
|
|
+ new THREE.BoxLineGeometry( 6, 6, 6, 10, 10, 10 ),
|
|
|
|
+ new THREE.LineBasicMaterial( { color: 0x808080 } )
|
|
|
|
+ );
|
|
|
|
+ room.position.y = 3;
|
|
|
|
+ scene.add( room );
|
|
|
|
+
|
|
|
|
+ scene.add( new THREE.HemisphereLight( 0x606060, 0x404040 ) );
|
|
|
|
+
|
|
|
|
+ var geometry = new THREE.BoxBufferGeometry( 0.15, 0.15, 0.15 );
|
|
|
|
+
|
|
|
|
+ for ( var x = 0; x < size; x ++ ) {
|
|
|
|
+ for ( var y = 0; y < size; y ++ ) {
|
|
|
|
+
|
|
|
|
+ var xVal = x / size;
|
|
|
|
+ var yVal = y / size;
|
|
|
|
+ var color = new THREE.Color( 1, 1, 1 );
|
|
|
|
+ color.r = x % 2;
|
|
|
|
+ color.g = y % 2;
|
|
|
|
+ color.b = 1;
|
|
|
|
+ var object = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: color } ));
|
|
|
|
+
|
|
|
|
+ object.position.x = xVal * 8 - 4;
|
|
|
|
+ object.position.y = yVal * 8 - 4;
|
|
|
|
+ object.position.z = -4;
|
|
|
|
+
|
|
|
|
+ room.add( object );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
|
|
+ renderer.setPixelRatio( window.devicePixelRatio );
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+ renderer.vr.enabled = true;
|
|
|
|
+ container.appendChild( renderer.domElement );
|
|
|
|
+
|
|
|
|
+ window.addEventListener( 'resize', onWindowResize, false );
|
|
|
|
+
|
|
|
|
+ document.body.appendChild( WEBVR.createButton( renderer ) );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function onWindowResize() {
|
|
|
|
+
|
|
|
|
+ camera.aspect = window.innerWidth / window.innerHeight;
|
|
|
|
+ camera.updateProjectionMatrix();
|
|
|
|
+
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function animate() {
|
|
|
|
+
|
|
|
|
+ renderer.setAnimationLoop( render );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function render() {
|
|
|
|
+
|
|
|
|
+ renderer.render( scene, camera );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ </script>
|
|
|
|
+ </body>
|
|
|
|
+</html>
|