import * as THREE from "three" ; /**
 * Use `ColorCache` to reuse a color specified by name and save allocation as well as
 * setup time.
 *
 * Implemented as a singleton. Do not modify colors after getting them from the `ColorCache`.
 */ export class ColorCache { /**
     * Return instance of `ColorCache`.
     */ static get instance ( ) { return this . m_instance ; } private static readonly m_instance : ColorCache = new ColorCache ( ) ; private readonly m_map : Map < string , THREE . Color > = new Map ( ) ; param colorCode getColor ( colorCode ) { if ( typeof colorCode === "number" ) { colorCode = "#" + colorCode . toString ( 16 ) . padStart ( 6 , "0" ) ; } let color = this . m_map . get ( colorCode ) ; if ( color !== undefined ) { return color ; } color = new THREE . Color ( colorCode ) ; this . m_map . set ( colorCode , color ) ; return color ; } /**
     * Returns the number of elements in the cache.
     */ get size ( ) : number { return this . m_map . size ; } /**
     * Clears the cache. Only references to the THREE.Color are removed from the cache.
     * Consequently, clearing the cache does not cause any negative visual impact.
     */ clear ( ) { this . m_map . clear ( ) ; } }