SHARE
TWEET

Untitled

a guest Dec 14th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function menuShow(menu){
  2.     document.getElementById(menu).classList.toggle("slideMenu");
  3. }
  4. var material;
  5.  
  6.  
  7. function updateNoseColor(){
  8.     scene.remove(nose);
  9.     var geometry = new THREE.ConeGeometry( .4, 1, 32 );
  10.     var color = new THREE.Color(parseInt(document.getElementById("nosecolor").value, 16))
  11.     material = new THREE.MeshBasicMaterial( {color: color} );
  12.     //three.js cannot take a string as a value, so im not sure what to do
  13.     var nose = new THREE.Mesh( geometry, material );
  14.     scene.add(nose);
  15. }
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. var scene = new THREE.Scene();
  24. var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );
  25.  
  26.  
  27. var renderer = new THREE.WebGLRenderer();
  28. renderer.setSize( window.innerWidth, window.innerHeight );
  29. document.body.appendChild( renderer.domElement );
  30.  
  31.  
  32. var controls = new THREE.OrbitControls( camera, renderer.domElement );
  33. controls.update();
  34. // controls.autoRotate = true;
  35. controls.autoRotateSpeed = 5;
  36. controls.enablePan = false;
  37. controls.minDistance = 6;
  38. controls.maxDistance = 20;
  39. // create head
  40. var head;
  41.  
  42. var geometry = new THREE.SphereGeometry( 1.5, 32, 32 );
  43. var texture = new THREE.TextureLoader().load('icetexture2.jpg');
  44. var material = new THREE.MeshBasicMaterial( { map: texture } );
  45. head = new THREE.Mesh( geometry, material );
  46. head.position = new THREE.Vector3(0,0,0);
  47. scene.add( head );
  48. head.rotation.y = Math.PI / 3;
  49.  
  50. //create body
  51. var body;
  52.  
  53. var geometry = new THREE.SphereGeometry( 1, 32, 32 );
  54. var texture = new THREE.TextureLoader().load('icetexture2.jpg');
  55. var material = new THREE.MeshBasicMaterial( { map: texture } );
  56. body = new THREE.Mesh( geometry, material );
  57. scene.add( body );
  58. body.position.set(0,2,0);
  59.  
  60. var bottom;
  61.  
  62. var geometry = new THREE.SphereGeometry( 2, 32, 32 );
  63. var texture = new THREE.TextureLoader().load('icetexture2.jpg');
  64. var material = new THREE.MeshBasicMaterial( { map: texture } );
  65. bottom = new THREE.Mesh( geometry, material );
  66. scene.add( bottom );
  67. bottom.rotation.y = Math.PI / 2;
  68. bottom.position.set(0,-2.5,0);
  69.  
  70.  
  71. var nose;
  72. var geometry = new THREE.ConeGeometry( .4, 1, 32 );
  73. var material = new THREE.MeshBasicMaterial( {color:0xffa500} );
  74. var nose = new THREE.Mesh( geometry, material );
  75.  
  76. scene.add( nose );
  77. nose.rotation.x = Math.PI / 2;
  78. nose.position.set(0,1.75,1);
  79. //Eyes
  80. //eye 1
  81. var geometry = new THREE.CylinderGeometry( .1, .1, .3, 32 );
  82. var material = new THREE.MeshBasicMaterial( {color: 0x000000} );
  83.  
  84. var eye1 = new THREE.Mesh( geometry, material );
  85. scene.add( eye1 );
  86. eye1.position.set(-.3,2.25,.8);
  87. eye1.rotation.x = Math.PI / 2;
  88. camera.position.z = 10;
  89.  
  90. var eye2 = new THREE.Mesh( geometry, material );
  91. scene.add( eye2 );
  92. eye2.position.set(.3,2.25,.8);
  93. eye2.rotation.x = Math.PI / 2;
  94. camera.position.z = 10;
  95.  
  96.  
  97. //arms
  98. //arm1
  99. var geometry = new THREE.CylinderGeometry( .1, .1, 4, 32 );
  100. var texture = new THREE.TextureLoader().load('branch2.jpeg');
  101. var material = new THREE.MeshBasicMaterial( { map: texture } );
  102.  
  103.  
  104. var arm1 = new THREE.Mesh( geometry, material );
  105. scene.add( arm1 );
  106. arm1.position.set(1.25,.6,0);
  107. arm1.rotation.z = Math.PI/4;
  108.  
  109. //arm2
  110. var arm2 = new THREE.Mesh( geometry, material );
  111. scene.add( arm2 );
  112. arm2.position.set(-1.25,.6,0);
  113. arm2.rotation.z = Math.PI/-4;
  114. //armsegments
  115.  
  116. var geometry = new THREE.CylinderGeometry( .05, .05, .8, 32 );
  117. var seg1 = new THREE.Mesh( geometry, material );
  118. scene.add( seg1 );
  119. seg1.position.set(2.2,-.34,0);
  120. seg1.rotation.z = Math.PI/-4;
  121.  
  122. var seg2 = new THREE.Mesh( geometry, material );
  123. scene.add( seg2 );
  124. seg2.position.set(-2.2,-.34,0);
  125. seg2.rotation.z = Math.PI/4;
  126.  
  127. //hat
  128.  
  129. var geometry = new THREE.CylinderGeometry( 1, 1, .3, 32 );
  130. var texture = new THREE.TextureLoader().load('felt.jpg');
  131. var material = new THREE.MeshBasicMaterial( {map:texture} );
  132. var brim = new THREE.Mesh( geometry, material );
  133.  
  134. scene.add( brim );
  135. brim.position.set(0,2.8,0);
  136.  
  137.  
  138. var geometry = new THREE.CylinderGeometry( .75, .75, .7, 32 );
  139.  
  140. var hattop = new THREE.Mesh( geometry, material );
  141.  
  142. scene.add( hattop );
  143. hattop.position.set(0,3,0);
  144.  
  145.  
  146.  
  147. camera.position.z = 10;
  148.  
  149.  
  150. var animate = function () {
  151.     requestAnimationFrame( animate );
  152.    
  153.     controls.update();
  154.     renderer.render( scene, camera );
  155. };
  156.  
  157. animate();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top