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.


                <script async src="[email protected]/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="importmap">
    "imports": {
      "three": "[email protected]/build/three.module.js",
      "three/addons/": "[email protected]/examples/jsm/"


                body {
  overflow: hidden;
  margin: 0;




import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";

// general setup, boring, skip to the next comment

var scene = new THREE.Scene();
    scene.background = new THREE.Color( 'lightgray' );

var camera = new THREE.PerspectiveCamera( 30, innerWidth/innerHeight );
    camera.position.set( 3, 3, 15 );
    camera.lookAt( scene.position );

var renderer = new THREE.WebGLRenderer( {antialias: true} );
    renderer.setSize( innerWidth, innerHeight );
    renderer.setAnimationLoop( animationLoop );
    document.body.appendChild( renderer.domElement );
window.addEventListener( "resize", (event) => {
    camera.aspect = innerWidth/innerHeight;
    camera.updateProjectionMatrix( );
    renderer.setSize( innerWidth, innerHeight );

var controls = new OrbitControls( camera, renderer.domElement );
    controls.enableDamping = true;

var ambientLight = new THREE.AmbientLight( 'white', 0.3 );
    scene.add( ambientLight );

// next comment

// setting up a spot light

var spotLight = new THREE.SpotLight( 'yellow', 1 );
		spotLight.position.y = 3;
		spotLight.angle = 0.1;
		spotLight.penumbra = 1;
    scene.add( spotLight );

// and its helper

var spotLightHelper = new THREE.SpotLightHelper( spotLight );
		scene.add( spotLightHelper );

// a floor to show the light spot of the spot light

var floor = new THREE.Mesh(
			new THREE.BoxGeometry( 3, 0.1, 3 ),
    	new THREE.MeshPhongMaterial( {color:'white', reflectivity:1} )
		floor.position.y = -0.05;
		scene.add( floor );

function animationLoop( t )
		// change spot light angle
		spotLight.angle = 0.3+0.295*Math.sin( t/1000 );
		// update helper
		spotLightHelper.update( );
    controls.update( );
    renderer.render( scene, camera );