WorldWindEarth / worldwindjs

WorldWindJS is a community maintained fork of the WebWorldWind virtual globe SDK from NASA - an interactive 3D globe library featuring maps, imagery and terrain plus 2D map projections.
https://worldwind.earth/worldwindjs/
38 stars 9 forks source link

Placemark level of details selection is missing #34

Closed ComBatVision closed 5 years ago

ComBatVision commented 5 years ago

WorldWindJS implementation of Placemark is missing level of details selection for placemark image source, depending on camera distance, as it was already done in Java and Android implementations.

Function makeOrderedRenderable in Placemark should execute some selectLod(dc, this, this.eyeDistance) function before this.determineActiveAttributes(dc) to allow application to define placemark attributes selection depending on this.eyeDistance.

You can look at example in Android repository.

ComBatVision commented 5 years ago

There are four solutions of this issue in JS: 1) We can declare undefined attribute selectLevelOfDetails in Placemark, expecting that somebody will assign a function with parameters dc, placemark and distance to it in application. Than call function this.selectLevelOfDetails inside determineActiveAttributes if it is defined. This approach is more suitable for JS. 2) We can declare undefined attribute levelOfDetailsSelector in Placemark, expecting that somebody will assign any object, which must have selectLevelOfDetails function with parameters dc, placemark and distance in it. Than call function this.levelOfDetailsSelector.selectLevelOfDetails if it is defined. This approach will be similar with Java and Android Interface approach, but little bit confused in JS. 3) We can combine approach 1 and 2 by impementing a setter for levelOfDetailsSelector and determine if we put function or object in it. If it is an object than just assign it to attribute, if it is a function, than wrap it into generic object. Then work with attribute as described in approach2. 4) We can define empty function selectLevelOfDetails with required parameters inside Placemark and expect that application will redefine a function in placemark or override it in possible child object implementation.

Which approach will you approve?

emxsys commented 5 years ago

@Sufaev I'm partial to options 1 and 4. These options seem to be aligned with existing paradigms used in WebWorldWind.

ComBatVision commented 5 years ago

@emxsys Could you give me any example of already available realization of this paradigm in project? I want to see code style to make code maximum aligned to it.

emxsys commented 5 years ago

@Sufaev I'm sorry, I have to leave in just a couple of minutes. If my recollection serves me correctly, I think the whole Renderable hierarchy may have some examples. I'll be back online in a day or two.

ComBatVision commented 5 years ago

Created PR with last approach https://github.com/WorldWindEarth/worldwindjs/pull/35 Please, merge it to develop.