Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie authored Oct 11, 2024
2 parents 2741e5a + 3bf7cd2 commit a82407f
Show file tree
Hide file tree
Showing 21 changed files with 399 additions and 37 deletions.
2 changes: 1 addition & 1 deletion blog/2024-03-05-pixi-v8-launches.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords: ['PixiJS', 'pixi.js', 'webGL', 'webGPU', 'performance', '2d rendering'

Get ready to push the boundaries of what's possible on the web! PixiJS v8 has landed, and it's a game-changer. Celebrating a decade of driving innovation, we've supercharged PixiJS with the latest technological advancements, making it faster, more robust, and ridiculously powerful. From the seamless integration of WebGPU to leveraging modern JavaScript for smoother development, PixiJS v8 is all about empowering you to create jaw-dropping web experiences with ease. It's not just an update; it's the future of 2D web graphics, today. Dive in and let PixiJS v8 elevate your projects to unseen heights. Let's make the web a more beautiful place, one pixi(el) at a time.

<!--truncated-->
<!--truncate-->

## 🚀 Revolutionizing Web Graphics: Welcome to PixiJS v8

Expand Down
63 changes: 63 additions & 0 deletions blog/2024-06-14-pixi-spine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: PixiJS Joins the Spine 4.2 Physics Revolution! 🚀
description: Elevate your animations with Spine 1.1.0 and the revolutionary physics features of Spine 4.2, now fully integrated with PixiJS v8.
slug: pixi-js-hearts-spine
authors:
- name: GoodBoyDigital
title: PixiJS Creator
url: https://github.com/GoodBoyDigital
image_url: https://github.com/GoodBoyDigital.png
tags: [PixiJS, Spine, WebGL, WebGPU, Animation]
hide_table_of_contents: true
keywords: ['PixiJS', 'Spine', 'webGL', 'webGPU', '2D animation', 'JavaScript graphics', 'game development']
---

We have exciting news for all animation enthusiasts and game developers! The Spine team has just smashed it out of the park with the release of [Spine 4.2](https://en.esotericsoftware.com/blog/Spine-4.2-The-physics-revolution), which includes some truly great new features. The best part for us PixiJS users? We can start leveraging these remarkable features today in both v7 and v8!

<!--truncate-->

For those unfamiliar, Spine is the standard for creating stunning 2D animations. It offers an intuitive editor and a multitude of runtimes to ensure that your animations can be utilized across various platforms. PixiJS has supported Spine for almost as long as both have existed (around 10 years)! Personally, we have been shipping games with Spine for about that long as well.

Initially, we maintained our own player. This worked well, but as Spine evolved and new releases were introduced, we had to invest considerable time and energy to modify our custom player. In the past year, the Esoteric team has been managing the v7 version of the player after PixiJS's [elementalcode](https://x.com/miltoncandelero) made the initial implementation on top of their excellent HTML5 runtime. This means that as these incredible updates are released, the PixiJS community can use them almost immediately!

Here are a few of the exciting new features:

### 🏋️‍♂️ Physics in Spine

Spine 4.2 revolutionizes animation with built-in physics, allowing bones to move naturally by simulating real-world physics. This means:
- **Automatic Secondary Motion**: Save time and enhance your animations with automated movement for hair, clothing, and more.

<iframe src="https://pixijs.io/spine-v8/examples/physics2.html" width="100%" height="500"></iframe>

- **Dynamic Movement**: Enjoy fluid and realistic physics that respond to character movements and animations.

<iframe src="https://pixijs.io/spine-v8/examples/physics.html" width="100%" height="500"></iframe>

### 📎 Attachments

You can now attach any PixiJS Container to a slot in your animation with a simple-to-use API.

- `addSlotObject(slotName, object)`
- `removeSlotObject(slotName)`
- `getSlotObject(slotName)`

<iframe src="https://pixijs.io/spine-v8/examples/slot-objects.html" width="100%" height="500"></iframe>

### 🏎️ v8 Spine Player Beta

We have not forgotten about v8! Just as we engineered v8 with the goal of being the fastest WebGPU (and WebGL!) renderer available, we applied this same focus to the v8 implementation of Spine. Here are some impressive statistics:

- **50% Faster**: Enjoy significant performance improvements, making it over 50% faster than the previous v7 version.
- **50% Less Memory**: We've optimized memory usage, reducing it by over 50% compared to the current v7 version.

We are proud to say that this is one of if not *the* fastest way to render Spine animations on the web 🏆. Get ready to create smooth, high-performance animations with ease.

We plan on handing this implementation back over to the Spine team once we have dotted all the i's and crossed the t's. The last missing feature is the dark-tint property, which is not currently taken into account when rendering in v8. Other than that, all other features are present. If you are not using dark-tint, then this version will work great on v8; we are already using it in production for our games!

We included all the examples in the repo for you to play with [here](https://github.com/pixijs/spine-v8/tree/main/examples).

You can also check out the live v8 examples [here](https://pixijs.io/spine-v8/examples/)

## 📲 Stay Connected

Follow [Doormat23](https://twitter.com/Doormat23) and [PixiJS](https://twitter.com/PixiJS) on social media for the latest updates. Join our vibrant community on [Discord](https://discord.gg/nrnDP9wtyX) for real-time discussions and support.
132 changes: 132 additions & 0 deletions blog/2024-07-18-assetpack-1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: AssetPack 1.0.0 Release!
description: AssetPack 1.0.0 is here! 🎉
slug: assetpack-1.0.0
authors:
- name: Zyie
title: PixiJS Co-owner
url: https://github.com/Zyie
image_url: https://github.com/Zyie.png
tags: [PixiJS, AssetPack, Web, Games, Spine, Optimisation, 'Asset Management']
hide_table_of_contents: true
keywords: ['PixiJS', 'Spine', 'JavaScript', 'game development', 'web development', 'asset management', 'loading']
---

Today we are very excited to announce [AssetPack](https://pixijs.io/assetpack) 1.0, an asset management and optimization tool for web developers.

In the world of web development, managing and optimizing assets often demands significant manual effort. Developers need to ensure that their images are compressed, their audio files are optimized, their fonts are loaded efficiently, and more. This process can be time-consuming and error-prone, especially when working on large projects with many assets. To address this challenge, AssetPack provides a configurable asset pipeline that automates many of these tasks, making it easier for developers to manage and deploy assets in their projects.

<!--truncate-->

## What is AssetPack?

AssetPack is a tool designed to streamline the management, optimization, and deployment of assets in web projects. It is framework-agnostic and can be used with any framework you like, such as PixiJS, Three.js, Phaser, and others. AssetPack employs a plugin-based system, allowing you to create your own plugins to customize asset processing according to your needs.

<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', paddingBottom: '24px' }}>
<img
src={'/images/blog/assetpack-screenshot.png'}
alt="AssetPack screenshot"
/>
</div>

AssetPack comes out of the box with the following plugins:

- **Cache Busting**: Automatically appends a unique hash to asset URLs to ensure that clients always load the latest version of the asset.
- **Compression**: Compresses images using sharp, allowing for the creation of webp/avif images and compressing png/jpg to reduce file sizes.
- **TexturePacker**: Automatically generates spritesheets from images.
- **Mipmap**: Generates mipmaps for textures to improve rendering performance e.g. 2x, 1x, 0.5x, etc.
- **Spine**: Optimizes Spine animations by creating mipmaps for `.atlas` files.
- **Audio/FFmpeg**: Converts audio files to the desired format and bitrate using FFmpeg.
- **JSON**: Minifies JSON files to reduce their size.
- **Webfont**: Converts all fonts files to WOFF2 format, and plugins for SDF and MSDF font generation
- **Manifest**: Generates a manifest file containing all asset URLs for easy loading. This can be used with PixiJS's `Assets` loader

The above plugins are just a few examples of what AssetPack can do. You can create your own plugins to extend AssetPack's functionality further.

### Key Features of AssetPack

#### Caching & CI

AssetPack intelligently caches assets, transforming each asset only once. This reduces redundant processing and speeds up build times, ensuring that you always have the latest version of your assets without unnecessary overhead.

This is perfect for Continuous Integration (CI) environments, AssetPack allows you to commit raw assets to your repository and transform them as part of your build process. This ensures that your assets are always optimized and up-to-date with minimal manual intervention. See the Github Action example [here](https://pixijs.io/assetpack/docs/guide/getting-started/github-action/) for more information.

#### Performance

Designed to handle large quantities of assets, AssetPack utilizes the fastest tools available. This ensures that your asset pipeline can keep up with the demands of modern web development, delivering optimized assets quickly and efficiently.

#### Watch Mode

With the Watch mode, AssetPack monitors your assets in real-time, updating them as you add or remove files. This live update feature streamlines development, allowing you to see changes immediately without having to manually trigger asset processing. Combined with the caching system, Watch mode ensures that only the necessary assets are transformed, keeping build times to a minimum.

#### Tag System

AssetPack's tag-powered system makes asset management intuitive and flexible. By simply adding tags to folders or files (e.g., `{tps}` to create a sprite sheet), you can easily apply specific processing rules. This feature simplifies complex asset workflows and enhances customization.

<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', paddingBottom: '24px' }}>
<img
src={'/images/blog/assetpack-screenshot-tags.png'}
alt="AssetPack screenshot"
/>
</div>

## How to use AssetPack

### Installation

To install AssetPack, you need to install the `@assetpack/core` package.

```bash
npm install --save-dev @assetpack/core
```

:::info COMPATIBILITY NOTE
AssetPack requires [Node.js](https://nodejs.org/en/) version 20+, please upgrade if your package manager warns about it.
:::

### Setup

To set up AssetPack, you need to create a configuration file that defines what assets you want to optimise and how you want to optimise them.

First create a `.assetpack.js` file in the root of your project. This file should export an object with the following properties:

```js
// .assetpack.js
import { pixiPipes } from '@assetpack/core';

export default {
entry: './raw-assets',
output: './public/assets',
pipes: [
/* If you are using AssetPack with PixiJS, you can use the `pixiPipes` function
* to add a pre-configured set of plugins, with an opinionated
* set of defaults for PixiJS.
*/
...pixiPipes()
],
};
```

To see the full list of configuration options, see the [API Reference](https://pixijs.io/assetpack/docs/guide/configuration/) page.

Then to run AssetPack, you can use the CLI, run programmatically, or use a build tool like Vite.

- [CLI](https://pixijs.io/assetpack/docs/guide/getting-started/cli)
- [Programmatic](https://pixijs.io/assetpack/docs/guide/getting-started/programmatic)
- [Vite](https://pixijs.io/assetpack/docs/guide/getting-started/vite)

AssetPack has a number of built-in plugins for you to use, to see the full list of plugins, see the [Plugins](https://pixijs.io/assetpack/docs/guide/pipes/overview) page.

### Open Source Games

AssetPack is already in use in our open source games repo. Check out the [games](https://pixijs.io/assetpack/examples) leveraging AssetPack for asset management. These examples showcase the power and flexibility of AssetPack in real-world scenarios.

## Conclusion

AssetPack is a powerful tool that can help you manage and optimize assets in your web projects. By automating many of the tasks involved in asset management, AssetPack can save you time and effort, allowing you to focus on building great web experiences. We hope you find AssetPack useful in your projects, and we look forward to seeing what you create with it!

We are committed to continuously improving AssetPack, and your feedback is invaluable to us. If you encounter any issues or have suggestions for new features, please reach out on our discord or open an issue on our GitHub repository.

## 🌐 Stay Connected

Follow [Zyie](https://twitter.com/_Zyie_) and [PixiJS](https://twitter.com/PixiJS) on social media for the latest updates. Join our vibrant community on [Discord](https://discord.gg/nrnDP9wtyX) for real-time discussions and support.
103 changes: 103 additions & 0 deletions blog/2024-10-03-pixi-v8-particle-container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: ParticleContainer - The New Speed Demon in PixiJS v8
description: Introducing the new ParticleContainer in PixiJS v8—faster than ever, optimized for rendering millions of particles effortlessly.
slug: particlecontainer-v8
authors:
- name: Mat Groves
title: PixiJS
url: https://github.com/GoodboyDigital
image_url: https://github.com/GoodboyDigital.png
tags: [PixiJS, ParticleContainer, WebGL, Games, Performance, Optimization]
hide_table_of_contents: true
keywords: ['PixiJS', 'ParticleContainer', 'game development', 'web graphics', 'optimization', 'WebGL']
---

PixiJS v8 has taken speed to the next level with the release of its new `ParticleContainer`. This new feature brings a jaw-dropping performance boost, capable of rendering 100K+ without breaking a sweat. If you’ve got tons of elements to throw on the screen, you’re in for a treat!

<!--truncate-->

## 🚀 New ParticleContainer Design

The key difference in PixiJS v8 is that the `ParticleContainer` doesn’t deal with sprites any more, it works with lightweight **particles**. While particles share many properties with sprites (like texture, position, anchor, scale, rotation, alpha and color), they cut out unnecessary overhead. The result is **speed**, pure and simple.

How fast, you ask? Well, take a look on my machine (Macbook Pro M3):

- **Sprites + Container**: 200,000 at 60fps.
- **Particles + ParticleContainer**: 1,000,000 at 60fps!

Yes, that’s a _million_ bunnies on-screen, and honestly the main bottleneck at that point wasn’t even rendering but the logic behind the bouncing movement! Give this a spin and see for yourself:

<iframe src="https://goodboydigital.github.io/pixi-bunnymark/dist/?asParticles=true&count=1000&renderer=webgl" width="700" height="500" frameborder="0"></iframe>

The key takeaway is that you can now render **huge volumes of elements** absurdly fast, making PixiJS v8 a perfect choice for high-performance games or visually intensive projects. And yes this is faster than the v7 particle container by **over 3x**!

Please checkout the [migration guide](../8.x/guides/migrations/v8#particlecontainer) for more information on how to migrate your code to the new particle container.

### Speed Secret: Static vs. Dynamic Properties

To get the most out of this performance beast, it’s essential to understand **static** vs. **dynamic** properties. PixiJS gives you full control over which properties update every frame (dynamic) and which don’t need constant updates (static). Here’s how they work:

- **Static properties**: Once set, they stay the same unless explicitly changed. By keeping them static, you reduce computational load, meaning faster rendering. This is your responsibility to update :)
- **Dynamic properties**: These are recalculated and uploaded to the GPU every frame regardless.

By default, **only the position** is dynamic, but you can configure others if needed. The fewer dynamic properties you have, the faster the rendering will be!

### PixiJS v8 Particle Container Usage

Let’s walk through a simple example of how to get started:

```javascript
import { ParticleContainer, Particle, Texture } from 'pixi.js';

// Create a particle container with default options
const container = new ParticleContainer({
// this is the default, but we show it here for clarity
dynamicProperties: {
position: true, // Allow dynamic position changes (default)
scale: false, // Static scale for extra performance
rotation: false, // Static rotation
color: false // Static color
}
});

// Add particles
const texture = Texture.from('path/to/bunny.png');

for (let i = 0; i < 100000; ++i) {
let particle = new Particle({
texture,
x: Math.random() * 800,
y: Math.random() * 600,
});

container.addParticle(particle);
}

// Add container to the Pixi stage
app.stage.addChild(container);
```

In this example, we create a `ParticleContainer`, set properties to static where possible, and generate a 100k particles. By using a shared texture (hello, sprite sheets!), we ensure that all particles share the same graphical assets, making rendering even more efficient.

### Reasons to Use ParticleContainer

The `ParticleContainer` shines when you need **insane numbers** of visual elements on-screen, especially when you want them moving and interacting in real time. Whether you're building particle effects, swarms of characters, or abstract art installations, PixiJS v8 has you covered. The static vs. dynamic property system gives you granular control over performance, allowing you to fine-tune the balance between flexibility and speed.

This is basically the fastest we could make it by still keeping allowing for different textures (via sprite sheets) and still empowering devs to manipulate the particles via JS and not having to move the movement to the GPU (which might be faster, but is more complex and less flexible). So even though we are choosing to call them particles, they are more like something in between a traditional particle and a classic sprite.

This is ideal for projects where frame rate and rendering volume matter—such as games, interactive apps, and high-volume data visualization. By controlling the dynamic properties of your particles, you can optimize your application’s performance to fit your needs.

### Next Steps

The new `ParticleContainer` is a game-changer, but there are still some areas for improvement! For one, there is room to optimise further the static uploading of properties (you may notice the example above is slower when adding bunnys - but then speeds up once stable). We plan to expose how the particles are batched so that developers can add / remove attributes from the batch to make it even faster or add more flexibility and customization. But for now, this is a great starting point and we hope you enjoy the new `ParticleContainer`!

## 🎉 Conclusion

PixiJS v8’s `ParticleContainer` is a game-changer when it comes to rendering at scale. Its ability to push **millions** of particles at full speed opens up a world of possibilities for game developers, animators, and creative coders. Get in, experiment with the new API, and see just how fast your visuals can fly!

Ready to give it a spin? Try out the new `ParticleContainer` in PixiJS v8, and push the limits of performance in your projects!


## 🌐 Stay Connected

Follow [Doormat23](https://twitter.com/Doormat23) and [PixiJS](https://twitter.com/PixiJS) on social media for the latest updates. Join our vibrant community on [Discord](https://discord.gg/nrnDP9wtyX) for real-time discussions and support.
Loading

0 comments on commit a82407f

Please sign in to comment.