Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              
            
          
!

CSS

            
              
            
          
!

JS

            
              (function() {
    'use strict';
    
    var camera, scene, renderer,
        container, stats, particle,
        winHalfX, winHalfY,
        height, width, fieldOfView,
        aspectRatio, nearPlane, farPlane,
        body, cameraZ, material,
        i = 0,
        count = 0,
        Tau = Math.PI * 2,
        mouseX = 0,
        mouseY = 0,
        amtX = 50,
        amtY = 50,
        sep = 100,
        spriteOpts = {},
        particles = [],
        cssString = 'margin: 0; overflow: hidden;';

    function onDocumentReady() {
        body = document.body;
        body.style.cssText = cssString;

        container = document.createElement('div');
        body.appendChild(container);

        height = window.innerHeight;
        winHalfY = height / 2;
        width = window.innerWidth;
        winHalfX = width / 2;
        fieldOfView = 75;
        aspectRatio = width / height;
        nearPlane = 1;
        farPlane = 10000;
        cameraZ = 750;

        rendererer(onRendererRenderered);
    }

    // renders the renderer 😎
    function rendererer(complete) {
        //lights (no lights!) camera, action!
        camera = new THREE.PerspectiveCamera(fieldOfView, aspectRatio, nearPlane, farPlane);
        camera.position.z = cameraZ;

        // aaaaaaaaand scene! (No wait, we're not done!)
        // aaaaaaaaand ten more minutes.
        scene = new THREE.Scene();

        //material settings
        spriteOpts = {
            color: 0xffffff,
            program: function(ctx) {
                ctx.beginPath();
                ctx.arc(0, 0, 0.5, 0, Tau, true);
                ctx.fill();
            }
        };

        material = new THREE.SpriteCanvasMaterial(spriteOpts);

        // Stop! particle time!
        for (var ix = 0, lx = amtX; ix < lx; ix++) {

            for (var iy = 0, ly = amtY; iy < ly; iy++) {
                particle = particles[i++] = new THREE.Sprite(material);
                particle.position.x = ix * sep - ((amtX * sep) / 2);
                particle.position.z = iy * sep - ((amtY * sep) / 2);
                scene.add(particle);
            }
        }

        //render the scene
        renderer = new THREE.CanvasRenderer();
        renderer.setClearColor(0xf6780a, 1);
        renderer.setPixelRatio(window.devicePixelRatio);
        renderer.setSize(width, height);

        // append the rendered scene to the container
        container.appendChild(renderer.domElement);
        
        // aaaaaaaaand Scene? (yes, scene!)
        if (complete) {
            complete();
        }
    }

    function onRendererRenderered() {
        // stats stats stats stats stats stats stats, eeeeerrryyybooodddaay! - Lil Jon, probably.
        stats = new Stats();
        stats.domElement.style.position = 'absolute';
        stats.domElement.style.top = stats.domElement.style.right = '0';
        container.appendChild(stats.domElement);

        // bind events
        document.addEventListener('mousemove', onDocumentMouseMove);
        document.addEventListener('touchstart', onDocumentTouchStart);
        document.addEventListener('touchmove', onDocumentTouchMove);
        window.addEventListener('resize', onWindowResize);

    }

    function onDocumentMouseMove(e) {
        mouseX = e.clientX - winHalfX;
        mouseY = e.clientY - winHalfY;
    }

    function onDocumentTouchStart(e) {
        if (e.touches.length === 1) {
            e.preventDefault();
            mouseX = e.touches[0].pageX - winHalfX;
            mouseY = e.touches[0].pageY - winHalfY;
        }
    }

    function onDocumentTouchMove(e) {
        if (e.touches.length === 1) {
            e.preventDefault();
            mouseX = e.touches[0].pageX - winHalfX;
            mouseY = e.touches[0].pageY - winHalfY;
        }
    }

    function onWindowResize() {
        // update variables to new values
        height = window.innerHeight;
        winHalfY = height / 2;
        width = window.innerWidth;
        winHalfX = width / 2;

        camera.aspect = width / height;
        camera.updateProjectionMatrix();
        renderer.setSize(width, height);
    }

    function animate() {
        requestAnimationFrame(animate);

        update();
        stats.update();
    }

    function update() {
        camera.position.x += (mouseX - camera.position.x) * 0.05;
        camera.position.y += (mouseY - camera.position.y) * 0.05;
        camera.lookAt(scene.position);
        
        i = 0;
        for (var ix = 0, lx = amtX; ix < lx; ix++) {

            for (var iy = 0, ly = amtY; iy < ly; iy++) {
                particle = particles[i++];
                particle.position.y = (Math.sin((ix + count) * 0.3) * 50) + (Math.sin((iy + count) * 0.5) * 50);
                particle.scale.x = particle.scale.y = (Math.sin((ix + count) * 0.3) + 1) * 4 + (Math.sin((iy + count) * 0.5) + 1) * 4;
                scene.add(particle);
            }
        }

        renderer.render(scene, camera);
        count += 0.1;
    }

    document.addEventListener('DOMContentLoaded', onDocumentReady);
    document.addEventListener('DOMContentLoaded', animate);

})();
            
          
!
999px

Console