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>
      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;

  <p>Seven colored star</p>






                // We always need a scene

var scene = new THREE.Scene();

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

// function to create a Geometry for a three-pointed star with four triangular faces
// size is the radius of the circle that circumscribes the star

var size = 50;

function starGeometry (size) {
  var starGeom = new THREE.Geometry();
  var angle;
  var lens = [size, size/4];
  for (var i = 0; i < 6; i++) {
     angle = i*(Math.PI/3);
     len = lens[i % 2];
     starGeom.vertices.push(new THREE.Vector3(len*Math.cos(angle), len*Math.sin(angle)));
  starGeom.faces.push(new THREE.Face3(0,1,5));
  starGeom.faces.push(new THREE.Face3(1,2,3));
  starGeom.faces.push(new THREE.Face3(3,4,5));
  starGeom.faces.push(new THREE.Face3(1,3,5));
  return starGeom;

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

// vector of colors to use for the 6 vertices of the star geometry

var colors = [new THREE.Color("red"), new THREE.Color("orange"), new THREE.Color("yellow"), 
              new THREE.Color("green"), new THREE.Color("blue"), new THREE.Color("violet")];

// create a star using color interpolation of the triangular faces

var starGeom = starGeometry(size);      // create the initial geometry

starGeom.vertexColors = colors;         // setup vertex colors

TW.computeFaceColors(starGeom);         // setup vertex colors for each face

// create material that uses vertex colors and is double-sided
var starMaterial = new THREE.MeshBasicMaterial( {vertexColors: THREE.VertexColors,
                                                 side: THREE.DoubleSide} );

// create mesh and add to scene
var starMesh = new THREE.Mesh(starGeom, starMaterial);

// add six more stars of solid color, surrounding the central star

var x, y, angle;

for (i = 0; i < 6; i++) {
   angle = i*(Math.PI/3);
   x = 1.5*size*Math.cos(angle);
   y = 1.5*size*Math.sin(angle);
   starGeom = starGeometry(size);
   starMaterial = new THREE.MeshBasicMaterial( {color: colors[i],
                                                side: THREE.DoubleSide} );
   starMesh = new THREE.Mesh(starGeom, starMaterial);

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

var renderer = new THREE.WebGLRenderer();


               {minx: -2*size, maxx: 2*size,
                miny: -2*size, maxy: 2*size,
                minz: 5, maxz: 5});