visuals

visuals

Viewers of records in 3D, for a page in the browser. This globe is live: turn it, select a record, and replay the last three days.

Drag to turn the Earth. Click it, then scroll to zoom.

    Sample data. The warnings and the earthquakes are made up. The land is from Natural Earth.

    Marks in a room

    A viewer puts marks on a scene: a sign at a point, a run along a surface, a link and a field. The shape of a sign tells its level.

    Drag to turn the room. The outlet behind the desk stays in view.

      Sample data. The room and each value are made up.

      A conversation and its topics

      A flat picture shows the messages of a conversation, the parts of each message and the topics of the parts. A person moves it, zooms it and gives a part its topic.

      Drag to move the picture. Scroll or pinch to zoom. Select a part, then choose its topic. One request waits on you: answer it.

      Sample data. Each message and each topic is made up.

      Put a globe in a page

      npm install @mark1russell7/visuals three
      import { GLOBE_POLAR, createGlobe, globeView } from "@mark1russell7/visuals/globe";
      import { createStage } from "@mark1russell7/visuals/three";
      
      const globe = createGlobe({
        areas: [
          { record: "storm", kind: "warning", value: "A storm warning", region },
        ],
        points: [
          { record: "city", kind: "city", value: "A city", place: { lat: 32.8, lon: -96.8 } },
        ],
      });
      
      const stage = createStage(document.querySelector("#globe"), {
        content: globe,
        theme,
        label: "The Earth with one storm warning",
        views: { earth: globeView({ lat: 35, lon: -95 }) },
        home: "earth",
        polar: GLOBE_POLAR,
        pan: false,
        onSelect: (value) => console.log(value),
      });

      Replay a history

      import { changeTimes, isLive, replayOf } from "@mark1russell7/visuals";
      import { createScrubber } from "@mark1russell7/visuals/scrubber";
      import "@mark1russell7/visuals/scrubber.css";
      
      // The value of each part of the globe is its time in the picture, in hours.
      const lives = [{ from: 6, to: 18 }, { from: 12 }];
      
      createScrubber(document.querySelector("#time"), {
        label: "Time of the picture",
        replay: replayOf({ from: 0, to: 24 }),
        times: changeTimes(lives),
        labels: [{ at: 0, text: "00:00" }, { at: 12, text: "12:00" }],
        format: (at) => `${String(Math.floor(at)).padStart(2, "0")}:00`,
        onChange: ({ at }) => {
          globe.show((part) => isLive(part.value, at));
          stage.refresh();
        },
      });

      Name the places

      import { globePoint, inSight, pointRadius } from "@mark1russell7/visuals/globe";
      import { createLabels } from "@mark1russell7/visuals/labels";
      import { createStage, stackContents } from "@mark1russell7/visuals/three";
      import "@mark1russell7/visuals/labels.css";
      
      const box = document.querySelector("#globe");
      const labels = createLabels(box, {
        labels: [
          {
            record: "city",
            at: globePoint({ lat: 32.8, lon: -96.8 }),
            text: "Dallas",
            clear: pointRadius(8),
          },
        ],
        // A place on the far side of the Earth has no name.
        visible: (point, eye) => inSight(point, eye, 1),
      });
      
      const stage = createStage(box, {
        content: stackContents([globe, labels]),
        theme,
        label: "The Earth with the name of one city",
      });

      Put marks on a scene

      import { fitView } from "@mark1russell7/visuals";
      import { createMarkers } from "@mark1russell7/visuals/markers";
      import { createStage, stackContents } from "@mark1russell7/visuals/three";
      
      const markers = createMarkers([
        {
          type: "point",
          record: "outlet-2",
          kind: "outlet",
          level: "near",
          label: "Outlet 2: 1210 W of 1440 W",
          // The point on the wall, and the direction out of the wall.
          frame: { at: { x: 2.3, y: 0.3, z: 0 }, out: { x: 0, y: 0, z: 1 } },
        },
      ]);
      
      const stage = createStage(document.querySelector("#room"), {
        // The content `room` has the solids. The marks are on top of them.
        content: stackContents([room, markers]),
        theme,
        label: "A room with one outlet",
        views: { corner: fitView({ polar: 1, azimuth: 0.7 }) },
        home: "corner",
        onHover: (mark) => console.log(mark?.label),
      });

      The README tells each option. Releases shows each version, and Status shows the open work.