@docyrus/animaguru 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/NOTICE.md +256 -0
  2. package/README.md +241 -0
  3. package/dist/animaguru.js +27338 -0
  4. package/package.json +37 -0
  5. package/skills/animaguru/SKILL.md +115 -0
  6. package/skills/animaguru-advertising/SKILL.md +25 -0
  7. package/skills/animaguru-advertising/references/brand-bumper.md +11 -0
  8. package/skills/animaguru-advertising/references/comparison.md +11 -0
  9. package/skills/animaguru-advertising/references/creator-testimonial.md +11 -0
  10. package/skills/animaguru-advertising/references/editorial-advertorial.md +11 -0
  11. package/skills/animaguru-advertising/references/game-reward.md +11 -0
  12. package/skills/animaguru-advertising/references/offer-promotion.md +11 -0
  13. package/skills/animaguru-advertising/references/product-launch.md +11 -0
  14. package/skills/animaguru-advertising/references/product-proof.md +11 -0
  15. package/skills/animaguru-analog-film-tape/SKILL.md +29 -0
  16. package/skills/animaguru-analog-film-tape/references/recipe.md +23 -0
  17. package/skills/animaguru-animated-data-visualization/SKILL.md +39 -0
  18. package/skills/animaguru-animated-data-visualization/references/data-contract.md +16 -0
  19. package/skills/animaguru-animated-data-visualization/references/variants.md +17 -0
  20. package/skills/animaguru-art-deco-motion/SKILL.md +29 -0
  21. package/skills/animaguru-art-deco-motion/references/recipe.md +22 -0
  22. package/skills/animaguru-ascii-crt/SKILL.md +29 -0
  23. package/skills/animaguru-ascii-crt/references/recipe.md +22 -0
  24. package/skills/animaguru-blueprint-drafting/SKILL.md +29 -0
  25. package/skills/animaguru-blueprint-drafting/references/recipe.md +22 -0
  26. package/skills/animaguru-cartoon-character-animation/SKILL.md +35 -0
  27. package/skills/animaguru-cartoon-character-animation/references/variants.md +17 -0
  28. package/skills/animaguru-cutout-animation/SKILL.md +33 -0
  29. package/skills/animaguru-cutout-animation/references/production-recipe.md +37 -0
  30. package/skills/animaguru-cutout-animation/references/variants.md +17 -0
  31. package/skills/animaguru-cutout-animation/references/visual-style.md +34 -0
  32. package/skills/animaguru-dark-tech-stage/SKILL.md +29 -0
  33. package/skills/animaguru-dark-tech-stage/references/recipe.md +23 -0
  34. package/skills/animaguru-diagram-formula-motion/SKILL.md +36 -0
  35. package/skills/animaguru-diagram-formula-motion/references/variants.md +17 -0
  36. package/skills/animaguru-engraved-relief-print/SKILL.md +29 -0
  37. package/skills/animaguru-engraved-relief-print/references/recipe.md +24 -0
  38. package/skills/animaguru-flat-vector-motion/SKILL.md +35 -0
  39. package/skills/animaguru-flat-vector-motion/references/variants.md +17 -0
  40. package/skills/animaguru-general-video/SKILL.md +20 -0
  41. package/skills/animaguru-general-video/references/ambient-loop.md +11 -0
  42. package/skills/animaguru-general-video/references/music-lyrics.md +11 -0
  43. package/skills/animaguru-general-video/references/short-film.md +11 -0
  44. package/skills/animaguru-general-video/references/titles-event.md +11 -0
  45. package/skills/animaguru-general-video/references/visual-essay.md +11 -0
  46. package/skills/animaguru-generative-light-signal/SKILL.md +29 -0
  47. package/skills/animaguru-generative-light-signal/references/recipe.md +23 -0
  48. package/skills/animaguru-glass-mosaic/SKILL.md +29 -0
  49. package/skills/animaguru-glass-mosaic/references/recipe.md +23 -0
  50. package/skills/animaguru-halftone-editorial/SKILL.md +29 -0
  51. package/skills/animaguru-halftone-editorial/references/recipe.md +23 -0
  52. package/skills/animaguru-holographic-scan/SKILL.md +29 -0
  53. package/skills/animaguru-holographic-scan/references/recipe.md +22 -0
  54. package/skills/animaguru-interface-motion/SKILL.md +36 -0
  55. package/skills/animaguru-interface-motion/references/screen-mapping.md +16 -0
  56. package/skills/animaguru-interface-motion/references/variants.md +17 -0
  57. package/skills/animaguru-isometric-worlds/SKILL.md +35 -0
  58. package/skills/animaguru-isometric-worlds/references/variants.md +17 -0
  59. package/skills/animaguru-kinetic-typography/SKILL.md +35 -0
  60. package/skills/animaguru-kinetic-typography/references/variants.md +17 -0
  61. package/skills/animaguru-miniature-diorama/SKILL.md +29 -0
  62. package/skills/animaguru-miniature-diorama/references/recipe.md +23 -0
  63. package/skills/animaguru-painterly-depth-animation/SKILL.md +35 -0
  64. package/skills/animaguru-painterly-depth-animation/references/variants.md +17 -0
  65. package/skills/animaguru-paper-popup/SKILL.md +29 -0
  66. package/skills/animaguru-paper-popup/references/recipe.md +22 -0
  67. package/skills/animaguru-photo-footage-editorial/SKILL.md +29 -0
  68. package/skills/animaguru-photo-footage-editorial/references/recipe.md +23 -0
  69. package/skills/animaguru-pixel-art-animation/SKILL.md +36 -0
  70. package/skills/animaguru-pixel-art-animation/references/variants.md +17 -0
  71. package/skills/animaguru-portal-zoom/SKILL.md +29 -0
  72. package/skills/animaguru-portal-zoom/references/recipe.md +21 -0
  73. package/skills/animaguru-risograph-print/SKILL.md +29 -0
  74. package/skills/animaguru-risograph-print/references/recipe.md +23 -0
  75. package/skills/animaguru-sand-drawing/SKILL.md +29 -0
  76. package/skills/animaguru-sand-drawing/references/recipe.md +21 -0
  77. package/skills/animaguru-shadow-theatre/SKILL.md +29 -0
  78. package/skills/animaguru-shadow-theatre/references/recipe.md +23 -0
  79. package/skills/animaguru-silkscreen-poster/SKILL.md +29 -0
  80. package/skills/animaguru-silkscreen-poster/references/recipe.md +22 -0
  81. package/skills/animaguru-stop-motion-objects/SKILL.md +29 -0
  82. package/skills/animaguru-stop-motion-objects/references/recipe.md +23 -0
  83. package/skills/animaguru-studio-product-reveal/SKILL.md +29 -0
  84. package/skills/animaguru-studio-product-reveal/references/recipe.md +23 -0
  85. package/skills/animaguru-video/SKILL.md +79 -0
  86. package/skills/animaguru-whiteboard-line-drawing/SKILL.md +34 -0
  87. package/skills/animaguru-whiteboard-line-drawing/references/variants.md +17 -0
  88. package/templates/video/AGENTS.md +34 -0
  89. package/templates/video/CLAUDE.md +19 -0
  90. package/templates/video/README.md +101 -0
  91. package/templates/video/VIDEO-STYLE-NOTICES.txt +54 -0
  92. package/templates/video/film.config.json +10 -0
  93. package/templates/video/gitignore +11 -0
  94. package/templates/video/index.html +14 -0
  95. package/templates/video/package.json +28 -0
  96. package/templates/video/public/brand/logo-mark.svg +5 -0
  97. package/templates/video/scripts/build.mjs +12 -0
  98. package/templates/video/scripts/export-html.mjs +12 -0
  99. package/templates/video/scripts/export-mp4.mjs +209 -0
  100. package/templates/video/scripts/html-export-plugin.mjs +35 -0
  101. package/templates/video/scripts/html-export.mjs +54 -0
  102. package/templates/video/scripts/install-example.mjs +32 -0
  103. package/templates/video/scripts/review-analysis.mjs +29 -0
  104. package/templates/video/scripts/review-audio.mjs +24 -0
  105. package/templates/video/scripts/review.mjs +37 -0
  106. package/templates/video/scripts/starter-film.sha256 +1 -0
  107. package/templates/video/shared/locales/en/export.json +10 -0
  108. package/templates/video/shared/locales/en/film.json +42 -0
  109. package/templates/video/shared/locales/en/player.json +31 -0
  110. package/templates/video/shared/locales/en/style-studies.json +168 -0
  111. package/templates/video/shared/locales/en/timeline.json +33 -0
  112. package/templates/video/src/assets.ts +4 -0
  113. package/templates/video/src/download.ts +27 -0
  114. package/templates/video/src/exporter.ts +70 -0
  115. package/templates/video/src/film-resources.ts +29 -0
  116. package/templates/video/src/film.ts +132 -0
  117. package/templates/video/src/main.ts +219 -0
  118. package/templates/video/src/resource-timeline.ts +193 -0
  119. package/templates/video/src/review.ts +50 -0
  120. package/templates/video/src/studies/film.ts +26 -0
  121. package/templates/video/src/studies/media.ts +46 -0
  122. package/templates/video/src/studies/model.ts +60 -0
  123. package/templates/video/src/studies/pixi-renderer.ts +121 -0
  124. package/templates/video/src/studies/scenes.ts +410 -0
  125. package/templates/video/src/studies/timing.ts +53 -0
  126. package/templates/video/src/studies/variants.ts +39 -0
  127. package/templates/video/src/style.css +111 -0
  128. package/templates/video/src/timeline-model.ts +55 -0
  129. package/templates/video/style-source-provenance.json +11 -0
  130. package/templates/video/tsconfig.json +15 -0
  131. package/templates/video/vite.config.mjs +9 -0
  132. package/vendor/pixijs-skills/LICENSE +21 -0
  133. package/vendor/pixijs-skills/provenance.json +79 -0
  134. package/vendor/pixijs-skills/skills/pixijs/SKILL.md +66 -0
  135. package/vendor/pixijs-skills/skills/pixijs/references/index.md +136 -0
  136. package/vendor/pixijs-skills/skills/pixijs-accessibility/SKILL.md +224 -0
  137. package/vendor/pixijs-skills/skills/pixijs-application/SKILL.md +293 -0
  138. package/vendor/pixijs-skills/skills/pixijs-application/references/application-options.md +314 -0
  139. package/vendor/pixijs-skills/skills/pixijs-assets/SKILL.md +303 -0
  140. package/vendor/pixijs-skills/skills/pixijs-assets/references/background.md +137 -0
  141. package/vendor/pixijs-skills/skills/pixijs-assets/references/bundles.md +122 -0
  142. package/vendor/pixijs-skills/skills/pixijs-assets/references/caching.md +143 -0
  143. package/vendor/pixijs-skills/skills/pixijs-assets/references/compressed-textures.md +120 -0
  144. package/vendor/pixijs-skills/skills/pixijs-assets/references/fonts.md +205 -0
  145. package/vendor/pixijs-skills/skills/pixijs-assets/references/gif.md +171 -0
  146. package/vendor/pixijs-skills/skills/pixijs-assets/references/manifests.md +175 -0
  147. package/vendor/pixijs-skills/skills/pixijs-assets/references/progress.md +142 -0
  148. package/vendor/pixijs-skills/skills/pixijs-assets/references/resolution.md +142 -0
  149. package/vendor/pixijs-skills/skills/pixijs-assets/references/spritesheet.md +119 -0
  150. package/vendor/pixijs-skills/skills/pixijs-assets/references/svg.md +132 -0
  151. package/vendor/pixijs-skills/skills/pixijs-assets/references/video.md +158 -0
  152. package/vendor/pixijs-skills/skills/pixijs-blend-modes/SKILL.md +215 -0
  153. package/vendor/pixijs-skills/skills/pixijs-color/SKILL.md +299 -0
  154. package/vendor/pixijs-skills/skills/pixijs-core-concepts/SKILL.md +132 -0
  155. package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/render-loop.md +216 -0
  156. package/vendor/pixijs-skills/skills/pixijs-core-concepts/references/renderers.md +287 -0
  157. package/vendor/pixijs-skills/skills/pixijs-create/SKILL.md +276 -0
  158. package/vendor/pixijs-skills/skills/pixijs-custom-rendering/SKILL.md +405 -0
  159. package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/advanced-gpu.md +244 -0
  160. package/vendor/pixijs-skills/skills/pixijs-custom-rendering/references/uniform-types.md +94 -0
  161. package/vendor/pixijs-skills/skills/pixijs-environments/SKILL.md +243 -0
  162. package/vendor/pixijs-skills/skills/pixijs-events/SKILL.md +387 -0
  163. package/vendor/pixijs-skills/skills/pixijs-filters/SKILL.md +300 -0
  164. package/vendor/pixijs-skills/skills/pixijs-html-source/SKILL.md +228 -0
  165. package/vendor/pixijs-skills/skills/pixijs-math/SKILL.md +489 -0
  166. package/vendor/pixijs-skills/skills/pixijs-migration-v8/SKILL.md +415 -0
  167. package/vendor/pixijs-skills/skills/pixijs-performance/SKILL.md +489 -0
  168. package/vendor/pixijs-skills/skills/pixijs-scene-container/SKILL.md +345 -0
  169. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/SKILL.md +243 -0
  170. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/constructor-options.md +155 -0
  171. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/container-hierarchy.md +232 -0
  172. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/layers.md +145 -0
  173. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/masking.md +129 -0
  174. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/render-groups.md +140 -0
  175. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/scene-management.md +169 -0
  176. package/vendor/pixijs-skills/skills/pixijs-scene-core-concepts/references/transforms.md +198 -0
  177. package/vendor/pixijs-skills/skills/pixijs-scene-dom-container/SKILL.md +193 -0
  178. package/vendor/pixijs-skills/skills/pixijs-scene-gif/SKILL.md +233 -0
  179. package/vendor/pixijs-skills/skills/pixijs-scene-graphics/SKILL.md +576 -0
  180. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/SKILL.md +141 -0
  181. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-perspective.md +189 -0
  182. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-plane.md +159 -0
  183. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-rope.md +176 -0
  184. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh-simple.md +144 -0
  185. package/vendor/pixijs-skills/skills/pixijs-scene-mesh/references/mesh.md +213 -0
  186. package/vendor/pixijs-skills/skills/pixijs-scene-particle-container/SKILL.md +323 -0
  187. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/SKILL.md +120 -0
  188. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/animated-sprite.md +262 -0
  189. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/nineslice-sprite.md +202 -0
  190. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/sprite.md +181 -0
  191. package/vendor/pixijs-skills/skills/pixijs-scene-sprite/references/tiling-sprite.md +216 -0
  192. package/vendor/pixijs-skills/skills/pixijs-scene-text/SKILL.md +136 -0
  193. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/bitmap-text.md +232 -0
  194. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/html-text.md +192 -0
  195. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-bitmap-text.md +187 -0
  196. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/split-text.md +168 -0
  197. package/vendor/pixijs-skills/skills/pixijs-scene-text/references/text.md +311 -0
  198. package/vendor/pixijs-skills/skills/pixijs-ticker/SKILL.md +292 -0
