From fd5998ea176d17572d837fadb62e6362b1d57eb5 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Mon, 25 May 2020 20:37:17 +1000 Subject: [PATCH] Added dice tray resizing to match screen size --- src/components/map/MapDice.js | 1 + src/components/map/dice/DiceButtons.js | 2 +- src/components/map/dice/DiceControls.js | 3 +- src/components/map/dice/DiceScene.js | 43 ++++++++++++------------ src/components/map/dice/DiceTray.js | 5 +-- src/dice/diceTray/DiceTrayMesh.js | 2 +- src/dice/meshes/diceTraySingle.glb | Bin 11852 -> 11788 bytes 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/components/map/MapDice.js b/src/components/map/MapDice.js index fc64c04..fbf4a64 100644 --- a/src/components/map/MapDice.js +++ b/src/components/map/MapDice.js @@ -13,6 +13,7 @@ function MapDice() { position: "absolute", top: 0, left: 0, + bottom: 0, flexDirection: "column", alignItems: "flex-start", }} diff --git a/src/components/map/dice/DiceButtons.js b/src/components/map/dice/DiceButtons.js index 49319c9..29e95fa 100644 --- a/src/components/map/dice/DiceButtons.js +++ b/src/components/map/dice/DiceButtons.js @@ -24,7 +24,7 @@ function DiceButtons({ diceRolls, onDiceAdd }) { } return ( - + { - engine.resize(); - for (let entry of entries) { - canvasRef.current.width = entry.contentRect.width; - canvasRef.current.height = entry.contentRect.height; - } - }); - - resizeObserver.observe(containerRef.current); - - return () => { - resizeObserver.disconnect(); - }; }, [onSceneMount]); const selectedMeshRef = useRef(); @@ -110,16 +97,30 @@ function DiceScene({ onSceneMount, onPointerDown, onPointerUp }) { onPointerUp(); } + function handleResize(width, height) { + const engine = engineRef.current; + engine.resize(); + canvasRef.current.width = width; + canvasRef.current.height = height; + } + return (
- + + +
); } diff --git a/src/components/map/dice/DiceTray.js b/src/components/map/dice/DiceTray.js index 2a6327a..c90564a 100644 --- a/src/components/map/dice/DiceTray.js +++ b/src/components/map/dice/DiceTray.js @@ -218,8 +218,9 @@ function DiceTray({ isOpen }) { return ( T(-Xs+o)hB6#K6G7qsPGDF_Cxi#t$*N0AHsEdH?_b delta 90 zcmeB)ITOR1o)hB6#K6GdqsPF|F_Cw%gN{;ha$-)Zl2x>Uo`nGz7#dm{8CV)w>JT9k JyKzH|E&%(v6~O=i