Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

canvas {
  display: block;
  background-color: #000000;
}
              
            
!

JS

              
                var scene = new THREE.Scene();
scene.updateMatrixWorld( true );
var camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.z = 150;

var renderer = new THREE.WebGLRenderer( { alpha: true, antialias: true } );
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.setPixelRatio( window.devicePixelRatio || 1 );
renderer.setSize( window.innerWidth, window.innerHeight);
document.body.appendChild( renderer.domElement );

var pointLight = new THREE.PointLight( 0xffffff, 1, 0, 2 );
pointLight.castShadow = true;
pointLight.shadow.radius = 8;
pointLight.shadow.bias = 0.0001;
pointLight.shadow.normalBias = 5;
scene.add( pointLight );

//Set up shadow properties for the light
pointLight.shadow.mapSize.width = 2048;
pointLight.shadow.mapSize.height = 2048;
pointLight.shadow.camera.near = 0.5;
pointLight.shadow.camera.far = 500;

var pointLightHelper = new THREE.PointLightHelper( pointLight, 1 );
scene.add( pointLightHelper );

var light = new THREE.AmbientLight( 0x404040, .25 ); // soft white light
scene.add( light );

var geometry = new THREE.SphereGeometry( 15, 32, 32 );
var material = new THREE.MeshPhysicalMaterial( { color: 0xffffff } );
var sphere1 = new THREE.Mesh( geometry, material );
sphere1.receiveShadow = true;
sphere1.castShadow = false;
scene.add( sphere1 );

var sphere2 = new THREE.Mesh( geometry, material );
sphere2.position.x = 50;
sphere2.receiveShadow = true;
sphere2.castShadow = true;
scene.add( sphere2 );

var sphere3 = new THREE.Mesh( geometry, material );
sphere3.receiveShadow = true;
sphere3.castShadow = true;
sphere3.position.x = -50;
scene.add( sphere3 );

var sphere4 = new THREE.Mesh( geometry, material );
sphere4.receiveShadow = true;
sphere4.castShadow = true;
sphere4.position.x = 100;
scene.add( sphere4 );

var sphere5 = new THREE.Mesh( geometry, material );
sphere5.receiveShadow = true;
sphere5.castShadow = true;
sphere5.position.x = -100;
scene.add( sphere5 );

var angle = 0;
var radius = 75;

var onWindowResize = function () {
  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();

  renderer.setSize( window.innerWidth, window.innerHeight );
}

window.addEventListener( 'resize', onWindowResize, false );

var animate = function () {
  requestAnimationFrame( animate );
  
  // update stuff
  angle += .01;
  if (angle === 360) {
    angle = 0;
  }
  
  pointLight.position.x = radius * Math.cos(angle);
  pointLight.position.y = radius * Math.cos(angle);
  pointLight.position.z = radius * Math.sin(angle);

  renderer.setRenderTarget( null );
  renderer.render( scene, camera );
};

animate();
              
            
!
999px

Console