当前位置:网站首页>dat. GUI
dat. GUI
2022-07-01 23:16:00 【yzhSWJ】
dat.GUI Is a lightweight GUI Library (GUI Components ), Using this library, you can easily create interface components that can change code variables .
Use steps
(1) First on the page of <head> Add this library to the tag .
<script type="text/javascript" src="../libs/dat.gui.js"></script>
(2) Define a JavaScript object ( The assumption here is called controls), The object will be saved through dat.GUI The attributes of change .
var controls = new function () {
this.rotationSpeed = 0.02;
//......
};(3) Next you need to put this JavaScript Object passed to dat.gui object , And set the value range of each attribute .
var gui = new dat.GUI(); gui.add(controls, 'rotationSpeed', 0, 0.5); //......
(4) Finally, when the user is right dat.GUI Control ,controls The attribute values in will also be modified synchronously . Let's directly reference this attribute value in the program .
demo
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++ initialization gui++++++++++++++++++++++++++++++++++++++++++++
var gui = new dat.GUI();
gui.add(cube.position, "x")
.min(0)
.max(5)
.step(0.01)
.name(" Move x Axis coordinates ")
.onChange(value => {
console.log(' The modified value :', value)
})
.onFinishChange(value => {
console.log(' Stop completely and start ', value)
})
//+++++++++++++++++ Modify the object color ++++++++++++++
const params = {
color: '#ffff00',
fn: () => {
// Let the object move
gsap.to(cube.position, { x: 5, duration: 5, yoyo: true, repeat: -1 })
}
}
gui.addColor(params, "color")
.onChange(value => {
console.log(' The modified value :', value)
cube.material.color.set(value)
})
//+++++++++++++++++++++ Whether or not shown Option box ++++++++++++++++
gui.add(cube, "visible").name(' Whether or not shown ')
//+++++++++++ Set button trigger event ++++++++++++++++++++++++++
gui.add(params, 'fn').name(' Click on the cube movement ')
//+++++++++++++++++ Put the configuration in a folder +++++++++++++++++++++
var folder = gui.addFolder(" Set cube ")// Folder name
// Put the settings under the folder
folder.add(cube.material, 'wireframe')// Show wireframe only 边栏推荐
- Redis~02 cache: how to ensure data consistency in MySQL and redis when updating data?
- Introduction and use of plantuml
- Rank ranking with MySQL 5.7
- SWT/ANR问题--SWT 导致 low memory killer(LMK)
- 证券开户选哪个证券公司比较好,哪个更安全
- What is the mosaic tailgate?
- 想请教股票开户要认识谁?在线开户是安全么?
- Istio、eBPF 和 RSocket Broker:深入研究服务网格
- Where can the courses purchased by CSDN be accessed
- 【Swoole系列1】在Swoole的世界中,你将学习到什么?
猜你喜欢

Cisco -- an external tool for WAN's concept examination

CADD course learning (3) -- target drug interaction

2022年R1快开门式压力容器操作考题及答案
![[applet] realize the left and right [sliding] list through the scroll view component](/img/18/b1b4e9923782856143721dad84cbab.png)
[applet] realize the left and right [sliding] list through the scroll view component

Redis~02 缓存:更新数据时如何保证MySQL和Redis中的数据一致性?

常见的二十种软件测试方法详解(史上最全)

Win 10 mstsc connect RemoteApp

CKS CKA CKAD 将终端更改为远程桌面

“35岁,公司老总,月薪2万送外卖“:时代抛弃你,连声再见都没有

MySQL -- deduction of index storage model
随机推荐
Contents of other parts of the map
通过Go语言创建CA与签发证书
思科考试--路由的概念和配置考试
Introduction and use of plantuml
flutter Unable to load asset: assets/images/888.png
若干互联网暴露面的收敛及处置建议
认识线程
MySQL -- index of InnoDB storage engine
Happy number [fast and slow pointer of ring PROBLEMS]
每日三题 6.29
毕业季,既是告别,也是新的开始
通过Go语言创建CA与签发证书
Compare the version number [double pointer to intercept the string you want]
Where can the courses purchased by CSDN be accessed
会声会影2022智能、快速、简单的视频剪辑软件
plain framework的实际应用和扩展
[micro service sentinel] @sentinelresource details
Detailed explanation of twenty common software testing methods (the most complete in History)
CKS CKA ckad change terminal to remote desktop
Win 10 mstsc connect RemoteApp