首页 > 解决方案 > 从 hitTest.face.normal 获取全局法线

问题描述

我正在做一个 hitTest 以在法线面上创建一个剖面。为了获得全球常态,我必须对hitTest.face.normal. 它似乎几乎可以工作,但我的结果似乎与实际正常情况略有不同,所以我认为我做错了什么:

const normalMatrix = new THREE.Matrix3().getNormalMatrix( this.hitTest.object.matrixWorld );
const normal = this.hitTest.face.normal.clone().applyMatrix3( normalMatrix )

this.SectionExtension.tool.setSectionPlane(normal, this.hitTest.point)

如图所示,我的最终切割平面与实际平面略有偏差

谁能看到以这种方式获得飞机可能会出现什么问题,或者有没有人有更好的方法来找到全球常态?

先感谢您!

标签: three.jsautodesk-forgeautodesk-viewer

解决方案


你能分享更多关于面部正常应该是什么的细节吗?Section Plane以下是查看器的上下文菜单如何根据面部命中点创建剖面的代码片段。它可能会有所帮助。

const selected = viewer.getSelection();
const intersection = viewer.impl.hitTest(status.canvasX, status.canvasY, false, selected);

// Ensure that the selected object is the on that recieved the context click.
if (intersection && intersection.face && selected.indexOf(intersection.dbId) !== -1) {
    sectionExtension.tool.setSectionPlane(section, intersection.face.normal, intersection.point);
}

推荐阅读