simularium / simularium-viewer

NPM package to view Simularium trajectories in 3D
Apache License 2.0
2 stars 0 forks source link

send selected agent data to front end #392

Closed interim17 closed 2 months ago

interim17 commented 3 months ago

Time Estimate or Size

small < 10 minutes

Problem

Advances website ticket: #411

We need to display metadata about selected/followed agents in the front end. That data doesn't currently leave the viewer so we need a way to get it to the front end.

Solution

This change set provides a method for retrieving data about the current followObject and a new optional viewer callback onFollowObjectChanged that handles that data.

Made NULL_AGENT constant for use in constructor and when nothing is selected.

The new code in the test-bed is a bare bones version of the meta data panel that is coming for the website, designs here.

Open questions: 1) Separate follow object and metadata selection? Clicking on an agent selects it to be camera followed and to have its metadata displayed, so it seemed obvious to use the existing followObject in visGeometry for both. If we wanted the metadata panel to stay selected/active when the user clicks "home" and toggles follow mode off (aka camera reset), we would need to store two separate objects. Having them paired on a single selected object is the simplest, since most of the UI interactions for the two features are in sync.

2) Typing was simplest if getFollowObjectData returned the NULL_AGENT when there was no selected instance, I prefer that to returning undefined or null. It does require a function using that data to do a check like agent.instanceID !== -1 when implementing.

3) I am open to naming feedback on all these methods, wasn't 100% confident in onFollowObjectChanged, updateFollowObjectData, and getFollowObjectData.

4) There are some idiosyncrasies in how the instanceIds in some trajectories are assigned that affect the reliability of these features (both following and displaying metadata) that need to be discussed with UX before the final front end work is done, but we will need this ability to send this data about selected agents to the front end.

Type of change

Steps to Verify:

  1. Select an agent and confirm that its meta data shows up in the test-bed viewer and that it updates during playback if the agent moves or changes.
github-actions[bot] commented 3 months ago

jest coverage report ๐Ÿงช

Total coverage

Status Category Percentage Covered / Total
๐Ÿ”ด Statements 41% 2049/4997
๐Ÿ”ด Branches 43.35% 845/1949
๐Ÿ”ด Functions 36.98% 419/1133
๐Ÿ”ด Lines 41.22% 1962/4759

Status of coverage: ๐ŸŸข - ok, ๐ŸŸก - slightly more than threshold, ๐Ÿ”ด - under the threshold

Show files with reduced coverage ๐Ÿ”ป ### Reduced coverage | Status | Filename | Statements | Branches | Functions | Lines | | :----: | :-------------- | :----------------- | :------- | :----------------- | :-------------- | | ๐ŸŸก | src | 74.78% | 69.09% | 43.18% | 75% | | ๐ŸŸก | constants.ts | 76.19% (-2.75% ๐Ÿ”ป) | 100% | 44.44% (-5.56% ๐Ÿ”ป) | 75% (-2.77% ๐Ÿ”ป) | | ๐Ÿ”ด | index.ts | 7.7% | 7.25% | 5.69% | 7.66% | | ๐Ÿ”ด | src/viewport | 14.33% | 10.52% | 14.63% | 13.88% | | ๐Ÿ”ด | index.tsx | 14.33% | 10.52% | 14.63% | 13.88% | | ๐Ÿ”ด | src/visGeometry | 21.77% | 22.79% | 27.61% | 21.65% | > Status of coverage: ๐ŸŸข - ok, ๐ŸŸก - slightly more than threshold, ๐Ÿ”ด - under the threshold