Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.


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.


                <!DOCTYPE html>
    <title>Basic Three.js App</title>

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




                /*jshint esversion: 6 */

/* first, let's set up the scene, create a camera, and a renderer*/

let scene = new THREE.Scene();
let aspect = 3 / 2;
let camera = new THREE.PerspectiveCamera(75, aspect, 0.1, 1000);
let renderer = new THREE.WebGLRenderer();
renderer.setSize(300, 200);

camera.position.z = 50;

/* next, let's create a cube and give it a material*/

let geometry = new THREE.BoxGeometry(30, 30, 30);
let material = new THREE.MeshLambertMaterial({
    color: "#12c712"

let cube = new THREE.Mesh(geometry, material);

// wireframe
let geo = new THREE.EdgesGeometry( cube.geometry );
let mat = new THREE.LineBasicMaterial( { color: 0x074a07, linewidth: 2 } );
let wireframe = new THREE.LineSegments( geo, mat );
cube.add( wireframe );


/* to see our cube, we'll need a light source */

const color = 0xFFFFFF;
const intensity = 1;
const light = new THREE.AmbientLight(color, intensity);

let deltaZ = 0.5;

/* finally, let's render our scene - read up on requestAnimationFrame()! */

let render = function() {
    cube.rotation.x += 0.01;
    cube.rotation.z += 0.005;

        deltaZ = -deltaZ;

    renderer.render(scene, camera);

cameraOufOfRange = () => {
    return (camera.position.z >= 100 || camera.position.z <= 50);