当前位置:网站首页>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 建议大家尝试
边栏推荐
- What is the function of the regular expression replaceAll() method?
- 【Office】Microsoft Office下载地址合集(微软官方原版离线安装下载)
- egg框架使用(一)
- 2022.8.3
- Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
- MySQL advanced (twenty-seven) database index principle
- 19. Server-side session technology Session
- Development common manual link sharing
- PAT Level B - B1021 Single Digit Statistics (15)
- 蚁剑webshell动态加密连接分析与实践
猜你喜欢
随机推荐
NowCoderTOP35-40——持续更新ing
公众号如何运维?公众号运维专业团队
IDEA执行Test操作导致数据插入时出现了重复数据
手把手教你纯c实现异常捕获try-catch组件
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
Can MySQL use aggregate functions without GROUP BY?
2022-08-01 回顾基础二叉树以及操作
轩辕实验室丨欧盟EVITA项目预研 第一章(四)
IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
入门 Polkadot 平行链开发,看这一篇就够了
PHP operation mangoDb
为什么sys_class 里显示的很多表的 RELTABLESPACE 值为 0 ?
首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
[Unity] [UGUI] [Display text on the screen]
Advanced usage of C language
开发常用手册链接分享
21 Days of Deep Learning - Convolutional Neural Networks (CNN): Clothing Image Classification (Day 3)
无题十一
seata源码解析:TM RM 客户端的初始化过程
自定义过滤器和拦截器实现ThreadLocal线程封闭








