当前位置:网站首页>three.js debugging tool dat.gui use
three.js debugging tool dat.gui use
2022-08-05 10:01:00 【Jedi Hongbin】
在three.js Easy observation object changes as web page Often a can't reached the position that we want to 需要微调 And each load model still needs some time Debugging time is longer 相应的three.jsThe author wrote this debugging tool 方便three.js中调试.
安装
yarn add dat.gui
or
npm install --save dat.gui
导出
// CommonJS:
const dat = require('dat.gui');
// ES6:
import * as dat from 'dat.gui';
创建一个实例
const gui = new dat.GUI();
I prefer to use
import {
GUI } from "dat.gui";
const gui = new GUI();
All in all select the way you like to create aguiOpen debugging
gui的工作方式
传入一个对象,The object of the values of type determining forms of the debugging tools
比如 值是一个boolean值 The corresponding debugging tools will show a check box The present value of state
如果 值是一个函数 Corresponding is a button Click on the button to trigger the function
In order to as debugging format 接下来 According to the scene to introduce several debug mode
Modify the position of the object
物体的posiiton属性中的x,y,z决定位置
gui.add(mesh.position,'x')
The modified object transfer into the first parameter The modified attribute name(字符串形式)作为第二个参数 That is correctx轴坐标
gui.add(mesh.position,'x',0,100)
Behind the two parameters is minimum and maximum
这是类型定义 The rest of the a parameter is how much a change
In view of the location change can encapsulate a function Province line to write
typescript
const positionkeys: ["x", "y", "z"] = ["x", "y", "z"];
export const guiPosiiton = (mesh: Object3D, range: number = 20, name?: string) => {
const {
name: meshName, type, uuid, position } = mesh;
// 新建一个文件夹
const fidld = gui.addFolder(name || meshName || type + uuid.substring(0, 5));
for (const key of positionkeys) {
fidld.add(position, key, position[key] - range, position[key] + range);
}
};
javascript
const positionkeys = ["x", "y", "z"];
export const guiPosiiton = (mesh, range = 20, name) => {
const {
name: meshName, type, uuid, position } = mesh;
// 新建一个文件夹
const fidld = gui.addFolder(name || meshName || type + uuid.substring(0, 5));
for (const key of positionkeys) {
fidld.add(position, key, position[key] - range, position[key] + range);
}
};
监听值的改变
gui.add({
count:0},'count',-10,10).onChange(val => {
xxx.xxx = val;
})
在onChange中获得当前的value
按钮
gui.add({
fn:() => console.log(123) },'fn')
点击 fn 调用fn这个函数 Don't want to use the property name if the name can be set active
gui.add({
fn:() => console.log(123) },'fn').name('打印')
Modify texture color
const material = new MeshPhongMaterial();
const params = {
color: 0xffffff
};
gui.addColor(params, "color").onChange((color) => {
material.color = color;
});
模式选择 – 选择器
const options = [1, 2, 3, 4];
gui.add({
难度: 1 }, "难度")
.options(options)
.onChange((val) => {
console.log("select", val);
});
字符串修改
gui.add({
name: "hongbin" }, "name");
Commonly used is probably this several follow-up will slowly add more debugging method
Everyone can be adjusted according to the environment This tool is very interesting 建议大家尝试
边栏推荐
- PAT乙级-B1021 个位数统计(15)
- 深度学习21天——卷积神经网络(CNN):天气识别(第5天)
- The Seven Weapons of Programmers
- First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
- Oracle temporary table space role
- PAT Grade B-B1020 Mooncake(25)
- 基于MindSpore高效完成图像分割,实现Dice!
- 浅析WSGI协议
- 上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
- three.js调试工具dat.gui使用
猜你喜欢
随机推荐
首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
告白数字化转型时代:麦聪软件以最简单的方式让企业把数据用起来
Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
2022/8/4 考试总结
攻防世界-PWN-new_easypwn
深度学习21天——卷积神经网络(CNN):服装图像分类(第3天)
轩辕实验室丨欧盟EVITA项目预研 第一章(四)
Jenkins使用手册(2) —— 软件配置
无题十三
STM32+ULN2003驱动28BYJ4步进电机(根据圈数正转、反转)
长达四年的减肥记录
【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样
NowCoderTOP35-40 - continuous update ing
手写柯里化 - toString 理解
ffmpeg drawtext add text watermark
Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)
IO流篇 -- 基于io流实现文件夹拷贝(拷贝子文件夹及子文件夹内文件)满满的干货
Happens-before rules for threads
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
seata源码解析:TM RM 客户端的初始化过程