You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- **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
+
constMeshComponent=createEntity(Mesh)
325
+
326
+
// Equivalent to <T.Mesh /> but without the full namespace
327
+
<MeshComponentposition={[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
Use the selector form to derive a specific value reactively:
423
+
424
+
```tsx
425
+
constcamera=useThree(ctx=>ctx.camera)
426
+
// camera() is an Accessor<Camera>
427
+
```
394
428
395
429
**Returns:**
396
430
@@ -413,7 +447,7 @@ Provides access to the `three.js` context, including the renderer, scene, camera
413
447
`solid-three` implements a stack-based system for managing its current camera and raycaster:
414
448
415
449
- **Stack-based Management**: Both cameras and raycasters are managed as stacks internally
416
-
- **Default at Tail**: The `defaultCamera` and `defaultRaycaster` from Canvas props form the tail of their respective stacks
450
+
- **Default at Tail**: The `camera` and `raycaster` from Canvas props form the tail of their respective stacks
417
451
- **Current Active Camera at Head**: The camera/raycaster at the top of the stack is the currently active camera/raycaster
418
452
- **Push To The Stack To Become Active**: By calling `setCamera(camera)` and `setRaycaster(raycaster)`, the camera/raycaster is pushed to the stack. This causes it to become the currently active camera/raycaster
419
453
- **Pop From The Stack To Deactivate**: `setCamera(camera)` and `setRaycaster(raycaster)` return a cleanup-function to pop the camera/raycaster from the stack. If the camera/raycaster was on top of the stack, the previous camera/raycaster in the stack becomes active again
@@ -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>
@@ -745,7 +779,7 @@ const App = () => {
745
779
const raycaster =newCursorRaycaster()
746
780
747
781
// CursorRaycaster is used by default, but you can explicitly set it:
748
-
return <CanvasdefaultRaycaster={raycaster}>{/* Your scene */}</Canvas>
782
+
return <Canvasraycaster={raycaster}>{/* Your scene */}</Canvas>
749
783
}
750
784
```
751
785
@@ -760,7 +794,7 @@ import { CenterRaycaster } from "solid-three"
760
794
constApp= () => {
761
795
const raycaster =newCenterRaycaster()
762
796
763
-
return <CanvasdefaultRaycaster={raycaster}>>{/* Your scene */}</Canvas>
797
+
return <Canvasraycaster={raycaster}>>{/* Your scene */}</Canvas>
0 commit comments