@graview/graverse 0.0.0-stage → 0.2.19
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/LICENSE +96 -0
- package/README.md +50 -2
- package/dist/camera.d.ts +108 -0
- package/dist/camera.d.ts.map +1 -0
- package/dist/camera.js +169 -0
- package/dist/camera.js.map +1 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +72 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +610 -0
- package/dist/index.js.map +1 -0
- package/dist/labels.d.ts +36 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +79 -0
- package/dist/labels.js.map +1 -0
- package/dist/layout.d.ts +74 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +238 -0
- package/dist/layout.js.map +1 -0
- package/dist/space-host.d.ts +47 -0
- package/dist/space-host.d.ts.map +1 -0
- package/dist/space-host.js +2 -0
- package/dist/space-host.js.map +1 -0
- package/dist/space.d.ts +3 -0
- package/dist/space.d.ts.map +1 -0
- package/dist/space.js +757 -0
- package/dist/space.js.map +1 -0
- package/dist/style.d.ts +2 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +125 -0
- package/dist/style.js.map +1 -0
- package/dist/words.d.ts +16 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +43 -0
- package/dist/words.js.map +1 -0
- package/package.json +63 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
## Acceptance
|
|
4
|
+
|
|
5
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
6
|
+
|
|
7
|
+
## Copyright License
|
|
8
|
+
|
|
9
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
10
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
11
|
+
available, and prepare derivative works of the software, in each case subject
|
|
12
|
+
to the limitations and conditions below.
|
|
13
|
+
|
|
14
|
+
## Limitations
|
|
15
|
+
|
|
16
|
+
You may not provide the software to third parties as a hosted or managed
|
|
17
|
+
service, where the service provides users with access to any substantial set
|
|
18
|
+
of the features or functionality of the software.
|
|
19
|
+
|
|
20
|
+
You may not move, change, disable, or circumvent the license key
|
|
21
|
+
functionality in the software, and you may not remove or obscure any
|
|
22
|
+
functionality in the software that is protected by the license key.
|
|
23
|
+
|
|
24
|
+
You may not alter, remove, or obscure any licensing, copyright, or other
|
|
25
|
+
notices of the licensor in the software. Any use of the licensor's trademarks
|
|
26
|
+
is subject to applicable law.
|
|
27
|
+
|
|
28
|
+
## Patents
|
|
29
|
+
|
|
30
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
31
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
32
|
+
sale, import and have imported the software, in each case subject to the
|
|
33
|
+
limitations and conditions in this license. This license does not cover any
|
|
34
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
35
|
+
the software. If you or your company make any written claim that the software
|
|
36
|
+
infringes or contributes to infringement of any patent, your patent license
|
|
37
|
+
for the software granted under these terms ends immediately. If your company
|
|
38
|
+
makes such a claim, your patent license ends immediately for work on behalf
|
|
39
|
+
of your company.
|
|
40
|
+
|
|
41
|
+
## Notices
|
|
42
|
+
|
|
43
|
+
You must ensure that anyone who gets a copy of any part of the software from
|
|
44
|
+
you also gets a copy of these terms.
|
|
45
|
+
|
|
46
|
+
If you modify the software, you must include in any modified copies of the
|
|
47
|
+
software prominent notices stating that you have modified the software.
|
|
48
|
+
|
|
49
|
+
## No Other Rights
|
|
50
|
+
|
|
51
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
52
|
+
these terms.
|
|
53
|
+
|
|
54
|
+
## Termination
|
|
55
|
+
|
|
56
|
+
If you use the software in violation of these terms, such use is not
|
|
57
|
+
licensed, and your licenses will automatically terminate. If the licensor
|
|
58
|
+
provides you with a notice of your violation, and you cease all violation of
|
|
59
|
+
this license no later than 30 days after you receive that notice, your
|
|
60
|
+
licenses will be reinstated retroactively. However, if you violate these
|
|
61
|
+
terms after such reinstatement, any additional violation of these terms will
|
|
62
|
+
cause your licenses to terminate automatically and permanently.
|
|
63
|
+
|
|
64
|
+
## No Liability
|
|
65
|
+
|
|
66
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
67
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
68
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
69
|
+
legal claim.*
|
|
70
|
+
|
|
71
|
+
## Definitions
|
|
72
|
+
|
|
73
|
+
The **licensor** is the entity offering these terms, and the **software** is
|
|
74
|
+
the software the licensor makes available under these terms, including any
|
|
75
|
+
portion of it.
|
|
76
|
+
|
|
77
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
80
|
+
organization that you work for, plus all organizations that have control
|
|
81
|
+
over, are under the control of, or are under common control with that
|
|
82
|
+
organization. **control** means ownership of substantially all the assets of
|
|
83
|
+
an entity, or the power to direct its management and policies by vote,
|
|
84
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
85
|
+
|
|
86
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
87
|
+
these terms.
|
|
88
|
+
|
|
89
|
+
**use** means anything you do with the software requiring one of your
|
|
90
|
+
licenses.
|
|
91
|
+
|
|
92
|
+
**trademark** means trademarks, service marks, and similar rights.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
Copyright 2025-2026 En Dash Consulting
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @graview/graverse
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Graverse: every app the local hub reaches, drawn as one space, found
|
|
4
|
+
across from one box, and opened at its own page through the hub. Read and
|
|
5
|
+
navigate; nothing here changes an app. Experimental.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
graview hub start # prints the address to open; the Graverse is the hub's own page
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The `graview` tool carries this page, built, in `dist/graverse/`, and the
|
|
12
|
+
hub serves it at its address. Nothing here is a product's dependency, and
|
|
13
|
+
no app's page carries it or `three`.
|
|
14
|
+
|
|
15
|
+
## The page
|
|
16
|
+
|
|
17
|
+
`mountGraverse(element)` draws the plain page: the index of spaces and
|
|
18
|
+
apps, the search box, the matches grouped by app with every field that
|
|
19
|
+
matched, a breadcrumb, where to start, and the detail of what is chosen,
|
|
20
|
+
with an app's records changed lately. It is the whole page with WebGL off,
|
|
21
|
+
and the whole page from the keyboard: Tab to an app, Enter to choose it,
|
|
22
|
+
Tab to Open. `/` finds, and Escape steps back along the breadcrumb, then
|
|
23
|
+
clears the search once nothing is chosen.
|
|
24
|
+
|
|
25
|
+
It asks the hub three things (`hubClient`): the universe described
|
|
26
|
+
(`POST /universe/describe`), a find read one app's answer at a time as each
|
|
27
|
+
arrives (`POST /universe/find`, lines of JSON), and one app's cloud, its
|
|
28
|
+
records as the seat sees them, asked live when the camera comes near
|
|
29
|
+
(`POST /universe/cloud`). Records are never kept by the hub for the page.
|
|
30
|
+
|
|
31
|
+
Where WebGL is there (`canDrawSpace`), the page fetches its drawing,
|
|
32
|
+
`@graview/graverse/space` (`mountSpace`), which is the only module that
|
|
33
|
+
imports `three`. Spaces are faint grounds; an app far away is one point of
|
|
34
|
+
light, as bright as it is recent; come near and its records gather into
|
|
35
|
+
its kinds where its city map puts them (`cityMap` from
|
|
36
|
+
`@graview/core/city`). At rest one label per space shows; while a search
|
|
37
|
+
is on, every app with matches is labeled with its count.
|
|
38
|
+
|
|
39
|
+
## The arithmetic
|
|
40
|
+
|
|
41
|
+
`@graview/graverse/camera` is the camera with no drawing library:
|
|
42
|
+
`dragTo` keeps the grabbed point under the pointer, `zoomAbout` keeps the
|
|
43
|
+
point under the pointer where it is, `turnAbout` keeps the pressed point
|
|
44
|
+
where it was, `glide` moves between two cameras (a cut under reduced
|
|
45
|
+
motion), and `project`, `pointUnder` and `framing` read the screen.
|
|
46
|
+
`@graview/graverse/layout` places everything, the same way every time:
|
|
47
|
+
`universeLayout` packs a space's apps by the cube root of their records,
|
|
48
|
+
`kindPlaces` stands an app's kinds on its city map and `recordPlaces`
|
|
49
|
+
puts each record by its own id.
|
|
50
|
+
|
|
51
|
+
Elastic License 2.0
|
package/dist/camera.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export interface Vec3 {
|
|
2
|
+
readonly x: number;
|
|
3
|
+
readonly y: number;
|
|
4
|
+
readonly z: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CameraState {
|
|
7
|
+
readonly target: Vec3;
|
|
8
|
+
readonly distance: number;
|
|
9
|
+
readonly yaw: number;
|
|
10
|
+
readonly pitch: number;
|
|
11
|
+
/** The vertical field of view, in degrees. */
|
|
12
|
+
readonly fov: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Viewport {
|
|
15
|
+
readonly width: number;
|
|
16
|
+
readonly height: number;
|
|
17
|
+
/**
|
|
18
|
+
* What the page's panels cover at each edge, in pixels: the picture is
|
|
19
|
+
* centered in what is left, so what the camera looks at stands in the
|
|
20
|
+
* middle of what a person can see, not under a panel.
|
|
21
|
+
*/
|
|
22
|
+
readonly inset?: {
|
|
23
|
+
readonly top: number;
|
|
24
|
+
readonly right: number;
|
|
25
|
+
readonly bottom: number;
|
|
26
|
+
readonly left: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** A point on the screen, in CSS pixels from the top left, and how far in front of the camera it stands. */
|
|
30
|
+
export interface ScreenPoint {
|
|
31
|
+
readonly x: number;
|
|
32
|
+
readonly y: number;
|
|
33
|
+
readonly depth: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const vec: (x: number, y: number, z: number) => Vec3;
|
|
36
|
+
export declare const add: (a: Vec3, b: Vec3) => Vec3;
|
|
37
|
+
export declare const sub: (a: Vec3, b: Vec3) => Vec3;
|
|
38
|
+
export declare const scale: (a: Vec3, k: number) => Vec3;
|
|
39
|
+
export declare const dot: (a: Vec3, b: Vec3) => number;
|
|
40
|
+
export declare const cross: (a: Vec3, b: Vec3) => Vec3;
|
|
41
|
+
export declare const length: (a: Vec3) => number;
|
|
42
|
+
export declare const distance: (a: Vec3, b: Vec3) => number;
|
|
43
|
+
/** How high a camera may look from: never under the ground, never quite straight down. */
|
|
44
|
+
export declare const PITCH_LOWEST = 0.06;
|
|
45
|
+
export declare const PITCH_HIGHEST = 1.5;
|
|
46
|
+
/** How near and how far a camera may stand from what it looks at. */
|
|
47
|
+
export declare const NEAREST = 2;
|
|
48
|
+
/** Where the camera stands. */
|
|
49
|
+
export declare function positionOf(camera: CameraState): Vec3;
|
|
50
|
+
/** The camera's own axes: where it looks, its right and its up. */
|
|
51
|
+
export declare function axesOf(camera: CameraState): {
|
|
52
|
+
readonly forward: Vec3;
|
|
53
|
+
readonly right: Vec3;
|
|
54
|
+
readonly up: Vec3;
|
|
55
|
+
};
|
|
56
|
+
/** Where a point in the world falls on the screen. A point behind the camera has a depth of zero or less. */
|
|
57
|
+
export declare function project(camera: CameraState, view: Viewport, point: Vec3): ScreenPoint;
|
|
58
|
+
/** The ray from the camera through a pixel of the screen. */
|
|
59
|
+
export declare function rayAt(camera: CameraState, view: Viewport, x: number, y: number): {
|
|
60
|
+
readonly origin: Vec3;
|
|
61
|
+
readonly direction: Vec3;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* THE WORLD POINT UNDER A PIXEL, at the depth of `through`: on the plane
|
|
65
|
+
* through it that faces the camera. What a drag grabs and a zoom keeps.
|
|
66
|
+
*/
|
|
67
|
+
export declare function pointUnder(camera: CameraState, view: Viewport, x: number, y: number, through: Vec3): Vec3;
|
|
68
|
+
/**
|
|
69
|
+
* A DRAG: the camera moved so the grabbed point stands under the pointer.
|
|
70
|
+
* The camera only slides; nothing turns or comes nearer.
|
|
71
|
+
*/
|
|
72
|
+
export declare function dragTo(camera: CameraState, view: Viewport, grabbed: Vec3, x: number, y: number): CameraState;
|
|
73
|
+
/**
|
|
74
|
+
* A ZOOM ABOUT A POINT: the camera comes nearer (`factor` under one) or goes
|
|
75
|
+
* farther, along the line to `anchor`, so the anchor, and everything at its
|
|
76
|
+
* depth, stays where it is on the screen.
|
|
77
|
+
*/
|
|
78
|
+
export declare function zoomAbout(camera: CameraState, anchor: Vec3, factor: number, farthest?: number): CameraState;
|
|
79
|
+
/**
|
|
80
|
+
* A TURN ABOUT A POINT: the view swings round `pivot` (`yaw` about the
|
|
81
|
+
* vertical, `pitch` up or down), and the pivot stays where it was on the
|
|
82
|
+
* screen. The pitch is held between the ground and straight down.
|
|
83
|
+
*/
|
|
84
|
+
export declare function turnAbout(camera: CameraState, pivot: Vec3, yaw: number, pitch: number): CameraState;
|
|
85
|
+
/** The camera's offset for three's `setViewOffset`: the picture moved so its middle is the middle of what is seen. */
|
|
86
|
+
export declare function viewOffset(view: Viewport): {
|
|
87
|
+
readonly x: number;
|
|
88
|
+
readonly y: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* A camera that frames a ball of `radius` about `center`, from the same
|
|
92
|
+
* direction, in what the panels leave of the screen: narrower of its
|
|
93
|
+
* width and height, so a phone sees all of it too.
|
|
94
|
+
*/
|
|
95
|
+
export declare function framing(camera: CameraState, center: Vec3, radius: number, view?: Viewport): CameraState;
|
|
96
|
+
/**
|
|
97
|
+
* A GLIDE from one camera to another: farther or deeper takes a little
|
|
98
|
+
* longer, never long. With reduced motion it is a cut: no time at all, and
|
|
99
|
+
* the first frame is the last.
|
|
100
|
+
*/
|
|
101
|
+
export interface Glide {
|
|
102
|
+
readonly ms: number;
|
|
103
|
+
at(elapsedMs: number): CameraState;
|
|
104
|
+
}
|
|
105
|
+
export declare function glide(from: CameraState, to: CameraState, options?: {
|
|
106
|
+
readonly reducedMotion?: boolean;
|
|
107
|
+
}): Gl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EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,KAAK,CAwBnH"}
|
package/dist/camera.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* THE GRAVERSE'S CAMERA, AS ARITHMETIC (Graview HQ feature:f-graverse-page).
|
|
3
|
+
*
|
|
4
|
+
* Moving is direct: a drag keeps the grabbed point under the pointer, a
|
|
5
|
+
* zoom keeps the point under the pointer where it is, and a turn keeps the
|
|
6
|
+
* pressed point where it was. Each is an exact move of one camera, worked
|
|
7
|
+
* out here with no drawing library, so the drawing (`./space`) and a test
|
|
8
|
+
* read one camera, and what a test holds is what a person feels.
|
|
9
|
+
*
|
|
10
|
+
* The camera looks at `target` from `distance` away, turned `yaw` about the
|
|
11
|
+
* vertical and raised `pitch` above the ground; up is always up. It is the
|
|
12
|
+
* camera a perspective drawing makes with a vertical field of view `fov`
|
|
13
|
+
* (degrees) and `lookAt(target)`.
|
|
14
|
+
*/
|
|
15
|
+
/** How far the middle of what is seen stands from the middle of the screen. */
|
|
16
|
+
function shiftOf(view) {
|
|
17
|
+
const inset = view.inset;
|
|
18
|
+
return inset ? { x: (inset.left - inset.right) / 2, y: (inset.top - inset.bottom) / 2 } : { x: 0, y: 0 };
|
|
19
|
+
}
|
|
20
|
+
export const vec = (x, y, z) => ({ x, y, z });
|
|
21
|
+
export const add = (a, b) => vec(a.x + b.x, a.y + b.y, a.z + b.z);
|
|
22
|
+
export const sub = (a, b) => vec(a.x - b.x, a.y - b.y, a.z - b.z);
|
|
23
|
+
export const scale = (a, k) => vec(a.x * k, a.y * k, a.z * k);
|
|
24
|
+
export const dot = (a, b) => a.x * b.x + a.y * b.y + a.z * b.z;
|
|
25
|
+
export const cross = (a, b) => vec(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
|
|
26
|
+
export const length = (a) => Math.hypot(a.x, a.y, a.z);
|
|
27
|
+
export const distance = (a, b) => length(sub(a, b));
|
|
28
|
+
const normal = (a) => {
|
|
29
|
+
const n = length(a);
|
|
30
|
+
return n === 0 ? vec(0, 0, 0) : scale(a, 1 / n);
|
|
31
|
+
};
|
|
32
|
+
const UP = vec(0, 1, 0);
|
|
33
|
+
/** How high a camera may look from: never under the ground, never quite straight down. */
|
|
34
|
+
export const PITCH_LOWEST = 0.06;
|
|
35
|
+
export const PITCH_HIGHEST = 1.5;
|
|
36
|
+
/** How near and how far a camera may stand from what it looks at. */
|
|
37
|
+
export const NEAREST = 2;
|
|
38
|
+
const clamp = (x, low, high) => Math.max(low, Math.min(high, x));
|
|
39
|
+
/** Where the camera stands. */
|
|
40
|
+
export function positionOf(camera) {
|
|
41
|
+
const level = Math.cos(camera.pitch);
|
|
42
|
+
return add(camera.target, vec(camera.distance * level * Math.sin(camera.yaw), camera.distance * Math.sin(camera.pitch), camera.distance * level * Math.cos(camera.yaw)));
|
|
43
|
+
}
|
|
44
|
+
/** The camera's own axes: where it looks, its right and its up. */
|
|
45
|
+
export function axesOf(camera) {
|
|
46
|
+
const forward = normal(sub(camera.target, positionOf(camera)));
|
|
47
|
+
const right = normal(cross(forward, UP));
|
|
48
|
+
return { forward, right, up: cross(right, forward) };
|
|
49
|
+
}
|
|
50
|
+
/** Where a point in the world falls on the screen. A point behind the camera has a depth of zero or less. */
|
|
51
|
+
export function project(camera, view, point) {
|
|
52
|
+
const { forward, right, up } = axesOf(camera);
|
|
53
|
+
const from = sub(point, positionOf(camera));
|
|
54
|
+
const depth = dot(from, forward);
|
|
55
|
+
const half = Math.tan((camera.fov * Math.PI) / 360);
|
|
56
|
+
const aspect = view.width / view.height;
|
|
57
|
+
const nx = dot(from, right) / (depth * half * aspect);
|
|
58
|
+
const ny = dot(from, up) / (depth * half);
|
|
59
|
+
const shift = shiftOf(view);
|
|
60
|
+
return { x: ((nx + 1) / 2) * view.width + shift.x, y: ((1 - ny) / 2) * view.height + shift.y, depth };
|
|
61
|
+
}
|
|
62
|
+
/** The ray from the camera through a pixel of the screen. */
|
|
63
|
+
export function rayAt(camera, view, x, y) {
|
|
64
|
+
const { forward, right, up } = axesOf(camera);
|
|
65
|
+
const half = Math.tan((camera.fov * Math.PI) / 360);
|
|
66
|
+
const shift = shiftOf(view);
|
|
67
|
+
const nx = ((x - shift.x) / view.width) * 2 - 1;
|
|
68
|
+
const ny = 1 - ((y - shift.y) / view.height) * 2;
|
|
69
|
+
return { origin: positionOf(camera), direction: normal(add(forward, add(scale(right, nx * half * (view.width / view.height)), scale(up, ny * half)))) };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* THE WORLD POINT UNDER A PIXEL, at the depth of `through`: on the plane
|
|
73
|
+
* through it that faces the camera. What a drag grabs and a zoom keeps.
|
|
74
|
+
*/
|
|
75
|
+
export function pointUnder(camera, view, x, y, through) {
|
|
76
|
+
const { forward } = axesOf(camera);
|
|
77
|
+
const ray = rayAt(camera, view, x, y);
|
|
78
|
+
const facing = dot(ray.direction, forward);
|
|
79
|
+
if (facing <= 1e-9)
|
|
80
|
+
return through;
|
|
81
|
+
const t = dot(sub(through, ray.origin), forward) / facing;
|
|
82
|
+
return add(ray.origin, scale(ray.direction, t));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A DRAG: the camera moved so the grabbed point stands under the pointer.
|
|
86
|
+
* The camera only slides; nothing turns or comes nearer.
|
|
87
|
+
*/
|
|
88
|
+
export function dragTo(camera, view, grabbed, x, y) {
|
|
89
|
+
const under = pointUnder(camera, view, x, y, grabbed);
|
|
90
|
+
return { ...camera, target: add(camera.target, sub(grabbed, under)) };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A ZOOM ABOUT A POINT: the camera comes nearer (`factor` under one) or goes
|
|
94
|
+
* farther, along the line to `anchor`, so the anchor, and everything at its
|
|
95
|
+
* depth, stays where it is on the screen.
|
|
96
|
+
*/
|
|
97
|
+
export function zoomAbout(camera, anchor, factor, farthest = Infinity) {
|
|
98
|
+
const next = clamp(camera.distance * factor, NEAREST, farthest);
|
|
99
|
+
const k = next / camera.distance;
|
|
100
|
+
return { ...camera, target: add(anchor, scale(sub(camera.target, anchor), k)), distance: next };
|
|
101
|
+
}
|
|
102
|
+
/** Turns a vector about an axis through the origin (Rodrigues). */
|
|
103
|
+
function turnVector(v, axis, angle) {
|
|
104
|
+
const k = normal(axis);
|
|
105
|
+
const c = Math.cos(angle);
|
|
106
|
+
const s = Math.sin(angle);
|
|
107
|
+
return add(add(scale(v, c), scale(cross(k, v), s)), scale(k, dot(k, v) * (1 - c)));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A TURN ABOUT A POINT: the view swings round `pivot` (`yaw` about the
|
|
111
|
+
* vertical, `pitch` up or down), and the pivot stays where it was on the
|
|
112
|
+
* screen. The pitch is held between the ground and straight down.
|
|
113
|
+
*/
|
|
114
|
+
export function turnAbout(camera, pivot, yaw, pitch) {
|
|
115
|
+
const lifted = clamp(camera.pitch + pitch, PITCH_LOWEST, PITCH_HIGHEST) - camera.pitch;
|
|
116
|
+
// The whole camera turns as one body about the pivot: where it stands and what it looks at.
|
|
117
|
+
let offset = turnVector(sub(camera.target, pivot), UP, yaw);
|
|
118
|
+
const yawed = camera.yaw + yaw;
|
|
119
|
+
const right = vec(Math.cos(yawed), 0, -Math.sin(yawed));
|
|
120
|
+
offset = turnVector(offset, right, -lifted);
|
|
121
|
+
return { ...camera, target: add(pivot, offset), yaw: yawed, pitch: camera.pitch + lifted };
|
|
122
|
+
}
|
|
123
|
+
/** The camera's offset for three's `setViewOffset`: the picture moved so its middle is the middle of what is seen. */
|
|
124
|
+
export function viewOffset(view) {
|
|
125
|
+
const shift = shiftOf(view);
|
|
126
|
+
return { x: -shift.x, y: -shift.y };
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A camera that frames a ball of `radius` about `center`, from the same
|
|
130
|
+
* direction, in what the panels leave of the screen: narrower of its
|
|
131
|
+
* width and height, so a phone sees all of it too.
|
|
132
|
+
*/
|
|
133
|
+
export function framing(camera, center, radius, view) {
|
|
134
|
+
const tan = Math.tan((camera.fov * Math.PI) / 360);
|
|
135
|
+
const inset = view?.inset ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
136
|
+
const seenHigh = view ? Math.max(1, view.height - inset.top - inset.bottom) / view.height : 1;
|
|
137
|
+
const seenWide = view ? Math.max(1, view.width - inset.left - inset.right) / view.height : 1;
|
|
138
|
+
const half = tan * Math.min(seenHigh, seenWide);
|
|
139
|
+
return { ...camera, target: center, distance: Math.max(NEAREST, (radius / half) * 1.15) };
|
|
140
|
+
}
|
|
141
|
+
export function glide(from, to, options = {}) {
|
|
142
|
+
if (options.reducedMotion)
|
|
143
|
+
return { ms: 0, at: () => to };
|
|
144
|
+
const across = distance(from.target, to.target) / Math.max(from.distance, to.distance, 1e-6);
|
|
145
|
+
const deeper = Math.abs(Math.log(to.distance / from.distance));
|
|
146
|
+
const ms = Math.round(clamp(500 + Math.log10(1 + across) * 550 + deeper * 100, 500, 1400));
|
|
147
|
+
// Yaw goes the short way round.
|
|
148
|
+
let turn = (to.yaw - from.yaw) % (Math.PI * 2);
|
|
149
|
+
if (turn > Math.PI)
|
|
150
|
+
turn -= Math.PI * 2;
|
|
151
|
+
if (turn < -Math.PI)
|
|
152
|
+
turn += Math.PI * 2;
|
|
153
|
+
return {
|
|
154
|
+
ms,
|
|
155
|
+
at(elapsed) {
|
|
156
|
+
const k = clamp(elapsed / ms, 0, 1);
|
|
157
|
+
const e = k < 0.5 ? 4 * k ** 3 : 1 - (-2 * k + 2) ** 3 / 2;
|
|
158
|
+
return {
|
|
159
|
+
target: add(from.target, scale(sub(to.target, from.target), e)),
|
|
160
|
+
// Distance moves by ratio, so a long dive feels even.
|
|
161
|
+
distance: from.distance * Math.pow(to.distance / from.distance, e),
|
|
162
|
+
yaw: from.yaw + turn * e,
|
|
163
|
+
pitch: from.pitch + (to.pitch - from.pitch) * e,
|
|
164
|
+
fov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I,CAAC,EAAE;QAAE,IAAI,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO;QACL,EAAE;QACF,EAAE,CAAC,OAAO;YACR,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACpC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC3D,OAAO;gBACL,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC/D,sDAAsD;gBACtD,QAAQ,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAClE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC;gBACxB,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC/C,GAAG,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;aACxC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AppAddress, AppCloud, EverywhereEvent, Refused, UniverseDescription } from "@graview/hub/runtime";
|
|
2
|
+
export interface GraverseClient {
|
|
3
|
+
describe(options?: {
|
|
4
|
+
readonly after?: string;
|
|
5
|
+
}): Promise<UniverseDescription | Refused>;
|
|
6
|
+
cloud(app: AppAddress, signal?: AbortSignal): Promise<AppCloud | Refused>;
|
|
7
|
+
find(query: string, options?: {
|
|
8
|
+
readonly cursor?: string;
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
}): AsyncIterable<EverywhereEvent>;
|
|
11
|
+
}
|
|
12
|
+
/** The hub at `base` (the page's own origin unless told), asked with `fetcher`. */
|
|
13
|
+
export declare function hubClient(base?: string, fetcher?: typeof fetch): GraverseClient;
|
|
14
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAUhH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,CAAC;IACxF,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;IAC1E,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;CAC5H;AAiBD,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,IAAI,SAAK,EAAE,OAAO,GAAE,OAAO,KAAmC,GAAG,cAAc,CAgDxG"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const refusedOf = (status, body) => typeof body === "object" && body !== null && typeof body.refused === "string" ? body : { refused: `The hub answered ${status}.` };
|
|
2
|
+
async function post(fetcher, url, body, signal) {
|
|
3
|
+
try {
|
|
4
|
+
const answered = await fetcher(url, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body), credentials: "same-origin", ...(signal ? { signal } : {}) });
|
|
5
|
+
const parsed = (await answered.json().catch(() => null));
|
|
6
|
+
if (!answered.ok || parsed === null)
|
|
7
|
+
return refusedOf(answered.status, parsed);
|
|
8
|
+
return parsed;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (signal?.aborted)
|
|
12
|
+
throw error;
|
|
13
|
+
return { refused: "The hub could not be reached. Is it still running? graview hub status says." };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** The hub at `base` (the page's own origin unless told), asked with `fetcher`. */
|
|
17
|
+
export function hubClient(base = "", fetcher = (...args) => fetch(...args)) {
|
|
18
|
+
const at = (path) => `${base.replace(/\/$/, "")}${path}`;
|
|
19
|
+
return {
|
|
20
|
+
describe: (options = {}) => post(fetcher, at("/universe/describe"), options.after ? { after: options.after } : {}),
|
|
21
|
+
cloud: (app, signal) => post(fetcher, at("/universe/cloud"), { app }, signal),
|
|
22
|
+
async *find(query, options = {}) {
|
|
23
|
+
let answered;
|
|
24
|
+
try {
|
|
25
|
+
answered = await fetcher(at("/universe/find"), {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: { "content-type": "application/json", accept: "application/x-ndjson" },
|
|
28
|
+
body: JSON.stringify({ query, ...(options.cursor ? { cursor: options.cursor } : {}) }),
|
|
29
|
+
credentials: "same-origin",
|
|
30
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (options.signal?.aborted)
|
|
35
|
+
return;
|
|
36
|
+
yield { type: "call-refused", refused: { refused: "The hub could not be reached. Is it still running? graview hub status says." } };
|
|
37
|
+
void error;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!answered.ok || !answered.body) {
|
|
41
|
+
yield { type: "call-refused", refused: refusedOf(answered.status, await answered.json().catch(() => null)) };
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// One event a line; a line may arrive in pieces.
|
|
45
|
+
const reader = answered.body.getReader();
|
|
46
|
+
const decoder = new TextDecoder();
|
|
47
|
+
let held = "";
|
|
48
|
+
for (;;) {
|
|
49
|
+
let chunk;
|
|
50
|
+
try {
|
|
51
|
+
chunk = await reader.read();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
held += decoder.decode(chunk.value ?? new Uint8Array(), { stream: !chunk.done });
|
|
57
|
+
let line;
|
|
58
|
+
while ((line = held.indexOf("\n")) !== -1) {
|
|
59
|
+
const text = held.slice(0, line).trim();
|
|
60
|
+
held = held.slice(line + 1);
|
|
61
|
+
if (text)
|
|
62
|
+
yield JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
if (chunk.done)
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (held.trim())
|
|
68
|
+
yield JSON.parse(held);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAgBA,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,IAAa,EAAW,EAAE,CAC3D,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,OAAQ,IAA8B,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,oBAAoB,MAAM,GAAG,EAAE,CAAC;AAE5K,KAAK,UAAU,IAAI,CAAI,OAAqB,EAAE,GAAW,E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;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type GraverseClient } from "./client.js";
|
|
2
|
+
export type { GraverseClient } from "./client.js";
|
|
3
|
+
export { hubClient } from "./client.js";
|
|
4
|
+
export type { Chosen, Space, SpaceHost, SpaceView } from "./space-host.js";
|
|
5
|
+
export interface GraverseOptions {
|
|
6
|
+
/** How the page asks the hub; the page's own origin unless told. */
|
|
7
|
+
readonly client?: GraverseClient;
|
|
8
|
+
/** Draw the space when the browser can (`auto`), or never (`false`). */
|
|
9
|
+
readonly space?: "auto" | false;
|
|
10
|
+
/** Where a link goes: the browser's address unless told. */
|
|
11
|
+
readonly go?: (url: string) => void;
|
|
12
|
+
/** Today, for how lately things changed: now unless told. */
|
|
13
|
+
readonly today?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Graverse {
|
|
16
|
+
/** Settles once the universe is described and the page drawn. */
|
|
17
|
+
readonly ready: Promise<void>;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
/** Whether this browser can draw WebGL at all: asked of a canvas nobody sees. */
|
|
21
|
+
export declare function canDrawSpace(): boolean;
|
|
22
|
+
export declare function mountGraverse(root: HTMLElement, options?: GraverseOptions): Graverse;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAsB7D,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,wEAAwE;IACxE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAChC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;CACjB;AAiBD,iFAAiF;AACjF,wBAAgB,YAAY,IAAI,OAAO,CAOtC;AASD,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAujBxF"}
|