Search the Community
Showing results for tags 'pixijs v6'.
-
I'm starting to use recently pixijsv6.5.0 and I can't put an image in the graphics when click on, but I can change the color by .tint graphics.tint = swapS ? '0x00ff00' : '0xff0000'; Repository: https://github.com/DevAndreAkira/jogo_velha/blob/master/js/script.js How can I use image in place of colors?
-
I wrote a demo in PixiJS 6.2.2. After I destroyed everything I know, Google Chrome Helper (Renderer)'s memory was still a few hundred megabytes in the activity monitor. Is there anything I haven't destroyed? The general process is as follows. Open demo in Chrome(40+MB Memory)->Select a 8K image(800+MB Memory)->Run destroyAll(400+MB Memory). If you have any ideas, please let me know. Thanks. Operating system: macOS 10.15.6. Browser: Google Chrome 107.0.5304.110 Demo: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/> </head> <body> <script src="https://pixijs.download/v6.2.2/pixi.js"></script> <script> let canvasWidth = 1000 let canvasHeight = 800 const app = new PIXI.Application({ width: canvasWidth, height: canvasHeight, backgroundColor: 0x1099bb}); document.body.appendChild(app.view); let scaleRatio = 0.1 let originTexture let mainSprite function init(o){ originTexture = o mainSprite = new PIXI.Sprite(originTexture) mainSprite.x = 0 mainSprite.y = 0; mainSprite.width = originTexture.width * scaleRatio; mainSprite.height = originTexture.height * scaleRatio; app.stage.addChild(mainSprite) } function changeFile(e){ let src = URL.createObjectURL(e[0]) let originTextureLoader = PIXI.Texture.fromLoader(src) originTextureLoader.then((o)=>{ URL.revokeObjectURL(src) originTexture && originTexture.destroy(true) mainSprite && mainSprite.destroy({children:true, texture:true, baseTexture:true}) originTextureLoader = null init(o) }) } function destroyAll() { document.body.removeChild(app.view) originTexture && originTexture.destroy(true) mainSprite && mainSprite.destroy({children:true, texture:true, baseTexture:true}) PIXI.utils.destroyTextureCache() app.renderer.gl.getExtension('WEBGL_lose_context').loseContext() app.destroy(true, {children:true, texture:true, baseTexture:true}) } </script> <div> <label> Select Image: <input type="file" onchange="changeFile(this.files)" /> </label> <button onclick="destroyAll()">destroy</button> </div> </body> </html>