Search code examples
javascripttexturesassetspixi.js

Pixijs 7 load texture via Asset background loading


I am getting stuck on loading a texture via pixi 7 new Asset package. What I want to do is loading the ressource (png file) via asset loader. Then create a TilingSprite with the loaded ressource as texture. The following code will never finish:

  const textureFromAsset = PIXI.Texture.from(assets.tiles);
  const gridFromAsset = new PIXI.TilingSprite(textureFromAsset, 250, 250);
  app.stage.addChild(gridFromAsset);

The ressource is loaded and shown correctly by using a Sprite. How can I load textures via pixi asset loader?

A full codepen example is here


Solution

  • Qick Solution: There is no need to create an extra texture. The asset can go as texture:

    const gridFromAsset = new PIXI.TilingSprite(assets.tiles, 250, 250);