- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4.2k
Only update shadow properties of lights that support shadows #5748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| I think there should be a more fundamental solution, not in the plugin/component level, but in the core of aframe, in order to make aframe a future proof and more resilient for changes and scalability. just for example a method of schema/data properties to check if a dependent property has the use need of another dependency property, if so, proceed, otherwise skip/ignore the existence of that unnecessary property. | 
| 
 A-Frame places few constraints on a component's properties. It's only concerned with parsing and equality checking, letting the component or system do whatever it wants with them. Any schema properties intended for validation ( While it is appealing to move these responsibilities from the component into the core, that isn't as simple as it might seem. Since a component is free to do whatever it wants with the properties, there will inevitable be situations the core validation and conditional logic can't handle. Take for example validation that combines multiple properties, or validation that depends on remotely fetched resources or is otherwise asynchronous. We should avoid a situation where validation, conditional logic and corresponding logging is split between a schema-driven part handled by the core and custom logic implemented per component. 
 There is an option for components to have a "dynamic schema". This is used by the  In case the schema would only include the  If I understand your suggestion correctly regarding skipping/ignoring the existence of unnecessary properties, the same behaviour would arise. Note that it'll depend on the component whether this behaviour is desired or not, which is separate from the conditional nature of the properties in question. That's not to say I'm opposed to ideas exploring ways to shift (some of) the responsibility into the core. It's just that I don't see a clean way that would avoid dividing the responsibility across both or would otherwise be limited. | 
| Thank you | 
| Thanks @mrxz ,but I had tested that change, it slowed down the toggling of the castShadow props, when checking or unchecking it the INSPECTOR, I have to wait long time to be reflected, also, it consumes a lot of GPU and a bit more CPU than before this update of the code..! | 
| 
 I'm unable the reproduce this, could you provide a (live) example showing the issue? Toggling the  
 All properties of the light component are parsed, regardless of the values of  | 
Description:
Fixes #5747.
The
lightcomponent would unconditionally update the properties oflight.shadowwhencastShadowwas enabled. However, not all light types support shadows, causing an error when switching the light type and/or enablingcastShadowfor an incompatible light type.Additionally I noticed that the
CameraHelperfor the shadow camera would not update when changing light type. By removing the camera helper when the light type changes, it's guaranteed to be recreated for the correct camera (if needed).Changes proposed:
light.shadowproperties if the light type supports shadows