当前位置:网站首页>dat.GUI
dat.GUI
2022-07-01 22:27:00 【yzhSWJ】
dat.GUI 是一个轻量级的图形用户界面库(GUI 组件),使用这个库可以很容易地创建出能够改变代码变量的界面组件。
使用步骤
(1)首先在页面的 <head> 标签中添加这个库。
<script type="text/javascript" src="../libs/dat.gui.js"></script>
(2)定义一个 JavaScript 对象(这里假设叫做 controls),该对象将保存希望通过 dat.GUI 改变的属性。
var controls = new function () {
this.rotationSpeed = 0.02;
//......
};(3)接下来需要将这个 JavaScript 对象传递给 dat.gui 对象,并设置各个属性的取值范围。
var gui = new dat.GUI(); gui.add(controls, 'rotationSpeed', 0, 0.5); //......
(4)最后当用户对 dat.GUI 控件进行操作时,controls 里的属性值也会同步修改。我们在程序中直接引用这个属性值就好了。
demo
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++初始化gui++++++++++++++++++++++++++++++++++++++++++++
var gui = new dat.GUI();
gui.add(cube.position, "x")
.min(0)
.max(5)
.step(0.01)
.name("移动x轴坐标")
.onChange(value => {
console.log('被修改后的值:', value)
})
.onFinishChange(value => {
console.log('完全停下出发', value)
})
//+++++++++++++++++修改物体颜色++++++++++++++
const params = {
color: '#ffff00',
fn: () => {
//让物体运动起来
gsap.to(cube.position, { x: 5, duration: 5, yoyo: true, repeat: -1 })
}
}
gui.addColor(params, "color")
.onChange(value => {
console.log('被修改后的值:', value)
cube.material.color.set(value)
})
//+++++++++++++++++++++是否显示 选项框++++++++++++++++
gui.add(cube, "visible").name('是否显示')
//+++++++++++设置按钮触发事件++++++++++++++++++++++++++
gui.add(params, 'fn').name('点击立方体运动')
//+++++++++++++++++把配置放在某一个文件夹下+++++++++++++++++++++
var folder = gui.addFolder("设置立方体")//文件夹名
//把设置都放在文件夹下面
folder.add(cube.material, 'wireframe')//只显示线框边栏推荐
- Simple interactive operation of electron learning (III)
- 每日刷题记录 (十)
- Cloud Vulnerability Global Database
- Detailed explanation of twenty common software testing methods (the most complete in History)
- Digital currency: far-reaching innovation
- Cisco test -- the concept and configuration test of routing
- 实在RPA:银行数字化,业务流程自动化“一小步”,贷款审核效率“一大步”
- 赵福全:短期解决保供,长期要打造安全、高效有韧性的供应链
- Happy number [fast and slow pointer of ring PROBLEMS]
- Vsphere+ and vsan+ are coming! VMware hybrid cloud focus: native, fast migration, mixed load
猜你喜欢
![[JUC learning road day 9] barrier derivatives](/img/7d/25a49afa470cfef5b7b383918d6a7d.png)
[JUC learning road day 9] barrier derivatives

vSphere+、vSAN+来了!VMware 混合云聚焦:原生、快速迁移、混合负载
![[target tracking] | single target tracking indicator](/img/07/033d5c07b07e3443330840e98940b3.png)
[target tracking] | single target tracking indicator

Metauniverse may become a new direction of Internet development

Advanced skills of testers: a guide to the application of unit test reports

Explain JMM in detail

Deadlock handling strategies - prevent deadlock, avoid deadlock, detect and remove deadlock

YOGA27多维一体电脑,兼具出色外观与高端配置

el-input文本域字数限制,超过显示变红并禁止输入

【嵌入式系统课设】单个按键控制LED灯
随机推荐
Where can the courses purchased by CSDN be accessed
SAP intelligent robot process automation (IRPA) solution sharing
Happy number [fast and slow pointer of ring PROBLEMS]
使用3DMax制作一个象棋棋子
Rank ranking with MySQL 5.7
Deadlock handling strategies - prevent deadlock, avoid deadlock, detect and remove deadlock
Cisco exam -- redundant network
[QT widget] encapsulates a simple thread management class
[daily training] 326 Power of 3
Using emqx cloud to realize one machine one secret verification of IOT devices
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
转--利用C语言中的setjmp和longjmp,来实现异常捕获和协程
tcpdump命令使用详解
Kubernetes create service access pod
Share some feelings of a programmer who has experienced layoffs twice a year
el-input文本域字数限制,超过显示变红并禁止输入
想请教一下,证券开户选择哪个证券比较好?手机开户是安全么?
El input text field word limit, beyond which the display turns red and input is prohibited
91. (cesium chapter) cesium rocket launch simulation
Groups and ranges of regular series