当前位置:网站首页>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 边栏推荐
- 硅谷产品实战学习感触
- The online beggar function of Japanese shopping websites
- [JUC learning road day 8] condition
- 【嵌入式系统课设】单个按键控制LED灯
- 2022安全员-C证考试题模拟考试题库及模拟考试
- 每日三题 6.29
- 从第三次技术革命看企业应用三大开发趋势
- [kotlin third party] coil koltin collaboration picture loading library coil glide like picture loading third party
- Compare the version number [double pointer to intercept the string you want]
- SWT/ANR问题--SWT 导致 kernel fuse deadlock
猜你喜欢

思科考试--路由的概念和配置考试
![[kotlin third party] coil koltin collaboration picture loading library coil glide like picture loading third party](/img/ad/dcb993c3e1e79d2c3663f031dfd1b3.png)
[kotlin third party] coil koltin collaboration picture loading library coil glide like picture loading third party

思科考试--冗余网络

"35 years old, the boss of the company, with a monthly salary of 20000, give away takeout": the times abandoned you, not even saying goodbye

Copy ‘XXXX‘ to effectively final temp variable

What is the mosaic tailgate?

Three development trends of enterprise application from the perspective of the third technological revolution
![[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

测试人进阶技能:单元测试报告应用指南

Cisco -- an external tool for WAN's concept examination
随机推荐
众昂矿业:发展以氟化工为主的特色化工产业具有先天优势
Convergence and disposal suggestions of some Internet exposure surfaces
CADD course learning (3) -- target drug interaction
硅谷产品实战学习感触
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
mysql binlog的清理
shell 自定义函数
CKS CKA CKAD 将终端更改为远程桌面
YOGA27多维一体电脑,兼具出色外观与高端配置
[micro service sentinel] sentinel integrates openfeign
Programming English vocabulary notebook
Armbain系统根分区空间不足处理
plain framework的实际应用和扩展
攻防演习防御体系构建之第三篇之建立实战化的安全体系
[MySQL] index creation, viewing and deletion
window安装wsl(二)
Cisco test -- the concept and configuration test of routing
Copy ‘XXXX‘ to effectively final temp variable
2022年危险化学品经营单位安全管理人员考试题及在线模拟考试
Which securities company is better and which is safer to open a securities account