Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Tennis</title>
    <link rel="stylesheet" type="text/css" href="home.css">
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <!--adding the js libraries-->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r72/three.min.js"></script>
    <script src="https://dl.dropboxusercontent.com/u/3587259/Code/Threejs/OrbitControls.js"></script><!--to be able to pan and do controls.update-->
</head>
<body>
    <div id="ThreeJS"></div>
</body>
</html>
 
var animationTracker,count=0;
    var floormesh=null,floorTexture,floorMaterial,floorGeometry;//floor
    var skyBoxGeometry,skyBoxMaterial,skyBox;//sky
    var SCREEN_WIDTH = 1256,SCREEN_HEIGHT = 643,scene,camera,renderer,light,container,animationTracker;
    var mesh;
    var textAnimationCount = 0,textMesh;
    init();
    function init()
    {
        /* 1.set SCREEN_WIDTH and SCREEN_HEIGHT */
   
        /* 2.scene*/
        scene = new THREE.Scene();
        /* 3.camera */
        camera = new THREE.PerspectiveCamera(45,SCREEN_WIDTH/SCREEN_HEIGHT,0.1,1000);
        camera.position.x = 0;
        camera.position.y = 14;
        camera.position.z = 45;
        camera.lookAt(scene.position);
        /* 4.renderer */
        renderer = new THREE.WebGLRenderer();
        renderer.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);
        /* 7.light */
        light = new THREE.DirectionalLight('white',1);
        //light.position.set(0,10,10).normalize();
        light.position.set(20,20,0).normalize();
        /* adding elements to scene */
        drawFloorAndSky();
        /* 8.weave together */
        container = document.getElementById('ThreeJS');
        container.appendChild(renderer.domElement);
        //scene.add(cube);
        renderer.render(scene,camera);
    }
    function drawFloorAndSkyAnimate()
    {
        animationTracker = requestAnimationFrame( drawFloorAndSkyAnimate );
        count++;
        renderer.render(scene,camera);
        controls.update();
        console.log("position : x=="+floor.position.x+",y=="+floor.position.y+",z=="+floor.position.z);
        console.log("rotation : x=="+floor.rotation.x+",y=="+floor.rotation.y+",z=="+floor.rotation.z);
    }
function drawFloorAndSkyAnimate()
    {
        animationTracker = requestAnimationFrame( drawFloorAndSkyAnimate );
        count++;
        renderer.render(scene,camera);
        controls.update();
        console.log("position : x=="+floor.position.x+",y=="+floor.position.y+",z=="+floor.position.z);
        console.log("rotation : x=="+floor.rotation.x+",y=="+floor.rotation.y+",z=="+floor.rotation.z);
    }
    function drawFloorAndSky()
    {
        //////////////
        // CONTROLS //
        //////////////
        // move mouse and: left   click to rotate,
        //                 middle click to zoom,
        //                 right  click to pan
        controls = new THREE.OrbitControls( camera, renderer.domElement );
        ///////////
        // FLOOR //
        ///////////
        // note: 4x4 checkboard pattern scaled so that each square is 25 by 25 pixels.
        //var floorTexture = new THREE.ImageUtils.loadTexture( 'images/checkerboard.jpg' );
        floorTexture = new THREE.ImageUtils.loadTexture( 'grass256.jpg' );
        floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
        floorTexture.repeat.set( 20, 20 );
        // DoubleSide: render texture on both sides of mesh
        floorMaterial = new THREE.MeshBasicMaterial( { map: floorTexture, side: THREE.DoubleSide } );
        floorGeometry = new THREE.PlaneGeometry(100, 100, 1, 1);
        floor = new THREE.Mesh(floorGeometry, floorMaterial);
        floor.position.y = -0.5;
        floor.rotation.x = Math.PI / 2;
        scene.add(floor);
        /////////
        // SKY //
        /////////
        // recommend either a skybox or fog effect (can't use both at the same time)
        // without one of these, the scene's background color is determined by webpage background
        // make sure the camera's "far" value is large enough so that it will render the skyBox!
        skyBoxGeometry = new THREE.CubeGeometry( 1000, 1000, 1000 );
        // BackSide: render faces from inside of the cube, instead of from outside (default).
        skyBoxMaterial = new THREE.MeshBasicMaterial( { color: 0x9999ff, side: THREE.BackSide } );
        skyBox = new THREE.Mesh( skyBoxGeometry, skyBoxMaterial );
        scene.add(skyBox);
        /* keeping it going */
        requestAnimationFrame( drawFloorAndSkyAnimate );
        renderer.render(scene,camera);
        controls.update();
    }
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers