一键导入
r3f-3d-optimization
Guidelines and production-ready patterns for maximizing performance and avoiding UI freezes in React Three Fiber (R3F) and Three.js scenes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guidelines and production-ready patterns for maximizing performance and avoiding UI freezes in React Three Fiber (R3F) and Three.js scenes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Firecrawl CLI gives AI agents and apps fast, reliable web context with strong search, scraping, and interaction tools. One install command sets up three skill segments: live CLI tools, app-integration build skills, and outcome-focused workflow skills. Route the reader to the right usage path after install.
Deploy, configure, and scale serverless workers, static applications, and integrations on Cloudflare. Specializes in Wrangler-based automation, Accountless/Temporary deployments (using wrangler deploy --temporary), and Binding resources. Use this skill in the following scenarios: * Serverless Deployment: When designing, scaffolding, or deploying Cloudflare Workers or Cloudflare Pages. * Accountless Testing: When performing frictionless testing or instant production previews without pre-configuring accounts or secrets. * Binding and Resources Integration: When binding D1 Databases, KV Stores, R2 Storage Buckets, or Hyperdrive to serverless handlers. * Configuration Tuning: When crafting, optimizing, or debugging wrangler.toml configurations.
Interacting with the Framer Agent workspace (@framer/agent), inspecting canvas status, applying design and page hierarchy modifications using Framer DSL commands, and deploying/publishing page layouts safely.
Manage version control and coordinate with remote repositories using the pre-installed Git binary. This skill covers repository initialization, remote management, branching strategies, and handling authentication in a headless environment. Use this skill in the following scenarios: * Repository Setup: When initializing new repositories or connecting to existing remotes. * Version Control Workflow: For staging changes, committing, and pushing/pulling from remote origins. * Remote Management: Configuring and verifying remote URLs. * Headless Automation: Performing Git operations within automated scripts and pipelines.
The advanced multi-agent orchestrator system to handle complex tasks by decomposing them into highly focused sequential worker agents (parallel read, sequential write) followed by a comprehensive Quality Assurance / Auditor review.
Debugging and repairing Vite import-analysis errors, missing package entrypoints, and corrupted node_modules installations.
| name | r3f-3d-optimization |
| description | Guidelines and production-ready patterns for maximizing performance and avoiding UI freezes in React Three Fiber (R3F) and Three.js scenes. |
This skill provides verified, highly effective optimization techniques for rendering interactive 3D WebGL scenes smoothly on both desktop and mobile web devices without blocking the main rendering thread.
Loading environment maps (HDRs) at startup can freeze the UI while the GPU compiles Prefiltered Mipmapped Radiance Environment Maps (PMREM). To prevent this, use a progressive loader that waits for the initial flat DOM/UI frame cycles to stabilize, then schedules mounting using requestIdleCallback.
import React, { useRef, useState } from 'react';
import { useFrame } from '@react-three/fiber';
import { Environment, useEnvironment } from '@react-three/drei';
// Preload the environment texture early at module initialization
useEnvironment.preload({ preset: 'city' });
const ProgressiveEnvironment: React.FC = () => {
const [shouldMount, setShouldMount] = useState(false);
const frameCountRef = useRef(0);
useFrame(() => {
if (frameCountRef.current < 2) {
frameCountRef.current++;
if (frameCountRef.current === 2) {
if (typeof window !== 'undefined' && 'requestIdleCallback' in window) {
(window as any).requestIdleCallback(() => {
setShouldMount(true);
}, { timeout: 1000 });
} else {
// Fallback for browsers that don't support requestIdleCallback
setTimeout(() => {
setShouldMount(true);
}, 200);
}
}
}
});
return shouldMount ? <Environment preset="city" resolution={128} /> : null;
};
By default, WebGL leverages multi-sample anti-aliasing (MSAA), which is computationally heavy on mobile devices. Replacing MSAA with a post-processing SMAA (Subpixel Morphological Anti-Aliasing) pass provides sharp lines and UI edges at a fraction of the performance cost.
npm install @react-three/postprocessing postprocessing
<Canvas gl={{ antialias: false }}><EffectComposer> containing <SMAA>:import { Canvas } from '@react-three/fiber';
import { EffectComposer, SMAA } from '@react-three/postprocessing';
import { SMAAPreset } from 'postprocessing';
export const OptimalCanvas = ({ children }) => (
<Canvas
gl={{ antialias: false, powerPreference: 'high-performance' }}
dpr={[1, 1.5]} // Cap DPR at 1.5x on high-density screens
>
{children}
<EffectComposer>
<SMAA preset={SMAAPreset.HIGH} />
</EffectComposer>
</Canvas>
);
High-resolution shadow maps are one of the most common causes of low frame rates. Always scale maps proportionally to the scene requirements.
shadow-mapSize={[2048, 2048]}shadow-mapSize={[512, 512]} paired with a soft filter like PCFShadowMap.<spotLight
position={[5, 10, 5]}
castShadow
shadow-mapSize-width={512}
shadow-mapSize-height={512}
/>
BoxGeometry subdivisions from 16x16x16 to 8x8x8 unless high precision is strictly necessary for vertex shader deformations.MeshPhysicalMaterial:
clearcoat (clearcoat: 0.0) and clearcoatRoughness to drastically simplify specular specular reflections.roughness value (e.g., 0.08 or higher) to avoid tiny micro-facet highlights that trigger render pipeline recalculations.