@@ -54,9 +54,12 @@ function Mesh (node, options) {
5454 color : null ,
5555 expressions : { } ,
5656 flatShading : null ,
57- glossiness : null ,
5857 positionOffset : null ,
59- normals : null
58+ normals : null ,
59+ glossiness : {
60+ factor : null ,
61+ color : [ 0 , 0 , 0 ]
62+ }
6063 } ;
6164
6265 if ( options ) this . setDrawOptions ( options ) ;
@@ -296,19 +299,24 @@ Mesh.prototype.getNormals = function getNormals (materialExpression) {
296299 *
297300 * @return {Mesh } Mesh
298301 */
299- Mesh . prototype . setGlossiness = function setGlossiness ( glossiness , strength ) {
302+ Mesh . prototype . setGlossiness = function setGlossiness ( glossiness , specularColor ) {
300303 var isMaterial = glossiness . __isAMaterial__ ;
301- var isColor = ! ! glossiness . getNormalizedRGB ;
304+ var hasSpecularColor = specularColor && specularColor . getNormalizedRGB ;
302305
303306 if ( isMaterial ) {
304- this . value . glossiness = [ null , null ] ;
307+ this . value . glossiness . factor = null ;
305308 this . value . expressions . glossiness = glossiness ;
306309 }
307- else if ( isColor ) {
310+ else {
308311 this . value . expressions . glossiness = null ;
309- this . value . glossiness = [ glossiness , strength || 20 ] ;
310- glossiness = glossiness ? glossiness . getNormalizedRGB ( ) : [ 0 , 0 , 0 ] ;
311- glossiness . push ( strength || 20 ) ;
312+ this . value . glossiness . factor = glossiness ;
313+ var glossinessValue = this . value . glossiness . color ;
314+ if ( hasSpecularColor ) {
315+ this . value . glossiness . color = specularColor ;
316+ glossinessValue = this . value . glossiness . color . getNormalizedRGB ( ) ;
317+ }
318+ glossinessValue . push ( this . value . glossiness . factor ) ;
319+ glossiness = glossinessValue ;
312320 }
313321
314322 if ( this . _initialized ) {
@@ -445,11 +453,11 @@ Mesh.prototype.onUpdate = function onUpdate() {
445453 this . _node . sendDrawCommand ( this . value . color . getNormalizedRGBA ( ) ) ;
446454 this . _node . requestUpdateOnNextTick ( this . _id ) ;
447455 }
448- if ( this . value . glossiness && this . value . glossiness [ 0 ] && this . value . glossiness [ 0 ] . isActive ( ) ) {
449- this . _node . sendDrawCommand ( Commands . GL_UNIFORMS ) ;
456+ if ( this . value . glossiness . color . isActive && this . value . glossiness . color . isActive ( ) ) {
457+ this . _node . sendDrawCommand ( ' GL_UNIFORMS' ) ;
450458 this . _node . sendDrawCommand ( 'u_glossiness' ) ;
451- var glossiness = this . value . glossiness [ 0 ] . getNormalizedRGB ( ) ;
452- glossiness . push ( this . value . glossiness [ 1 ] ) ;
459+ var glossiness = this . value . glossiness . color . getNormalizedRGB ( ) ;
460+ glossiness . push ( this . value . glossiness . factor ) ;
453461 this . _node . sendDrawCommand ( glossiness ) ;
454462 this . _node . requestUpdateOnNextTick ( this . _id ) ;
455463 }
@@ -649,7 +657,7 @@ Mesh.prototype.draw = function draw () {
649657
650658 if ( value . geometry != null ) this . setGeometry ( value . geometry ) ;
651659 if ( value . color != null ) this . setBaseColor ( value . color ) ;
652- if ( value . glossiness != null ) this . setGlossiness . apply ( this , value . glossiness ) ;
660+ if ( value . glossiness . factor != null ) this . setGlossiness . apply ( this , value . glossiness . factor ) ;
653661 if ( value . drawOptions != null ) this . setDrawOptions ( value . drawOptions ) ;
654662 if ( value . flatShading != null ) this . setFlatShading ( value . flatShading ) ;
655663
0 commit comments