Hi there,
I hope you are well.
I am trying to clamp a large number of entities to ground and fade them out over time. I can display a lot of entities quite nicely but I can’t seem to get the clamping and fading to work at the same time.
In this Sandcastle, I use my own function to update the alpha of my entities. However, this causes flickering of the entities when used together with HeightReference.CLAMP_TO_GROUND.
In this Sandcastle, I use a CallbackPropety for the entity colour which looks great but does not seem to work at all when HeightReference.CLAMP_TO_GROUND is used. (I am not sure if the plots are actually been drawn or not, it doesn’t look like it).
The Callback property looks really good and I would love to use it but not sure what I am missing when using the height reference as well.. Otherwise, I am not sure how to stop the flickering when updating using my own function.
Thank you for the assistance.
Kind Regards
Nic
Hi @Nicholas_Bowden,
First of all - just a small tip: the new sandcastle UI has an Insert button that adds in code snippets for creating toggles and menus in your sandcastle. It can be helpful if you want to demonstrate different options interactively without requiring someone to change the code itself.
Now, to the problem itself. I believe your second sandcastle actually works as intended, but is encountering a well-known bug (one which has a fix underway). If you add disableDepthTestDistance: Number.POSITIVE_INFINITY to your points, you’ll see that they are actually appearing and being clamped to the ground. See here. In your original, your points are simply being occluded by the terrain. When this PR is released, you’ll be able to see your points even without adding that parameter to disable the depth test.
Hi @mzschwartz5,
Thanks for your quick response and for the tip! Very useful.
I’ve unified my two examples which can be switched between using the Use Color Callback Toggle and tried out the disableDepthTestDistance. Here is the Sandcastle.
So when not using the color callback method: I am still seeing flickering when clamped to ground and fading out the plots manually regardless of if the depth test is disabled or not. Although it seems slightly less than it was at times but still pretty bad at other times for the same settings.
When using the color callback property method, when clamp to ground is enabled the plots completely disappear regardless of whether the depth test is disabled or not. I am not sure if this is a bug or I am doing something wrong/silly.
Thank you for pointing me to that PR. Will keep and eye for the release and see if it fixes things for me although I think that PR applies to prevent billboards from clipping with terrain? Will that fix the Callback property issue as well?
Kind regards
Nic
Hmm… this does appear to be a bug. It looks like there’s a weird interaction between clamping to ground and color callbacks. (Or maybe callbacks of any type?)
I’ll see if anyone has heard of this before. A quick search through the repo issues did not yield much.
Hi @mzschwartz5,
I adjusted your minimal example here for position and choosing different colours and they seem to work fine. However, they differ in that they use an external setInterval to edit the variable defined outside the property callback. Interestingly the alpha seems to work fine in this example.
So the issue maybe seems to be how the callback is defined, where the variables used in the callback are defined or maybe how often the output is being changed?
Is there a place to log a bug for the minimal example you posted?
For this example, where the alpha is made to flicker, if I set the update interval to around 10ms, it disappears completely and above 20ms it remains on the screen (with the flickering alpha as expected). Testing the update speed with the position and random colour examples didn’t produce any differences, the point remained on the screen regardless of the update interval and clamp to ground flag.
So the bug seems specific to the callback properties modifying the alpha value of the colour where the value is repeatedly modified over a period approximately less than 10-15ms. Maybe there is a way to rate limit the speed at which the colour callback is called?
Here is a Sandcastle where the alpha update interval is randomized and the minimum alpha is 0.5 (so it is always visible). You can see the plot starts to flicker in and out of the screen when clamp to ground is on. It is must flicker off when the update interval is closer to 1ms and flickers on when the update interval is closer to 15ms.
Found a work around which is to discretize the alpha value over the course of the fadeout. This prevents the alpha value changing every function call of the callback property (effectively lengthening the interval at which it needs to be re-rendered I guess, I am not sure how it all works under the hood).
Hello @mzschwartz5
I hope you are well.
Has a fix been merged in for this yet?
Kind regards
Nic