Internal class used to cache rendered results to avoid duplicated rendering.

This class can be used to improve performance when rendering block references. Because different colors will result in different materials, the block name and color are used together to create the cache key.

const cache = AcDbRenderingCache.instance;
const key = cache.createKey('MyBlock', 0xFF0000);
const renderedEntity = cache.draw(renderer, blockRecord, 0xFF0000);

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Creates a cache key by combining the block name and color.

    Parameters

    • name: string

      The block name

    • color: number

      The color value

    Returns string

    A unique key for the cache entry

    const key = cache.createKey('MyBlock', 0xFF0000);
    // Returns: "MyBlock_16711680"
  • Draws a block table record and optionally caches the result.

    This method renders the block table record using the specified renderer and color, and optionally stores the result in the cache for future use.

    Parameters

    • renderer: AcGiRenderer<AcGiEntity>

      The renderer to use for drawing

    • blockTableRecord: AcDbBlockTableRecord

      The block table record to draw

    • color: number

      The color to use for rendering

    • cache: boolean = true

      Whether to cache the rendering result (default: true)

    • Optionaltransform: AcGeMatrix3d

      Optional transformation matrix to apply

    • Optionalnormal: AcGeVector3d

      Optional normal vector

    Returns undefined | AcGiEntity

    The rendered entity

    const renderedEntity = cache.draw(
    renderer,
    blockRecord,
    0xFF0000,
    true,
    transform,
    normal
    );
  • Gets rendering results with the specified key.

    Parameters

    • name: string

      The key of the rendering results

    Returns undefined | AcGiEntity

    The rendering results with the specified key, or undefined if not found

    const cachedEntity = cache.get('MyBlock_16711680');
    if (cachedEntity) {
    // Use cached entity
    }
  • Checks if rendering results with the specified key exist in the cache.

    Parameters

    • name: string

      The key to check

    Returns boolean

    True if the key exists in the cache, false otherwise

    if (cache.has('MyBlock_16711680')) {
    console.log('Cached result found');
    }