当前位置:网站首页>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 建议大家尝试
边栏推荐
- 21 Days of Deep Learning - Convolutional Neural Networks (CNN): Clothing Image Classification (Day 3)
- hcip BGP 增强实验
- [强网杯2022]WP-UM
- CCVR eases heterogeneous federated learning based on classifier calibration
- NowCoderTOP35-40 - continuous update ing
- Seata source code analysis: initialization process of TM RM client
- 19. Server-side session technology Session
- HStreamDB Newsletter 2022-07|分区模型优化、数据集成框架进一步完善
- eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
- MySQL内部函数介绍
猜你喜欢

电竞、便捷、高效、安全,盘点OriginOS功能的关键词

Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g

Open Source Summer | How OpenHarmony Query Device Type (eTS)

如何实现按键的短按、长按检测?

Dry goods!Generative Model Evaluation and Diagnosis

After Keil upgrades to AC6, what changes?

MySQL内部函数介绍

How to realize the short press and long press detection of the button?

three物体围绕一周呈球形排列

CPU的亲缘性affinity
随机推荐
力扣(LeetCode)216. 组合总和 III(2022.08.04)
HStreamDB Newsletter 2022-07|分区模型优化、数据集成框架进一步完善
仿SBUS与串口数据固定转换
After Keil upgrades to AC6, what changes?
IDEA performs the Test operation, resulting in duplicate data when data is inserted
干货!生成模型的评价与诊断
Voice conversion相关语音数据集综合汇总
What is CRM Decision Analysis Management?
STM32+ULN2003驱动28BYJ4步进电机(根据圈数正转、反转)
Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)
无题五
无题十二
无题七
js劫持数组push方法
一文道清什么是SPL
Imitation SBUS fixed with serial data conversion
项目成本控制如何帮助项目成功?
The Seven Weapons of Programmers
mysql进阶(二十七)数据库索引原理
MySQL advanced (twenty-seven) database index principle