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

Commit

Permalink
HARP-12685: Optimize label placement
Browse files Browse the repository at this point in the history
Signed-off-by: stefan.dachwitz <[email protected]>
  • Loading branch information
StefanDachwitz committed Nov 3, 2020
1 parent 3a6a034 commit d64f416
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions @here/harp-mapview/lib/ScreenProjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,27 @@ export class ScreenProjector {
* Test if the area around the specified point is visible on the screen.
*
* @param {(Vector3Like)} source The centered source vector to project.
* @param {(Number)} width Half of the width of the area in NDC space [0..1].
* @param {(Number)} height Half of the height of the area in NDC space [0..1].
* @param {(Number)} halfWidth Half of the width of the area in screen space [0..1].
* @param {(Number)} halfHeight Half of the height of the area in screen space [0..1].
* @param {THREE.Vector2} target The target vector.
* @returns {THREE.Vector2} The projected vector (the parameter 'target') or undefined if
* the area is completely outside the screen.
*/
projectAreaToScreen(
source: Vector3Like,
width: number,
height: number,
halfWidth: number,
halfHeight: number,
target: THREE.Vector2 = new THREE.Vector2()
): THREE.Vector2 | undefined {
width *= 2;
height *= 2;
halfWidth *= 2;
halfHeight *= 2;
const p = this.projectVector(source, ScreenProjector.tempV3);
if (
isInRange(p) &&
p.x + width >= -1 &&
p.x - width <= 1 &&
p.y + height >= -1 &&
p.y - height <= 1
p.x + halfWidth >= -1 &&
p.x - halfWidth <= 1 &&
p.y + halfHeight >= -1 &&
p.y - halfHeight <= 1
) {
return this.ndcToScreen(p, target);
}
Expand Down

0 comments on commit d64f416

Please sign in to comment.