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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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






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

let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 1, 1000);
camera.position.set(0, 130, 50);
let renderer = new THREE.WebGLRenderer({
  antialias: true
renderer.setSize(innerWidth, innerHeight);

let controls = new OrbitControls(camera, renderer.domElement);
let light = new THREE.DirectionalLight(0xffffff, 1);
  new THREE.AmbientLight(0xffffff, 0.5)

var wallShape = new THREE.Shape([
  new THREE.Vector2(-52,50),
  new THREE.Vector2(-52,-52),
  new THREE.Vector2(52,-52),
  new THREE.Vector2(52,52),
  new THREE.Vector2(-52,52),
  new THREE.Vector2(-52,50),
  new THREE.Vector2(50,50),
  new THREE.Vector2(50,-50),
  new THREE.Vector2(-50,-50),
  new THREE.Vector2(-50,50),
  new THREE.Vector2(-52,50),
var wall_geometry = new THREE.ExtrudeGeometry( wallShape, {depth: 40, bevelEnabled: false} );
var  wall_material = new THREE.MeshBasicMaterial({color: 0x909698, transparent:true, opacity:0.5, side: THREE.DoubleSide});
var wall = new THREE.Mesh(wall_geometry, wall_material);
wall.rotation.x = -Math.PI/2;

let uniforms = {
  selection: {value: new THREE.Vector3(1,1,1)},
  u_color: { value: new THREE.Color("#122222") },
  u_tcolor: { value: new THREE.Color("#ff2222") },
  u_r: { value: 0.25 },
  u_length: { value: 2 },
  u_max: { value: 100 }

let m = new THREE.MeshLambertMaterial({
  color: 0xffff64,
  side: THREE.DoubleSide,
  transparent: true, // set transparency
  onBeforeCompile: shader => {
    shader.uniforms.selection = uniforms.selection;
    shader.uniforms.u_color = uniforms.u_color
    shader.uniforms.u_tcolor = uniforms.u_tcolor
    shader.uniforms.u_r = uniforms.u_r
    shader.uniforms.u_length = uniforms.u_length
    shader.uniforms.u_max = uniforms.u_max
    shader.vertexShader = `
        varying vec3 vPos;
        `#include <begin_vertex>`,
      `#include <begin_vertex>
        vPos = transformed;
    shader.fragmentShader = `
        #define ss(a, b, c) smoothstep(a, b, c)
        uniform vec3 selection;
        uniform vec3 u_color;
        uniform vec3 u_tcolor;
        uniform float u_r;
        uniform float u_length;
        uniform float u_max;
        varying vec3 vPos;
        `#include <dithering_fragment>`,
      `#include <dithering_fragment>
        float uOpacity = 0.; //background_opacity:1
        vec3 vColor = u_color; //background_color:black
        float uLength = sqrt((vPos.x-0.0)*(vPos.x-0.0)+(vPos.y+0.0)*(vPos.y+0.0))/0.75;

        if ( uLength <= u_r && uLength > u_r - u_length ) { 
            uOpacity = 1.; //ring_opacity:1
            vColor = u_tcolor; //ring_color:black
        gl_FragColor = vec4(vColor,uOpacity);

let g = new THREE.PlaneGeometry(100,100);
let o = new THREE.Mesh(g, m);
o.rotation.x = -Math.PI/2;
o.position.y = 2

window.addEventListener("resize", onResize);

let clock = new THREE.Clock();

renderer.setAnimationLoop(_ => {
  let t = clock.getDelta();

   uniforms.u_r.value += t * 10;
  if (uniforms.u_r.value >= 10) {
     uniforms.u_r.value = 1
  renderer.render(scene, camera);

function onResize(event) {
  camera.aspect = innerWidth / innerHeight;
  renderer.setSize(innerWidth, innerHeight);