Skip to content

Commit

Permalink
Merge pull request #5295 from oterral/vector-tiles-labels-translu
Browse files Browse the repository at this point in the history
Add anchorLineColor to Cesium3DTileStyle
  • Loading branch information
bagnell authored May 16, 2017
2 parents d07420f + bd3ea99 commit 6cf4f3f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Source/Scene/Cesium3DTileFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,31 @@ define([
}
},

/**
* Gets and sets the color for the anchor line.
*
* @memberof Cesium3DTileFeature.prototype
*
* @type {Color}
*
* @default {@link Color.WHITE}
*/
anchorLineColor : {
get : function() {
if (defined(this._polylineCollection)) {
var polyline = this._polylineCollection.get(this._batchId);
return polyline.material.uniforms.color;
}
return undefined;
},
set : function(value) {
if (defined(this._polylineCollection)) {
var polyline = this._polylineCollection.get(this._batchId);
polyline.material.uniforms.color = value;
}
}
},

font : {
get : function() {
if (defined(this._labelCollection)) {
Expand Down
27 changes: 27 additions & 0 deletions Source/Scene/Cesium3DTileStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ define([
var DEFAULT_JSON_NUMBER_EXPRESSION = 1.0;
var DEFAULT_LABEL_STYLE_EXPRESSION = LabelStyle.FILL;
var DEFAULT_FONT_EXPRESSION = '"30px sans-serif"';
var DEFAULT_ANCHOR_LINE_COLOR_EXPRESSION = 'color("#ffffff")';
var DEFAULT_BACKGROUND_COLOR_EXPRESSION = 'rgba(42, 42, 42, 0.8)';
var DEFAULT_BACKGROUND_X_PADDING_EXPRESSION = 7.0;
var DEFAULT_BACKGROUND_Y_PADDING_EXPRESSION = 5.0;
Expand Down Expand Up @@ -75,6 +76,7 @@ define([
this._outlineWidth = undefined;
this._labelStyle = undefined;
this._font = undefined;
this._anchorLineColor = undefined;
this._backgroundColor = undefined;
this._backgroundXPadding = undefined;
this._backgroundYPadding = undefined;
Expand Down Expand Up @@ -136,6 +138,7 @@ define([
var outlineWidthExpression = defaultValue(styleJson.outlineWidth, DEFAULT_JSON_NUMBER_EXPRESSION);
var labelStyleExpression = defaultValue(styleJson.labelStyle, DEFAULT_LABEL_STYLE_EXPRESSION);
var fontExpression = defaultValue(styleJson.font, DEFAULT_FONT_EXPRESSION);
var anchorLineColorExpression = defaultValue(styleJson.anchorLineColor, DEFAULT_ANCHOR_LINE_COLOR_EXPRESSION);
var backgroundColorExpression = defaultValue(styleJson.backgroundColor, DEFAULT_BACKGROUND_COLOR_EXPRESSION);
var backgroundXPaddingExpression = defaultValue(styleJson.backgroundXPadding, DEFAULT_BACKGROUND_X_PADDING_EXPRESSION);
var backgroundYPaddingExpression = defaultValue(styleJson.backgroundYPadding, DEFAULT_BACKGROUND_Y_PADDING_EXPRESSION);
Expand Down Expand Up @@ -222,6 +225,15 @@ define([

that._font = font;

var anchorLineColor;
if (typeof anchorLineColorExpression === 'string') {
anchorLineColor = new Expression(anchorLineColorExpression);
} else if (defined(anchorLineColorExpression.conditions)) {
anchorLineColor = new ConditionsExpression(anchorLineColorExpression);
}

that._anchorLineColor = anchorLineColor;

var backgroundColor;
if (typeof backgroundColorExpression === 'string') {
backgroundColor = new Expression(backgroundColorExpression);
Expand Down Expand Up @@ -641,6 +653,21 @@ define([
}
},

anchorLineColor : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true.');
}
//>>includeEnd('debug');

return this._anchorLineColor;
},
set : function(value) {
this._anchorLineColor = value;
}
},

backgroundColor : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Expand Down
5 changes: 5 additions & 0 deletions Source/Scene/Cesium3DTileStyleEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ define([
feature.backgroundYPadding = style.backgroundYPadding.evaluate(frameState, feature);
feature.backgroundEnabled = style.backgroundEnabled.evaluate(frameState, feature);

if (defined(feature.anchorLineColor)) {
feature.anchorLineColor = style.anchorLineColor.evaluateColor(frameState, feature);
}

var scaleByDistanceNearRange = style.scaleByDistanceNearRange;
var scaleByDistanceNearValue = style.scaleByDistanceNearValue;
var scaleByDistanceFarRange = style.scaleByDistanceFarRange;
Expand Down Expand Up @@ -192,6 +196,7 @@ define([
feature.outlineWidth = 1.0;
feature.labelStyle = LabelStyle.FILL;
feature.font = '30px sans-serif';
feature.anchorLineColor = Color.WHITE;
feature.backgroundColor = 'rgba(42, 42, 42, 0.8)';
feature.backgroundXPadding = 7.0;
feature.backgroundYPadding = 5.0;
Expand Down

0 comments on commit 6cf4f3f

Please sign in to comment.