3d-dice / dice-box

3D Game Dice for any JavaScript App
https://fantasticdice.games/
MIT License
124 stars 27 forks source link

Error in Svelte App #108

Open JayJayBinks opened 1 month ago

JayJayBinks commented 1 month ago

Error

Initially the dice roll fine but after a while i get this error colliderFaceMap Error: No value found for d20 mesh face -1

After reloading everything works again, for a while.

Setup

SvelteKit App with 3d-dice as npm dependency

I have a Tailwind dice box at top level: <div id="dice-box" class="fixed inset-0 w-screen h-screen z-30 pointer-events-none"></div>

On document ready i initialize it and everything works fine: diceBox = new DiceBox("#dice-box", { assetPath: "/assets/dice-box/", // required }); diceBox.init();

<button id="roll-dice-button" class="btn btn-ghost m-3 " disabled={rolledValueState.value} onclick={(evt) => {diceBox.show(); diceBox.roll("1d20").then(results => {rolledValueState.value = results[0].value;})}}>

JayJayBinks commented 1 month ago

Duplicate of #74 . I was also using hide() and show(). Lets see if removing it fixes the issue.

frankieali commented 1 month ago

If mesh face is -1 that usually means the die has left the scene and been culled. This can happen when the dice are thrown with a high enough force to go through the dice-box walls. It also sometimes happened when the dice are too big for the box they're in. Let me know if removing hide/show methods works. I'll have to set up a testing sandbox to see if I can recreate the issue.

JayJayBinks commented 1 month ago

After removing the hide/show i did not get this error anymore.