Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
HARP-10772: Add enablePicking to DataSourceOptions
Browse files Browse the repository at this point in the history
Disabling picking for data sources that don't need it will make it faster.

Signed-off-by: Andres Mandado <andres.mandado-almajano@here.com>
  • Loading branch information
atomicsulfate committed Jul 20, 2020
1 parent dab7341 commit 8ce945f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions @here/harp-debug-datasource/lib/DebugTileDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class DebugTileDataSource extends DataSource {
super({ name, minDataLevel: 1, maxDataLevel: 20, storageLevelOffset: -1 });

this.cacheable = true;
this.enablePicking = false;
}

/** @override */
Expand Down
1 change: 1 addition & 0 deletions @here/harp-mapview/lib/BackgroundDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class BackgroundDataSource extends DataSource {
super({ name: "background" });
this.cacheable = true;
this.addGroundPlane = true;
this.enablePicking = false;
}

updateStorageLevelOffset() {
Expand Down
18 changes: 17 additions & 1 deletion @here/harp-mapview/lib/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export interface DataSourceOptions {
* @default true
*/
allowOverlappingTiles?: boolean;

/**
* Whether features from these data source can picked by calling
* {@link MapView.intersectMapObjects}. Disabling picking for data sources that don't need it
* will improve picking performance.
* @default true
*/
enablePicking?: boolean;
}

/**
Expand Down Expand Up @@ -130,6 +138,9 @@ export abstract class DataSource extends THREE.EventDispatcher {
maxDisplayLevel: number = 20;

allowOverlappingTiles: boolean = true;

enablePicking: boolean = true;

/**
* @internal
* @hidden
Expand Down Expand Up @@ -177,7 +188,8 @@ export abstract class DataSource extends THREE.EventDispatcher {
minDisplayLevel,
maxDisplayLevel,
storageLevelOffset,
allowOverlappingTiles
allowOverlappingTiles,
enablePicking
} = options;
if (name === undefined || name.length === 0) {
name = `anonymous-datasource#${++DataSource.uniqueNameCounter}`;
Expand Down Expand Up @@ -212,6 +224,10 @@ export abstract class DataSource extends THREE.EventDispatcher {
if (allowOverlappingTiles !== undefined) {
this.allowOverlappingTiles = allowOverlappingTiles;
}

if (enablePicking !== undefined) {
this.enablePicking = enablePicking;
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions @here/harp-mapview/lib/PickHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ export class PickHandler {

const tileList = this.mapView.visibleTileSet.dataSourceTileList;
tileList.forEach(dataSourceTileList => {
if (!dataSourceTileList.dataSource.enablePicking) {
return;
}

dataSourceTileList.renderedTiles.forEach(tile => {
tmpOBB.copy(tile.boundingBox);
tmpOBB.position.sub(this.mapView.worldCenter);
Expand Down
1 change: 1 addition & 0 deletions @here/harp-mapview/lib/PolarTileDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class PolarTileDataSource extends DataSource {
this.m_geometryLevelOffset = geometryLevelOffset;
this.m_debugTiles = debugTiles;
this.cacheable = false;
this.enablePicking = false;
}

/** @override */
Expand Down
1 change: 1 addition & 0 deletions @here/harp-webtile-datasource/lib/WebTileDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class WebTileDataSource extends DataSource {

this.dataProvider = this.m_options.dataProvider;
this.cacheable = true;
this.enablePicking = false;
this.storageLevelOffset = -1;
this.m_resolution = getOptionValue(
m_options.resolution,
Expand Down

0 comments on commit 8ce945f

Please sign in to comment.