I built a simple PIXI.js app to implement PIXI.RenderTexture, and it doesn't work.
It should render two square sprites, black and white. The black one is added with regular stage.addChild
:
const sprite1 = new PIXI.Sprite(PIXI.Texture.from('bc-sq-200.png'));
sprite1.x = 500;
app.stage.addChild(sprite1);
The white one is supposed to be rendered with renderTexture
:
const sprite2 = new PIXI.Sprite(PIXI.Texture.from('wt-sq-200.png'));
// app.stage.addChild(sprite2);
const renderer = PIXI.autoDetectRenderer();
const renderTexture = PIXI.RenderTexture.create({ width: 700, height: 700 });
renderer.render(sprite2, { renderTexture });
const mainSprite = PIXI.Sprite.from(renderTexture);
app.stage.addChild(mainSprite);
However, only the black square can be seen.
What could be the problem? What is going wrong?
Minimal example Github repo: https://github.com/poludnev/test-pixi-render-texture