<commit_before>var debug = require('./debug');
var error = debug('components:texture:error');
var THREE = require('../lib/three');
var TextureLoader = new THREE.TextureLoader();
var texturePromises = {};
var warn = debug('components:texture:warn');

/**
 * Sets image texture on material as `map`.
 *
 * @param {object} material - three.js material.
 * @param {string|object} src - An <img> element or url to an image file.
 * @param {string} repeat - X and Y value for size of texture repeating (in UV units).
 */
function loadImageTexture (material, src, repeat) {
  return new Promise(function (resolve, reject) {
    console.log('loading image texture', src);
    var isEl = typeof src !== 'string';
    var onLoad = createTexture;
    var onProgress = function () {};
    var onError = function (xhr) {
      console.log('ERROR');
      error('The URL "$s" could not be fetched (Error code: %s; Response: %s)',
      xhr.status, xhr.statusText);
    };

    if (isEl) {
      createTexture(src);
    } else {
      TextureLoader.load(src, onLoad, onProgress, onError);
    }

    function createTexture (texture) {
      console.log('create texture');
      if (!(texture instanceof THREE.Texture)) { texture = new THREE.Texture(texture); }
      var repeatXY;
      if (repeat) {
        repeatXY = repeat.split(' ');
        if (repeatXY.length === 2) {
          texture.wrapS = THREE.RepeatWrapping;
          texture.wrapT = THREE.RepeatWrapping;
          texture.repeat.set(parseInt(repeatXY[0], 10),
          parseInt(repeatXY[1], 10));
        }
      }
      material.map = texture;
      texture.needsUpdate = true;
      material.needsUpdate = true;
      resolve(texture);
    }
  });
}

/**
 * Updates material texture
 * @param  {object} material [description]
 * @param  {object} texture  [description]
 */
function updateMaterial (material, texture) {
  if (material.map !== undefined) {
    if (texture) { texture.needsUpdate = true; }
    material.map = texture;
    material.needsUpdate = true;<commit_msg>removed log calls used for debugging<commit_after>var debug = require('./debug');
var error = debug('components:texture:error');
var THREE = require('../lib/three');
var TextureLoader = new THREE.TextureLoader();
var texturePromises = {};
var warn = debug('components:texture:warn');

/**
 * Sets image texture on material as `map`.
 *
 * @param {object} material - three.js material.
 * @param {string|object} src - An <img> element or url to an image file.
 * @param {string} repeat - X and Y value for size of texture repeating (in UV units).
 */
function loadImageTexture (material, src, repeat) {
  return new Promise(function (resolve, reject) {
    var isEl = typeof src !== 'string';
    var onLoad = createTexture;
    var onProgress = function () {};
    var onError = function (xhr) {
      error('The URL "$s" could not be fetched (Error code: %s; Response: %s)',
      xhr.status, xhr.statusText);
    };

    if (isEl) {
      createTexture(src);
    } else {
      TextureLoader.load(src, onLoad, onProgress, onError);
    }

    function createTexture (texture) {
      if (!(texture instanceof THREE.Texture)) { texture = new THREE.Texture(texture); }
      var repeatXY;
      if (repeat) {
        repeatXY = repeat.split(' ');
        if (repeatXY.length === 2) {
          texture.wrapS = THREE.RepeatWrapping;
          texture.wrapT = THREE.RepeatWrapping;
          texture.repeat.set(parseInt(repeatXY[0], 10),
          parseInt(repeatXY[1], 10));
        }
      }
      material.map = texture;
      texture.needsUpdate = true;
      material.needsUpdate = true;
      resolve(texture);
    }
  });
}

/**
 * Updates material texture
 * @param  {object} material [description]
 * @param  {object} texture  [description]
 */
function updateMaterial (material, texture) {
  if (material.map !== undefined) {
    if (texture) { texture.needsUpdate = true; }
    material.map = texture;
    material.needsUpdate = true;
{'fraction_non_alphanumeric': 0.13811320754716983, 'fraction_numerical': 0.003522012578616352, 'mean_word_length': 3.032454361054767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2090208', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1152, 'n_words': 339}