当光标在3d模型上悬停时,我尝试显示快照图标(一些黄色图标和光标一起出现在进行测量时)。这是我的职责,对我一点也不管用。我错过了什么吗?
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 .提前感谢!
发布于 2020-07-27 01:23:04
我认为这个问题是由于观看者缺少容器偏移造成的。世界坐标不能被正确地测试。如果有帮助,请检查下面的代码。如果我误解了这个问题,你能分享更多关于它不起作用的信息吗?
更新
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()
}https://stackoverflow.com/questions/63032246
复制相似问题