canvas_materials_normal.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js canvas - normal material</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: #808080;
  17. padding: 5px;
  18. font-family: Monospace;
  19. font-size: 13px;
  20. text-align: center;
  21. }
  22. a {
  23. color: #ffffff;
  24. text-decoration: none;
  25. }
  26. a:hover {
  27. color: #0080ff;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div id="container"></div>
  33. <div id="info">
  34. <a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - normal material.<br />
  35. Walt Disney head by <a href="http://davidoreilly.com/post/18087489343/disneyhead" target="_blank">David OReilly</a>
  36. </div>
  37. <script src="../build/Three.js"></script>
  38. <script>
  39. var camera, scene, renderer,
  40. loader, mesh;
  41. init();
  42. animate();
  43. function init() {
  44. var container = document.getElementById( 'container' );
  45. camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 2000 );
  46. camera.position.set( 0, - 6, 100 );
  47. scene = new THREE.Scene();
  48. scene.add( camera );
  49. loader = new THREE.JSONLoader();
  50. loader.load( 'obj/WaltHeadLo.js', function ( geometry ) {
  51. mesh = new THREE.Mesh( geometry, new THREE.MeshNormalMaterial( { overdraw: true } ) );
  52. scene.add( mesh );
  53. } );
  54. renderer = new THREE.CanvasRenderer();
  55. renderer.setSize( window.innerWidth, window.innerHeight );
  56. container.appendChild( renderer.domElement );
  57. }
  58. //
  59. function animate() {
  60. requestAnimationFrame( animate );
  61. render();
  62. }
  63. function render() {
  64. var time = Date.now() * 0.0005;
  65. if ( mesh ) {
  66. mesh.rotation.x -= 0.005;
  67. mesh.rotation.y -= 0.01;
  68. }
  69. renderer.render( scene, camera );
  70. }
  71. </script>
  72. </body>
  73. </html>