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 🙏

© 2024 – Pkg Stats / Ryan Hefner

modular-particle-system-webgl-renderer

v1.1.0

Published

WebGL 2 renderer for modular-particle-system package

Downloads

2

Readme

Simple WebGL 2 renderer package for modular-particle-system.

Minified size 9 kB. Capable of rendering up to 100 000 particles with smooth FPS (60 times per second).

Available as:

  • IIFE
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.iife.js"></script>

By using the IIFE build, you can even embed a fully functional particle system + renderer with pure HTML code, for example like this.

  • NPM package

npm install modular-particle-system-webgl-renderer

NOTE: Usage from NPM package is currently untested.

// IIFE
const { Renderer } = modularParticleSystemWebglRenderer;

// NPM
import { Renderer } from "modular-particle-system-webgl-renderer";

const imgCloudTexture = new Image();
imgCloudTexture.src = `my-assets/generic/cloud.png`;
const textures = {
  "generic/cloud.png": imgCloudTexture,
};

const renderer = Renderer({
  particleSystem,
  container: document.body,
  textures,
});

Extended usage

Renderer Options

Required particleSystem

Reference to a modular ParticleSystem object.

Required container

Reference to a HTML element that will contain the renderer.

Required textures

Texture sources for rendering particles.

This is a object where each property key describes the name of a texture and the value is a texture source. Several types of values are supported:

Optional autoUpdate

If omitted or true, the renderer will automatically update the ParticleSystem between each frame.

Optional coordinateSystem

Defaults to 'pixels'. Can be one of:

  • 'pixels': Particle positions are in pixels, {x:0, y: 0} is at top left corner of container, positive X is right, positive Y is down..

  • 'pixels-centered': Particle positions are in pixels, {x:0, y: 0} is at center of container, positive X is right, positive Y is down.

Optional maxParticlesCount

Defaults to 50000, can be used to set a limit for particle rendering. When number of particles exceeds this, the renderer will render some subset of the particles but not all.

Optional loggingEnabled

Defaults to true, which enables printing information to the console. To disable all non-error console logging, set to false.

Destroy Renderer

const renderer = Renderer({ ... });
renderer.destroy()

Known limitations

The renderer currently only supports rendering with 1 texture source.

The vision is to allow rendering with a relatively small number of relatively small textures, let's say 10 textures each smaller than 200x200px, since this is within the limits of keeping things simple and performant.

Development

cd modular-particle-system-webgl-renderer
npm i
npm start