Giter VIP home page Giter VIP logo

examples's Introduction

PixiJS β€” The HTML5 Creation Engine

pixi.js logo

Discord npm version Node.js CI Financial Contributors

This project aims to provide a fast, lightweight 2D library that works across all devices. The PixiJS renderer allows everyone to enjoy the power of hardware acceleration without prior knowledge of WebGL. Also, it's fast. Really fast.

If you want to keep up to date with the latest PixiJS news then feel free to follow us on Twitter @PixiJS and we will keep you posted! You can also check back on our site as any breakthroughs will be posted up there too!

We are now a part of the Open Collective and with your support you can help us make PixiJS even better. To make a donation, simply click the button below and we'll love you forever!

What to Use PixiJS for and When to Use It

PixiJS is a rendering library that will allow you to create rich, interactive graphics and cross-platform applications and games without having to dive into the WebGL API or deal with browser and device compatibility.

PixiJS supports WebGPU with fallback support for WebGL. As a library, PixiJS is a fantastic tool for authoring interactive content. Use it for your graphics-rich, interactive websites, applications, and HTML5 games. Out-of-the-box, cross-platform compatibility and graceful degradation mean you have less work to do and more fun doing it! If you want to create polished and refined experiences relatively quickly without delving into dense, low-level code, all while avoiding the headaches of browser inconsistencies, then sprinkle your next project with some PixiJS magic!

Boost your development and feel free to use your imagination!

Current features

  • WebGL renderer (with automatic smart batching, allowing for REALLY fast performance)
  • WebGPU renderer (new to the latest browsers!)
  • Canvas renderer (Fastest in town!)
  • Full scene graph
  • Super easy to use API (similar to the flash display list API)
  • Support for texture atlases
  • Asset loader / sprite sheet loader
  • Auto-detect which renderer should be used
  • Full Mouse and Multi-touch Interaction
  • Text
  • BitmapFont text
  • Multiline Text
  • Render Texture
  • Primitive Drawing
  • Masking
  • Filters
  • Community-Supported Plugins

Setup

It's easy to get started with PixiJS! Simply download a prebuilt build!

Alternatively, PixiJS can be installed with npm or simply using a content delivery network (CDN) URL to embed PixiJS directly on your HTML page.

NPM Install

npm install pixi.js

There is no default export. The correct way to import PixiJS is:

import * as PIXI from 'pixi.js';

CDN Install

Via jsDelivr:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pixi.min.js"></script>

Or via unpkg:

<script src="https://unpkg.com/[email protected]/dist/pixi.min.js"></script>

Basic Usage Example

import { Application, Sprite, Assets } from 'pixi.js';

// The application will create a renderer using WebGL, if possible,
// with a fallback to a canvas render. It will also setup the ticker
// and the root stage PIXI.Container
const app = new Application();

// Wait for the Renderer to be available
await app.init();

// The application will create a canvas element for you that you
// can then insert into the DOM
document.body.appendChild(app.canvas);

// load the texture we need
const texture = await Assets.load('bunny.png');

// This creates a texture from a 'bunny.png' image
const bunny = new Sprite(texture);

// Setup the position of the bunny
bunny.x = app.renderer.width / 2;
bunny.y = app.renderer.height / 2;

// Rotate around the center
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;

// Add the bunny to the scene we are building
app.stage.addChild(bunny);

// Listen for frame updates
app.ticker.add(() => {
    // each frame we spin the bunny around a bit
    bunny.rotation += 0.01;
});

Learn

  • Website: Find out more about PixiJS on the official website.
  • Getting Started:
    • Check out the getting started guide.
    • Also, check out @miltoncandelero's PixiJS tutorials aimed toward videogames with recipes and best practices here
  • Examples: Get stuck right in and play around with PixiJS code and features right here!
  • API Documentation: Get to know the PixiJS API by checking out the docs.
  • Guide: Supplementary usage guides to the API Documentation here.

Demos

Community

  • Forums: Check out the discussions and Stackoverflow -- both friendly places to ask your PixiJS questions.
  • Chat: You can join us on Discord to chat about PixiJS.

How to build

Note that for most users you don't need to build this project. If all you want is to use PixiJS, then just download one of our prebuilt releases. The only time you should need to build PixiJS is if you are developing it.

If you don't already have Node.js and NPM, go install them. Then, in the folder where you have cloned the repository, install the build dependencies using npm:

npm install

Then, to build the source, run:

npm run build

How to generate the documentation

The docs can be generated using npm:

npm run docs

Contribute

Want to be part of the PixiJS project? Great! All are welcome! We will get there quicker together :) Whether you find a bug, have a great feature request, or you fancy owning a task from the road map above, feel free to get in touch.

