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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

                       <script id="fragmentShader" type="x-shader/x-fragment">
            precision mediump float;

            uniform float time;
            uniform float mouseX;
            uniform float mouseY;
            uniform sampler2D texture;
            varying vec2 vUv;

            void main() {
    float d = -distance(vec2(mouseX,mouseY), gl_FragCoord.xy);
    float r = dot(gl_FragCoord.xy, vec2(0.005,0.005))/d;
    vec2 tex = vec2(vUv.x + r, vUv.y + r);
  	gl_FragColor = vec4(texture2D(texture, tex).rgb, 1.0);


        <script id="vertexShader" type="x-shader/x-vertex">
            precision mediump float;
            varying vec2 vUv;
            uniform float time;
           void main() {
                vUv  = uv;
                gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
        <div class="stage"></div>
        <canvas class="noise-canvas"></canvas>
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	width: 100%;
	height: 100%; 
	opacity: 0.3;
    z-index: 2;
              'use strict'


const APP_CONFIG = {
	debug: false,
	gridDebugSize: {
		x: 10,
		y: 10
	fontSize: 600,
	axisHelperSize: 10

class App {

		_.bindAll(this, 'animate', 'onResize', 'onMouseMove');

		this.time = 0;

		this.planeHeight = 50;
		this.ratio = window.innerWidth / window.innerHeight;
		this.planeWidth = this.planeHeight*this.ratio;
		this.cameraOpts = {
			aspect: window.innerWidth / window.innerHeight,
			near: 0.1,
			far : 10000,
			z: this.planeHeight

		let fov = 2 * Math.atan( this.planeHeight / ( 2 * this.cameraOpts.z ) ) * ( 180 / Math.PI ); = new THREE.PerspectiveCamera(fov, this.cameraOpts.aspect, this.cameraOpts.near, this.cameraOpts.far); = this.cameraOpts.z;

		this.stage = new THREE.Scene();

		this.renderer = new THREE.WebGLRenderer({ antialias: true});
		this.renderer.setSize(window.innerWidth, window.innerHeight);




		if (APP_CONFIG.debug){

		let texture = new THREE.Texture(this.createCanvas("Interactive Art Director")); 
		texture.needsUpdate = true;

		let planeGeometry = new THREE.PlaneGeometry(this.planeWidth, this.planeHeight, 0, 0);
		this.uniforms = {
			texture: { 
				type: 't',
				value: texture 
			time: {
				type: "f",
				value: this.time
			mouseX: {
				type: "f",
				value: 0
			mouseY: {
				type: "f",
				value: 0
		var vertShader = document.getElementById('vertexShader').innerHTML;
    var fragShader = document.getElementById('fragmentShader').innerHTML;

		let planeMaterial = new THREE.ShaderMaterial({ 
			uniforms: this.uniforms,
	        vertexShader: vertShader,
        	fragmentShader: fragShader,
        	wireframe : false,
            wireframeLinewidth : 2,
            transparent : true

		this.plane = new THREE.Mesh(planeGeometry, planeMaterial);

		let container = document.querySelector('.stage');
		TweenMax.ticker.addEventListener('tick', this.animate);



  		this.canvas = document.createElement( 'canvas' );
		this.canvas.height = 4096;
		this.canvas.width = this.canvas.height*this.ratio;
		let context = this.canvas.getContext( '2d' );
    context.rect(0, 0, this.canvas.width, this.canvas.height);
    context.fillStyle = '#202020';
		context.font = 'Bold '+ APP_CONFIG.fontSize +'px Avenir';
		context.fillStyle = '#262626';
		let width = context.measureText(text).width;
		context.fillText(text, this.canvas.width/2 - width/2, this.canvas.height/2);

		return this.canvas;


		let gridHelper = new THREE.GridHelper( APP_CONFIG.gridDebugSize.x, APP_CONFIG.gridDebugSize.y );
		this.stage.add( gridHelper );
		let axisHelper = new THREE.AxisHelper( APP_CONFIG.axisHelperSize );
		this.stage.add( axisHelper );

		let lazyLayout = _.debounce(this.onResize, 300);
		window.addEventListener('resize', lazyLayout);
		window.addEventListener('mousemove', this.onMouseMove);

		this.renderer.setSize(window.innerWidth, window.innerHeight);;

		this.mousePos = {
			x: e.clientX,
			y: e.clientY

			this.uniforms.mouseX.value = this.mousePos.x;
			this.uniforms.mouseY.value = window.innerHeight - this.mousePos.y;

		this.uniforms.time.value +=  0.1;


new App();
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.