-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Making ShadowMap constructor private #4890
Making ShadowMap constructor private #4890
Conversation
I'm not sure if this is possible to do, but can the constructor be private but |
How do users get to the shadow map object? Through the scene? We could keep this class public with the private constructor and make any other members private as needed. |
|
How's this, @lilleyse ? Should normalOffset be visible since its mentioned? |
Looking at jsdoc documentation Whether the constructor can be hidden or not, I think its still a good idea to keep the parameters since they are helpful for anyone coding cesium. Maybe we just need a note that it is not recommend to construct a I don't see a problem with instantiating with
Hm, I suppose there should be a setting for this since it is mentioned. The normal offset is controlled by setting |
Oh so Cesium adds |
Overall adding that warning comment and using |
Yes, more precisely
|
@rahwang any update here? |
Changes made, @pjcozzi . Now using |
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.
Looks good. With a few tweaks I tested that the new normalOffset
setter works well.
@@ -107,37 +107,28 @@ define([ | |||
|
|||
/** | |||
* Creates a shadow map from the provided light camera. | |||
* <p> | |||
* Use {@link Viewer#shadowMap} |
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.
It's fine to remove the indentation for this line.
Expand on the description a bit. Maybe Use {@link Viewer#shadowMap} to get the scene's shadow map originating from the sun. In general do not construct directly.
* @param {Number} [options.maximumDistance=5000.0] The maximum distance used for generating cascaded shadows. Lower values improve shadow quality. | ||
* @param {Number} [options.size=2048] The width and height, in pixels, of each shadow map. | ||
* @param {Boolean} [options.softShadows=false] Whether percentage-closer-filtering is enabled for producing softer shadows. | ||
* @param {Number} [options.darkness=0.3] The shadow darkness. |
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.
It's still nice to keep these parameter descriptions even if the shadow map isn't meant to be constructed directly.
* | ||
* @exception {DeveloperError} Only one or four cascades are supported. | ||
* | ||
* @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Shadows.html|Cesium Sandcastle Shadows Demo} | ||
* |
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.
Remove empty line.
@@ -149,6 +140,8 @@ define([ | |||
|
|||
this._enabled = defaultValue(options.enabled, true); | |||
this._softShadows = defaultValue(options.softShadows, false); | |||
this._normalOffset = defaultValue(options.normalOffset, true); |
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.
When the parameters are added back to the doc, include normalOffset
.
@@ -149,6 +140,8 @@ define([ | |||
|
|||
this._enabled = defaultValue(options.enabled, true); | |||
this._softShadows = defaultValue(options.softShadows, false); | |||
this._normalOffset = defaultValue(options.normalOffset, true); | |||
this._normalOffsetScale = defaultValue(options.normalOffsetScale, 0.1); |
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 would not expose this right now as an option or a getter/setter. The default values used before are tuned for the different bias modes.
}, | ||
set : function(value) { | ||
this.dirty = this._normalOffset !== value; | ||
this._normalOffset = value; |
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 setter should also set this._terrainBias.normalOffset
, this._primitiveBias.normalOffset
, and this._pointBias.normalOffset
,
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.
Also add a test for this. It should be fine to set normalOffset
to false and expect the normalOffset
to be false for all the bias modes. I don't think this requires any rendering as part of the test.
Looks good! |
See #4010