计算顶点法线功能。

This commit is contained in:
tengge1 2019-11-08 22:06:12 +08:00
parent 7af7dc01f4
commit 2db3aa2f18
3 changed files with 27 additions and 3 deletions

View File

@ -44,7 +44,7 @@ Supported Languages: 中文 / [繁體中文](README-tw.md) / [English](README-en
30. 修复点击眼睛图标时整个场景树折叠bug。
31. 新增添加模型模式:添加到中心、点击场景添加。
32. 增加显示选项,设置选中边框颜色和粗细。
33. 新增BufferGeometry组件查看BufferGeometry的顶点数量、法线数量、UV坐标数量、索引数量。
33. 新增BufferGeometry组件查看BufferGeometry的顶点数量、法线数量、UV坐标数量、索引数量。提供计算顶点法线功能,如果模型是黑的,可能没有法线,可以试一下这个功能。
## v0.3.6更新

View File

@ -920,5 +920,7 @@
"Position Count": "顶点数量",
"Normal Count": "法线数量",
"UV Count": "UV数量",
"Index Count": "索引数量"
"Index Count": "索引数量",
"Compute Vertex Normals": "计算顶点法线",
"Compute Face Normals": "计算面法线"
}

View File

@ -1,4 +1,4 @@
import { PropertyGrid, PropertyGroup, TextProperty, DisplayProperty, CheckBoxProperty, NumberProperty, IntegerProperty } from '../../../third_party';
import { PropertyGrid, PropertyGroup, TextProperty, DisplayProperty, CheckBoxProperty, NumberProperty, IntegerProperty, ButtonProperty } from '../../../third_party';
import SetGeometryCommand from '../../../command/SetGeometryCommand';
/**
@ -22,6 +22,9 @@ class BufferGeometryComponent extends React.Component {
this.handleExpand = this.handleExpand.bind(this);
this.handleUpdate = this.handleUpdate.bind(this);
this.handleComputeVertexNormals = this.handleComputeVertexNormals.bind(this);
// this.handleComputeFaceNormals = this.handleComputeFaceNormals.bind(this);
}
render() {
@ -36,6 +39,8 @@ class BufferGeometryComponent extends React.Component {
<DisplayProperty label={_t('Normal Count')} value={normalCount.toString()}></DisplayProperty>
<DisplayProperty label={_t('UV Count')} value={uvCount.toString()}></DisplayProperty>
<DisplayProperty label={_t('Index Count')} value={indexCound.toString()}></DisplayProperty>
<ButtonProperty text={_t('Compute Vertex Normals')} onChange={this.handleComputeVertexNormals}></ButtonProperty>
{/* <ButtonProperty text={'Compute Face Normals'} onChange={this.handleComputeFaceNormals}></ButtonProperty> */}
</PropertyGroup>;
}
@ -72,6 +77,23 @@ class BufferGeometryComponent extends React.Component {
indexCound: geometry.index ? geometry.index.count : 0
});
}
handleComputeVertexNormals() {
const geometry = this.selected.geometry;
if (!geometry) {
return;
}
geometry.computeVertexNormals();
}
// computeFaceNormalsthree.js
// handleComputeFaceNormals() {
// const geometry = this.selected.geometry;
// if (!geometry) {
// return;
// }
// geometry.computeFaceNormals();
// }
}
export default BufferGeometryComponent;