Skip to content

Commit bca50d4

Browse files
author
Jordy Moos
committed
More scenes
1 parent 94912ef commit bca50d4

File tree

18 files changed

+342
-24
lines changed

18 files changed

+342
-24
lines changed

src/elm/Actor/Actor.elm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import Data.Config exposing (Config)
9999
import Data.Coordinate exposing (Coordinate)
100100
import Data.Direction exposing (Direction)
101101
import Data.Position exposing (Position)
102+
import Data.Rotation as Rotation
102103
import Dict exposing (Dict)
103104
import GameState.PlayingLevel.Msg as PlayingMsg
104105

@@ -274,7 +275,9 @@ type alias AframeRendererData =
274275

275276

276277
type alias AframeCamera =
277-
{ offsets : PositionOffsets }
278+
{ rotation : Rotation.Rotation
279+
, offsets : PositionOffsets
280+
}
278281

279282

280283
type alias Level =

src/elm/Actor/Decoder.elm

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import Data.Config exposing (Config)
8181
import Data.Coordinate exposing (Coordinate)
8282
import Data.Direction as Direction exposing (Direction)
8383
import Data.Position exposing (Position)
84+
import Data.Rotation exposing (Rotation)
8485
import Dict exposing (Dict)
8586
import GameState.PlayingLevel.Animation.CurrentTick as CurrentTickAnimation
8687
import GameState.PlayingLevel.Animation.PseudoRandomTraversal as PseudoRandomTraversalAnimation
@@ -150,19 +151,36 @@ aframeRendererDecoder =
150151
aframeCameraDecoder : Decoder AframeCamera
151152
aframeCameraDecoder =
152153
Decode.succeed AframeCamera
154+
|> JDP.optional "rotation" rotationDecoder defaultAframeCamera.rotation
153155
|> JDP.optional "offsets" positionOffsetsDecoder defaultAframeCamera.offsets
154156

155157

158+
rotationDecoder : Decoder Rotation
159+
rotationDecoder =
160+
Decode.succeed Rotation
161+
|> JDP.optional "x" Decode.float 0.0
162+
|> JDP.optional "y" Decode.float 0.0
163+
|> JDP.optional "z" Decode.float 0.0
164+
165+
156166
defaultAframeCamera : AframeCamera
157167
defaultAframeCamera =
158-
{ offsets = emptyPositionOffsets
168+
{ rotation = defaultRotation
169+
, offsets = emptyPositionOffsets
170+
}
171+
172+
173+
defaultRotation : Rotation
174+
defaultRotation =
175+
{ x = 0.0
176+
, y = 0.0
177+
, z = 0.0
159178
}
160179

161180

162181
defaultBackgrounds : List RenderComponentData
163182
defaultBackgrounds =
164-
[
165-
]
183+
[]
166184

167185

168186
configDecoder : Decoder Config

src/elm/Data/Rotation.elm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Data.Rotation exposing
2+
( Rotation
3+
, getPitch
4+
, getRoll
5+
, getYaw
6+
)
7+
8+
9+
type alias Rotation =
10+
{ x : Float
11+
, y : Float
12+
, z : Float
13+
}
14+
15+
16+
getPitch : Rotation -> Float
17+
getPitch rotation =
18+
rotation.x
19+
20+
21+
getYaw : Rotation -> Float
22+
getYaw rotation =
23+
rotation.y
24+
25+
26+
getRoll : Rotation -> Float
27+
getRoll rotation =
28+
rotation.z

src/elm/Renderer/Aframe/LevelRenderer.elm

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,25 @@ drawCamera aframeRenderData level viewPositionCoordinate viewPixelOffset acc =
9494
toFloat viewPositionCoordinate.y + (toFloat level.config.height / 2.0) - yOffset
9595

9696
cameraNode =
97-
node "a-camera"
97+
node "a-entity"
9898
[ attribute "position" <|
9999
String.join " "
100100
[ String.fromFloat x
101101
, String.fromFloat (y * -1)
102102
, String.fromFloat computedOffsets.z
103103
]
104-
, attribute "wasd-controls" "enabled: false;"
104+
, attribute "rotation" <|
105+
String.join " "
106+
[ String.fromFloat aframeRenderData.camera.rotation.x
107+
, String.fromFloat aframeRenderData.camera.rotation.y
108+
, String.fromFloat aframeRenderData.camera.rotation.z
109+
]
110+
]
111+
[ node "a-camera"
112+
[ attribute "wasd-controls" "enabled: false;"
113+
]
114+
[]
105115
]
106-
[]
107116
in
108117
addToDrawAcc 0 cameraNode acc
109118

0 commit comments

Comments
 (0)