Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

pixi.jsのcontainerからテクスチャーを作る

pixi.jsのcontainerからtextureをつくるやり方です。
こんな感じのクラスを作ってみました。

class ContainerToTexture {
  private width: number;
  private height: number;
  private texture: PIXI.RenderTexture;
  constructor(width: number, height: number){
    this.resize(width, height);
  }
  /**
   * コンテナをテクスチャーに変換する
   * @param container 変換するcontainer
   * @returns 生成したテクスチャー
   */
  public convert(container: PIXI.Container){
    core.app.renderer.render(container, this.texture);//rendererをお使いにの場所に変えてください
    return this.texture;
  }
  //テクスチャーのサイズを変更
  public resize(width: number, height: number){
    this.width = width;
    this.height = height;
    this.texture = new PIXI.RenderTexture(
      new PIXI.BaseRenderTexture({width: width, height: height})
    );
  }
}

幅と高さを指定してクラスを作ってconvert()で変換したいcontainerを渡してやるとテクスチャーになって返ってきます。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?