From 6bdffaf86341d118a965f7316c7141baea58d87c Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Thu, 18 Jul 2019 17:22:32 -0400 Subject: meshsketch: key-stroke to toggle whirling camera animation. --- MeshSketch.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MeshSketch.hs b/MeshSketch.hs index d9290fd..56bbdaa 100644 --- a/MeshSketch.hs +++ b/MeshSketch.hs @@ -101,6 +101,7 @@ ringPointAttr ('r':'p':c:cs) = toLower c : cs -- State created by uploadState. data State = State { stAnimator :: Animator + , stWhirl :: IORef (Maybe Int) , stCamera :: IORef Camera , stFullscreen :: IO () , stSkyboxes :: Skyboxes @@ -212,8 +213,10 @@ initializeState mm storage = do plane <- newIORef $ Just (xzPlaneVector G.// [(3,-1)]) recentPts <- newIORef Give0 angle <- newIORef 0 + whirl <- newIORef Nothing let st = State { stAnimator = tm + , stWhirl = whirl , stCamera = cam , stFullscreen = toggle , stSkyboxes = skyboxes @@ -232,7 +235,6 @@ initializeState mm storage = do , stObjects = objsRef , stMasks = masksRef } - -- _ <- addAnimation tm (whirlingCamera st) return st destroyState :: GLArea -> State -> IO () @@ -906,6 +908,13 @@ onEvent mm realized ev = do KEY_F -> do put 'F' stFullscreen st + KEY_A -> do + mw <- readIORef (stWhirl st) + case mw of + Just w -> do removeAnimation (stAnimator st) w + writeIORef (stWhirl st) Nothing + Nothing -> do w <- addAnimation (stAnimator st) (whirlingCamera st) + writeIORef (stWhirl st) (Just w) _ -> return () e -> return () -- cgit v1.2.3