A few questions about the Speckle Viewer

Hello everyone! This is my first post here, and probably the answer to most of my questions is RTFM! In my defense, I spent some time checking out the viewer and the code base but couldn’t find a definitive answer to some of these questions. Hence, creating this post!

Background

I had a call today with @Ami_Nigam to discuss the new Rhino panel for the Pollination Rhino plugin we ran a test study and I was telling him about the new option to download the visualization as an HTML, and he told me that they would probably use Speckle instead. He baked the results to Rhino and used the Rhino connector to push (is this what you call it?) it to Speckle, and in a few seconds, we had the results showing up on the web → Speckle - That gave me an excuse to test the viewer after a long time, and I should say that it has come a long way! Great work Speckle team!

Then I started to think about two possibilities:

  1. To write a translator from Pollination’s VisualizationSet schema to Speckle schema. That way it will be easier for Pollination and Ladybug Tools users to stream the results to Speckle. This is something that has come up a few times but there are workarounds to do it by baking the results and using the Speckle connectors.

  2. [Maybe] using the Speckle viewer as the default viewer for Pollination instead of our Pollination viewer. This is a high-risk and major change but it will justify writing the translator, and it will also make our life easy in the future since we don’t have to develop and maintain a separate viewer.

    You can check out the Pollination Viewer here: Webpack App. It is built using the vtkjs library and is using react as the framework which is compatible with our front-end and the rest of the development stack. Here is a self-contained HTML file with the viewer if you want to give it a try: visualization_detailed.html (3.2 MB)

Questions

Now even though the Speckle viewer has many nice features that the Pollination viewer doesn’t currently have like comments, nested layer structure, and shadows it has a few critical features that seem to be missing from the Speckle viewer.

1. Legends

Am I right that the Speckle viewer doesn’t support legends? Are there any examples of having legends with color-sets based on data attached to a geometry? In what we do, colors without legends are not that useful. If you check the example that I shared you can see that a single geometry can have different datasets attached to it, and each dataset can have its own legend parameters. This felt out of the current scope of the viewer. I saw a discussion or two that it has come up but I didn’t see any serious discussion about the details of how legends might be implemented.

2. Embedding viewer in other applications

We reuse the viewer almost everywhere. In Rhino, Revit, on the web, inside Streamlit apps, etc. I saw that there is an option to embed the viewer on a web page but is there an option to create a standalone HTML file that can be saved and loaded? That’s how we currently use the viewer inside the Revit plugin. I couldn’t find an example for this one.

3. Using the viewer without a server

This is a dumb one! Do we always need a Speckle server for streaming the geometries to the viewer or is there a static version of the viewer that can be embedded in an app without a server? From what I have seen so far, the answer is no but I hope that I’m wrong.

Thank you, and I hope tomorrow evening’s event to be a great one!

5 Likes

Hey hey! Not sure this is entirely a good idea (as we’ve partially discussed in the past :sweat_smile: ), as our viewer’s target functionality is different than your viewer’s target functionality.

Direct answers first, they’re partly related to each other.

  1. Legends: can be done. It’s more of a frontend problem.

  2. Other applications: Can be done. The viewer is an independent package that has been used in react and vue apps so far. Unsure regarding the single html file. I see no network requests, so I guess this file includes the actual data. This brings me to 3:

  3. We don’t have the infrastructure yet in place for this.

The viewer currently can only deal with objects being streamed from Speckle, via the famous object-loader lib. There are plans to allow direct loading of objects from, say, json files, but not yet prioritised.

I see several hurdles - we can definitively have multiple data sets (read: vertex color sets) for a single mesh, but we’d need to find a way to expose them to the end user and then figure out the swapping logic. @alex might not be very happy reading this, but it’s probably doable.

There’s also a product question thereafter, which is should we support this in our frontend, or leave it to you only? I prefer the latter to be honest!

What scares me is that I am sure there’s quite a bit of complex domain logic that y’all have already built for analysis visualisation purposes, and I’m unsure how well we could support and maintain it (ie, edges, point cloud vis, etc.). It can definitively be done - we are good at solving tech problems, but unsure if it’s the right thing to do now.

I’ll try and grab Chris later and chat :slight_smile:

2 Likes

Hello

Indeed, currently the viewer can only load things up properly from speckle streams. It is possible to add custom user content, like some people have done in the past, however it will have to completely bypass the viewer API, so I wouldn’t recommend this route unless it’s for very simple things. Like Dim said, we are planning to make the viewer more general purpose, and we are slowly making progress in that direction. Loading data from non-speckle stream sources is something we will look into.

As for multiple per vertex data sets, it is possible to have them, but we need to have a good mechanism for exploiting them in a generic and useful way

Cheers

2 Likes

Thanks for the quick responses, @dimitrie and @alex .

I am here at the conference and we should definitely talk about this when we get the chance. I can see Mostapha is excited about the long-term potential here but I think there’s also just a lot that we can do more immediately here to help people walk between our ecosystems easily. Just having support for legends in your viewer would make it useful for people to take the simulations from Pollination and share the findings in Speckle. Even if it’s a just legend in the 3D scene as 3D geometry made on the Ladybug Tools side of things, this could be enough to get a sense of the value added here. Let’s talk more when we get a break.

6 Likes

Thank you all for the comments and suggestions.

@dimitrie, this one is slightly different from what I was suggesting before. I’m now interested to stream the simulation results/visualization set (VSF) and not necessarily the simulatable model (HBJSON) to Speckle. The visualization set is much closer to what the Speckle community would want/use.

Thank you for the clarification, @alex!

For the first version, we can do this inefficiently and create a new colored mesh for each dataset and only turn on the active one by default. The user then can switch between by turning on/off the visibility of each mesh.

I assume implementing legends is something that can benefit most of the Speckle users but for everything that gets specific to Pollination I agree with you.

That is very true. The Pollination viewer has been through a few rounds of refactoring based on the feedback and will need more of those. Building on top of the VTK infrastructure that is designed to be used for scientific visualization has saved us so much time. We have to reimplement many of those details in Speckle which can take a long time and can potentially be high-risk.

Maybe a better more generic solution, in the long term, is for Speckle to support VTKJS and then we can use that as the intermediate format.

And I second what @chriswmackey said that I’m thinking about replacing the viewer as a long-term solution but creating Speckle streams from Pollination/Ladybug Tools visualization set can be done with a few tweaks. We can do 3D geometry non-editable legends and that should make many of the users happy. I will deal with my soul being scratched every time that I will see one! :smile:

2 Likes

I just wanted to say that I really like this idea if you think it’s feasible from the Speckle side:

Maybe we can discuss this more when we get the chance. At the least, a discussion like that would give me a sense of how difficult a proof of concept would be for sending simulation results to Speckle.

5 Likes