Custom Loader - Viewer 2.0 API

Hello Dear Specklers!

Fantastic work on the new Viewer 2.0 API @alex !

I’ve been diving into the API lately, experimenting with building a Viewer that showcases Rooms and Areas as planar meshes. Later on I want to build an extension to load some Sprites that represent the positions of furniture within the interior.

I made a custom Loader to fetch Rooms from a Speckle stream and display them using room.outline. Seems to work quite well, but there is a couple of issues that I encountered.

Please see my code here: Sandbox

The Issues I have:

  1. cameraController.setOrthoCameraOn()
    doesn’t extend the zoom to the scene when called immediately after the loader. As a temporary solution, I’ve implemented a workaround using a timeout to call it with a slight delay.

  2. Raycasting/Selecting - it occasionally selects a room that is below the first one or fails to select a room altogether. Could this be related to the BVH not being built correctly with my custom loader?

  3. Ambient Occlusion - after selecting and deselecting couple of times, AO gets darker (like it doesn’t clear previous frames?). It happens regardless if I use the custom loader or the SpeckleLoader. Edit: It works fine in 2.17.0-alpha.8. :slight_smile:

  4. Double-click event - works correctly with version 2.17.0-alpha.6 , but with 2.17.0-alpha.8 , it throws an error stating it can’t find the ID of the selected object. I’ve noticed a similar issue when using OBJLoader with this version.

  5. There are some Loader Types that are not exported currently, but I’ve seen that you are working on it atm :slight_smile:

3 Likes

Hi @DanielSBoba

Thank you for trying out API 2.0! We’re all very excited to see people use it in the wild, especially for interesting use cases such as yours! :slight_smile:

I’ll need to take a close look at the issues you mentioned, and get back to you soon!

Cheers

5 Likes

Hi @DanielSBoba

I went over your issue points one by one, and here are the resolutions

cameraController.setOrthoCameraOn()
doesn’t extend the zoom to the scene when called immediately after the loader. As a temporary solution, I’ve implemented a workaround using a timeout to call it with a slight delay.

Indeed, there is a timing issue here related to how the controller library that we use currently works. An alternative to using a timeout is to call cameraController.controls.update(1) before cameraController.setOrthoCameraOn().

Raycasting/Selecting - it occasionally selects a room that is below the first one or fails to select a room altogether. Could this be related to the BVH not being built correctly with my custom loader?

This issue is now fixed. You custom loader had nothing to do with it, it was a fp precision issue :slight_smile:

Double-click event - works correctly with version 2.17.0-alpha.6 , but with 2.17.0-alpha.8 , it throws an error stating it can’t find the ID of the selected object. I’ve noticed a similar issue when using OBJLoader with this version.

Issue fixed

There are some Loader Types that are not exported currently, but I’ve seen that you are working on it atm

The types exported by API 2.0 are still yet to be completely decided, but we’re getting closer :slight_smile:

The fixes mentioned are coming out with an alpha.9 npm release in the next days along with another big update to API 2.0 which I’ll be describing in it’s own post :wink:

Thank you again for the valuable feedback you’re providing and I can only hope to see more of it! :slight_smile:

Cheers

3 Likes

That’s awesome @alex,
Thank you for the feedback!

1 Like