Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Raycasting the map

kircher1 edited this page Jun 14, 2019 · 15 revisions

Overview

Using the MapRenderer's Raycast API, it is possible to detect the point and location where a ray intersects the map surface.

If a ray intersects the map, the following information is provided about the hit:

  • The point in world space
  • The triangle normal in world space
  • The distance from the ray origin to the hit point (in world space)
  • The LatLonAlt of the hit point

The raycast API enables various features and scenarios. A basic example would be handling tap and mouse-clicks to determine what LatLon a user is clicking on.

More complex scenarios that enable map manipulations like dragging and panning the map with a mouse, or the pointer of a MR-based controller, like in the clip shown above.

Usage

TODO

To build functionality that leverages the raycast API, like map interactions, it may also be useful to convert points from Unity space to LatLon relative to the map. The MapRendererTransformExtensions provide the methods for these conversions.

Performance considerations

Raycasting takes a short amount of time to execute, but this is done on the Unity thread where time is critical, especially for mixed reality scenarios where frame targets can be upwards of 90 FPS.

It is best to minimize the raycast API usage: Don't call the API unnecessarily. Also, avoid cases where the API is called with the same arguments in a given frame, in this case, the original result can be cached and reused.


Clone this wiki locally