skydialv0.4.1 Vanilla JavaScript
  1. skydial
  2. Frameworks
  3. Vanilla JavaScript

Vanilla JavaScript

The DOM entry owns only the element you supply. It returns update and destroy methods; destroying is idempotent. A container cannot be mounted twice until its previous instance is destroyed. Keep this API on the client, after the element exists.

A real 3D celestial website widget loads here. Positions, illumination and rotation are computed from the selected moment. Exact date and time controls remain available without WebGL.

The code for what is on screen

import { mountCelestial } from 'skydial/dom'
import 'skydial/style.css'

const widget = mountCelestial(element, 'widget', { kind: 'earth', size: 'small' })
widget.update({ kind: 'moon', size: 'medium' })
// When removing the host element:
widget.destroy()

Update replaces the props object while retaining unchanged component state. Use controlled date values to change the moment after mount; defaultDate only establishes initial state. Renderer peers are required here too. For direct Three.js scenes without React, use the separate three entry.