Galious Posted September 14, 2021 Share Posted September 14, 2021 (edited) Hello! When extending the sprite class and using it instead of adding the default sprite the performance becomes really bad. // Using this reduces the performance a lot after 5k+ sprites: class Car extends Sprite { constructor() { super(); this.texture = Texture.from("/car.png"); this.interactive = true; this.anchor.set(0.5, 0.5); //... other manipulation } } app.stage.addChild(new Car()) // compared to this (nearly no performance loss even after 50k+ sprites): function addCar(app) { const sprite = new Sprite() sprite.texture = Texture.from("/car.png"); sprite.interactive = true; sprite.anchor.set(0.5, 0.5); //... other manipulation } app.stage.addChild(addCar(app)) What could be the reason for this? Edited September 14, 2021 by Galious Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 14, 2021 Share Posted September 14, 2021 Sorry, was in train, couldnt answer due to bad internet https://github.com/pixijs/pixijs/issues/7771 Welcome to modern JS builders. Galious 1 Quote Link to comment Share on other sites More sharing options...
Galious Posted September 15, 2021 Author Share Posted September 15, 2021 Thank you! I am using PixiJS with NextJS, exporting the pixi code to a different module and compiling it to ES5 works fine now. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.