Advertisement
yskang

threejs-minecraft-31

Apr 25th, 2020 (edited)
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //In index.html
  2. <script src="js/PointerLockControls.js"></script>
  3. <script src="js/NavigationTool.js"></script>
  4.  
  5. //In index.css
  6. html,
  7. body {
  8.   width: 100%;
  9.   height: 100%;
  10. }
  11.  
  12. body {
  13.   margin: 0px;
  14.   background-color: #ffffff;
  15.   overflow: hidden;
  16.   font-family: arial;
  17. }
  18.  
  19. button#animate {
  20.   z-index: 10;
  21.   position: absolute;
  22. }
  23.  
  24. button#reset {
  25.   z-index: 10;
  26.   position: absolute;
  27.   left: 70px;
  28. }
  29.  
  30. #blocker {
  31.   position: absolute;
  32.   width: 100%;
  33.   height: 100%;
  34.   background-color: rgba(0, 0, 0, 0.5);
  35. }
  36.  
  37. #instructions {
  38.   width: 100%;
  39.   height: 100%;
  40.   display: -webkit-box;
  41.   display: -moz-box;
  42.   display: box;
  43.   -webkit-box-orient: horizontal;
  44.   -moz-box-orient: horizontal;
  45.   box-orient: horizontal;
  46.   -webkit-box-pack: center;
  47.   -moz-box-pack: center;
  48.   box-pack: center;
  49.   -webkit-box-align: center;
  50.   -moz-box-align: center;
  51.   box-align: center;
  52.   color: #ffffff;
  53.   text-align: center;
  54.   cursor: pointer;
  55. }
  56.  
  57. // In index.js
  58. // ... other code snippet
  59.  
  60.  
  61. const planeGeometry = new THREE.PlaneGeometry( 300, 300, 50, 50 );
  62. // ... other code snippet
  63. const plane = new THREE.Mesh( planeGeometry, planeMaterial );
  64. plane.name = 'floor';
  65. plane.receiveShadow = true;
  66.  
  67. // … other code snippet
  68.  
  69. // Add navigation tool
  70. //const navTool = new THREE.OrbitControls(camera);
  71. //navTool.enableDamping = true;
  72. //navTool.dampingFactor = 0.25;
  73. const navTool = new NavigationTool( camera );
  74. navTool.attach( scene );
  75.  
  76. // Find this block and replace the original one with the following
  77. // Start rendering
  78. function render() {
  79.     requestAnimationFrame( render );
  80.  
  81.     navTool.update( scene );
  82.     creeper.animate();
  83.     renderer.render( scene, camera );
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement