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>Relaxing floral scene with three different pictures</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;



                // create a scene
var scene = new THREE.Scene();

// displayPanels() displays three panels with different texture-mapped images
// of floral scenes - the input is an array of THREE.Texture objects

function displayPanels (textures) {
    // plane geometry with texture-mapped floral image for central panel
    var planeGeom = new THREE.PlaneGeometry(10,10);
    var planeMat = new THREE.MeshBasicMaterial( {color: 0xffffff,
                                                 map: textures[0]} );
    var planeMesh = new THREE.Mesh(planeGeom, planeMat);

    // map the second image onto the right panel
    var planeGeomR = new THREE.PlaneGeometry(10,10);
    var planeMatR = new THREE.MeshBasicMaterial( {color: 0xffffff,
                                              map: textures[1]} );
    var planeMeshR = new THREE.Mesh(planeGeomR, planeMatR);
    var dist = 5*Math.cos(Math.PI/4);
    planeMeshR.position.set(5+dist, 0, dist);
    planeMeshR.rotation.y = -Math.PI/4;

    // map the third image onto the left panel
    var planeGeomL = new THREE.PlaneGeometry(10,10);
    var planeMatL = new THREE.MeshBasicMaterial( {color: 0xffffff,
                                              map: textures[2]} );
    var planeMeshL = new THREE.Mesh(planeGeomR, planeMatL);
    planeMeshL.position.set(-5-dist, 0, dist);
    planeMeshL.rotation.y = Math.PI/4;

    TW.render();    // render the scene

var renderer = new THREE.WebGLRenderer();


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

// using the TW.loadTextures() function, load three images (stored in the same
// folder as this webpage), and when all of the images are loaded, invoke the
// anonymous function callback with an input array of THREE.Texture objects

TW.loadTextures(["", "", ""],
            function (textures) {
            } );