summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-18 17:22:32 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-18 17:22:32 -0400
commit6bdffaf86341d118a965f7316c7141baea58d87c (patch)
tree97449cda348c0744a2ff921dbec50bc4795fc93f
parent592575a2745233fcb865fe27768bdab54ce74bbd (diff)
meshsketch: key-stroke to toggle whirling camera animation.
-rw-r--r--MeshSketch.hs11
1 files changed, 10 insertions, 1 deletions
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
101-- State created by uploadState. 101-- State created by uploadState.
102data State = State 102data State = State
103 { stAnimator :: Animator 103 { stAnimator :: Animator
104 , stWhirl :: IORef (Maybe Int)
104 , stCamera :: IORef Camera 105 , stCamera :: IORef Camera
105 , stFullscreen :: IO () 106 , stFullscreen :: IO ()
106 , stSkyboxes :: Skyboxes 107 , stSkyboxes :: Skyboxes
@@ -212,8 +213,10 @@ initializeState mm storage = do
212 plane <- newIORef $ Just (xzPlaneVector G.// [(3,-1)]) 213 plane <- newIORef $ Just (xzPlaneVector G.// [(3,-1)])
213 recentPts <- newIORef Give0 214 recentPts <- newIORef Give0
214 angle <- newIORef 0 215 angle <- newIORef 0
216 whirl <- newIORef Nothing
215 let st = State 217 let st = State
216 { stAnimator = tm 218 { stAnimator = tm
219 , stWhirl = whirl
217 , stCamera = cam 220 , stCamera = cam
218 , stFullscreen = toggle 221 , stFullscreen = toggle
219 , stSkyboxes = skyboxes 222 , stSkyboxes = skyboxes
@@ -232,7 +235,6 @@ initializeState mm storage = do
232 , stObjects = objsRef 235 , stObjects = objsRef
233 , stMasks = masksRef 236 , stMasks = masksRef
234 } 237 }
235 -- _ <- addAnimation tm (whirlingCamera st)
236 return st 238 return st
237 239
238destroyState :: GLArea -> State -> IO () 240destroyState :: GLArea -> State -> IO ()
@@ -906,6 +908,13 @@ onEvent mm realized ev = do
906 KEY_F -> do 908 KEY_F -> do
907 put 'F' 909 put 'F'
908 stFullscreen st 910 stFullscreen st
911 KEY_A -> do
912 mw <- readIORef (stWhirl st)
913 case mw of
914 Just w -> do removeAnimation (stAnimator st) w
915 writeIORef (stWhirl st) Nothing
916 Nothing -> do w <- addAnimation (stAnimator st) (whirlingCamera st)
917 writeIORef (stWhirl st) (Just w)
909 _ -> return () 918 _ -> return ()
910 919
911 e -> return () 920 e -> return ()