Skip to content

Commit

Permalink
Fix type of CompressedTexture.mipmaps (#1024)
Browse files Browse the repository at this point in the history
* MipmapImageData

* Cleanup

---------

Co-authored-by: Nathan Bierema <[email protected]>
  • Loading branch information
HunterLarco and Methuselah96 authored Jun 18, 2024
1 parent 1792852 commit b77b069
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
8 changes: 4 additions & 4 deletions types/three/src/textures/CompressedArrayTexture.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CompressedPixelFormat, TextureDataType, Wrapping } from "../constants.js";
import { CompressedTexture } from "./CompressedTexture.js";
import { CompressedTexture, CompressedTextureMipmap } from "./CompressedTexture.js";

/**
* Creates an texture 2D array based on data in compressed form, for example from a
Expand Down Expand Up @@ -37,16 +37,16 @@ export class CompressedArrayTexture extends CompressedTexture {

/**
* Create a new instance of {@link CompressedArrayTexture}
* @param mipmaps The mipmaps array should contain objects with data, width and height.
* The mipmaps should be of the correct {@link format} and {@link type}. See {@link THREE.mipmaps}.
* @param mipmaps The mipmaps array should contain objects with data, width and height. The mipmaps should be of the
* correct format and type.
* @param width The width of the biggest mipmap.
* @param height The height of the biggest mipmap.
* @param depth The number of layers of the 2D array texture
* @param format The format used in the mipmaps. See {@link THREE.CompressedPixelFormat}.
* @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
*/
constructor(
mipmaps: ImageData[],
mipmaps: CompressedTextureMipmap[],
width: number,
height: number,
depth: number,
Expand Down
18 changes: 13 additions & 5 deletions types/three/src/textures/CompressedTexture.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import {
TextureDataType,
Wrapping,
} from "../constants.js";
import { TypedArray } from "../core/BufferAttribute.js";
import { Texture } from "./Texture.js";

export interface CompressedTextureMipmap {
data: TypedArray;
width: number;
height: number;
}

/**
* Creates a texture based on data in compressed form, for example from a {@link https://en.wikipedia.org/wiki/DirectDraw_Surface | DDS} file.
* @remarks For use with the {@link THREE.CompressedTextureLoader | CompressedTextureLoader}.
Expand All @@ -18,8 +25,8 @@ import { Texture } from "./Texture.js";
export class CompressedTexture extends Texture {
/**
* This creates a new {@link THREE.CompressedTexture | CompressedTexture} object.
* @param mipmaps The mipmaps array should contain objects with data, width and height.
* The mipmaps should be of the correct {@link format} and {@link type}. See {@link THREE.mipmaps}.
* @param mipmaps The mipmaps array should contain objects with data, width and height. The mipmaps should be of the
* correct format and type.
* @param width The width of the biggest mipmap.
* @param height The height of the biggest mipmap.
* @param format The format used in the mipmaps. See {@link THREE.CompressedPixelFormat}.
Expand All @@ -33,7 +40,7 @@ export class CompressedTexture extends Texture {
* @param colorSpace See {@link Texture.colorSpace .colorSpace}. Default {@link NoColorSpace}
*/
constructor(
mipmaps: ImageData[],
mipmaps: CompressedTextureMipmap[],
width: number,
height: number,
format: CompressedPixelFormat,
Expand Down Expand Up @@ -62,9 +69,10 @@ export class CompressedTexture extends Texture {
set image(value: { width: number; height: number });

/**
* The mipmaps array should contain objects with data, width and height. The mipmaps should be of the correct {@link format} and {@link type}.
* The mipmaps array should contain objects with data, width and height. The mipmaps should be of the correct
* format and type.
*/
mipmaps: ImageData[];
mipmaps: CompressedTextureMipmap[];

/**
* @override
Expand Down
2 changes: 1 addition & 1 deletion types/three/src/textures/Texture.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class Texture extends EventDispatcher<{ dispose: {} }> {
* Array of user-specified mipmaps
* @defaultValue `[]`
*/
mipmaps: any[]; // ImageData[] for 2D textures and CubeTexture[] for cube textures;
mipmaps: any[]; // CompressedTextureMipmap[] for 2D textures and CubeTexture[] for cube textures;

/**
* How the image is applied to the object.
Expand Down

0 comments on commit b77b069

Please sign in to comment.