icy3dw/src/client/object/other/cubemap.ts

26 lines
688 B
TypeScript
Raw Normal View History

2022-04-11 18:11:31 +00:00
import { CubeTextureLoader, CubeTexture } from 'three';
const loader = new CubeTextureLoader();
export class CubeMap {
constructor(public source: string, public texture: CubeTexture) {}
public static async load(base: string): Promise<CubeMap> {
return new Promise((resolve, reject) =>
loader.load(
[
`${base}/left.png`, // pos-x
`${base}/right.png`, // neg-x
`${base}/top.png`, // pos-y
`${base}/bottom.png`, // neg-y
`${base}/front.png`, // pos-z
`${base}/back.png`, // neg-z
],
(texture) => resolve(new CubeMap(base, texture)),
undefined,
reject,
),
);
}
}