デバッグ

Starter pack

3Dグラフィックスでは、シーンで何が起こっているのかを理解するのが難しい場合があります。3Dの世界を2Dの画面で見ていることを忘れないでください。

カメラやオブジェクトの異なる設定に基づいて、シーンはさまざまな方法でレンダリングされる可能性があります。

シーンのデバッグを助けるために、threejsr3f はいくつかのツールを提供しています。

ヘルパー

ヘルパーは、非表示のオプションを視覚化するのに役立つコンポーネントです。

AxesHelper

axesHelper は、シーン内の X, Y および Z 軸を表示します。

カメラやオブジェクトを移動・回転させ始めるときに非常に有用です。

これは three パッケージから来ているので、次のようにインスタンス化できます:

<Canvas>
  <axesHelper />
  {/* ... */}

これにより、シーン内の軸の視覚的表現が得られます:

Axes helper

GridHelper

gridHelperは、シーンにグリッドを表示します。

<gridHelper args={[10, 10, "green", "blue"]} />

シーンにグリッドが表示されます。

Grid helper

他の3Dオブジェクトと同様に、移動、スケール、および回転が可能です

Grid

R3Fには独自のgridコンポーネントもあります。

これはグリッドにフェード効果を追加する能力やセクションやセルのサイズを選ぶなどのgridHelperよりも多くのオプションを提供します。

<Grid
  sectionSize={3}
  sectionColor={"purple"}
  sectionThickness={1}
  cellSize={1}
  cellColor={"#6f6f6f"}
  cellThickness={0.6}
  infiniteGrid
  fadeDistance={50}
  fadeStrength={5}
/>

シーンにフェードするグリッドが表示されます:

Grid

BoxHelper

The boxHelperは、オブジェクトの周りにボックスを表示します。

Three.js logoReact logo

React Three Fiber: The Ultimate Guide to 3D Web Development

✨ You have reached the end of the preview ✨

Go to the next level with Three.js and React Three Fiber!

Get full access to this lesson and the complete course when you enroll:

  • 🔓 Full lesson videos with no limits
  • 💻 Access to the final source code
  • 🎓 Course progress tracking & completion
  • 💬 Invite to our private Discord community
Unlock the Full Course – Just $85

One-time payment. Lifetime updates included.