Separated dice loading and dice instance creation and added loading spinner for dice
This commit is contained in:
@@ -8,7 +8,7 @@ class GalaxyDice extends Dice {
|
||||
static meshes;
|
||||
static material;
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"galaxy_pbr",
|
||||
@@ -19,6 +19,12 @@ class GalaxyDice 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],
|
||||
|
||||
@@ -13,7 +13,7 @@ class IronDice extends Dice {
|
||||
return { mass: properties.mass * 2, friction: properties.friction };
|
||||
}
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"iron_pbr",
|
||||
@@ -24,6 +24,12 @@ class IronDice 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],
|
||||
|
||||
@@ -8,10 +8,10 @@ class NebulaDice extends Dice {
|
||||
static meshes;
|
||||
static material;
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"nebula_pbr",
|
||||
"neubula_pbr",
|
||||
{ albedo, metalRoughness, normal },
|
||||
scene
|
||||
);
|
||||
@@ -19,6 +19,12 @@ class NebulaDice 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],
|
||||
|
||||
@@ -8,7 +8,7 @@ class SunriseDice extends Dice {
|
||||
static meshes;
|
||||
static material;
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"sunrise_pbr",
|
||||
@@ -19,6 +19,12 @@ class SunriseDice 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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -8,7 +8,7 @@ class WalnutDice extends Dice {
|
||||
static meshes;
|
||||
static material;
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"walnut_pbr",
|
||||
@@ -19,6 +19,12 @@ class WalnutDice 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],
|
||||
|
||||
Reference in New Issue
Block a user