Skip to content

Commit 6a9f2d6

Browse files
committed
docs: fix README API docs
- Rename defaultCamera/defaultRaycaster Canvas props to camera/raycaster - Add useThree selector overload signature - Add useFrame return type (() => void) - Add createEntity section under T
1 parent 3d0d678 commit 6a9f2d6

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
3. [Components](#components)
2121
- [Canvas](#canvas)
2222
- [T](#t)
23+
- [createEntity](#createentity)
2324
- [Entity](#entity)
2425
- [Portal](#portal)
2526
- [Resource](#resource)
@@ -312,6 +313,22 @@ const T = createT({ Mesh, BoxGeometry, MeshBasicMaterial })
312313
- **In Libraries**: create multiple `T` to allow for treeshaking or use [`<Entity/>`](#entity) instead
313314
- **Multiple Ts**: Create multiple T instances for lazy loading different parts of three.js
314315
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+
315332
### Portal
316333
317334
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).
390407
391408
### useThree
392409
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+
```
394428
395429
**Returns:**
396430
@@ -485,7 +519,7 @@ useFrame(
485519
priority?: number
486520
stage?: "before" | "after"
487521
}
488-
)
522+
): () => void
489523
```
490524
491525
</details>

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export { useFrame, useLoader, useThree } from "./hooks.ts"
66
export { useProps } from "./props.ts"
77
export * from "./raycasters.tsx"
88
export * as S3 from "./types.ts"
9-
export { autodispose, getMeta, hasMeta as hasMeta, load, meta } from "./utils.ts"
9+
export { autodispose, getMeta, hasMeta, load, meta } from "./utils.ts"

0 commit comments

Comments
 (0)