@glyphcss/react 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -28
- package/dist/index.cjs +480 -300
- package/dist/index.d.cts +116 -64
- package/dist/index.d.ts +116 -64
- package/dist/index.js +383 -206
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,49 +16,60 @@ Requires React 18 or 19 as a peer dependency.
|
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
GlyphCamera,
|
|
20
|
+
GlyphScene,
|
|
21
|
+
GlyphMesh,
|
|
22
|
+
GlyphOrbitControls,
|
|
23
23
|
} from "@glyphcss/react";
|
|
24
24
|
|
|
25
25
|
export function App() {
|
|
26
26
|
return (
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
</
|
|
32
|
-
</
|
|
27
|
+
<GlyphCamera rotX={0.4} zoom={0.32}>
|
|
28
|
+
<GlyphScene cols={80} rows={40}>
|
|
29
|
+
<GlyphOrbitControls />
|
|
30
|
+
<GlyphMesh src="/cottage.glb" />
|
|
31
|
+
</GlyphScene>
|
|
32
|
+
</GlyphCamera>
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## Component reference
|
|
38
38
|
|
|
39
|
-
### `<
|
|
39
|
+
### `<GlyphCamera>` / `<GlyphOrthographicCamera>`
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
Orthographic camera. `GlyphCamera` is the ergonomic default alias. Wraps
|
|
42
|
+
`<GlyphScene>` — the camera is always the outermost element.
|
|
42
43
|
|
|
43
44
|
| Prop | Type | Default | Description |
|
|
44
45
|
|---|---|---|---|
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `className` | `string` | — | CSS class on the `<pre>` container |
|
|
46
|
+
| `rotX` | `number` | `0` | Tilt in radians |
|
|
47
|
+
| `rotY` | `number` | `0` | Azimuth in radians |
|
|
48
|
+
| `zoom` | `number` | `0.4` | Mesh fraction of min(cols, rows) |
|
|
49
49
|
|
|
50
|
-
### `<
|
|
50
|
+
### `<GlyphPerspectiveCamera>`
|
|
51
51
|
|
|
52
|
-
Perspective camera.
|
|
52
|
+
Perspective (foreshortened) camera. Required for `<GlyphFirstPersonControls>`.
|
|
53
53
|
|
|
54
54
|
| Prop | Type | Default | Description |
|
|
55
55
|
|---|---|---|---|
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `zoom` | `number` | `
|
|
56
|
+
| `rotX` | `number` | `0` | Tilt in radians |
|
|
57
|
+
| `rotY` | `number` | `0` | Azimuth in radians |
|
|
58
|
+
| `distance` | `number` | `3` | Perspective distance in world units |
|
|
59
|
+
| `zoom` | `number` | `0.4` | Mesh fraction of min(cols, rows) |
|
|
60
|
+
|
|
61
|
+
### `<GlyphScene>`
|
|
62
|
+
|
|
63
|
+
Root of every React glyphcss render tree. Owns the `<pre>` output element and rasterizes all meshes on camera or state change. Must be a child of a camera component.
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| `cols` | `number` | `80` | Grid width in character cells |
|
|
68
|
+
| `rows` | `number` | `40` | Grid height in character cells |
|
|
69
|
+
| `mode` | `"wireframe" \| "solid" \| "voxel"` | `"solid"` | Render mode |
|
|
70
|
+
| `className` | `string` | — | CSS class on the `<pre>` container |
|
|
60
71
|
|
|
61
|
-
### `<
|
|
72
|
+
### `<GlyphMesh>`
|
|
62
73
|
|
|
63
74
|
Loads and displays a 3D mesh. Supports `.obj`, `.glb`, `.gltf`, `.vox`.
|
|
64
75
|
|
|
@@ -67,16 +78,16 @@ Loads and displays a 3D mesh. Supports `.obj`, `.glb`, `.gltf`, `.vox`.
|
|
|
67
78
|
| `src` | `string` | URL of the mesh file |
|
|
68
79
|
| `color` | `string` | Override mesh color |
|
|
69
80
|
|
|
70
|
-
### `<
|
|
81
|
+
### `<GlyphOrbitControls>` / `<GlyphMapControls>`
|
|
71
82
|
|
|
72
83
|
Mouse/touch/keyboard camera controls.
|
|
73
84
|
|
|
74
85
|
### Hooks
|
|
75
86
|
|
|
76
|
-
- `
|
|
77
|
-
- `
|
|
78
|
-
- `
|
|
79
|
-
- `
|
|
87
|
+
- `useGlyphCamera()` — access the camera context
|
|
88
|
+
- `useGlyphSceneContext()` — access scene state
|
|
89
|
+
- `useGlyphMesh(handle)` — mesh state and imperative API
|
|
90
|
+
- `useGlyphAnimation(clips, controller)` — three.js-style animation mixer
|
|
80
91
|
|
|
81
92
|
## License
|
|
82
93
|
|