-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
SpotLightShadow.cameraAutoUpdate / Light.shadowAutoUpdate #14663
base: dev
Are you sure you want to change the base?
Conversation
9476109
to
2cbd289
Compare
src/lights/SpotLightShadow.js
Outdated
@@ -20,6 +21,8 @@ SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype | |||
|
|||
update: function ( light ) { | |||
|
|||
if ( ! this.cameraAutoUpdate ) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, I would do the following in the calling method:
if ( shadow.isSpotLightShadow && shadow.cameraAutoUpdate ) {
shadow.update( light );
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I definitely support this. I also support removal of the need for this pattern: light.shadow = new THREE.LightShadow( ... ); Forcing the shadow frustum to auto-size to the cone can have the side-effect of causing pixelated shadows. |
2 more commits :
|
I am not sure about 2da8234 though, at it breaks http://localhost:8000/examples/webgl_lights_spotlight.html due to three.js/examples/webgl_lights_spotlight.html Line 142 in 2cbd289
|
@WestLangley what do you think of this new commit 64b191c ? |
7f3ce22
to
9a706ef
Compare
docs/api/lights/SpotLight.html
Outdated
<h3>[property:Boolean shadowAutoUpdate]</h3> | ||
<p> | ||
If set to *true*, the shadow camera will be automatically updated each frame to match the | ||
geometry of the spotLight (a square frustum tightly fitting the cone of the spot light defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If set to *true*, the shadow camera frustum will be automatically sized to match the cone of the spotLight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -175,6 +175,13 @@ <h3>[property:Object3D target]</h3> | |||
The spotlight will now track the target object. | |||
</p> | |||
|
|||
<h3>[property:Boolean shadowAutoUpdate]</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[property:Boolean autoSizeShadowFrustum] ?
@@ -134,6 +134,11 @@ <h3>[method:Object toJSON]()</h3> | |||
Serialize this LightShadow. | |||
</p> | |||
|
|||
<h3>[method:void update]( [param:Light light] )</h3> | |||
<p> | |||
Updates this LightShadow (e.g. [page:SpotLightShadow.update SpotLightShadow.update]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is akin to a virtual base class and does not do anything. Define what it does where it is overloaded.
Actually, I think some others need to chime in regarding both the feature and the implementation details. You are not "auto-updating" the shadow camera frustum, you are "auto-sizing" it. At least that is how I see it. |
The naming It is thus more generic and makes |
Up ! There is no new functionality here. The goal is to provide a better API for the hack of overwriting the SpotLightShadow with a LightShadow to prevent the lightshadow update. The alternatives are : (Complementarily the This PR implements B without the |
Preventing the Autoupdating of the
SpotLight.shadow.camera
was previously performed through the hack of overwriting the SpotLightShadow with a LightShadow.Instead, this PR proposes a new property
SpotLightShadow.cameraAutoUpdate
Light.shadowAutoUpdate
that makes optional the fitting of the shadow camera frustum to the square cone defined by light.angle/light.distance.(this PR is the item 2 of #14658, extracted here for an easier review)
== Edit ==
Instead of overwriting the shadow, an alternative hack to get the same result would be to set
this.shadow.isSpotLightShadow = false
. As that was the sole use ofisSpotLightShadow
, this PR is essentially moving and renamingLight.shadow.isSpotLightShadow
toLight.shadowAutoUpdate
.