@n3rdw1z4rd/core 0.24.0 → 0.26.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.
Files changed (54) hide show
  1. package/README.md +45 -0
  2. package/dist/astar.js +3 -3
  3. package/dist/desktop.d.ts +37 -0
  4. package/dist/desktop.js +14 -0
  5. package/dist/dungeon-generator.js +4 -4
  6. package/dist/electron/after-pack.cjs +17 -0
  7. package/dist/electron/index.d.ts +110 -0
  8. package/dist/electron/index.js +257 -0
  9. package/dist/electron/preload.cjs +12 -0
  10. package/dist/electron/updater.d.ts +81 -0
  11. package/dist/electron/updater.js +133 -0
  12. package/dist/electron.cjs +416 -0
  13. package/dist/electron.d.cts +189 -0
  14. package/dist/graph/index.d.ts +21 -0
  15. package/dist/graph/subgraph.js +1 -1
  16. package/dist/graph.cjs +2 -2
  17. package/dist/graph.d.cts +21 -0
  18. package/dist/index.cjs +25 -11
  19. package/dist/index.d.cts +48 -0
  20. package/dist/index.d.ts +13 -1
  21. package/dist/index.js +2 -1
  22. package/dist/map2d.js +2 -2
  23. package/dist/math.js +2 -2
  24. package/dist/{rng-edL6atS3.cjs → rng-BtvhTJmM.cjs} +2 -2
  25. package/dist/{spatial-partition-3d-D1uyJVhM.cjs → spatial-partition-3d-qhjqIpcy.cjs} +1 -1
  26. package/dist/three/adaptive-grid.d.ts +1 -1
  27. package/dist/three/adaptive-grid.js +1 -1
  28. package/dist/three/asteroid-mesh.d.ts +1 -1
  29. package/dist/three/camera-rig.js +1 -1
  30. package/dist/three/cube-sphere-geometry.d.ts +1 -1
  31. package/dist/three/index.d.ts +13 -2
  32. package/dist/three/particle-system-3d.js +1 -1
  33. package/dist/three/picking.d.ts +1 -1
  34. package/dist/three/picking.js +1 -1
  35. package/dist/three/starfield.js +4 -4
  36. package/dist/three/texture-atlas.d.ts +1 -1
  37. package/dist/three/texture-atlas.js +1 -1
  38. package/dist/three/texture-utils.js +2 -4
  39. package/dist/three/voxel-geometry.d.ts +44 -10
  40. package/dist/three/voxel-geometry.js +282 -77
  41. package/dist/three/voxel-mesh.d.ts +1 -1
  42. package/dist/three/voxel-mesh.js +1 -1
  43. package/dist/three/world.d.ts +1 -1
  44. package/dist/three/world.js +1 -1
  45. package/dist/three.cjs +290 -87
  46. package/dist/three.d.cts +55 -10
  47. package/dist/vite.cjs +124 -0
  48. package/dist/vite.d.cts +53 -2
  49. package/dist/vite.d.ts +53 -2
  50. package/dist/vite.js +122 -1
  51. package/dist/webgl.js +2 -2
  52. package/package.json +23 -3
  53. package/dist/input/_input.d.ts +0 -23
  54. package/dist/input/_input.js +0 -96
