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

threejs-particle-shader

v0.3.0

Published

[View Demo](http://pwambach.github.io/threejs-particle-shader/)

Downloads

12

Readme

threejs-particle-shader

View Demo

This project offers an configurable and easy way to integrate a shader based particle system into a three.js project.
Basically it's a rewrite of my particle shader experiments with the goal to reuse the basic shader code anywhere but keeping everything flexible.

WIP!

Inspired by the "One Million Particles" Chrome Experiment

Usage

  1. Load the script from the dist folder
<script src="dist/particles.js"></script>
  1. Create a particle system. This function expects your THREE.js WebGL renderer and the rendered scene. Optionally you can customize the particle system by providing an options object.
var particles = new Particles(renderer, scene, options);
  1. To animate the particles you have to update the the system in your render loop.
particles.update();

Options

  • textureSize Integer (Default: 256): Sets the size of the particle shader textures resulting in the number of rendered particles. A size of 256 results in 256*256=65536 particles.

  • pointSize Float (Default: 1.0): The size of a single particle (the gl_PointSize value for the display shader)

  • gravityFactor Float (Default: 1.0): Gravity Factor for the default particle movement. In case you change the default movement using the velocityFunctionString this variable can be used as a custom input value.

  • explodeRate Float (Default: 1.0): The intensity of the initial random velocity and position spread

  • targetPosition THREE.Vector3 (Default: (0,0,0)): The position of the gravity center for the default particle movement. You can also use this value for custom movements. Have a look at example 4.

  • targetPosition THREE.DataTexture (Default: null): With a targetTexture you can specify a targetPosition for each particle. Have a look at example 3 for how to create a targetTexture.

  • velocityFunctionString String (Default: null): The velocityFunctionString allows to change the default behavior of the velocity fragment shader. If a value is specified the original code of the shader will be replaced with the defined string. The value has to be valid GLSL code and should set the variable outVelocity as a vec3. Currently these values are available for calculations:

inVelocity
inPosition
targetPos
dist        //the distance from the particle to the targetPosition
direction   //the normalized direction pointing from the particle to the targetPosition

If you specify a targetTexture, the targetPos will not be the targetPosition from options.targetPosition but the position for this specific particle defined in the targetTexture.

  • positionFunctionString String (Default: null): The positionFunctionString works in the same way. The string value will be set in the position fragment shader. pos should be set as a vec3. For now the only input variable is: velocity

  • colorFunctionString String (Default: null): The colorFunctionString works in the same way. The string value will be set in the displays fragment shader. color should be set as a vec4. For now the only input variables are: dist, alpha

License

MIT