![](/img/trans.png)
[英]Select particular 3d view to show in autodesk forge viewer
[英]Show icon snap on Forge Viewer 3D
I try to show snap icon ( some yellow icon go with cursor appear when make measurement ) when the cursor hover on the 3d model. 這是我的 function,它根本不適合我。 我想念什么嗎?
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();
}
我也參考了其中一些主題,但對我不起作用。 如何使用 Forge Viewer Snapper? 如何激活 Autodesk Forge Snapper? https://autodeskviewer.com/viewers/latest/docs/extensions_Measure_Measure.js.html 。 預先感謝 !
我認為這個問題是由於缺少查看器的容器偏移量造成的。 無法正確測試世界坐標。 如果有幫助,請檢查下面的代碼。 如果我誤解了這個問題,您能否分享更多關於它不起作用的信息?
更新:
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()
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.