I'm trying to load multiple sprites and display them in PIXI.js. The filenames are are contained in a JSON manifest, which I fetch, then pass to loader. Despite loading successfully (I can see requests being made in inspector), they are never shown on PIXI stage. The code is contained in two files.
background.js:
import * as PIXI from 'pixi.js';
import axios from 'axios';
const loader = PIXI.Loader.shared;
const ticker = PIXI.Ticker.shared;
const paintMovingSprite = ({ resource, container, surfaceWidth, surfaceHeight }) => {
  let texture = new PIXI.Sprite(resource.texture);
  let ratio = (surfaceHeight / texture.height / 3) * Math.random();
  texture.width = texture.width * ratio + 50;
  texture.height = texture.height * ratio + 50;
  texture.x = Math.random() * surfaceWidth - texture.width / 2;
  texture.y = Math.random() * surfaceHeight - texture.height / 2;
  return texture;
};
const renderBackground = ({ fileNames, surfaceWidth, surfaceHeight }) => {
  return new Promise((resolve, reject) => {
    const container = new PIXI.Container();
    loader.add(fileNames).load((_, resources) => {
      Object.keys(resources).forEach(resource => {
        container.addChild(
          paintMovingSprite({ resource, surfaceWidth, surfaceHeight })
        );
      });
      const testG = new PIXI.Graphics();
      testG.beginFill(0xFFFF00);
      testG.lineStyle(5, 0xFF0000);
      testG.drawRect(0, 0, 300, 200);
      console.log(container);
      container.addChild(testG);
      return resolve(container);
     });
  });
};
export { renderBackground };
The interesting thing here is that the test rectangle graphic renders successfully and the container contains all the children it should (one per image).
import * as PIXI from 'pixi.js';
import axios from 'axios';
import * as Menu from './menu.js';
import * as Background from './background.js';
PIXI.utils.sayHello();
const app = new PIXI.Application({
  width: window.innerWidth,
  height: window.innerHeight,
  backgroundColor: 0xffffff,
  autoResize: true,
});
document.body.appendChild(app.view);
/* config */
app.renderer.backgroundColor = 0x33ff3f;
app.stage.sortableChildren = true;
let fileNames = null; 
const renderPage = () => {
  axios.get('assets/asset-data.json').then((resp) => {
    fileNames = resp.data['mix12'];
  Background.renderBackground({
       fileNames, 
       surfaceWidth: app.renderer.width,
       surfaceHeight: app.renderer.height,
    }).then(container => {
      // container object here looks correct and contains all the children
      app.stage.addChild(container);
    });
  });
};
renderPage();
I'm new to the framework, so might be missing something rudimentary.
Thanks.
 
    