@@ -51,9 +51,12 @@ function Mesh (node, options) {
51
51
expressions : { } ,
52
52
geometry : null ,
53
53
flatShading : null ,
54
- glossiness : null ,
55
54
positionOffset : null ,
56
- normals : null
55
+ normals : null ,
56
+ glossiness : {
57
+ factor : null ,
58
+ color : [ 0 , 0 , 0 ]
59
+ }
57
60
} ;
58
61
59
62
if ( options ) this . setDrawOptions ( options ) ;
@@ -292,19 +295,24 @@ Mesh.prototype.getNormals = function getNormals (materialExpression) {
292
295
*
293
296
* @return {Mesh } Mesh
294
297
*/
295
- Mesh . prototype . setGlossiness = function setGlossiness ( glossiness , strength ) {
298
+ Mesh . prototype . setGlossiness = function setGlossiness ( glossiness , specularColor ) {
296
299
var isMaterial = glossiness . __isAMaterial__ ;
297
- var isColor = ! ! glossiness . getNormalizedRGB ;
300
+ var hasSpecularColor = specularColor && specularColor . getNormalizedRGB ;
298
301
299
302
if ( isMaterial ) {
300
- this . value . glossiness = [ null , null ] ;
303
+ this . value . glossiness . factor = null ;
301
304
this . value . expressions . glossiness = glossiness ;
302
305
}
303
- else if ( isColor ) {
306
+ else {
304
307
this . value . expressions . glossiness = null ;
305
- this . value . glossiness = [ glossiness , strength || 20 ] ;
306
- glossiness = glossiness ? glossiness . getNormalizedRGB ( ) : [ 0 , 0 , 0 ] ;
307
- glossiness . push ( strength || 20 ) ;
308
+ this . value . glossiness . factor = glossiness ;
309
+ var glossinessValue = this . value . glossiness . color ;
310
+ if ( hasSpecularColor ) {
311
+ this . value . glossiness . color = specularColor ;
312
+ glossinessValue = this . value . glossiness . color . getNormalizedRGB ( ) ;
313
+ }
314
+ glossinessValue . push ( this . value . glossiness . factor ) ;
315
+ glossiness = glossinessValue ;
308
316
}
309
317
310
318
if ( this . _initialized ) {
@@ -441,11 +449,11 @@ Mesh.prototype.onUpdate = function onUpdate() {
441
449
this . _node . sendDrawCommand ( this . value . color . getNormalizedRGBA ( ) ) ;
442
450
this . _node . requestUpdateOnNextTick ( this . _id ) ;
443
451
}
444
- if ( this . value . glossiness && this . value . glossiness [ 0 ] && this . value . glossiness [ 0 ] . isActive ( ) ) {
452
+ if ( this . value . glossiness . color . isActive && this . value . glossiness . color . isActive ( ) ) {
445
453
this . _node . sendDrawCommand ( 'GL_UNIFORMS' ) ;
446
454
this . _node . sendDrawCommand ( 'u_glossiness' ) ;
447
- var glossiness = this . value . glossiness [ 0 ] . getNormalizedRGB ( ) ;
448
- glossiness . push ( this . value . glossiness [ 1 ] ) ;
455
+ var glossiness = this . value . glossiness . color . getNormalizedRGB ( ) ;
456
+ glossiness . push ( this . value . glossiness . factor ) ;
449
457
this . _node . sendDrawCommand ( glossiness ) ;
450
458
this . _node . requestUpdateOnNextTick ( this . _id ) ;
451
459
}
@@ -640,7 +648,7 @@ Mesh.prototype.draw = function draw () {
640
648
641
649
if ( value . geometry != null ) this . setGeometry ( value . geometry ) ;
642
650
if ( value . color != null ) this . setBaseColor ( value . color ) ;
643
- if ( value . glossiness != null ) this . setGlossiness . apply ( this , value . glossiness ) ;
651
+ if ( value . glossiness . factor != null ) this . setGlossiness . apply ( this , value . glossiness . factor ) ;
644
652
if ( value . drawOptions != null ) this . setDrawOptions ( value . drawOptions ) ;
645
653
if ( value . flatShading != null ) this . setFlatShading ( value . flatShading ) ;
646
654
0 commit comments