-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Rough update to KHR_lights support to match current spec #13341
Conversation
For the renderer light settings, I think it's ok just to add: // The KHR_lights extension should use physically-correct lighting mode.
renderer.physicallyCorrectLights = true; ... to the entire example, no need to turn it on/off when the extension is selected. |
@donmccurdy looks good? |
@mrdoob we should plan this one for r92, more likely, it will about a week before we've answered a couple last questions about this extension (partly my fault on that 😅). |
@MiiBond I think i've come around for having ambient lights on the scene... do you want to include that change in this PR? |
@donmccurdy I think this pull request handles the ambient light on the scene, doesn't it? Or did you mean something else? |
It did just occur to me that the handling of direction for |
Oh! My mistake, I'd expected to see something in your PR checking for a light in the scene, but I guess that part was already here.
Hmm yeah. If we want a spotlight to point correctly in a direction relative to its local transform, even if the node is animated, perhaps we do this: light.target.position.set( 0, 0, 1 );
light.add( light.target ); |
@donmccurdy Yeah, I think that works. |
Can we replace the current |
@mrdoob I just followed the convention already being used and just added a new one for the new extension. There are already 5 other copies of |
I see... |
We could drop For a future cleanup PR, I don't think we need to have all of |
/ping @donmccurdy |
@@ -202,14 +202,13 @@ | |||
var ambient = new THREE.AmbientLight( 0x222222 ); | |||
scene.add( ambient ); | |||
|
|||
var directionalLight = new THREE.DirectionalLight( 0xdddddd ); | |||
var directionalLight = new THREE.DirectionalLight( 0xdddddd, 4 ); |
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.
Why the intensity increase here? Related to physicallyCorrectLights setting?
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 think so, yeah. That was a while ago...
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 — We can remove some other example models in another PR.
examples/js/loaders/GLTFLoader.js
Outdated
@@ -261,7 +262,14 @@ THREE.GLTFLoader = ( function () { | |||
|
|||
case 'spot': | |||
lightNode = new THREE.SpotLight( color ); | |||
lightNode.position.set( 0, 0, 1 ); | |||
// Handle spotlight properties. | |||
var spot = light.spot || {}; |
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.
How about doing this instead?
var spot = light.spot || { innerConeAngle: 0, outerConeAngle: Math.PI / 4.0 };
lightNode.angle = spot.outerConeAngle;
lightNode.penumbra = 1.0 - ( spot.innerConeAngle / spot.outerConeAngle );
lightNode.target.position.set( 0, 0, 1 );
lightNode.add( lightNode.target );
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.
innerConeAngle
and outerConeAngle
are not required to be present, so their default values must be set independently. @MiiBond is the spot
property required? Perhaps:
light.spot = light.spot || {};
light.spot.innerConeAngle = light.spot.innerConeAngle !== undefined ? light.spot.innerConeAngle : 0;
light.spot.outerConeAngle = light.spot.innerConeAngle !== undefined ? light.spot.innerConeAngle : Math.PI / 4.0;
// ...
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.
spot
isn't required, no.
I'm not sure I follow what you're suggesting with your change. Are you just suggesting to get rid of the variable declarations within the case statement?
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 think that is the idea; i'm happy with or without that change.
examples/js/loaders/GLTFLoader.js
Outdated
var outerConeAngle = spot.outerConeAngle !== undefined ? spot.outerConeAngle : Math.PI / 4.0; | ||
lightNode.angle = outerConeAngle; | ||
lightNode.penumbra = 1.0 - innerConeAngle / outerConeAngle; | ||
lightNode.target.position.set( 0, 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.
The target of a spot is 0, 0, 1
by default?
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.
The local direction of the glTF light is always +Z; the only way to rotate it is by rotating the object or its parents in the scene graph.
Thanks! |
Updated to match current spec.
KhronosGroup/glTF#1223