A globe: a camera and a body, inheriting from `view3d`. Nothing is
projected — the geometry stays on the sphere and the horizon does the
clipping.
Created with `board.create('globe3d', [corner, size], attributes)`.
- Source:
Members
scaleTo
Animated change of scale.
Cheaper than the projection morph and needing none of its bookkeeping:
every layer multiplies by scaleNow() while it draws, so nothing has to
be rebuilt, no point counts have to match, and layers above the surface
follow by themselves because their factor is relative.
- Source:
Methods
addGeoLayer(kind, source, styleopt, orientsopt) → {Object}
A layer of your own geometry, clipped against the horizon like the
others.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
kind |
string | "rings" for filled shapes, anything else for lines. | |
source |
function | Yields the geometry, as rings or polylines of [lon, lat] in degrees. Read again on every refresh. | |
style |
Object |
<optional> |
Curve attributes. Settings made once on the globe — `tabindex` above all — reach it too, and this overrides them. |
orients |
function |
<optional> |
The winding of each ring, +1 or -1. Read on the sphere: the planar shoelace misreads a ring at a pole or across the antimeridian, and this value is used as given. |
- Source:
Returns:
The layer: `refresh()` and `setVisible(on)`.
- Type
- Object
at(bx, by) → (nullable) {Array.<number>}
Screen point to geographic position, or null beside the globe.
Parameters:
| Name | Type | Description |
|---|---|---|
bx |
number | Board x. |
by |
number | Board y. |
- Source:
Returns:
[lon, lat] in degrees, or null where the
point misses the sphere.
- Type
- Array.<number>
centre() → {Array.<number>}
Where the camera is looking.
- Source:
Returns:
[lon, lat] in degrees, read back out of the
rotation matrix.
- Type
- Array.<number>
clearSelection() → {Object}
Empty the selection. Announces once, and only if it was not empty.
- Source:
Returns:
The globe, for chaining.
- Type
- Object
clipState() → {null}
Present so a host can be asked the same question as a map.
A sphere has no strip to clip against — the horizon does that work —
so there is no shared state to hand out.
- Source:
Returns:
Always.
- Type
- null
deselect(id) → {Object}
Take a country out of the selection. Deselecting what is not selected
changes nothing and announces nothing.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | A country id. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
destroy() → {Object}
Take the globe off the board.
Listeners outlive the element that installed them: four globes left
twenty of them behind, each answering every pointer move for something
nobody is looking at. A board that cannot take a listener back is why
the guard above exists as well.
- Source:
Returns:
The globe, for chaining.
- Type
- Object
fromGeo(lon, lat) → {Object}
Geographic position to screen; `front` says whether it faces us.
Parameters:
| Name | Type | Description |
|---|---|---|
lon |
number | Longitude in degrees. |
lat |
number | Latitude in degrees. |
- Source:
Returns:
Board position,
and whether the point faces the camera.
- Type
- Object
geoPoint3D(lonFn, latFn, styleopt) → {Object}
A JSXGraph point3d that sits on the sphere and follows two functions.
Useful where something else decides where it should be — a slider, a
clock, an animation — and the point is to be dragged or measured with
the rest of the 3D scene.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
lonFn |
function | Yields the longitude in degrees. | |
latFn |
function | Yields the latitude in degrees. | |
style |
Object |
<optional> |
Attributes for the point3d. |
- Source:
Returns:
The point3d.
- Type
- Object
lookAt(lon, lat) → {Object}
The only supported way to aim the camera. Slider.setValue clamps hard,
and updateAngleSliderBounds() picks different ranges depending on the
trackball: azimuth always [0, 2pi], elevation [-pi/2, pi/2] with the
trackball and [0, 2pi] without. A raw setView latches at 90 degrees
east, or anywhere in the southern hemisphere.
Parameters:
| Name | Type | Description |
|---|---|---|
lon |
number | Longitude to face, in degrees. |
lat |
number | Latitude, held just short of the poles. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
pixelRadius()
Screen radius of the sphere in pixels. Everything drawn on or above it
derives its sampling from this, so the resolution follows the size on
screen instead of a fixed count.
- Source:
rotateMode(mode) → {Object}
How the pointer may turn the globe.
Parameters:
| Name | Type | Description |
|---|---|---|
mode |
string | 'free' for the trackball, 'azimuth' for spinning about the axis only, 'none' to fix it. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
select(id) → {Object}
Add a country to the selection.
A tap goes through this same method, so both routes agree about what
`selectMode` means: 'single' replaces, 'multiple' accumulates. The map
had all three of the faults below, and so did this.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | A country id from the dataset. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
selectMode() → {string}
The selection mode in force.
- Source:
Returns:
'none', 'single' or 'multiple'.
- Type
- string
selected() → {Array.<string>}
The current selection.
- Source:
Returns:
Country ids, in the order they were added.
- Type
- Array.<string>
setClickTolerance(px) → {Object}
How far the pointer may travel between press and release and still
count as a tap rather than a turn of the globe.
Parameters:
| Name | Type | Description |
|---|---|---|
px |
number | Distance in pixels. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setHoverCountries(on) → {Object}
Whether moving the pointer sends countryover and countryout.
Parameters:
| Name | Type | Description |
|---|---|---|
on |
boolean | Whether to report hovering. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setLayer(name, on) → {Object}
Switch a layer on or off.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | A layer name: land, farSide, coast, countries, capitals, graticule, or one returned by addGeoLayer. |
on |
boolean | Whether to draw it. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setPicking(on) → {Object}
Whether a tap looks up which country was hit at all. With it off the
globe still reports geoclick, but neither countryclick nor the
selection.
Parameters:
| Name | Type | Description |
|---|---|---|
on |
boolean | Whether to identify countries. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setScale(f) → {Object}
Shrink the Earth so a whole orbit fits inside the world cube.
Parameters:
| Name | Type | Description |
|---|---|---|
f |
number | The new radius in world units. Zero or less is refused: negative mirrors the body through the centre and leaves `at` answering null everywhere. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setSelectMode(mode) → {Object}
How a tap builds a selection: 'none', 'single' or 'multiple'.
Parameters:
| Name | Type | Description |
|---|---|---|
mode |
string | One of the three; anything else warns and is ignored. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setSelection(ids) → {Object}
Replace the whole selection at once.
Parameters:
| Name | Type | Description |
|---|---|---|
ids |
Array.<string> | Country ids. Unknown ones are refused, and under `selectMode: single` the last one named wins. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setSmallCountries(on) → {Object}
Whether the 29 countries with no outline are drawn as stand-in circles.
Parameters:
| Name | Type | Description |
|---|---|---|
on |
boolean | Whether to draw them. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
setTrackballReset(on) → {Object}
Whether the stored pointer delta is cleared on every board update.
updateProjectionTrackball re-applies that delta each time, so an extra
update from an unrelated handler turns the globe again — several times
per pointer move, and between two layer updates within one frame.
Parameters:
| Name | Type | Description |
|---|---|---|
on |
boolean | Whether to clear it. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
showDistortion(mode) → {Object}
Show what a projection does to shape and size — on the globe, where it
does nothing, which is the point of drawing it here as well.
Parameters:
| Name | Type | Description |
|---|---|---|
mode |
string | 'tissot' or 'none'. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
showFeatures(list) → {Object}
Draw a set of named features: equator, tropics, polar circles, the
prime meridian, the date line, the nominal time zones, the terminator.
They replace whatever was shown before, so an empty list clears them.
Parameters:
| Name | Type | Description |
|---|---|---|
list |
Array.<string> | Keys of `G.features`. |
- Source:
Returns:
The globe, for chaining.
- Type
- Object
spin(speedopt) → {Object}
Turn the globe by itself, about its axis.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
speed |
number |
<optional> |
0.0045 | Radians per frame; negative turns the other way. |
- Source:
Returns:
The globe, for chaining. A running spin is stopped
first, and without a frame timer nothing is started.
- Type
- Object
stop() → {Object}
Stop a spin, leaving the globe where it is.
- Source:
Returns:
The globe, for chaining.
- Type
- Object
stopScale() → {Object}
Cut a running scale animation short, leaving the radius where it is.
- Source:
Returns:
The globe, for chaining.
- Type
- Object
tapState() → {Object}
What the tap detector has seen: counts of down, move and up, whether it
is reading pointer events or board events, and how far the last gesture
travelled.
For diagnosis. On touch devices the board's own 'up' carries no
coordinates at all, which is why there are two paths to begin with.
- Source:
Returns:
A live view of the counters.
- Type
- Object
trackballState() → {Object}
What the trackball is doing: the board mode, whether a move handler is
installed, whether the reset above is on, and the stored delta.
For diagnosis. A globe that turns twice per gesture, or not at all, is
hard to investigate from the outside.
- Source:
Returns:
A snapshot of those five values.
- Type
- Object