Removed unnesasary async from createDiceInstace and simplified dice meshes to reduce spawn delay

This commit is contained in:
Mitchell McCaffrey 2020-05-28 12:51:42 +10:00
parent 2775fc6e16
commit fc8c65e525
18 changed files with 12 additions and 12 deletions

View File

@ -154,17 +154,17 @@ function DiceTrayOverlay({ isOpen }) {
} }
} }
async function handleDiceAdd(style, type) { function handleDiceAdd(style, type) {
const scene = sceneRef.current; const scene = sceneRef.current;
const shadowGenerator = shadowGeneratorRef.current; const shadowGenerator = shadowGeneratorRef.current;
if (scene && shadowGenerator) { if (scene && shadowGenerator) {
const instance = await style.createInstance(type, scene); const instance = style.createInstance(type, scene);
shadowGenerator.addShadowCaster(instance); shadowGenerator.addShadowCaster(instance);
Dice.roll(instance); Dice.roll(instance);
let dice = { type, instance, asleep: false }; let dice = { type, instance, asleep: false };
// If we have a d100 add a d10 as well // If we have a d100 add a d10 as well
if (type === "d100") { if (type === "d100") {
const d10Instance = await style.createInstance("d10", scene); const d10Instance = style.createInstance("d10", scene);
shadowGenerator.addShadowCaster(d10Instance); shadowGenerator.addShadowCaster(d10Instance);
Dice.roll(d10Instance); Dice.roll(d10Instance);
dice.d10Instance = d10Instance; dice.d10Instance = d10Instance;

View File

@ -138,7 +138,7 @@ class Dice {
); );
} }
static async createInstance(mesh, physicalProperties, scene) { static createInstance(mesh, physicalProperties, scene) {
this.instanceCount++; this.instanceCount++;
return this.createInstanceFromMesh( return this.createInstanceFromMesh(

View File

@ -21,7 +21,7 @@ class GalaxyDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

View File

@ -46,7 +46,7 @@ class GemstoneDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

View File

@ -48,7 +48,7 @@ class GlassDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

View File

@ -26,7 +26,7 @@ class IronDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

View File

@ -21,7 +21,7 @@ class NebulaDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -21,7 +21,7 @@ class SunriseDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

View File

@ -21,7 +21,7 @@ class SunsetDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

View File

@ -48,7 +48,7 @@ class WalnutDice extends Dice {
} }
} }
static async createInstance(diceType, scene) { static createInstance(diceType, scene) {
if (!this.material || !this.meshes) { if (!this.material || !this.meshes) {
throw Error("Dice not loaded, call load before creating an instance"); throw Error("Dice not loaded, call load before creating an instance");
} }

Binary file not shown.