-----------------------------------------------------------------------------
{-# LANGUAGE ConstrainedClassMethods #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
module THREE.Texture
  ( -- * Types
    Texture (..)
  , TextureClass (..)
    -- * Constructors
  , THREE.Texture.new
    -- * Read-only Properties
    -- * Properties
    -- * Methods
  ) where
-----------------------------------------------------------------------------
import           Miso
-----------------------------------------------------------------------------
import           THREE.Constants.Textures
import           THREE.Constants.Textures.MagnificationFilters
import           THREE.Constants.Textures.MinificationFilters
import           THREE.EventDispatcher
import           THREE.Internal as THREE
import           THREE.Matrix3
import           THREE.Source
import           THREE.Vector2
-----------------------------------------------------------------------------
-- | https://threejs.org/docs/#api/en/textures/Texture
class (EventDispatcher texture) => TextureClass texture where

  -- ReadOnly

  id :: ReadOnly texture Int
  id = MisoString -> ReadOnly texture Int
forall object return.
(FromJSVal return, ToObject object) =>
MisoString -> ReadOnly object return
readonly MisoString
"id"

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

  -- Property

  name :: Property texture MisoString
  name = MisoString -> Property texture MisoString
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"name"

  -- TODO write a typeclass for Image?
  image :: Property texture Object
  image = MisoString -> Property texture Object
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"image"

  mipmaps :: Property texture [Object]
  mipmaps = MisoString -> Property texture [Object]
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"mipmaps"

  mapping :: Property texture MappingModes
  mapping = MisoString -> Property texture MappingModes
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"mapping"

  channel :: Property texture UvChannel
  channel = MisoString -> Property texture UvChannel
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"channel"

  wrapS :: Property texture WrappingModes
  wrapS = MisoString -> Property texture WrappingModes
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"wrapS"

  wrapT :: Property texture WrappingModes
  wrapT = MisoString -> Property texture WrappingModes
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"wrapT"

  magFilter :: Property texture MagnificationFilters
  magFilter = MisoString -> Property texture MagnificationFilters
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"magFilter"

  minFilter :: Property texture MinificationFilters
  minFilter = MisoString -> Property texture MinificationFilters
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"minFilter"

  anisotropy :: Property texture Double
  anisotropy = MisoString -> Property texture Double
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"anisotropy"

  format :: Property texture Formats
  format = MisoString -> Property texture Formats
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"format"

  internalFormat :: Property texture InternalFormats
  internalFormat = MisoString -> Property texture InternalFormats
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"internalFormat"

  type_ :: Property texture Types
  type_ = MisoString -> Property texture Types
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"type"

  offset :: Property texture Vector2
  offset = MisoString -> Property texture Vector2
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"offset"

  repeat :: Property texture Vector2
  repeat = MisoString -> Property texture Vector2
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"repeat"

  rotation :: Property texture Double
  rotation = MisoString -> Property texture Double
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"rotation"

  center :: Property texture Vector2
  center = MisoString -> Property texture Vector2
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"center"

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

  matrix :: Property texture Matrix3
  matrix = MisoString -> Property texture Matrix3
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"matrix"

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

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

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

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

  colorSpace :: Property texture ColorSpace
  colorSpace = MisoString -> Property texture ColorSpace
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"colorSpace"

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

  onUpdate :: Property texture (Maybe Function)
  onUpdate = MisoString -> Property texture (Maybe Function)
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object (Maybe field)
optional MisoString
"onUpdate"

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

  userData :: Property texture Object
  userData = MisoString -> Property texture Object
forall object field.
(ToObject object, ToJSVal field, FromJSVal field) =>
MisoString -> Property object field
property MisoString
"userData"

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

  -- Method

  updateMatrix :: Method texture () ()
  updateMatrix = MisoString -> Method texture () ()
forall object return args.
(FromJSVal return, ToArgs args, ToObject object) =>
MisoString -> Method object args return
method MisoString
"updateMatrix"

  clone :: (FromJSVal texture) => Method texture () texture
  clone = MisoString -> Method texture () texture
forall object return args.
(FromJSVal return, ToArgs args, ToObject object) =>
MisoString -> Method object args return
method MisoString
"clone"

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

  dispose :: Method texture () ()
  dispose = MisoString -> Method texture () ()
forall object return args.
(FromJSVal return, ToArgs args, ToObject object) =>
MisoString -> Method object args return
method MisoString
"dispose"

  transformUv :: Method texture Vector2 Vector2
  transformUv = MisoString -> Method texture Vector2 Vector2
forall object return args.
(FromJSVal return, ToArgs args, ToObject object) =>
MisoString -> Method object args return
method MisoString
"transformUv"

instance TextureClass JSVal

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

newtype Texture
  = Texture
  { Texture -> JSVal
unTexture :: JSVal
  } deriving newtype (Texture -> IO [JSVal]
(Texture -> IO [JSVal]) -> ToArgs Texture
forall args. (args -> IO [JSVal]) -> ToArgs args
$ctoArgs :: Texture -> IO [JSVal]
toArgs :: Texture -> IO [JSVal]
ToArgs, Texture -> IO Object
(Texture -> IO Object) -> ToObject Texture
forall a. (a -> IO Object) -> ToObject a
$ctoObject :: Texture -> IO Object
toObject :: Texture -> IO Object
ToObject, Texture -> IO JSVal
(Texture -> IO JSVal) -> ToJSVal Texture
forall a. (a -> IO JSVal) -> ToJSVal a
$ctoJSVal :: Texture -> IO JSVal
toJSVal :: Texture -> IO JSVal
ToJSVal)
    deriving anyclass (ToObject Texture
ToJSVal Texture
Method Texture (MisoString, Function) ()
Method Texture Object ()
(ToObject Texture, ToJSVal Texture) =>
Method Texture (MisoString, Function) ()
-> Method Texture (MisoString, Function) ()
-> Method Texture (MisoString, Function) ()
-> Method Texture Object ()
-> EventDispatcher Texture
forall object.
(ToObject object, ToJSVal object) =>
Method object (MisoString, Function) ()
-> Method object (MisoString, Function) ()
-> Method object (MisoString, Function) ()
-> Method object Object ()
-> EventDispatcher object
$caddEventListener :: Method Texture (MisoString, Function) ()
addEventListener :: Method Texture (MisoString, Function) ()
$chasEventListener :: Method Texture (MisoString, Function) ()
hasEventListener :: Method Texture (MisoString, Function) ()
$cremoveEventListener :: Method Texture (MisoString, Function) ()
removeEventListener :: Method Texture (MisoString, Function) ()
$cdispatchEvent :: Method Texture Object ()
dispatchEvent :: Method Texture Object ()
EventDispatcher, Property Texture Bool
Property Texture Double
Property Texture Int
Property Texture [Object]
Property Texture (Maybe Function)
Property Texture MisoString
Property Texture Object
Property Texture ColorSpace
Property Texture Formats
Property Texture InternalFormats
Property Texture MappingModes
Property Texture Types
Property Texture UvChannel
Property Texture WrappingModes
Property Texture MagnificationFilters
Property Texture MinificationFilters
Property Texture Matrix3
Property Texture Source
Property Texture Vector2
ReadOnly Texture Int
ReadOnly Texture MisoString
EventDispatcher Texture
Method Texture () ()
Method Texture Object Object
FromJSVal Texture => Method Texture () Texture
EventDispatcher Texture =>
ReadOnly Texture Int
-> ReadOnly Texture MisoString
-> Property Texture MisoString
-> Property Texture Object
-> Property Texture [Object]
-> Property Texture MappingModes
-> Property Texture UvChannel
-> Property Texture WrappingModes
-> Property Texture WrappingModes
-> Property Texture MagnificationFilters
-> Property Texture MinificationFilters
-> Property Texture Double
-> Property Texture Formats
-> Property Texture InternalFormats
-> Property Texture Types
-> Property Texture Vector2
-> Property Texture Vector2
-> Property Texture Double
-> Property Texture Vector2
-> Property Texture Bool
-> Property Texture Matrix3
-> Property Texture Bool
-> Property Texture Bool
-> Property Texture Bool
-> Property Texture Int
-> Property Texture ColorSpace
-> Property Texture Int
-> Property Texture (Maybe Function)
-> Property Texture Bool
-> Property Texture Object
-> Property Texture Source
-> Method Texture () ()
-> (FromJSVal Texture => Method Texture () Texture)
-> Method Texture Object Object
-> Method Texture () ()
-> Method Texture Vector2 Vector2
-> TextureClass Texture
Method Texture Vector2 Vector2
forall texture.
EventDispatcher texture =>
ReadOnly texture Int
-> ReadOnly texture MisoString
-> Property texture MisoString
-> Property texture Object
-> Property texture [Object]
-> Property texture MappingModes
-> Property texture UvChannel
-> Property texture WrappingModes
-> Property texture WrappingModes
-> Property texture MagnificationFilters
-> Property texture MinificationFilters
-> Property texture Double
-> Property texture Formats
-> Property texture InternalFormats
-> Property texture Types
-> Property texture Vector2
-> Property texture Vector2
-> Property texture Double
-> Property texture Vector2
-> Property texture Bool
-> Property texture Matrix3
-> Property texture Bool
-> Property texture Bool
-> Property texture Bool
-> Property texture Int
-> Property texture ColorSpace
-> Property texture Int
-> Property texture (Maybe Function)
-> Property texture Bool
-> Property texture Object
-> Property texture Source
-> Method texture () ()
-> (FromJSVal texture => Method texture () texture)
-> Method texture Object Object
-> Method texture () ()
-> Method texture Vector2 Vector2
-> TextureClass texture
$cid :: ReadOnly Texture Int
id :: ReadOnly Texture Int
$cuuid :: ReadOnly Texture MisoString
uuid :: ReadOnly Texture MisoString
$cname :: Property Texture MisoString
name :: Property Texture MisoString
$cimage :: Property Texture Object
image :: Property Texture Object
$cmipmaps :: Property Texture [Object]
mipmaps :: Property Texture [Object]
$cmapping :: Property Texture MappingModes
mapping :: Property Texture MappingModes
$cchannel :: Property Texture UvChannel
channel :: Property Texture UvChannel
$cwrapS :: Property Texture WrappingModes
wrapS :: Property Texture WrappingModes
$cwrapT :: Property Texture WrappingModes
wrapT :: Property Texture WrappingModes
$cmagFilter :: Property Texture MagnificationFilters
magFilter :: Property Texture MagnificationFilters
$cminFilter :: Property Texture MinificationFilters
minFilter :: Property Texture MinificationFilters
$canisotropy :: Property Texture Double
anisotropy :: Property Texture Double
$cformat :: Property Texture Formats
format :: Property Texture Formats
$cinternalFormat :: Property Texture InternalFormats
internalFormat :: Property Texture InternalFormats
$ctype_ :: Property Texture Types
type_ :: Property Texture Types
$coffset :: Property Texture Vector2
offset :: Property Texture Vector2
$crepeat :: Property Texture Vector2
repeat :: Property Texture Vector2
$crotation :: Property Texture Double
rotation :: Property Texture Double
$ccenter :: Property Texture Vector2
center :: Property Texture Vector2
$cmatrixAutoUpdate :: Property Texture Bool
matrixAutoUpdate :: Property Texture Bool
$cmatrix :: Property Texture Matrix3
matrix :: Property Texture Matrix3
$cgenerateMipmaps :: Property Texture Bool
generateMipmaps :: Property Texture Bool
$cpremultiplyAlpha :: Property Texture Bool
premultiplyAlpha :: Property Texture Bool
$cflipY :: Property Texture Bool
flipY :: Property Texture Bool
$cunpackAlignment :: Property Texture Int
unpackAlignment :: Property Texture Int
$ccolorSpace :: Property Texture ColorSpace
colorSpace :: Property Texture ColorSpace
$cversion :: Property Texture Int
version :: Property Texture Int
$conUpdate :: Property Texture (Maybe Function)
onUpdate :: Property Texture (Maybe Function)
$cneedsUpdate :: Property Texture Bool
needsUpdate :: Property Texture Bool
$cuserData :: Property Texture Object
userData :: Property Texture Object
$csource :: Property Texture Source
source :: Property Texture Source
$cupdateMatrix :: Method Texture () ()
updateMatrix :: Method Texture () ()
$cclone :: FromJSVal Texture => Method Texture () Texture
clone :: FromJSVal Texture => Method Texture () Texture
$ctoJSON :: Method Texture Object Object
toJSON :: Method Texture Object Object
$cdispose :: Method Texture () ()
dispose :: Method Texture () ()
$ctransformUv :: Method Texture Vector2 Vector2
transformUv :: Method Texture Vector2 Vector2
TextureClass)

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

-- Constructor

new :: (TextureNewParams t, ToArgs t) => t -> THREE.Three Texture
new :: forall t. (TextureNewParams t, ToArgs t) => t -> IO Texture
new = (JSVal -> Texture) -> MisoString -> t -> IO Texture
forall args con.
ToArgs args =>
(JSVal -> con) -> MisoString -> args -> Three con
THREE.new JSVal -> Texture
Texture MisoString
"Texture"

class TextureNewParams t
instance TextureNewParams ()
instance TextureNewParams Object  -- TODO Image?
instance TextureNewParams (Object, MappingModes)
instance TextureNewParams (Object, MappingModes, WrappingModes)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes, MagnificationFilters)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes, MagnificationFilters, MinificationFilters)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes, MagnificationFilters, MinificationFilters, Formats)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes, MagnificationFilters, MinificationFilters, Formats, Types)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes, MagnificationFilters, MinificationFilters, Formats, Types, Double)
instance TextureNewParams (Object, MappingModes, WrappingModes, WrappingModes, MagnificationFilters, MinificationFilters, Formats, Types, Double, ColorSpace)