-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-----------------------------------------------------------------------------
module THREE.Source
  ( -- * Types
    Source (..)
    -- * Constructor
  , THREE.Source.new
    -- * Properties
  , data_
  , needsUpdate
  , dataReady
  , uuid
  , version
    -- * Methods
  , toJSON
  ) where
-----------------------------------------------------------------------------
import           Miso
-----------------------------------------------------------------------------
import           THREE.Internal as THREE
-----------------------------------------------------------------------------
-- | https://threejs.org/docs/#api/en/textures/Source
newtype Source
  = Source
  { Source -> JSVal
unSource :: JSVal
  } deriving (Source -> IO Object
(Source -> IO Object) -> ToObject Source
forall a. (a -> IO Object) -> ToObject a
$ctoObject :: Source -> IO Object
toObject :: Source -> IO Object
ToObject, Source -> IO JSVal
(Source -> IO JSVal) -> ToJSVal Source
forall a. (a -> IO JSVal) -> ToJSVal a
$ctoJSVal :: Source -> IO JSVal
toJSVal :: Source -> IO JSVal
ToJSVal, Source -> IO [JSVal]
(Source -> IO [JSVal]) -> ToArgs Source
forall args. (args -> IO [JSVal]) -> ToArgs args
$ctoArgs :: Source -> IO [JSVal]
toArgs :: Source -> IO [JSVal]
ToArgs)

instance FromJSVal Source where
  fromJSVal :: JSVal -> IO (Maybe Source)
fromJSVal = Maybe Source -> IO (Maybe Source)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe Source -> IO (Maybe Source))
-> (JSVal -> Maybe Source) -> JSVal -> IO (Maybe Source)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Source -> Maybe Source
forall a. a -> Maybe a
Just (Source -> Maybe Source)
-> (JSVal -> Source) -> JSVal -> Maybe Source
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> Source
Source

-----------------------------------------------------------------------------

-- Constructor

-- TODO define a typeclass for source data? 
new :: (ToArgs a) => a -> THREE.Three Source
new :: forall a. ToArgs a => a -> IO Source
new = (JSVal -> Source) -> MisoString -> a -> IO Source
forall args con.
ToArgs args =>
(JSVal -> con) -> MisoString -> args -> Three con
THREE.new JSVal -> Source
Source MisoString
"Source"

-- ReadOnly

uuid :: ReadOnly Source MisoString
uuid :: ReadOnly Source MisoString
uuid = MisoString -> ReadOnly Source MisoString
forall object return.
(FromJSVal return, ToObject object) =>
MisoString -> ReadOnly object return
readonly MisoString
"uuid"

-----------------------------------------------------------------------------

-- Property

data_ :: (FromJSVal a, ToJSVal a) => Property Source (Maybe a)
data_ :: forall a. (FromJSVal a, ToJSVal a) => Property Source (Maybe a)
data_ = MisoString -> Property Source (Maybe a)
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object (Maybe field)
optional MisoString
"data"

needsUpdate :: Property Source Bool
needsUpdate :: Property Source Bool
needsUpdate = MisoString -> Property Source Bool
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"needsUpdate"

dataReady :: Property Source Bool
dataReady :: Property Source Bool
dataReady = MisoString -> Property Source Bool
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"dataReady"

version :: Property Source Int
version :: Property Source Int
version = MisoString -> Property Source Int
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"version"

-----------------------------------------------------------------------------

-- Method

toJSON :: Method Source Object Object
toJSON :: Method Source Object Object
toJSON = MisoString -> Method Source Object Object
forall object return args.
(FromJSVal return, ToArgs args, ToObject object) =>
MisoString -> Method object args return
method MisoString
"toJSON"

-----------------------------------------------------------------------------