从hitTest.face.normal中获取全局法线。

问题描述 投票:0回答:1

我正在做一个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.js autodesk-forge autodesk-viewer
1个回答
0
投票

你能分享更多关于脸部法线应该是什么的细节吗?这里是代码片段,如何查看器的上下文菜单。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);
}

0
投票

如果有人有兴趣的话,我找到了一个解决我问题的方法。

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

在使用法线之前,帮助我得到正确的法线。我没有使用'renderProxy'来做任何事情--但我假设它能以某种方式帮助查看者。总之--这对我来说是可行的

© www.soinside.com 2019 - 2024. All rights reserved.