Pen Settings



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


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


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.


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.






                // This is necessary for the <canvas> to remain pure. More here:
THREE.ImageUtils.crossOrigin = "";

// Allow the canvas to hit the edges of the screen with no scrollbar = 0; = "hidden";

// Set up the scene, camera, and renderer as global variables.
var scene, camera, renderer;


// Sets up the scene.
function init() {

  // Create the scene and set the scene size.
  scene = new THREE.Scene();
  var WIDTH = window.innerWidth,
      HEIGHT = window.innerHeight;

  // Create a renderer and add it to the DOM.
  renderer = new THREE.WebGLRenderer({antialias:true});
  renderer.setSize(WIDTH, HEIGHT);

  // Create a camera, zoom it out from the model a bit, and add it to the scene.
  camera = new THREE.PerspectiveCamera(45, WIDTH / HEIGHT, 0.1, 20000);
  camera.position.y = 1;
  // Create an event listener that resizes the renderer with the browser window.
  window.addEventListener('resize', function() {
    var WIDTH = window.innerWidth,
        HEIGHT = window.innerHeight;
    renderer.setSize(WIDTH, HEIGHT);
    camera.aspect = WIDTH / HEIGHT;

  // Set the background color of the scene.
  renderer.setClearColorHex(0x333F47, 1);

  // Create some lights and add them to the scene.
  pointLight = new THREE.PointLight( 0x3300aa );
  pointLight.position.x = -100;
  pointLight.position.y = -1;
  pointLight.position.z = -50;
  pointLight.distance = 2000;
  pointLight.intensity = 1.4;
  scene.add( pointLight );

  directionalLight = new THREE.DirectionalLight( 0xffaa00 );
  directionalLight.position.set( 1, 10, 50 ).normalize();
  directionalLight.intensity = 1.4;
  scene.add( directionalLight );

  // Create a material using texture maps
  // Note: These are commercial textures from
  diffuse = THREE.ImageUtils.loadTexture( "" );
  specular = THREE.ImageUtils.loadTexture( "" );
  normal = THREE.ImageUtils.loadTexture( "" );

  var material = new THREE.MeshPhongMaterial({
    map: diffuse,
    specular: 0xffffff,
    specularMap: specular,
    shininess: 10,
    normalMap: normal

  // Load in the mesh and add it to the scene.
  var loader = new THREE.JSONLoader();
    mesh = new THREE.Mesh(geometry, material);


// Renders the scene and updates the render as needed.
function animate() {

  // Read more about requestAnimationFrame at

  // Rotate the camera and lights every update.
  var timer = * 0.00025;
  camera.position.x = Math.cos( timer ) * 2;
  camera.position.z = Math.sin( timer ) * 1;
  directionalLight.position.y = Math.sin( timer ) * 1;
  camera.lookAt( new THREE.Vector3( 0, 0.4, 0 ) );

  // Render the scene.
  renderer.render(scene, camera);