setTexture2D method

void setTexture2D(
  1. Texture texture,
  2. int slot
)

Implementation

void setTexture2D(Texture texture, int slot) {
  var textureProperties = properties.get(texture);

  if (texture is VideoTexture) updateVideoTexture(texture);
  if (texture is OpenGLTexture) {
    uploadOpenGLTexture(textureProperties, texture, slot);
    return;
  }

  if (texture.version > 0 && textureProperties["__version"] != texture.version) {
    var image = texture.image;

    if (texture is! OpenGLTexture && image == null) {
      print('three.WebGLRenderer: Texture marked for update but image is null');
    } else if (texture is! OpenGLTexture && image.complete == false) {
      print('three.WebGLRenderer: Texture marked for update but image is incomplete');
    } else {
      uploadTexture(textureProperties, texture, slot);
      return;
    }
  }

  state.activeTexture(gl.TEXTURE0 + slot);
  state.bindTexture(gl.TEXTURE_2D, textureProperties["__webglTexture"]);
}