resolveAndAddImage = async () => {
    image = await resolveImage(image, id);
    //>>includeStart('debug', pragmas.debug);
    Check.defined("image", image);
    //>>includeEnd('debug');

    if (this.isDestroyed() || !defined(image)) {
      return -1;
    }

    return this._addImage(index, image);
  }
Adds an image to the atlas.  If the image is already in the atlas, the atlas is unchanged and
the existing index is used.
@private
@param {string} id An identifier to detect whether the image already exists in the atlas.
@param {HTMLImageElement|HTMLCanvasElement|string|Resource|Promise|TextureAtlas.CreateImageCallback} image An image or canvas to add to the texture atlas,
       or a URL to an Image, or a Promise for an image, or a function that creates an image.
@returns {Promise<number>} A Promise that resolves to the image region index. -1 is returned if resouces are in the process of being destroyed.