Issue when moving camera and using accuSnap #1259
-
We are building a tool to simulate driving on a route and we wanted to calculate the distance of between the camera position and the world point under the mouse. But when we use accuSnap to evaluate the distance it snap to a far off point of the rode (linestring) not under the cursor that makes the distance wrong. we think there might be something wrong when moving the camera and using accusnap. Any advise? We have this snippet witch is execute in a loop await IModelApp.accuSnap.reEvaluate();
const hit = IModelApp.accuSnap.currHit;
this.decoration.distance = hit ? this.calculateDistance(hit?.getPoint()) : 0; for moving the camera we use const eyePoint = Point3d.createFrom(this._cameraPosition);
eyePoint.addInPlace(Vector3d.unitZ(this._height));
eyePoint.addInPlace(Vector3d.unitZ().crossProduct(this._cameraLookAt).scale(-this._lateralOffset));
this._view.lookAtUsingLensAngle(eyePoint, eyePoint.plus(this._cameraLookAt), new Vector3d(0, 0, 1), Angle.createDegrees(this._fov));
this._viewport.synchWithView({
animateFrustumChange: true,
animationTime: this._intervalTime * 1000,
easingFunction: Easing.Linear.None,
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I would recommend not enabling AccuSnap for this, what is likely happening is that you have a snap mode of SnapMode.NearestKeypoint and it is evaluating the snap location based on the default keypoint divisor, which is 2. So for a line you will either get the start point, end point, or mid point depending on which is closest to the location under the cursor. For surfaces/solids, keypoint snap returns a point on the closest edge, etc. The other reason not to use AccuSnap is that it calls into the backend to evaluate the element geometry. Have a look at Viewport.pickNearestVisibleGeometry or Viewport.pickDepthPoint instead. |
Beta Was this translation helpful? Give feedback.
I would recommend not enabling AccuSnap for this, what is likely happening is that you have a snap mode of SnapMode.NearestKeypoint and it is evaluating the snap location based on the default keypoint divisor, which is 2.
So for a line you will either get the start point, end point, or mid point depending on which is closest to the location under the cursor. For surfaces/solids, keypoint snap returns a point on the closest edge, etc. The other reason not to use AccuSnap is that it calls into the backend to evaluate the element geometry.
Have a look at Viewport.pickNearestVisibleGeometry or Viewport.pickDepthPoint instead.