@@ -0,0 +1,189 @@
1
+ /**
2
+ * The Electron main process for a web build as a desktop app: the build served over its own
3
+ * `app://` origin (so workers, fetch and localStorage behave as on the web), one window, one copy
4
+ * of the app at a time, links kept out of it, localStorage written to disk before quitting, and
5
+ * optionally updating itself from the site the web build is on.
6
+ *
7
+ * ```js
8
+ * // electron/main.mjs (package.json: "main": "electron/main.mjs")
9
+ * import { createDesktopApp } from '@n3rdw1z4rd/core/electron';
10
+ *
11
+ * createDesktopApp({
12
+ * title: 'My Game',
13
+ * root: new URL('../dist/', import.meta.url),
14
+ * update: { site: 'https://my-game.example.com' },
15
+ * });
16
+ * ```
17
+ *
18
+ * The page gets {@link Desktop} as `window.desktop` (see `desktop` in the main entry point). The
19
+ * packaged app needs `@n3rdw1z4rd/core` at run time: list it in `dependencies`. Node-only: not
20
+ * exported from the package root.
21
+ *
22
+ * @packageDocumentation
23
+ * @module @n3rdw1z4rd/core/electron
24
+ */
25
+ import { BrowserWindow, MenuItemConstructorOptions } from "electron";
26
+ /**
27
+ * A build's `version.json`, as {@link buildManifest} (in `@n3rdw1z4rd/core/vite`) writes it: which
28
+ * build it is, when it was built, the desktop API level it needs, and every file in it.
29
+ *
30
+ * @category Desktop
31
+ */
32
+ export interface BuildManifest {
33
+ /** the build's id, e.g. "0.7.0-6ae4707": letters, digits, dots and dashes (it names a folder) */
34
+ version: string;
35
+ /** ISO time it was built: a build is newer if it was built later */
36
+ builtAt: string;
37
+ /** the desktop API level it needs (the app's `api` must be at least this); default 1 */
38
+ needs?: number;
39
+ /** every file but version.json itself, paths relative to the build, with `/` */
40
+ files: {
41
+ path: string;
42
+ size: number;
43
+ sha256: string;
44
+ }[];
45
+ }
46
+ /** A build to run: its folder and its manifest (without `files` if it has no version.json: a dev build). */
47
+ export interface PickedBuild {
48
+ dir: string;
49
+ info: Pick<BuildManifest, 'version' | 'builtAt'> & Partial<BuildManifest>;
50
+ }
51
+ /** The part of `fetch`'s response the updater uses. */
52
+ export interface FetchLike {
53
+ (url: string, init: {
54
+ signal: AbortSignal;
55
+ cache?: 'no-store';
56
+ }): Promise<{
57
+ ok: boolean;
58
+ status: number;
59
+ arrayBuffer(): Promise<ArrayBuffer>;
60
+ }>;
61
+ }
62
+ export interface UpdateOptions {
63
+ /** where builds come from: https://host[:port] (http only for localhost) */
64
+ site: string;
65
+ /** where downloaded builds are kept: one folder each, and current.json naming the one to run */
66
+ store: string;
67
+ /** the build running now */
68
+ current: PickedBuild;
69
+ /** the folder of the build that came with the app (never deleted) */
70
+ bundledDir: string;
71
+ /** this app's desktop API level */
72
+ api: number;
73
+ fetch: FetchLike;
74
+ /** ms to wait for version.json; default 15000 (each file gets 60000) */
75
+ timeout?: number;
76
+ log?: (message: string) => void;
77
+ }
78
+ export type UpdateResult = {
79
+ status: 'updated';
80
+ version: string;
81
+ } | {
82
+ status: 'up-to-date' | 'not-newer' | 'needs-newer-app' | 'unavailable' | 'failed';
83
+ reason: string;
84
+ };
85
+ /** Whether `site` is one builds may come from: https, or http on localhost (for tests). */
86
+ export declare function isUpdateSite(site: string): boolean;
87
+ /** A build folder's manifest, if the build is complete (version.json is written last). */
88
+ export declare function readBuild(dir: string): BuildManifest | undefined;
89
+ /**
90
+ * The build to run: the downloaded one `store/current.json` names, if it's complete, works with
91
+ * this app's `api` and is no older than the bundled one (a rebuilt app brings a newer build);
92
+ * otherwise the bundled one.
93
+ */
94
+ export declare function pickBuild(options: {
95
+ bundledDir: string;
96
+ store: string;
97
+ api: number;
98
+ bundledOnly?: boolean;
99
+ }): PickedBuild;
100
+ /**
101
+ * Looks for a newer build on `site`. If there is one (built later than the one running, and not
102
+ * needing a newer app), downloads all of it into a folder of its own, checks every file's size
103
+ * and SHA-256, and only then makes it current (current.json), keeping the build that was running
104
+ * and removing older ones. Anything wrong (offline, a bad file) and nothing changes.
105
+ */
106
+ export declare function downloadUpdate(options: UpdateOptions): Promise<UpdateResult>;
107
+ /** @category Desktop */
108
+ export interface DesktopAppOptions {
109
+ /** the window's title, and the name on log lines */
110
+ title: string;
111
+ /** the bundled web build: a folder with index.html (a path, or a file: URL) */
112
+ root: string | URL;
113
+ /**
114
+ * the host of the page's origin, `app://<host>`. The page's localStorage belongs to its
115
+ * origin: changing this later loses what's saved. Default `'app'`.
116
+ */
117
+ host?: string;
118
+ /**
119
+ * `'game'` (default): full-screen the first time, then as it was left; sound without a click
120
+ * first; full speed when the window is behind another one. `'app'`: windowed, and Chromium's
121
+ * usual throttling in the background.
122
+ */
123
+ profile?: 'game' | 'app';
124
+ window?: {
125
+ width?: number;
126
+ height?: number;
127
+ minWidth?: number;
128
+ minHeight?: number;
129
+ /** shown before the page draws; default '#000000' */
130
+ backgroundColor?: string;
131
+ /** relative to `root`; default 'icon-512.png' (if it's there) */
132
+ icon?: string;
133
+ /** `'remember'`: as it was left (F11, or `desktop.toggleFullscreen()`), `first` the first time. Default: `'game'` remembers (full-screen first), `'app'` doesn't */
134
+ fullscreen?: boolean | {
135
+ remember: true;
136
+ first: boolean;
137
+ };
138
+ };
139
+ /** the window's menu; default none */
140
+ menu?: MenuItemConstructorOptions[] | null;
141
+ /** links out of the app: `'browser'` (default) opens https links in the user's browser, `'deny'` opens nothing */
142
+ links?: 'browser' | 'deny';
143
+ /** draw WebGL in software (SwiftShader) where Chromium finds no usable graphics card, rather than not at all. Default true */
144
+ softwareWebGL?: boolean;
145
+ /** the site the page is told about (`desktop.site`); default `update.site` */
146
+ site?: string;
147
+ /**
148
+ * Updating itself from `site`: at start-up it runs the newest complete build it has (one it
149
+ * downloaded, or the bundled one), then looks for a newer one, downloads and checks it, and
150
+ * reloads into it. `--no-update` turns that off for one run, `--bundled` runs the bundled build.
151
+ * Needs `version.json` in each build: see `buildManifest()` in `@n3rdw1z4rd/core/vite`.
152
+ */
153
+ update?: false | {
154
+ /** https://host[:port] the builds come from */
155
+ site: string;
156
+ /** this app's desktop API level: a build that needs more waits for a rebuilt app. Default 1 */
157
+ api?: number;
158
+ /** folder in the app's user data for downloaded builds; default 'builds' */
159
+ folder?: string;
160
+ /** check as soon as the window opens; default true (`desktop.update()` checks any time) */
161
+ onStart?: boolean;
162
+ };
163
+ /** environment variable that overrides the site (update and `desktop.site`) for testing, e.g. 'MY_GAME_SITE' */
164
+ siteEnv?: string;
165
+ /** environment variable that, set to 1, starts windowed (as `--windowed` does) */
166
+ windowedEnv?: string;
167
+ /** the preload script; default core's (which gives the page {@link Desktop}) */
168
+ preload?: string;
169
+ }
170
+ /** What {@link createDesktopApp} returns. */
171
+ export interface DesktopApp {
172
+ /** resolves with the window once it's open */
173
+ readonly ready: Promise<BrowserWindow>;
174
+ /** the window, once it's open */
175
+ readonly window: BrowserWindow | undefined;
176
+ /** the build running now */
177
+ readonly build: PickedBuild;
178
+ /** look for a newer build now; got one: switch to it and reload. Resolves true if it did */
179
+ checkForUpdate(): Promise<boolean>;
180
+ /** to the console and to desktop.log in the app's user data folder */
181
+ log(message: string): void;
182
+ }
183
+ /**
184
+ * Starts the desktop app. Call it once, straight away at start-up (it registers the `app://`
185
+ * scheme, which Electron only allows before the app is ready).
186
+ *
187
+ * @category Desktop
188
+ */
189
+ export declare function createDesktopApp(options: DesktopAppOptions): DesktopApp;
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Node graphs: a graph document format, typed pins, node types (built-in or written as
3
+ * scripts), and a lazy, memoized evaluator with list broadcasting. No DOM: runs in a page,
4
+ * a worker or Node.
5
+ *
6
+ * ```ts
7
+ * import { createGraph, createNodeRegistry, addNode, connect, GraphEvaluator } from '@n3rdw1z4rd/core/graph';
8
+ *
9
+ * const nodes = createNodeRegistry();
10
+ * const graph = createGraph();
11
+ * const grid = addNode(graph, nodes.get('list/grid2d')!, [0, 0], { cols: 3, rows: 2 });
12
+ * const count = addNode(graph, nodes.get('list/count')!, [240, 0]);
13
+ * connect(graph, nodes, { node: grid.id, port: 'points' }, { node: count.id, port: 'list' });
14
+ *
15
+ * const { results } = await new GraphEvaluator(nodes).evaluate(graph);
16
+ * results.get(count.id)!.outputs.count; // 6
17
+ * ```
18
+ *
19
+ * @packageDocumentation
20
+ * @module @n3rdw1z4rd/core/graph
21
+ */
1
22
  import { ConnectCheck, GRAPH_FORMAT, GRAPH_VERSION, GraphDoc, GraphGroup, GraphLink, GraphNode, PortRef, SubgraphDef, addNode, canConnect, connect, createGraph, disconnect, getNode, graphId, linkInto, linksInto, normalizeGraph, removeNode } from "./doc.js";
