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>Library on a Plane</h1>

<p>This demo shows a texture-mapping of the following image onto a
simple <code>THREE.PlaneGeometry</code>.</p>

<img src="">


                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;



                var planeGeom, planeTex, planeMat, planeMesh;
var imageLoaded = false;
var loader = new THREE.TextureLoader();

function updateTextureParams(quad, sMin, sMax, tMin, tMax) {
    var elt = quad.faceVertexUvs[0]; // dunno why they have this 1-elt array
    var face0 = elt[0];
    face0[0] = new THREE.Vector2(sMin,tMax);
    face0[1] = new THREE.Vector2(sMin,tMin);
    face0[2] = new THREE.Vector2(sMax,tMax);
    var face1 = elt[1];
    face1[0] = new THREE.Vector2(sMin,tMin);
    face1[1] = new THREE.Vector2(sMax,tMin); //(sMax,tMin);
    face1[2] = new THREE.Vector2(sMax,tMax);
    quad.uvsNeedUpdate = true;

function loadPlaneImage() {
                function (texture) {
                    console.log("image is loaded");
                    imageLoaded = true;
                    // these should be local, but we use globals
                    // so that students can poke around
                    planeGeom = new THREE.PlaneGeometry( 4, 4);
                    updateTextureParams(planeGeom, 0, 1, 0, 1);
                    planeMat = new THREE.MeshBasicMaterial( {color: THREE.ColorKeywords.white,
                                                             map: texture});
                    planeMesh = new THREE.Mesh( planeGeom, planeMat );

var scene = new THREE.Scene();

var renderer = new THREE.WebGLRenderer();


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