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.


<!doctype html>
    <title>Sibling picket fence</title>
      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;

  <h1>Sibling picket fence</h1>
  <p>Demonstrates the use of clone() and relative transformations for sibling objects</p>






                function makeFence(scene, params) {
  /* Makes a fence, with the left end at the origin and proceeding down
    the x axis. The pickets are made from barn objects, scaled to be unit
    height (at the shoulder) and very thin. */

  var fence = new THREE.Object3D();
  var picket = TW.createBarnSolidColor(0.1, 1, 0.01, "brown");
  var yAxis = new THREE.Vector3(0,1,0);
  for (var i = 0; i < params.numPickets; i++) {
    var picket = picket.clone();
    picket.rotateOnAxis(yAxis, params.yRotation);
  return fence;

sceneParams = {
  numPickets: 30,
  xOffset: 0.11,
  yRotation: (-2 * Math.PI) / 30

var scene = new THREE.Scene();
var fence = makeFence(scene, sceneParams);
var renderer = new THREE.WebGLRenderer();
TW.mainInit(renderer, scene);
var state = TW.cameraSetup(renderer, scene, {
  minx: -1,
  maxx: 2,
  miny: 0,
  maxy: 1,
  minz: -1,
  maxz: 1

function redraw() {
  fence = makeFence(scene, sceneParams);

var gui = new dat.GUI();
gui.add(sceneParams, "numPickets", 1, 50).onChange(redraw);
gui.add(sceneParams, "xOffset", 0, 0.3).onChange(redraw);
gui.add(sceneParams, "yRotation", -1, 1).onChange(redraw);