cobejs
它能做什么
这个技能指导 AI 智能体使用 cobe 库在网站中加入一个紧凑的三维地球。适合需要带标记的装饰性地球的首屏或关于页面,而无需沉重的三维工具包。
适用场景
- ✓当首屏或关于页面需要一个带位置标记的旋转地球时。
- ✓当你只想要一个小型地球,而不是完整的三维工具包时。
- ✓当地球仅用于装饰,但仍需响应交互时。
技能链接
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/cobejs/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我在关于页面加一个小型旋转地球,上面标出我们三个城市的办公室位置。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会设置画布,根据屏幕调整大小,并用标记的坐标和颜色创建地球。它还会处理尺寸变化,在手机上限制像素密度,并可以暂停或移除地球。
技术内容(原始 SKILL.md)
作者在 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,heightphi,theta(rotation angles)scale,dark,diffusebaseColor,markerColor,glowColormarkers: [{ location: [lat, lon], size, color? }]
- Lifecycle:
globe.toggle()pauses RAFglobe.destroy()removes instance
Common pitfalls
- Canvas sizing mismatch
- Set CSS size AND set canvas
width/heightscaled for DPR.
- Set CSS size AND set canvas
- 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)?
常见问题
它需要 React 吗?
不需要,但该技能包含在 React 和 Next.js 中使用的说明。
标记是什么?
按纬度和经度放置的点,每个点都可以设置大小,并可选颜色。
为什么画布尺寸很重要?
该技能提醒,画布尺寸必须与屏幕的像素比例匹配,因此需要同时设置屏幕显示尺寸和绘制尺寸。
详情
作者的原始描述
Use when adding a lightweight interactive globe with cobe (canvas setup, markers, interaction, performance, integration with React/Next.js).
repo: MengTo/Skills
热度
- GitHub 星标
- 7.2k
- 排名
- #13413
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
3d-cloth-material
7.2k帮你的智能体在 Three.js 中制作逼真的编织织物,包括纱线编织纹理、柔和光泽、自然褶皱、下摆和缝线。
3d-falling-leaves
7.2k帮你的智能体在 3D 场景中添加逼真的飘落树叶,树叶会翻滚、随风飘动,并在镜头移动时循环利用。
3d-four-seasons
7.2k帮你的智能体为 3D 场景添加春夏秋冬四季效果,无需重建场景即可改变植被、光线、天空和积雪。
3d-high-poly-models
7.2k帮你的智能体构建形状平滑、边缘可信的精细 3D 模型,然后制作在网页上运行流畅的轻量版本。