npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

css-to-webgl

v0.1.86

Published

``` import CssToWebgl from 'css-to-webgl';

Downloads

2

Readme

NOTE: This is just for fun. Do not use in production.

import CssToWebgl from 'css-to-webgl';

const testBoxGeo = new THREE.BoxBufferGeometry(50, 50, 50);
const testBoxMat = new THREE.MeshBasicMaterial({ color: 'red' });
const testBoxMesh = new THREE.Mesh(testBoxGeo, testBoxMat);
testBoxMesh.position.z = -50;

const cssToWebgl = new CssToWebgl({
    THREE, // pass inn THREE.js
    shaders: {
        testFs,
    },
    meshes: {
        testBox: testBoxMesh,
    },
    bufferTextures: {
        brain: bufferTexture.texture,
    },
    renderer, // same renderer as used by bufferTexture
    onRender: (delta, elapsed) => {
        testBoxMesh.rotation.set(
            (Math.PI * 0.1 + elapsed) % (Math.PI * 2),
            (Math.PI * 0.2 + elapsed) % (Math.PI * 2),
            (Math.PI * 0.3 + elapsed) % (Math.PI * 2)
        );
        testBoxMesh.updateMatrix();
    },
    attributePrefix: 'data-render' // is default
    preloadAssets: [imageSrc1, imageSrc2],
    onLoad: () => {
        // called after scene is ready
    },
    scrollContainer: myScrollableDiv, // default is window
});

Call cssToWebgl.updateElements() when DOM is ready (and images are loaded)

Data attributes

Used to indicate a scroll container. Body will have overflow hidden, so this will have to be a child of body data-render-scrollable="true"

Type data-render="text|color|image|video|has-image|texture|bufferTexture"

Speed of parallax scroll data-render-scroll-speed="slow|medium|fast|max|0.0-1.0"

Enter and leave duration/Tween easing data-render-enter-duration="500" data-render-leave-duration="500" data-render-enter-easing="Quadratic.InOut" data-render-leave-easing="Quadratic.InOut"

Only trigger in view animation once data-render-enter-once="true"

Color (used together with data-render="color|text") data-render-color="rgb(0,0,255)"

Blend mode data-render-blending="additive|subtractive|multiply"

ID of custom vertex shader data-render-fs="myVertexShader"

ID of custom fragment shader data-render-fs="myFragmentShader"

ID of custom material data-render-material="myMaterial"

ID of custom mesh data-render-mesh="myMesh"

  • Note that the z can't be above 0
  • Whenever updating the mesh, for instance in onRender, call .updateMatrix()

ID of custom render target texture data-render-buffer-texture="myRenderTargetTextureId"

Geometry segments data-render-width-segments="20" data-render-height-segments="20" data-render-depth-segments="20"

Z position (place objects beneath others) data-render-z="-20"

Fixed position data-render-fixed="true"

Active uniform (controls the value of uActive) data-render-active="0"

Custom uniforms data-render-uniform-test="-20" data-render-uniform-anotheruniform="0.5"

Only floats and name has to be lowercase and in one word

Types

text

Will attempt to rasterize text on canvas, so you can use the text as a texture. The texture will be black and white (for antialiasing) and is available under the sampler2D uniform uTexture. Color is vec3 uColor

image

Used on <img>-tag. Creates texture of currentSrc

has-image

Searches children for <img>-tag with data attribute data-render-src="your-image-source.jpg". Creates texture of currentSrc child image

video

Used on <video>-tag. Creates texture of src

texture

Experimental. Uses domToImage to create a texture of the current dom element. Doesn't work well with margins and overflow. Ensure that the element it is used on doesn't have margins or collaped margins.

bufferTexture

Use texture output of a WebGLRenderTarget as a sampler2D uniform.

Magic uniforms

The following uniforms will be added to shaders

  • float uElapsed
  • vec2 uMouse
  • vec2 uResolution
  • float uDPR
  • float uGlobalVisible
  • float uVisible
  • float uScrollSpeed
  • float uScrollProgress
  • float uActive (can be used arbitrarily, value comes from data-render-active)
  • sampler2D uImage (for types image, video)
  • sampler2D uTexture (for types texture, text)
  • vec3 uColor (for types color, text)
  • float uHovering (if element or parent is <button> or <a>)
  • float uFocused (if element or parent is <button> or <a>)

CSS

Add the following:

[data-render-hidden],
[data-render='video'],
[data-render='text'],
[data-render='image'],
[data-render='color'] {
  opacity: 0;
}