Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <!doctype html>
<html>

<head>
  <title>Simple camera using TW</title>
  <style>
    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: 800px;
      height: 500px;
      display: block;
      margin: 10px auto;
    }
  </style>
</head>

<body>

  <h1>Simple camera using TW</h1>

  <div id="canvasParent"></div>

  <div id="footer">
    <p>&copy; Scott D. Anderson.
      This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/1.0/">Creative
        Commons License</a>
  </div>

</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

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

// ====================================================================
// Camera setup. See last line of example as well

var camera = new THREE.PerspectiveCamera(
  45, // fovy in degrees
  800 / 500, // aspect ratio: our canvas is 800/500 pixels
  1, // near
  100 // far
);

camera.position.set(10, 5, 30); // so that the barn is roughly centered
camera.up.set(0, 1, 0); // this is actually the default

// this location is roughly in the center of the front of the barn
var barnFront = new THREE.Vector3(10, 5, 0);

camera.lookAt(barnFront);

// This will render the current scene using the current camera
// Invoked at the end of this code.
function render() {
  renderer.render(scene, camera);
}

// ====================================================================

/* Next, we create objects in our scene. Here, one wire barn. */

var wirebarn = TW.createWireBarn(20, 10, 40);
scene.add(wirebarn);

// ================================================================
// Gotta do this! Render the scene using the current camera.

render();

              
            
!
999px

Console