From d50535abb03c6887dfa75b42b1ec35c30d6ec2c4 Mon Sep 17 00:00:00 2001 From: Eugene Maksymenko Date: Mon, 7 Dec 2020 21:07:17 +0200 Subject: [PATCH] Implement placemark level of details selector (https://github.com/WorldWindEarth/worldwindjs/issues/34) --- src/shapes/Placemark.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/shapes/Placemark.js b/src/shapes/Placemark.js index ee38d37c1..5be0b577a 100644 --- a/src/shapes/Placemark.js +++ b/src/shapes/Placemark.js @@ -424,13 +424,7 @@ define([ * cannot be created or should not be created at the time this method is called. */ Placemark.prototype.makeOrderedRenderable = function (dc) { - var w, h, s, - offset; - - this.determineActiveAttributes(dc); - if (!this.activeAttributes) { - return null; - } + var w, h, s, offset; // Compute the placemark's model point and corresponding distance to the eye point. If the placemark's // position is terrain-dependent but off the terrain, then compute it ABSOLUTE so that we have a point for @@ -442,6 +436,14 @@ define([ this.eyeDistance = this.alwaysOnTop ? 0 : dc.eyePoint.distanceTo(this.placePoint); + // Extension point to override placemark attributes depending on camera distance + this.selectLevelOfDetail(dc, this, this.eyeDistance); + + this.determineActiveAttributes(dc); + if (!this.activeAttributes) { + return null; + } + if (this.mustDrawLeaderLine(dc)) { dc.surfacePointForMode(this.position.latitude, this.position.longitude, 0, this.altitudeMode, this.groundPoint); @@ -513,6 +515,17 @@ define([ return this; }; + /** + * Set the placemark attributes for the current distance to the camera and highlighted state. + * + * @param {DrawContext} dc The current render context + * @param {Placemark} placemark The placemark needing a level of detail selection + * @param {Number} cameraDistance The distance from the placemark to the camera (meters) + */ + Placemark.prototype.selectLevelOfDetail = function (dc, placemark, cameraDistance) { + // Intentionally empty. Can be override in application if required. + }; + // Internal. Intentionally not documented. Placemark.prototype.determineActiveAttributes = function (dc) { if (this.highlighted && this.highlightAttributes) {