loadTexture method

dynamic loadTexture(
  1. dynamic textureIndex
)

Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures @param {number} textureIndex @return {Promise<THREE.Texture>}

Implementation

loadTexture(textureIndex) async {
  var parser = this;
  Map<String, dynamic> json = this.json;
  var options = this.options;

  Map<String, dynamic> textureDef = json["textures"][textureIndex];
  var sourceIndex = textureDef["source"];
  var sourceDef = json["images"][sourceIndex];

  var textureExtensions = textureDef["extensions"] ?? {};

  var source;

  if (textureExtensions[EXTENSIONS["MSFT_TEXTURE_DDS"]] != null) {
    source = json["images"]
        [textureExtensions[EXTENSIONS["MSFT_TEXTURE_DDS"]]["source"]];
  } else {
    source = json["images"][textureDef["source"]];
  }

  var loader;

  if (sourceDef["uri"] != null) {
  //  print("xxxx"+sourceDef['uri']);
    loader = options["manager"].getHandler(sourceDef["uri"]);
   // TextLoader loaderii=loader;
   // loaderii.
   // print("ooo"+loader.toString());
  }

  if (loader == null) {
    loader = textureExtensions[EXTENSIONS["MSFT_TEXTURE_DDS"]] != null
        ? parser.extensions[EXTENSIONS["MSFT_TEXTURE_DDS"]]["ddsLoader"]
        : this.textureLoader;
  }

  return this.loadTextureImage(textureIndex, sourceIndex, loader);
}