当前位置:网站首页>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
边栏推荐
- Rank ranking with MySQL 5.7
- Explain the use of locksupport in detail
- Explain ThreadLocal in detail
- 每日三题 6.30
- Data enhancement of semi supervised learning
- Microservice stability management
- 若干互联网暴露面的收敛及处置建议
- What are the benefits of third party acceptance testing? Recommended by professional third-party software testing institutions
- Openresty load balancing
- Genicam gentl standard ver1.5 (4) Chapter 5 acquisition engine
猜你喜欢
What is the mosaic tailgate?
【嵌入式系统课设】单个按键控制LED灯
mysql binlog的清理
实在RPA:银行数字化,业务流程自动化“一小步”,贷款审核效率“一大步”
Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
2022年危险化学品经营单位安全管理人员考试题及在线模拟考试
The digital summit is popular, and city chain technology has triggered a new round of business transformation
思科--WAN 的概念考试外部工具
2022 R1 fast opening pressure vessel operation test questions and answers
Introduction and use of plantuml
随机推荐
rviz打开后如何显示实时2D地图
flutter Unable to load asset: assets/images/888. png
Redis数据类型和应用场景
【微服务|Sentinel】SentinelResourceAspect详解
微信个人小商店一键开通助手小程序开发
内存泄露和内存溢出的区别是什么?
有些能力,是工作中学不来的,看看这篇超过90%同行
CKS CKA ckad change terminal to remote desktop
Openresty load balancing
Three development trends of enterprise application from the perspective of the third technological revolution
Multiple smart pointers
js——arguments的使用
91. (cesium chapter) cesium rocket launch simulation
“35岁,公司老总,月薪2万送外卖“:时代抛弃你,连声再见都没有
Istio, ebpf and rsocket Broker: in depth study of service grid
通过Go语言创建CA与签发证书
数字化转型道阻且长,如何迈好关键的第一步
Contents of other parts of the map
win 10 mstsc连接 RemoteApp
Simple interactive operation of electron learning (III)