@jingx/baccarat-threejs
v1.0.7
Published
Three.js Baccarat table animation packaged as a React component for Next.js.
Downloads
390
Readme
baccarat-threejs
Three.js baccarat table animation packaged as:
- a React component:
BaccaratGame - a lower-level runtime factory:
createBaccaratGame
Install
npm install @jingx/baccarat-threejsReact usage
import { BaccaratGame } from "@jingx/baccarat-threejs";
export default function Page() {
return (
<main style={{ width: "100%", height: "100vh" }}>
<BaccaratGame
currentCountdown={14}
playerCards={[
{ suit: "spade", rank: "A", ordering: 1 },
{ suit: "club", rank: "9", ordering: 2 },
]}
bankerCards={[
{ suit: "diamond", rank: "10", ordering: 1 },
{ suit: "heart", rank: "8", ordering: 2 },
]}
result="Player"
showResultSeconds={5}
/>
</main>
);
}Runtime usage
import { createBaccaratGame } from "@jingx/baccarat-threejs";
const game = createBaccaratGame({
container: document.getElementById("scene-root"),
currentCountdown: 14,
playerCards: [
{ suit: "spade", rank: "A", ordering: 1 },
{ suit: "club", rank: "9", ordering: 2 },
],
bankerCards: [
{ suit: "diamond", rank: "10", ordering: 1 },
{ suit: "heart", rank: "8", ordering: 2 },
],
result: "Player",
showResultSeconds: 5,
});
game.setCurrentCountdown(13);
game.destroy();Options
containerRuntime only. Required mount element.playerCardsOrdered player hand data. Up to 3 cards are rendered.bankerCardsOrdered banker hand data. Up to 3 cards are rendered.playerCardOptional fallback face card code whenplayerCardsis empty. Default:TWO_SPADES.bankerCardOptional fallback face card code whenbankerCardsis empty. Default:TEN_DIAMONDS.currentCountdownExternal countdown value used to drive round state.resultResult overlay text, for example"Player","Banker", or"Tie".showResultSecondsResult display duration in seconds. Default:2.beforeCountdownSecondsOptional positive number used as the pause before reveal.startNewRoundAtOptional countdown threshold for starting a new round.showResultDurationSecondsAlias for result display duration.onAfterReleaseCallback fired after all cards are revealed.
Countdown behavior
- The default fresh-round trigger is
currentCountdown === 14. - While
currentCountdown > 0, the countdown overlay shows the remaining value. - If the first countdown value is already
0or below, the scene waits for the next fresh round. - Update the runtime with
game.setCurrentCountdown(nextValue)as your external countdown changes.
Build
npm run build