8Observer8 Posted October 12, 2019 Share Posted October 12, 2019 Hello, Where can I find the information why this code does not work: //If you ever need to, here's how you can clean out WebGL's GPU //memory manually Object.keys(PIXI.utils.TextureCache).forEach((texture) => { PIXI.utils.TextureCache[texture].destroy(true); }); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 12, 2019 Share Posted October 12, 2019 It should work. Do the debug Also we have that method in "utils" already Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted October 12, 2019 Author Share Posted October 12, 2019 Error message: Quote Sprite.js:264 Uncaught TypeError: Cannot read property 'width' of null at e.calculateVertices (Sprite.js:264) at e._render (Sprite.js:361) at e.render (Container.js:503) at e.render (Container.js:508) at e.render (Renderer.js:361) at t.mo.render (Application.js:95) at ze.emit (TickerListener.js:96) at Ve.update (Ticker.js:443) at Ve._tick (Ticker.js:158) Full code: import * as PIXI from "pixijs"; export default class Game { private _app: PIXI.Application; public constructor() { //Create a Pixi Application this._app = new PIXI.Application({ width: 256, height: 256, antialias: true, transparent: false, resolution: 1 }); //Add the canvas that Pixi automatically created for you to the HTML document document.body.appendChild(this._app.view); //load an image and run the `setup` function when it's done PIXI.Loader.shared.load() .add("images/cat.png") .load(() => this.Setup()); } //This `setup` function will run when the image has loaded private Setup(): void { //Create the cat sprite let cat = new PIXI.Sprite(PIXI.Loader.shared.resources["images/cat.png"].texture); //You can also create the `cat` sprite from the texture, like this: // let cat = new PIXI.Sprite(PIXI.utils.TextureCache["images/cat.png"]); //Add the cat to the stage this._app.stage.addChild(cat); // This code does not work //If you ever need to, here's how you can clean out WebGL's GPU //memory manually Object.keys(PIXI.utils.TextureCache).forEach((texture) => { PIXI.utils.TextureCache[texture].destroy(true); }); } } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 12, 2019 Share Posted October 12, 2019 Well, you destroyed texture but sprite still has link to it and when app renders-> sprite renders->goodbye. There's no way to set all sprite texture to null when you destroy texture. If we make mechanism like that, it will REQUIRE everyone to use destroy() on sprites which is not requirement right now. 8Observer8 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.