spacemap 0.1.0
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/LICENSE +373 -0
- package/README.md +590 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
Mozilla Public License Version 2.0
|
|
2
|
+
==================================
|
|
3
|
+
|
|
4
|
+
1. Definitions
|
|
5
|
+
--------------
|
|
6
|
+
|
|
7
|
+
1.1. "Contributor"
|
|
8
|
+
means each individual or legal entity that creates, contributes to
|
|
9
|
+
the creation of, or owns Covered Software.
|
|
10
|
+
|
|
11
|
+
1.2. "Contributor Version"
|
|
12
|
+
means the combination of the Contributions of others (if any) used
|
|
13
|
+
by a Contributor and that particular Contributor's Contribution.
|
|
14
|
+
|
|
15
|
+
1.3. "Contribution"
|
|
16
|
+
means Covered Software of a particular Contributor.
|
|
17
|
+
|
|
18
|
+
1.4. "Covered Software"
|
|
19
|
+
means Source Code Form to which the initial Contributor has attached
|
|
20
|
+
the notice in Exhibit A, the Executable Form of such Source Code
|
|
21
|
+
Form, and Modifications of such Source Code Form, in each case
|
|
22
|
+
including portions thereof.
|
|
23
|
+
|
|
24
|
+
1.5. "Incompatible With Secondary Licenses"
|
|
25
|
+
means
|
|
26
|
+
|
|
27
|
+
(a) that the initial Contributor has attached the notice described
|
|
28
|
+
in Exhibit B to the Covered Software; or
|
|
29
|
+
|
|
30
|
+
(b) that the Covered Software was made available under the terms of
|
|
31
|
+
version 1.1 or earlier of the License, but not also under the
|
|
32
|
+
terms of a Secondary License.
|
|
33
|
+
|
|
34
|
+
1.6. "Executable Form"
|
|
35
|
+
means any form of the work other than Source Code Form.
|
|
36
|
+
|
|
37
|
+
1.7. "Larger Work"
|
|
38
|
+
means a work that combines Covered Software with other material, in
|
|
39
|
+
a separate file or files, that is not Covered Software.
|
|
40
|
+
|
|
41
|
+
1.8. "License"
|
|
42
|
+
means this document.
|
|
43
|
+
|
|
44
|
+
1.9. "Licensable"
|
|
45
|
+
means having the right to grant, to the maximum extent possible,
|
|
46
|
+
whether at the time of the initial grant or subsequently, any and
|
|
47
|
+
all of the rights conveyed by this License.
|
|
48
|
+
|
|
49
|
+
1.10. "Modifications"
|
|
50
|
+
means any of the following:
|
|
51
|
+
|
|
52
|
+
(a) any file in Source Code Form that results from an addition to,
|
|
53
|
+
deletion from, or modification of the contents of Covered
|
|
54
|
+
Software; or
|
|
55
|
+
|
|
56
|
+
(b) any new file in Source Code Form that contains any Covered
|
|
57
|
+
Software.
|
|
58
|
+
|
|
59
|
+
1.11. "Patent Claims" of a Contributor
|
|
60
|
+
means any patent claim(s), including without limitation, method,
|
|
61
|
+
process, and apparatus claims, in any patent Licensable by such
|
|
62
|
+
Contributor that would be infringed, but for the grant of the
|
|
63
|
+
License, by the making, using, selling, offering for sale, having
|
|
64
|
+
made, import, or transfer of either its Contributions or its
|
|
65
|
+
Contributor Version.
|
|
66
|
+
|
|
67
|
+
1.12. "Secondary License"
|
|
68
|
+
means either the GNU General Public License, Version 2.0, the GNU
|
|
69
|
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
70
|
+
Public License, Version 3.0, or any later versions of those
|
|
71
|
+
licenses.
|
|
72
|
+
|
|
73
|
+
1.13. "Source Code Form"
|
|
74
|
+
means the form of the work preferred for making modifications.
|
|
75
|
+
|
|
76
|
+
1.14. "You" (or "Your")
|
|
77
|
+
means an individual or a legal entity exercising rights under this
|
|
78
|
+
License. For legal entities, "You" includes any entity that
|
|
79
|
+
controls, is controlled by, or is under common control with You. For
|
|
80
|
+
purposes of this definition, "control" means (a) the power, direct
|
|
81
|
+
or indirect, to cause the direction or management of such entity,
|
|
82
|
+
whether by contract or otherwise, or (b) ownership of more than
|
|
83
|
+
fifty percent (50%) of the outstanding shares or beneficial
|
|
84
|
+
ownership of such entity.
|
|
85
|
+
|
|
86
|
+
2. License Grants and Conditions
|
|
87
|
+
--------------------------------
|
|
88
|
+
|
|
89
|
+
2.1. Grants
|
|
90
|
+
|
|
91
|
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
92
|
+
non-exclusive license:
|
|
93
|
+
|
|
94
|
+
(a) under intellectual property rights (other than patent or trademark)
|
|
95
|
+
Licensable by such Contributor to use, reproduce, make available,
|
|
96
|
+
modify, display, perform, distribute, and otherwise exploit its
|
|
97
|
+
Contributions, either on an unmodified basis, with Modifications, or
|
|
98
|
+
as part of a Larger Work; and
|
|
99
|
+
|
|
100
|
+
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
101
|
+
for sale, have made, import, and otherwise transfer either its
|
|
102
|
+
Contributions or its Contributor Version.
|
|
103
|
+
|
|
104
|
+
2.2. Effective Date
|
|
105
|
+
|
|
106
|
+
The licenses granted in Section 2.1 with respect to any Contribution
|
|
107
|
+
become effective for each Contribution on the date the Contributor first
|
|
108
|
+
distributes such Contribution.
|
|
109
|
+
|
|
110
|
+
2.3. Limitations on Grant Scope
|
|
111
|
+
|
|
112
|
+
The licenses granted in this Section 2 are the only rights granted under
|
|
113
|
+
this License. No additional rights or licenses will be implied from the
|
|
114
|
+
distribution or licensing of Covered Software under this License.
|
|
115
|
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
116
|
+
Contributor:
|
|
117
|
+
|
|
118
|
+
(a) for any code that a Contributor has removed from Covered Software;
|
|
119
|
+
or
|
|
120
|
+
|
|
121
|
+
(b) for infringements caused by: (i) Your and any other third party's
|
|
122
|
+
modifications of Covered Software, or (ii) the combination of its
|
|
123
|
+
Contributions with other software (except as part of its Contributor
|
|
124
|
+
Version); or
|
|
125
|
+
|
|
126
|
+
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
127
|
+
its Contributions.
|
|
128
|
+
|
|
129
|
+
This License does not grant any rights in the trademarks, service marks,
|
|
130
|
+
or logos of any Contributor (except as may be necessary to comply with
|
|
131
|
+
the notice requirements in Section 3.4).
|
|
132
|
+
|
|
133
|
+
2.4. Subsequent Licenses
|
|
134
|
+
|
|
135
|
+
No Contributor makes additional grants as a result of Your choice to
|
|
136
|
+
distribute the Covered Software under a subsequent version of this
|
|
137
|
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
138
|
+
permitted under the terms of Section 3.3).
|
|
139
|
+
|
|
140
|
+
2.5. Representation
|
|
141
|
+
|
|
142
|
+
Each Contributor represents that the Contributor believes its
|
|
143
|
+
Contributions are its original creation(s) or it has sufficient rights
|
|
144
|
+
to grant the rights to its Contributions conveyed by this License.
|
|
145
|
+
|
|
146
|
+
2.6. Fair Use
|
|
147
|
+
|
|
148
|
+
This License is not intended to limit any rights You have under
|
|
149
|
+
applicable copyright doctrines of fair use, fair dealing, or other
|
|
150
|
+
equivalents.
|
|
151
|
+
|
|
152
|
+
2.7. Conditions
|
|
153
|
+
|
|
154
|
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
155
|
+
in Section 2.1.
|
|
156
|
+
|
|
157
|
+
3. Responsibilities
|
|
158
|
+
-------------------
|
|
159
|
+
|
|
160
|
+
3.1. Distribution of Source Form
|
|
161
|
+
|
|
162
|
+
All distribution of Covered Software in Source Code Form, including any
|
|
163
|
+
Modifications that You create or to which You contribute, must be under
|
|
164
|
+
the terms of this License. You must inform recipients that the Source
|
|
165
|
+
Code Form of the Covered Software is governed by the terms of this
|
|
166
|
+
License, and how they can obtain a copy of this License. You may not
|
|
167
|
+
attempt to alter or restrict the recipients' rights in the Source Code
|
|
168
|
+
Form.
|
|
169
|
+
|
|
170
|
+
3.2. Distribution of Executable Form
|
|
171
|
+
|
|
172
|
+
If You distribute Covered Software in Executable Form then:
|
|
173
|
+
|
|
174
|
+
(a) such Covered Software must also be made available in Source Code
|
|
175
|
+
Form, as described in Section 3.1, and You must inform recipients of
|
|
176
|
+
the Executable Form how they can obtain a copy of such Source Code
|
|
177
|
+
Form by reasonable means in a timely manner, at a charge no more
|
|
178
|
+
than the cost of distribution to the recipient; and
|
|
179
|
+
|
|
180
|
+
(b) You may distribute such Executable Form under the terms of this
|
|
181
|
+
License, or sublicense it under different terms, provided that the
|
|
182
|
+
license for the Executable Form does not attempt to limit or alter
|
|
183
|
+
the recipients' rights in the Source Code Form under this License.
|
|
184
|
+
|
|
185
|
+
3.3. Distribution of a Larger Work
|
|
186
|
+
|
|
187
|
+
You may create and distribute a Larger Work under terms of Your choice,
|
|
188
|
+
provided that You also comply with the requirements of this License for
|
|
189
|
+
the Covered Software. If the Larger Work is a combination of Covered
|
|
190
|
+
Software with a work governed by one or more Secondary Licenses, and the
|
|
191
|
+
Covered Software is not Incompatible With Secondary Licenses, this
|
|
192
|
+
License permits You to additionally distribute such Covered Software
|
|
193
|
+
under the terms of such Secondary License(s), so that the recipient of
|
|
194
|
+
the Larger Work may, at their option, further distribute the Covered
|
|
195
|
+
Software under the terms of either this License or such Secondary
|
|
196
|
+
License(s).
|
|
197
|
+
|
|
198
|
+
3.4. Notices
|
|
199
|
+
|
|
200
|
+
You may not remove or alter the substance of any license notices
|
|
201
|
+
(including copyright notices, patent notices, disclaimers of warranty,
|
|
202
|
+
or limitations of liability) contained within the Source Code Form of
|
|
203
|
+
the Covered Software, except that You may alter any license notices to
|
|
204
|
+
the extent required to remedy known factual inaccuracies.
|
|
205
|
+
|
|
206
|
+
3.5. Application of Additional Terms
|
|
207
|
+
|
|
208
|
+
You may choose to offer, and to charge a fee for, warranty, support,
|
|
209
|
+
indemnity or liability obligations to one or more recipients of Covered
|
|
210
|
+
Software. However, You may do so only on Your own behalf, and not on
|
|
211
|
+
behalf of any Contributor. You must make it absolutely clear that any
|
|
212
|
+
such warranty, support, indemnity, or liability obligation is offered by
|
|
213
|
+
You alone, and You hereby agree to indemnify every Contributor for any
|
|
214
|
+
liability incurred by such Contributor as a result of warranty, support,
|
|
215
|
+
indemnity or liability terms You offer. You may include additional
|
|
216
|
+
disclaimers of warranty and limitations of liability specific to any
|
|
217
|
+
jurisdiction.
|
|
218
|
+
|
|
219
|
+
4. Inability to Comply Due to Statute or Regulation
|
|
220
|
+
---------------------------------------------------
|
|
221
|
+
|
|
222
|
+
If it is impossible for You to comply with any of the terms of this
|
|
223
|
+
License with respect to some or all of the Covered Software due to
|
|
224
|
+
statute, judicial order, or regulation then You must: (a) comply with
|
|
225
|
+
the terms of this License to the maximum extent possible; and (b)
|
|
226
|
+
describe the limitations and the code they affect. Such description must
|
|
227
|
+
be placed in a text file included with all distributions of the Covered
|
|
228
|
+
Software under this License. Except to the extent prohibited by statute
|
|
229
|
+
or regulation, such description must be sufficiently detailed for a
|
|
230
|
+
recipient of ordinary skill to be able to understand it.
|
|
231
|
+
|
|
232
|
+
5. Termination
|
|
233
|
+
--------------
|
|
234
|
+
|
|
235
|
+
5.1. The rights granted under this License will terminate automatically
|
|
236
|
+
if You fail to comply with any of its terms. However, if You become
|
|
237
|
+
compliant, then the rights granted under this License from a particular
|
|
238
|
+
Contributor are reinstated (a) provisionally, unless and until such
|
|
239
|
+
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
240
|
+
ongoing basis, if such Contributor fails to notify You of the
|
|
241
|
+
non-compliance by some reasonable means prior to 60 days after You have
|
|
242
|
+
come back into compliance. Moreover, Your grants from a particular
|
|
243
|
+
Contributor are reinstated on an ongoing basis if such Contributor
|
|
244
|
+
notifies You of the non-compliance by some reasonable means, this is the
|
|
245
|
+
first time You have received notice of non-compliance with this License
|
|
246
|
+
from such Contributor, and You become compliant prior to 30 days after
|
|
247
|
+
Your receipt of the notice.
|
|
248
|
+
|
|
249
|
+
5.2. If You initiate litigation against any entity by asserting a patent
|
|
250
|
+
infringement claim (excluding declaratory judgment actions,
|
|
251
|
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
252
|
+
directly or indirectly infringes any patent, then the rights granted to
|
|
253
|
+
You by any and all Contributors for the Covered Software under Section
|
|
254
|
+
2.1 of this License shall terminate.
|
|
255
|
+
|
|
256
|
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
257
|
+
end user license agreements (excluding distributors and resellers) which
|
|
258
|
+
have been validly granted by You or Your distributors under this License
|
|
259
|
+
prior to termination shall survive termination.
|
|
260
|
+
|
|
261
|
+
************************************************************************
|
|
262
|
+
* *
|
|
263
|
+
* 6. Disclaimer of Warranty *
|
|
264
|
+
* ------------------------- *
|
|
265
|
+
* *
|
|
266
|
+
* Covered Software is provided under this License on an "as is" *
|
|
267
|
+
* basis, without warranty of any kind, either expressed, implied, or *
|
|
268
|
+
* statutory, including, without limitation, warranties that the *
|
|
269
|
+
* Covered Software is free of defects, merchantable, fit for a *
|
|
270
|
+
* particular purpose or non-infringing. The entire risk as to the *
|
|
271
|
+
* quality and performance of the Covered Software is with You. *
|
|
272
|
+
* Should any Covered Software prove defective in any respect, You *
|
|
273
|
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
274
|
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
275
|
+
* essential part of this License. No use of any Covered Software is *
|
|
276
|
+
* authorized under this License except under this disclaimer. *
|
|
277
|
+
* *
|
|
278
|
+
************************************************************************
|
|
279
|
+
|
|
280
|
+
************************************************************************
|
|
281
|
+
* *
|
|
282
|
+
* 7. Limitation of Liability *
|
|
283
|
+
* -------------------------- *
|
|
284
|
+
* *
|
|
285
|
+
* Under no circumstances and under no legal theory, whether tort *
|
|
286
|
+
* (including negligence), contract, or otherwise, shall any *
|
|
287
|
+
* Contributor, or anyone who distributes Covered Software as *
|
|
288
|
+
* permitted above, be liable to You for any direct, indirect, *
|
|
289
|
+
* special, incidental, or consequential damages of any character *
|
|
290
|
+
* including, without limitation, damages for lost profits, loss of *
|
|
291
|
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
292
|
+
* and all other commercial damages or losses, even if such party *
|
|
293
|
+
* shall have been informed of the possibility of such damages. This *
|
|
294
|
+
* limitation of liability shall not apply to liability for death or *
|
|
295
|
+
* personal injury resulting from such party's negligence to the *
|
|
296
|
+
* extent applicable law prohibits such limitation. Some *
|
|
297
|
+
* jurisdictions do not allow the exclusion or limitation of *
|
|
298
|
+
* incidental or consequential damages, so this exclusion and *
|
|
299
|
+
* limitation may not apply to You. *
|
|
300
|
+
* *
|
|
301
|
+
************************************************************************
|
|
302
|
+
|
|
303
|
+
8. Litigation
|
|
304
|
+
-------------
|
|
305
|
+
|
|
306
|
+
Any litigation relating to this License may be brought only in the
|
|
307
|
+
courts of a jurisdiction where the defendant maintains its principal
|
|
308
|
+
place of business and such litigation shall be governed by laws of that
|
|
309
|
+
jurisdiction, without reference to its conflict-of-law provisions.
|
|
310
|
+
Nothing in this Section shall prevent a party's ability to bring
|
|
311
|
+
cross-claims or counter-claims.
|
|
312
|
+
|
|
313
|
+
9. Miscellaneous
|
|
314
|
+
----------------
|
|
315
|
+
|
|
316
|
+
This License represents the complete agreement concerning the subject
|
|
317
|
+
matter hereof. If any provision of this License is held to be
|
|
318
|
+
unenforceable, such provision shall be reformed only to the extent
|
|
319
|
+
necessary to make it enforceable. Any law or regulation which provides
|
|
320
|
+
that the language of a contract shall be construed against the drafter
|
|
321
|
+
shall not be used to construe this License against a Contributor.
|
|
322
|
+
|
|
323
|
+
10. Versions of the License
|
|
324
|
+
---------------------------
|
|
325
|
+
|
|
326
|
+
10.1. New Versions
|
|
327
|
+
|
|
328
|
+
Mozilla Foundation is the license steward. Except as provided in Section
|
|
329
|
+
10.3, no one other than the license steward has the right to modify or
|
|
330
|
+
publish new versions of this License. Each version will be given a
|
|
331
|
+
distinguishing version number.
|
|
332
|
+
|
|
333
|
+
10.2. Effect of New Versions
|
|
334
|
+
|
|
335
|
+
You may distribute the Covered Software under the terms of the version
|
|
336
|
+
of the License under which You originally received the Covered Software,
|
|
337
|
+
or under the terms of any subsequent version published by the license
|
|
338
|
+
steward.
|
|
339
|
+
|
|
340
|
+
10.3. Modified Versions
|
|
341
|
+
|
|
342
|
+
If you create software not governed by this License, and you want to
|
|
343
|
+
create a new license for such software, you may create and use a
|
|
344
|
+
modified version of this License if you rename the license and remove
|
|
345
|
+
any references to the name of the license steward (except to note that
|
|
346
|
+
such modified license differs from this License).
|
|
347
|
+
|
|
348
|
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
349
|
+
Licenses
|
|
350
|
+
|
|
351
|
+
If You choose to distribute Source Code Form that is Incompatible With
|
|
352
|
+
Secondary Licenses under the terms of this version of the License, the
|
|
353
|
+
notice described in Exhibit B of this License must be attached.
|
|
354
|
+
|
|
355
|
+
Exhibit A - Source Code Form License Notice
|
|
356
|
+
-------------------------------------------
|
|
357
|
+
|
|
358
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
359
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
360
|
+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
361
|
+
|
|
362
|
+
If it is not possible or desirable to put the notice in a particular
|
|
363
|
+
file, then You may include the notice in a location (such as a LICENSE
|
|
364
|
+
file in a relevant directory) where a recipient would be likely to look
|
|
365
|
+
for such a notice.
|
|
366
|
+
|
|
367
|
+
You may add additional accurate notices of copyright ownership.
|
|
368
|
+
|
|
369
|
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
370
|
+
---------------------------------------------------------
|
|
371
|
+
|
|
372
|
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
373
|
+
defined by the Mozilla Public License, v. 2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
# spacemap
|
|
2
|
+
|
|
3
|
+
The map of the Solar System from [spacemap.co](https://spacemap.co), on your
|
|
4
|
+
website! There are flat maps too, and 360 panoramas from the surface.
|
|
5
|
+
|
|
6
|
+
Distances are kilometres and angles are degrees throughout. Objects are named
|
|
7
|
+
by their export id — `naif-399` for Earth, `spkid-20000004` for Vesta,
|
|
8
|
+
`norad_satcat-25544` for the ISS.
|
|
9
|
+
|
|
10
|
+
Licensed MPL-2.0. No key, no quota for now. The credit line the map draws is
|
|
11
|
+
not removable: the imagery it shows requires attribution. Some body textures
|
|
12
|
+
are licensed for non-commercial use only.
|
|
13
|
+
|
|
14
|
+
## Getting it
|
|
15
|
+
|
|
16
|
+
As one script that carries everything it needs — `spacemap.js`, an ES module,
|
|
17
|
+
next to `spacemap.iife.js` for pages that want a global instead:
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<div id="map" style="height: 500px"></div>
|
|
21
|
+
<script type="module">
|
|
22
|
+
import { createMap } from './spacemap.js';
|
|
23
|
+
const map = await createMap({ container: '#map' });
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or from npm, where three.js is yours to provide:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm install spacemap three
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { createMap } from 'spacemap';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## The Solar System map
|
|
38
|
+
|
|
39
|
+
`createMap` resolves once the map is worth looking at: the opening body placed,
|
|
40
|
+
and the one-off quality benchmark done. Small bodies go on streaming in behind
|
|
41
|
+
the map it hands back.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const map = await createMap({
|
|
45
|
+
container: '#map',
|
|
46
|
+
view: { body: 'naif-499', lat: 20, lon: 0, distanceKm: 40000 },
|
|
47
|
+
date: new Date('2030-01-01'),
|
|
48
|
+
locale: 'fr'
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Moving the camera
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
await map.flyTo({ body: 'naif-599' }); // fly, framing it for you
|
|
56
|
+
map.jumpTo({ body: 'naif-599', distanceKm: 2e6 }); // no flight
|
|
57
|
+
map.jumpTo({ body: 'naif-399', facing: 'naif-10', elevationDeg: 30 });
|
|
58
|
+
map.getCamera(); // { body, lat, lon, distanceKm }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`flyTo` resolves when the flight lands. What a target leaves out the map frames
|
|
62
|
+
itself, so `{ body }` alone is the ordinary way to move.
|
|
63
|
+
|
|
64
|
+
Clicking a named surface feature reports it; `panTo` turns to one without
|
|
65
|
+
travelling:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
map.on('featureselect', (feature) => map.panTo({ body: feature.bodyId, feature }));
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To place the camera yourself, frame by frame, take it off the map's own
|
|
72
|
+
controls:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
const hold = map.holdCamera();
|
|
76
|
+
map.on('frame', () =>
|
|
77
|
+
hold.set({ position: { body: 'naif-499', offsetKm: [x, y, z] }, target: { body: 'naif-499' } })
|
|
78
|
+
);
|
|
79
|
+
hold.release();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Events
|
|
83
|
+
|
|
84
|
+
`on` returns a function that stops listening; `once` and `off` do what they say.
|
|
85
|
+
|
|
86
|
+
| event | when |
|
|
87
|
+
| --------------------------------- | -------------------------------------------------- |
|
|
88
|
+
| `focuschange` | the camera settled on another object |
|
|
89
|
+
| `camera` | the camera came to rest |
|
|
90
|
+
| `featureselect` | a nomenclature label was clicked |
|
|
91
|
+
| `clock` | the date, play state, rate or direction changed |
|
|
92
|
+
| `loading` / `progress` | data is coming in |
|
|
93
|
+
| `error` | the data could not be loaded |
|
|
94
|
+
| `notice` / `noticedismiss` | a condition worth telling the reader about |
|
|
95
|
+
| `layerschange` | a layer was switched |
|
|
96
|
+
| `frame` | once per drawn frame |
|
|
97
|
+
| `contextlost` / `contextrestored` | the GPU context dropped and came back |
|
|
98
|
+
| `datastale` | the export was republished while this map was open |
|
|
99
|
+
| `userpromoted` | how many reader-promoted bodies can be cleared |
|
|
100
|
+
|
|
101
|
+
### The clock
|
|
102
|
+
|
|
103
|
+
`map.clock` is the simulation clock. It starts on wall-clock time unless the
|
|
104
|
+
map was opened on a date.
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
map.clock.pause();
|
|
108
|
+
map.clock.setTimeScale(86400); // a day a second
|
|
109
|
+
map.clock.toggleDirection();
|
|
110
|
+
map.clock.setDate(new Date('2035-06-01'));
|
|
111
|
+
map.clock.now();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Drawing on it
|
|
115
|
+
|
|
116
|
+
Everything you draw is put somewhere by an **anchor**, and the anchor is what
|
|
117
|
+
keeps it there as the map moves under it. There are two kinds. A surface anchor
|
|
118
|
+
is a longitude, a latitude and a height on a body, and turns with the body as
|
|
119
|
+
it spins; an inertial anchor is a body and an offset in kilometres on ecliptic
|
|
120
|
+
axes, which travels with the body but does not turn. Either way the drawing
|
|
121
|
+
follows what it is drawn on, over any distance and any date.
|
|
122
|
+
|
|
123
|
+
Six things sit **in space**, measured from an anchor in kilometres:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
// Your own element, pinned to a place.
|
|
127
|
+
const marker = map.addMarker({
|
|
128
|
+
anchor: { body: 'naif-499', latitude: 18.4, longitude: 77.5, altitudeKm: 0 },
|
|
129
|
+
element: pin,
|
|
130
|
+
align: [0.5, 1],
|
|
131
|
+
occlude: true
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// A line. Points are kilometres from the anchor, on ecliptic axes.
|
|
135
|
+
map.addPolyline({ anchor: { body: 'naif-499' }, points, color: '#66aaff', closed: true });
|
|
136
|
+
|
|
137
|
+
// An area, filled in its own colour unless you name another.
|
|
138
|
+
map.addPolygon({ anchor: { body: 'naif-499' }, points, color: '#ffcc55', fillOpacity: 0.3 });
|
|
139
|
+
|
|
140
|
+
// A circle round a place, in a plane you turn where you like. It is a ring
|
|
141
|
+
// rather than a disc unless you give it a fill: what it is drawn round is
|
|
142
|
+
// usually the point.
|
|
143
|
+
const ring = map.addCircle({
|
|
144
|
+
anchor: { body: 'naif-499' },
|
|
145
|
+
radiusKm: 20000,
|
|
146
|
+
normal: [0.4, 0, 1],
|
|
147
|
+
widthPx: 3
|
|
148
|
+
});
|
|
149
|
+
ring.setRadiusKm(30000);
|
|
150
|
+
|
|
151
|
+
// Text at a place, without an element of your own to build and style.
|
|
152
|
+
map.addLabel({ anchor: { body: 'naif-499', latitude: 18.4, longitude: 77.5 }, text: 'Elysium' });
|
|
153
|
+
|
|
154
|
+
// A picture at a place. It holds its size on screen wherever the camera goes.
|
|
155
|
+
map.addIcon({ anchor: { body: 'naif-499' }, url: badge, widthPx: 28, occlude: true });
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Three more are drawn **on a body**, following its curve and turning with it.
|
|
159
|
+
These take longitude and latitude rather than kilometres — the same places the
|
|
160
|
+
flat map's shapes take, so one list of points draws on both maps:
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
map.addSurfacePolyline({ body: 'naif-499', points: track, interpolate: 'geodesic' });
|
|
164
|
+
map.addSurfacePolygon({ body: 'naif-499', points: quadrangle, color: '#88ddff' });
|
|
165
|
+
map.addSurfaceCircle({ body: 'naif-499', center: { lon: 77.5, lat: 18.4 }, radiusKm: 800 });
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`boxRing`, `smallCircle` and `graticule`, the flat map's helpers, make point
|
|
169
|
+
lists these take; `circlePoints` does the same for a circle in space.
|
|
170
|
+
|
|
171
|
+
Every drawing answers `remove()` and `setVisible()`, a shape answers
|
|
172
|
+
`setAnchor()` and `setPoints()`, and `map.clearDrawings()` takes them all away
|
|
173
|
+
at once, leaving the map itself alone.
|
|
174
|
+
|
|
175
|
+
`ShapeStyle` is shared by the shapes: `color`, `widthPx` in screen pixels,
|
|
176
|
+
`opacity`, `fill` and `fillOpacity`. A width of zero leaves the outline out, for
|
|
177
|
+
an area drawn as a fill alone. The flat map says the same things with the same
|
|
178
|
+
words — its version is `FlatShapeStyle`, named apart because a page can hold
|
|
179
|
+
both maps at once — so a drawing described once can be handed to either.
|
|
180
|
+
|
|
181
|
+
Two rules fall out of the scene rather than out of taste. Widths are pixels
|
|
182
|
+
because the map spans metres to astronomical units, and a line a kilometre wide
|
|
183
|
+
is a wall from low orbit and nothing at all from the next planet out. And a body
|
|
184
|
+
hides what is behind it: a shape in space is drawn with the orbit trails and is
|
|
185
|
+
cut off at a body's edge exactly as they are, and a shape on a surface stops at
|
|
186
|
+
the limb. Markers, labels and icons are HTML rather than geometry and would
|
|
187
|
+
otherwise show through the body they sit on, so they take `occlude` to be hidden
|
|
188
|
+
when the place they mark turns away.
|
|
189
|
+
|
|
190
|
+
A shape on a surface floats a little above it by default — half a percent of the
|
|
191
|
+
body's radius, which is 17 km at Mars. That clears the relief the map draws, so
|
|
192
|
+
the shape reads as lying on the ground rather than sinking into it, and ground
|
|
193
|
+
higher than that still comes through, as it should. Give it an `altitudeKm` of
|
|
194
|
+
its own for a track flown rather than walked.
|
|
195
|
+
|
|
196
|
+
Labels and icons are elements, so listen to them directly through their
|
|
197
|
+
`element`; they take pointer events only once you pass `interactive: true`,
|
|
198
|
+
since the camera is dragged through the layer they sit in. Shapes drawn as
|
|
199
|
+
geometry are not clickable.
|
|
200
|
+
|
|
201
|
+
### Objects of your own
|
|
202
|
+
|
|
203
|
+
A spacecraft, a station, a body the export has never heard of: your own thing on
|
|
204
|
+
the map, moving under its own trajectory and drawn with your own model.
|
|
205
|
+
|
|
206
|
+
```js
|
|
207
|
+
const sat = map.objects.add({
|
|
208
|
+
id: 'my-sat',
|
|
209
|
+
name: 'My Satellite',
|
|
210
|
+
position: tle(line1, line2),
|
|
211
|
+
model: { object3d: myMesh, scaleM: 12, minPx: 24 },
|
|
212
|
+
label: true
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
map.objects.get('my-sat');
|
|
216
|
+
map.objects.all();
|
|
217
|
+
sat.remove();
|
|
218
|
+
map.objects.clear();
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**The map ships no model loader.** `object3d` is a three.js `Object3D` you have
|
|
222
|
+
already built or loaded — a mesh of your own, or a GLB you put through your own
|
|
223
|
+
`GLTFLoader`. That keeps a loader, its Draco and KTX2 decoders and their WASM out
|
|
224
|
+
of a bundle every reader downloads, for a feature most embeds never use, and it
|
|
225
|
+
leaves you the loader you already have rather than one this package chose for
|
|
226
|
+
you. From npm, three.js is a peer dependency: your copy is the map's copy, and
|
|
227
|
+
there is nothing to reconcile. From the CDN script the map's three.js is bundled
|
|
228
|
+
inside it and private, so a page that builds a model loads its own copy; that
|
|
229
|
+
works, since all the map does with the object is put it in a scene and place it,
|
|
230
|
+
but the package is the way to do this without two copies of three.js on the page.
|
|
231
|
+
|
|
232
|
+
`scaleM` is how big the model is drawn, in metres across its longest dimension
|
|
233
|
+
— the real size, arrays and booms deployed. Left out, it is drawn at the size it
|
|
234
|
+
was built. A twelve-metre satellite is nothing at all from a planetary view, so
|
|
235
|
+
`minPx` gives it a floor in pixels: below that it is drawn bigger than life,
|
|
236
|
+
above it, true to size.
|
|
237
|
+
|
|
238
|
+
Four constructors say where an object is, and any of them can be used anywhere
|
|
239
|
+
an anchor can — a marker, a drawing, a camera pose:
|
|
240
|
+
|
|
241
|
+
```js
|
|
242
|
+
import { elements, fixed, kmToAu, samples, tle } from 'spacemap';
|
|
243
|
+
|
|
244
|
+
// Parked: on the ground, or at an offset from a body's centre.
|
|
245
|
+
fixed({ body: 'naif-499', latitude: 18.4, longitude: 77.5, altitudeKm: 0 });
|
|
246
|
+
fixed({ body: 'naif-499', offsetKm: [0, 20000, 0] });
|
|
247
|
+
|
|
248
|
+
// A list of states, read between.
|
|
249
|
+
samples({ body: 'naif-399', samples: [{ jd, km: [x, y, z] }, ...] });
|
|
250
|
+
|
|
251
|
+
// A Keplerian orbit, propagated from its epoch.
|
|
252
|
+
elements({
|
|
253
|
+
body: 'naif-399',
|
|
254
|
+
elements: {
|
|
255
|
+
a: kmToAu(6878), // semi-major axis, in AU
|
|
256
|
+
e: 0.001,
|
|
257
|
+
i: 51.6, // inclination, degrees
|
|
258
|
+
om: 247, // longitude of the ascending node
|
|
259
|
+
w: 130, // argument of pericentre
|
|
260
|
+
ma: 325, // mean anomaly at the epoch
|
|
261
|
+
n: 5658, // mean motion, degrees a day
|
|
262
|
+
epoch: 2460584.5, // Julian date
|
|
263
|
+
equatorial: true // referenced to Earth's equator, not the ecliptic
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Two lines of a NORAD element set, propagated with SGP4 round Earth.
|
|
268
|
+
tle(line1, line2);
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Offsets and states are kilometres on ecliptic J2000 axes, measured from the body
|
|
272
|
+
they name — the Sun when they name none. Orbital elements are the export's own,
|
|
273
|
+
which means the semi-major axis is in astronomical units: the one distance on
|
|
274
|
+
this surface that is not in kilometres, because that is how elements are quoted
|
|
275
|
+
everywhere the map reads them. `kmToAu` is there for that line alone. Set
|
|
276
|
+
`equatorial` when the angles are referenced to Earth's equator, as a TLE's are.
|
|
277
|
+
|
|
278
|
+
Between two states the path is a cubic through both of them, tangent to the
|
|
279
|
+
slope their neighbours imply, which is the curve a coasting object actually
|
|
280
|
+
follows — a straight line between states would cut every corner of an orbit.
|
|
281
|
+
States may be given in any order and at any spacing; they are read at their own
|
|
282
|
+
dates. **Outside the dates the states cover, the object is not drawn.** A list
|
|
283
|
+
that has run out is not evidence of where anything is, and the map would rather
|
|
284
|
+
show nothing than park a probe at its last known place. A TLE is the same the
|
|
285
|
+
other way: SGP4 propagates it as far as you ask, accuracy falling away from the
|
|
286
|
+
element set's epoch, and a date it cannot be propagated to — a decayed satellite
|
|
287
|
+
— leaves the object undrawn. Keplerian elements are defined at every date, so an
|
|
288
|
+
object on them is always somewhere.
|
|
289
|
+
|
|
290
|
+
What an object takes part in, and what it does not, is worth saying plainly. It
|
|
291
|
+
is drawn in the scene beside the bodies, so **a body in front of it hides it and
|
|
292
|
+
it hides what is behind it**, and it holds its place as the map's origin moves
|
|
293
|
+
from body to body. `label: true` writes its name beside it in the map's own
|
|
294
|
+
label style, `occludeLabel` hiding that while the object is round the far side.
|
|
295
|
+
|
|
296
|
+
It is **not** a body. `getBody` does not know it, `flyTo` cannot reach it, a
|
|
297
|
+
click does not select it — the map resolves a click through a pass over its own
|
|
298
|
+
objects, which a host object has no id in — and it draws no orbit trail of its
|
|
299
|
+
own. Those all read the published catalogue, and an object of yours is not in
|
|
300
|
+
it. What you get instead is its position, at any date you like, which is enough
|
|
301
|
+
to do the rest yourself:
|
|
302
|
+
|
|
303
|
+
```js
|
|
304
|
+
sat.positionKm(map.clock.jd); // [x, y, z] km from the body it is measured from
|
|
305
|
+
|
|
306
|
+
// Following it: its position is an anchor, so a held camera takes it as a
|
|
307
|
+
// target, and a standoff behind it as its own place.
|
|
308
|
+
const hold = map.holdCamera();
|
|
309
|
+
map.on('frame', ({ jd }) => {
|
|
310
|
+
const km = sat.positionKm(jd);
|
|
311
|
+
if (!km) return;
|
|
312
|
+
hold.set({
|
|
313
|
+
position: { body: sat.position.body, offsetKm: [km[0] + 500, km[1], km[2] + 200] },
|
|
314
|
+
target: sat.position
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// A trail: sample the trajectory and hand the points to a polyline.
|
|
319
|
+
const points = [];
|
|
320
|
+
for (let i = -60; i <= 0; i++) points.push(sat.positionKm(map.clock.jd + i / 1440));
|
|
321
|
+
map.addPolyline({ anchor: { body: 'naif-399' }, points: points.filter(Boolean), fade: true });
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
`clearDrawings()` leaves objects alone — they are not drawings — and
|
|
325
|
+
`map.objects.clear()` takes only them.
|
|
326
|
+
|
|
327
|
+
### Its own imagery on a body
|
|
328
|
+
|
|
329
|
+
A body the map already knows can wear your pictures instead of the export's:
|
|
330
|
+
|
|
331
|
+
```js
|
|
332
|
+
map.setBodyAppearance('naif-499', { surface: url, night: url, clouds: url });
|
|
333
|
+
map.setBodyAppearance('naif-499', {}); // back to the map's own
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Each is a URL the browser can load — an equirectangular map, east to the right,
|
|
337
|
+
longitude 0 in the middle, which is how every body's imagery is drawn. `night`
|
|
338
|
+
is the lights on the unlit side, `clouds` a layer over the surface whose alpha
|
|
339
|
+
is the cover; a body with neither of its own gets one built for it. The set is
|
|
340
|
+
replaced whole, so what a call leaves out goes back to the map's own picture.
|
|
341
|
+
|
|
342
|
+
**A picture given here is what the body wears at every distance.** The map picks
|
|
343
|
+
its own imagery by how much of the screen the body fills, stepping up a tier as
|
|
344
|
+
you approach; there is nothing to pick once a host has said what the body looks
|
|
345
|
+
like, so that pass stops fetching for it and, every frame, checks that what is on
|
|
346
|
+
the body is still yours — a system reload, a defocus or a lost GPU context puts
|
|
347
|
+
it straight back.
|
|
348
|
+
|
|
349
|
+
The flat map needs nothing of its own for this: its pictures are layers already,
|
|
350
|
+
and `addRasterLayer` puts one of yours over or in place of them.
|
|
351
|
+
|
|
352
|
+
### Layers
|
|
353
|
+
|
|
354
|
+
What the map draws is a set of layers, each switched by id — the kinds of
|
|
355
|
+
object first, then the chrome drawn around them:
|
|
356
|
+
|
|
357
|
+
`planets`, `dwarfPlanets`, `moons`, `asteroids`, `comets`, `spacecraft`,
|
|
358
|
+
`satellites` (the ones round Earth), `debris`, `orbits`, `labels` (the names of
|
|
359
|
+
objects), `nomenclature` (the names of places on them) and `stars` (the sky
|
|
360
|
+
behind everything).
|
|
361
|
+
|
|
362
|
+
```js
|
|
363
|
+
const map = await createMap({
|
|
364
|
+
container: '#map',
|
|
365
|
+
layers: { asteroids: false, comets: false, debris: false }
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
map.setLayerVisible('moons', false);
|
|
369
|
+
map.isLayerVisible('moons'); // false
|
|
370
|
+
map.getLayers(); // every id, so a switcher need not spell them out
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**A layer switched off in the options is never downloaded; a layer switched off
|
|
374
|
+
later is only hidden.** The two are different asks and the map answers them
|
|
375
|
+
differently on purpose. `layers` at open time is what an embed about Mars
|
|
376
|
+
wants: the belts, the comets and the thirty thousand Earth satellites are not
|
|
377
|
+
fetched at all, and the map opens on a fraction of the data. `setLayerVisible`
|
|
378
|
+
is what a reader's checkbox wants: it lands on the next frame and never asks
|
|
379
|
+
the network for anything, whichever way it is switched.
|
|
380
|
+
|
|
381
|
+
The corollary is worth saying plainly: **switching on a layer that was off at
|
|
382
|
+
open time shows nothing**, because there is nothing to show. Switch off in the
|
|
383
|
+
options what the map is not for; switch at runtime what the reader is to have a
|
|
384
|
+
say in.
|
|
385
|
+
|
|
386
|
+
Two groups are hidden rather than skipped. `planets` and `dwarfPlanets` share
|
|
387
|
+
one file with the Sun, so leaving them out saves no download. `satellites` and
|
|
388
|
+
`debris` share one file with each other, so the download is only skipped when
|
|
389
|
+
neither is wanted.
|
|
390
|
+
|
|
391
|
+
The asteroids are one layer, not five. The export files them by orbit class,
|
|
392
|
+
and those classes do not divide cleanly into the dynamical families
|
|
393
|
+
`Body.orbitClass` reports — two of them belong to no family at all — so a
|
|
394
|
+
family switch would leave objects answering to nothing. Read `orbitClass` off a
|
|
395
|
+
body to tell the families apart.
|
|
396
|
+
|
|
397
|
+
Hiding is a drawing decision and nothing else. The Sun lights the scene
|
|
398
|
+
whatever is off, `flyTo` reaches a hidden body, and `getBody` still knows it.
|
|
399
|
+
|
|
400
|
+
The flat map has layers too, of its own: the pictures wrapped round a body and
|
|
401
|
+
the lines drawn over them. Those depend on the body on screen and carry their
|
|
402
|
+
own names, so it reads them out whole:
|
|
403
|
+
|
|
404
|
+
```js
|
|
405
|
+
flat.getLayers(); // ['surface', 'clouds', 'night', 'graticule', 'nomenclature']
|
|
406
|
+
flat.layers; // the same, with a label, a kind and a credit each
|
|
407
|
+
flat.setLayerVisible('clouds', false);
|
|
408
|
+
flat.isLayerVisible('clouds');
|
|
409
|
+
flat.on('layerschange', (layers) => redraw(layers));
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## The flat map
|
|
413
|
+
|
|
414
|
+
One body's surface, drawn flat, with layers you can switch and drawings of your
|
|
415
|
+
own on top.
|
|
416
|
+
|
|
417
|
+
```js
|
|
418
|
+
const flat = await createFlatMap({
|
|
419
|
+
container: '#flat',
|
|
420
|
+
body: 'naif-399',
|
|
421
|
+
projection: 'orthographic',
|
|
422
|
+
centerLon: 10,
|
|
423
|
+
zoom: 2
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
flat.setLayerVisible('clouds', false);
|
|
427
|
+
flat.setProjection('equirectangular');
|
|
428
|
+
flat.addCircle({ at: { lon: 12.5, lat: 41.9 }, radiusDeg: 5, stroke: '#f80' });
|
|
429
|
+
flat.on('click', (at) => at && console.log(at.lon, at.lat));
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Panoramas
|
|
433
|
+
|
|
434
|
+
A rover's panorama from the inside, with arrows along its traverse. The
|
|
435
|
+
three-dimensional part is all the SDK draws; the date, the place, a list to
|
|
436
|
+
pick from or a map of the traverse are the page's to build.
|
|
437
|
+
|
|
438
|
+
```js
|
|
439
|
+
const view = await createPanorama({
|
|
440
|
+
container: '#panorama',
|
|
441
|
+
body: 'naif-499',
|
|
442
|
+
// A panorama's id, or its `time,lat,lon` key; the body's first when omitted.
|
|
443
|
+
at: 'curiosity-n_l000_0016_edr003cyltsm0078_drivem3'
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
view.getPanoramas(); // every panorama of the body, mission by mission in time order
|
|
447
|
+
view.getNeighbours(); // the previous and next one on this traverse, with bearing and distance
|
|
448
|
+
view.on('load', (entry) => console.log(entry.sol, entry.time, entry.lat, entry.lon));
|
|
449
|
+
view.on('viewchange', ({ heading, pitch, fov }) => {});
|
|
450
|
+
view.setView({ heading: 90 });
|
|
451
|
+
await view.open(view.getPanoramas()[3]);
|
|
452
|
+
await view.step('next');
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Pressing an arrow opens the panorama it points at, unless `followArrows` is
|
|
456
|
+
false: then only the `step` event fires, for a page that keeps the panorama in
|
|
457
|
+
its own URL. The `arrows` event says where each arrow landed on screen, for a
|
|
458
|
+
label beside it. `interactive: false` turns the drag, pinch, wheel and arrow
|
|
459
|
+
keys off; `arrows: false` and `setArrowsVisible` hide the arrows.
|
|
460
|
+
|
|
461
|
+
Limits keep the reader inside part of the sweep, or at one zoom. Headings run
|
|
462
|
+
clockwise from the first to the second, so `[300, 60]` is the arc across
|
|
463
|
+
north; a pair of equal values locks that axis.
|
|
464
|
+
|
|
465
|
+
```js
|
|
466
|
+
createPanorama({ container: '#panorama', body: 'naif-499', limits: { pitch: [-20, 20] } });
|
|
467
|
+
view.setLimits({ heading: [300, 60], fov: [60, 60] }); // ±60° of north, no zoom
|
|
468
|
+
view.setLimits({}); // free again
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Restricting the map
|
|
472
|
+
|
|
473
|
+
Both maps take restrictions on what the reader may do. Each gesture is a
|
|
474
|
+
handler of its own, the way Mapbox has them:
|
|
475
|
+
|
|
476
|
+
```js
|
|
477
|
+
map.scrollZoom.disable();
|
|
478
|
+
map.scrollZoom.isEnabled(); // false
|
|
479
|
+
map.dragRotate.enable();
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
The Solar System map has `dragRotate`, `scrollZoom`, `keyboard`, `bodySelect`
|
|
483
|
+
and `featureSelect`; the flat map has `dragPan` and `scrollZoom`. They can be
|
|
484
|
+
set as the map opens, either one at a time or all at once:
|
|
485
|
+
|
|
486
|
+
```js
|
|
487
|
+
createMap({ container: '#map', interactive: false }); // every gesture off
|
|
488
|
+
createMap({ container: '#map', interactions: { scrollZoom: false } }); // one
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
`limits` says how far the reader may go. On the Solar System map that is a
|
|
492
|
+
distance from the focused body, a band of it to look down from, and the objects
|
|
493
|
+
a click may focus:
|
|
494
|
+
|
|
495
|
+
```js
|
|
496
|
+
const map = await createMap({
|
|
497
|
+
container: '#map',
|
|
498
|
+
limits: {
|
|
499
|
+
minDistanceKm: 8000,
|
|
500
|
+
maxDistanceKm: 400000,
|
|
501
|
+
minLat: -40,
|
|
502
|
+
maxLat: 40,
|
|
503
|
+
minLon: -60,
|
|
504
|
+
maxLon: 60,
|
|
505
|
+
bodies: ['naif-399', 'naif-301']
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
map.setLimits({ maxDistanceKm: 1e6 }); // replaced whole, not merged
|
|
510
|
+
map.getLimits();
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
On the flat map it is a zoom range and a band the middle of the frame stays in:
|
|
514
|
+
|
|
515
|
+
```js
|
|
516
|
+
flat.setLimits({ minZoom: 2, maxZoom: 8, minLon: -30, maxLon: 30 });
|
|
517
|
+
flat.getLimits();
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
**Limits gate reader input and nothing else.** `flyTo`, `jumpTo`, `panTo`,
|
|
521
|
+
`setView` and a held camera go where they are told, outside the limits
|
|
522
|
+
included; the reader's next gesture brings the map back inside. This is a
|
|
523
|
+
deliberate departure from Mapbox, where `maxBounds` holds the map whatever
|
|
524
|
+
moved it. Restrict what the reader may reach, and drive the map yourself to
|
|
525
|
+
anywhere you like.
|
|
526
|
+
|
|
527
|
+
A longitude band may run through the antimeridian: 170 to −170 is the twenty
|
|
528
|
+
degrees across it. One edge alone leaves the other at the antimeridian.
|
|
529
|
+
|
|
530
|
+
`setLimits` replaces the whole set, so `setLimits({})` lifts the restrictions
|
|
531
|
+
again. Angles are degrees and distances kilometres, as everywhere else.
|
|
532
|
+
|
|
533
|
+
### Cooperative gestures
|
|
534
|
+
|
|
535
|
+
A map inside a page the reader scrolls past can hand the plain gestures back to
|
|
536
|
+
the page:
|
|
537
|
+
|
|
538
|
+
```js
|
|
539
|
+
createMap({ container: '#map', cooperativeGestures: true });
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
The wheel then scrolls the page unless ctrl (⌘ on a Mac) is held, and one
|
|
543
|
+
finger drags the page rather than the map — two fingers still move it. A hint
|
|
544
|
+
says so whenever the plain gesture is tried; `messages` rewords it through
|
|
545
|
+
`cooperative_wheel`, `cooperative_wheel_mac` and `cooperative_touch`. The
|
|
546
|
+
handler is `map.cooperativeGestures`, on and off like any other.
|
|
547
|
+
|
|
548
|
+
## Controls
|
|
549
|
+
|
|
550
|
+
A control is anything that builds an element when it is added:
|
|
551
|
+
|
|
552
|
+
```js
|
|
553
|
+
map.addControl(
|
|
554
|
+
{
|
|
555
|
+
onAdd() {
|
|
556
|
+
const button = document.createElement('button');
|
|
557
|
+
button.textContent = 'Home';
|
|
558
|
+
button.onclick = () => map.flyTo({ body: 'naif-399' });
|
|
559
|
+
return button;
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
'top-left'
|
|
563
|
+
);
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
Corners are `top-left`, `top-right`, `bottom-left` and `bottom-right`;
|
|
567
|
+
top-right unless the control or the caller names another. `removeControl` takes
|
|
568
|
+
one back off — except the credit line, which throws.
|
|
569
|
+
|
|
570
|
+
The panorama view takes controls the same way. The credit line is the only control the SDK ships. Zoom buttons, a layer
|
|
571
|
+
switcher or a clock are the page's to build, in its own look, from the calls
|
|
572
|
+
this document describes: `flyTo` and `jumpTo`, `getLayers` and
|
|
573
|
+
`setLayerVisible` with the `layerschange` event, and `map.clock` with the
|
|
574
|
+
`clock` event.
|
|
575
|
+
|
|
576
|
+
## Where the data comes from
|
|
577
|
+
|
|
578
|
+
Both maps read the published export. `dataUrl` and `imagesUrl` point them
|
|
579
|
+
somewhere else — your own mirror, or a local copy while you develop. They are
|
|
580
|
+
page-wide: the last map created sets them, and data already fetched keeps the
|
|
581
|
+
origin it came from.
|
|
582
|
+
|
|
583
|
+
`locale` picks localized names; `messages` replaces the English wording the map
|
|
584
|
+
renders itself, one key at a time.
|
|
585
|
+
|
|
586
|
+
## Finishing with a map
|
|
587
|
+
|
|
588
|
+
```js
|
|
589
|
+
map.remove();
|
|
590
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spacemap",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The map of the Solar System from spacemap.co, on your website!",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"solar system",
|
|
7
|
+
"spacecraft",
|
|
8
|
+
"orbits",
|
|
9
|
+
"map",
|
|
10
|
+
"three.js"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://spacemap.co",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/julie-dujardin/space-map/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/julie-dujardin/space-map.git",
|
|
19
|
+
"directory": "frontend"
|
|
20
|
+
},
|
|
21
|
+
"license": "MPL-2.0",
|
|
22
|
+
"author": "Julie Dujardin",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"default": "./index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"main": "index.js",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@types/three": "^0.183.0",
|
|
33
|
+
"three": "^0.183.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@types/three": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|