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[gltfExtensions["MSFT_TEXTURE_DDS"]] != null) {
  //   source = json["images"][textureExtensions[gltfExtensions["MSFT_TEXTURE_DDS"]]["source"]];
  // } else {
  //   source = json["images"][textureDef["source"]];
  // }

  var loader;

  if (sourceDef["uri"] != null) {
    loader = options["manager"].getHandler(sourceDef["uri"]);
  }

  loader ??= textureExtensions[gltfExtensions["MSFT_TEXTURE_DDS"]] != null
      ? parser.extensions[gltfExtensions["MSFT_TEXTURE_DDS"]]["ddsLoader"]
      : textureLoader;

  return loadTextureImage(textureIndex, sourceIndex, loader);
}