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>Inconsistent triangle interpolation on a square</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: 400px;
          display: block;
          margin: 10px auto;

  <h1>Inconsistent triangle interpolation on a square</h1>
  <p>Demo of two RGB triangles arranged as a square automatically interpolated by WebGL, but with different colors assigned to the same vertex on the two triangles.






                var scene = new THREE.Scene();

var vertexA = new THREE.Vector3(0, 0, 0);
var colorA = new THREE.Color( );

var vertexB = new THREE.Vector3(1, 0, 0);
var colorB = new THREE.Color( THREE.ColorKeywords.lime );

// same position as B but a different color
var vertexB2 = new THREE.Vector3(1, 0, 0); 
var colorB2 = new THREE.Color( );

var vertexC = new THREE.Vector3(0, 1, 0);
var colorC = new THREE.Color( );

// same position as C but a different color
var vertexC2 = new THREE.Vector3(0, 1, 0); 
var colorC2 = new THREE.Color( THREE.ColorKeywords.lime );

var vertexD = new THREE.Vector3(1, 1, 0 );
var colorD = new THREE.Color( );

var triGeom = new THREE.Geometry();
triGeom.vertices = [ vertexA, vertexB, vertexC, vertexD, vertexB2, vertexC2 ];
triGeom.faces = [ new THREE.Face3(0, 1, 2),
                  new THREE.Face3(3, 5, 4)
triGeom.vertexColors = [ colorA, colorB, colorC, colorD, colorB2, colorC2 ];

// set particular vertex colors for each face

// create a material that uses the vertex colors to compute face color
var material = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } );

var mesh = new THREE.Mesh( triGeom, material );


// ================================================================
var renderer = new THREE.WebGLRenderer();


               {minx: 0, maxx: 1,
                miny: 0, maxy: 1,
                minz: 0, maxz: 0});