A Pen by Prince

Thumbnail
This awesome code was written by 0x1000, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 0x1000 ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  Prince</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  
  <script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/0x1000/a-pen-by-prince-vJvQQg */
body {
  margin: 0;
}

canvas {
  width: 100%;
  height: 100%;
}

/*Downloaded from https://www.codeseek.co/0x1000/a-pen-by-prince-vJvQQg */
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var geometry = new THREE.BoxGeometry(3, 3, 3);
var material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
var cube = new THREE.Mesh(geometry, material);
scene.add(cube);
camera.position.z = 5;
var r = 0;
window.addEventListener('mousemove', function(event) {
  r = event.clientX;
});
var animate = function() {
  requestAnimationFrame(animate);
  
  cube.rotation.y = r / 100;
  renderer.render(scene, camera);  
}

animate();

Comments