web3d-webgl
Use when the user asks about Three.js, React Three Fiber (R3F), drei, GLTF/Draco/KTX2 model loading, 3D product configurators, WebGL scene performance or…
от j4flmao★ 47 звёзд на GitHub
Установить web3d-webgl в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Web3D with Three.js & React Three Fiber
Purpose
Three.js is the dominant scene-graph library for WebGL (and WebGPU through WebGPURenderer); React Three Fiber (R3F) is its React renderer. This skill produces scenes that load fast (compressed assets), render efficiently (few draw calls, capped pixel ratio, on-demand rendering) and do not leak GPU memory.
Agent Protocol
Trigger
"three.js", "threejs", "react three fiber", "r3f", "drei", "gltf", "glb", "draco", "ktx2", "3d configurator", "webgl scene slow".
Input Context
- Plain Three.js or R3F (React version: R3F v9 pairs with React 19, v8 with React 18).
- Asset types and sizes (GLB, textures), target devices (mobile?).
- Interactivity: static viewer, configurator, continuous animation.
Output Artifact
Scene setup code, asset pipeline commands, performance settings.
Response Format
Renderer: {WebGLRenderer|WebGPURenderer} DPR cap: {n}
Assets: {file -> compression (Draco/Meshopt, KTX2)}
Draw calls target: {n}
Render loop: {continuous|on-demand}
Cleanup: {dispose strategy}
Plain Three.js Setup
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
export async function createViewer(container: HTMLElement, modelUrl: string) {
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(container.clientWidth, container.clientHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace; // default since r152
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, container.clientWidth / container.clientHeight, 0.1, 100);
camera.position.set(2, 1.5, 3);
scene.add(new THREE.HemisphereLight(0xffffff, 0x444444, 1.5));
const sun = new THREE.DirectionalLight(0xffffff, 2.5);
sun.position.set(5, 10, 7);
scene.add(sun);
const draco = new DRACOLoader().setDecoderPath('/draco/');
const loader = new GLTFLoader().setDRACOLoader(draco);
const gltf = await loader.loadAsync(modelUrl);
scene.add(gltf.scene);
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
const resize = new ResizeObserver(() => {
const { clientWidth: w, clientHeight: h } = container;
camera.aspect = w / h;
camera.updateProjectionMatrix();
renderer.setSize(w, h);
});
resize.observe(container);
renderer.setAnimationLoop(() => {
controls.update();
renderer.render(scene, camera);
});
return function dispose() {
renderer.setAnimationLoop(null);
resize.disconnect();
controls.dispose();
scene.traverse((obj) => {
if (obj instanceof THREE.Mesh) {
obj.geometry.dispose();
const materials = Array.isArray(obj.material) ? obj.material : [obj.material];
for (const m of materials) {
for (const value of Object.values(m)) if (value instanceof THREE.Texture) value.dispose();
m.dispose();
}
}
});
draco.dispose();
renderer.dispose();
renderer.domElement.remove();
};
}
Lights use physically based units (r155+ default): old examples with PointLight(0xffffff, 1, 100) look far too dark; increase intensity or use directional/hemisphere/environment lighting.
React Three Fiber
import { Canvas, useFrame } from '@react-three/fiber';
import { OrbitControls, Environment, useGLTF } from '@react-three/drei';
import { Suspense, useRef } from 'react';
import type { Mesh } from 'three';
function Spinner() {
const ref = useRef<Mesh>(null);
useFrame((_, delta) => {
if (ref.current) ref.current.rotation.y += delta * 0.5; // frame-rate independent
});
return (
<mesh ref={ref}>
<boxGeometry args={[1, 1, 1]} />
<meshStandardMaterial color="hotpink" />
</mesh>
);
}
function Model({ url }: { url: string }) {
const { scene } = useGLTF(url); // Draco decoding supported via drei defaults
return <primitive object={scene} />;
}
export default function Viewer() {
return (
<div style={{ height: '100vh' }}>
<Canvas dpr={[1, 2]} camera={{ position: [2, 1.5, 3], fov: 45 }} frameloop="demand">
<Suspense fallback={null}>
<Environment preset="studio" />
<Model url="/models/chair.glb" />
<Spinner />
</Suspense>
<OrbitControls makeDefault />
</Canvas>
</div>
);
}
useGLTF.preload('/models/chair.glb');
- Never
setStateinsideuseFrame; mutate refs. frameloop="demand"renders only on changes (controls callinvalidate()); with continuous animation likeSpinneruse the default"always".- The
attach="geometry"/attach="material"props from old examples are unnecessary; children attach automatically. - R3F disposes objects it creat
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл web3d-webgl?
Use when the user asks about Three.js, React Three Fiber (R3F), drei, GLTF/Draco/KTX2 model loading, 3D product configurators, WebGL scene performance or three.js memory leaks. Produces Three.js/R3F scenes with loading, instancing, disposal and frame-loop rules. Not for raw WebGPU/WebGL pipelines (use webgpu-webgl-rendering) or game engines (use unity).
Как установить скилл web3d-webgl?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл web3d-webgl запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
slack-gif-creator
AnthropicKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
automate-this
GitHubAnalyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
from-the-other-side-vega
GitHubPatterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
plantuml-ascii
GitHubGenerate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…