123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <!doctype html>
- <html lang="en">
- <head>
- <title>three.js canvas - geometry - earth</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <style type="text/css">
- body {
- color: #808080;
- font-family:Monospace;
- font-size:13px;
- text-align:center;
- background-color: #ffffff;
- margin: 0px;
- overflow: hidden;
- }
- #info {
- position: absolute;
- top: 0px; width: 100%;
- padding: 5px;
- }
- a {
- color: #0080ff;
- }
- </style>
- </head>
- <body>
- <div id="container"></div>
- <div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - earth demo</div>
- <script type="text/javascript" src="../build/Three.js"></script>
- <script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
- <script type="text/javascript" src="js/Stats.js"></script>
- <script type="text/javascript">
- var container, stats;
- var camera, scene, renderer;
- var mesh;
- var mouseX = 0, mouseY = 0;
- var windowHalfX = window.innerWidth / 2;
- var windowHalfY = window.innerHeight / 2;
- init();
- animate();
- function init() {
- container = document.getElementById( 'container' );
- camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
- camera.position.z = 500;
- scene = new THREE.Scene();
- mesh = new THREE.Mesh( new THREE.PlaneGeometry( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ) } ) );
- mesh.overdraw = true;
- mesh.position.y = - 250;
- mesh.rotation.x = - 90 * Math.PI / 180;
- scene.add(mesh);
- mesh = new THREE.Mesh( new THREE.SphereGeometry( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ) );
- mesh.overdraw = true;
- scene.add(mesh);
- renderer = new THREE.CanvasRenderer();
- renderer.setSize( window.innerWidth, window.innerHeight );
- container.appendChild( renderer.domElement );
- stats = new Stats();
- stats.domElement.style.position = 'absolute';
- stats.domElement.style.top = '0px';
- container.appendChild( stats.domElement );
- document.addEventListener( 'mousemove', onDocumentMouseMove, false );
- }
- function onDocumentMouseMove( event ) {
- mouseX = ( event.clientX - windowHalfX );
- mouseY = ( event.clientY - windowHalfY );
- }
- //
- function animate() {
- requestAnimationFrame( animate );
- render();
- stats.update();
- }
- function render() {
- camera.position.x += ( mouseX - camera.position.x ) * 0.05;
- camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
- mesh.rotation.y -= 0.005;
- renderer.render( scene, camera );
- }
- </script>
- </body>
- </html>
|