How to use the @pixi/core.BaseTexture.addToCache function in @pixi/core

To help you get started, we’ve selected a few @pixi/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixijs / pixi.js / packages / mixin-cache-as-bitmap / src / index.js View on Github external
const cacheAlpha = this.alpha;

    this.alpha = 1;

    const cachedRenderTarget = renderer.context;

    bounds.ceil(settings.RESOLUTION);

    const renderTexture = RenderTexture.create(bounds.width, bounds.height);

    const textureCacheId = `cacheAsBitmap_${uid()}`;

    this._cacheData.textureCacheId = textureCacheId;

    BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId);
    Texture.addToCache(renderTexture, textureCacheId);

    // need to set //
    const m = _tempMatrix;

    this.transform.localTransform.copyTo(m);
    m.invert();

    m.tx -= bounds.x;
    m.ty -= bounds.y;

    // m.append(this.transform.worldTransform.)
    // set all properties to there original so we can render to a texture
    this.renderCanvas = this._cacheData.originalRenderCanvas;

    // renderTexture.render(this, m, true);
github pixijs / pixi.js / packages / mixin-cache-as-bitmap / src / index.js View on Github external
bounds.ceil(settings.RESOLUTION);

    // for now we cache the current renderTarget that the WebGL renderer is currently using.
    // this could be more elegant..
    const cachedRenderTarget = renderer._activeRenderTarget;
    // We also store the filter stack - I will definitely look to change how this works a little later down the line.
    // const stack = renderer.filterManager.filterStack;

    // this renderTexture will be used to store the cached DisplayObject
    const renderTexture = RenderTexture.create(bounds.width, bounds.height);

    const textureCacheId = `cacheAsBitmap_${uid()}`;

    this._cacheData.textureCacheId = textureCacheId;

    BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId);
    Texture.addToCache(renderTexture, textureCacheId);

    // need to set //
    const m = _tempMatrix;

    m.tx = -bounds.x;
    m.ty = -bounds.y;

    // reset
    this.transform.worldTransform.identity();

    // set all properties to there original so we can render to a texture
    this.render = this._cacheData.originalRender;

    renderer.render(this, renderTexture, true, m, true);
    // now restore the state be setting the new properties