Skip to content

Commit

Permalink
CODE: adapted surface coloring to ColorMaker
Browse files Browse the repository at this point in the history
  • Loading branch information
arose committed Aug 10, 2015
1 parent 4e29f5c commit 1cf20c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
25 changes: 21 additions & 4 deletions js/ngl/representation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5428,13 +5428,28 @@ NGL.DotRepresentation.prototype = NGL.createObject(
type: "number", precision: 1, max: 1, min: 0, uniform: true
}

}, NGL.Representation.prototype.parameters ),
}, NGL.Representation.prototype.parameters, {

colorScheme: {
type: "select", update: "color", options: {
"": "",
"value": "value",
"uniform": "uniform",
// "value-min": "value-min",
// "deviation": "deviation",
// "size": "size"
}
},

} ),

defaultSize: 0.1,

init: function( params ){

var p = params || {};
p.colorScheme = p.colorScheme || "uniform";
p.colorValue = p.colorValue || 0xDDDDDD;

this.disableImpostor = p.disableImpostor || false;

Expand Down Expand Up @@ -5487,7 +5502,7 @@ NGL.DotRepresentation.prototype = NGL.createObject(

this.dotBuffer = new NGL.SphereBuffer(
this.surface.getDataPosition(),
this.surface.getDataColor( this.color ),
this.surface.getDataColor( this.getColorParams() ),
this.surface.getDataSize( this.radius, this.scale ),
undefined,
{
Expand All @@ -5506,7 +5521,7 @@ NGL.DotRepresentation.prototype = NGL.createObject(

this.dotBuffer = new NGL.PointBuffer(
this.surface.getDataPosition(),
this.surface.getDataColor( this.color ),
this.surface.getDataColor( this.getColorParams() ),
{
pointSize: this.radius,
sizeAttenuation: true, // this.sizeAttenuation,
Expand All @@ -5531,7 +5546,9 @@ NGL.DotRepresentation.prototype = NGL.createObject(

if( what[ "color" ] ){

dotData[ "color" ] = this.surface.getDataColor( this.color );
dotData[ "color" ] = this.surface.getDataColor(
this.getColorParams()
);

}

Expand Down
25 changes: 15 additions & 10 deletions js/ngl/surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ NGL.Surface.prototype = {

},

getColor: function( color ){
getColor: function( params ){

var tc = new THREE.Color( color );
var p = params || {};

var tc = new THREE.Color( p.value );
var col = NGL.Utils.uniformArray3(
this.size, tc.r, tc.g, tc.b
);
Expand Down Expand Up @@ -132,9 +134,9 @@ NGL.Surface.prototype = {

},

getDataColor: function(){
getDataColor: function( params ){

return this.getColor.apply( this, arguments );
return this.getColor.call( this, params );

},

Expand Down Expand Up @@ -641,18 +643,20 @@ NGL.Volume.prototype = {

},

getDataColor: function( color ){
getDataColor: function( params ){

var p = params || {};

var spectralScale = chroma
.scale( 'Spectral' )
.mode('lch')
.domain( [ this.getDataMin(), this.getDataMax() ]);
.scale( p.scale || 'Spectral' )
.mode( p.mode || 'lch' )
.domain( p.domain || [ this.getDataMin(), this.getDataMax() ]);

var n = this.dataPosition.length / 3;
var data = this.data;
var array;

switch( color ){
switch( p.scheme || "uniform" ){

case "value":

Expand All @@ -666,9 +670,10 @@ NGL.Volume.prototype = {
}
break;

case "uniform":
default:

var tc = new THREE.Color( color );
var tc = new THREE.Color( p.value );
array = NGL.Utils.uniformArray3(
n, tc.r, tc.g, tc.b
);
Expand Down

0 comments on commit 1cf20c9

Please sign in to comment.