Skip to content

Commit

Permalink
#8740 Move the mouse on 3D Tiles (#8748)
Browse files Browse the repository at this point in the history
* fix drill pick on 3D model

* add test
  • Loading branch information
allyoucanmap authored Oct 28, 2022
1 parent 5888617 commit 28a03e7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
3 changes: 1 addition & 2 deletions web/client/components/map/cesium/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ class CesiumMap extends React.Component {
// we can use pick so the only first intersect feature will be returned
// this is more intuitive for uses such as get feature info
const feature = map.scene.drillPick(position).find((aFeature) => {
const {entityCollection: {owner: {queryable}}} = aFeature.id;
return queryable;
return !(aFeature?.id?.entityCollection?.owner?.queryable === false);
});
if (feature instanceof Cesium.Cesium3DTileFeature && feature?.tileset?.msId) {
const msId = feature.tileset.msId;
Expand Down
31 changes: 31 additions & 0 deletions web/client/components/map/cesium/__tests__/Layer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,37 @@ describe('Cesium layer', () => {
expect(cmp.layer.dataSource.entities.values.length).toBe(1);
expect(cmp.layer.detached).toBe(true);
});
it('should create a vector layer queryable', () => {
const options = {
type: 'vector',
features: [{ type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [0, 0] } }],
title: 'Title',
visibility: true,
bbox: {
crs: 'EPSG:4326',
bounds: {
minx: -180,
miny: -90,
maxx: 180,
maxy: 90
}
},
queryable: false
};
// create layers
const cmp = ReactDOM.render(
<CesiumLayer
type="vector"
options={options}
map={map}
/>, document.getElementById('container'));
expect(cmp).toBeTruthy();
expect(cmp.layer).toBeTruthy();
expect(cmp.layer.dataSource).toBeTruthy();
expect(cmp.layer.dataSource.entities.values.length).toBe(1);
expect(cmp.layer.detached).toBe(true);
expect(cmp.layer.dataSource.queryable).toBe(false);
});
it('should create a wfs layer', () => {
const options = {
type: 'wfs',
Expand Down
1 change: 1 addition & 0 deletions web/client/components/map/cesium/plugins/VectorLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const createLayer = (options, map) => {
}

dataSource.show = !!options.visibility;
dataSource.queryable = options.queryable === undefined || options.queryable;

return {
detached: true,
Expand Down
3 changes: 1 addition & 2 deletions web/client/utils/cesium/ClickUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export const getMouseXYZ = (viewer, event) => {
}

const feature = viewer.scene.drillPick(mousePosition).find((aFeature) => {
const {entityCollection: {owner: {queryable}}} = aFeature.id;
return queryable;
return !(aFeature?.id?.entityCollection?.owner?.queryable === false);
});
if (feature) {
let currentDepthTestAgainstTerrain = scene.globe.depthTestAgainstTerrain;
Expand Down

0 comments on commit 28a03e7

Please sign in to comment.