Skip to content

Commit

Permalink
Use ColorBlendMode.getColorBlend function
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Dec 6, 2016
1 parent cade6fa commit 6a60f25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
17 changes: 15 additions & 2 deletions Source/Scene/ColorBlendMode.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/*global define*/
define([
'../Core/freezeObject'
'../Core/freezeObject',
'../Core/Math'
], function(
freezeObject) {
freezeObject,
CesiumMath) {
'use strict';

/**
Expand All @@ -22,5 +24,16 @@ define([
MIX : 2
};

ColorBlendMode.getColorBlend = function(colorBlendMode, colorBlendAmount) {
if (colorBlendMode === ColorBlendMode.HIGHLIGHT) {
return 0.0;
} else if (colorBlendMode === ColorBlendMode.REPLACE) {
return 1.0;
} else if (colorBlendMode === ColorBlendMode.MIX) {
// The value 0.0 is reserved for highlight, so clamp to just above 0.0.
return CesiumMath.clamp(colorBlendAmount, CesiumMath.EPSILON4, 1.0);
}
};

return freezeObject(ColorBlendMode);
});
11 changes: 1 addition & 10 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2927,16 +2927,7 @@ define([

function createColorBlendFunction(model) {
return function() {
var colorBlendMode = model.colorBlendMode;
var colorBlendAmount = model.colorBlendAmount;
if (colorBlendMode === ColorBlendMode.HIGHLIGHT) {
return 0.0;
} else if (colorBlendMode === ColorBlendMode.REPLACE) {
return 1.0;
} else if (colorBlendMode === ColorBlendMode.MIX) {
// The value 0.0 is reserved for highlight, so clamp to just above 0.0.
return CesiumMath.clamp(colorBlendAmount, CesiumMath.EPSILON4, 1.0);
}
return ColorBlendMode.getColorBlend(model.colorBlendMode, model.colorBlendAmount);
};
}

Expand Down

0 comments on commit 6a60f25

Please sign in to comment.