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

Commit

Permalink
HARP-11817: Fixes labels placed outside of frustum (#1816)
Browse files Browse the repository at this point in the history
Signed-off-by: Frauke Fritz <frauke.fritz@here.com>
  • Loading branch information
FraukeF committed Sep 4, 2020
1 parent 59ff471 commit 66a1eb8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
12 changes: 9 additions & 3 deletions @here/harp-mapview/lib/text/TextElementsRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,9 @@ export class TextElementsRenderer {
this.m_tmpVector3
);
// Only process labels frustum-clipped labels
if (this.m_screenProjector.project(worldPosition, tempScreenPosition) === undefined) {
if (
this.m_screenProjector.projectOnScreen(worldPosition, tempScreenPosition) === undefined
) {
return false;
}
// Add this POI as a point label.
Expand Down Expand Up @@ -1791,7 +1793,9 @@ export class TextElementsRenderer {
for (let pointIndex = 0; pointIndex < path.length; ++pointIndex) {
const point = path[pointIndex];
// Only process labels frustum-clipped labels
if (this.m_screenProjector.project(point, tempScreenPosition) !== undefined) {
if (
this.m_screenProjector.projectOnScreen(point, tempScreenPosition) !== undefined
) {
// Find a suitable location for the lineMarker to be placed at.
let tooClose = false;
for (let j = 0; j < shieldGroup.length; j += 2) {
Expand Down Expand Up @@ -1832,7 +1836,9 @@ export class TextElementsRenderer {
for (let pointIndex = 0; pointIndex < path.length; ++pointIndex) {
const point = path[pointIndex];
// Only process labels frustum-clipped labels
if (this.m_screenProjector.project(point, tempScreenPosition) !== undefined) {
if (
this.m_screenProjector.projectOnScreen(point, tempScreenPosition) !== undefined
) {
this.addPointLabel(
labelState,
point,
Expand Down
34 changes: 31 additions & 3 deletions @here/harp-mapview/test/TextElementsRendererTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,25 @@ const tests: TestCase[] = [
}
],
frameTimes: FADE_2_CYCLES
},
{
name: "Poi only fades in, if its inside frustum",
tiles: [
{
labels: [
[
poiBuilder("outside frustum marker").withPosition(
(WORLD_SCALE * (4 * DEF_TEXT_WIDTH_HEIGHT)) / SCREEN_WIDTH,
(WORLD_SCALE * (4 * DEF_TEXT_WIDTH_HEIGHT)) / SCREEN_HEIGHT,
WORLD_SCALE * 10
),
fadedOut(FADE_2_CYCLES.length)
]
],
frames: firstNFrames(FADE_2_CYCLES, FADE_IN.length)
}
],
frameTimes: FADE_2_CYCLES
}
];

Expand Down Expand Up @@ -612,7 +631,10 @@ describe("TextElementsRenderer", function() {
return [];
}
return inputElements.map((inputElement: InputTextElement) => {
expect(frameStates(inputElement).length).equal(frameCount);
expect(frameStates(inputElement).length).equal(
frameCount,
"frameStates of inputElement equals frameCount"
);
// Only used to identify some text elements for testing purposes.
const dummyUserData = {};
const element = builder(inputElement)
Expand All @@ -637,10 +659,16 @@ describe("TextElementsRenderer", function() {
// frame states to an array.
test.tiles.forEach((tile: InputTile, tileIndex: number) => {
if (tile.frames !== undefined) {
expect(tile.frames.length).equal(test.frameTimes.length);
expect(tile.frames.length).equal(
test.frameTimes.length,
"frames length is the same"
);
}
if (tile.terrainFrames !== undefined) {
expect(tile.terrainFrames.length).equal(test.frameTimes.length);
expect(tile.terrainFrames.length).equal(
test.frameTimes.length,
"terrainFrames length is the same"
);
enableElevation = true;
}
const labels = buildLabels(tile.labels, elementFrameStates, test.frameTimes.length);
Expand Down

0 comments on commit 66a1eb8

Please sign in to comment.