Sansar Maps · embedding
Embed the sky view
The real sky for any place and moment, drawn with WebGL 2: the atmosphere and twilight, 117,000 catalogue stars and 3.4 million deep ones, the Milky Way, the Sun, Moon and planets, deep-sky objects, satellites, constellations in 50 cultures, and information drawn in the sky. Put it in a page with an iframe, or build on the SkyView module.
The iframe: /embed.html
A bare sky view, set up entirely by URL parameters, that the page around it can drive with messages:
<iframe src="http://localhost:8080/embed.html?lat=40.71&lon=-74.01&projection=dome"
title="The sky over New York" style="width:480px;height:480px;border:0;border-radius:50%"></iframe>
| Parameter | Default | Meaning |
|---|---|---|
lat, lon, elevation | Greenwich | The observer (degrees, metres). |
time, rate, tz | now, 1 | The moment (ISO 8601 or now), its speed (1 real time, 0 paused, 3600 an hour a second), and the IANA time zone for times drawn in the sky. |
projection | stereographic | stereographic, perspective, fisheye, equirectangular, or dome (an all-sky fisheye looking straight up, with a flat horizon). |
az, alt, fov | 180, 30, 100 | Where the view looks, and its field across the smaller side (degrees). |
target, track | —, 1 | Point at sun, moon or a planet, and follow it. |
show, hide | — | Comma-separated layers to turn on or off: show=equatorialGrid,constellationArt. |
labels, constellations, grid, ground, atmosphere | — | Shortcuts: 1 or 0. |
bortle, landscape | 3, hills | Light pollution (1–9); hills, flat or none. |
twinkle, satellites, deepStars, interactive, transparent | 1, 1, 1, 1, 0 | Star twinkle; the satellite layer (elements from this server); the deep-star tiles; mouse and touch; a transparent background. |
night, nightDim | 0, 0 | Red night mode (every pixel red-only), and its dimmer (0 full red to 1 darkest). |
ar | 0 | AR mode, to lay over a camera video. |
culture | western | A sky culture: chinese, maori, norse, … |
theme | — | A URL-encoded JSON theme. |
dir, lang | — | The page’s writing direction and language, as a host app in a right-to-left language sets them. |
Messages
The parent page sends { type: 'sky:…', … } with frame.contentWindow.postMessage(message, '*'); the embed answers on the parent window. The iframe example drives all of them.
| Message | Fields | Does |
|---|---|---|
sky:set | lat, lon, elevation, timeZone, time, rate, view, animate, layers, options, theme, skyCulture, lookAt | Any of them: the observer, the moment, the view ({ az, alt, fov }, eased with animate), layers, options ({ bortle, nightMode, … }), the theme, a sky culture, or a target to turn to. |
sky:annotate | spec | Draws an annotation; replies sky:annotated { id }. |
sky:removeAnnotation | id | Removes one. |
sky:clearAnnotations | group? | Removes all, or one group. |
sky:orientation | rotation, fov?, screenAngle? | Drives the view from a device orientation (see setOrientation); rotation: null lets go. |
sky:getState | — | Replies sky:state { state }. |
From the embed: sky:ready { state } once everything has loaded, sky:select { object: { kind, id, name } | null } when the reader taps something, sky:annotation { id, annotationType, group } when an annotation is tapped, and the replies above.
frame.contentWindow.postMessage({ type: 'sky:set', time: '2026-08-12T21:30:00Z', view: { az: 45, alt: 40, fov: 90 }, animate: true }, '*');
frame.contentWindow.postMessage({ type: 'sky:annotate', spec: { type: 'pointer', target: 'saturn', text: 'Saturn' } }, '*');
addEventListener('message', (e) => { if (e.data?.type === 'sky:select') console.log(e.data.object); });
SkyView
import { SkyView } from 'http://localhost:8080/sky/skyview.js';
const sky = new SkyView(document.getElementById('sky'), {
lat: -33.87, lon: 151.21, // Sydney
time: 'now', // or a Date, milliseconds or an ISO string
az: 180, alt: 30, fov: 100,
layers: { constellationArt: true },
});
await sky.firstSky; // the first frame with stars (~1.5 s on a phone): hide a splash here
await sky.ready; // everything loaded: the full catalogue, deep-sky objects, the Milky Way
sky.on('select', (obj) => console.log(obj?.name));
The view fills its container (it adds two canvases, keeps them sized with a ResizeObserver, and makes the container position: relative if it was static). It needs WebGL 2 with float render targets, which every current desktop and phone browser has. Data load in stages, the first sky first; the modules for annotations, deep stars and constellation art load when they are first used. The canvas is focusable, labelled and keyboard-driven (arrows, + and −).
Options
| Option | Default | Meaning |
|---|---|---|
lat, lon, elevation, timeZone | Greenwich, null | The observer; the time zone for times drawn in the sky. |
time, rate | 'now', 1 | The moment and its speed. With 'now' the view follows the clock. |
projection | 'stereographic' | stereographic (natural wide angle), perspective (a camera), fisheye (to 360°), equirectangular. |
az, alt, fov, roll | 180, 28, 100, 0 | The view, in degrees; fov spans the smaller side. minFov 0.01, maxFov by projection. |
layers | see Layers | Which layers are drawn. |
bortle | 3 | Light pollution, Bortle 1 (pristine) to 9 (inner city): the sky’s brightness and how many stars show. |
landscape | 'hills' | 'hills', 'flat', 'none', or your horizon as [[azimuth, altitude], …]. |
twinkle, refraction, turbidity | true, true, 1 | Scintillation; atmospheric refraction; haze. |
starBrightness, starSize, blackPoint | 1, 1, 1 | Display tweaks; blackPoint: 0 turns off the dark-sky black point. |
interactive, keyboard | true, true | Drag, zoom, pinch, tap; arrow keys. |
autoRender, maxFps, idleFps, twinkleFps | true, 60, 30, 0 | autoRender: false draws only when you call render() (in step with a 3D engine). At rest the view draws on demand; twinkleFps (≤ 10) keeps stars twinkling on a wall display. |
satellites, satelliteGroups, apiBase | true, 'stations,visual', the module’s server | Satellites with elements from this server (/api/satellites/elements). |
nightMode, nightDim | false, 0 | Red night mode and its dimmer. |
ar, transparent, preserveDrawingBuffer | false | AR mode; a transparent canvas; keep the buffer for toDataURL. |
pixelRatio, adaptiveResolution, minPixelRatio, quality | auto, true, 0.5, 'auto' | Resolution; while frames are slow the sky canvas drops resolution (labels stay sharp); the quality governor (0–5, see getQuality()). |
deepStars, deepStarSource, deepStarBudgetMB | true, /data/deepstars/, 32 | The deep-star tiles. |
skyCulture | 'western' | The sky culture drawn. |
theme | null | A partial theme. |
yourView | null (the whole sky) | The directions the observer can see, { ranges: [[fromAz, toAz], …], minAlt } (each range clockwise, so [300, 60] runs through north); with the outsideView layer the rest of the horizon is shaded. /sky/view.js has the in-view math (inView, trackInView, passInView); plan() takes the same view and ranks what is up inside it first. |
labelDensity, locale, compassLabels, deepSkyName | 0, null | More or fewer labels (−1…1); the language of drawn times; the eight compass letters in your language; deep-sky names in your language (a function or a map). |
formatTime, hourCycle | —, the locale’s | How times in the sky read (path ticks, horizon marks): your own formatter, or 'h23' / 'h12'. |
reducedMotion | the system’s | true: no twinkle, flights become cuts, nothing pulses. |
moonTexture, starTrails, starTrailSeconds, exactFrames | 'auto', true, 2, false | The 4k Moon only when zoomed in ('full': always); star trails while time runs fast; recompute the planets every frame. |
Layers
sky.setLayers({ … }) with any of these booleans (defaults in brackets): stars (on), starNames (on), constellations (on), constellationNames (on), constellationArt (off: each culture’s figure artwork as a faint engraving), asterisms (off), boundaries (off), planets, planetNames, sun, moon (on), deepSky, deepSkyNames (on), milkyWay, zodiacalLight, atmosphere, ground, cardinals, labels (on), satellites, satelliteNames, meteorShowers (on), azimuthalGrid, equatorialGrid, ecliptic, equator, meridian, galactic, horizonLine (off), zodiac and lunarMansions (off: the culture’s zodiac band and lunar mansions; getSkyCulture() says which it has), landmarks (on: what setLandmarks gave) and outsideView (on: the horizon outside yourView shaded).
Methods
| Method | Does |
|---|---|
setLocation({ lat, lon, elevation, timeZone }) · getLocation() | Moves the observer. |
setTime(t, { rate }) · setRate(r) · getTime() | The moment ('now' follows the clock again) and its speed; getTime() → { time, rate, live }. |
setView({ az, alt, fov, roll, projection }, { animate, duration }) · getView() | Where the view looks. |
pan(dAz, dAlt, { animate }) · zoomBy(factor, { animate }) · animateTo({ az, alt, fov }, ms) | Turn, zoom (2 = twice as close), fly (eased; a cut with reduced motion). |
lookAt(target, { fov, duration, track }) | Turns to 'mars', { alt, az } or an object descriptor; returns false if it has no direction. |
pick(x, y, radius = 16) · select(obj, { center, track, fov }) | The object under a CSS pixel ({ kind, id, name, ref, … }), and selecting it (a ring, and a path for satellites); emits select. |
directionOf(ref) · limitingMagAt(enu) | An object’s apparent direction (a unit ENU vector); the faintest star visible in a direction. |
setLayers({ … }) · getLayers() · setOptions({ … }) | Layers and options (bortle, landscape, night mode, AR, deep stars, …). |
setTheme(theme) · getTheme() | The look of labels, lines and symbols (Theme). |
annotate(spec) · clearAnnotations(group?) · getAnnotations() · describeAnnotations() | Information drawn in the sky. |
setInsets({ top, right, bottom, left }) · setOccluders([{ x, y, w, h }]) | Room for your interface. |
setLandmarks([{ id, text, az, kind }]) · getLandmarks() | Names on the horizon at their azimuth, standing on the skyline (kind 'town', 'airport' or 'lake'; first in the list wins a crowded spot); the landmarks layer. /sky/landmarks.js has distanceKm, bearingDeg and pickLandmarks to choose them from /data/map/landmarks/. |
setOrientation(rotation, { fov, screenAngle }) · SkyView.arFieldOfView(opts) | Drives the view from a device orientation (a quaternion [x, y, z, w], a 3×3 matrix or device axes in ENU) with no gimbal lock; null hands it back to touch. The field matching a camera video. |
setDeepStarSource(source) · findDeepStar(id) · getDeepStarStats() | Deep stars. |
setSkyCulture(culture, { names, translate }) · getSkyCulture() | Sky cultures. |
setTexture('milkyway' | 'moon', src) | Your own Milky Way or Moon image (URL, Blob, bitmap or canvas); null restores the built-in one. |
describeView() | What is in view, for screen readers and guides (Describing the view). |
getState() | Time, location, view, layers, the Sun and Moon, the sky’s brightness (mag/arcsec²) and the naked-eye limit, the selection, night mode, AR and culture. |
sampleColor(alt, az) · renderPanorama({ width, azimuthLeft, labels, ground }) · snapshot() | The sky’s colour in a direction (sRGB 0–1); a 360°×180° panorama canvas; a PNG data URL of the view. |
getStats() · getQuality() · render() · destroy() | Frame statistics; the quality governor’s level; draw now; free the GPU. |
Events
const off = sky.on(name, fn) returns a function that removes the listener; sky.off(name, fn) does too.
| Event | Payload | When |
|---|---|---|
firstsky | { ms, sinceStart } | The first frame with stars and the horizon (also the sky.firstSky promise). |
ready | the view | Everything has loaded (also sky.ready). |
select | descriptor or null | A tap, a click or select(). |
hover | descriptor or null | The mouse over an object. |
annotation | { id, type, group, spec, x, y } | A tappable annotation was tapped. |
view · time · location · layers · theme | the new value | After each change. |
frame | the view | After each frame drawn. |
stars · satellites | { loaded, count } · the list | The full catalogue, or satellite elements, arrived. |
skyculture | { id, name } | A culture was drawn. |
quality | getQuality() | The quality governor changed level. |
Theme, night mode and AR
setTheme() deep-merges over the current theme (setTheme(null) restores the defaults). The app passes its design tokens this way, so the sky’s typography matches the interface:
sky.setTheme({
fonts: { serif: '"Sky Map Serif", Georgia, serif', sans: '"Sky Map Sans", system-ui, sans-serif' },
labels: {
constellation: { family: 'serif', size: 11, letterSpacing: 3, transform: 'uppercase', color: 'rgba(150,168,214,.64)' },
star: { family: 'serif', italic: true, size: 13, color: 'rgba(214,218,230,.92)' },
},
lines: { constellations: [0.56, 0.65, 0.87, 0.3] }, // [r, g, b, a] in 0–1
halo: { color: 'rgba(2,3,7,.66)', width: 3 },
scale: 1.3, // large text
});
Label styles: constellation, star, starDim, bayer, flamsteed, planet, sunMoon, deepSky, satellite, cardinal, cardinalMinor, grid, radiant, selection, annotation, annotationMuted, asterism, each { family, size, weight, color, letterSpacing, transform, italic, smallCaps }. Lines: constellations, boundaries, azimuthalGrid, equatorialGrid, ecliptic, equator, meridian, galactic, horizonLine, satellitePath, annotations, asterisms (with lineWidths by the same keys); symbols, halo, scale and art (the engraving ink). render/theme.js has every default.
Red night mode: setOptions({ nightMode: true, nightDim }) draws every pixel (sky, labels, annotations) with green and blue exactly 0, dimmable to about 15 %. AR mode: setOptions({ ar: true }) gives a transparent background over a camera video, with no ground, atmosphere or Milky Way, a perspective projection and labels tuned to read over video; arDistortion: { k1, k2 } matches the camera’s lens.
Annotations
sky.annotate(spec) draws information in the sky, where it belongs, and returns a handle { id, spec, update(patch), remove() }. Annotations follow the theme, fade in and out, work in every projection, turn red in night mode and, for pointers, callouts, rings, markers and horizon marks, can be tapped (the view emits annotation). The annotations example switches each on and off.
Common fields: type, id?, group? (for clearAnnotations(group)), label? (screen-reader text), color? (CSS), muted?, lineWidth?, dash? (true or [on, off]), interactive?. Targets: a body name ('mars'); a ref ({ kind: 'body' | 'star' | 'deepstar' | 'dso' | 'satellite' | 'constellation', … } from pick(), select or positions.search()); or a direction: { alt, az } (apparent), { ra, dec } (J2000, ra in hours), { raDeg, dec } or { enu: [x, y, z] }.

