-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
Rough update to KHR_lights support to match current spec #13341
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
Changes from 6 commits
e362e29
6c5da91
317870b
b9d316d
f22daf7
9fa3edc
f45894b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,7 +252,8 @@ THREE.GLTFLoader = ( function () { | |
|
||
case 'directional': | ||
lightNode = new THREE.DirectionalLight( color ); | ||
lightNode.position.set( 0, 0, 1 ); | ||
lightNode.target.position.set( 0, 0, 1 ); | ||
lightNode.add( lightNode.target ); | ||
break; | ||
|
||
case 'point': | ||
|
@@ -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 || {}; | ||
var innerConeAngle = spot.innerConeAngle !== undefined ? spot.innerConeAngle : 0; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. The target of a spot is There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
lightNode.add( lightNode.target ); | ||
break; | ||
|
||
case 'ambient': | ||
|
@@ -272,33 +280,11 @@ THREE.GLTFLoader = ( function () { | |
|
||
if ( lightNode ) { | ||
|
||
if ( light.constantAttenuation !== undefined ) { | ||
lightNode.decay = 2; | ||
|
||
lightNode.intensity = light.constantAttenuation; | ||
if ( light.intensity !== undefined ) { | ||
|
||
} | ||
|
||
if ( light.linearAttenuation !== undefined ) { | ||
|
||
lightNode.distance = 1 / light.linearAttenuation; | ||
|
||
} | ||
|
||
if ( light.quadraticAttenuation !== undefined ) { | ||
|
||
lightNode.decay = light.quadraticAttenuation; | ||
|
||
} | ||
|
||
if ( light.fallOffAngle !== undefined ) { | ||
|
||
lightNode.angle = light.fallOffAngle; | ||
|
||
} | ||
|
||
if ( light.fallOffExponent !== undefined ) { | ||
|
||
console.warn( 'THREE.GLTFLoader:: light.fallOffExponent not currently supported.' ); | ||
lightNode.intensity = light.intensity; | ||
|
||
} | ||
|
||
|
@@ -2546,7 +2532,8 @@ THREE.GLTFLoader = ( function () { | |
|
||
'mesh', | ||
'skin', | ||
'camera' | ||
'camera', | ||
'light' | ||
|
||
] ).then( function ( dependencies ) { | ||
|
||
|
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?
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
andouterConeAngle
are not required to be present, so their default values must be set independently. @MiiBond is thespot
property required? Perhaps: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.