Skip to content

Commit

Permalink
Use original billboard/label/point instead of trying to clone them. B…
Browse files Browse the repository at this point in the history
…illboard images are impossible to clone without reading from the texture atlas.
  • Loading branch information
bagnell committed Aug 25, 2016
1 parent 8be0183 commit dac90cb
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 71 deletions.
73 changes: 4 additions & 69 deletions Source/DataSources/EntityCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,80 +152,13 @@ define([
return bbox;
}

function cloneLabel(label) {
return {
text : label.text,
show : label.show,
font : label.font,
fillColor : label.fillColor,
outlineColor : label.outlineColor,
outlineWidth : label.outlineWidth,
style : label.outlineStyle,
verticalOrigin : label.verticalOrigin,
horizontalOrigin : label.horizontalOrigin,
pixelOffset : label.pixelOffset,
eyeOffset : label.eyeOffset,
position : label.position,
scale : label.scale,
id : label.id,
translucencyByDistance : label.translucencyByDistance,
pixelOffsetScaleByDistance : label.pixelOffsetScaleByDistance,
heightReference : label.heightReference
};
}

function cloneBillboard(billboard) {
return {
show : billboard.show,
position : billboard.position,
heightReference : billboard.heightReference,
pixelOffset : billboard.pixelOffset,
scaleByDistance : billboard.scaleByDistance,
translucencyByDistance : billboard.translucencyByDistance,
pixelOffsetScaleByDistance : billboard.pixelOffsetScaleByDistance,
eyeOffset : billboard.eyeOffset,
horizontalOrigin : billboard.horizontalOrigin,
verticalOrigin : billboard.verticalOrigin,
scale : billboard.scale,
color : billboard.color,
rotation : billboard.rotation,
alignedAxis : billboard.alignedAxis,
width : billboard.width,
height : billboard.height,
sizeInMeters : billboard.sizeInMeters,
id : billboard.id,
pickPrimitive : billboard.pickPrimitive,
image : billboard.image
};
}

function clonePoint(point) {
return {
show : point.show,
position : point.position,
scaleByDistance : point.scaleByDistance,
translucencyByDistance : point.translucencyByDistance,
pixelSize : point.pixelSize,
color : point.color,
outlineColor : point.outlineColor,
outlineWidth : point.outlineWidth,
id : point.id
};
}

function addNonClusteredItem(item, entityCluster) {
if (defined(item._labelCollection)) {
entityCluster._clusterLabelCollection.add(cloneLabel(item));
} else if (defined(item._billboardCollection)) {
entityCluster._clusterBillboardCollection.add(cloneBillboard(item));
} else if (defined(item._pointPrimitiveCollection)) {
entityCluster._clusterPointCollection.add(clonePoint(item));
}
item._clusterRender = true;

if (!defined(item._labelCollection) && defined(item.id._label)) {
var labelIndex = item.id._labelIndex;
var label = entityCluster._labelCollection.get(labelIndex);
entityCluster._clusterLabelCollection.add(cloneLabel(label));
label._clusterRender = true;
}
}

Expand All @@ -245,6 +178,8 @@ define([
var length = collection.length;
for (var i = 0; i < length; ++i) {
var item = collection.get(i);
item._clusterRender = false;

if (!item.show || !occluder.isPointVisible(item.position)) {
continue;
}
Expand Down
14 changes: 14 additions & 0 deletions Source/Scene/Billboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ define([
this._removeCallbackFunc = undefined;
this._mode = SceneMode.SCENE3D;

this._clusterShow = true;

this._updateClamping();
}

Expand Down Expand Up @@ -821,6 +823,18 @@ define([
this._actualClampedPosition = Cartesian3.clone(value, this._actualClampedPosition);
makeDirty(this, POSITION_INDEX);
}
},

_clusterRender : {
get : function() {
return this._clusterShow;
},
set : function(value) {
if (this._clusterShow !== value) {
this._clusterShow = value;
makeDirty(this, SHOW_INDEX);
}
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/BillboardCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ define([
var horizontalOrigin = billboard.horizontalOrigin;
var heightReference = billboard._heightReference;
var verticalOrigin = (heightReference === HeightReference.NONE) ? billboard._verticalOrigin : VerticalOrigin.BOTTOM;
var show = billboard.show;
var show = billboard.show && billboard._clusterRender;

// If the color alpha is zero, do not show this billboard. This lets us avoid providing
// color during the pick pass and also eliminates a discard in the fragment shader.
Expand Down
23 changes: 23 additions & 0 deletions Source/Scene/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ define([
this._removeCallbackFunc = undefined;
this._mode = undefined;

this._clusterShow = true;

this._updateClamping();
}

Expand Down Expand Up @@ -701,6 +703,27 @@ define([
}
}
}
},

_clusterRender : {
get : function() {
return this._clusterShow;
},
set : function(value) {
if (this._clusterShow !== value) {
this._clusterShow = value;

var glyphs = this._glyphs;
for (var i = 0, len = glyphs.length; i < len; i++) {
var glyph = glyphs[i];
if (defined(glyph.billboard)) {
// Set all the private values here, because we already clamped to ground
// so we don't want to do it again for every glyph
glyph.billboard._clusterRender = value;
}
}
}
}
}
});

Expand Down
14 changes: 14 additions & 0 deletions Source/Scene/PointPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ define([
this._id = options.id;
this._collection = defaultValue(options.collection, pointPrimitiveCollection);

this._clusterShow = true;

this._pickId = undefined;
this._pointPrimitiveCollection = pointPrimitiveCollection;
this._dirty = false;
Expand Down Expand Up @@ -354,6 +356,18 @@ define([
this._pickId.object.id = value;
}
}
},

_clusterRender : {
get : function() {
return this._clusterShow;
},
set : function(value) {
if (this._clusterShow !== value) {
this._clusterShow = value;
makeDirty(this, SHOW_INDEX);
}
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/PointPrimitiveCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ define([
}
}

var show = pointPrimitive.show;
var show = pointPrimitive.show && pointPrimitive._clusterRender;

// If the color alphas are zero, do not show this pointPrimitive. This lets us avoid providing
// color during the pick pass and also eliminates a discard in the fragment shader.
Expand Down

0 comments on commit dac90cb

Please sign in to comment.