path — a target’s track between two moments, with hour ticks in the view’s time zone.
horizonMark — where something rises or sets, with the time.
pointer — a circle round the target; off screen, an arrow at the edge with the name and angle.
callout — a title and up to three lines beside an object, with a leader line.
ring — a highlight round a target or a screen point; it pulses unless reduced motion is on.
marker — numbered markers, as tonight’s plan numbers its targets.
fov — an eyepiece, binocular or camera field, or a Telrad, on a target or the view’s centre.
polyline — any line in the sky, in horizontal or equatorial coordinates.| Type | Fields |
|---|---|
path | target, start, end (Date, ms or ISO), ticks? ('hour', minutes or false), tickLabels? (true, false or every n-th), arrow? ('end' | 'mid' | 'none'), text?; or points: [{ alt, az, label? } | { ra, dec, label? }] for a track of your own. |
horizonMark | az, event? ('rise' | 'set'), text?, time? (written in the view’s time zone when there is no text). |
pointer | target, text? |
callout | target, title, lines? (up to 3), placement? ('auto', 'right', 'left', 'upper-right', …) |
ring | target or screen: 'center' | { x, y }, radiusDeg? or radiusPx?, pulse?, text? |
marker | target, number?, text? |
fov | kind ('eyepiece' | 'binocular' | 'camera' | 'telrad'), target? (default: the view’s centre), fovDeg (true field), width, height (camera, degrees), rotation (camera: from celestial north through east), crosshair?, text? |
polyline | points: [[az, alt], …] (frame: 'horizontal', the default) or [[raDeg, dec], …] (frame: 'equatorial') or [{ alt, az, label? } | { ra, dec, label? }], closed?, arrow?, dash? |
const dusk = Date.parse('2026-11-09T17:00:00Z'), dawn = Date.parse('2026-11-10T06:00:00Z');
sky.annotate({ type: 'path', target: 'saturn', start: dusk, end: dawn, group: 'plan' });
sky.annotate({ type: 'callout', target: 'saturn', title: 'Saturn', lines: ['39° up in the south'], group: 'plan' });
const m = sky.annotate({ type: 'marker', target: { ra: 0.7123, dec: 41.269 }, number: 1, text: 'M31', group: 'plan' });
m.update({ number: 2 }); sky.clearAnnotations('plan');
Insets and occluders
When your interface covers part of the view, setInsets({ top, right, bottom, left }) (CSS px) moves the view’s centre to the middle of what is left, with an off-axis projection so nothing is distorted: select, lookAt, flights, tracking, the AR reticle and off-screen pointers all use the uncovered part. setOccluders([{ x, y, w, h }]) lists rectangles (a clock, a dock, an open panel) that labels and callouts keep clear of; setOccluders([]) clears them. The annotations example sets both for its panel.
Deep stars
Beyond the 117,000 catalogue stars, the view streams about 3.4 million Gaia DR3 stars (to magnitude 12.5) as you zoom, from packed tile files read by HTTP range requests (tools/data/deepstars-format.md describes the SKYT1 format). setDeepStarSource(source) takes:
- a base URL (default
/data/deepstars/):index.jsonand range requests onL1.bin,L2.bin, …; { index, files: { 'L1.bin': Blob | ArrayBuffer, … }, base? }: a local pack, as the app stores for offline use (missing files come frombase);{ index, read: (file, start, endExclusive) => Promise<ArrayBuffer> }: any reader;null: no deep stars.
findDeepStar(id) finds a star by its Gaia DR3 source_id; getDeepStarStats() reports tiles, stars, requests and bytes.
The deep-star tiles are Gaia DR3 data (ESA/Gaia/DPAC) under CC BY-NC 3.0 IGO: non-commercial use only. For a commercial product, ask ESA, or pass deepStars: false or a deep-star source under another licence.
Sky cultures
await sky.setSkyCulture('maori') draws another culture’s figures and names (the IAU boundaries stay): any id in /data/skycultures/index.json (50 cultures from Stellarium, each with its own licence and authors), 'western' to go back, or a culture object of your own in the same format (tools/data/skycultures-format.md). { names: 'english' | 'native' | 'pronounce' | 'native+pronounce' } picks which name to show; { translate: (name, kind) => string } supplies your own. getSkyCulture() → { id, name, zodiac, lunarMansions }.
Describing the view
For screen readers and guides, describeView() returns the view’s direction (direction, az, alt, fov), the labelled objects drawn, most important first (objects: [{ kind, id, name, x, y }]), and the annotations on screen. The app turns it into a sentence (press V). The canvas has role="img" and a label; selections arrive as select events for you to announce.
Panoramas and 3D scenes
- A live layer: put a
SkyViewwithprojection: 'perspective', autoRender: false, interactive: falsebehind a transparent WebGL canvas, copy the 3D camera’s direction and field intosky.setView()each frame, then callsky.render(). The house example does this. - An environment map:
sky.renderPanorama({ width: 1024, azimuthLeft: 270 })returns an equirectangular canvas whose left edge is azimuth 270°, which matches three.js’sEquirectangularReflectionMappingwith north at −z.
For the lights, Sky.lighting() gives the Sun’s and Moon’s directions in three.js axes, their colours after extinction and their illuminance in lux, and sky.sampleColor(alt, az) matches fog to the horizon.