Make sure to read the Contributing Guide before submitting changes.

License

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

examples's People

Contributors

alvinsight avatar bcq028 avatar benbyford avatar bigtimebuddy avatar dependabot[bot] avatar dranitski avatar eneaentertainment avatar englercj avatar excaa avatar exponenta avatar goodboydigital avatar ivanpopelyshev avatar mfluehr avatar mghenri avatar miltoncandelero avatar munrocket avatar nikolas avatar palisan avatar pr-o avatar rtalon83 avatar shukantpal avatar supersodasea avatar themoonrat avatar timjrobinson avatar tobireif avatar tyrothefox avatar vikpe avatar winniehell avatar zprodev avatar zyie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Cannot build app

when using npm run build it is showing this

F:\pixi-test\examples\examples\js\plugin-picture\mask-blur.js
9:22 error Strings must use singlequote quotes
11:16 error Strings must use singlequote quotes
11:37 error Strings must use singlequote quotes
18:5 error Expected exception block, space or tab after '//' in comment spaced-comment
43:23 error There should be no line break before or after '=' operator-linebreak
44:9 error Strings must use singlequote quotes
44:47 error '+' should be placed at the beginning of the line operator-linebreak
45:9 error Strings must use singlequote quotes
45:59 error '+' should be placed at the beginning of the line operator-linebreak
46:9 error Strings must use singlequote quotes
59:30 error Strings must use singlequote quotes
59:54 error Missing trailing comma comma-dangle

F:\pixi-test\examples\examples\js\text\text.js
25:22 error Missing trailing comma comma-dangle
40:22 error Strings must use singlequote quotes
45:17 error Strings must use singlequote quotes
46:15 error Strings must use singlequote quotes
47:24 error Missing trailing comma comma-dangle
51:23 error A space is required after ',' comma-spacing

missing bezier arrow example

hi, i want draw a dynamic arrow with bezier curve, but i can find demo on how draw a arrow with graphics.
how i can perform this?
image

it for use in this kind of context, but i can't perform this in photoshop, too complex to do.
bezier with arrow
it possible to add a bezier arrow in pixi demo to help understand?
Or if someone have a code to share ?
https://www.pixiplayground.com/#/edit/cohufb~Y8gCB8VPlmql8f
thanks in advance.

add license?

which license are code examples and assets shared under?

Can assets in this repo be used for commercial purposes?

Hey there, I was just wondering if the characters in this repo could be used commercially in other websites? I've noticed the package json file mentions MIT license, I'm just not sure if that applies to all the assets in the repo as well?

