diff --git a/examples-testing/changes.patch b/examples-testing/changes.patch index c67a3ad16..46636d9a8 100644 --- a/examples-testing/changes.patch +++ b/examples-testing/changes.patch @@ -8121,7 +8121,7 @@ index 8c025071..a47c4832 100644 mouseY = (event.clientY - windowHalfY) * 4; } diff --git a/examples-testing/examples/webgl_materials_cubemap_render_to_mipmaps.ts b/examples-testing/examples/webgl_materials_cubemap_render_to_mipmaps.ts -index 599a1369..fa4f85c1 100644 +index 599a1369..a23a0582 100644 --- a/examples-testing/examples/webgl_materials_cubemap_render_to_mipmaps.ts +++ b/examples-testing/examples/webgl_materials_cubemap_render_to_mipmaps.ts @@ -1,8 +1,8 @@ @@ -8154,7 +8154,14 @@ index 599a1369..fa4f85c1 100644 const params = { magFilter: THREE.LinearFilter, minFilter: THREE.LinearMipMapLinearFilter, -@@ -83,7 +83,7 @@ function allocateCubemapRenderTarget(cubeMapSize) { +@@ -77,13 +77,13 @@ function allocateCubemapRenderTarget(cubeMapSize) { + const rt = new THREE.WebGLCubeRenderTarget(cubeMapSize, params); + + const mipLevels = Math.log(cubeMapSize) * Math.LOG2E + 1.0; +- for (let i = 0; i < mipLevels; i++) rt.texture.mipmaps.push({}); ++ for (let i = 0; i < mipLevels; i++) (rt.texture.mipmaps as THREE.CubeTexture[]).push({} as THREE.CubeTexture); + + rt.texture.mapping = THREE.CubeReflectionMapping; return rt; } @@ -8732,7 +8739,7 @@ index 178c2ce4..fb67cabe 100644 mouseY = event.clientY - windowHalfY; } diff --git a/examples-testing/examples/webgl_materials_texture_manualmipmap.ts b/examples-testing/examples/webgl_materials_texture_manualmipmap.ts -index 24bd4eb9..5d5e77b6 100644 +index 24bd4eb9..2dad75e8 100644 --- a/examples-testing/examples/webgl_materials_texture_manualmipmap.ts +++ b/examples-testing/examples/webgl_materials_texture_manualmipmap.ts @@ -3,9 +3,9 @@ import * as THREE from 'three'; @@ -8759,6 +8766,29 @@ index 24bd4eb9..5d5e77b6 100644 imageCanvas.width = imageCanvas.height = size; +@@ -49,14 +49,14 @@ function init() { + + const canvas = mipmap(128, '#f00'); + const textureCanvas1 = new THREE.CanvasTexture(canvas); +- textureCanvas1.mipmaps[0] = canvas; +- textureCanvas1.mipmaps[1] = mipmap(64, '#0f0'); +- textureCanvas1.mipmaps[2] = mipmap(32, '#00f'); +- textureCanvas1.mipmaps[3] = mipmap(16, '#400'); +- textureCanvas1.mipmaps[4] = mipmap(8, '#040'); +- textureCanvas1.mipmaps[5] = mipmap(4, '#004'); +- textureCanvas1.mipmaps[6] = mipmap(2, '#044'); +- textureCanvas1.mipmaps[7] = mipmap(1, '#404'); ++ textureCanvas1.mipmaps![0] = canvas; ++ textureCanvas1.mipmaps![1] = mipmap(64, '#0f0'); ++ textureCanvas1.mipmaps![2] = mipmap(32, '#00f'); ++ textureCanvas1.mipmaps![3] = mipmap(16, '#400'); ++ textureCanvas1.mipmaps![4] = mipmap(8, '#040'); ++ textureCanvas1.mipmaps![5] = mipmap(4, '#004'); ++ textureCanvas1.mipmaps![6] = mipmap(2, '#044'); ++ textureCanvas1.mipmaps![7] = mipmap(1, '#404'); + textureCanvas1.colorSpace = THREE.SRGBColorSpace; + textureCanvas1.repeat.set(1000, 1000); + textureCanvas1.wrapS = THREE.RepeatWrapping; @@ -97,7 +97,7 @@ function init() { addPainting(scene1, mesh1); addPainting(scene2, mesh2); diff --git a/types/three/examples/jsm/loaders/DDSLoader.d.ts b/types/three/examples/jsm/loaders/DDSLoader.d.ts index a8c604730..9053a9b23 100644 --- a/types/three/examples/jsm/loaders/DDSLoader.d.ts +++ b/types/three/examples/jsm/loaders/DDSLoader.d.ts @@ -1,7 +1,13 @@ -import { CompressedPixelFormat, CompressedTextureLoader, LoadingManager, PixelFormat } from "three"; +import { + CompressedPixelFormat, + CompressedTextureLoader, + CompressedTextureMipmap, + LoadingManager, + PixelFormat, +} from "three"; export interface DDS { - mipmaps: object[]; + mipmaps: CompressedTextureMipmap[]; width: number; height: number; format: PixelFormat | CompressedPixelFormat; diff --git a/types/three/examples/jsm/loaders/KTXLoader.d.ts b/types/three/examples/jsm/loaders/KTXLoader.d.ts index 8e43e3dac..326789960 100644 --- a/types/three/examples/jsm/loaders/KTXLoader.d.ts +++ b/types/three/examples/jsm/loaders/KTXLoader.d.ts @@ -1,7 +1,13 @@ -import { CompressedPixelFormat, CompressedTextureLoader, LoadingManager, PixelFormat } from "three"; +import { + CompressedPixelFormat, + CompressedTextureLoader, + CompressedTextureMipmap, + LoadingManager, + PixelFormat, +} from "three"; export interface KTX { - mipmaps: object[]; + mipmaps: CompressedTextureMipmap[]; width: number; height: number; format: PixelFormat | CompressedPixelFormat; diff --git a/types/three/examples/jsm/loaders/PVRLoader.d.ts b/types/three/examples/jsm/loaders/PVRLoader.d.ts index 9df979b37..1ba14766e 100644 --- a/types/three/examples/jsm/loaders/PVRLoader.d.ts +++ b/types/three/examples/jsm/loaders/PVRLoader.d.ts @@ -1,7 +1,7 @@ -import { CompressedPixelFormat, CompressedTextureLoader, LoadingManager } from "three"; +import { CompressedPixelFormat, CompressedTextureLoader, CompressedTextureMipmap, LoadingManager } from "three"; export interface PVR { - mipmaps: object[]; + mipmaps: CompressedTextureMipmap[]; width: number; height: number; format: CompressedPixelFormat; diff --git a/types/three/src/textures/CompressedTexture.d.ts b/types/three/src/textures/CompressedTexture.d.ts index 380987337..21f5427c7 100644 --- a/types/three/src/textures/CompressedTexture.d.ts +++ b/types/three/src/textures/CompressedTexture.d.ts @@ -40,10 +40,10 @@ export class CompressedTexture extends Texture { * @param colorSpace See {@link Texture.colorSpace .colorSpace}. Default {@link NoColorSpace} */ constructor( - mipmaps: CompressedTextureMipmap[], - width: number, - height: number, - format: CompressedPixelFormat, + mipmaps?: CompressedTextureMipmap[], + width?: number, + height?: number, + format?: CompressedPixelFormat, type?: TextureDataType, mapping?: Mapping, wrapS?: Wrapping, @@ -72,7 +72,7 @@ export class CompressedTexture extends Texture { * The mipmaps array should contain objects with data, width and height. The mipmaps should be of the correct * format and type. */ - mipmaps: CompressedTextureMipmap[]; + mipmaps: CompressedTextureMipmap[] | undefined; /** * @override diff --git a/types/three/src/textures/Texture.d.ts b/types/three/src/textures/Texture.d.ts index 2220e7410..c1fc6706b 100644 --- a/types/three/src/textures/Texture.d.ts +++ b/types/three/src/textures/Texture.d.ts @@ -13,6 +13,8 @@ import { import { EventDispatcher } from "../core/EventDispatcher.js"; import { Matrix3 } from "../math/Matrix3.js"; import { Vector2 } from "../math/Vector2.js"; +import { CompressedTextureMipmap } from "./CompressedTexture.js"; +import { CubeTexture } from "./CubeTexture.js"; import { Source } from "./Source.js"; /** Shim for OffscreenCanvas. */ @@ -127,7 +129,7 @@ export class Texture extends EventDispatcher<{ dispose: {} }> { * Array of user-specified mipmaps * @defaultValue `[]` */ - mipmaps: any[]; // CompressedTextureMipmap[] for 2D textures and CubeTexture[] for cube textures; + mipmaps: CompressedTextureMipmap[] | CubeTexture[] | HTMLCanvasElement[] | undefined; /** * How the image is applied to the object.