clampToHeight & heightReference incorrect behavior when toggling tileset on/off

Hello all,

I have the sandbox here to explain the issue.

Our use case is that users can place billboards on their 3d tileset and they can also toggle the 3d tileset on and off. We would also have the terrain data turned off when 3d tileset is on, we think it would improve the performance since we won’t need the terrain data if we have the 3d tileset.

As the sandbox shows, the first time it loads, the billboards are correctly placed on the 3d tileset (with HeightReference.NONE and getting the position using viewer.scene.clampToHeight).


If you click the toggle button, the billboards are also properly placed on the ground (since it’s using HeightReference.CLAMP_TO_GROUND and terrain is using the world terrain).


If you click the toggle button again to show the 3d tileset, for some reason the billboards are now on the ground but the labels are stuck at the 3d tileset. This is the unexpected behavior that I was asking for help about.

To elaborate, it was fine for one single frame, then this screen happens the moment you pan/tilt the camera. Here’s a gif.

Peek 2021-07-14 15-38

Subsequent toggles would have the same result.


It’s worth nothing that in the code, I’ve always recreated the billboards whenever toggling the button, to avoid any state that might have stuck in between toggling actions, though I did try setting the entity.billboard.heightReference manually when toggling, but it’s the same.

Please try it out yourself by toggling the button a few times to see if it has the same result or not.

It seems to me that it is a bug, but if there’s anything else I could improve in terms of the implementation, let me know. Thank you!

@iwakuya

Thank you for the detailed forum post! The sandcastle demo is very helpful - I was able to quickly reproduce the error. Also, your implementation seems fine to me.

I noticed a few things:

  1. This error seems to occur for any number of billboard values.

  2. If toggled is initialized to true (`let toggled = true;) we see even more erratic behavior when toggling the tileset on and off. It seems like the billboards disappear and then re-appear.

Are you able to reproduce these two errors? Do you have any ideas for a quick-fix? A quick-fix might be helpful to have before we start looking at the source code.

-Sam

Hello, thanks for looking into this. Yes both issues occur on my side too. I should have mentioned in the original post that I did try them out with fewer billboards and other iterations (for example, I did try keeping the terrain all the time, only having the heightReference being toggled), which still caused the issue to happen regardless.

As for any quick-fix, I’ve been looking into workarounds but none of them could really work without actually involving changing the UX of the feature (for example, keeping the terrain on or not letting them toggle), which is a deal breaker. So I think we would love to see if the bug could be fix. Or rather if anyone else knows any other workaround for this. Cheers

1 Like

@iwakuya

Thank you for the additional details. I just submitted an issue on our GitHub page.

Let me know if there are any details that I missed when creating the issue. I would be happy to review a pull request for this issue, as I think it impacts a significant number of users. However, given the sheer number of issues that our development team needs to address, I can’t promise that this issue will be looked at immediately.

-Sam

1 Like