grungnet/src/helpers/babylon.ts
2021-06-05 13:35:31 +10:00

21 lines
483 B
TypeScript

import { Texture } from "@babylonjs/core/Materials/Textures/texture";
// Turn texture load into an async function so it can be awaited
export async function importTextureAsync(url: string): Promise<Texture> {
return new Promise((resolve, reject) => {
let texture = new Texture(
url,
null,
undefined,
false,
undefined,
() => {
resolve(texture);
},
() => {
reject("Unable to load texture");
}
);
});
}