<commit_before>define ["underscore","three"], (_,THREE) ->
    cache = {}
    
    (text, options) ->
        options or (options = {})
        _.defaults options,
            willCache: true
            size: 30
            font: "Times Roman"
            color: "#ff0000"
        id = {text: text, font: options.font, color: options.color}
        return cache[id] if id of cache
        canvas = document.createElement('canvas')
        context = canvas.getContext('2d')
        context.font = "#{options.size}px #{options.font}"
        metrics = context.measureText(text)
        canvas.width = metrics.width
        canvas.height = options.size
        context.clearRect(0, 0, canvas.width, canvas.height)
        context.font = "#{options.size}px #{options.font}"
        context.fillStyle = options.color
        context.fillText(text,0,canvas.height)
        texture = new THREE.Texture(canvas)
        texture.needsUpdate = true
        if options.willCache<commit_msg>Fix caching of textures.<commit_after>define ["underscore","three"], (_,THREE) ->
    cache = {}
    
    (text, options) ->
        options or (options = {})
        _.defaults options,
            willCache: true
            size: 30
            font: "Times Roman"
            color: "#ff0000"
        id = JSON.stringify({text: text, font: options.font, color: options.color})
        console.log("render text called")
        return cache[id] if id of cache
        canvas = document.createElement('canvas')
        $("#container").append(canvas)
        context = canvas.getContext('2d')
        context.font = "#{options.size}px #{options.font}"
        metrics = context.measureText(text)
        canvas.width = metrics.width
        canvas.height = options.size
        context.clearRect(0, 0, canvas.width, canvas.height)
        context.font = "#{options.size}px #{options.font}"
        context.fillStyle = options.color
        context.fillText(text,0,canvas.height)
        texture = new THREE.Texture(canvas)
        texture.needsUpdate = true
        if options.willCache
{'fraction_non_alphanumeric': 0.12681510164569215, 'fraction_numerical': 0.00968054211035818, 'mean_word_length': 2.25, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4597368', 'n_tokens_mistral': 576, 'n_tokens_neox': 560, 'n_words': 132}