threeD example

Created Tuesday 07 April 2020

<!DOCTYPE html>
        <head>
                <title> threed </title>
        </head>



<body>

<script src="three.min.js"></script>

<script>

	

    var camera, scene, renderer,
    geometry, material, mesh;

    init();
    animate();

    function init() {
        scene = new THREE.Scene();

        camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
        camera.position.z = 500;

        geometry = new THREE.BoxGeometry( 200, 20, 200 );
        material = new THREE.MeshBasicMaterial( { color: 0xff0074, wireframe: false } );

        mesh = new THREE.Mesh( geometry, material );
        scene.add( mesh );

        renderer = new THREE.WebGLRenderer();
        renderer.setSize( window.innerWidth, window.innerHeight );

        document.body.appendChild( renderer.domElement );
    }

    function animate() {
        requestAnimationFrame( animate );
        render();
    }

    function render() {
        mesh.rotation.x += 0.03;
        mesh.rotation.y += 0.12;

        renderer.render( scene, camera );
    }

</script>



</body>
</html>


Backlinks: FSU Courses:LIS5364