2
23
  import { EvaluateOptions, EvaluateResult, FrameInfo, GraphEvaluator, NodeResult, OUTPUT_LISTS } from "./evaluate.js";
3
24
  import { NodeDef, NodeRegistry, NodeSpec, Param, ParamSpec, Port, PortSpec, RunContext, RunFn, WidgetSpec, defineNode } from "./node.js";
@@ -168,7 +168,7 @@ function collapseToSubgraph(doc, registry, nodeIds, title = "Subgraph") {
168
168
  from: { ...l.from }
169
169
  });
170
170
  }
171
- let minX = Infinity, minY = Infinity, sumX = 0, sumY = 0;
171
+ let minX = 1e400, minY = 1e400, sumX = 0, sumY = 0;
172
172
  for (const n of inside) {
173
173
  minX = Math.min(minX, n.pos[0]);
174
174
  minY = Math.min(minY, n.pos[1]);
package/dist/graph.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rng = require("./rng-edL6atS3.cjs");
2
+ const require_rng = require("./rng-BtvhTJmM.cjs");
3
3
  // src/graph/types.ts
4
4
  /** @category Graph */
5
5
  function parseType(type) {
@@ -1528,7 +1528,7 @@ function collapseToSubgraph(doc, registry, nodeIds, title = "Subgraph") {
1528
1528
  from: { ...l.from }
1529
1529
  });
1530
1530
  }
