Skip to content

Commit

Permalink
Fix highlighting of Cesium 3D Tile Features
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-HNguyen committed Sep 3, 2019
1 parent 8dc5aef commit 01b0241
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
6 changes: 4 additions & 2 deletions 3dwebclient/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function listHighlightedObjects() {
var highlightingListElement = document.getElementById("citydb_highlightinglist");

emptySelectBox(highlightingListElement, function() {
var highlightedObjects = webMap.getAllHightlightedObjects();
var highlightedObjects = webMap.getAllHighlightedObjects();
for (var i = 0; i < highlightedObjects.length; i++) {
var option = document.createElement("option");
option.text = highlightedObjects[i];
Expand Down Expand Up @@ -588,10 +588,12 @@ function addEventListeners(layer) {
if (!(object._content instanceof Cesium.Batched3DModel3DTileContent))
return;

var featureArray = object._content._batchTable._features;
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = featureArray[object._batchId].getProperty("id");
if (!Cesium.defined(objectId))
return;

targetEntity = new Cesium.Entity({
id: objectId
Expand Down
2 changes: 1 addition & 1 deletion js/3dcitydb-web-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
* get highlighted objects from all layers
* @returns {Array}
*/
WebMap3DCityDB.prototype.getAllHightlightedObjects = function () {
WebMap3DCityDB.prototype.getAllHighlightedObjects = function () {
var results = [];
var count = 0;
var layers = this._layers;
Expand Down
40 changes: 22 additions & 18 deletions js/Cesium3DTilesDataLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@
if (Cesium.defined(features)) {
var object = features[k];

var idArray = object._content._batchTable._properties.id;
if (!Cesium.defined(idArray))
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = idArray[object._batchId];
var objectId = featureArray[object._batchId].getProperty("id");

if (scope.isInHighlightedList(objectId) && !Cesium.Color.equals(object.color, scope._highlightColor)) {
scope.highlightObject(object)
Expand Down Expand Up @@ -320,10 +320,12 @@
if (!(object._content instanceof Cesium.Batched3DModel3DTileContent))
return;

var idArray = object._content._batchTable._properties.id;
if (!Cesium.defined(idArray))
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = featureArray[object._batchId].getProperty("id");
if (!Cesium.defined(objectId))
return;
var objectId = idArray[object._batchId];

if (scope.isInHighlightedList(objectId))
return;
Expand All @@ -341,10 +343,12 @@
if (!(object._content instanceof Cesium.Batched3DModel3DTileContent))
return;

var idArray = object._content._batchTable._properties.id;
if (!Cesium.defined(idArray))
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = featureArray[object._batchId].getProperty("id");
if (!Cesium.defined(objectId))
return;
var objectId = idArray[object._batchId];

if (scope.isInHighlightedList(objectId)) {
scope.unHighlight([objectId]);
Expand All @@ -359,10 +363,10 @@
if (!(object._content instanceof Cesium.Batched3DModel3DTileContent))
return;

var idArray = object._content._batchTable._properties.id;
if (!Cesium.defined(idArray))
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = idArray[object._batchId];
var objectId = featureArray[object._batchId].getProperty("id");

if (scope.isInHighlightedList(objectId))
return;
Expand All @@ -375,10 +379,10 @@
if (!(object._content instanceof Cesium.Batched3DModel3DTileContent))
return;

var idArray = object._content._batchTable._properties.id;
if (!Cesium.defined(idArray))
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = idArray[object._batchId];
var objectId = featureArray[object._batchId].getProperty("id");

if (scope.isInHighlightedList(objectId))
return;
Expand Down Expand Up @@ -460,11 +464,11 @@
if (!(object._content instanceof Cesium.Batched3DModel3DTileContent))
return;

var idArray = object._content._batchTable._properties.id;
if (!Cesium.defined(idArray))
var featureArray = object._content._features;
if (!Cesium.defined(featureArray))
return;
var objectId = featureArray[object._batchId].getProperty("id");

var objectId = idArray[object._batchId];
var highlightColor = this._highlightedObjects[objectId];
if (highlightColor) {
if (!Cesium.defined(object.getProperty("originalColorValue"))) {
Expand Down

0 comments on commit 01b0241

Please sign in to comment.