Threejs Impl React Three Fiberのロゴ

Threejs Impl React Three Fiber

組織
Impertio-Studio
threejs-impl-react-three-fiber

Use when building 3D scenes with React using React Three Fiber (R3F). Prevents the common mistake of mixing imperative Three.js code with R3F's declarative model, creating objects inside useFrame, or forgetting Suspense for loaders. Covers Canvas, useFrame, useThree, useLoader, JSX mapping, event system, performance patterns. Keywords: React Three Fiber, R3F, Canvas, useFrame, useThree, useLoader, @react-three/fiber, 3D React, declarative Three.js, use Three.js with React, JSX 3D components.

概要

公開者Impertio-Studio
リポジトリThree.js-Claude-Skill-Package
スキル名threejs-impl-react-three-fiber
スター
29
フォーク
3
同梱ファイル
3
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 3個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    Impertio-StudioがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルThreejs Impl React Three FiberをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Impertio-Studio/Three.js-Claude-Skill-Package/tree/master/skills/source/threejs-impl/threejs-impl-react-three-fiber
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Impertio-Studio/Three.js-Claude-Skill-Package.git /tmp/Three.js-Claude-Skill-Package
mkdir -p .claude/skills
cp -r /tmp/Three.js-Claude-Skill-Package/skills/source/threejs-impl/threejs-impl-react-three-fiber .claude/skills/threejs-impl-react-three-fiber
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでThreejs Impl React Three Fiberを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にThreejs Impl React Three Fiberを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Threejs Impl React Three Fiberは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

threejs-impl-react-three-fiber

Quick Reference

Canvas Component Props

PropTypeDefaultPurpose
glRenderer props | (canvas) => Renderer{}WebGL renderer config or factory
cameraCamera props | THREE.Camera{ fov: 75, near: 0.1, far: 1000, position: [0,0,5] }Default camera
sceneScene props | THREE.Scene{}Scene configuration
shadowsboolean | ShadowMapTypefalseEnable shadow maps
raycasterRaycaster props{}Raycaster configuration
frameloop"always" | "demand" | "never""always"Render loop strategy
resizeResizeOptions{ scroll: true, debounce: { scroll: 50, resize: 0 } }Resize behavior
orthographicbooleanfalseUse OrthographicCamera
dprnumber | [min, max][1, 2]Device pixel ratio
linearbooleanfalseLinear color space
flatbooleanfalseDisable tone mapping
legacybooleanfalseDisable color management
eventsEventManagerR3F defaultCustom event manager
eventSourceHTMLElement | React.RefObjectParent nodeEvent capture element
eventPrefixstring"offset"Coordinate prefix
onCreated(state: RootState) => void--Post-init callback
onPointerMissed(event: PointerEvent) => void--Click misses all meshes
fallbackReact.ReactNode--DOM fallback during init

Frameloop Modes

ModeBehavior
"always"ALWAYS renders every frame via requestAnimationFrame
"demand"ONLY renders when invalidate() is called -- use for static scenes
"never"NEVER renders automatically -- caller MUST invoke advance(timestamp)

Critical Warnings

NEVER create Three.js objects inside useFrame -- this allocates memory every frame and causes GC pressure. ALWAYS create objects outside the callback or use useMemo.

NEVER forget <Suspense> when using useLoader -- the component WILL suspend and crash without a Suspense boundary.

NEVER add the same Three.js object instance to the scene tree multiple times via <primitive> -- Three.js objects can only have one parent.

NEVER use useThree() without a selector when you only need one property -- the full state object triggers re-renders on every frame. ALWAYS use useThree((s) => s.camera).

NEVER mix imperative scene.add() calls with R3F's declarative JSX tree -- R3F manages the scene graph and imperative mutations cause desync.

ALWAYS use delta from useFrame for animations -- hardcoded time steps cause speed variations across different frame rates.

ALWAYS use useMemo for imperatively created geometries and materials -- without it, new objects are allocated on every render.


JSX-to-Three.js Mapping Rules

R3F uses deterministic conventions to translate JSX into Three.js scene graph operations:

  1. Lowercase JSX = Three.js class. <mesh /> creates new THREE.Mesh(). <meshStandardMaterial /> creates new THREE.MeshStandardMaterial().

  2. args = constructor arguments (array). <sphereGeometry args={[1, 32, 32]} /> becomes new THREE.SphereGeometry(1, 32, 32). When args changes, the object is destroyed and recreated.

  3. attach = parent property binding. <meshStandardMaterial attach="material" /> sets parent.material = this. Geometries auto-attach to "geometry", materials to "material".

  4. Dash-notation attach for nested paths. attach="shadow-camera" sets parent.shadow.camera = this. Array indexing: attach="material-0".

  5. Functional attach. attach={(parent, self) => { parent.add(self); return () => parent.remove(self); }} for custom bind/unbind.

  6. Properties with .set() accept shorthand. position={[1, 2, 3]} calls object.position.set(1, 2, 3). color="hotpink" calls object.color.set("hotpink").

  7. Scalar shorthand. scale={2} calls object.scale.setScalar(2).

  8. Dash-case pierces nested properties. rotation-x={Math.PI} sets object.rotation.x = Math.PI.


Hooks

useFrame

typescript
useFrame((state: RootState, delta: number, xrFrame?: XRFrame) => void, priority?: number)

Subscribes a callback to the render loop. Executes every frame.

State object key properties:

