Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ $ nix-shell --run 'cabal build'

#### Constants
- [ ] [Animation](https://threejs.org/docs/#api/en/constants/Animation)
- [x] [BlendingEquations](https://threejs.org/docs/#api/en/constants/CustomBlendingEquations)
- [ ] [BufferAttributeUsage](https://threejs.org/docs/#api/en/constants/BufferAttributeUsage)
- [ ] [Core](https://threejs.org/docs/#api/en/constants/Core)
- [ ] [CustomBlendingEquations](https://threejs.org/docs/#api/en/constants/CustomBlendingEquations)
- [x] [DestinationFactors](https://threejs.org/docs/#api/en/constants/CustomBlendingEquations)
- [ ] [Materials](https://threejs.org/docs/#api/en/constants/Materials)
- [ ] [Renderer](https://threejs.org/docs/#api/en/constants/Renderer)
- [x] [SourceFactors](https://threejs.org/docs/#api/en/constants/CustomBlendingEquations)
- [ ] [Textures](https://threejs.org/docs/#api/en/constants/Textures)

#### Core
Expand Down
43 changes: 43 additions & 0 deletions src/THREE/Constants/BlendingEquations.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-----------------------------------------------------------------------------
{-# LANGUAGE LambdaCase #-}
-----------------------------------------------------------------------------
-- | https://threejs.org/docs/index.html#api/en/constants/CustomBlendingEquations
module THREE.Constants.BlendingEquations
( -- * Types
BlendingEquations (..)
) where
-----------------------------------------------------------------------------
import Language.Javascript.JSaddle
-----------------------------------------------------------------------------

data BlendingEquations
= AddEquation
| SubtractEquation
| ReverseSubtractEquation
| MinEquation
| MaxEquation

instance ToJSVal BlendingEquations where
toJSVal = toJSVal . go
where
go :: BlendingEquations -> Int
go = \case
AddEquation -> 100
SubtractEquation -> 101
ReverseSubtractEquation -> 102
MinEquation -> 103
MaxEquation -> 104

instance FromJSVal BlendingEquations where
fromJSVal = fmap (>>= go) . fromJSVal
where
go :: Int -> Maybe BlendingEquations
go = \case
100 -> Just AddEquation
101 -> Just SubtractEquation
102 -> Just ReverseSubtractEquation
103 -> Just MinEquation
104 -> Just MaxEquation
_ -> Nothing

-----------------------------------------------------------------------------
26 changes: 0 additions & 26 deletions src/THREE/Constants/CustomBlendingEquations.hs

This file was deleted.

72 changes: 72 additions & 0 deletions src/THREE/Constants/DestinationFactors.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
-----------------------------------------------------------------------------
{-# LANGUAGE LambdaCase #-}
-----------------------------------------------------------------------------
-- | https://threejs.org/docs/index.html#api/en/constants/CustomBlendingEquations
module THREE.Constants.DestinationFactors
( -- * Types
DestinationFactors (..)
) where
-----------------------------------------------------------------------------
import Language.Javascript.JSaddle
-----------------------------------------------------------------------------

-- same as SourceFactors, w/o SrcAlphaSaturateFactor

data DestinationFactors
= ZeroFactor
| OneFactor
| SrcColorFactor
| OneMinusSrcColorFactor
| SrcAlphaFactor
| OneMinusSrcAlphaFactor
| DstAlphaFactor
| OneMinusDstAlphaFactor
| DstColorFactor
| OneMinusDstColorFactor
| ConstantColorFactor
| OneMinusConstantColorFactor
| ConstantAlphaFactor
| OneMinusConstantAlphaFactor

instance ToJSVal DestinationFactors where
toJSVal = toJSVal . go
where
go :: DestinationFactors -> Int
go = \case
ZeroFactor -> 200
OneFactor -> 201
SrcColorFactor -> 202
OneMinusSrcColorFactor -> 203
SrcAlphaFactor -> 204
OneMinusSrcAlphaFactor -> 205
DstAlphaFactor -> 206
OneMinusDstAlphaFactor -> 207
DstColorFactor -> 208
OneMinusDstColorFactor -> 209
ConstantColorFactor -> 211
OneMinusConstantColorFactor -> 212
ConstantAlphaFactor -> 213
OneMinusConstantAlphaFactor -> 214

instance FromJSVal DestinationFactors where
fromJSVal = fmap (>>= go) . fromJSVal
where
go :: Int -> Maybe DestinationFactors
go = \case
200 -> Just ZeroFactor
201 -> Just OneFactor
202 -> Just SrcColorFactor
203 -> Just OneMinusSrcColorFactor
204 -> Just SrcAlphaFactor
205 -> Just OneMinusSrcAlphaFactor
206 -> Just DstAlphaFactor
207 -> Just OneMinusDstAlphaFactor
208 -> Just DstColorFactor
209 -> Just OneMinusDstColorFactor
211 -> Just ConstantColorFactor
212 -> Just OneMinusConstantColorFactor
213 -> Just ConstantAlphaFactor
214 -> Just OneMinusConstantAlphaFactor
_ -> Nothing

-----------------------------------------------------------------------------
73 changes: 73 additions & 0 deletions src/THREE/Constants/SourceFactors.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
-----------------------------------------------------------------------------
{-# LANGUAGE LambdaCase #-}
-----------------------------------------------------------------------------
-- | https://threejs.org/docs/index.html#api/en/constants/CustomBlendingEquations
module THREE.Constants.SourceFactors
( -- * Types
SourceFactors (..)
) where
-----------------------------------------------------------------------------
import Language.Javascript.JSaddle
-----------------------------------------------------------------------------

data SourceFactors
= ZeroFactor
| OneFactor
| SrcColorFactor
| OneMinusSrcColorFactor
| SrcAlphaFactor
| OneMinusSrcAlphaFactor
| DstAlphaFactor
| OneMinusDstAlphaFactor
| DstColorFactor
| OneMinusDstColorFactor
| SrcAlphaSaturateFactor
| ConstantColorFactor
| OneMinusConstantColorFactor
| ConstantAlphaFactor
| OneMinusConstantAlphaFactor

instance ToJSVal SourceFactors where
toJSVal = toJSVal . go
where
go :: SourceFactors -> Int
go = \case
ZeroFactor -> 200
OneFactor -> 201
SrcColorFactor -> 202
OneMinusSrcColorFactor -> 203
SrcAlphaFactor -> 204
OneMinusSrcAlphaFactor -> 205
DstAlphaFactor -> 206
OneMinusDstAlphaFactor -> 207
DstColorFactor -> 208
OneMinusDstColorFactor -> 209
SrcAlphaSaturateFactor -> 210
ConstantColorFactor -> 211
OneMinusConstantColorFactor -> 212
ConstantAlphaFactor -> 213
OneMinusConstantAlphaFactor -> 214

instance FromJSVal SourceFactors where
fromJSVal = fmap (>>= go) . fromJSVal
where
go :: Int -> Maybe SourceFactors
go = \case
200 -> Just ZeroFactor
201 -> Just OneFactor
202 -> Just SrcColorFactor
203 -> Just OneMinusSrcColorFactor
204 -> Just SrcAlphaFactor
205 -> Just OneMinusSrcAlphaFactor
206 -> Just DstAlphaFactor
207 -> Just OneMinusDstAlphaFactor
208 -> Just DstColorFactor
209 -> Just OneMinusDstColorFactor
210 -> Just SrcAlphaSaturateFactor
211 -> Just ConstantColorFactor
212 -> Just OneMinusConstantColorFactor
213 -> Just ConstantAlphaFactor
214 -> Just OneMinusConstantAlphaFactor
_ -> Nothing

-----------------------------------------------------------------------------
4 changes: 3 additions & 1 deletion three.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ library
THREE.StereoCamera
-- Constants
THREE.Constants.Animation
THREE.Constants.BlendingEquations
THREE.Constants.BufferAttributeUsage
THREE.Constants.Core
THREE.Constants.CustomBlendingEquations
THREE.Constants.DestinationFactors
THREE.Constants.Materials
THREE.Constants.Renderer
THREE.Constants.SourceFactors
THREE.Constants.Textures
-- Core
THREE.BufferAttribute
Expand Down