Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                
              
            
!

CSS

              
                html, body, canvas
    margin 0
    padding 0
    width 100vw
    height 100vh
    overflow hidden
    background #1B2B34
    background radial-gradient(ellipse at center, #001B36 0%, #000 100%)
    position absolute
    top 0
    left 0

div
    z-index 100
    
div:last-child
    top 48px !important
        
canvas
    z-index 10
              
            
!

JS

              
                import Stats from "https://cdn.skypack.dev/stats.js@0.17.0";
imageSrc = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAABhjSURBVHja7F1ZkxxVdv5uVnW3ekMSYpMYEDuIRYBg2PdBbGNgZiLG4Qc77LAf/OgnR/gX+NHhVz95wuMIR8xEDDYDDAwggZAAsQzDIhASCBBa0AKSutWtXqrq+rsns7qqqzPvvZm1KAsyK7KrKiurOu893znnO+eee1NprVFsP9wtKLqgAECxFQAotgIAxVYAoNgKABTbD2wrO8/4x6KT+nL7j8ICFFsBgGIrAFBsBQCKrQBA3jbVP1FAfhqqv2eCVXloc/k0doJK2Wi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QiUzY3qE6BQCA9lbcbme4VcOvrCvtjaNsORM4+iY3AMgy3Vmn7Kw0713XkbbgMim8jSvm8L3Tuc+d1PrihhFJGqY9hJ9u/N0tdJ0hwZK2HDtpDWTbaJ5vm9LmL04LAGxxvu+dQ3yKIG0C9r29ik4JWh9wuvoBKcDtc+19wwFsHePqfB8QpHnO0nFx1ivt4IzOYAV8rzvXBSG+Qrdpv48G+Hac7kBbsrQr7jU60M6+CAPTzmXz/ayd16ejXS6Cm4f2dTQT6HvDKN/OczVYpzi3W21M0xYf8Pf9HUOSOqidJEwWroDT1K4sYNBtHMttIigpF5AFDLoNcHQzweXTriyWrqdg6MbNo5M6pxOkLMtn3QZ4N9rbs7aWu6QdtgtWbXbA6RK8j8Bt16Ty2NZyDzum21YAOQBDp9vd97eNs22qTwTcDaGpvLS1nPOO+r5uuWl7gGL7QW8FAAoAFFsBgGIrAFBsP8xNaa2LXigsQLEVACi2AgDFVgCg2AoAFFsBgGIrAFBsBQCKrQBAsRUAKLbv9fb/AgwANvVvEBK8IxUAAAAASUVORK5CYII=`

let renderer
    , controls
    , scene
    , camera
let w, h
    , statsFps
    , statsMs
    , radius = .2
    , material
    , uniforms

resize()
init()
animate()

function rand(min, max) {
    return Math.random() * (max - min) + min
}

function resize() {
    w = document.body.clientWidth
    h = document.body.clientHeight
    if (!camera) {
        return
    }
    
    uniforms.scale.value = h * .5
    camera.aspect = w / h
    camera.updateProjectionMatrix()
    renderer.setSize(w, h)
}

function init() {
    
    scene = new THREE.Scene()

    camera = new THREE.PerspectiveCamera(75, w / h, 1, 6000)
    camera.position.z = 25
    
    renderer = new THREE.WebGLRenderer({alpha: true})
    renderer.setSize(w, h)
    renderer.setClearColor("#0C7CA5", 0)
    renderer.setPixelRatio(window.devicePixelRatio)
    renderer.sortObjects = false
    renderer.autoClear = false
    renderer.generateMipmaps = false
    
    let light = new THREE.HemisphereLight('#fff', '#eee', 50)
    light.position.set(0, 0, 300)
    light.castShadow = true
    scene.add(light)

    light = new THREE.PointLight(0x222222, 3)
    light.position.x = 1000
    light.position.y = 500
    light.position.z = 1000
    light.castShadow = true
    scene.add(light)
    
    const pointsGeometry = makeLine()
    
    material = new THREE.PointsMaterial({
        size: radius,
        // color: 0xff00ff,
        map:  new THREE.TextureLoader().load(imageSrc),
        blending: THREE.AdditiveBlending,
        depthWrite: false,
        transparent: true
    })
    
    const shaderPoint = THREE.ShaderLib.points
    uniforms = THREE.UniformsUtils.clone(shaderPoint.uniforms)

    const image = new Image()
    uniforms.map.value = new THREE.Texture(image)
    image.onload = function() {
        uniforms.map.value.needsUpdate = true
    };
    image.src = imageSrc
    uniforms.size.value = radius
    uniforms.scale.value = h * .5
    
    material = new THREE.ShaderMaterial({
        uniforms: uniforms,
        defines: {
            USE_MAP: "",
            USE_SIZEATTENUATION: ""
        },
        transparent: true,
        // alphaTest: .4,
        depthWrite: false,
        // depthTest: false,
        blending: THREE.AdditiveBlending,        
        vertexShader: shaderPoint.vertexShader,
        fragmentShader: shaderPoint.fragmentShader
    })
    
    const points = new THREE.Points(pointsGeometry, material)
    scene.add(points)
    
    camera.lookAt(scene.position)
    
    controls = new THREE.OrbitControls(camera, renderer.domElement);
    
    document.body.appendChild(renderer.domElement)
        
    statsFps = new Stats()
    document.body.appendChild(statsFps.dom)
    
    statsMs = new Stats()
    statsMs.showPanel(1)
    document.body.appendChild(statsMs.dom)
    
    window.addEventListener('resize', resize, false)
    
    renderer.domElement.addEventListener('dblclick', () => {
        material.size = rand(.1, 1)
        material.needsUpdate = true
    }, false)
    
}

let t = 0
function animate() {
    
    requestAnimationFrame(animate)
    
    renderer.clear()
    renderer.render(scene, camera)
    

    // if (!(t++ % 500)) {
    //     material.size = rand(.1, 1)
    //     material.needsUpdate = true
    // }
    
    controls.update()
    statsFps.update()
    statsMs.update()
    
}

function getPoints(start, end, size) {
    const vec3 = start.clone()
    const res = []
    for(let i = 0; i < size; i++) {
        vec3.set(start.x, start.y, start.z)
        vec3.lerp(end, i/size)
        res.push(vec3.x, vec3.y, vec3.z)
    }
    return res
}

function getPositions(points, count, alpha) {
    let positions = []
    if (!points)
        return positions
    
    let l = count
    let index = 0
    const vec3s = new THREE.Vector3()
    const vec3e = vec3s.clone()
    const vec3n = vec3s.clone()
    let dist, size, i, items
    while(l--) {
        vec3s.set(points.getX(l), points.getY(l), points.getZ(l))
        vec3n.set(vec3s.x, vec3s.y, vec3s.z)
        if (l < 1) {
            positions.push(vec3n.x, vec3n.y, vec3n.z)
            break;
        }
        vec3e.set(points.getX(l - 1), points.getY(l - 1), points.getZ(l - 1));

        dist = vec3n.distanceTo(vec3e);
        size = dist * alpha | 0
        
        items = getPoints(vec3s, vec3e)
        
        positions.push.apply(positions, items)
    }
    
    return positions
}

function sortFunction(a, b) {
    return a - b;
}

function genWireframe(geometry, alpha) {
    var vertices = geometry.vertices;
    var faces = geometry.faces;
    var numEdges = 0;
    var l, i, j;

    var edge = [0, 0], hash = {};
    var keys = [ 'a', 'b', 'c' ];

    // allocate maximal size
    var edges = new Uint32Array(6 * faces.length);

    for (i = 0, l = faces.length; i < l; i++) {

        var face = faces[i];

        for (j = 0; j < 3; j++) {

            edge[0] = face[keys[j]];
            edge[1] = face[keys[( j + 1 ) % 3]];
            edge.sort(sortFunction);

            var key = edge.toString();

            if (hash[key] === undefined) {

                edges[2 * numEdges] = edge[0];
                edges[2 * numEdges + 1] = edge[1];
                hash[key] = true;
                numEdges++;

            }
        }
    }

    const coords = []
    let vec3s
        , vec3e
        , dist
        , items
        , size
        ;

    for (i = 0, l = numEdges; i < l; i++) {
        vec3s = vertices[edges [2 * i]]
        vec3e = vertices[edges [2 * i + 1]]
        
        dist = vec3s.distanceTo(vec3e)
        size = dist * alpha | 0

        items = getPoints(vec3s, vec3e, size)

        coords.push.apply(coords, items);
    }

    return coords;
}

function makeLine() {
    
    let geometry = new THREE.IcosahedronGeometry(20, 4)    
        
    const pos = genWireframe(geometry, 10/radius)
    
    geometry = new THREE.BufferGeometry()
    geometry.addAttribute("position", new THREE.BufferAttribute(new Float32Array(pos), 3))
    return geometry
}
              
            
!
999px

Console