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

pixi-custom

v0.0.8

Published

A flexible(sort of) way to expose the possibility of using vertex shader in PIXI 3

Downloads

10

Readme

PIXI-CUSTOM

PIXI-CUSTOM provides PIXI users a flexible(sort of) way to use custom geometries and vertex shader in PIXI 3.

PIXI-CUSTOM is made with browserify and love. However, I believe most of our users use the standalone version for PIXI, therefore even though you can install PIXI-CUSTOM with npm pixi-custom, I assume you have your PIXI exposed as a global variable in your website. If you just use to download the standalone version of PIXI-CUSTOM, you can DOWNLOAD IT HERE

Do you want to put a 3D globe or other 3D models into PIXI? Pixi-custom can make it happens!

Not convinced yet? Check out the the following examples:

Examples

Particles

http://edankwan.github.io/pixi-custom/examples/points.html

Lines

http://edankwan.github.io/pixi-custom/examples/lines.html

Mesh

http://edankwan.github.io/pixi-custom/examples/mesh.html

Update Attributes

http://edankwan.github.io/pixi-custom/examples/update-attributes.html

Multi Instances

http://edankwan.github.io/pixi-custom/examples/multi-instances.html

Draw Offset

http://edankwan.github.io/pixi-custom/examples/draw-offset.html

Model

http://edankwan.github.io/pixi-custom/examples/model.html

Using filters with PIXI-CUSTOM

http://edankwan.github.io/pixi-custom/examples/mesh-post-processing.html

Usage

var shader = new pixiCustom.Shader({
    renderer: renderer,
    vs : vsString,
    fs : fsString,
    attributes : {
        aRandom: { type: '1f' }
    },
    uniforms : {
        uTime:  { type: '1f' }
    }
});

The codes above will define the shader interface but it doesn't store the data.

As you have to have vertices in the PIXI mesh, otherwise it will throw an error, I pre-inserted the default vertices attribute in the Class like:

attributes : {
	vertices: {
	    // id is the variable name in the glsl, if not defined, it uses the property name instead
	    id: 'aVertexPosition',
	    // usage: 'DYNAMIC_DRAW',
	    // not support object type like v2 PIXI.Point
	    type: '2f'
	}
}

If you want to override it using 3 dimensional float, you can add the whole chunk in to override it (See Mesh)

After the shader is created, the values will be placed at the root of the object like this:

particles = new pixiCustom.Points({
    shader : shader,
    vertices : vertices,
    aRandom : aRandom,
    uTime : 0,
    beforeRender : function(gl) {
        // in case you want to do some advanced stuff
        // gl.enable(gl.DEPTH_TEST);
        // gl.enable(gl.CULL_FACE);
        // gl.cullFace(gl.BACK);
    },
    afterRender : function(gl) {
        // gl.disable(gl.DEPTH_TEST);
    }
});

Which means you can easily change the values by doing:

particles.aRandom[0] = 100;
particles.dirties['aRandom'] = true;

particles.uTime += dt;

Internal Uniforms

If we don't take good use of the PIXI container system, there is no point to use PIXI. So, PIXI Custom respect the internal uniform setting.

// translation matrix
uniform mat3 translationMatrix;

// projection matrix
uniform mat3 projectionMatrix;

// alpha value that multiplied parent container alpha 
uniform float alpha;

Using filters with Pixi-custom

As Pixi-custom allows us to customize the geometry and to use the vertex shader, there is no way for PIXI to know what is the actual bound box of the instance to apply the filters. So, since PIXI-custom 0.0.7, we allow you to set the bound box manually so that the filters can work properly.

var myMesh = new pixiCustom.Mesh({...});
myMesh.bounds = new PIXI.Rectangle(-100, -100, 200, 200); // x: -100, y: -100, width: 200, height: 2000

var blurFilter = new PIXI.filters.BlurFilter();
blurFilter.blur = 4;
myMesh.filters = [blurFilter];

Contribute

Please files issues for any bugs you ran into and features you want to be added into PIXI-CUSTOM. Any pull requests are welcome as well :)

License

This content is released under the (http://opensource.org/licenses/MIT) MIT License.