1531
- let minX = Infinity, minY = Infinity, sumX = 0, sumY = 0;
1531
+ let minX = 1e400, minY = 1e400, sumX = 0, sumY = 0;
1532
1532
  for (const n of inside) {
1533
1533
  minX = Math.min(minX, n.pos[0]);
1534
1534
  minY = Math.min(minY, n.pos[1]);
package/dist/graph.d.cts CHANGED
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Node graphs: a graph document format, typed pins, node types (built-in or written as
3
+ * scripts), and a lazy, memoized evaluator with list broadcasting. No DOM: runs in a page,
4
+ * a worker or Node.
5
+ *
6
+ * ```ts
7
+ * import { createGraph, createNodeRegistry, addNode, connect, GraphEvaluator } from '@n3rdw1z4rd/core/graph';
8
+ *
9
+ * const nodes = createNodeRegistry();
10
+ * const graph = createGraph();
11
+ * const grid = addNode(graph, nodes.get('list/grid2d')!, [0, 0], { cols: 3, rows: 2 });
12
+ * const count = addNode(graph, nodes.get('list/count')!, [240, 0]);
13
+ * connect(graph, nodes, { node: grid.id, port: 'points' }, { node: count.id, port: 'list' });
14
+ *
15
+ * const { results } = await new GraphEvaluator(nodes).evaluate(graph);
16
+ * results.get(count.id)!.outputs.count; // 6
17
+ * ```
18
+ *
19
+ * @packageDocumentation
20
+ * @module @n3rdw1z4rd/core/graph
21
+ */
1
22
  /**
2
23
  * Pin types. A type is a name (`number`, `vec2`, your own…) with a color for the editor;
3
24
  * a trailing `[]` in a port declaration (`vec2[]`) makes the port a **list port** — it takes
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rng = require("./rng-edL6atS3.cjs");
3
- const require_spatial_partition_3d = require("./spatial-partition-3d-D1uyJVhM.cjs");
4
2
  let heap_js = require("heap-js");
3
+ const require_rng = require("./rng-BtvhTJmM.cjs");
4
+ const require_spatial_partition_3d = require("./spatial-partition-3d-qhjqIpcy.cjs");
5
5
  // src/astar.ts
6
6
  const DEFAULT_MAX_NODES = 1e4;
7
7
  const DIRECTIONS = [
@@ -52,7 +52,7 @@ function findPath(start, goal, cost, options = {}) {
52
52
  const dy = Math.abs(y - goal.y);
53
53
  return diagonal ? Math.max(dx, dy) === 1 : dx + dy === 1;
54
54
  };
55
- const passable = (x, y) => cost(x, y) < Infinity;
55
+ const passable = (x, y) => cost(x, y) < 1e400;
56
56
  if (!adjacent && !partial && !passable(goal.x, goal.y) && !(start.x === goal.x && start.y === goal.y)) return [];
57
57
  let seq = 0;
58
58
  const open = new heap_js.Heap((a, b) => a.f - b.f || a.h - b.h || a.seq - b.seq);
@@ -86,7 +86,7 @@ function findPath(start, goal, cost, options = {}) {
86
86
  const k = key$1(x, y);
87
87
  if (closed.has(k)) continue;
88
88
  const stepCost = cost(x, y);
89
- if (!(stepCost < Infinity)) continue;
89
+ if (!(stepCost < 1e400)) continue;
90
90
  const isDiagonal = dx !== 0 && dy !== 0;
91
91
  if (isDiagonal && !cutCorners && (!passable(current.x + dx, current.y) || !passable(current.x, current.y + dy))) continue;
92
92
  const g = current.g + (isDiagonal ? stepCost * require_rng.SQRT2 : stepCost);
@@ -536,6 +536,19 @@ function buildColorPalette(grayscaleSteps = 8, colorSteps = 4, ...colors) {
536
536
  for (const rgb of colorList) palette.push(...colorRamp(rgb, colorSteps));
537
537
  return palette;
538
538
  }
539
+ // src/desktop.ts
540
+ /**
541
+ * The desktop app's {@link Desktop} when running in it; undefined in a browser (and outside one).
542
+ *
543
+ * ```ts
544
+ * import { desktop } from '@n3rdw1z4rd/core';
545
+ *
546
+ * if (desktop) quitButton.onclick = () => desktop.quit();
547
+ * ```
548
+ *
549
+ * @category Desktop
550
+ */
551
+ const desktop = typeof window === "undefined" ? void 0 : window.desktop;
539
552
  // src/disposable.ts
540
553
  /**
541
554
  * Collects cleanup functions (e.g. the unsubscribe functions returned by {@link Observable.subscribe}
@@ -587,7 +600,7 @@ const MAP_2D_MIN_COORD = -1048576;
587
600
  *
588
601
  * @category Maps & Spatial
589
602
  */
590
- const MAP_2D_MAX_COORD = 1048575;
603
+ const MAP_2D_MAX_COORD = 0xfffff;
591
604
  /**
592
605
  * Sparse 2D grid of numbers keyed by integer coordinates. Coordinates are floored, so any point
593
606
  * inside a cell addresses that cell. Cells holding `defaultValue` are not stored: setting a cell to
@@ -630,7 +643,7 @@ var Map2D = class {
630
643
  return [Math.floor(x), Math.floor(y)];
631
644
  }
632
645
  _key(x, y) {
633
- if (!this._warnedOutOfRange && (x < -1048576 || x > 1048575 || y < -1048576 || y > 1048575)) {
646
+ if (!this._warnedOutOfRange && (x < -1048576 || x > 0xfffff || y < -1048576 || y > 0xfffff)) {
634
647
  this._warnedOutOfRange = true;
635
648
  console.warn(`Map2D: (${x}, ${y}) is outside the supported range [${MAP_2D_MIN_COORD}, ${MAP_2D_MAX_COORD}] per axis; it wraps around and collides with other coordinates. Further warnings for this map are suppressed.`);
636
649
  }
@@ -1087,7 +1100,7 @@ function _getShortestPathBetweenRects(rectA, rectB) {
1087
1100
  let paths = {
1088
1101
  a: edgeA[0],
1089
1102
  b: edgeB[0],
1090
- distance: Infinity
1103
+ distance: 1e400
1091
1104
  };
1092
1105
  for (const a of edgeA) for (const b of edgeB) {
1093
1106
  const d = require_rng.distance2d(a.x, a.y, b.x, b.y);
@@ -1104,13 +1117,13 @@ function _getShortestPathBetweenRects(rectA, rectB) {
1104
1117
  }
1105
1118
  function _generatePaths(map, rooms, params = {}) {
1106
1119
  const walkable = params.walkableValues ?? [map.defaultValue];
1107
- const cost = (x, y) => walkable.includes(map.get(x, y)) ? 1 : Infinity;
1120
+ const cost = (x, y) => walkable.includes(map.get(x, y)) ? 1 : 1e400;
1108
1121
  const paths = [];
1109
1122
  _generateMST(rooms, params).forEach((rects) => {
1110
1123
  const { a, b } = _getShortestPathBetweenRects(rects.a, rects.b);
1111
1124
  paths.push(findPath(a, b, cost, {
1112
1125
  adjacent: true,
1113
- maxNodes: Infinity
1126
+ maxNodes: 1e400
1114
1127
  }));
1115
1128
  });
1116
1129
  return paths;
@@ -3584,7 +3597,7 @@ function CreateVertexArray(gl, info, attributes, indices) {
3584
3597
  vao,
3585
3598
  buffers: []
3586
3599
  };
3587
- let vertexCount = Infinity;
3600
+ let vertexCount = 1e400;
3588
3601
  gl.bindVertexArray(vao);
3589
3602
  for (const name in attributes) {
3590
3603
  const attribute = info.attributes[name];
@@ -3624,7 +3637,7 @@ function CreateVertexArray(gl, info, attributes, indices) {
3624
3637
  if (!result.buffers.includes(indices.buffer)) result.buffers.push(indices.buffer);
3625
3638
  }
3626
3639
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, result.indexBuffer);
3627
- } else if (vertexCount < Infinity) result.count = vertexCount;
3640
+ } else if (vertexCount < 1e400) result.count = vertexCount;
3628
3641
  gl.bindVertexArray(null);
3629
3642
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
3630
3643
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
@@ -4093,6 +4106,7 @@ exports.buildColorPalette = buildColorPalette;
4093
4106
  exports.clamp = require_rng.clamp;
4094
4107
  exports.controlId = controlId;
4095
4108
  exports.degrees = require_rng.degrees;
4109
+ exports.desktop = desktop;
4096
4110
  exports.distance2d = require_rng.distance2d;
4097
4111
  exports.distance3d = require_rng.distance3d;
4098
4112
  exports.ecs = ecs;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * The main entry point: math and RNG, input, pathfinding, maps, ECS, events, color, canvas and
3
+ * raw WebGL helpers. Never imports three.js; see {@link "@n3rdw1z4rd/core/three"} for those helpers.
4
+ *
5
+ * ```ts
6
+ * import { rng, findPath, Input } from '@n3rdw1z4rd/core';
7
+ * ```
8
+ *
9
+ * @packageDocumentation
10
+ * @module @n3rdw1z4rd/core
11
+ */
1
12
  import { _ as XYZ, a as Map3DCell, c as MAP_2D_MIN_COORD, d as ColorPalette, f as RGB, g as XY, h as NoiseFunction3D, i as Map3D, l as Map2D, m as KeyValue, n as MAP_3D_MAX_COORD, o as DEFAULT_MAP_2D_VALUE, p as buildColorPalette, r as MAP_3D_MIN_COORD, s as MAP_2D_MAX_COORD, t as DEFAULT_MAP_3D_VALUE, u as Map2DData } from "./map3d-DRHhbrFn.cjs";
2
13
  /**
3
14
  * Cost of stepping onto tile (x, y). Return `Infinity` for blocked tiles. Costs should be >= 1
@@ -349,6 +360,43 @@ export declare class Color {
349
360
  /** new fully transparent black (0, 0, 0, 0) */
350
361
  static get TRANSPARENT(): Color;
351
362
  }
