Added continuous dice roll calculation and scene render sleep

This commit is contained in:
Mitchell McCaffrey
2020-05-14 22:51:06 +10:00
parent d9c928dfcd
commit 6e027cd9a3
5 changed files with 269 additions and 169 deletions

View File

@@ -3,7 +3,7 @@ import * as BABYLON from "babylonjs";
import * as AMMO from "ammo.js";
import "babylonjs-loaders";
function DiceScene({ onSceneMount }) {
function DiceScene({ onSceneMount, onPointerDown, onPointerUp }) {
const sceneRef = useRef();
const engineRef = useRef();
const canvasRef = useRef();
@@ -86,6 +86,7 @@ function DiceScene({ onSceneMount }) {
selectedMeshRef.current = pickInfo.pickedMesh;
}
}
onPointerDown();
}
function handlePointerUp() {
@@ -105,6 +106,8 @@ function DiceScene({ onSceneMount }) {
}
selectedMeshRef.current = null;
selectedMeshDeltaPositionRef.current = null;
onPointerUp();
}
return (
@@ -121,4 +124,9 @@ function DiceScene({ onSceneMount }) {
);
}
DiceScene.defaultProps = {
onPointerDown() {},
onPointerUp() {},
};
export default DiceScene;