Skip to content
Skillpedia
Websites & UI (frontend)7.2k · #13413

cobejs

What it does

This skill guides an AI agent in adding a compact 3D globe to a website using the cobe library. It is for hero or about pages that want a decorative globe with markers, without a heavy 3D toolkit.

When to use it

  • ✓When a hero or about page needs a spinning globe with location markers.
  • ✓When you want a small globe rather than a full 3D toolkit.
  • ✓When the globe should be decorative but still respond to interaction.

Skill link

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/cobejs/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/cobejs/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Add a small spinning globe to my about page with markers for our offices in three cities.”

5 new skills a week. 1 minute to read.

How it works

The agent sets up a canvas, sizes it for the screen, and creates the globe with marker coordinates and colors. It also handles resizing, limits the pixel density on phones and can pause or remove the globe.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

cobe.js — Lightweight WebGL Globe Skill

When to use

  • A “spinning globe” / location markers in hero or about pages
  • You want a small, focused globe lib (not full three.js)
  • Decorative + interactive (markers, rotation) with minimal setup

Key APIs/patterns

  • Core:
    • import createGlobe from "cobe"
    • const globe = createGlobe(canvas, { ...options, onRender(state) { ... } })
  • Important options (common):
    • devicePixelRatio, width, height
    • phi, theta (rotation angles)
    • scale, dark, diffuse
    • baseColor, markerColor, glowColor
    • markers: [{ location: [lat, lon], size, color? }]
  • Lifecycle:
    • globe.toggle() pauses RAF
    • globe.destroy() removes instance

Common pitfalls

  • Canvas sizing mismatch
    • Set CSS size AND set canvas width/height scaled for DPR.
  • Not updating on resize
    • Recompute width/height and recreate or update params.
  • Too high DPR on mobile
    • Clamp DPR to 1–2.

Quick recipe: responsive globe with markers

import createGlobe from "cobe";

const canvas = document.getElementById("cobe");
let phi = 0;

function setup() {
  const rect = canvas.getBoundingClientRect();
  const dpr = Math.min(window.devicePixelRatio, 2);
  canvas.width = Math.round(rect.width * dpr);
  canvas.height = Math.round(rect.height * dpr);

  const globe = createGlobe(canvas, {
    devicePixelRatio: dpr,
    width: canvas.width,
    height: canvas.height,
    phi: 0,
    theta: 0.2,
    dark: 0,
    diffuse: 1.2,
    scale: 1,
    mapSamples: 16000,
    mapBrightness: 6,
    baseColor: [0.2, 0.2, 0.25],
    glowColor: [1, 1, 1],
    markerColor: [0.8, 0.5, 1],
    markers: [{ location: [1.3521, 103.8198], size: 0.08 }],
    onRender: (state) => {
      state.phi = phi;
      phi += 0.01;
    },
  });

  return globe;
}

let globe = setup();
window.addEventListener("resize", () => {
  globe.destroy();
  globe = setup();
});

What to ask the user

  • Globe size and placement (hero, section, card)?
  • Marker locations + colors (brand-aligned)?
  • Interaction needs (drag to rotate vs. ambient spin)?
FAQ

Does it need React?

No, but the skill includes notes for using it with React and Next.js.

What are the markers?

Points placed by latitude and longitude, with a size and an optional color for each.

Why does the canvas size matter?

The skill warns that the canvas size must match the screen's pixel ratio, so both the on-screen size and the drawing size are set.

Details

Original description by the author

Use when adding a lightweight interactive globe with cobe (canvas setup, markers, interaction, performance, integration with React/Next.js).

repo: MengTo/Skills

Popularity

GitHub stars
7.2k
Ranking position
#13413
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills