spacemap 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,7 +44,7 @@ your page:
44
44
  ```html
45
45
  <div id="map" style="height: 500px"></div>
46
46
  <script type="module">
47
- import { createMap } from 'https://cdn.jsdelivr.net/npm/spacemap@0.1.4/dist/spacemap.js';
47
+ import { createMap } from 'https://cdn.jsdelivr.net/npm/spacemap@0.1.6/dist/spacemap.js';
48
48
  const map = await createMap({ container: '#map' });
49
49
  </script>
50
50
  ```
@@ -166,6 +166,24 @@ anchor there is on the lit side even on a body whose spin is not measured. It
166
166
  is null as well until the map has read how the body spins, which it does once
167
167
  the camera is on the body or its system.
168
168
 
169
+ The same three measures are functions that need no map, for a page that has
170
+ none or that cannot wait for one to reach a date. They take the date and
171
+ resolve when the export has answered for it:
172
+
173
+ ```js
174
+ import { distanceKm, offsetKm, subsolarPoint } from 'spacemap';
175
+
176
+ const landing = new Date('1971-07-30T22:16:00Z');
177
+ await distanceKm({ body: 'naif-301' }, { body: 'naif-499' }, landing);
178
+ await offsetKm({ body: 'naif-301' }, { body: 'naif-499' }, landing);
179
+ await subsolarPoint('naif-301', landing);
180
+ ```
181
+
182
+ Null means nowhere at that date and never not loaded yet. They place planets,
183
+ moons and small bodies as the map does. Spacecraft are not placed, and a
184
+ satellite of Earth only near the present: those need the map. A failed
185
+ download rejects.
186
+
169
187
  ### Drawing on it
170
188
 
171
189
  Everything you draw is put somewhere by an **anchor**, and the anchor is what
@@ -235,6 +253,10 @@ an area drawn as a fill alone. The flat map says the same things with the same
235
253
  words — its version is `FlatShapeStyle`, named apart because a page can hold
236
254
  both maps at once — so a drawing described once can be handed to either.
237
255
 
256
+ A line, in space or on a surface, takes `dash` as the flat map's does: `'4 3'`
257
+ is four pixels drawn and three left out, counted on screen like the width, so
258
+ the dashes read the same from any distance.
259
+
238
260
  Two rules fall out of the scene rather than out of taste. Widths are pixels
239
261
  because the map spans metres to astronomical units, and a line a kilometre wide
240
262
  is a wall from low orbit and nothing at all from the next planet out. And a body
@@ -466,6 +488,22 @@ flat.isLayerVisible('clouds');
466
488
  flat.on('layerschange', (layers) => redraw(layers));
467
489
  ```
468
490
 
491
+ ### Bodies kept in sight
492
+
493
+ The map decides what to name by how far the camera is: a planet's halo and
494
+ orbit drop out once its whole orbit is a few pixels across, and a name gives way
495
+ to a bigger neighbour's. `setPinnedBodies` takes that decision for the bodies a
496
+ page is about:
497
+
498
+ ```js
499
+ map.setPinnedBodies(['naif-499', 'spkid-20000433']); // Mars and Eros, from anywhere
500
+ map.setPinnedBodies([]); // back to the map's own judgement
501
+ ```
502
+
503
+ A pinned body keeps its halo, name and orbit from however far, and through a
504
+ hidden layer. A moon is the exception: it is only drawn inside the system the
505
+ camera is in, so pin its planet to mark it from outside.
506
+
469
507
  ## The flat map
470
508
 
471
509
  One body's surface, drawn flat, with layers you can switch and drawings of your