@@ -0,0 +1,489 @@
1
+ ---
2
+ name: pixijs-performance
3
+ description: "Use this skill when profiling or optimizing a PixiJS v8 app for FPS, draw calls, or GPU memory. Covers destroy patterns (cacheAsTexture(false), releaseGlobalResources), GCSystem and TextureGCSystem, PrepareSystem, object pooling, batching rules, BitmapText for dynamic text, culling (Culler, CullerPlugin, cullable, cullArea), resolution/antialias tradeoffs, low-level wins (transient MSAA render textures, render bundles, partial buffer updates). Triggers on: FPS, jank, draw calls, batching, object pool, GCSystem, PrepareSystem, Culler, cacheAsTexture, memory leak, destroy patterns, render bundle, transient, MSAA, Buffer.update, WebGPU performance, TexturePool, repeatEdgePixels, bind group."
4
+ license: MIT
5
+ ---
6
+
7
+ Profile before optimizing. PixiJS handles a lot of content well out of the box; browser DevTools Performance + GPU profiling should be your first move. Once you've found the bottleneck, apply the targeted pattern below (destroy, pool, batch, cache, or cull).
8
+
9
+ ## Quick Start
10
+
11
+ ```ts
12
+ container.cacheAsTexture(true);
13
+ container.updateCacheTexture();
14
+ container.cacheAsTexture(false);
15
+ container.destroy({ children: true });
16
+
17
+ import { CullerPlugin, extensions } from "pixi.js";
18
+ extensions.add(CullerPlugin);
19
+
20
+ offscreenContainer.cullable = true;
21
+ offscreenContainer.cullArea = new Rectangle(0, 0, 256, 256);
22
+
23
+ // Tune GC via init options (ms). The `textureGC.*` properties are
24
+ // deprecated since 8.15.0 — use these on the Application init instead.
25
+ await app.init({ gcMaxUnusedTime: 60_000, gcFrequency: 30_000 });
26
+ ```
27
+
28
+ **Related skills:** `pixijs-scene-container` (destroy options), `pixijs-scene-core-concepts` (render groups, layers, culling), `pixijs-scene-text` (BitmapText for dynamic content), `pixijs-assets` (atlasing), `pixijs-custom-rendering` (custom batchers).
29
+
30
+ ## Core Patterns
31
+
32
+ ### Proper destroy with cleanup
33
+
34
+ ```ts
35
+ import { Sprite, Assets } from "pixi.js";
36
+
37
+ const texture = await Assets.load("character.png");
38
+ const sprite = new Sprite(texture);
39
+
40
+ // Destroy sprite only (preserve texture for reuse)
41
+ sprite.destroy();
42
+
43
+ // Destroy sprite AND its texture
44
+ sprite.destroy({ children: true, texture: true, textureSource: true });
45
+ ```
46
+
47
+ When done with a loaded asset entirely:
48
+
49
+ ```ts
50
+ Assets.unload("character.png");
51
+ ```
52
+
53
+ This removes it from the cache and unloads the GPU resource.
54
+
55
+ Objects you build for custom rendering clean up the same way: call `geometry.destroy()` and `renderTarget.destroy()` on the ones you create. Destroying a container also destroys the batchers cached for its render group.
56
+
57
+ ### Application destroy/recreate cycle
58
+
59
+ ```ts
60
+ import { Application } from "pixi.js";
61
+
62
+ // Correct destroy that cleans global pools
63
+ app.destroy({ releaseGlobalResources: true });
64
+
65
+ const newApp = new Application();
66
+ await newApp.init({ width: 800, height: 600 });
67
+ ```
68
+
69
+ Without `releaseGlobalResources: true`, pooled objects (batches, textures) from the old app leak into the new one, causing flickering and corruption.
70
+
71
+ ### Texture garbage collection
72
+
73
+ PixiJS auto-collects unused textures and GPU resources (including WebGPU bind groups) via `GCSystem`. Defaults: checks every 30 seconds, removes resources idle for 60 seconds. These are time-based (milliseconds).
74
+
75
+ ```ts
76
+ import { Application } from "pixi.js";
77
+
78
+ const app = new Application();
79
+
80
+ await app.init({
81
+ gcActive: true,
82
+ gcMaxUnusedTime: 120000, // idle time before cleanup in ms (default: 60000)
83
+ gcFrequency: 60000, // check interval in ms (default: 30000)
84
+ });
85
+ ```
86
+
87
+ For manual control:
88
+
89
+ ```ts
90
+ texture.source.unload(); // immediate GPU memory release
91
+ ```
92
+
93
+ ### PrepareSystem for GPU upload
94
+
95
+ Upload textures and graphics to GPU before rendering to avoid first-frame hitches:
96
+
97
+ ```ts
98
+ import "pixi.js/prepare";
99
+ import { Application, Assets } from "pixi.js";
100
+
101
+ const app = new Application();
102
+ await app.init();
103
+
104
+ // Don't render until assets are uploaded
105
+ app.stop();
106
+
107
+ const texture = await Assets.load("large-scene.png");
108
+
109
+ // Upload to GPU ahead of time
110
+ await app.renderer.prepare.upload(app.stage);
111
+
112
+ // Now rendering won't hitch on first frame
113
+ app.start();
114
+ ```
115
+
116
+ `prepare.upload()` accepts a Container (uploads all textures, text, and graphics in the subtree) or individual resources.
117
+
118
+ ### cacheAsTexture for performance
119
+
120
+ `cacheAsTexture()` renders a container's subtree to a single texture, reducing draw calls for complex static content. Internally it creates a render group and caches the result.
121
+
122
+ **When to use:**
123
+
124
+ - Many static children (UI panels, decorative backgrounds, complex Graphics)
125
+ - Containers with expensive filters (cache the filter result)
126
+ - Large subtrees that rarely change
127
+
128
+ **Tradeoffs:**
129
+
130
+ - Uses GPU memory for the cached texture (larger containers = more memory)
131
+ - Max texture size is GPU-dependent (typically 4096x4096 or larger). No PixiJS property exposes it, so query the backend directly:
132
+ - Must call `updateCacheTexture()` after modifying children
133
+ - Combining with masks is fragile (see the masking skill)
134
+
135
+ ```ts
136
+ import type { WebGLRenderer, WebGPURenderer } from "pixi.js";
137
+
138
+ // Available after renderer/app init on both backends
139
+ const maxTextureSize = renderer.name === "webgpu"
140
+ ? (renderer as WebGPURenderer).gpu.device.limits.maxTextureDimension2D
141
+ : (renderer as WebGLRenderer).gl.getParameter(WebGL2RenderingContext.MAX_TEXTURE_SIZE);
142
+ ```
143
+
144
+ ```ts
145
+ import { Container, Sprite } from "pixi.js";
146
+
147
+ const panel = new Container();
148
+ // ... add many static children ...
149
+
150
+ panel.cacheAsTexture(true);
151
+
152
+ // With options
153
+ panel.cacheAsTexture({ resolution: 2, antialias: true });
154
+
155
+ // Refresh after changes
156
+ panel.updateCacheTexture();
157
+
158
+ // MUST disable before destroying (see Common Mistakes below)
159
+ panel.cacheAsTexture(false);
160
+ panel.destroy();
161
+ ```
162
+
163
+ **Avoid:** toggling on/off repeatedly (constant re-caching negates benefits), caching sparse containers (negligible gain), caching containers larger than 4096x4096.
164
+
165
+ ### Object recycling
166
+
167
+ Reuse objects by changing their properties instead of destroy/recreate:
168
+
169
+ ```ts
170
+ import { Sprite, Container, Texture } from "pixi.js";
171
+
172
+ class BulletPool {
173
+ private _pool: Sprite[] = [];
174
+ private _container: Container;
175
+
176
+ constructor(container: Container) {
177
+ this._container = container;
178
+ }
179
+
180
+ public get(texture: Texture): Sprite {
181
+ let bullet = this._pool.pop();
182
+
183
+ if (!bullet) {
184
+ bullet = new Sprite(texture);
185
+ this._container.addChild(bullet);
186
+ }
187
+
188
+ bullet.texture = texture;
189
+ bullet.position.set(0, 0);
190
+ bullet.rotation = 0;
191
+ bullet.scale.set(1);
192
+ bullet.alpha = 1;
193
+ bullet.tint = 0xffffff;
194
+ bullet.blendMode = "normal";
195
+ bullet.visible = true;
196
+ return bullet;
197
+ }
198
+
199
+ public release(bullet: Sprite): void {
200
+ bullet.visible = false;
201
+ this._pool.push(bullet);
202
+ }
203
+ }
204
+ ```
205
+
206
+ Destroying and recreating is significantly more expensive than toggling `visible` and updating properties. GPU resources stay allocated; only scene graph visibility changes.
207
+
208
+ ### Batching optimization
209
+
210
+ PixiJS batches similar consecutive objects into single draw calls. Batch breaks occur on:
211
+
212
+ - Object type change (Sprite vs Graphics)
213
+ - Texture source change (beyond the per-batch texture limit, typically 16)
214
+ - Blend mode change
215
+ - Topology change
216
+
217
+ Optimize draw order:
218
+
219
+ ```ts
220
+ import { Sprite, Graphics, Container } from "pixi.js";
221
+
222
+ // 4 draw calls: type alternates
223
+ const bad = new Container();
224
+ bad.addChild(new Sprite(t1));
225
+ bad.addChild(new Graphics().rect(0, 0, 10, 10).fill(0xff0000));
226
+ bad.addChild(new Sprite(t2));
227
+ bad.addChild(new Graphics().rect(0, 0, 10, 10).fill(0x00ff00));
228
+
229
+ // 2 draw calls: types grouped
230
+ const good = new Container();
231
+ good.addChild(new Sprite(t1));
232
+ good.addChild(new Sprite(t2));
233
+ good.addChild(new Graphics().rect(0, 0, 10, 10).fill(0xff0000));
234
+ good.addChild(new Graphics().rect(0, 0, 10, 10).fill(0x00ff00));
235
+ ```
236
+
237
+ Same principle applies to blend modes: `screen/normal/screen/normal` = 4 draws; `screen/screen/normal/normal` = 2 draws.
238
+
239
+ ### Spritesheets over individual textures
240
+
241
+ ```ts
242
+ import { Assets, Sprite } from "pixi.js";
243
+
244
+ // Load a spritesheet (single texture atlas)
245
+ const sheet = await Assets.load("game-atlas.json");
246
+
247
+ // All frames share one GPU texture; enables batching
248
+ const hero = new Sprite(sheet.textures["hero.png"]);
249
+ const enemy = new Sprite(sheet.textures["enemy.png"]);
250
+ const coin = new Sprite(sheet.textures["coin.png"]);
251
+ ```
252
+
253
+ Individual textures each require their own GPU upload and break batches when the texture limit is exceeded. Spritesheets consolidate many frames into one atlas texture.
254
+
255
+ Use `@0.5x` filename suffix on half-resolution sheets so PixiJS auto-scales them.
256
+
257
+ ### Text performance
258
+
259
+ Text and HTMLText re-render to a canvas and re-upload to the GPU on every change. Never update them per frame unconditionally:
260
+
261
+ ```ts
262
+ import { BitmapText, Text } from "pixi.js";
263
+
264
+ // Wrong: re-renders canvas + GPU upload every frame
265
+ app.ticker.add(() => {
266
+ scoreText.text = `Score: ${score}`;
267
+ });
268
+
269
+ // Correct: use BitmapText for frequently changing content
270
+ const scoreText = new BitmapText({
271
+ text: "Score: 0",
272
+ style: { fontFamily: "Arial", fontSize: 24, fill: 0xffffff },
273
+ });
274
+
275
+ app.ticker.add(() => {
276
+ scoreText.text = `Score: ${score}`;
277
+ });
278
+ ```
279
+
280
+ BitmapText renders from a pre-generated glyph atlas. Updates only reposition quads; no canvas re-render or GPU upload. Use it for scores, timers, counters, and anything that changes frequently.
281
+
282
+ If you must use canvas Text, guard updates so they only happen when the value changes:
283
+
284
+ ```ts
285
+ app.ticker.add(() => {
286
+ const next = `Score: ${score}`;
287
+ if (scoreText.text !== next) {
288
+ scoreText.text = next;
289
+ }
290
+ });
291
+ ```
292
+
293
+ Text resolution matches the renderer resolution by default. Lower it independently via `text.resolution = 1` to reduce GPU memory on high-DPI displays.
294
+
295
+ ### Graphics performance
296
+
297
+ Graphics objects are fastest when their shape doesn't change (transforms, alpha, and tint are fine). Small Graphics (under ~100 points) are batched like Sprites. Complex Graphics with hundreds of shapes are slow; convert them to textures instead:
298
+
299
+ ```ts
300
+ import { Graphics, Sprite } from "pixi.js";
301
+
302
+ const complex = new Graphics();
303
+ // ... draw complex shape ...
304
+
305
+ // Render once to texture, use as Sprite
306
+ const texture = app.renderer.generateTexture(complex);
307
+ const sprite = new Sprite(texture);
308
+ ```
309
+
310
+ ### Culling
311
+
312
+ PixiJS skips rendering objects outside the visible area when `cullable` is set. Disabled by default because it trades CPU cost (bounds checking) for GPU savings. Culling only runs when the `CullerPlugin` is registered:
313
+
314
+ ```ts
315
+ import { extensions, CullerPlugin, Culler, Rectangle } from "pixi.js";
316
+
317
+ extensions.add(CullerPlugin); // before Application.init
318
+
319
+ // Enable on objects that may be off-screen
320
+ sprite.cullable = true;
321
+
322
+ // Optional: a pre-computed cull rectangle avoids per-frame bounds calculation.
323
+ // Without cullArea, the Culler uses the object's global bounds instead.
324
+ sprite.cullArea = new Rectangle(0, 0, 800, 600);
325
+
326
+ // Skip culling an entire subtree (static UI, always visible)
327
+ uiRoot.cullableChildren = false;
328
+
329
+ // Or cull manually without the plugin:
330
+ Culler.shared.cull(app.stage, app.renderer.screen);
331
+ ```
332
+
333
+ `cullableChildren` on a container stops the culler from recursing into its descendants; a large win for static UI panels with many children. `Culler.shared.cull(container, rect)` runs the same logic manually for custom render pipelines. Use culling when you're GPU-bound; avoid it when CPU-bound, since the per-object bounds check adds overhead.
334
+
335
+ ### Resolution and antialias tradeoffs
336
+
337
+ ```ts
338
+ import { Application } from "pixi.js";
339
+
340
+ const app = new Application();
341
+
342
+ // Mobile-friendly: lower resolution, no antialias
343
+ await app.init({
344
+ resolution: 1,
345
+ antialias: false,
346
+ backgroundAlpha: 1, // opaque background is faster
347
+ });
348
+ ```
349
+
350
+ `resolution: 2` quadruples the pixel count. On mobile, this can halve frame rate. Profile to find the right balance.
351
+
352
+ ### Low-level rendering optimizations
353
+
354
+ ```ts
355
+ import { RenderTexture } from "pixi.js";
356
+
357
+ // single-pass antialiased render texture: also discard its MSAA depth/stencil at end of pass
358
+ const rt = RenderTexture.create({ width: 1024, height: 1024, antialias: true, transient: true });
359
+
360
+ // upload only the changed byte range of a large buffer (also works on WebGL)
361
+ buffer.update(changedBytes, offsetBytes);
362
+
363
+ // upload only a texel range of a data texture (end is exclusive)
364
+ bufferImageSource.update(100, 116);
365
+ ```
366
+
367
+ On a tile-based WebGPU GPU (`renderer.device.extensions.tileBased`: every phone GPU and Apple silicon) the multisample colour buffer of every antialiased target is already discarded instead of written back, and a pass that reopens the target restores it from the resolved image; the buffer may not be allocated at all when `renderer.device.extensions.transientAttachment` is true. `transient: true` additionally discards the multisample depth/stencil buffer, and the colour buffer on other GPUs. Only use it on textures rendered in a single pass and never re-entered with `clear: false` or wrapped by a filter or mask. For static custom draw sequences on WebGPU, record a render bundle once and replay it each frame; see the `pixijs-custom-rendering` skill.
368
+
369
+ ### Stagger bulk texture destruction
370
+
371
+ ```ts
372
+ function staggerDestroy(textures: Texture[], perFrame: number = 5): void {
373
+ let index = 0;
374
+ const ticker = app.ticker;
375
+
376
+ const destroy = () => {
377
+ const end = Math.min(index + perFrame, textures.length);
378
+
379
+ for (let i = index; i < end; i++) {
380
+ textures[i].destroy(true);
381
+ }
382
+ index = end;
383
+
384
+ if (index >= textures.length) {
385
+ ticker.remove(destroy);
386
+ }
387
+ };
388
+
389
+ ticker.add(destroy);
390
+ }
391
+ ```
392
+
393
+ Destroying many textures in one frame causes a freeze. Spread the cost across frames.
394
+
395
+ ### Filters and masks cost
396
+
397
+ - Set `container.filterArea = new Rectangle(x, y, w, h)` when you know the bounds. Without it, PixiJS measures bounds every frame.
398
+ - Release filter memory: `container.filters = null`.
399
+ - Full-screen filter textures are pooled at screen size, but padding (the `BlurFilter` default) pushes the request past the screen and up to the next power of two. Set `repeatEdgePixels: true` on full-screen blurs to keep them screen-sized.
400
+ - Mask cost (cheapest to most expensive): axis-aligned Rectangle masks (scissor rect) < Graphics masks (stencil buffer) < Sprite/alpha masks (filter pipeline). Hundreds of masks will slow things down regardless of type; prefer rectangle masks when bounds are axis-aligned.
401
+ - Set `interactiveChildren = false` on containers with no interactive children.
402
+ - Set `hitArea` on large containers to skip recursive child hit testing.
403
+
404
+ ### Safe destroy order
405
+
406
+ Remove from scene before destroying:
407
+
408
+ ```ts
409
+ parent.removeChild(sprite);
410
+ sprite.destroy();
411
+ ```
412
+
413
+ Destroying while the render pipeline still holds a reference causes null-pointer crashes. If destruction must happen mid-frame, defer it:
414
+
415
+ ```ts
416
+ app.ticker.addOnce(() => {
417
+ parent.removeChild(sprite);
418
+ sprite.destroy();
419
+ });
420
+ ```
421
+
422
+ ## Common Mistakes
423
+
424
+ ### [CRITICAL] App destroy without releaseGlobalResources
425
+
426
+ Wrong:
427
+
428
+ ```ts
429
+ app.destroy();
430
+ const newApp = new Application();
431
+ ```
432
+
433
+ Correct:
434
+
435
+ ```ts
436
+ app.destroy({ releaseGlobalResources: true });
437
+ const newApp = new Application();
438
+ ```
439
+
440
+ Without this flag, stale pooled batches and textures from the old app persist in global pools and get reused by the new app, causing flickering and visual corruption.
441
+
442
+
443
+ ### [HIGH] Interleaving object types in scene graph
444
+
445
+ `sprite / graphic / sprite / graphic` = 4 draw calls.
446
+ `sprite / sprite / graphic / graphic` = 2 draw calls.
447
+
448
+ Group same object types together in the child order to minimize batch breaks. Same applies to blend mode ordering.
449
+
450
+
451
+ ### [HIGH] Destroying and recreating objects instead of recycling
452
+
453
+ Destroy/recreate is expensive: it deallocates GPU resources, triggers garbage collection, and requires fresh GPU uploads. Reuse objects by updating `texture`, `position`, `visible`, and other properties. Use an object pool pattern for frequently spawned/despawned entities.
454
+
455
+
456
+ ### [HIGH] Loading many individual textures instead of spritesheets
457
+
458
+ Each separate texture consumes its own GPU memory slot and breaks batching when the per-batch texture limit is reached. Spritesheets consolidate textures into atlases. Also avoid textures exceeding 4096px on either axis, as they fail on some mobile GPUs.
459
+
460
+
461
+ ### [HIGH] Updating Text or HTMLText every frame
462
+
463
+ Each update re-renders the full string to a canvas and uploads to the GPU. At 60fps this creates massive overhead. Use BitmapText for dynamic content (scores, timers, counters). If canvas Text is required, only update when the value actually changes. Source: src/**docs**/concepts/performance-tips.md
464
+
465
+ ### [HIGH] Using complex Graphics instead of textures
466
+
467
+ Hundreds of complex Graphics objects are slow to render. Small Graphics (under ~100 points) batch efficiently like Sprites, but complex ones do not. Render complex static shapes to a texture with `renderer.generateTexture()` and display as a Sprite. Source: src/**docs**/concepts/performance-tips.md
468
+
469
+ ### [MEDIUM] Not staggering bulk texture destruction
470
+
471
+ Destroying dozens of textures in a single frame causes a visible freeze. Spread destruction across multiple frames (e.g., 5 per frame via a ticker callback). Source: src/**docs**/concepts/garbage-collection.md
472
+
473
+ ### [MEDIUM] Not using PrepareSystem for large scenes
474
+
475
+ Without `renderer.prepare.upload()`, textures upload to the GPU on first render, causing frame hitches. For loading screens or scene transitions, upload before displaying. Requires `import 'pixi.js/prepare'` (not included even in the default bundle; always import it explicitly). Source: src/prepare/PrepareSystem.ts
476
+
477
+ ### [MEDIUM] Using high resolution or antialias without profiling
478
+
479
+ `resolution: 2` quadruples the pixel count. `antialias: true` adds GPU cost. Both degrade performance on mobile devices. Always profile on target hardware before enabling. Source: performance-tips.md
480
+
481
+ ## API Reference
482
+
483
+ - [GCSystem](https://pixijs.download/release/docs/rendering.GCSystem.html.md)
484
+ - [TextureGCSystem](https://pixijs.download/release/docs/rendering.TextureGCSystem.html.md)
485
+ - [RenderableGCSystem](https://pixijs.download/release/docs/rendering.RenderableGCSystem.html.md)
486
+ - [PrepareSystem](https://pixijs.download/release/docs/rendering.PrepareSystem.html.md)
487
+ - [Culler](https://pixijs.download/release/docs/scene.Culler.html.md)
488
+ - [CullerPlugin](https://pixijs.download/release/docs/app.CullerPlugin.html.md)
489
+ - [Pool](https://pixijs.download/release/docs/utils.Pool.html.md)