Three.js: Avoid exporting LightShadow class

Created on 29 Aug 2020  路  3Comments  路  Source: mrdoob/three.js

Description of the problem

Currently the shadow camera of SpotLight (actually its fov property) is coupled to the light's angle. So doing this:

spotLight.shadow.camera.fov = 45;

has no effect. Thus it is not possible to configure a smaller shadow frustum when having a large spot light cone.

The workaround for this use case is to overwrite SpotLight.shadow with an new instance of the internal LightShadow class. This prevents the execution of SpotLightShadow.updateMatrices() which is responsible for the mentioned fov/angle coupling.

One possible solution for this issue was outlined here: https://github.com/mrdoob/three.js/pull/20147#issuecomment-679092113

The idea is to introduce a new boolean property called SpotLightShadow.autoFOV. If set to false, the existing coupling is disabled so setting SpotLightShadow.fov actually has an effect.

Implementing this solution or an alternative would make it possible to prevent the export of LightShadow (which shouldn't be public). In general, a light's shadow property should be considered as read-only and not overwritten by the user.

Three.js version
  • [x] Dev
  • [x] r120
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Suggestion

Most helpful comment

Now that #20218 is merged should be okay to remove LightShadow from the exports?

All 3 comments

Implementing this solution or an alternative would make it possible to prevent the export of LightShadow (which shouldn't be public)

Agreed. Please see #20218 for an alternative.

Now that #20218 is merged should be okay to remove LightShadow from the exports?

Finally solved 馃槄 .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

makc picture makc  路  3Comments

yqrashawn picture yqrashawn  路  3Comments

seep picture seep  路  3Comments

jack-jun picture jack-jun  路  3Comments

boyravikumar picture boyravikumar  路  3Comments