itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

How to enable snapping feature on location or distance measurement tool with blankiModelConnection or to have it working with 3D model and prohibit point identification in background.

Open Praful-Bentley opened this issue 2 months ago • 12 comments

We observe the red circle aligning the face of the iTwin geometry and the yellow cross at the center. This is very helpful in snapping to a location on the 3D model (iTwin geometries).

https://github.com/user-attachments/assets/b25de073-ea7f-49e9-bd84-d22edd760283

By default this is not working for the reality or 3D model as shown. I want this snapping to be enabled for the reality model or 3D model for the location or any custom Hit location tool in my application. What should I do?

Praful-Bentley avatar Nov 14 '25 06:11 Praful-Bentley

@MarcBedard8 any recommendations here for snapping to reality models?

aruniverse avatar Nov 14 '25 16:11 aruniverse

Reality model are composed of meshes and doesn't give geometry to snap to. You can change snap mode to snap to nearest or keypoint.

Image

MarcBedard8 avatar Nov 14 '25 16:11 MarcBedard8

Let me tell the user if that works for them.

Until then, I'll mark it close.

Praful-Bentley avatar Nov 17 '25 06:11 Praful-Bentley

I have to reopen this issue as the user still finds it uneasy to measure distances.

Like in this video, I turned off the map but I'm able to click a point in the space. Is there a way to make the points to only identify the 3D geometry but not the empty space ?

https://github.com/user-attachments/assets/39057a27-cca2-4471-9ae9-a1d83d66481b

Praful-Bentley avatar Nov 18 '25 08:11 Praful-Bentley

Look like we had a similar thread some time ago (c.f.: https://github.com/iTwin/itwinjs-core/discussions/7457#discussioncomment-11524528) @saaaaaally Do you remember if/how we solve this?

MarcBedard8 avatar Nov 18 '25 14:11 MarcBedard8

Yes, solved a similar issue in the measure volume tool by using this code for selecting points:

public static getDepthPoint(ev: BeButtonEvent): Point3d {
  if (!ev.viewport)
    return ev.point;

  const pickRadiusPixels = ev.viewport.pixelsFromInches(0.2);
  const result = ev.viewport.pickDepthPoint(ev.rawPoint, pickRadiusPixels);
  const planePoint = result.plane.getOriginRef();
  return planePoint;
}

saaaaaally avatar Nov 19 '25 19:11 saaaaaally

Yes, solved a similar issue in the measure volume tool by using this code for selecting points:

public static getDepthPoint(ev: BeButtonEvent): Point3d {
  if (!ev.viewport)
    return ev.point;

  const pickRadiusPixels = ev.viewport.pixelsFromInches(0.2);
  const result = ev.viewport.pickDepthPoint(ev.rawPoint, pickRadiusPixels);
  const planePoint = result.plane.getOriginRef();
  return planePoint;
}

So, do I need to create all the measurements tools again locally where I need this feature in my application and use this method in it?

Praful-Bentley avatar Nov 21 '25 11:11 Praful-Bentley

You could create a tool that derived from the original one and override that part.

MarcBedard8 avatar Nov 21 '25 16:11 MarcBedard8

I'll try that.

Can we have this feature built into the tool out of the box to be able to identify the 3D geometries and the background map or space?

Can I request this feature, if yes, how should i?

Praful-Bentley avatar Dec 02 '25 05:12 Praful-Bentley

I have created a sandbox with a custom distance measurement tool from a reference.

The objective is to prohibit any point selection in the black background. User should be able to only click or identify points on 3d Reality Model or iTwin Geometry.

Image

Can we update the tool to avoid identifying the point in the background?

Praful-Bentley avatar Dec 02 '25 12:12 Praful-Bentley

@ben-polinsky , @aruniverse. This appears to be a major issue on the user’s side. Can we prioritize addressing it?

tm-zub avatar Dec 08 '25 15:12 tm-zub

@Praful-Bentley can this be closed in favor of https://github.com/iTwin/itwinjs-core/issues/8843?

Also, looking at the sandbox, you're overriding the MeasureDistanceTool, but you aren't registering the tool, so it must be reverting to the base MeasureDistanceTool?

That should get you started. I'll try to take a look at this a bit more closely tomorrow, as well.

ben-polinsky avatar Dec 10 '25 21:12 ben-polinsky

Sure closing this.

Praful-Bentley avatar Dec 17 '25 11:12 Praful-Bentley