Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Source/DataSources/BillboardVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ define([
var textureValue;
var billboard = item.billboard;
var show = entity.isShowing && entity.isAvailable(time) && Property.getValueOrDefault(billboardGraphics._show, time, true);

var allowPicking = entity.allowPicking;

if (show) {
position = Property.getValueOrUndefined(entity._position, time, position);
textureValue = Property.getValueOrUndefined(billboardGraphics._image, time);
Expand Down Expand Up @@ -169,6 +170,7 @@ define([
billboard.pixelOffsetScaleByDistance = Property.getValueOrUndefined(billboardGraphics._pixelOffsetScaleByDistance, time, pixelOffsetScaleByDistance);
billboard.sizeInMeters = Property.getValueOrDefault(billboardGraphics._sizeInMeters, defaultSizeInMeters);
billboard.distanceDisplayCondition = Property.getValueOrUndefined(billboardGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
billboard.allowPicking = allowPicking;

var subRegion = Property.getValueOrUndefined(billboardGraphics._imageSubRegion, time, boundingRectangle);
if (defined(subRegion)) {
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/BoxGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ define([
distanceDisplayCondition : distanceDisplayConditionAttribute
}
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -620,6 +621,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
3 changes: 3 additions & 0 deletions Source/DataSources/CorridorGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ define([
distanceDisplayCondition : distanceDisplayConditionAttribute
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand All @@ -664,6 +665,7 @@ define([
distanceDisplayCondition : distanceDisplayConditionAttribute
}
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -694,6 +696,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/CylinderGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ define([
distanceDisplayCondition : distanceDisplayConditionAttribute
}
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -646,6 +647,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
3 changes: 3 additions & 0 deletions Source/DataSources/EllipseGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ define([
distanceDisplayCondition : distanceDisplayConditionAttribute
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand All @@ -685,6 +686,7 @@ define([
attributes : {
distanceDisplayCondition : distanceDisplayConditionAttribute
},
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -715,6 +717,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/EllipsoidGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ define([
distanceDisplayCondition : distanceDisplayConditionAttribute
}
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand All @@ -690,6 +691,7 @@ define([
lineWidth : this._geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
12 changes: 12 additions & 0 deletions Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ define([
* @param {String} [options.name] A human readable name to display to users. It does not have to be unique.
* @param {TimeIntervalCollection} [options.availability] The availability, if any, associated with this object.
* @param {Boolean} [options.show] A boolean value indicating if the entity and its children are displayed.
* @param {Boolean} [options.allowPicking=true] A boolean value indicating if the entity will be pickable with {@link Scene#pick}.
* @param {Property} [options.description] A string Property specifying an HTML description for this entity.
* @param {PositionProperty} [options.position] A Property specifying the entity position.
* @param {Property} [options.orientation] A Property specifying the entity orientation.
Expand Down Expand Up @@ -128,6 +129,7 @@ define([
this._definitionChanged = new Event();
this._name = options.name;
this._show = defaultValue(options.show, true);
this._allowPicking = defaultValue(options.allowPicking, true);
this._parent = undefined;
this._propertyNames = ['billboard', 'box', 'corridor', 'cylinder', 'description', 'ellipse', //
'ellipsoid', 'label', 'model', 'orientation', 'path', 'point', 'polygon', //
Expand Down Expand Up @@ -269,6 +271,16 @@ define([
this._definitionChanged.raiseEvent(this, 'show', value, !value);
}
},
/**
* Gets whether this entity is allowed to be picked (selected).
* @memberof Entity.prototype
* @type {Boolean}
*/
allowPicking: {
get : function() {
return this._allowPicking;
}
},
/**
* Gets whether this entity is being displayed, taking into account
* the visibility of any ancestor entities.
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/LabelVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ define([
var text;
var label = item.label;
var show = entity.isShowing && entity.isAvailable(time) && Property.getValueOrDefault(labelGraphics._show, time, true);
var allowPicking = entity.allowPicking;

if (show) {
position = Property.getValueOrUndefined(entity._position, time, position);
Expand Down Expand Up @@ -165,6 +166,7 @@ define([
label.translucencyByDistance = Property.getValueOrUndefined(labelGraphics._translucencyByDistance, time, translucencyByDistance);
label.pixelOffsetScaleByDistance = Property.getValueOrUndefined(labelGraphics._pixelOffsetScaleByDistance, time, pixelOffsetScaleByDistance);
label.distanceDisplayCondition = Property.getValueOrUndefined(labelGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
label.allowPicking = allowPicking;
}
return true;
};
Expand Down
3 changes: 2 additions & 1 deletion Source/DataSources/ModelVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ define([
model = Model.fromGltf({
url : uri,
incrementallyLoadTextures : Property.getValueOrDefault(modelGraphics._incrementallyLoadTextures, time, defaultIncrementallyLoadTextures),
scene : this._scene
scene : this._scene,
allowPicking: entity.allowPicking,
});

model.readyPromise.otherwise(onModelError);
Expand Down
4 changes: 3 additions & 1 deletion Source/DataSources/PathVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ define([
var showProperty = pathGraphics._show;
var polyline = item.polyline;
var show = entity.isShowing && (!defined(showProperty) || showProperty.getValue(time));

var allowPicking = entity.allowPicking;

//While we want to show the path, there may not actually be anything to show
//depending on lead/trail settings. Compute the interval of the path to
//show and check against actual availability.
Expand Down Expand Up @@ -370,6 +371,7 @@ define([
polyline.material = MaterialProperty.getValue(time, pathGraphics._material, polyline.material);
polyline.width = Property.getValueOrDefault(pathGraphics._width, time, defaultWidth);
polyline.distanceDisplayCondition = Property.getValueOrUndefined(pathGraphics._distanceDisplayCondition, time, polyline.distanceDisplayCondition);
polyline.allowPicking = allowPicking;
};

PolylineUpdater.prototype.removeObject = function(item) {
Expand Down
4 changes: 4 additions & 0 deletions Source/DataSources/PointVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ define([
var billboard = item.billboard;
var heightReference = Property.getValueOrDefault(pointGraphics._heightReference, time, HeightReference.NONE);
var show = entity.isShowing && entity.isAvailable(time) && Property.getValueOrDefault(pointGraphics._show, time, true);
var allowPicking = entity.allowPicking;

if (show) {
position = Property.getValueOrUndefined(entity._position, time, position);
show = defined(position);
Expand Down Expand Up @@ -156,13 +158,15 @@ define([
pointPrimitive.outlineWidth = Property.getValueOrDefault(pointGraphics._outlineWidth, time, defaultOutlineWidth);
pointPrimitive.pixelSize = Property.getValueOrDefault(pointGraphics._pixelSize, time, defaultPixelSize);
pointPrimitive.distanceDisplayCondition = Property.getValueOrUndefined(pointGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
pointPrimitive.allowPicking = allowPicking;
} else { // billboard
billboard.show = true;
billboard.position = position;
billboard.scaleByDistance = Property.getValueOrUndefined(pointGraphics._scaleByDistance, time, scaleByDistance);
billboard.translucencyByDistance = Property.getValueOrUndefined(pointGraphics._translucencyByDistance, time, translucencyByDistance);
billboard.distanceDisplayCondition = Property.getValueOrUndefined(pointGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
billboard.heightReference = heightReference;
billboard.allowPicking = allowPicking;

var newColor = Property.getValueOrDefault(pointGraphics._color, time, defaultColor, color);
var newOutlineColor = Property.getValueOrDefault(pointGraphics._outlineColor, time, defaultOutlineColor, outlineColor);
Expand Down
3 changes: 3 additions & 0 deletions Source/DataSources/PolygonGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ define([
color: ColorGeometryInstanceAttribute.fromColor(currentColor)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand All @@ -698,6 +699,7 @@ define([
id : entity,
geometry : new PolygonGeometry(options)
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -727,6 +729,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/PolylineVolumeGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ define([
id : entity,
geometry : new PolylineVolumeGeometry(options)
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -620,6 +621,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
3 changes: 3 additions & 0 deletions Source/DataSources/RectangleGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ define([
color: ColorGeometryInstanceAttribute.fromColor(currentColor)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand All @@ -671,6 +672,7 @@ define([
id : entity,
geometry : new RectangleGeometry(options)
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -700,6 +702,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/WallGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ define([
id : entity,
geometry : new WallGeometry(options)
}),
allowPicking: entity.allowPicking,
appearance : appearance,
asynchronous : false,
shadows : shadows
Expand Down Expand Up @@ -622,6 +623,7 @@ define([
lineWidth : geometryUpdater._scene.clampLineWidth(outlineWidth)
}
}),
allowPicking: entity.allowPicking,
asynchronous : false,
shadows : shadows
}));
Expand Down
28 changes: 27 additions & 1 deletion Source/Scene/Billboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ define([
this._id = options.id;
this._collection = defaultValue(options.collection, billboardCollection);

this._allowPicking = defaultValue(options.allowPicking, true);
this._pickId = undefined;
this._pickPrimitive = defaultValue(options._pickPrimitive, this);
this._billboardCollection = billboardCollection;
Expand Down Expand Up @@ -240,6 +241,31 @@ define([
}
},

/**
* Gets whether to allow picking this billboard.
* @memberof Billboard.prototype
* @type {Boolean}
*/
allowPicking : {
get : function() {
return this._allowPicking;
},
set : function(value) {
//>>includeStart('debug', pragmas.debug)
if (!defined(value)) {
throw new DeveloperError('value is required.');
}
//>>includeEnd('debug');
if (this._allowPicking !== value) {
this._allowPicking = value;
// Need to destroy the pickId so that it can be recreated (or ignored) as necessary
this._pickId = this._pickId && this._pickId.destroy();
// This forces the pickID color to be re-retrieved by BillboardCollection.writeCompressedAttrib2
makeDirty(this, COLOR_INDEX);
}
}
},

/**
* Gets or sets the height reference of this billboard.
* @memberof Billboard.prototype
Expand Down Expand Up @@ -876,7 +902,7 @@ define([
});

Billboard.prototype.getPickId = function(context) {
if (!defined(this._pickId)) {
if (!defined(this._pickId) && this._allowPicking) {
this._pickId = context.createPickId({
primitive : this._pickPrimitive,
collection : this._collection,
Expand Down
5 changes: 4 additions & 1 deletion Source/Scene/BillboardCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,10 @@ define([
var i;
var writer = vafWriters[attributeLocations.compressedAttribute2];
var color = billboard.color;
var pickColor = billboard.getPickId(context).color;

// The billboard might not be pickable, in which case pickID is undefined.
var pickID = billboard.getPickId(context);
var pickColor = defined(pickID) ? pickID.color : new Color(0.0,0.0,0.0,0.0);
var sizeInMeters = billboard.sizeInMeters ? 1.0 : 0.0;
var validAlignedAxis = Math.abs(Cartesian3.magnitudeSquared(billboard.alignedAxis) - 1.0) < CesiumMath.EPSILON6 ? 1.0 : 0.0;

Expand Down
29 changes: 29 additions & 0 deletions Source/Scene/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ define([
this._labelCollection = labelCollection;
this._glyphs = [];

this._allowPicking = defaultValue(options.allowPicking, true);

this._rebindAllGlyphs = true;
this._repositionAllGlyphs = true;

Expand Down Expand Up @@ -693,6 +695,33 @@ define([
}
},

/**
* Gets whether to allow picking this Label.
* @memberof Label.prototype
* @type {Boolean}
*/
allowPicking : {
get : function() {
return this._allowPicking;
},
set : function(value) {
//>>includeStart('debug', pragmas.debug)
if (!defined(value)) {
throw new DeveloperError('value is required.');
}
//>>includeEnd('debug');
if (this._allowPicking !== value) {
var glyphs = this._glyphs;
for (var i = 0, len = glyphs.length; i < len; i++) {
var glyph = glyphs[i];
if (defined(glyph.billboard)) {
glyph.billboard.allowPicking = value;
}
}
}
}
},

/**
* Gets or sets the user-defined object returned when the label is picked.
* @memberof Label.prototype
Expand Down
Loading