@nakednous/host 0.0.4 → 0.0.6
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 +15 -5
- package/dist/index.js +466 -90
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ device streams (WebHID, Gamepad), image and video sources, a DOM label overlay a
|
|
|
6
6
|
**zero renderer**, pure vanilla DOM.
|
|
7
7
|
|
|
8
8
|
> **Status: 0.0.x.** The whole surface below is shipped. What a bridge draws (a handle's locus,
|
|
9
|
-
> a track's path, a helm's rig) lives in `
|
|
9
|
+
> a track's path, a helm's rig) lives in `webgl.tree` / `p5.tree`; the host only computes, through
|
|
10
10
|
> `@nakednous/tree`, and listens.
|
|
11
11
|
|
|
12
12
|
---
|
|
@@ -46,7 +46,7 @@ WebGL or WebGPU — it owns a canvas element's input and the frame clock, and ha
|
|
|
46
46
|
application
|
|
47
47
|
│
|
|
48
48
|
▼
|
|
49
|
-
|
|
49
|
+
webgl.tree · webgpu.tree ← bridge: the GPU, thinly
|
|
50
50
|
│
|
|
51
51
|
├── @nakednous/host ← this package: pointer, handles, tracks, helms, players, streams, media, labels, orbit
|
|
52
52
|
│ │
|
|
@@ -82,16 +82,17 @@ dependency first and an options object last, and registers with the context so
|
|
|
82
82
|
| `host.poseTrack(opts)` · `host.cameraTrack(cam, opts)` | core tracks ticked while they play; `{ handles }` builds `TrackHandles`, one handle per keyframe |
|
|
83
83
|
| `host.hid(opts)` · `host.gamepad(opts)` | rate streams — `lin[3]` / `ang[3]` in raw device units, `bind(helm)` feeds it each tick; `available`, `connected` |
|
|
84
84
|
| `host.image(url)` · `host.video(opts)` · `host.raster(draw, w, h)` | texture sources — an `ImageBitmap`, a hidden `<video>` from a file or the camera with a `ready` promise, a Canvas2D drawing |
|
|
85
|
-
| `host.
|
|
85
|
+
| `host.mesh(url, opts)` | one mesh — the arrays shape `{ position, indices, normal?, tangent?, texcoord?, color?, joints?, weights? }` with its `bounds` `{ min, max, center, diag }` beside them — from an OBJ file, a one-part glTF 2.0 file (`.glb`, `.gltf`), or any format through `{ parse: (arrayBuffer) => arrays }`; what a bridge's buffer upload takes as it is, and `size / mesh.bounds.diag` fits any file to `size`. A file of several parts rejects, naming `model`. `{ format }` when the URL does not say. **`normals`**: left out, the file's normals are kept and a mesh without any gets smooth ones; `'smooth'` always recomputes them, summed per position, so a faceted file or a texture seam smooths too; `'flat'` always recomputes them on the flattened mesh (every triangle owning its vertices: more vertices, indices counting up); `false` computes nothing. The procedure, its limits and sources are tree's `mesh` module's; glTF viewers compute flat normals for a file without any — here that is `'flat'` |
|
|
86
|
+
| `host.model(url, opts)` | a model with its structure — `{ parts: [{ name, node, skin, mesh, targets, color }], nodes: { names, parents, rest }, skins: [{ name, joints, inverseBind }], clips: [{ name, duration, channels }] }` — what a rig, morph targets or animation need. A part's `mesh` is as `host.mesh` returns it, in the part's own space; `targets` are morph deltas; nodes come parents first with a rest pose, and with `skins` and `clips` feed tree's `clipSample` · `poseBlend` · `poseWorld` · `jointPalette` as they are. Same options; `'flat'` flattens each part's morph targets with its mesh. An OBJ file is one white part under one identity node. host's own parsers: no textures, cameras, sparse accessors or compressed geometry |
|
|
86
87
|
| `host.labels` · `host.hasLabels` | the label layer, created on first access — `set(id, text, x, y, z, opts)` at a world anchor, `setScreen(id, text, sx, sy, opts)` in canvas px, `{ frame: true }` for a label that lives one frame, `tick()`; `hasLabels` probes without creating |
|
|
87
|
-
| `host.orbit(cam, opts)` | the fall-through gesture — one pointer orbits, two pan and dolly, the wheel dollies; `update()` reports whether the camera moved; the vertical sense follows the bag's projection (y-up GL, y-flipped p5) |
|
|
88
|
+
| `host.orbit(cam, opts)` | the fall-through gesture — one pointer orbits, two pan and dolly, the wheel dollies; `damping` in seconds (default 0.2; 0 exact) makes the camera trail the gesture and complete it after release; `update(dt)` reports whether the camera moved; the vertical sense follows the bag's projection (y-up GL, y-flipped p5) |
|
|
88
89
|
| `host.tick(dt)` | external-loop mode: tick the players; the caller flushes the pointer once its consumers ran |
|
|
89
90
|
| `host.register(c)` · `host.unregister(c)` · `host.dispose()` | the lifecycle |
|
|
90
91
|
|
|
91
92
|
The module-level functions behind the methods are exported too (`createView`, `createPointer`,
|
|
92
93
|
`createPlayers`, `createLoop`, `observeCanvas`, `Handle`, `PointerRouter`, `cameraHelm`,
|
|
93
94
|
`poseHelm`, `helmBasis`, `poseTrack`, `cameraTrack`, `TrackHandles`, `createHid`,
|
|
94
|
-
`createGamepad`, `decodeSpaceNavigator`, `loadImage`, `createVideo`, `raster`, `loadModel`, `createLabels`,
|
|
95
|
+
`createGamepad`, `decodeSpaceNavigator`, `loadImage`, `createVideo`, `raster`, `loadMesh`, `loadModel`, `createLabels`,
|
|
95
96
|
`createOrbit`), so an adapter can compose them on its own context.
|
|
96
97
|
|
|
97
98
|
---
|
|
@@ -154,6 +155,15 @@ npm run build # rollup → dist/index.js
|
|
|
154
155
|
|
|
155
156
|
---
|
|
156
157
|
|
|
158
|
+
## Acknowledgements
|
|
159
|
+
|
|
160
|
+
- [glTF 2.0](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html) (Khronos Group) — the format `host/gltf` reads: the GLB container, accessors and buffer views, skins, morph targets, animations.
|
|
161
|
+
- Wavefront OBJ — the format `host/obj` reads.
|
|
162
|
+
- [three.js](https://threejs.org/) — the orbit's damping follows the shape of its `OrbitControls`, made time-based.
|
|
163
|
+
- [twgl](https://twgljs.org/) — the arrays shape a model's meshes arrive in.
|
|
164
|
+
|
|
165
|
+
Both parsers are host's own; no third-party code ships in the package.
|
|
166
|
+
|
|
157
167
|
## License
|
|
158
168
|
|
|
159
169
|
AGPL-3.0-only
|