3dstreet
3dstreet copied to clipboard
add shadowCameraAutomatic option
- add shadowCameraAutomatic option with #default-street element for automatic shadow camera sizing
- delete shadowCamera parameters
Deploy Preview for 3dstreet-core-builds ready!
Name | Link |
---|---|
Latest commit | c995f2f8f4c5a6c1ec6f71b781b6c040ec888cf7 |
Latest deploy log | https://app.netlify.com/sites/3dstreet-core-builds/deploys/659f4e3ed79e6a000859a6ce |
Deploy Preview | https://deploy-preview-449--3dstreet-core-builds.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
I'm still testing this option for automatic shadow camera sizing. It is good for determining the size of the shadow area. But I want to test whether the performance has changed
I noticed that if use the shadowCameraAutomatic
option for the light
component, the scene slows down noticeably. This happens after turning on the editor and going to the viewer again. Perhaps because with this option the size of the object passed to shadowCameraAutomatic
is calculated every tick, but not sure.
I sized the shadow camera according to the length of the street and added 10 meters to each side since the camera is aimed at an angle. For all enviroment modes, shadows from all objects are displayed on the scene. Tested with different street length
A couple thoughts:
- I'm not sure "default-street" length is the source of truth for how to position camera shadow in a scene -- there may be multiple streets, intersections or other user-defined geometry in the scene. This element id may not always be present.
- What is the best way to test this? What is the goal here? Is it to have shadow on any object that is in the camera field of view? Is that possible with A-Frame?
- You mentioned performance issues with
shadowCameraAutomatic
. IsshadowCameraAutomatic
supposed to automate the above? Does it work for this use case ignoring the performance issue? If so maybe it's worth digging a bit more to fix the root cause?
I'm not sure "default-street" length is the source of truth for how to position camera shadow in a scene -- there may be multiple streets, intersections or other user-defined geometry in the scene. This element id may not always be present.
Yes, I thought about that too. Maybe it's worth storing length in a STREET object?
What is the best way to test this? What is the goal here? Is it to have shadow on any object that is in the camera field of view? Is that possible with A-Frame?
Yes, the goal here is to have shadows on all objects. I came from here:
https://github.com/3DStreet/3dstreet/issues/439
Yes, it's possible in AFrame, why not? Just need to adjust the light.shadow.camera
area. The problem is that this area is adjusted to the light source, not the viewer's camera. It would be possible to simply specify very large values ββfor the shadow.camera area, but then the shadow becomes pixelated in small scenes
Is
shadowCameraAutomatic
supposed to automate the above? Does it work for this use case ignoring the performance issue? If so maybe it's worth digging a bit more to fix the root cause?
Yes, this works if we specify in shadowCameraAutomatic
a scene element in the scene that the light and shadow should cover. But what the root cause you mean? Not quite understand
On my computer, after adding this setting, there are quite severe performance leaks. After turning the editor on and off
I'm not sure "default-street" length is the source of truth for how to position camera shadow in a scene -- there may be multiple streets, intersections or other user-defined geometry in the scene. This element id may not always be present.
Maybe we just can use #street-container
instead of #default-street
? And calculate #street-container
size to use them for shadow.camera
sizes
@Algorush yes one level higher? So in theory
shadowCameraAutomatic
automatically adjusts for the combination of the camera frustum and the bounding box of the target entity?
looks like yes
I looked at the code of the aframe light
component and it turns out that the size of the element, or rather the array of elements passed to shadowCameraAutomatic
, is calculated every tick, if this option is enabled:
https://github.com/aframevr/aframe/blob/770f95a0cda0ad083c6d6f8d6ce4399804f238d5/src/components/light.js#L155
Therefore, this led to severe performance losses when using it. I can take a function from the light component that determines the exact dimensions of the shadowCamera, but I think that it is very large and in our case it is enough to simply specify the maximum side of the vector with the size of streetContainer. And add +/-10 meters to take into account that the camera light is at an angle. I'll test with different light angles again
calculating the dimensions of a street-container
is a little more difficult than it seems. We can't use the element's loaded
event since we are loading the content via JS. I tried different options, the option worked well when I added shadowCameraAutomatic
with the street-container
element, and then turned off this option through setTimeout
, after few seconds (5 is enough). Works good. But on this scene (https://streetmix.net/kfarr/3/3dstreet-demo-street) an error occurs. It looks like the problem is that one of the segments did not load and has NaN
values in one of properties
I'll try to do something about it next time. For now I'll deal with other issues.
I also suggest adding a check to aframe-streetmix-parser.js: if the chosen segment type is not supported, don't load it or load the sidewalk segment instead or use the neighboring segment type? Will make new issue for this.
And if we add such a check, then we can use the option with shadowCameraAutomatic
and setTimeout
for the first time