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

Commit

Permalink
Fixes #1270. Contstruct correct Raycaster
Browse files Browse the repository at this point in the history
  • Loading branch information
nzjony committed Feb 7, 2020
1 parent 42234cc commit 810f40d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion @here/harp-examples/src/datasource_features_lines-and-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ export namespace LinesPointsFeaturesExample {
styleSetName: "myStyleSet",
features: getFeatures(faults)
});
map.addDataSource(featuresDataSource);
map.addDataSource(featuresDataSource).then(() => {
map.canvas.addEventListener("click", (e: MouseEvent) => {
const intersectionResults = map.intersectMapObjects(e.pageX, e.pageY);
const usableResults = intersectionResults.filter(
result => result.userData !== undefined
);
console.log(intersectionResults, usableResults);
});
});
// end:harp_demo_features_linespoints_3.ts

function getFeatures(features: {
Expand Down
3 changes: 2 additions & 1 deletion @here/harp-mapview/lib/MapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { ThemeLoader } from "./ThemeLoader";
import { Tile } from "./Tile";
import { MapViewUtils } from "./Utils";
import { ResourceComputationType, VisibleTileSet, VisibleTileSetOptions } from "./VisibleTileSet";
import { PickingRaycaster } from "./PickingRaycaster";

declare const process: any;

Expand Down Expand Up @@ -749,7 +750,7 @@ export class MapView extends THREE.EventDispatcher {
private m_enablePolarDataSource: boolean = true;

// gestures
private readonly m_raycaster = new THREE.Raycaster();
private readonly m_raycaster = new PickingRaycaster(this);
private readonly m_plane = new THREE.Plane(new THREE.Vector3(0, 0, 1));
private readonly m_sphere = new THREE.Sphere(undefined, EarthConstants.EQUATORIAL_RADIUS);

Expand Down

0 comments on commit 810f40d

Please sign in to comment.