Skip to content

Commit 4fe9e16

Browse files
authored
Merge pull request #50 from bigmistqke/next
fix: canvas-level onClick/onClickMissed not firing The fix is working, and `clickMissed` events fire appropriately.
2 parents dade8a4 + 6a9f2d6 commit 4fe9e16

24 files changed

Lines changed: 3258 additions & 24 deletions

.github/workflows/pkg-pr-new.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
run: pnpm build
3737

3838
- name: Publish preview
39-
run: pnpx pkg-pr-new publish --compact
39+
run: pnpx pkg-pr-new publish --compact --template ./demo

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
dist
33
types
44
node_modules
5+
demo/node_modules
56
packed/

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>

demo/.stackblitzrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"installCommand": "pnpm install",
3+
"startCommand": "pnpm run dev"
4+
}

demo/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>solid-three</title>
7+
<style>
8+
* { margin: 0; padding: 0; box-sizing: border-box; }
9+
html, body, #root { width: 100%; height: 100%; }
10+
</style>
11+
</head>
12+
<body>
13+
<div id="root"></div>
14+
<script src="./src/main.tsx" type="module"></script>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)