Loading...
Loading...
Use this skill when upgrading to PixiJS v8 from v7 or diagnosing broken v7 code after an upgrade. Covers async app.init, single pixi.js package (deprecated @pixi/* sub-packages), Graphics shape-then-fill, BaseTexture → TextureSource, shader/uniform rework, ParticleContainer+Particle, constructor options objects, DisplayObject removal, settings/utils removal, Ticker signature, events rewrite. Triggers on: migrate v7, v8 breaking changes, @pixi/ import, DisplayObject, beginFill, endFill, cacheAsBitmap, BaseTexture, deprecated.
npx skill4agent add pixijs/pixijs-skills pixijs-migration-v8const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
const g = new Graphics()
.rect(0, 0, 100, 100)
.fill({ color: 0xff0000 })
.stroke({ width: 2, color: 0x000000 });
app.stage.addChild(g);pixijs-applicationpixijs-scene-graphicspixijs-custom-renderingpixijs-scene-textpixijs-performanceconst app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);new Application({...})app.viewnew Application<Renderer<HTMLCanvasElement>>()new Application<HTMLCanvasElement>()import { Sprite, Application, Assets, Graphics } from "pixi.js";@pixi/*@pixi/sound@pixi/*@pixi/accessibility@pixi/app@pixi/assets@pixi/compressed-textures@pixi/core@pixi/display@pixi/events@pixi/extensions@pixi/extract@pixi/filter-alpha@pixi/filter-blur@pixi/filter-color-matrix@pixi/filter-displacement@pixi/filter-fxaa@pixi/filter-noise@pixi/graphics@pixi/mesh@pixi/mesh-extras@pixi/mixin-cache-as-bitmap@pixi/mixin-get-child-by-name@pixi/mixin-get-global-position@pixi/particle-container@pixi/prepare@pixi/sprite@pixi/sprite-animated@pixi/sprite-tiling@pixi/spritesheet@pixi/text@pixi/text-bitmap@pixi/text-htmlskipExtensionImports: trueimport "pixi.js/graphics";
import "pixi.js/text";
import "pixi.js/events";
import { Application } from "pixi.js";
await app.init({ skipExtensionImports: true });manageImports: false@deprecated since 8.1.6skipExtensionImports: truepixi.js/advanced-blend-modespixi.js/unsafe-evalpixi.js/preparepixi.js/math-extraspixi.js/ddspixi.js/ktxpixi.js/ktx2pixi.js/basisimport { AdjustmentFilter } from 'pixi-filters/adjustment'@pixi/filter-adjustmentconst g = new Graphics().rect(50, 50, 100, 100).fill(0xff0000);beginFill(0xff0000).drawRect(50, 50, 100, 100).endFill()| v7 | v8 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
graphics
.rect(0, 0, 100, 100)
.fill({ texture: Texture.WHITE, alpha: 0.5, color: 0xff0000 });beginFill(color, alpha)beginTextureFill({ texture, alpha, color })graphics.rect(0, 0, 100, 100).fill("blue").stroke({ width: 2, color: "white" });lineStyle(2, 'white')lineTextureStyle({ texture, width, color })graphics.rect(0, 0, 100, 100).fill(0x00ff00).circle(50, 50, 20).cut();beginHole()endHole()const context = new GraphicsContext().rect(0, 0, 100, 100).fill(0xff0000);
const g1 = new Graphics(context);
const g2 = new Graphics(context);new Graphics(graphics.geometry)const text = new Text({ text: "Hello", style: { fontSize: 24 } });
const bmp = new BitmapText({ text: "Hello", style: { fontFamily: "MyFont" } });
const html = new HTMLText({ text: "<b>Hello</b>", style: { fontSize: 24 } });new Text('Hello', { fontSize: 24 })import 'pixi.js/text-bitmap'Assets.load('font.fnt')await Assets.load('image.png')Texture.from('image.png')const ns = new NineSliceSprite({
texture,
leftWidth: 10,
topHeight: 10,
rightWidth: 10,
bottomHeight: 10,
});SimpleMeshMeshSimpleSimplePlaneMeshPlaneSimpleRopeMeshRopeconst geom = new MeshGeometry({
positions: vertices,
uvs,
indices,
topology: "triangle-list",
});new MeshGeometry(vertices, uvs, indices)const container = new ParticleContainer({
boundsArea: new Rectangle(0, 0, 800, 600),
});
const particle = new Particle(texture);
container.addParticle(particle);container.addChild(new Sprite(texture))sprite.eventMode = "static";
sprite.cursor = "pointer";
sprite.on("pointertap", () => {
/* handle */
});sprite.interactive = true;eventMode = 'static'eventMode'passive''static''dynamic'app.ticker.add((ticker) => {
bunny.rotation += ticker.deltaTime;
});app.ticker.add((dt) => { bunny.rotation += dt; })dtTickerNaNthis.onRender = this._onRender.bind(this)const shader = Shader.from({
gl: { vertex: vertexSrc, fragment: fragmentSrc },
resources: {
myUniforms: new UniformGroup({ uTime: { value: 0, type: "f32" } }),
},
});Shader.from(vertex, fragment, uniforms)const filter = new Filter({
glProgram: GlProgram.from({ fragment, vertex }),
resources: { filterUniforms: { uTime: { value: 0, type: "f32" } } },
});new Filter(vertex, fragment, { uTime: 0 })new UniformGroup({ uTime: { value: 1, type: 'f32' } })new UniformGroup({ uTime: 1 })texture.sourcetexture.styletexture.update()sprite.onViewUpdate()texture.frame.width = texture.frame.width / 2;
texture.update(); // recalculate texture UVs first
sprite.onViewUpdate(); // then refresh the sprite's displayBaseTexture.mipmapautoGenerateMipmapsconst rt = RenderTexture.create({
width: 100,
height: 100,
autoGenerateMipmaps: true,
});
renderer.render({ target: rt, container: scene });
rt.source.updateMipmaps();import { DOMAdapter, WebWorkerAdapter } from "pixi.js";
DOMAdapter.set(WebWorkerAdapter);
DOMAdapter.get().createCanvas();settings.ADAPTER = WebWorkerAdapter; settings.ADAPTER.createCanvas();BrowserAdapterWebWorkerAdapterContainerclass MyObj extends DisplayObjectSpriteGraphicsMeshTextContainercontainer.namecontainer.labelcontainer.cacheAsBitmap = truecontainer.cacheAsTexture(true)getBounds()BoundsRectangleBounds.x.y.width.height.rectangleRectangle.contains()AbstractRenderer.defaultOptions.resolution = 1DOMAdapter.set(BrowserAdapter)import { isMobile } from 'pixi.js'utils.isMobileTextFormatbitmapFontTextParserXMLStringFormatbitmapFontXMLStringParserXMLFormatbitmapFontXMLParserAssets.add({ alias: 'bunny', src: 'bunny.png' })Assets.add('bunny', 'bunny.png')| v7 | v8 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
cullable = trueCuller.shared.cull(container, viewRect)CullerPluginextensions.add(CullerPlugin)@pixi/*@pixi/sound@pixi/*pixi.jsnew Application({...})await app.init({...}){gl, resources}ParticleSpriteticker.deltaTimeeventModeinteractivesettingsutilsDisplayObjectContainersprite.onViewUpdate()source.updateMipmaps()settings.ADAPTERDOMAdapter.set()import { Sprite } from "@pixi/sprite";
import { Application } from "@pixi/app";import { Sprite, Application } from "pixi.js";pixi.js@pixi/*@pixi/soundclass MyObject extends DisplayObject { ... }class MyObject extends Container { ... }DisplayObjectContainertexture.source.scaleMode = SCALE_MODES.NEAREST;texture.source.scaleMode = 'nearest';interactive = trueeventModesprite.interactive = true;eventMode = 'static'sprite.eventMode = 'static';eventMode'passive''static''dynamic'interactive = trueeventModeimport { utils } from 'pixi.js'; utils.isMobile.any();import { isMobile } from 'pixi.js'; isMobile.any();utilstexture.framesprite.onViewUpdate()