<commit_before>//Cube texture.

//## Example use
//     var envMap = TextureCube.load("image_####.jpg");
//     envMap.bind();

//## Reference
define(["pex/core/Texture", "pex/core/Context", "pex/sys/IO"], function(Texture, Context, IO) {

  //### TextureCube ( )
  //Does nothing, use *load()* method instead.
  function TextureCube() {
    this.init(Context.currentContext.gl.TEXTURE_CUBE_MAP);
  }

  TextureCube.prototype = new Texture();

  //### load ( src )
  //Load texture from file (in Plask) or url (in the web browser).
  //
  //`src` - path to file or url (e.g. *path/file_####.jpg*) *{ String }*
  //
  //Returns the loaded texture *{ Texture2D }*
  //
  //*Note* the path or url must contain #### that will be replaced by
  //id (e.g. *posx*) of the cube side*
  //
  //*Note: In Plask the texture is ready immediately, in the web browser it's
  //first black until the file is loaded and texture can be populated with the image data.*
  TextureCube.load = function(src) {

    var gl = Context.currentContext.gl;

    var texture = new TextureCube();

    var cubeMapTargets = [
      gl.TEXTURE_CUBE_MAP_POSITIVE_X, 'posx',
      gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 'negx',
      gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 'posy',
      gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 'negy',
      gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 'posz',
      gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 'negz'
    ];

    for (var i=0; i<cubeMapTargets.length; i += 2) {
      IO.loadImageData(gl, texture, cubeMapTargets[i], src.replace("####", cubeMapTargets[i+1]), function(image) {
        texture.width = image.width;
        texture.height = image.height;
      });
    }

    gl.bindTexture(texture.target, texture.handle);
    gl.texParameteri(texture.target, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
    gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    gl.texParameteri(texture.target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(texture.target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

    return texture;
  }

  //### dispose ( )<commit_msg>Moved filtering of TextureCube before we start loading images<commit_after>//Cube texture.

//## Example use
//     var envMap = TextureCube.load("image_####.jpg");
//     envMap.bind();

//## Reference
define(["pex/core/Texture", "pex/core/Context", "pex/sys/IO"], function(Texture, Context, IO) {

  //### TextureCube ( )
  //Does nothing, use *load()* method instead.
  function TextureCube() {
    this.init(Context.currentContext.gl.TEXTURE_CUBE_MAP);
  }

  TextureCube.prototype = new Texture();

  //### load ( src )
  //Load texture from file (in Plask) or url (in the web browser).
  //
  //`src` - path to file or url (e.g. *path/file_####.jpg*) *{ String }*
  //
  //Returns the loaded texture *{ Texture2D }*
  //
  //*Note* the path or url must contain #### that will be replaced by
  //id (e.g. *posx*) of the cube side*
  //
  //*Note: In Plask the texture is ready immediately, in the web browser it's
  //first black until the file is loaded and texture can be populated with the image data.*
  TextureCube.load = function(src) {
    var gl = Context.currentContext.gl;

    var texture = new TextureCube();

    var cubeMapTargets = [
      gl.TEXTURE_CUBE_MAP_POSITIVE_X, 'posx',
      gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 'negx',
      gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 'posy',
      gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 'negy',
      gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 'posz',
      gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 'negz'
    ];

    gl.bindTexture(texture.target, texture.handle);
    gl.texParameteri(texture.target, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
    gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    gl.texParameteri(texture.target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(texture.target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

    for (var i=0; i<cubeMapTargets.length; i += 2) {
      IO.loadImageData(gl, texture, cubeMapTargets[i], src.replace("####", cubeMapTargets[i+1]), function(image) {
        texture.width = image.width;
        texture.height = image.height;
      });
    }

    return texture;
  }

  //### dispose ( )
{'fraction_non_alphanumeric': 0.14911643669813604, 'fraction_numerical': 0.0019365770999757927, 'mean_word_length': 3.2863070539419086, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1048042', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1456, 'n_words': 328}