PropertyTypeDescription
glTHREE.WebGLRendererThe renderer
sceneTHREE.SceneThe scene
cameraTHREE.CameraActive camera
clockTHREE.ClockSystem clock
pointerTHREE.Vector2Normalized pointer (-1 to +1)
size{ width, height, top, left }Canvas dimensions (px)
viewport{ width, height, factor, distance, aspect }Camera-relative metrics
invalidate() => voidRequest render in demand mode
advance(timestamp: number) => voidAdvance one tick in never mode
performance{ current, min, max, regress() }Adaptive performance
set(state) => voidMutate state directly
get() => RootStateRead state non-reactively

Priority system: Callbacks execute in ascending priority order. When ANY callback has priority > 0, R3F disables automatic renderer.render(). The highest-priority subscriber MUST call state.gl.render(state.scene, state.camera) manually. Negative priorities do NOT disable auto-rendering.

useThree

typescript
const state = useThree()                              // full state (re-renders often)
const camera = useThree((state) => state.camera)      // selector (re-renders only on change)

Returns the RootState (same object as useFrame's state). ALWAYS use a selector when only one property is needed.

useLoader

typescript
const result = useLoader(LoaderClass, url, extensions?, onProgress?)
const results = useLoader(LoaderClass, [url1, url2], extensions?)

Suspense-based asset loading. ALWAYS wrap in <Suspense fallback={...}>.

  • Assets are cached by URL -- loading the same URL twice returns the cached result.
  • useLoader.preload(LoaderClass, url) preloads before component mount.
  • GLTF results include { nodes, materials, scene, animations }.

useGraph

typescript
const { nodes, materials } = useGraph(object3D)

Traverses an Object3D hierarchy and returns memoized { nodes, materials } collections keyed by name.


Primitives and extend()

Primitives

Insert pre-existing Three.js objects into the declarative tree:

jsx
<primitive object={existingMesh} position={[10, 0, 0]} />
  • NEVER add the same object instance multiple times -- Three.js objects can have only one parent.
  • Primitives do NOT auto-dispose; the caller MUST manage lifecycle.

extend()

Register custom Three.js classes as JSX elements:

jsx
import { extend } from '@react-three/fiber'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'

extend({ OrbitControls })
// Now usable as <orbitControls args={[camera, domElement]} />

The JSX element name is the camelCase version of the registered key.


Event System

R3F implements pointer events via raycasting. Events bubble through the scene graph.

Supported Events

EventTrigger
onClickPointer click on mesh
onContextMenuRight-click / context menu
onDoubleClickDouble click
onPointerUpPointer released
onPointerDownPointer pressed
onPointerOverPointer enters mesh (fires continuously)
onPointerOutPointer leaves mesh
onPointerEnterPointer enters mesh (fires once)
onPointerLeavePointer leaves mesh (fires once)
onPointerMovePointer moves over mesh
onPointerMissedClick hits no mesh (Canvas-level)
onWheelScroll wheel
onUpdateObject receives new props

Event Object Properties

PropertyTypeDescription
objectTHREE.Object3DThe mesh actually hit
eventObjectTHREE.Object3DObject with the event handler
pointTHREE.Vector3Intersection in world space
distancenumberCamera-to-intersection distance
uvTHREE.Vector2UV coordinates at intersection
faceTHREE.FaceIntersected face
rayTHREE.RayRay used for intersection
cameraTHREE.CameraActive camera
intersectionsIntersection[]All intersected objects
deltanumberPixel distance down-to-up
sourceEventEventOriginal DOM event
stopPropagation()functionPrevent bubbling to occluded objects

Performance Patterns

Disposal

  • R3F ALWAYS calls dispose() on Three.js objects when components unmount, freeing GPU resources.
  • Set dispose={null} on an element to PREVENT auto-disposal -- use when objects are shared across components.

Static Scenes

Use frameloop="demand" with invalidate() for scenes that do not animate continuously (dashboards, configurators). This saves GPU cycles.

Portals

jsx
import { createPortal } from '@react-three/fiber'

createPortal(children, targetScene)

Renders children into a different scene/layer without affecting the main scene graph.

useMemo for Imperative Objects

ALWAYS wrap imperatively created geometries and materials in useMemo:

jsx
const geometry = useMemo(() => new THREE.TorusKnotGeometry(1, 0.3, 128, 32), [])

Without useMemo, a new object is created on every render.


Reference Links

Official Sources

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Threejs Impl React Three Fiber」では何ができますか?

Use when building 3D scenes with React using React Three Fiber (R3F). Prevents the common mistake of mixing imperative Three.js code with R3F's declarative model, creating objects inside useFrame, or forgetting Suspense for loaders. Covers Canvas, useFrame, useThree, useLoader, JSX mapping, event system, performance patterns. Keywords: React Three Fiber, R3F, Canvas, useFrame, useThree, useLoader, @react-three/fiber, 3D React, declarative Three.js, use Three.js with React, JSX 3D components.

TypingMindでThreejs Impl React Three Fiberを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Threejs Impl React Three Fiberはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにThreejs Impl React Three Fiberをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Impertio-Studio/Three.js-Claude-Skill-Package/tree/master/skills/source/threejs-impl/threejs-impl-react-three-fiberを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Threejs Impl React Three Fiberを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Threejs Impl React Three Fiberは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもThreejs Impl React Three Fiberを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Threejs Impl React Three Fiber」は無料ですか?

はい。Impertio-StudioがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