当前位置:网站首页>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 边栏推荐
猜你喜欢

rviz打开后如何显示实时2D地图

Detailed explanation of twenty common software testing methods (the most complete in History)

Demo program implementation of QT version Huarui camera

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
![[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
![Jielizhi Bluetooth headset quality control and production skills [chapter]](/img/3e/571d246d211a979e948dae1de56e93.png)
Jielizhi Bluetooth headset quality control and production skills [chapter]

Glass mosaic

【嵌入式系统课设】单个按键控制LED灯

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

Multiple smart pointers
随机推荐
2022年起重机司机(限桥式起重机)考试试题及模拟考试
CADD课程学习(3)-- 靶点药物相互作用
每日三题 6.28
关于游戏性能优化的一些感想
js——arguments的使用
What is the relationship between modeling and later film and television?
Which securities company is better and which is safer to open a securities account
What is mosaic?
Simple interactive operation of electron learning (III)
Design of ESP automatic download circuit
Force buckle 710 Random numbers in the blacklist
SWT/ANR问题--SWT 导致 kernel fuse deadlock
第三方验收测试有什么好处?专业第三方软件测试机构推荐
[micro service sentinel] sentinel integrates openfeign
Istio, ebpf and rsocket Broker: in depth study of service grid
Understanding threads
STM32F030F4驱动TIM1637数码管芯片
Advanced skills of testers: a guide to the application of unit test reports
Redis~02 cache: how to ensure data consistency in MySQL and redis when updating data?
MySQL -- convert rownum in Oracle to MySQL