-
-
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
Serialize and load JSON Light .shadow property #9416
Conversation
satori99
commented
Jul 27, 2016
- Add .toJSON() method to LightShadow
- Light .toJSON() writes .shadow property
- Parse .shadow property in DirectionLight and Spotlight JSON data
* Add .toJSON() method to LightShadow * Light .toJSON() writes .shadow property * Parse .shadow property in DirectionLight and Spotlight JSON data
A DirectionalLight that casts a shadow will be serialized something like this;
|
@@ -50,6 +50,8 @@ Light.prototype = Object.assign( Object.create( Object3D.prototype ), { | |||
if ( this.decay !== undefined ) data.object.decay = this.decay; | |||
if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra; | |||
|
|||
if ( this.castShadow && this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON(); |
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.
I wonder if the this.castShadow
check is needed. Thinking about the editor case... One could set the shadow parameters but have the castShadow
temporarily false
. The shadow parameters would then get lost.
The .shadow (LightShadow) property of DirectionalLights and SpotLights is always created by the lights constructor. Even when shadows are not used at all. So this would always be exported I think. If its acceptable to always export default shadow settings, then I can remove that condition. alternatively, the camera classes could be altered to only export non-default properties? |
I removed the castShadow check. I thought about it a bit more, and I think you are right. It doesn't really matter if shadows are used in a scene or not, as that is a renderer setting anyway. |
Thanks! |
* Serialize and load JSON Light .shadow property * Add .toJSON() method to LightShadow * Light .toJSON() writes .shadow property * Parse .shadow property in DirectionLight and Spotlight JSON data * Remove .castShadow condition when exporting .shadow property to JSON