<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
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |