How to use the @here/harp-utils.Math2D.Box function in @here/harp-utils

To help you get started, we’ve selected a few @here/harp-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heremaps / harp.gl / @here / harp-mapview / lib / text / TextElementsRenderer.ts View on Github external
/**
 * Minimum number of pixels per character. Used during estimation if there is enough screen space
 * available to render a text.
 */
const MIN_AVERAGE_CHAR_WIDTH = 5;

const logger = LoggerManager.instance.create("TextElementsRenderer", { level: LogLevel.Log });

// Development flag: Enable debug print.
const PRINT_LABEL_DEBUG_INFO: boolean = false;
const updateStats = PRINT_LABEL_DEBUG_INFO ? new UpdateStats(logger) : undefined;
const placementStats = PRINT_LABEL_DEBUG_INFO ? new PlacementStats(logger) : undefined;

const tempBox = new THREE.Box2();
const tempBoxes: THREE.Box2[] = [];
const tempBox2D = new Math2D.Box();

const tempPosition = new THREE.Vector3();
const tempScreenPosition = new THREE.Vector2();
const tempScreenPoints: THREE.Vector2[] = [];
const tempPoiScreenPosition = new THREE.Vector2();
const tempTextOffset = new THREE.Vector2();

class TileTextElements {
    constructor(readonly tile: Tile, readonly group: TextElementGroup) {}
}

class TextElementLists {
    constructor(readonly lists: TileTextElements[]) {}

    get priority() {
        assert(this.lists.length > 0);
github heremaps / harp.gl / @here / harp-mapview / lib / poi / PoiRenderer.ts View on Github external
static computeIconScreenBox(
        poiInfo: PoiInfo,
        screenPosition: THREE.Vector2,
        scale: number,
        zoomLevel: number,
        /* out */ screenBox: Math2D.Box = new Math2D.Box()
    ): Math2D.Box {
        assert(poiInfo.poiRenderBatch !== undefined);
        assert(poiInfo.poiRenderBatch !== INVALID_RENDER_BATCH);

        const width = poiInfo.computedWidth! * scale;
        const height = poiInfo.computedHeight! * scale;
        const technique = poiInfo.technique;
        const iconXOffset = getPropertyValue(technique.iconXOffset, zoomLevel);
        const iconYOffset = getPropertyValue(technique.iconYOffset, zoomLevel);

        const centerX = screenPosition.x + (typeof iconXOffset === "number" ? iconXOffset : 0);
        const centerY = screenPosition.y + (typeof iconYOffset === "number" ? iconYOffset : 0);

        screenBox.x = centerX - width / 2;
        screenBox.y = centerY - height / 2;
        screenBox.w = width;
github heremaps / harp.gl / @here / harp-mapview / lib / poi / BoxBuffer.ts View on Github external
const maxX = positions.getX(positionIndex + 1);
            if (screenX > maxX) {
                continue;
            }

            const minY = positions.getY(positionIndex);
            if (screenY < minY) {
                continue;
            }

            const maxY = positions.getY(positionIndex + 2);
            if (screenY > maxY) {
                continue;
            }

            const box = new Math2D.Box(minX, minY, maxX - minX, maxY - minY);
            if (
                imageData !== undefined &&
                pickInfos[pickInfoIndex].poiInfo !== undefined &&
                pickInfos[pickInfoIndex].poiInfo.uvBox !== undefined &&
                this.isPixelTransparent(
                    imageData,
                    screenX,
                    screenY,
                    box,
                    pickInfos[pickInfoIndex].poiInfo.uvBox,
                    canvas
                )
            ) {
                continue;
            }