Skip to content

Instantly share code, notes, and snippets.

@ikekou
Last active December 17, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikekou/5589109 to your computer and use it in GitHub Desktop.
Save ikekou/5589109 to your computer and use it in GitHub Desktop.
[JavScript][CoffeeScript] dat.GUIマイテンプレ
class Config
_instance = null
constructor:()->
throw new Error 'Cant create instance, use \'getInstance\'.'
@getInstance: () ->
_instance ?= new _PrivateClass()
class _PrivateClass
str:'some string !'
num1:1
num2:1
num3:2
num4:2
bool:true
func:()->
console.log 'some function !'
constructor: () ->
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="http://dat-gui.googlecode.com/git/build/dat.gui.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
Hello dat.GUI !
</body>
</html>
window.onload=()->
c=Config.getInstance()
g=new dat.GUI()
g.remember(c)
g.add(c,'str')
controller=g.add(c,'num1',-10,10)
g.add(c,'num2').min(-10).max(10).step(1)
g.add(c,'num3',[1,2,3])
g.add(c,'num4',{first:'1',second:'2',third:'3'})
g.add(c,'bool')
g.add(c,'func')
controller.onChange((value)->
console.log("#onChange : " + value)
)
controller.onFinishChange((value)->
console.log("#onFinishChange : " + value)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment