当前位置:网站首页>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
边栏推荐
- 2022 R1 fast opening pressure vessel operation test questions and answers
- vim给目录加颜色
- Treatment of insufficient space in the root partition of armbain system
- 【Kotlin 第三方 】coil koltin协程图片加载库Coil类似Glide的图片加载第三方
- CKS CKA ckad change terminal to remote desktop
- Compare the version number [double pointer to intercept the string you want]
- The online beggar function of Japanese shopping websites
- mysql binlog的清理
- Jerry's burning of upper version materials requires [chapter]
- 2022安全员-C证考试题模拟考试题库及模拟考试
猜你喜欢
【嵌入式系统课设】单个按键控制LED灯
The online beggar function of Japanese shopping websites
Demo program implementation of QT version Huarui camera
91. (cesium chapter) cesium rocket launch simulation
Cisco test -- the concept and configuration test of routing
[applet] realize the left and right [sliding] list through the scroll view component
Cisco -- an external tool for WAN's concept examination
思科--WAN 的概念考试外部工具
正则系列之组和范围(Groups and Ranges)
OpenVINO 模型性能评估工具—DL Workbench
随机推荐
微信个人小商店一键开通助手小程序开发
Some thoughts on game performance optimization
rviz打开后如何显示实时2D地图
[micro service sentinel] sentinelresourceaspect details
CADD course learning (3) -- target drug interaction
Microservice stability management
STM32F030F4驱动TIM1637数码管芯片
vim给目录加颜色
力扣 710. 黑名单中的随机数
每日三题 6.28
plain framework的实际应用和扩展
The difference between timer and scheduledthreadpoolexecutor
Wechat personal small store one click opening assistant applet development
OpenVINO 模型性能评估工具—DL Workbench
The online beggar function of Japanese shopping websites
The digital summit is popular, and city chain technology has triggered a new round of business transformation
[MySQL] index classification
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
openresty 负载均衡
通过Go语言创建CA与签发证书