diff --git a/.all-contributorsrc b/.all-contributorsrc
index 829fd5715..9b0180207 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -325,14 +325,23 @@
]
},
{
- "login": "subhankar-trisetra",
+ "login": "subhankar-trisetra",
"name": "Subhankar Pal",
"avatar_url": "https://avatars.githubusercontent.com/u/98544661?v=4",
"profile": "https://subho57.github.io",
"contributions": [
- "code",
- ],
- }
+ "code"
+ ]
+ },
+ {
+ "login": "capnmidnight",
+ "name": "Sean T. McBeth",
+ "avatar_url": "https://avatars.githubusercontent.com/u/298046?v=4",
+ "profile": "http://www.seanmcbeth.com/",
+ "contributions": [
+ "code"
+ ]
+ }
],
"skipCi": true,
"contributorsPerLine": 7
diff --git a/README.md b/README.md
index 795cbad4a..a7f13fc75 100644
--- a/README.md
+++ b/README.md
@@ -67,8 +67,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Alejandro Laufer 🐛 💻 |
Gianmarco 💻 |
David Peicho 💻 |
- Subhankar Pal 💻 📖 |
- Maccesch 💻 ⚠️ |
+ Joe Pea 💻 |
+ Subhankar Pal 💻 |
+ Sean T. McBeth 💻 |
diff --git a/types/three/src/textures/CanvasTexture.d.ts b/types/three/src/textures/CanvasTexture.d.ts
index 6828dff37..816e07dcd 100644
--- a/types/three/src/textures/CanvasTexture.d.ts
+++ b/types/three/src/textures/CanvasTexture.d.ts
@@ -1,7 +1,7 @@
import { Texture } from './Texture';
import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType } from '../constants';
-export class CanvasTexture extends Texture {
+export class CanvasTexture extends Texture {
/**
* @param canvas
* @param [format=THREE.RGBAFormat]
@@ -15,7 +15,7 @@ export class CanvasTexture extends Texture {
* @param [encoding=THREE.LinearEncoding]
*/
constructor(
- canvas: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap,
+ canvas: HTMLCanvasElement | OffscreenCanvas,
mapping?: Mapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
diff --git a/types/three/src/textures/CompressedTexture.d.ts b/types/three/src/textures/CompressedTexture.d.ts
index 582413c56..7f8bc073a 100644
--- a/types/three/src/textures/CompressedTexture.d.ts
+++ b/types/three/src/textures/CompressedTexture.d.ts
@@ -1,4 +1,4 @@
-import { Texture } from './Texture';
+import { Dimensions2D, Texture } from './Texture';
import {
Mapping,
Wrapping,
@@ -8,7 +8,7 @@ import {
TextureEncoding,
} from '../constants';
-export class CompressedTexture extends Texture {
+export class CompressedTexture extends Texture {
/**
* @param mipmaps
* @param width
@@ -38,9 +38,6 @@ export class CompressedTexture extends Texture {
encoding?: TextureEncoding,
);
- get image(): { width: number; height: number };
- set image(value: { width: number; height: number });
-
mipmaps: ImageData[];
/**
diff --git a/types/three/src/textures/CubeTexture.d.ts b/types/three/src/textures/CubeTexture.d.ts
index 75958c05e..f6659787f 100644
--- a/types/three/src/textures/CubeTexture.d.ts
+++ b/types/three/src/textures/CubeTexture.d.ts
@@ -1,7 +1,7 @@
-import { Texture } from './Texture';
+import { BaseTextureImageType, Texture } from './Texture';
import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType, TextureEncoding } from '../constants';
-export class CubeTexture extends Texture {
+export class CubeTexture extends Texture {
/**
* @param [images=[]]
* @param [mapping=THREE.CubeReflectionMapping]
@@ -15,7 +15,7 @@ export class CubeTexture extends Texture {
* @param [encoding=THREE.LinearEncoding]
*/
constructor(
- images?: any[], // HTMLImageElement or HTMLCanvasElement
+ images?: BaseTextureImageType[],
mapping?: Mapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
diff --git a/types/three/src/textures/Data3DTexture.d.ts b/types/three/src/textures/Data3DTexture.d.ts
index 52dfd17b6..e13a63947 100644
--- a/types/three/src/textures/Data3DTexture.d.ts
+++ b/types/three/src/textures/Data3DTexture.d.ts
@@ -1,7 +1,7 @@
-import { Texture } from './Texture';
+import { DataDimensions3D, Texture } from './Texture';
import { TextureFilter } from '../constants';
-export class Data3DTexture extends Texture {
+export class Data3DTexture extends Texture {
constructor(data: BufferSource, width: number, height: number, depth: number);
/**
diff --git a/types/three/src/textures/DataArrayTexture.d.ts b/types/three/src/textures/DataArrayTexture.d.ts
index 594c236eb..a2f3f3717 100644
--- a/types/three/src/textures/DataArrayTexture.d.ts
+++ b/types/three/src/textures/DataArrayTexture.d.ts
@@ -1,7 +1,7 @@
-import { Texture } from './Texture';
+import { DataDimensions3D, Texture } from './Texture';
import { TextureFilter } from '../constants';
-export class DataArrayTexture extends Texture {
+export class DataArrayTexture extends Texture {
constructor(data?: BufferSource, width?: number, height?: number, depth?: number);
/**
diff --git a/types/three/src/textures/DataTexture.d.ts b/types/three/src/textures/DataTexture.d.ts
index 2d847a474..3bd15eeb2 100644
--- a/types/three/src/textures/DataTexture.d.ts
+++ b/types/three/src/textures/DataTexture.d.ts
@@ -1,7 +1,7 @@
-import { Texture } from './Texture';
+import { DataDimensions2D, Texture } from './Texture';
import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType, TextureEncoding } from '../constants';
-export class DataTexture extends Texture {
+export class DataTexture extends Texture {
/**
* @param data
* @param width
diff --git a/types/three/src/textures/DepthTexture.d.ts b/types/three/src/textures/DepthTexture.d.ts
index 343d3034b..fc5d8a56e 100644
--- a/types/three/src/textures/DepthTexture.d.ts
+++ b/types/three/src/textures/DepthTexture.d.ts
@@ -1,7 +1,7 @@
-import { Texture } from './Texture';
+import { Dimensions2D, Texture } from './Texture';
import { Mapping, Wrapping, TextureFilter, TextureDataType } from '../constants';
-export class DepthTexture extends Texture {
+export class DepthTexture extends Texture {
/**
* @param width
* @param height
@@ -25,9 +25,6 @@ export class DepthTexture extends Texture {
anisotropy?: number,
);
- get image(): { width: number; height: number };
- set image(value: { width: number; height: number });
-
/**
* @default false
*/
diff --git a/types/three/src/textures/FramebufferTexture.d.ts b/types/three/src/textures/FramebufferTexture.d.ts
index c5b52178a..ebbe5826f 100644
--- a/types/three/src/textures/FramebufferTexture.d.ts
+++ b/types/three/src/textures/FramebufferTexture.d.ts
@@ -1,7 +1,7 @@
-import { Texture } from './Texture';
+import { Dimensions2D, Texture } from './Texture';
import { PixelFormat } from '../constants';
-export class FramebufferTexture extends Texture {
+export class FramebufferTexture extends Texture {
readonly isFramebufferTexture: true;
constructor(width: number, height: number, format: PixelFormat);
diff --git a/types/three/src/textures/Texture.d.ts b/types/three/src/textures/Texture.d.ts
index ef0391bee..b82558832 100644
--- a/types/three/src/textures/Texture.d.ts
+++ b/types/three/src/textures/Texture.d.ts
@@ -11,8 +11,33 @@ import {
TextureDataType,
TextureEncoding,
} from '../constants';
+import { CubeTexture } from './CubeTexture';
-export class Texture extends EventDispatcher {
+export interface Dimensions2D {
+ width: number;
+ height: number;
+}
+
+export interface TextureData {
+ data: BufferSource;
+}
+
+export interface DataDimensions2D extends Dimensions2D, TextureData {}
+
+export interface DataDimensions3D extends DataDimensions2D {
+ depth: number;
+}
+
+export type BaseTextureMipMapType = TexImageSource | DataDimensions2D | DataDimensions3D;
+
+export type BaseTextureImageType = BaseTextureMipMapType | Dimensions2D;
+
+export type BaseTextureTypes = BaseTextureImageType | BaseTextureImageType[];
+
+export class Texture<
+ ImageT extends BaseTextureTypes = TexImageSource,
+ MipMapT extends BaseTextureMipMapType = TexImageSource,
+> extends EventDispatcher {
/**
* @param [image]
* @param [mapping=THREE.Texture.DEFAULT_MAPPING]
@@ -26,7 +51,7 @@ export class Texture extends EventDispatcher {
* @param [encoding=THREE.LinearEncoding]
*/
constructor(
- image?: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement,
+ image?: ImageT,
mapping?: Mapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
@@ -61,7 +86,7 @@ export class Texture extends EventDispatcher {
* video element as a source for your texture image and continuously update this texture
* as long as video is playing - the {@link VideoTexture} class handles this automatically.
*/
- get image(): any;
+ get image(): ImageT;
/**
* An image object, typically created using the {@link TextureLoader.load} method.
@@ -71,12 +96,12 @@ export class Texture extends EventDispatcher {
* video element as a source for your texture image and continuously update this texture
* as long as video is playing - the {@link VideoTexture} class handles this automatically.
*/
- set image(data: any);
+ set image(data: ImageT);
/**
* @default []
*/
- mipmaps: any[]; // ImageData[] for 2D textures and CubeTexture[] for cube textures;
+ mipmaps: MipMapT[]; // ImageData[] for 2D textures and CubeTexture[] for cube textures;
/**
* @default THREE.Texture.DEFAULT_MAPPING