Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pkg-pr-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
run: pnpm build

- name: Publish preview
run: pnpx pkg-pr-new publish --compact
run: pnpx pkg-pr-new publish --compact --template ./demo
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
dist
types
node_modules
demo/node_modules
packed/
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
3. [Components](#components)
- [Canvas](#canvas)
- [T](#t)
- [createEntity](#createentity)
- [Entity](#entity)
- [Portal](#portal)
- [Resource](#resource)
Expand Down Expand Up @@ -312,6 +313,22 @@ const T = createT({ Mesh, BoxGeometry, MeshBasicMaterial })
- **In Libraries**: create multiple `T` to allow for treeshaking or use [`<Entity/>`](#entity) instead
- **Multiple Ts**: Create multiple T instances for lazy loading different parts of three.js

#### createEntity

`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:

```tsx
import { createEntity } from "solid-three"
import { Mesh } from "three"

const MeshComponent = createEntity(Mesh)

// Equivalent to <T.Mesh /> but without the full namespace
<MeshComponent position={[0, 1, 0]}>
...
</MeshComponent>
```

### Portal

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.
Expand Down Expand Up @@ -390,7 +407,24 @@ Wrapper-component around ['useLoader'](#useloader).

### useThree

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.
Provides access to the `three.js` context, including the renderer, scene, camera, and more.

**Signatures:**

```tsx
// Returns the full context object directly
useThree(): Context

// Returns a reactive accessor for a derived value
useThree<T>(callback: (value: Context) => T): Accessor<T>
```

Use the selector form to derive a specific value reactively:

```tsx
const camera = useThree(ctx => ctx.camera)
// camera() is an Accessor<Camera>
```

**Returns:**

Expand Down Expand Up @@ -485,7 +519,7 @@ useFrame(
priority?: number
stage?: "before" | "after"
}
)
): () => void
```

</details>
Expand Down
4 changes: 4 additions & 0 deletions demo/.stackblitzrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"installCommand": "pnpm install",
"startCommand": "pnpm run dev"
}
16 changes: 16 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>solid-three</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="root"></div>
<script src="./src/main.tsx" type="module"></script>
</body>
</html>
Loading
Loading