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.


                <h1>Mikey cube</h1>



                body {
  max-width: 100%;
/* feel free to style the canvas any way you want. If you want it to
      use the entire window, set width: 100% and height: 100%. */

canvas {
  width: 80%;
  height: 500px;
  display: block;
  margin: 10px auto;



                /* Kelsey Reiman
   Summer 2014 
   Creates a cube with a different texture on each face.

   Modified by Scott to use the newer texture loader, Fall 2016

var scene = new THREE.Scene();
var renderer = new THREE.WebGLRenderer();


var state = TW.cameraSetup(renderer,
                           {minx: -1, maxx: 1,
                            miny: -1, maxy: 1,
                            minz: -1, maxz: 1});

var modifyFront = false;

var mikeyCube; 

function makeMikeyCube() {
        [ '',
          '' ],
        function (textures) {
            // create an array of materials from these textures
            var mats = [];
            for( var i=0; i < textures.length; i++ ) {
                textures[i].wrapS = THREE.RepeatWrapping;
                textures[i].wrapT = THREE.RepeatWrapping;
                mats.push(new THREE.MeshBasicMaterial( {map: textures[i]} ));
            // create a cube using MeshFaceMaterial, one material for each face
            var cube = new THREE.Mesh( new THREE.BoxGeometry(2,2,2),
                                       new THREE.MeshFaceMaterial( mats ) );
            if(modifyFront) doModifyFront(cube);
            mikeyCube = cube;


function doModifyFront(cube) {
    var geom = cube.geometry;
    var faces = geom.faces;
    var UVs = geom.faceVertexUvs[0];
    for( var i = 0; i < faces.length; i++ ) {
        var face = faces[i];
        // modify the (s,t) parameters to give 2x3 pattern on front face (4)
        if( face.materialIndex == 4 ) {
            var faceUV = UVs[i];
            // for all three vertices
            for( j = 0; j < 3; j++ ) {
                var UV = faceUV[j];
                UV.x = 2*UV.x;
                UV.y = 3*UV.y;
    document.getElementById('info').innerHTML = 

TW.setKeyboardCallback('p',function () { modifyFront = !modifyFront;
                                         makeMikeyCube(); },
                       "pattern on front of cube");