Mischief

84 / Scenes

Wireframe Globe

A wireframe world with places marked on it, arcs between them, and the same places written out underneath as text.

  • London
  • New York
  • Singapore
  • Sao Paulo
  • Bengaluru

Five regions. Drag to spin it.

Installation

Copy the source into your project, or keep it behind a package.

npx shadcn@latest add Tinkerers-Labs/mischief-ui/wireframe-globe
import { WireframeGlobe } from "mischief-ui/wireframe-globe"
Also installs
  • three

Or paste it in yourself. The source imports the shared cn helper from @/lib/utils, so point that at your own copy.

registry/default/wireframe-globe/wireframe-globe.tsx
"use client" import * as React from "react"import * as THREE from "three"import {  RenderSurface,  useThemeColors,  type SurfaceColor,} from "@/registry/default/render-surface/render-surface"import { cn } from "@/lib/utils" export type GlobeMarker = {  id?: string  lat: number

Usage

export function Regions() {
  return (
    <WireframeGlobe
      markers={[
        { id: "lhr", lat: 51.47, lng: -0.45, label: "London" },
        { id: "sin", lat: 1.36, lng: 103.99, label: "Singapore" },
      ]}
      className="aspect-square"
    />
  )
}

The list is not optional

A globe is usually showing something real: where the regions are, where the customers are, where the incident is. That information cannot live only in a canvas, so the markers are also rendered as a plain list for anything that does not read one.

This is why label is required rather than optional. A marker without a name is a dot on a sphere and there is nothing to say about it.

What it needs installed

Along with the scene hero, this is one of the two components that ask for three, and it is an optional peer. The package root does not export it, because a barrel holding it would fail to resolve for everyone who had not installed three.

npm install mischief-ui three
Import it from its own entry: mischief-ui/wireframe-globe, not the package root.

Turning it

It turns slowly on its own and can be dragged, and a drag carries a little momentum before the steady turn takes over again. Set interactive to false when the globe sits behind something else that should be receiving the pointer.

API

markersGlobeMarker[]Places to mark.
arcsGlobeArc[]Lines drawn between two places.
colorstringThe sphere. Defaults to "--border".
accentstringThe markers and arcs. Defaults to "--primary".
speednumberTurns per second. Defaults to 0.06.
interactivebooleanLets the pointer spin it. On by default.

GlobeMarker

latnumberDegrees north.
lngnumberDegrees east.
labelstringWhat the place is called. Required, and used in the text list.
idstringOptional key.

GlobeArc

from{ lat, lng }Where the line starts.
to{ lat, lng }Where it ends.

Accessibility

The canvas is decoration and the markers are a real list, so the places are read out in order whether or not anything renders. Under reduced motion one frame is drawn and the globe neither turns nor drifts, though it can still be dragged, because that movement is the reader's own.