JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/GoodBoyDigital/pixi.js/dev/bin/pixi.js"></script>
aaaa
JavaScript
var renderer,r,g,bunny,stage,ani;
function init() {
renderer= new PIXI.autoDetectRenderer( 100,100, {backgroundColor:0});
stage= new PIXI.Container();
bunny = PIXI.Sprite.fromImage('http://pixijs.github.io/examples/_assets/basics/bunny.png');
g= new PIXI.Graphics, r;
g.beginFill(0);
r= g.drawRect(0,0,100,100);
stage.addChild(r);
bunny.position.x=50, bunny.position.y=50;
bunny.anchor.x=0.5, bunny.anchor.y=0.5;
stage.addChild(bunny);
r.interactive=true;
r.on('mousedown', onDown);
document.body.appendChild( renderer.view );
animate();
console.log(performance.memory.usedJSHeapSize);
}
function onDown() { // teardown
if (ani) cancelAnimationFrame(ani);
r.off('mousedown', onDown);
stage.removeChild(r), r= null;
stage.removeChild(bunny), stage= null;
g.destroy(), g= null;
bunny.destroy(), bunny= null;
document.body.removeChild( renderer.view );
renderer.destroy(), renderer= null;
init();
}
init();
function animate() {
ani=null;
bunny.rotation+=0.01;
ani= requestAnimationFrame(animate);
renderer.render(stage);
}