|
20 | 20 | 3. [Components](#components) |
21 | 21 | - [Canvas](#canvas) |
22 | 22 | - [T](#t) |
| 23 | + - [createEntity](#createentity) |
23 | 24 | - [Entity](#entity) |
24 | 25 | - [Portal](#portal) |
25 | 26 | - [Resource](#resource) |
@@ -312,6 +313,22 @@ const T = createT({ Mesh, BoxGeometry, MeshBasicMaterial }) |
312 | 313 | - **In Libraries**: create multiple `T` to allow for treeshaking or use [`<Entity/>`](#entity) instead |
313 | 314 | - **Multiple Ts**: Create multiple T instances for lazy loading different parts of three.js |
314 | 315 |
|
| 316 | +#### createEntity |
| 317 | +
|
| 318 | +`createT` is built on top of `createEntity`, which creates a single typed component from one Three.js constructor. Use it directly when you need a one-off component without building a full namespace: |
| 319 | +
|
| 320 | +```tsx |
| 321 | +import { createEntity } from "solid-three" |
| 322 | +import { Mesh } from "three" |
| 323 | + |
| 324 | +const MeshComponent = createEntity(Mesh) |
| 325 | + |
| 326 | +// Equivalent to <T.Mesh /> but without the full namespace |
| 327 | +<MeshComponent position={[0, 1, 0]}> |
| 328 | + ... |
| 329 | +</MeshComponent> |
| 330 | +``` |
| 331 | +
|
315 | 332 | ### Portal |
316 | 333 |
|
317 | 334 | The `Portal` component allows you to place children outside the regular scene graph while maintaining reactive updates. This is useful for rendering objects into different scenes or bypassing the normal parent-child relationships. |
@@ -390,7 +407,24 @@ Wrapper-component around ['useLoader'](#useloader). |
390 | 407 |
|
391 | 408 | ### useThree |
392 | 409 |
|
393 | | -Provides access to the `three.js` context, including the renderer, scene, camera, and more. This hook can be used with or without a selector function for optimized access to specific properties. |
| 410 | +Provides access to the `three.js` context, including the renderer, scene, camera, and more. |
| 411 | +
|
| 412 | +**Signatures:** |
| 413 | +
|
| 414 | +```tsx |
| 415 | +// Returns the full context object directly |
| 416 | +useThree(): Context |
| 417 | + |
| 418 | +// Returns a reactive accessor for a derived value |
| 419 | +useThree<T>(callback: (value: Context) => T): Accessor<T> |
| 420 | +``` |
| 421 | +
|
| 422 | +Use the selector form to derive a specific value reactively: |
| 423 | +
|
| 424 | +```tsx |
| 425 | +const camera = useThree(ctx => ctx.camera) |
| 426 | +// camera() is an Accessor<Camera> |
| 427 | +``` |
394 | 428 |
|
395 | 429 | **Returns:** |
396 | 430 |
|
@@ -485,7 +519,7 @@ useFrame( |
485 | 519 | priority?: number |
486 | 520 | stage?: "before" | "after" |
487 | 521 | } |
488 | | -) |
| 522 | +): () => void |
489 | 523 | ``` |
490 | 524 |
|
491 | 525 | </details> |
|
0 commit comments