SHARE
TWEET

Untitled

a guest Feb 18th, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <body></body>
  2. <script src="/three.js"></script>
  3. <script src="/controls/FlyControls.js"></script>
  4.   // The "scene" is where stuff in our game will happen:
  5.   var scene = new THREE.Scene();
  6.   var flat = {flatShading: true};
  7.   var light = new THREE.AmbientLight('white', 0.8);
  8.   scene.add(light);
  9.  
  10.   // The "camera" is what sees the stuff:
  11.   var aspectRatio = window.innerWidth / window.innerHeight;
  12.   var camera = new THREE.PerspectiveCamera(75, aspectRatio, 1, 10000);
  13.   camera.position.z = 500;
  14.   scene.add(camera);
  15.  
  16.   // The "renderer" draws what the camera sees onto the screen:
  17.   var renderer = new THREE.WebGLRenderer({antialias: true});
  18.   renderer.setSize(window.innerWidth, window.innerHeight);
  19.   document.body.appendChild(renderer.domElement);
  20.  
  21.   // ******** START CODING ON THE NEXT LINE ********
  22. var shape = new THREE.SphereGeometry(50);
  23. var cover = new THREE.MeshBasicMaterial({color:"blue"});
  24. var planet = new THREE.Mesh(shape, cover);
  25. planet.position.set(-300,0,0);
  26. scene.add(planet);
  27.  
  28. var shape = new THREE.SphereGeometry(50);
  29. var cover = new THREE.MeshBasicMaterial({color:"yellow"});
  30. var planet = new THREE.Mesh(shape, cover);
  31. planet.position.set(200, 0, 250);
  32. scene.add(planet);
  33.  
  34. function makePlanet() {
  35.   var size = r(50);
  36.   var x = r(1000) - 500;
  37.   var y = r(1000) - 500;
  38.   var z = r(1000) - 1000;
  39.   var surface = "purple";
  40.  
  41.   var shape = new THREE.SphereGeometry(size);
  42.   var cover = new THREE.MeshBasicMaterial({color: rColor()})
  43.   var planet = new THREE.Mesh(shape, cover);
  44.   planet.position.set(x, y, z);
  45.   scene.add(planet);
  46. }
  47. makePlanet();
  48. makePlanet();
  49.  
  50. for (var i=0; i<100; i++) {
  51.   makePlanet();
  52. }
  53. console.log(Math.random())
  54.  
  55. function r(max){
  56.   if (max) return max * Math.random();
  57.   return Math.random();
  58. }
  59.  
  60.  var randomNum = r();
  61.  console.log(randomNum);
  62.  
  63.  randomNum = r(100);
  64.  console.log(r(100));
  65.  
  66.  console.log(r(100));
  67.  console.log(r(100));
  68.  
  69.  function rColor() {
  70.    return new THREE.Color (r(), r(), r());
  71.  }
  72.  
  73. var controls = new THREE.FlyControls(camera);
  74. controls.movementSpeed= 100;
  75. controls.rollSpeed=0.5;
  76. controls.dragToLook=true;
  77. controls.autoForward=false;
  78.  
  79.   // Now, show what the camera sees on the screen:
  80.   renderer.render(scene, camera);
  81. </script>
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