363
+ /**
364
+ * What the desktop app (`@n3rdw1z4rd/core/electron`) gives the page, as `window.desktop`.
365
+ *
366
+ * @category Desktop
367
+ */
368
+ export interface Desktop {
369
+ /** the site the app was built for (its servers: the page's own origin is app://...); '' if none */
370
+ readonly site: string;
371
+ /** close the app (there's no browser tab to close) */
372
+ quit(): void;
373
+ /** full screen on and off (F11 does too) */
374
+ toggleFullscreen(): void;
375
+ /** the build running (and when it was built), the app's own version and desktop API level, and whether the site has a build that needs a newer app */
376
+ version(): Promise<{
377
+ build: string;
378
+ builtAt: string;
379
+ app: string;
380
+ api: number;
381
+ needsNewerApp: boolean;
382
+ }>;
383
+ /** "Updated to ..." once, right after an update has reloaded the page; otherwise null */
384
+ updateNote(): Promise<string | null>;
385
+ /** look for a newer build now: true if there was one (the page is reloading into it) */
386
+ update(): Promise<boolean>;
387
+ }
388
+ /**
389
+ * The desktop app's {@link Desktop} when running in it; undefined in a browser (and outside one).
390
+ *
391
+ * ```ts
392
+ * import { desktop } from '@n3rdw1z4rd/core';
393
+ *
394
+ * if (desktop) quitButton.onclick = () => desktop.quit();
395
+ * ```
396
+ *
397
+ * @category Desktop
398
+ */
399
+ export declare const desktop: Desktop | undefined;
352
400
  /**
353
401
  * Collects cleanup functions (e.g. the unsubscribe functions returned by {@link Observable.subscribe}
354
402
  * and {@link Signal.subscribe}) and runs them all at once.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,20 @@
1
+ /**
2
+ * The main entry point: math and RNG, input, pathfinding, maps, ECS, events, color, canvas and
3
+ * raw WebGL helpers. Never imports three.js; see {@link "@n3rdw1z4rd/core/three"} for those helpers.
4
+ *
5
+ * ```ts
6
+ * import { rng, findPath, Input } from '@n3rdw1z4rd/core';
7
+ * ```
8
+ *
9
+ * @packageDocumentation
10
+ * @module @n3rdw1z4rd/core
11
+ */
1
12
  import { PathOptions, StepCost, findPath } from "./astar.js";
2
13
  import { CanvasColor, CanvasRenderer, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_PIXEL_SIZE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DrawParams, SpriteParams } from "./canvas-renderer.js";
3
14
  import { Clock, ClockCallback, ONE_SECOND } from "./clock.js";
4
15
  import { ColorPalette, RGB, buildColorPalette } from "./color-palette.js";
5
16
  import { Color } from "./color.js";
17
+ import { Desktop, desktop } from "./desktop.js";
6
18
  import { Disposable } from "./disposable.js";
7
19
  import { DoorsParams, GenerateDoors, GenerateRooms, GenerateRoomsParams, GenerateWalls, PathsParams, PointPair, RectPair, RoomsParams, TILE_EMPTY, TILE_FLOOR, TILE_PATH } from "./dungeon-generator.js";
8
20
  import { Component, ComponentInstances, ComponentType, ECS, Entity, System, ecs } from "./ecs.js";
@@ -33,4 +45,4 @@ import { Vector } from "./vector.js";
33
45
  import { RendererParams, WebGlRenderer } from "./webgl-renderer.js";
34
46
  import { AttributeInfo, AttributeSource, BindRenderTarget, BufferOptions, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Draw, DrawOptions, GetProgramLocations, LoadWebGlTexture, ProgramInfo, ProgramLocations, RenderTarget, RenderTargetOptions, ResizeRenderTarget, ResizeWebGlContext, SetUniforms, ShaderType, TextureData, TextureInfo, TextureOptions, UniformInfo, UniformValue, UpdateBuffer, UpdateTexture, VertexArrayInfo } from "./webgl.js";
35
47
  import { WorkerInterface } from "./worker-interface.js";
