@nakednous/tree 0.0.28 → 0.0.29
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 +5 -3
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -616,6 +616,8 @@ projLeft projRight projTop projBottom
|
|
|
616
616
|
|
|
617
617
|
**Pixel ratio:** `pixelRatio(proj, vpH, eyeZ, ndcZMin)` — world-units-per-pixel at a given depth, handles both perspective and orthographic.
|
|
618
618
|
|
|
619
|
+
**Viewport matrix:** `mat4Viewport(out, vp, ndcZMin)` — the matrix `W` taking NDC to screen coordinates, so world → screen is `(W · P · V · p) / w` through `mat4MulPoint` and screen → world the inverse of that composition
|
|
620
|
+
|
|
619
621
|
**Pick matrix:** `mat4Pick(proj, px, py, vp)` — mutates a projection matrix in-place so that the pixel at `(px, py)` maps to the full NDC square, making a 1×1 FBO render contain exactly that pixel. Takes the same signed viewport `vp` as `mapLocation` — the y-convention is preserved automatically.
|
|
620
622
|
|
|
621
623
|
**Pointer ray:** `unproject(outO, outD, sx, sy, m, vp, ndcZMin)` — a screen point as a world ray: origin on the near plane, unit direction toward the far plane. Same bag and signed viewport as `mapLocation` (`mat4PVInv` filled by the caller); `null` when the bag has no inverse. The point-at-depth form stays `mapLocation(SCREEN → WORLD)` with a depth in `z`.
|
|
@@ -700,11 +702,11 @@ The fixture format is specified in `tools/golden.js`. A function without a fixtu
|
|
|
700
702
|
|
|
701
703
|
---
|
|
702
704
|
|
|
703
|
-
## Relationship to
|
|
705
|
+
## Relationship to the bridges
|
|
704
706
|
|
|
705
|
-
[p5.tree](https://github.com/VisualComputing/p5.tree)
|
|
707
|
+
The bridges are where rendering lives. [p5.tree](https://github.com/VisualComputing/p5.tree) reads live p5 renderer state (camera matrices, viewport, NDC convention) into the host's view bag and draws the gizmo arrays with p5's own strokes; `twgl.tree` installs the camera, uploads the declared transforms and draws the same arrays through a line pipe on raw WebGL2; `webgpu.tree` realizes the same surface on WebGPU. Between them sits [`@nakednous/host`](https://github.com/nakednous/host): the pointer, the players, the handles, helms and tracks, the device streams, labels and the orbit — DOM transport, no renderer — which every bridge drives and which computes only through this package.
|
|
706
708
|
|
|
707
|
-
`@nakednous/tree` provides the algorithms. The
|
|
709
|
+
`@nakednous/tree` provides the algorithms, `@nakednous/host` the transport, `@nakednous/ui` the panels. The bridges provide the drawing.
|
|
708
710
|
|
|
709
711
|
---
|
|
710
712
|
|
package/dist/index.js
CHANGED
|
@@ -1404,6 +1404,32 @@ function pixelRatio(proj, vpH, eyeZ, ndcZMin) {
|
|
|
1404
1404
|
// Pick-matrix
|
|
1405
1405
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1406
1406
|
|
|
1407
|
+
/**
|
|
1408
|
+
* The viewport matrix W: NDC into screen coordinates, the S · T that seats the
|
|
1409
|
+
* NDC cube in the viewport rectangle and carries NDC depth into [0, 1].
|
|
1410
|
+
*
|
|
1411
|
+
* ┌ w/2 0 0 x + w/2 ┐
|
|
1412
|
+
* │ 0 h/2 0 y + h/2 │ vp = [x, y, w, h], h < 0 for screen y-down
|
|
1413
|
+
* │ 0 0 1/(1−n) −n/(1−n) │ n = ndcZMin
|
|
1414
|
+
* └ 0 0 0 1 ┘
|
|
1415
|
+
*
|
|
1416
|
+
* W is affine, so world → screen is one composition, (W · P · V · p) / w, and
|
|
1417
|
+
* screen → world its inverse — the same points mapLocation's WORLD ↔ SCREEN reaches.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {Float32Array|number[]} out 16-element destination.
|
|
1420
|
+
* @param {number[]} vp Viewport [x, y, w, h]; same signed convention as mapLocation.
|
|
1421
|
+
* @param {number} ndcZMin WEBGL (−1) or WEBGPU (0).
|
|
1422
|
+
* @returns {Float32Array|number[]} out
|
|
1423
|
+
*/
|
|
1424
|
+
function mat4Viewport(out, vp, ndcZMin) {
|
|
1425
|
+
const hw = vp[2] / 2, hh = vp[3] / 2, dz = 1 / (1 - ndcZMin);
|
|
1426
|
+
out[0]=hw; out[1]=0; out[2]=0; out[3]=0;
|
|
1427
|
+
out[4]=0; out[5]=hh; out[6]=0; out[7]=0;
|
|
1428
|
+
out[8]=0; out[9]=0; out[10]=dz; out[11]=0;
|
|
1429
|
+
out[12]=vp[0] + hw; out[13]=vp[1] + hh; out[14]=-ndcZMin * dz; out[15]=1;
|
|
1430
|
+
return out;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1407
1433
|
/**
|
|
1408
1434
|
* Mutate a projection matrix in-place so that the pixel at (px, py) maps to
|
|
1409
1435
|
* the full NDC square — making a 1×1 FBO render contain exactly that pixel.
|
|
@@ -5098,5 +5124,5 @@ function paneTris(out, p0, p1, p2, p3, opts) {
|
|
|
5098
5124
|
return _end(out);
|
|
5099
5125
|
}
|
|
5100
5126
|
|
|
5101
|
-
export { AIM, APEX, AXIS, BODY, BOTTOM, CENTER, CIRCLE, COLOR_DIM, COLOR_X, COLOR_Y, COLOR_Z, CONTROLS, CameraTrack, Constraint, DIAL, DIRECTION, EYE, FAR, HANDLE, HANDLES, HELM_CHANNELS, INVISIBLE, LABELS, LEFT, LOCUS, MATRIX, MODEL, NDC, NEAR, NONE, ORIGIN, PATH, PLANE, PLANE_BOTTOM, PLANE_FAR, PLANE_LEFT, PLANE_NEAR, PLANE_RIGHT, PLANE_TOP, POINT, PoseHelm, PoseTrack, RIGHT, RING, ROTATE, SCREEN, SELF, SEMIVISIBLE, SPHERE, SQUARE, TANGENTS, TANGENTS_IN, TANGENTS_OUT, TOP, TRANSLATE, VISIBLE, WEBGL, WEBGPU, WORLD, X, Y, Z, _X, _Y, _Z, _i, _j, _k, axesLines, azElFromDir, boxVisibility, bullsEyeLines, cameraCopy, cameraDolly, cameraEye, cameraFromMat4, cameraFromPose, cameraOrbit, cameraPan, cameraPlanes, cameraProj, cameraToPose, cameraView, capacityOf, createArrays, createCamera, createConstraint, crossLines, dirFromAzEl, distanceToPlane, frustumCorners, frustumLines, frustumPlanes, gridLines, growArrays, helmRigLines, hermiteLines, hermiteVec3, i, idToRgba, j, k, lerpVec3, locusLines, mapDirection, mapLocation, mat3Direction, mat3NormalFromMat4, mat4Bias, mat4Eye, mat4FromBasis, mat4FromScale, mat4FromTRS, mat4FromTranslation, mat4Invert, mat4Location, mat4MV, mat4Mul, mat4MulDir, mat4MulPoint, mat4Ortho, mat4PV, mat4Persp, mat4Pick, mat4Reflect, mat4ToRotation, mat4ToScale, mat4ToTransform, mat4ToTranslation, mat4View, oneEuro, paneTris, pathLines, pixelRatio, pointVisibility, pointerHit, poseDelta, projBottom, projFar, projFov, projHfov, projIsOrtho, projLeft, projNear, projRight, projTop, qConjugate, qCopy, qDot, qFromAxisAngle, qFromLookDir, qFromMat4, qFromRotMat3x3, qFromUnitVectors, qMul, qNegate, qNlerp, qNormalize, qRotateVec3, qSet, qSlerp, qToAxisAngle, qToMat4, rayClosestPointOnAxis, rayHitCapsule, rayHitRing, rayHitSphere, rayPlane, raySphere, rgbaToId, ringLines, sphereVisibility, transformToMat4, unproject };
|
|
5127
|
+
export { AIM, APEX, AXIS, BODY, BOTTOM, CENTER, CIRCLE, COLOR_DIM, COLOR_X, COLOR_Y, COLOR_Z, CONTROLS, CameraTrack, Constraint, DIAL, DIRECTION, EYE, FAR, HANDLE, HANDLES, HELM_CHANNELS, INVISIBLE, LABELS, LEFT, LOCUS, MATRIX, MODEL, NDC, NEAR, NONE, ORIGIN, PATH, PLANE, PLANE_BOTTOM, PLANE_FAR, PLANE_LEFT, PLANE_NEAR, PLANE_RIGHT, PLANE_TOP, POINT, PoseHelm, PoseTrack, RIGHT, RING, ROTATE, SCREEN, SELF, SEMIVISIBLE, SPHERE, SQUARE, TANGENTS, TANGENTS_IN, TANGENTS_OUT, TOP, TRANSLATE, VISIBLE, WEBGL, WEBGPU, WORLD, X, Y, Z, _X, _Y, _Z, _i, _j, _k, axesLines, azElFromDir, boxVisibility, bullsEyeLines, cameraCopy, cameraDolly, cameraEye, cameraFromMat4, cameraFromPose, cameraOrbit, cameraPan, cameraPlanes, cameraProj, cameraToPose, cameraView, capacityOf, createArrays, createCamera, createConstraint, crossLines, dirFromAzEl, distanceToPlane, frustumCorners, frustumLines, frustumPlanes, gridLines, growArrays, helmRigLines, hermiteLines, hermiteVec3, i, idToRgba, j, k, lerpVec3, locusLines, mapDirection, mapLocation, mat3Direction, mat3NormalFromMat4, mat4Bias, mat4Eye, mat4FromBasis, mat4FromScale, mat4FromTRS, mat4FromTranslation, mat4Invert, mat4Location, mat4MV, mat4Mul, mat4MulDir, mat4MulPoint, mat4Ortho, mat4PV, mat4Persp, mat4Pick, mat4Reflect, mat4ToRotation, mat4ToScale, mat4ToTransform, mat4ToTranslation, mat4View, mat4Viewport, oneEuro, paneTris, pathLines, pixelRatio, pointVisibility, pointerHit, poseDelta, projBottom, projFar, projFov, projHfov, projIsOrtho, projLeft, projNear, projRight, projTop, qConjugate, qCopy, qDot, qFromAxisAngle, qFromLookDir, qFromMat4, qFromRotMat3x3, qFromUnitVectors, qMul, qNegate, qNlerp, qNormalize, qRotateVec3, qSet, qSlerp, qToAxisAngle, qToMat4, rayClosestPointOnAxis, rayHitCapsule, rayHitRing, rayHitSphere, rayPlane, raySphere, rgbaToId, ringLines, sphereVisibility, transformToMat4, unproject };
|
|
5102
5128
|
//# sourceMappingURL=index.js.map
|