Separated dice loading and dice instance creation and added loading spinner for dice

This commit is contained in:
Mitchell McCaffrey
2020-05-27 14:47:51 +10:00
parent da84f923d1
commit 7f0b4e32af
11 changed files with 117 additions and 11 deletions
+7 -1
View File
@@ -8,7 +8,7 @@ class SunsetDice extends Dice {
static meshes;
static material;
static async createInstance(diceType, scene) {
static async load(scene) {
if (!this.material) {
this.material = this.loadMaterial(
"sunset_pbr",
@@ -19,6 +19,12 @@ class SunsetDice extends Dice {
if (!this.meshes) {
this.meshes = await this.loadMeshes(this.material, scene);
}
}
static async createInstance(diceType, scene) {
if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance");
}
return Dice.createInstance(
this.meshes[diceType],