-
-
Notifications
You must be signed in to change notification settings - Fork 35.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
FBXLoader: support for colors specified as single floats. #12648
Conversation
@MarcRibguth the error message you were getting was because the light in your model was failing to load. This PR fixes this and sets the light color correctly. However this doesn't fix the issue that colors of the model in your |
@looeee thanks for the reply, I will do that. |
How about... function parseColor( property ) {
var color = new THREE.Color();
if ( property.type === 'Color' ) {
return color.setScalar( property.value );
} else {
return color.fromArray( property.value );
}
} |
@mrdoob done. BTW, which style do you prefer in the library? 1 function parseColor( property ) {
var color = new THREE.Color();
if ( property.type === 'Color' ) {
return color.setScalar( property.value );
} else {
return color.fromArray( property.value );
}
} 2 function parseColor( property ) {
var color = new THREE.Color();
if ( property.type === 'Color' ) {
return color.setScalar( property.value );
}
return color.fromArray( property.value );
} |
Hmm, actually, yeah... In this case 2. is prettier 😇 |
OK, updated 🙂 |
Another option would be: function parseColor( property ) {
var color = new THREE.Color();
switch ( property.type ) {
case 'ColorRGB':
return color.fromArray( property.value );
case 'Color':
return color.setScalar( property.value );
}
} It depends of how many other types there are. |
Merging for now. |
Thanks! |
As far as I'm aware it should just be either 'Color' (float) or 'ColorRGB' (array). In any case, if there are more types used (e.g. 'Number', 'Double', 'Vector3' etc ) then they will all map to either an array or float, so I would favour function parseColor( property ) {
var color = new THREE.Color();
if( Array.isArray( propery.value ) {
return color.fromArray( property.value );
}
return color.setScalar( property.value );
} However I think the current function is sufficient. |
Fix for #12067 (comment)
Extends the
parseColor
function to support color typeColor
(rather thanColorRGB
), where the value is a single float rather than an RGB triple.Also fix an error when parsing light color.