Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
<head>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
</head>
<body>
	<div class="wrap">
		<canvas id="melonsoda"></canvas>
	</div>
</body>
</html>
              
            
!

CSS

              
                body {
 position: relative;
 margin: 0;
 overflow: hidden;
}
.wrap {
 background: #000;
 display:flex;
 align-items: center;
 justify-content: center;
 position: relative;
 height: 100%;
 width: 100%;
 background: linear-gradient(to bottom, #53C46A, #168921);
}
.wrap canvas {
 background: linear-gradient(to bottom, #53C46A, #168921);
 width: 100%;
 height: 100%;
}

              
            
!

JS

              
                window.addEventListener('load', init);
 
const width = window.innerWidth; 
const height = window.innerHeight; 
 
function init() {
  const scene = new THREE.Scene();
 
  const camera = new THREE.PerspectiveCamera(45, width / height);
  camera.position.set(0, 300, 700); 
 
  const canvasElement = document.querySelector('#melonsoda') 
  const renderer = new THREE.WebGLRenderer({
    canvas: canvasElement,
    antialias: true, 
    alpha: true
  });
  renderer.setSize(width, height);
 
  const light = new THREE.AmbientLight(0xFFFFFF, 1.0); 
  light.position.set( 0, 0, 0 );
  scene.add(light);
 
  const x_size = window.innerWidth;
  const y_size = window.innerHeight;
  const length = 500;
  const plane_scale = 6;
  const plane = [];
 
  for(let i=0; i<length; i++){
    let geometry = new THREE.SphereGeometry( plane_scale, plane_scale, plane_scale );
    var material = new THREE.MeshBasicMaterial({
      color: '0xffffff',
      opacity: 0.5,
      transparent: true
    });
 
    plane[i] = new THREE.Mesh( geometry, material );
    plane[i].position.x = x_size * (Math.random() - 0.7);
    plane[i].position.y = y_size * (Math.random() - 0.5);
    plane[i].position.z = x_size * (Math.random() - 0.7);
    scene.add( plane[i] );
  }
  function random(min, max) {
    let rand = Math.floor((min + (max - min + 1) * Math.random()));
    return rand;
  }
  tick();
  function tick() {
    for(let i=0; i<length; i++){
      plane[i].position.x += (random(-5, 5)*0.1);
      plane[i].position.y += 2.5;
      plane[i].position.z += (random(-5, 5)*0.1);
      if (plane[i].position.y > height) {
        plane[i].position.x = x_size * (Math.random() - 0.5);
        plane[i].position.y = 0;
        plane[i].position.z = x_size * (Math.random() - 0.5);
      }
    }
    renderer.render(scene, camera);
    requestAnimationFrame(tick);
  }
  function start() {
    renderer.render(scene, camera);
  }
  start();
}
              
            
!
999px

Console