Commit 274ec007 authored by Alfakhori's avatar Alfakhori
Browse files

Update public/webXR/three.html

parent 09b3f0a8
Pipeline #7503 passed with stages
in 10 seconds
...@@ -14,53 +14,50 @@ ...@@ -14,53 +14,50 @@
<!-- Starting an immersive WebXR session requires user interaction. <!-- Starting an immersive WebXR session requires user interaction.
We start this one with a simple button. --> We start this one with a simple button. -->
<script> <script>
// ------------------------------------------------ // create a Scene
// BASIC SETUP const scene = new Scene();
// ------------------------------------------------
// Create an empty scene // Set the background color
var scene = new THREE.Scene(); scene.background = new Color('skyblue');
// Create a basic perspective camera // Create a camera
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); const fov = 35; // AKA Field of View
camera.position.z = 4; const aspect = container.clientWidth / container.clientHeight;
const near = 0.1; // the near clipping plane
const far = 100; // the far clipping plane
// Create a renderer with Antialiasing const camera = new PerspectiveCamera(fov, aspect, near, far);
var renderer = new THREE.WebGLRenderer({antialias:true});
// Configure renderer clear color // every object is initially created at ( 0, 0, 0 )
renderer.setClearColor("#000000"); // move the camera back so we can view the scene
camera.position.set(0, 0, 10);
// Configure renderer size // create a geometry
renderer.setSize( window.innerWidth, window.innerHeight ); const geometry = new BoxBufferGeometry(2, 2, 2);
// Append Renderer to DOM // create a default (white) Basic material
document.body.appendChild( renderer.domElement ); const material = new MeshBasicMaterial();
// ------------------------------------------------ // create a Mesh containing the geometry and material
// FUN STARTS HERE const cube = new Mesh(geometry, material);
// ------------------------------------------------
// Create a Cube Mesh with basic material // add the mesh to the scene
var geometry = new THREE.BoxGeometry( 1, 1, 1 ); scene.add(cube);
var material = new THREE.MeshBasicMaterial( { color: "#433F81" } );
var cube = new THREE.Mesh( geometry, material );
// Add cube to Scene // create the renderer
scene.add( cube ); const renderer = new WebGLRenderer();
// Render Loop // next, set the renderer to the same size as our container element
var render = function () { renderer.setSize(container.clientWidth, container.clientHeight);
requestAnimationFrame( render );
cube.rotation.x += 0.01; // finally, set the pixel ratio so that our scene will look good on HiDPI displays
cube.rotation.y += 0.01; renderer.setPixelRatio(window.devicePixelRatio);
// Render the scene // add the automatically created <canvas> element to the page
renderer.render(scene, camera); container.append(renderer.domElement);
};
render(); // render, or 'create a still image', of the scene
renderer.render(scene, camera);
</script> </script>
</body> </body>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment