Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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.
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();
};
}