
Cobe.js
Skill用轻量 WebGL 库 cobe 在首页或关于页加入可旋转的地球,讲解画布按设备像素比设置尺寸、位置标记、旋转动画、窗口缩放后重建与销毁,可在 React/Next.js 中集成。
name: cobejs
description: Use when adding a lightweight interactive globe with cobe (canvas setup, markers, interaction, performance, integration with React/Next.js).
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)?
相關資源

WebGL Components
Skill在产品界面里嵌入小型常驻 WebGL 视觉元素(头像、光球、玻璃与彩虹质感、动态纹理)时的工程要点:全页共享一个 WebGL 上下文、统一帧循环并限帧、控制片元着色器开销、处理上下文丢失、始终提供非 WebGL 的降级样式,以及 React 服务端渲染下的写法。
flornkm/skills114
Page Transition Animation
Skill在 Next.js App Router 里实现页面切换动画,并解决 Framer Motion 的 AnimatePresence 退出动画在路由跳转时不触发的问题:用 template.tsx、按路径设置 key 的 AnimatePresence 加 FrozenRouter,或改用 View Transitions API(原生或 next-view-transitions)。
iart-ai/web-animation-skills45
Three.js
Skill用 Three.js 构建或调试网页 3D 场景:场景、相机、渲染器、光照与材质,GLTF 加载与控制器,以及限制设备像素比、处理窗口缩放、释放 WebGL 资源等性能要点,减少动态效果时只渲染静帧。
MengTo/Skills6.8k
GSAP
Skill用 GSAP 编写或调试网页动画:补间、时间线与位置参数、缓动、错峰,以及 ScrollTrigger 的固定与滚动联动;说明优先动 transform、在 React 中用 gsap.context() 清理、图片加载后刷新等常见问题。
MengTo/Skills6.8k
WebGL Landing Steering
Skill在制作以 WebGL 为主视觉的落地页前先定方向:按品牌调性与页面类型在四种视觉路线中选一种,过信息、性能、无障碍、稳定性四道关,先做静态降级再增强,输出推荐路线、视觉规格、技术栈与构建顺序。
MengTo/Skills6.8k
Lottie Animation
Skill把 After Effects 导出的 Lottie 动画接入网页、iOS、Android 与 React Native:优先用 dotLottie 运行时,控制播放、片段与速度,做滚动或悬停驱动的交互,运行时换色,并附 AE 导出检查清单。
iart-ai/web-animation-skills45