Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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.


Save Automatically?

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.




  overflow: hidden;
  margin: 0;


import * as THREE from "";
import {OrbitControls} from "";

import { Line2 } from '';
import { LineMaterial } from '';
import { LineGeometry } from '';
import { GeometryUtils } from '';

let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 1, 100);
camera.position.set(5, 8, 13);
let renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(innerWidth, innerHeight);

let controls = new OrbitControls(camera, renderer.domElement);

let grid = new THREE.GridHelper(10, 10, 0x303030, 0x202020);

let pts = [];
let clr = [];
let wdth = [];
let counter = 10;
for(let i = 0; i < counter; i++){
    THREE.MathUtils.randFloat(-5, 5),
    THREE.MathUtils.randFloat(-5, 5),
    THREE.MathUtils.randFloat(-5, 5)
  clr.push(Math.random(), Math.random(), Math.random());
  if (i < counter - 1) wdth.push(THREE.MathUtils.randInt(2, 20));
console.log(pts.length, clr.length, wdth.length);

let geometry = new LineGeometry();
geometry.setPositions( pts );
geometry.setColors( clr );
geometry.setAttribute("linewidth", new THREE.InstancedBufferAttribute(new Float32Array(wdth), 1));


let matLine = new LineMaterial( {

  color: 0xffffff,
  //linewidth: 5, // in pixels
  vertexColors: true,
  //resolution:  // to be set by renderer, eventually
  dashed: false,
  alphaToCoverage: true,
  onBeforeCompile: shader => {
    shader.vertexShader = `
    `.replace(`uniform float linewidth;`, `attribute float linewidth;`);

} );

let line = new Line2( geometry, matLine );
line.scale.set( 1, 1, 1 );
scene.add( line );

renderer.setAnimationLoop( _ => {
  matLine.resolution.set( innerWidth, innerHeight );
  renderer.render(scene, camera);