viewer icon indicating copy to clipboard operation
viewer copied to clipboard

Support Reality Data location as initial viewer location

Open ben-polinsky opened this issue 6 months ago • 2 comments

Reality Data often has location data attached to it. This can be queried using RealityDataSource.getSpatialLocationAndExtents(). However, the RealityData client isn't fully initialized until iModelApp is initialized.

To initialize the iModelApp in our Viewer, we need to pass what we have deemed to be valid props. For "spatial" blank connections, this means a location and extents. And thus we have a chicken or the egg situation: iModelApp must be initialized before we can get location data, but we need the location data to initialize iModelApp.

A shabby workaround is to force a re-render of the viewer when the desired location data is returned from the RD client, supplying a dummy initial location to get iModelApp initialized in the meantime.

I need to take a closer look at iModelApp/RD initialization as well as how BlankConnections work in core to come up with a good solution - but perhaps separating iModelApp init into a hook could work.

Edit: here's the example I've whipped up with ugly initialization: https://github.com/ben-polinsky/reality-data-viewer-example/

ben-polinsky avatar Aug 20 '25 19:08 ben-polinsky

I'm very oblivious to reality data, but I'm assuming the data differs based on the iModel used... how would passing something dynamic into the initial props of the viewer work?

hl662 avatar Aug 20 '25 19:08 hl662

Reality Data is attached to an iTwin or to an org: https://developer.bentley.com/apis/reality-management/operations/get-all-reality-data/

I don't know that the Viewer needs to accept something dynamic (but we could possibly pass a promise). Above I am suggesting we separate the initialization of iModelApp from the Viewer init as one possibility.

ben-polinsky avatar Aug 20 '25 19:08 ben-polinsky