【问题标题】:Getting global normal from hitTest.face.normal从 hitTest.face.normal 获取全局法线
【发布时间】:2020-08-14 17:56:31
【问题描述】:

我正在做一个 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

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

提前谢谢你!

【问题讨论】:

  • 你能用这个代码试试吗:const normal = this.hitTest.face.normal.clone(); 然后normal.transformDirection( this.hitTest.object.matrixWorld );
  • 相同的结果.. 已经进行了更多测试 - 如果面孔相当简单且正常接近干净的 X/Y/Z 向量,那么我没有任何问题。会不会是容忍问题?我不知道 Autodesk-forge 的容差,但我可以看到面法线有相当多的小数点 - 所以我猜某种四舍五入可能会使我的剖面像这样稍微偏离?

标签: three.js autodesk-forge autodesk-viewer


【解决方案1】:

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

【讨论】:

  • 我不确定我能准确地弄清楚正常情况应该是什么,我只能看到结果(原始帖子中的图片)略有偏差。这可能是正常的容忍问题吗?我看到上下文菜单使用了 'viewer.impl.hitTest' 而不仅仅是 'viewer.hitTest' 我可以检查并确保这不会给我另一个结果。
【解决方案2】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    相关资源
    最近更新 更多