从 hitTest.face.normal 获取全局正常值

Getting global normal from 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)

As seen on the picture, my ending cut plane is slightly off the actual plane

任何人都可以看到在这种获取飞机的方式中可能出现的问题,或者任何人有更好的方法来找到全局正常值吗?

提前致谢!

你能分享更多关于面部法线应该是什么的细节吗?下面是查看器的上下文菜单 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);
}

如果有人感兴趣,那么我找到了解决问题的方法 出于某种原因,当 运行

const currentFragId = this.hitTest.fragId;
const renderProxy = this.viewer.impl.getRenderProxy(this.viewer.model,currentFragId);

在使用法线之前帮助我获得了正确的法线。我不使用 'renderProxy' 做任何事情 - 但我认为它以某种方式帮助观众。无论如何 - 这对我有用!