@kalyptos/narcissus 0.0.0-stage → 0.1.0
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 +28 -0
- package/README.md +45 -2
- package/dist/adapters/disk.d.ts +3 -0
- package/dist/adapters/files.d.ts +3 -0
- package/dist/adapters/http.d.ts +3 -0
- package/dist/adapters/memory.d.ts +3 -0
- package/dist/adapters/opfs.d.ts +9 -0
- package/dist/cli/export.d.ts +1 -0
- package/dist/cli/info.d.ts +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +151 -0
- package/dist/cli/publish.d.ts +2 -0
- package/dist/cli/shared.d.ts +8 -0
- package/dist/cli/validate.d.ts +1 -0
- package/dist/controls/controls.d.ts +22 -0
- package/dist/controls/index.d.ts +2 -0
- package/dist/controls/pose.d.ts +65 -0
- package/dist/controls-5FaXzanr.js +2633 -0
- package/dist/element/index.d.ts +27 -0
- package/dist/element/index.js +107 -0
- package/dist/engine/engine.d.ts +73 -0
- package/dist/engine/gpu/buffers.d.ts +22 -0
- package/dist/engine/gpu/cull.d.ts +8 -0
- package/dist/engine/gpu/device.d.ts +12 -0
- package/dist/engine/gpu/fullscreen.d.ts +7 -0
- package/dist/engine/gpu/heights.d.ts +12 -0
- package/dist/engine/gpu/layout.d.ts +24 -0
- package/dist/engine/gpu/pool.d.ts +44 -0
- package/dist/engine/gpu/present.d.ts +3 -0
- package/dist/engine/gpu/project.d.ts +18 -0
- package/dist/engine/gpu/raster.d.ts +19 -0
- package/dist/engine/gpu/renderer.d.ts +39 -0
- package/dist/engine/gpu/sort.d.ts +13 -0
- package/dist/engine/gpu/timing.d.ts +18 -0
- package/dist/engine/index.d.ts +10 -0
- package/dist/engine/math/frustum.d.ts +5 -0
- package/dist/engine/math/mat4.d.ts +13 -0
- package/dist/engine/plan/cut.d.ts +46 -0
- package/dist/engine/plan/draw.d.ts +16 -0
- package/dist/engine/plan/footprint.d.ts +13 -0
- package/dist/engine/plugin.d.ts +52 -0
- package/dist/engine/plugins/dof.d.ts +3 -0
- package/dist/engine/plugins/fog.d.ts +3 -0
- package/dist/engine/plugins/grade.d.ts +3 -0
- package/dist/engine/quality.d.ts +10 -0
- package/dist/engine/stream/feed.d.ts +27 -0
- package/dist/engine/stream/jobs.d.ts +18 -0
- package/dist/engine/stream/loader.d.ts +22 -0
- package/dist/engine/stream/remote.d.ts +24 -0
- package/dist/engine/stream/scheduler.d.ts +43 -0
- package/dist/engine/stream/synthetic.d.ts +5 -0
- package/dist/engine/stream/worker.d.ts +43 -0
- package/dist/engine/types.d.ts +51 -0
- package/dist/engine/world/tree.d.ts +54 -0
- package/dist/format/col.d.ts +5 -0
- package/dist/format/encode.d.ts +41 -0
- package/dist/format/hash.d.ts +2 -0
- package/dist/format/idx.d.ts +16 -0
- package/dist/format/index.d.ts +9 -0
- package/dist/format/index.js +1 -0
- package/dist/format/inflate.d.ts +4 -0
- package/dist/format/page.d.ts +25 -0
- package/dist/format/spec.d.ts +57 -0
- package/dist/format/types.d.ts +78 -0
- package/dist/format/world.d.ts +5 -0
- package/dist/format-CxKTIugr.js +905 -0
- package/dist/http-DL7R39Nc.js +14 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +81 -0
- package/dist/ports-DZRKjdYD.js +6 -0
- package/dist/ports.d.ts +11 -0
- package/dist/synthetic-BZcHRI1P.js +383 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/info.d.ts +15 -0
- package/dist/tools/ply.d.ts +18 -0
- package/dist/tools/validate.d.ts +25 -0
- package/dist/tools/walk.d.ts +15 -0
- package/dist/tools-DwOGah9N.js +242 -0
- package/docs/format.md +166 -0
- package/package.json +58 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Kalyptos
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# narcissus
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The open library for Guldmund Trees: gaussian-splat scenes of any size, stored as static files and streamed by range request. narcissus holds the format, a WebGPU engine that draws it, a viewer element, and tools to check and publish a world.
|
|
4
|
+
|
|
5
|
+
## Show a world
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<script
|
|
9
|
+
type="module"
|
|
10
|
+
src="https://cdn.jsdelivr.net/npm/@kalyptos/narcissus/dist/element/index.js"
|
|
11
|
+
></script>
|
|
12
|
+
<narcissus-viewer
|
|
13
|
+
src="https://example.com/world/world.json"
|
|
14
|
+
style="height: 100vh"
|
|
15
|
+
></narcissus-viewer>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or with a bundler:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install @kalyptos/narcissus
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createEngine, Controls } from '@kalyptos/narcissus';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Check and publish a world
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx @kalyptos/narcissus validate ./world --deep
|
|
32
|
+
npx @kalyptos/narcissus info ./world
|
|
33
|
+
npx @kalyptos/narcissus export ./world -o level3.ply --level 3
|
|
34
|
+
npx @kalyptos/narcissus publish ./world remote:bucket/world
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Read more
|
|
38
|
+
|
|
39
|
+
- [docs/format.md](docs/format.md): the specification of Guldmund Trees
|
|
40
|
+
- [docs/hosting.md](docs/hosting.md): how to serve, publish and show a world
|
|
41
|
+
- [docs/architecture.md](docs/architecture.md): how the code is built, and how to add a source or a plugin
|
|
42
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
43
|
+
|
|
44
|
+
## Licence
|
|
45
|
+
|
|
46
|
+
[BSD-3-Clause](LICENSE).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Cache } from '../ports.ts';
|
|
2
|
+
/**
|
|
3
|
+
* a Cache in the origin private file system, least recently used first past bytes; null when the
|
|
4
|
+
* browser offers none (private windows); every failure inside is a miss, never an error.
|
|
5
|
+
* shard k keeps its files in cache/k and must be their only user.
|
|
6
|
+
*/
|
|
7
|
+
export declare function opfsCache(bytes: number, shard: number): Promise<Cache | null>;
|
|
8
|
+
/** removes everything in cache/ but the directories of shards 0 to shards - 1; never fails */
|
|
9
|
+
export declare function pruneOpfs(shards: number): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function exportWorld(args: string[]): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function info(args: string[]): Promise<number>;
|
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as e } from "../ports-DZRKjdYD.js";
|
|
3
|
+
import { t } from "../http-DL7R39Nc.js";
|
|
4
|
+
import { a as n, r, t as i } from "../tools-DwOGah9N.js";
|
|
5
|
+
import { createWriteStream as a, statSync as o } from "node:fs";
|
|
6
|
+
import { pipeline as s } from "node:stream/promises";
|
|
7
|
+
import { parseArgs as c } from "node:util";
|
|
8
|
+
import { resolve as l } from "node:path";
|
|
9
|
+
import { open as u } from "node:fs/promises";
|
|
10
|
+
import { spawn as d } from "node:child_process";
|
|
11
|
+
import { once as f } from "node:events";
|
|
12
|
+
//#region src/adapters/disk.ts
|
|
13
|
+
var p = async (t, n) => {
|
|
14
|
+
let r = await u(t).catch((n) => {
|
|
15
|
+
throw n.code === "ENOENT" ? new e(`no file ${t}`) : n;
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
if (!n) return new Uint8Array(await r.readFile());
|
|
19
|
+
let e = new Uint8Array(n[1] - n[0]), { bytesRead: t } = await r.read(e, 0, e.length, n[0]);
|
|
20
|
+
return e.subarray(0, t);
|
|
21
|
+
} finally {
|
|
22
|
+
await r.close();
|
|
23
|
+
}
|
|
24
|
+
}, m = /^https?:\/\//;
|
|
25
|
+
function h(e) {
|
|
26
|
+
if (m.test(e)) return {
|
|
27
|
+
source: t,
|
|
28
|
+
url: e.endsWith("/") ? `${e}world.json` : e,
|
|
29
|
+
remote: !0
|
|
30
|
+
};
|
|
31
|
+
let n = l(e).replaceAll("\\", "/");
|
|
32
|
+
return {
|
|
33
|
+
source: p,
|
|
34
|
+
url: o(n, { throwIfNoEntry: !1 })?.isDirectory() ? `${n}/world.json` : n,
|
|
35
|
+
remote: !1
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function g(e) {
|
|
39
|
+
let t = [
|
|
40
|
+
"bytes",
|
|
41
|
+
"KiB",
|
|
42
|
+
"MiB",
|
|
43
|
+
"GiB",
|
|
44
|
+
"TiB"
|
|
45
|
+
], n = Math.min(t.length - 1, Math.floor(Math.log2(Math.max(e, 1)) / 10));
|
|
46
|
+
return `${n === 0 ? e : (e / 2 ** (10 * n)).toFixed(1)} ${t[n]}`;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/cli/export.ts
|
|
50
|
+
var _ = "usage: narcissus export <world> -o <file.ply> [--level <g>] [--box <w,s,e,n>]";
|
|
51
|
+
async function v(e) {
|
|
52
|
+
let { values: t, positionals: n } = c({
|
|
53
|
+
args: e,
|
|
54
|
+
options: {
|
|
55
|
+
out: {
|
|
56
|
+
type: "string",
|
|
57
|
+
short: "o"
|
|
58
|
+
},
|
|
59
|
+
level: {
|
|
60
|
+
type: "string",
|
|
61
|
+
default: "0"
|
|
62
|
+
},
|
|
63
|
+
box: { type: "string" }
|
|
64
|
+
},
|
|
65
|
+
allowPositionals: !0
|
|
66
|
+
}), r = Number(t.level), o = t.box?.split(",").map(Number), l = Number.isInteger(r) && r >= 0 && (!o || o.length === 4 && o.every(Number.isFinite));
|
|
67
|
+
if (n.length !== 1 || !t.out || !l) throw Error(_);
|
|
68
|
+
let { source: u, url: d } = h(n[0]), f = a(t.out);
|
|
69
|
+
return await s(i(u, d, {
|
|
70
|
+
level: r,
|
|
71
|
+
box: o
|
|
72
|
+
}), f), console.log(`${t.out}: ${g(f.bytesWritten)}`), 0;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/cli/info.ts
|
|
76
|
+
async function y(e) {
|
|
77
|
+
let { positionals: t } = c({
|
|
78
|
+
args: e,
|
|
79
|
+
allowPositionals: !0
|
|
80
|
+
});
|
|
81
|
+
if (t.length !== 1) throw Error("usage: narcissus info <world>");
|
|
82
|
+
let { source: n, url: i } = h(t[0]), { world: a, units: o, levels: s, bytes: l } = await r(n, i), { e: u, n: d, h: f } = a.extent, p = (e) => e.toLocaleString("en-US");
|
|
83
|
+
return console.log(`version ${a.version}`), console.log(`crs ${a.crs}, heights in ${a.height}`), console.log(`extent e ${u[0]} to ${u[1]}, n ${d[0]} to ${d[1]}, h ${f[0]} to ${f[1]}`), console.log(`roots ${a.roots.length}`), console.log(`packs ${g(l)}`), o.forEach((e, t) => console.log(`units level ${t}: ${p(e)}`)), s.forEach(({ pages: e, splats: t }, n) => {
|
|
84
|
+
console.log(`splats level ${n}: ${p(t)} in ${p(e)} pages`);
|
|
85
|
+
}), 0;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/cli/validate.ts
|
|
89
|
+
async function b(e) {
|
|
90
|
+
let { values: t, positionals: r } = c({
|
|
91
|
+
args: e,
|
|
92
|
+
options: { deep: {
|
|
93
|
+
type: "boolean",
|
|
94
|
+
default: !1
|
|
95
|
+
} },
|
|
96
|
+
allowPositionals: !0
|
|
97
|
+
});
|
|
98
|
+
if (r.length !== 1) throw Error("usage: narcissus validate <world> [--deep]");
|
|
99
|
+
let { source: i, url: a, remote: o } = h(r[0]), s = process.stderr.isTTY, l = await n(i, a, {
|
|
100
|
+
deep: t.deep,
|
|
101
|
+
server: o,
|
|
102
|
+
progress: s ? ({ units: e }) => process.stderr.write(`\r${e} units`) : void 0
|
|
103
|
+
});
|
|
104
|
+
s && process.stderr.write("\r\x1B[K");
|
|
105
|
+
for (let { path: e, fault: t } of l.faults) console.log(`${e}: ${t}`);
|
|
106
|
+
let u = l.faults.length, d = u === 0 ? "no faults" : `${u} ${u === 1 ? "fault" : "faults"}`;
|
|
107
|
+
return console.log(`${l.units} units, ${l.files} files, ${g(l.bytes)}: ${d}`), u === 0 ? 0 : 1;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/cli/publish.ts
|
|
111
|
+
var x = "usage: narcissus publish <folder> <remote:path> [--url <world.json url>] [-- <rclone flags>]", S = "public, max-age=31536000, immutable", C = "no-cache", w = (e) => ["--header-upload", `Cache-Control: ${e}`];
|
|
112
|
+
async function T(e) {
|
|
113
|
+
console.log(`rclone ${e.join(" ")}`);
|
|
114
|
+
let t = d("rclone", e, { stdio: "inherit" }), [n] = await f(t, "exit").catch((e) => {
|
|
115
|
+
throw e.code === "ENOENT" ? Error("rclone is not installed: https://rclone.org/install/") : e;
|
|
116
|
+
});
|
|
117
|
+
if (n !== 0) throw Error(`rclone ended with code ${n}`);
|
|
118
|
+
}
|
|
119
|
+
async function E(e) {
|
|
120
|
+
let t = e.indexOf("--"), n = t < 0 ? [] : e.slice(t + 1), { values: r, positionals: i } = c({
|
|
121
|
+
args: t < 0 ? e : e.slice(0, t),
|
|
122
|
+
options: { url: { type: "string" } },
|
|
123
|
+
allowPositionals: !0
|
|
124
|
+
});
|
|
125
|
+
if (i.length !== 2) throw Error(x);
|
|
126
|
+
let [a, o] = i.map((e) => e.replace(/\/+$/, ""));
|
|
127
|
+
return await b([a]) === 0 ? (await T([
|
|
128
|
+
"copy",
|
|
129
|
+
`${a}/u`,
|
|
130
|
+
`${o}/u`,
|
|
131
|
+
"--immutable",
|
|
132
|
+
...w(S),
|
|
133
|
+
...n
|
|
134
|
+
]), await T([
|
|
135
|
+
"copyto",
|
|
136
|
+
`${a}/world.json`,
|
|
137
|
+
`${o}/world.json`,
|
|
138
|
+
...w(C),
|
|
139
|
+
...n
|
|
140
|
+
]), r.url ? b([r.url]) : 0) : 1;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/cli/main.ts
|
|
144
|
+
var D = "usage: narcissus <command>\n\n validate <world> [--deep]\n checks every file of a world; --deep also reads every pack whole\n info <world>\n what a world holds\n export <world> -o <file.ply> [--level <g>] [--box <w,s,e,n>]\n one level as a gaussian-splat ply\n publish <folder> <remote:path> [--url <world.json url>] [-- <rclone flags>]\n uploads a world with rclone, unit files first\n\n <world> is a folder, a world.json path or an http(s) url", O = {
|
|
145
|
+
validate: b,
|
|
146
|
+
info: y,
|
|
147
|
+
export: v,
|
|
148
|
+
publish: E
|
|
149
|
+
}, [k, ...A] = process.argv.slice(2), j = O[k];
|
|
150
|
+
j ? process.exitCode = await j(A).catch((e) => (console.error(e instanceof Error ? e.message : String(e)), 1)) : (console.error(D), process.exitCode = k === void 0 || k === "help" || k === "--help" ? 0 : 1);
|
|
151
|
+
//#endregion
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Fetch } from '../ports.ts';
|
|
2
|
+
/** the source and world.json url of a world named by a url, a folder or a world.json path */
|
|
3
|
+
export declare function target(world: string): {
|
|
4
|
+
source: Fetch;
|
|
5
|
+
url: string;
|
|
6
|
+
remote: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function size(bytes: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validate(args: string[]): Promise<number>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Engine } from '../engine/index.ts';
|
|
2
|
+
import { type Limits, type Pose } from './pose.ts';
|
|
3
|
+
type Ground = (e: number, n: number) => number;
|
|
4
|
+
/** metres one screen pixel spans at dist in a view pixels tall */
|
|
5
|
+
export declare function metresPerPixel(dist: number, pixels: number): number;
|
|
6
|
+
/** right, forward and up from the held key codes */
|
|
7
|
+
export declare function flyAxes(keys: ReadonlySet<string>): [number, number, number];
|
|
8
|
+
/** moves the shown pose toward the target over dt seconds; the target itself once settled */
|
|
9
|
+
export declare function smooth(shown: Pose, target: Pose, dt: number, ground: Ground, limits?: Limits): Pose;
|
|
10
|
+
/** map camera: left drag orbits, right/middle/shift drag pans the ground, wheel zooms, f flies */
|
|
11
|
+
export declare class Controls {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(canvas: HTMLCanvasElement, engine: Engine, ground: Ground, pose: Pose, limits?: Limits);
|
|
14
|
+
/** the pose the camera shows now */
|
|
15
|
+
get pose(): Pose;
|
|
16
|
+
/** fires on every frame the user moves the camera */
|
|
17
|
+
onChange(fn: () => void): () => void;
|
|
18
|
+
/** puts the focus on a ground point; heading and tilt stay, a far view closes in */
|
|
19
|
+
moveTo(e: number, n: number): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Camera, World } from '../engine/index.ts';
|
|
2
|
+
/** easting, northing and height in world coordinates, metres */
|
|
3
|
+
export interface Point {
|
|
4
|
+
e: number;
|
|
5
|
+
n: number;
|
|
6
|
+
h: number;
|
|
7
|
+
}
|
|
8
|
+
/** a camera orbiting a focus point, in world coordinates */
|
|
9
|
+
export interface Pose extends Point {
|
|
10
|
+
/** degrees clockwise from north, the direction the camera looks */
|
|
11
|
+
yaw: number;
|
|
12
|
+
/** degrees, negative looks down */
|
|
13
|
+
pitch: number;
|
|
14
|
+
/** metres from camera to focus */
|
|
15
|
+
dist: number;
|
|
16
|
+
}
|
|
17
|
+
/** vertical field of view, degrees */
|
|
18
|
+
export declare const FOV = 45;
|
|
19
|
+
export declare const defaultView: {
|
|
20
|
+
yaw: number;
|
|
21
|
+
pitch: number;
|
|
22
|
+
dist: number;
|
|
23
|
+
};
|
|
24
|
+
/** how far a pose may go */
|
|
25
|
+
export interface Limits {
|
|
26
|
+
/** degrees */
|
|
27
|
+
pitch: readonly [number, number];
|
|
28
|
+
/** metres from camera to focus */
|
|
29
|
+
dist: readonly [number, number];
|
|
30
|
+
/** metres the camera stays above the ground under it */
|
|
31
|
+
clearance: number;
|
|
32
|
+
/** the lowest height of the camera */
|
|
33
|
+
floor: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const LIMITS: Limits;
|
|
36
|
+
/** the extent's centre when a root unit covers it, else the middle of the root unit nearest it, clipped to the extent */
|
|
37
|
+
export declare function opening({ leaf, roots, extent }: Pick<World, 'leaf' | 'roots' | 'extent'>): Point;
|
|
38
|
+
/** a pose from its text E,N,H,yaw,pitch,dist, as formatPose writes it; null when it is not one */
|
|
39
|
+
export declare function parsePose(text: string): Pose | null;
|
|
40
|
+
export declare function formatPose(p: Pose): string;
|
|
41
|
+
export declare function clampPose(p: Pose, ground?: (e: number, n: number) => number, limits?: Limits): Pose;
|
|
42
|
+
export declare function cameraOf(p: Pose): Point;
|
|
43
|
+
/** the engine camera that shows a pose */
|
|
44
|
+
export declare function viewOf(p: Pose): Camera;
|
|
45
|
+
/** a place on screen in viewport heights from the centre, x right and y down */
|
|
46
|
+
export interface Spot {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}
|
|
50
|
+
/** where a world point shows in p's view; fov vertical in degrees */
|
|
51
|
+
export declare function project(p: Pose, fov: number, at: Point): Spot;
|
|
52
|
+
/** the pose of a camera at from looking at to; yaw is 0 when looking straight down */
|
|
53
|
+
export declare function lookAt(from: Point, to: Point): Pose;
|
|
54
|
+
/** turns the view to yaw and pitch about the camera, which stays put */
|
|
55
|
+
export declare function look(p: Pose, yaw: number, pitch: number, limits?: Limits): Pose;
|
|
56
|
+
/** camera height above the focus, floored so a level view still has a scale */
|
|
57
|
+
export declare function height(p: Pose): number;
|
|
58
|
+
/** moves focus and camera together; right and forward follow the heading, metres */
|
|
59
|
+
export declare function fly(p: Pose, right: number, forward: number, up: number): Pose;
|
|
60
|
+
/** slides along the ground; metres of screen at the focus, so forward stretches as the view flattens */
|
|
61
|
+
export declare function pan(p: Pose, right: number, forward: number): Pose;
|
|
62
|
+
/** moves a toward b by fraction t: focus linearly, yaw the short way round, dist in log space */
|
|
63
|
+
export declare function blend(a: Pose, b: Pose, t: number): Pose;
|
|
64
|
+
/** close enough that the rest of the way is not visible */
|
|
65
|
+
export declare function settled(a: Pose, b: Pose): boolean;
|