canvas_materials_reflection.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js canvas - spherical reflection</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. body {
  9. background-color: #000000;
  10. margin: 0px;
  11. overflow: hidden;
  12. }
  13. #info {
  14. position: absolute;
  15. top: 0px; width: 100%;
  16. color: #ffffff;
  17. padding: 5px;
  18. font-family: Monospace;
  19. font-size: 13px;
  20. text-align: center;
  21. }
  22. a {
  23. color: #ffffff;
  24. }
  25. a:hover {
  26. color: #0080ff;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div id="container"></div>
  32. <div id="info">
  33. <a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - spherical reflection demo.<br />
  34. Walt Disney head by <a href="http://www.davidoreilly.com/2009/01/walt-disneys-head-on-a-plate" target="_blank">David OReilly</a>. Reflection texture by <a href="http://kewlers.scene.org/" target="_blank">Kewlers</a>.
  35. </div>
  36. <script src="../build/Three.js"></script>
  37. <script src="../src/extras/ImageUtils.js"></script>
  38. <script src="obj/WaltHead.js"></script>
  39. <script src="js/RequestAnimationFrame.js"></script>
  40. <script>
  41. var camera, scene, renderer,
  42. particle1, particle2, particle2,
  43. light1, light2, light3,
  44. geometry, mesh;
  45. init();
  46. animate();
  47. function init() {
  48. var container = document.getElementById( 'container' );
  49. camera = new THREE.Camera( 65, window.innerWidth / window.innerHeight, 1, 1000 );
  50. camera.position.z = 100;
  51. scene = new THREE.Scene();
  52. geometry = new WaltHead();
  53. geometry.computeVertexNormals();
  54. mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ) );
  55. mesh.overdraw = true;
  56. scene.add( mesh );
  57. renderer = new THREE.CanvasRenderer();
  58. renderer.setSize( window.innerWidth, window.innerHeight );
  59. container.appendChild( renderer.domElement );
  60. }
  61. //
  62. function animate() {
  63. requestAnimationFrame( animate );
  64. render();
  65. }
  66. function render() {
  67. var time = new Date().getTime() * 0.0005;
  68. mesh.rotation.y -= 0.01;
  69. renderer.render( scene, camera );
  70. }
  71. </script>
  72. </body>
  73. </html>