forked from dataarts/dat.gui
-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.html
95 lines (69 loc) · 2.47 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
<script type="text/javascript" src="build/dat.gui.js"></script>
<script type="text/javascript">
var obj = {
message: 'Hello World',
displayOutline: false,
maxSize: 6.0,
speed: 5,
height: 10,
noiseStrength: 10.2,
growthSpeed: 0.2,
type: 'three',
explode: function() {
alert('Bang!');
},
color0: "#ffae23", // CSS string
color1: [ 0, 128, 255 ], // RGB array
color2: [ 0, 128, 255, 0.3 ], // RGB with alpha
color3: { h: 350, s: 0.9, v: 0.3 }, // Hue, saturation, value
plotter: 0
};
var gui = new dat.gui.GUI();
gui.remember(obj);
gui.add(obj, 'message');
gui.add( new dat.controllers.StringController(obj,'message') );
gui.add(obj, 'displayOutline');
gui.add( new dat.controllers.BooleanController(obj,'displayOutline') );
gui.add(obj, 'explode');
gui.add(obj, 'maxSize').min(-10).max(10).step(0.25);
gui.add( new dat.controllers.NumberControllerSlider(obj, 'maxSize', -10, 10, 0.25) );
gui.add(obj, 'height').step(5); // Increment amount
gui.add( new dat.controllers.NumberControllerBox(obj,'height',{step: 5}) );
// Choose from accepted values
gui.add(obj, 'type', [ 'one', 'two', 'three' ]);
gui.add( new dat.controllers.OptionController(obj,'type',[ 'one', 'two', 'three' ]) );
// Choose from named values
gui.add(obj, 'speed', { Stopped: 0, Slow: 0.1, Fast: 5 });
gui.add( new dat.controllers.OptionController(obj, 'speed', { Stopped: 0, Slow: 0.1, Fast: 5 }) );
var f1 = gui.addFolder('Colors');
f1.addColor(obj, 'color0');
f1.addColor(obj, 'color1');
f1.addColor(obj, 'color2');
f1.addColor(obj, 'color3');
f1.add( new dat.controllers.ColorController(obj, 'color0') );
var f2 = gui.addFolder('Another Folder');
f2.add(obj, 'noiseStrength');
var f3 = f2.addFolder('Nested Folder');
f3.add(obj, 'growthSpeed');
var f4 = gui.addFolder('Custom Controllers');
plotter = new dat.controllers.PlotterController(obj, 'plotter');
f4.add(plotter, { liClass: 'plotter' });
plotter.listen();
var angle = 0,
max = Math.PI * 2;
setInterval(function() {
angle += 0.05;
if (angle > max) {
angle = 0;
}
obj.plotter = Math.sin(angle) + 1.5;
}, 10);
</script>
</body>
</html>