36
- export { Action, ActionEvent, ActionMap, ActionMapJSON, ActionOptions, ActionPhase, ActionRepeat, AttributeInfo, AttributeSource, BindRenderTarget, Binding, BufferOptions, CanvasColor, CanvasRenderer, CaptureOptions, Clock, ClockCallback, Color, ColorPalette, CompileShader, Component, ComponentInstances, ComponentType, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_REPEAT, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, DeviceQuery, Disposable, DoorsParams, Draw, DrawOptions, DrawParams, E, ECS, EPSILON, Emitter, Entity, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GamepadAxis, GamepadButton, GamepadInfo, GenerateDoors, GenerateRooms, GenerateRoomsParams, GenerateWalls, Gesture, GestureBinding, GestureEvent, GestureFrame, GestureRecognizer, GestureThresholds, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputActionMap, InputActionMapOptions, InputDevice, InputDeviceType, InputState, KeyBinding, KeyModifiers, KeyValue, LN10, LN2, LOG10E, LOG2E, Listener, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map2DData, Map3D, Map3DCell, MouseBinding, MouseButton, NoiseFunction3D, ONE_SECOND, Observable, Observer, PI, PadAxisBinding, PadBinding, ParticleRenderer, ParticleSystem2d, PathOptions, PathsParams, PointPair, PointerState, ProgramInfo, ProgramLocations, QUARTER_PI, RAD2DEG, RGB, Random, RectPair, Rectangle, RenderTarget, RenderTargetOptions, RendererParams, ResizeRenderTarget, ResizeWebGlContext, Rng, RoomsParams, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, SpatialPartitionEntity2d, SpatialPartitionEntity3d, SpriteParams, StepCost, Subscriber, System, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureData, TextureInfo, TextureOptions, Tilemap, TouchPoint, UniformInfo, UniformValue, UpdateBuffer, UpdateTexture, Vector, VertexArrayInfo, WebGlRenderer, WheelBinding, WheelDirection, WorkerInterface, XRAxis, XRAxisBinding, XRBinding, XRButton, XRHand, XRSessionLike, XR_AXES, XR_BUTTONS, XY, XYZ, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
48
+ export { Action, ActionEvent, ActionMap, ActionMapJSON, ActionOptions, ActionPhase, ActionRepeat, AttributeInfo, AttributeSource, BindRenderTarget, Binding, BufferOptions, CanvasColor, CanvasRenderer, CaptureOptions, Clock, ClockCallback, Color, ColorPalette, CompileShader, Component, ComponentInstances, ComponentType, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_REPEAT, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Desktop, DeviceQuery, Disposable, DoorsParams, Draw, DrawOptions, DrawParams, E, ECS, EPSILON, Emitter, Entity, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GamepadAxis, GamepadButton, GamepadInfo, GenerateDoors, GenerateRooms, GenerateRoomsParams, GenerateWalls, Gesture, GestureBinding, GestureEvent, GestureFrame, GestureRecognizer, GestureThresholds, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputActionMap, InputActionMapOptions, InputDevice, InputDeviceType, InputState, KeyBinding, KeyModifiers, KeyValue, LN10, LN2, LOG10E, LOG2E, Listener, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map2DData, Map3D, Map3DCell, MouseBinding, MouseButton, NoiseFunction3D, ONE_SECOND, Observable, Observer, PI, PadAxisBinding, PadBinding, ParticleRenderer, ParticleSystem2d, PathOptions, PathsParams, PointPair, PointerState, ProgramInfo, ProgramLocations, QUARTER_PI, RAD2DEG, RGB, Random, RectPair, Rectangle, RenderTarget, RenderTargetOptions, RendererParams, ResizeRenderTarget, ResizeWebGlContext, Rng, RoomsParams, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, SpatialPartitionEntity2d, SpatialPartitionEntity3d, SpriteParams, StepCost, Subscriber, System, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, TextureData, TextureInfo, TextureOptions, Tilemap, TouchPoint, UniformInfo, UniformValue, UpdateBuffer, UpdateTexture, Vector, VertexArrayInfo, WebGlRenderer, WheelBinding, WheelDirection, WorkerInterface, XRAxis, XRAxisBinding, XRBinding, XRButton, XRHand, XRSessionLike, XR_AXES, XR_BUTTONS, XY, XYZ, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, desktop, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { CanvasRenderer, DEFAULT_COLOR, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT
3
3
  import { Clock, ONE_SECOND } from "./clock.js";
4
4
  import { buildColorPalette } from "./color-palette.js";
5
5
  import { Color } from "./color.js";
6
+ import { desktop } from "./desktop.js";
6
7
  import { Disposable } from "./disposable.js";
7
8
  import { GenerateDoors, GenerateRooms, GenerateWalls, TILE_EMPTY, TILE_FLOOR, TILE_PATH } from "./dungeon-generator.js";
8
9
  import { ECS, ecs } from "./ecs.js";
@@ -32,4 +33,4 @@ import { Vector } from "./vector.js";
32
33
  import { WebGlRenderer } from "./webgl-renderer.js";
33
34
  import { BindRenderTarget, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Draw, GetProgramLocations, LoadWebGlTexture, ResizeRenderTarget, ResizeWebGlContext, SetUniforms, ShaderType, UpdateBuffer, UpdateTexture } from "./webgl.js";
34
35
  import { WorkerInterface } from "./worker-interface.js";
35
- export { ActionMap, BindRenderTarget, CanvasRenderer, Clock, Color, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_REPEAT, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Disposable, Draw, E, ECS, EPSILON, Emitter, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GenerateDoors, GenerateRooms, GenerateWalls, GestureRecognizer, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputActionMap, LN10, LN2, LOG10E, LOG2E, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map3D, ONE_SECOND, Observable, PI, ParticleRenderer, ParticleSystem2d, QUARTER_PI, RAD2DEG, Random, Rectangle, ResizeRenderTarget, ResizeWebGlContext, Rng, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, Tilemap, UpdateBuffer, UpdateTexture, Vector, WebGlRenderer, WorkerInterface, XR_AXES, XR_BUTTONS, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
36
+ export { ActionMap, BindRenderTarget, CanvasRenderer, Clock, Color, CompileShader, CreateBuffer, CreateProgram, CreateProgramInfo, CreateRenderTarget, CreateTexture, CreateVertexArray, CreateWebGlContext, DEFAULT_COLOR, DEFAULT_DEADZONE, DEFAULT_FONT, DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE, DEFAULT_MAP_2D_VALUE, DEFAULT_MAP_3D_VALUE, DEFAULT_PIXEL_SIZE, DEFAULT_REPEAT, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE, DEG2RAD, DeleteProgramInfo, DeleteRenderTarget, DeleteTexture, DeleteVertexArray, Disposable, Draw, E, ECS, EPSILON, Emitter, EventQueue, GAMEPAD_AXES, GAMEPAD_BUTTONS, GESTURES, GenerateDoors, GenerateRooms, GenerateWalls, GestureRecognizer, GetProgramLocations, GetUrlParams, HALF_PI, Input, InputActionMap, LN10, LN2, LOG10E, LOG2E, LoadWebGlTexture, MAP_2D_MAX_COORD, MAP_2D_MIN_COORD, MAP_3D_MAX_COORD, MAP_3D_MIN_COORD, Map2D, Map3D, ONE_SECOND, Observable, PI, ParticleRenderer, ParticleSystem2d, QUARTER_PI, RAD2DEG, Random, Rectangle, ResizeRenderTarget, ResizeWebGlContext, Rng, SQRT1_2, SQRT2, SetUniforms, ShaderType, Signal, SpatialPartition2d, SpatialPartition3d, TAU, TILE_EMPTY, TILE_FLOOR, TILE_PATH, Tilemap, UpdateBuffer, UpdateTexture, Vector, WebGlRenderer, WorkerInterface, XR_AXES, XR_BUTTONS, bindingLabel, bindingsEqual, buildColorPalette, clamp, controlId, degrees, desktop, distance2d, distance3d, ecs, findPath, fract, gesture, getRedYellowGreenGradientHex, hash32, hash32mix, inverseLerp, isNullOrUndefined, isPositiveString, k2xy, k2xyz, key, lerp, log, manhattanDistance, mod, mouse, nearlyEqual, normalizeRadians, pad, padAxis, radians, randomMatrix, rng, roundTo, saturate, smoothstep, squaredDistance, wheel, wrap, xr, xrAxis, xy2k, xyz2k };
package/dist/map2d.js CHANGED
@@ -19,7 +19,7 @@ const MAP_2D_MIN_COORD = -1048576;
19
19
  *
20
20
  * @category Maps & Spatial
21
21
  */
22
- const MAP_2D_MAX_COORD = 1048575;
22
+ const MAP_2D_MAX_COORD = 0xfffff;
23
23
  /**
24
24
  * Sparse 2D grid of numbers keyed by integer coordinates. Coordinates are floored, so any point
25
25
  * inside a cell addresses that cell. Cells holding `defaultValue` are not stored: setting a cell to
@@ -62,7 +62,7 @@ var Map2D = class {
62
62
  return [Math.floor(x), Math.floor(y)];
63
63
  }
64
64
  _key(x, y) {
65
- if (!this._warnedOutOfRange && (x < -1048576 || x > 1048575 || y < -1048576 || y > 1048575)) {
65
+ if (!this._warnedOutOfRange && (x < -1048576 || x > 0xfffff || y < -1048576 || y > 0xfffff)) {
66
66
  this._warnedOutOfRange = true;
67
67
  console.warn(`Map2D: (${x}, ${y}) is outside the supported range [${MAP_2D_MIN_COORD}, ${MAP_2D_MAX_COORD}] per axis; it wraps around and collides with other coordinates. Further warnings for this map are suppressed.`);
68
68
  }
package/dist/math.js CHANGED
@@ -183,9 +183,9 @@ const roundTo = (value, digits = 0) => {
183
183
  const hash32 = (n) => {
184
184
  n |= 0;
185
185
  n ^= n >>> 16;
186
- n = Math.imul(n, 2246822507);
186
+ n = Math.imul(n, 0x85ebca6b);
187
187
  n ^= n >>> 13;
188
- n = Math.imul(n, 3266489909);
188
+ n = Math.imul(n, 0xc2b2ae35);
189
189
  n ^= n >>> 16;
190
190
  return n >>> 0;
191
191
  };
@@ -183,9 +183,9 @@ const roundTo = (value, digits = 0) => {
183
183
  const hash32 = (n) => {
184
184
  n |= 0;
185
185
  n ^= n >>> 16;
186
- n = Math.imul(n, 2246822507);
186
+ n = Math.imul(n, 0x85ebca6b);
187
187
  n ^= n >>> 13;
188
- n = Math.imul(n, 3266489909);
188
+ n = Math.imul(n, 0xc2b2ae35);
189
189
  n ^= n >>> 16;
190
190
  return n >>> 0;
191
191
  };
@@ -1,4 +1,4 @@
1
- const require_rng = require("./rng-edL6atS3.cjs");
1
+ const require_rng = require("./rng-BtvhTJmM.cjs");
2
2
  // src/log.ts
3
3
  /**
4
4
  * `console.debug` with a bold gray `[dev]` prefix; takes the same arguments. Visible only when the
@@ -1,5 +1,5 @@
1
- import { EditorCamera } from "./editor-camera.js";
2
1
  import { BufferGeometry, ColorRepresentation, LineBasicMaterial, LineSegments } from "three";
2
+ import { EditorCamera } from "./editor-camera.js";
3
3
  /**
4
4
  * An infinite-looking grid on the XY plane for editor views: each {@link AdaptiveGrid.update}
5
5
  * rebuilds just the lines in view, doubling the spacing when zoomed out so lines never get
@@ -53,7 +53,7 @@ var AdaptiveGrid = class extends LineSegments {
53
53
  [view.width / 2, view.height / 2]
54
54
  ].map(([x, y]) => view.screenToWorld(x, y, z)).filter((p) => p !== null);
55
55
  const far = step * this.maxLines / 2;
56
- let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity;
56
+ let x0 = 1e400, x1 = -1e400, y0 = 1e400, y1 = -1e400;
57
57
  for (const p of pts) {
58
58
  x0 = Math.min(x0, p.x);
59
59
  x1 = Math.max(x1, p.x);
@@ -1,5 +1,5 @@
1
- import { NoiseFunction3D } from "../types.js";
2
1
  import { Mesh } from "three";
2
+ import { NoiseFunction3D } from "../types.js";
3
3
  /**
4
4
  * Options for the {@link AsteroidMesh} constructor.
5
5
  *
@@ -1,5 +1,5 @@
1
- import { clamp, lerp, radians, saturate } from "../math.js";
2
1
  import { Group, PerspectiveCamera, Raycaster, Vector3 } from "three";
2
+ import { clamp, lerp, radians, saturate } from "../math.js";
3
3
  // src/three/camera-rig.ts
4
4
  const DEFAULT_DISTANCE = 5;
5
5
  const damp = (current, target, damping, deltaTime) => damping > 0 ? lerp(current, target, 1 - Math.exp(-damping * deltaTime)) : target;
@@ -1,5 +1,5 @@
1
- import { NoiseFunction3D } from "../types.js";
2
1
  import { BufferGeometry } from "three";
2
+ import { NoiseFunction3D } from "../types.js";
3
3
  /**
4
4
  * A sphere built from a subdivided cube, for planets and other displaced spheres.
5
5
  *
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Three.js helpers: a scene `World` (entities, component schemas, save/load), camera rig, voxel meshing, texture atlases, procedural geometry, particles.
3
+ * Requires the `three` package (an optional peer dependency).
4
+ *
5
+ * ```ts
6
+ * import { CameraRig, buildVoxelGeometry } from '@n3rdw1z4rd/core/three';
7
+ * ```
8
+ *
9
+ * @packageDocumentation
10
+ * @module @n3rdw1z4rd/core/three
11
+ */
1
12
  import { AdaptiveGrid } from "./adaptive-grid.js";
2
13
  import { AsteroidMesh, AsteroidOptions } from "./asteroid-mesh.js";
3
14
  import { CameraRig, CameraRigParams, PitchLimits } from "./camera-rig.js";
@@ -11,7 +22,7 @@ import { ComponentRegistry, ComponentSchema, ComponentType, FieldDef, FieldType,
11
22
  import { CreateStarfield, CreateSystemStar } from "./starfield.js";
12
23
  import { AtlasParams, TextureAtlas, UV } from "./texture-atlas.js";
13
24
  import { CreateSubTexture, LoadTexture, TextureData } from "./texture-utils.js";
14
- import { BuildVoxelGeometryOptions, VoxelGeometry, buildVoxelGeometry } from "./voxel-geometry.js";
25
+ import { BuildVoxelGeometryOptions, VoxelGeometry, VoxelSource, buildVoxelGeometry } from "./voxel-geometry.js";
15
26
  import { VoxelBounds, VoxelMesh, VoxelMeshOptions } from "./voxel-mesh.js";
16
27
  import { ComponentRef, EntityDoc, SCENE_FORMAT, SCENE_VERSION, SceneDoc, World, WorldEvents, WorldSystem } from "./world.js";
17
- export { AdaptiveGrid, AddThreeComponent, AsteroidMesh, AsteroidOptions, AtlasParams, BuildVoxelGeometryOptions, CameraRig, CameraRigParams, ComponentRef, ComponentRegistry, ComponentSchema, ComponentType, CreateStarfield, CreateSubTexture, CreateSystemStar, CreateThreeEntity, CubeSphereGeometry, EditorCamera, EntityDoc, EntityHit, FieldDef, FieldType, GenerateEntityId, GetThreeComponent, IsThreeEntity, LoadTexture, ParticleSystem3d, PickOptions, PitchLimits, RemoveThreeComponent, Renderer, SCENE_FORMAT, SCENE_VERSION, SceneDoc, TextureAtlas, TextureData, ThreeComponent, ThreeEntity, ThreeSystem, UV, ViewInsets, VoxelBounds, VoxelGeometry, VoxelMesh, VoxelMeshOptions, World, WorldEvents, WorldSystem, applyFieldValue, buildVoxelGeometry, component, componentToJson, componentType, components, defineComponent, entityOf, field, fieldToJson, inferFieldType, pickEntity };
28
+ export { AdaptiveGrid, AddThreeComponent, AsteroidMesh, AsteroidOptions, AtlasParams, BuildVoxelGeometryOptions, CameraRig, CameraRigParams, ComponentRef, ComponentRegistry, ComponentSchema, ComponentType, CreateStarfield, CreateSubTexture, CreateSystemStar, CreateThreeEntity, CubeSphereGeometry, EditorCamera, EntityDoc, EntityHit, FieldDef, FieldType, GenerateEntityId, GetThreeComponent, IsThreeEntity, LoadTexture, ParticleSystem3d, PickOptions, PitchLimits, RemoveThreeComponent, Renderer, SCENE_FORMAT, SCENE_VERSION, SceneDoc, TextureAtlas, TextureData, ThreeComponent, ThreeEntity, ThreeSystem, UV, ViewInsets, VoxelBounds, VoxelGeometry, VoxelMesh, VoxelMeshOptions, VoxelSource, World, WorldEvents, WorldSystem, applyFieldValue, buildVoxelGeometry, component, componentToJson, componentType, components, defineComponent, entityOf, field, fieldToJson, inferFieldType, pickEntity };
@@ -1,9 +1,9 @@
1
+ import { BufferAttribute, BufferGeometry, DynamicDrawUsage, Group, Points, ShaderMaterial, Sphere, Vector3 } from "three";
1
2
  import { Random } from "../random.js";
2
3
  import { fract } from "../math.js";
3
4
  import { SpatialPartition3d } from "../spatial-partition-3d.js";
4
5
  import { rng } from "../rng.js";
5
6
  import { randomMatrix } from "../particle-system-2d.js";
6
- import { BufferAttribute, BufferGeometry, DynamicDrawUsage, Group, Points, ShaderMaterial, Sphere, Vector3 } from "three";
7
7
  // src/three/particle-system-3d.ts
8
8
  const vertexShader = `
9
9
  uniform float pointSize;
@@ -1,7 +1,7 @@
1
+ import { Object3D, Vector3 } from "three";
1
2
  import { ThreeEntity } from "./ecs.js";
2
3
  import { EditorCamera } from "./editor-camera.js";
3
4
  import { World } from "./world.js";
4
- import { Object3D, Vector3 } from "three";
5
5
  /** @category Three.js */
6
6
  export interface EntityHit {
7
7
  entity: ThreeEntity;