If they so happen to not be allowed to be used commercially, does anyone know a marketplace where I could by assets to use with this framework? (I'm specially interested in characters that could be used with the spine framework)

Thanks 😊

How to debug examples in Chrome?

I cloned examples repo git clone https://github.com/pixijs/examples and built it with npm run build. I want to be able to debug examples in Chrome. I mean set breakpoint in PIXI.Application, etc. With http-server -c-1 I do not see such an option. Running build seemed to be bundled and minified (pixi-examples.min.js). Is there such an option to debug examples? Or maybe should I request it?

image

Invalid comment in CacheAsBitmap example

At line 62 in /examples/?v=v6.0.4#/demos-basic/cacheAsBitmap.js
there are a comment:

    // var sprite = new PIXI.Sprite(alienContainer.generateTexture());
    // app.stage.addChild(sprite);
    // sprite.x = Math.random() * 800;
    // sprite.y = Math.random() * 600;

PIXI.Container.generateTexture - is not a function - example failed on PIXI 6.0.4

Video example issues

  1. testVideo.mp4 returns a 404 error
  2. This feature seems broken on Firefox Android (I tested it with a video of mine). It says NS_ERROR_NOT_AVAILABLE

Masking demo looks weird.

There's something wrong with Masking demo.

Maybe it's intentional but I don't think so. It used to look like this:

old

And now it's like:

current

After bit of digging looks like this code was shorted before:

thing.beginFill(0x8bc5ff, 0.4);
thing.moveTo(-120 + Math.sin(count) * 20, -100 + Math.cos(count)* 20);
thing.lineTo(120 + Math.cos(count) * 20, -100 + Math.sin(count)* 20);
thing.lineTo(120 + Math.sin(count) * 20, 100 + Math.cos(count)* 20);
thing.lineTo(-120 + Math.cos(count)* 20, 100 + Math.sin(count)* 20);
thing.lineTo(-120 + Math.sin(count) * 20, -100 + Math.cos(count)* 20);
thing.rotation = count * 0.1;

So I'm guessing something went wrong while moving examples around.
If somehow it's how it's suppose to look like, just close this issue.

Security Error in 3D Cards example

Error: "Failed to execute 'texImage2D' on 'WebGL2RenderingContext': The image element contains cross-origin data, and may not be loaded.".
If I understand right, couse of error is CORS. But how to fix it?

Pixi Spine Walking Animation Example Throws Error

The example shown on the documentation site here throws an error when I try to view it:
http://pixijs.github.io/examples/#/spine/spineboy.js

Error in console:
Uncaught Error: Cannot add resources while the loader is running.
at Loader.add (pixi.js:5190)
at Loader. (pixi-spine.js:5457)
at pixi.js:5432
at next (pixi.js:6616)
at Loader.bitmapFontParser (pixi.js:32776)
at pixi.js:5432
at next (pixi.js:6616)
at Loader.spritesheetParser (pixi.js:33098)
at pixi.js:5432
at next (pixi.js:6616)

pixi-example-error

It looks like all the spine examples have this issue since none are working for me.
On Chrome Version 55.0.2883.87 m

Version Selector Cut-off with Version Warning

When the current version doesn't work with the example, the pop-up selector for the version is cutoff.

screen shot 2019-02-12 at 3 48 19 pm

Also, might be nice to include a warning ⚠️ symbol next to the error message and give it some more padding, so it's a little more obvious. Doing this might solve the select cut-off.

basic.js example uses division instead of multiplication for frame-independent transformation

In example basic.js, there is the code:

// Listen for animate update
app.ticker.add(function(delta) {
    // just for fun, let's rotate mr rabbit a little
    // delta is 1 if running at 100% performance
    // creates frame-independent tranformation
    bunny.rotation += 0.1 / delta;
});

Instead, it should be:

// Listen for animate update
app.ticker.add(function(delta) {
    // just for fun, let's rotate mr rabbit a little
    // delta is 1 if running at 100% performance
    // creates frame-independent tranformation
    bunny.rotation += 0.1 * delta;
});

Delta is greater if there is a greater time difference between steps. To ensure the same speed of rotation at any performance, there should be multiplication.

Copy to create new examples doesnt work

In the readme you write how to create your own examples:

All you need to do is copy and paste this file to where you think your example belongs.
You can then come back to the browser and navigate to your file and start changing it.

Actually you need to explain a bit more. After creating an example you need to add it to the manifest.json in the root folder of the examples. This was working for me.

Features: Improvements to Examples

Feature Improvements

Having upgrade examples to work with v7, there are bunch of improvements that could make this examples project much better.

  • Convert src code to be React, remove jQuery
  • Convert styles to be SASS instead of LESS
  • Upgrade ESLint to latest, revisit config rules
  • Use History API to track changes (back, forward navigation)
  • Decouple the file system organization and manifest organization
  • Handle 404s with requests
  • Add embed code generation (e.g., ?embed=1&lite=1)
  • Don't embed plugin builds, source from an external CDN
  • Support for export for 3rd party tools (e.g, codepen, jsfiddle, codesandbox.io)
  • Revisit responsive design for large screen-sizes (weird positioning)

Fails on `npm start`

I followed the instructions and get an error:

    [01:15:29] Using gulpfile ~/github/examples/gulpfile.js
    [01:15:29] Starting 'build'...
    [01:15:29] Starting 'clean'...
    [01:15:29] Starting 'serve'...
    [01:15:29] Finished 'serve' after 42 ms
    [01:15:29] Server started http://localhost:9000
    [01:15:29] LiveReload started on port 35729
    [01:15:29] Finished 'clean' after 67 ms
    [01:15:29] Starting 'assets'...
    [01:15:29] Starting 'html:index'...
    [01:15:29] Starting 'styles:common'...
    [01:15:29] Starting 'jshint'...
    /Users/me/github/examples/node_modules/gulp-less/index.js:68
        }).done(undefined, cb);
           ^

how to use dragbones getbone??

