How to use @here/harp-lrucache - 3 common examples

To help you get started, we’ve selected a few @here/harp-lrucache 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 heremaps / harp.gl / @here / harp-text-canvas / lib / rendering / GlyphTextureCache.ts View on Github external
if (this.m_textureSize.y > MAX_TEXTURE_SIZE || this.m_textureSize.x > MAX_TEXTURE_SIZE) {
            // tslint:disable-next-line:no-console
            console.warn(
                "GlyphTextureCache texture size (" +
                    this.m_textureSize.x +
                    ", " +
                    this.m_textureSize.y +
                    ") exceeds WebGL's widely supported MAX_TEXTURE_SIZE (" +
                    MAX_TEXTURE_SIZE +
                    ").\n" +
                    "This could result in rendering errors on some devices.\n" +
                    "Please consider reducing its capacity or input assets size."
            );
        }

        this.m_entryCache = new LRUCache(capacity);
        this.initCacheEntries();

        this.m_scene = new THREE.Scene();
        this.m_camera = new THREE.OrthographicCamera(
            0,
            this.m_textureSize.x,
            this.m_textureSize.y,
            0
        );
        this.m_camera.position.z = 1;
        this.m_camera.updateMatrixWorld(false);
        this.m_rt = new THREE.WebGLRenderTarget(this.m_textureSize.x, this.m_textureSize.y, {
            wrapS: THREE.ClampToEdgeWrapping,
            wrapT: THREE.ClampToEdgeWrapping,
            depthBuffer: false,
            stencilBuffer: false
github heremaps / harp.gl / @here / harp-mapview / lib / VisibleTileSet.ts View on Github external
constructor(
        cacheSize: number,
        rct: ResourceComputationType = ResourceComputationType.EstimationInMb
    ) {
        this.m_resourceComputationType = rct;
        this.m_tileCache = new LRUCache(cacheSize, (tile: Tile) => {
            if (this.m_resourceComputationType === ResourceComputationType.EstimationInMb) {
                // Default is size in MB.
                return tile.memoryUsage * MB_FACTOR;
            } else {
                return 1;
            }
        });
        this.m_tileCache.evictionCallback = (_, tile) => {
            if (tile.tileLoader !== undefined) {
                // Cancel downloads as early as possible.
                tile.tileLoader.cancel();
            }
            this.m_disposedTiles.push(tile);
        };
        this.m_tileCache.canEvict = (_, tile) => {
            // Tiles can be evicted that weren't requested in the last frame.
github heremaps / harp.gl / @here / harp-mapview-decoder / lib / TileDataSource.ts View on Github external
this.m_decoder = m_options.decoder;
        } else if (m_options.concurrentDecoderServiceName) {
            this.m_decoder = ConcurrentDecoderFacade.getTileDecoder(
                m_options.concurrentDecoderServiceName,
                m_options.concurrentDecoderScriptUrl,
                m_options.concurrentDecoderWorkerCount
            );
        } else {
            throw new Error(
                `TileDataSource[${this.name}]: unable to create, missing decoder or ` +
                    `concurrentDecoderServiceName`
            );
        }
        this.useGeometryLoader = true;
        this.cacheable = true;
        this.m_tileLoaderCache = new LRUCache(this.getCacheCount());
        this.m_tileLoaderCache.evictionCallback = (_, tileLoader) => {
            // Cancel any pending downloads as early as possible.
            tileLoader.cancel();
        };
    }

@here/harp-lrucache

LRU cache

Apache-2.0
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular @here/harp-lrucache functions

Similar packages