首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Forge Viewer 3D上显示图标快照

在Forge Viewer 3D上显示图标快照
EN

Stack Overflow用户
提问于 2020-07-22 10:34:55
回答 1查看 189关注 0票数 0

当光标在3d模型上悬停时,我尝试显示快照图标(一些黄色图标和光标一起出现在进行测量时)。这是我的职责,对我一点也不管用。我错过了什么吗?

代码语言:javascript
复制
onMouseMove = (event) => {
  const snapper = new Autodesk.Viewing.Extensions.Snapping.Snapper(this.viewer);
  const worldCoordinate = this.viewer.impl.hitTest(event.clientX, event.clientY);

  if (worldCoordinate === null) return;
  const hitTestResult = this.viewer.impl.snappingHitTest(
    worldCoordinate.x,
    worldCoordinate.y,
    worldCoordinate.z
  );
  if (hitTestResult === null) return;
  snapper.snapping3D(hitTestResult);
  const result = snapper.getSnapResult();
}

我也参考了其中的一些话题,但不适合我。How to use Forge Viewer Snapper? How to activate Autodesk Forge Snapper? https://autodeskviewer.com/viewers/latest/docs/extensions_Measure_Measure.js.html .提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-27 01:23:04

我认为这个问题是由于观看者缺少容器偏移造成的。世界坐标不能被正确地测试。如果有帮助,请检查下面的代码。如果我误解了这个问题,你能分享更多关于它不起作用的信息吗?

更新

代码语言:javascript
复制
onMouseMove = (event) => {

  const snapper = new Autodesk.Viewing.Extensions.Snapping.Snapper(this.viewer);

  const viewer_pos = this.viewer.container.getBoundingClientRect();   

  const worldCoordinate = this.viewer.impl.hitTest(event.clientX-viewer_pos.x, event.clientY-viewer_pos.y); 
 if (worldCoordinate === null) return;

 // const hitTestResult = this.viewer.impl.snappingHitTest(
 //   worldCoordinate.point.x,
 //   worldCoordinate.point.y,
 //   worldCoordinate.point.z
 // );    
 //if (hitTestResult === null) return;

 snapper.snapping3D(worldCoordinate);
 const result = snapper.getSnapResult(); 
 snapper.indicator.render()
 }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63032246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档