@nakednous/host 0.0.8 → 0.0.9
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/dist/index.js +31 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -186,10 +186,11 @@ function observeCanvas(canvas, onChange) {
|
|
|
186
186
|
*
|
|
187
187
|
* - pointerdown · pointermove · pointerup · pointercancel on the canvas,
|
|
188
188
|
* keydown (Esc) on the window.
|
|
189
|
-
* - Coordinates in
|
|
190
|
-
*
|
|
191
|
-
* size read off the view bag's vp
|
|
192
|
-
* expect
|
|
189
|
+
* - Coordinates in screen space — the surface's logical pixels, top-left, y
|
|
190
|
+
* down — through the element's bounding rectangle: (clientX − rect.left) ·
|
|
191
|
+
* (width / rect.width), the logical size read off the view bag's vp. These
|
|
192
|
+
* are the numbers mapLocation(SCREEN) and vp expect (a viewport of negative
|
|
193
|
+
* height), so a CSS-scaled canvas maps correctly.
|
|
193
194
|
* - Per pointer: an entry { id, x, y, seq, down, up, cancel, owner }, kept
|
|
194
195
|
* from its press until the frame after its release; `seq` counts moves,
|
|
195
196
|
* so a consumer remembers the last seq it consumed and reads only new
|
|
@@ -787,7 +788,7 @@ class Handle {
|
|
|
787
788
|
}
|
|
788
789
|
|
|
789
790
|
// The proxy's world position and its grab radius in world units — a
|
|
790
|
-
// constant grabPx
|
|
791
|
+
// constant grabPx canvas size at the proxy's depth.
|
|
791
792
|
_proxyPrep() {
|
|
792
793
|
const c = this._constraint, v = this._view, p = this._proxyPos;
|
|
793
794
|
if (this._from && !this._grabbed) this._resolveFrame();
|
|
@@ -810,14 +811,14 @@ class Handle {
|
|
|
810
811
|
return rayHitSphere(o[0], o[1], o[2], d[0], d[1], d[2], p[0], p[1], p[2], this._proxyRad);
|
|
811
812
|
}
|
|
812
813
|
|
|
813
|
-
/** Unproject a
|
|
814
|
+
/** Unproject a screen-space pixel into the ray scratch; false on a stale view. */
|
|
814
815
|
_ray(x, y) {
|
|
815
816
|
const v = this._view;
|
|
816
817
|
if (v.stale) return false;
|
|
817
818
|
return unproject(_rayO, _rayD, x, y, v, v.vp, v.ndcZMin) !== null;
|
|
818
819
|
}
|
|
819
820
|
|
|
820
|
-
/** Hit-test the proxy at a
|
|
821
|
+
/** Hit-test the proxy at a screen-space pixel. */
|
|
821
822
|
_pickAt(x, y) {
|
|
822
823
|
return this._ray(x, y) && this._proxyT(_rayO, _rayD) < Infinity;
|
|
823
824
|
}
|
|
@@ -1207,7 +1208,7 @@ function cameraHelm(host, cam, opts) {
|
|
|
1207
1208
|
const helm = new PoseHelm();
|
|
1208
1209
|
_applyOpts(helm, opts);
|
|
1209
1210
|
if (opts && opts.from != null) {
|
|
1210
|
-
console.error('[host] cameraHelm: a camera helm is always body-fly and has no `from`. Ignoring it; bind the camera to a poseHelm for
|
|
1211
|
+
console.error('[host] cameraHelm: a camera helm is always body-fly and has no `from`. Ignoring it; bind the camera to a poseHelm for view- or world-relative motion.');
|
|
1211
1212
|
}
|
|
1212
1213
|
if (_isCameraState(cam)) helm.home(cameraToPose(_pose, cam));
|
|
1213
1214
|
const player = {
|
|
@@ -1294,8 +1295,14 @@ function poseHelm(host, opts) {
|
|
|
1294
1295
|
* poseTrack(host, opts) is a core PoseTrack whose activation hooks add and
|
|
1295
1296
|
* remove its player. cameraTrack(host, cam, opts) is a core CameraTrack whose
|
|
1296
1297
|
* player evaluates straight into the camera state `cam` — the state is the
|
|
1297
|
-
* keyframe shape, so track.eval(cam) is the write —
|
|
1298
|
-
* deactivate so the camera rests on the path
|
|
1298
|
+
* keyframe shape, so track.eval(cam) is the write — while the track plays, and
|
|
1299
|
+
* once more on deactivate so the camera rests on the path. That bound is the
|
|
1300
|
+
* point: a stopped track's camera belongs to whoever else drives it — the
|
|
1301
|
+
* reader's orbit, the figure's own camera code — so a consumer that renders
|
|
1302
|
+
* from the state derives it instead, one evaluation per frame after the tick
|
|
1303
|
+
* that advances the transport, which carries a seek, a dragged keyframe and a
|
|
1304
|
+
* capture into the state as well and repeats the player's write harmlessly
|
|
1305
|
+
* while the track plays. add() with no argument
|
|
1299
1306
|
* captures `cam`, add({ camera }) any camera-state object. { handles } on
|
|
1300
1307
|
* either decorates the track with TrackHandles: one VIEW handle per
|
|
1301
1308
|
* draggable keyframe field (pos / eye / center), an optional rot DIAL per
|
|
@@ -1401,7 +1408,17 @@ function poseTrack(host, opts) {
|
|
|
1401
1408
|
}
|
|
1402
1409
|
|
|
1403
1410
|
/**
|
|
1404
|
-
* A core CameraTrack evaluating into the camera state `cam` while it plays
|
|
1411
|
+
* A core CameraTrack evaluating into the camera state `cam` while it plays, and
|
|
1412
|
+
* once when it stops, so the camera rests on the path.
|
|
1413
|
+
*
|
|
1414
|
+
* The write is bounded by playback on purpose: while a track is stopped the
|
|
1415
|
+
* camera it names belongs to whoever else drives it — the reader's orbit, the
|
|
1416
|
+
* figure's own camera code — and a factory writing every frame would fight
|
|
1417
|
+
* them. A consumer that renders *from* the state therefore derives it: evaluate
|
|
1418
|
+
* the track once per frame, after the tick that advances the transport. A seek,
|
|
1419
|
+
* a dragged keyframe and a capture reach the state that way too, and the
|
|
1420
|
+
* evaluation repeats the player's own write harmlessly while the track plays.
|
|
1421
|
+
*
|
|
1405
1422
|
* @param {object} host
|
|
1406
1423
|
* @param {object} cam A camera state ({ eye, center, up, fov, halfHeight, near, far }).
|
|
1407
1424
|
* @param {{ handles?:boolean|object }} [opts]
|
|
@@ -2491,7 +2508,7 @@ function raster(draw, w, h, opts) {
|
|
|
2491
2508
|
* class — a CSS class beside the layer's own 'host-label', frame — a
|
|
2492
2509
|
* transient label that lives for the frame it was set in: a gizmo re-sets
|
|
2493
2510
|
* it every draw and tick() removes it once a frame passes without. A label
|
|
2494
|
-
* whose
|
|
2511
|
+
* whose window depth leaves [0, 1] or whose anchor leaves the canvas is
|
|
2495
2512
|
* hidden, not clamped. Elements are reused by id; tick() writes transforms
|
|
2496
2513
|
* only, text when the string changed.
|
|
2497
2514
|
*/
|
|
@@ -2684,7 +2701,7 @@ function createLabels(host, opts) {
|
|
|
2684
2701
|
* what is still draining, so do home() and enabled = false. The default is
|
|
2685
2702
|
* 0.2 s; 0 makes the orbit exact.
|
|
2686
2703
|
*
|
|
2687
|
-
*
|
|
2704
|
+
* Canvas y runs down; which world direction that is depends on the
|
|
2688
2705
|
* projection installed in the view bag: a y-up projection (GL's, tree's
|
|
2689
2706
|
* default) maps a downward drag to the eye's −up, a y-flipped one (p5's,
|
|
2690
2707
|
* mat4Proj[5] < 0) to +up. The orbit reads that sign off the bag each
|
|
@@ -2799,7 +2816,7 @@ function createOrbit(host, cam, opts) {
|
|
|
2799
2816
|
let moved = false;
|
|
2800
2817
|
let az = 0, el = 0, px = 0, py = 0, ld = 0; // this frame's step
|
|
2801
2818
|
const view = host.view;
|
|
2802
|
-
const ys = view.mat4Proj[5] < 0 ? -1 : 1; //
|
|
2819
|
+
const ys = view.mat4Proj[5] < 0 ? -1 : 1; // canvas-down is the eye's −up under a y-up projection, +up under p5's flip
|
|
2803
2820
|
if (a !== null && b === null) {
|
|
2804
2821
|
const t = tracked.get(a.id);
|
|
2805
2822
|
if (t) {
|