import { StylePriority } from "@here/harp-datasource-protocol" ; import { GeoCoordinates , isGeoCoordinatesLike , isVector3Like , Projection , Vector3Like } from "@here/harp-geoutils" ; import { GeoCoordLike } from "@here/harp-geoutils/lib/coordinates/GeoCoordLike" ; import * as THREE from "three" ; /**
 * An interface describing [[THREE.Object3D]]s anchored on
 * given  {@link @here/harp-geoutils#GeoCoordinates} .
 *
 *  remarkks example export type MapAnchor < T extends THREE . Object3D = THREE . Object3D > = T & { /**
     * The position of this [[MapAnchor]] in  {@link @here/harp-geoutils#GeoCoordinates} .
     *  deprecated geoPosition ? : GeoCoordinates ; /**
     * The anchor of this Object3D in  {@link @here/harp-geoutils#GeoCoordinates} * or world coordinates.
      anchor ? : GeoCoordLike | Vector3Like ; note pickable ? : boolean ; remarks styleSet ? : string ; remarks category ? : string ; defaultValue overlay ? : boolean ; } ; /**
 * Container holding [[MapAnchor]] objects.
 */ export class MapAnchors { private m_anchors : MapAnchor [ ] = [ ] ; private m_priorities : StylePriority [ ] = [ ] ; /**
     * All currently added [[MapAnchor]]s.
     */ get children ( ) { return this . m_anchors ; } param mapAnchor add ( mapAnchor ) { this . m_anchors . push ( mapAnchor ) ; } param mapAnchor note remove ( mapAnchor ) { const index = this . m_anchors . findIndex ( element => element === mapAnchor ) ; if ( index > - 1 ) { this . m_anchors . splice ( index , 1 ) ; } } /**
     * Remove all [[MapAnchor]]s.
     */ clear ( ) { this . m_anchors . length = 0 ; } setPriorities ( priorities ) { this . m_priorities = priorities ; } param projection param cameraPosition param rootNode param overlayRootNode param priorities internal hidden update ( projection , cameraPosition , rootNode , overlayRootNode ) { const worldPosition = new THREE . Vector3 ( ) ; this . m_anchors . forEach ( ( mapAnchor ) => { if ( mapAnchor . styleSet !== undefined ) { const priority = this . m_priorities ?. findIndex ( entry => entry . group === mapAnchor . styleSet && entry . category === mapAnchor . category ) ; if ( priority !== undefined && priority !== - 1 ) { mapAnchor . renderOrder = ( priority + 1 ) * 10 ; } } const anchor = mapAnchor . geoPosition !== undefined ? mapAnchor . geoPosition : mapAnchor . anchor ; if ( anchor !== undefined ) { if ( isVector3Like ( anchor ) ) { worldPosition . set ( anchor . x , anchor . y , anchor . z ) ; } else if ( isGeoCoordinatesLike ( anchor ) ) { projection . projectPoint ( anchor , worldPosition ) ; } mapAnchor . position . copy ( worldPosition ) . sub ( cameraPosition ) ; } if ( mapAnchor . overlay === true ) { overlayRootNode . add ( mapAnchor ) ; } else { rootNode . add ( mapAnchor ) ; } } ) ; } }