19 lines
437 B
TypeScript
19 lines
437 B
TypeScript
import { TextureLoader, Texture } from 'three';
|
|
|
|
const loader = new TextureLoader();
|
|
|
|
export class BaseTexture {
|
|
constructor(public source: string, public texture: Texture) {}
|
|
|
|
public static async load(src: string): Promise<BaseTexture> {
|
|
return new Promise((resolve, reject) =>
|
|
loader.load(
|
|
src,
|
|
(texture) => resolve(new BaseTexture(src, texture)),
|
|
undefined,
|
|
reject,
|
|
),
|
|
);
|
|
}
|
|
}
|