how to use dragbones getbone??
` const app = new PIXI.Application({ antialias: true });
document.body.appendChild(app.view);

app.stop();

// load spine data
PIXI.Loader.shared
    .add('skeleton', '/moban/dragonbones/Dragon_ske.json')
    .add('texture_json', '/moban/dragonbones/Dragon_tex.json')
    .add('texture_png', '/moban/dragonbones/Dragon_tex.png')
    .load(onAssetsLoaded);

function onAssetsLoaded(loader, res) {
    const factory = dragonBones.PixiFactory.factory;

    factory.parseDragonBonesData(res.skeleton.data);
    factory.parseTextureAtlasData(res.texture_json.data, res.texture_png.texture);
    var armature = factory.buildArmature("Dragon");
    // var armatureDisplay = armature.getDisplay();
    var armatureDisplay = factory.buildArmatureDisplay('Dragon', 'Dragon');
    // armatureDisplay.animation.play('walk');
    armatureDisplay.x = 400.0;
    armatureDisplay.y = 400.0;
    armatureDisplay.scale.x = 0.6;
    armatureDisplay.scale.y = 0.6;
     //θ°ƒζ•΄εŠ¨η”»ι€ŸεΊ¦
    // armatureDisplay.animation.timeScale = 0.1;

    //控刢ιͺ¨ιͺΌζ—‹θ½¬
    var head =armature.getBone("head");
    head.offset.rotation = 0.6;
    head.invalidUpdate();
    app.stage.addChild(armatureDisplay);
    // setTimeout(function() {
    //     armatureDisplay.animation.play('stand');
    //     setTimeout(function() {
    //         armatureDisplay.animation.play('walk');
    //     }, 2000)
    // }, 2000)

    app.start();
}`

this is no effect

algorithmic Zoom calculation for canvas and render

would be great if we could have an example with a zoom based on mouse position for canvas rendering.
I am not sure of the mathematical formula to use with event.
A example could help.
Thank you guys.

const mapZoom = SM_S._spriteset._tilemap.scale; // zoom based on scale the render
    function wheel_(event) {//TODO: zoom system
        if(event.wheelDeltaY>0){
            mapZoom.x+=0.05;
            mapZoom.y+=0.05;
            $gameMap._displayX+=0.05
            dX+=0.05;
        }else{
            mapZoom.x-=0.05;
            mapZoom.y-=0.05;
            $gameMap._displayX-=0.05
            dX-=0.05;
        }
    };

Demo website has issues in Firefox

I was unable to select items from the navigation in Firefox, I assume because of the attached Javascript error.

Works fine in Chrome.

TypeError: e.event.props is undefined[Learn More] examples:3:3027
    <anonymous> https://pixijs.io/examples/#/basics/basic.js:3
    <anonymous> https://pixijs.io/examples/#/basics/basic.js:3
    <anonymous> https://pixijs.io/examples/#/basics/basic.js:3
    <anonymous> https://pixijs.io/examples/#/basics/basic.js:3
    m6jQuery

Upgrade to v7.0.0

This project will need some work upgrading to v7:

  • Removes interaction plugin (replaces with events)
  • Removes Loader (replaces with Assets)

There are several plugins that will also require updating.

v4 examples are not working

This is the console error:

ERROR: 0:116: '26' : memory exhausted 

pixi.js:6453 WebGL: INVALID_VALUE: attachShader: no object or object deleted

pixi.js:6459 Pixi.js Error: Could not initialize shader.24.compileProgram @ pixi.js:6459
19.Shader @ pixi.js:5769
generateMultiTextureShader @ pixi.js:17743
88.SpriteRenderer.onContextChange @ pixi.js:17470
emit @ pixi.js:1238
...
window.onload   @   VM294:1

Video doesn't show in the examples

Hi guys, i found the trouble.
Maybe you know about that.
But anyway, in example on this LINK
Video show only in 4.0.0 version.
In version 4.0.1 and above video doesn't work, only music.
I checked in Google Chrome 53.0.2785.143 and Firefox 43.0.2

[BUG] - pixi example mouse trail on chrome (windows 8.1)

I'm using pixi v4.8.5 in my project and when I started to test it in one old notebook I noticed a bug in PIXI.mesh.Rope. Went to the official pixi examples to see how it would behave and realized the bug also happens there.

Expected Behavior

firefox

Current Behavior

chrome_opera

Environment

  • pixi.js version: 4.8.5
  • Browser: CHROME 81.0.4044.92
  • OS: Windows 8.1 Pro
  • Graphics card: Intel HD Graphics 3000

The same thing happens in v5 with the latest pixi version (using PIXI.SimpleRope).

The bug is also present when running on Opera (Version 67.0.3575.137).
It doesn't happen in Firefox (75.0).

If I use the flag forceCanves: true it works as expected, but the performance is not good.
The flag legacy: true doesn't fix it.

I decided to check my chrome on webglreport.com:

photo4945165254183200982

photo4945165254183200983

Firefox receives the green OK message for webgl1 and webgl2. Opera and chrome have the same results.

System says the driver is up to date.

I also have ubuntu 16.04 running on the same PC and the bug doesn't happen there (tested latest chrome and firefox).

Is there any workaround?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.