@yaks/voxel 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +79 -2
- package/_dist/boxes.d.ts +80 -0
- package/_dist/boxes.d.ts.map +1 -0
- package/_dist/chartbook.d.ts +14 -0
- package/_dist/chartbook.d.ts.map +1 -0
- package/_dist/chartsheet.d.ts +8 -0
- package/_dist/chartsheet.d.ts.map +1 -0
- package/_dist/light.d.ts +18 -0
- package/_dist/light.d.ts.map +1 -0
- package/_dist/mesh.d.ts +120 -0
- package/_dist/mesh.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/stream.d.ts +33 -0
- package/_dist/stream.d.ts.map +1 -0
- package/_dist/three/mod.d.ts +5 -0
- package/_dist/three/mod.d.ts.map +1 -0
- package/_dist/three/parts.d.ts +59 -0
- package/_dist/three/parts.d.ts.map +1 -0
- package/_dist/three/puppet.d.ts +93 -0
- package/_dist/three/puppet.d.ts.map +1 -0
- package/_dist/three/soft.d.ts +27 -0
- package/_dist/three/soft.d.ts.map +1 -0
- package/boxes.js +265 -0
- package/boxes.js.map +1 -0
- package/boxes.ts +266 -0
- package/chartbook.js +63 -0
- package/chartbook.js.map +1 -0
- package/chartbook.ts +88 -0
- package/chartsheet.js +31 -0
- package/chartsheet.js.map +1 -0
- package/chartsheet.ts +32 -0
- package/deno.json +1 -0
- package/light.js +45 -0
- package/light.js.map +1 -0
- package/light.ts +49 -0
- package/mesh.js +577 -0
- package/mesh.js.map +1 -0
- package/mesh.ts +624 -0
- package/mod.js +7 -0
- package/mod.js.map +1 -0
- package/mod.ts +7 -0
- package/package.json +45 -4
- package/stream.js +80 -0
- package/stream.js.map +1 -0
- package/stream.ts +86 -0
- package/three/mod.js +7 -0
- package/three/mod.js.map +1 -0
- package/three/mod.ts +7 -0
- package/three/parts.js +181 -0
- package/three/parts.js.map +1 -0
- package/three/parts.ts +185 -0
- package/three/puppet.js +311 -0
- package/three/puppet.js.map +1 -0
- package/three/puppet.ts +471 -0
- package/three/soft.js +338 -0
- package/three/soft.js.map +1 -0
- package/three/soft.ts +382 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Jeff Peterson
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yaks/voxel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Voxel geometry over plain values. Mesh a voxel grid or a set of boxes into
|
|
4
|
+
packed quads, select chunks by distance and detail, and cache heightfield charts
|
|
5
|
+
for a map. The root and geometry subpaths have no runtime dependencies,
|
|
6
|
+
renderer, graph or game world and run in a page or a worker. The `/three`
|
|
7
|
+
subpath draws these values with Three.js; nothing in the root imports it.
|
|
8
|
+
|
|
9
|
+
The page reads its game's graph and passes values here. A renderer consumes the
|
|
10
|
+
packed arrays; a game supplies chunk and sheet sizes. There are no stored words
|
|
11
|
+
or save migrations.
|
|
12
|
+
|
|
13
|
+
## Geometry
|
|
14
|
+
|
|
15
|
+
`@yaks/voxel/mesh` supplies the quad writer (`out`, `quad`, `pack`), voxel
|
|
16
|
+
shapes (`box`, `ball`, `blob`) and the packed representation.
|
|
17
|
+
`@yaks/voxel/boxes` turns box models into that representation, including flush
|
|
18
|
+
surfaces, worn pieces and shaped surfaces. `@yaks/voxel/light` bakes lamp light
|
|
19
|
+
into packed quads (`light`, `warmth`), so a worker meshing a building lights it
|
|
20
|
+
too; `@yaks/voxel/three`'s material brings that light up at dusk. All three are
|
|
21
|
+
also exported from `@yaks/voxel`.
|
|
22
|
+
|
|
23
|
+
## Three.js presentation
|
|
24
|
+
|
|
25
|
+
`@yaks/voxel/three` exports the voxel look, separately from the worker-safe
|
|
26
|
+
root:
|
|
27
|
+
|
|
28
|
+
- `geometry` takes ownership of packed quad arrays without copying.
|
|
29
|
+
- `soft`, `sight`, `cut`, `flash` and `night` provide the voxel material and its
|
|
30
|
+
cutaway, lighting and flash uniforms.
|
|
31
|
+
- `partOf`, `knit` and the other box-part helpers assemble jointed box models.
|
|
32
|
+
- `puppet` animates a caller-supplied `Rig` from `Act` values. Creature designs,
|
|
33
|
+
equipment and animation policy stay with the app.
|
|
34
|
+
|
|
35
|
+
Three.js is shared with the page and `@yaks/stage` by the platform compiler.
|
|
36
|
+
Stage knows no voxels: for its instancing cache, adapt a packed-quad template
|
|
37
|
+
with `(...args) => template(...args).then(geometry)`. No voxel adapter or
|
|
38
|
+
material is imported by stage. The rendering exports require the browser facet;
|
|
39
|
+
worker meshers continue to import `@yaks/voxel/mesh` or the root.
|
|
40
|
+
|
|
41
|
+
## Chunk detail
|
|
42
|
+
|
|
43
|
+
`@yaks/voxel/stream` selects chunks nearest first. Supply the chunk's side in
|
|
44
|
+
metres, the focus, sight distance and each chunk's current detail. `RINGS` and
|
|
45
|
+
`COARSER` describe the detail levels; a hysteresis margin keeps chunks on a ring
|
|
46
|
+
or sight boundary from flickering. An optional final argument bounds a world to
|
|
47
|
+
indices zero through that many chunks minus one.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { wanted } from '@yaks/voxel/stream'
|
|
51
|
+
|
|
52
|
+
let chunks = wanted(32, -16, -16, 1, () => undefined)
|
|
53
|
+
console.log(chunks) // [{ ci: -1, ck: -1, lod: 0, d: 0 }]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Charts
|
|
57
|
+
|
|
58
|
+
`@yaks/voxel/chartbook` keeps completed and concurrent chunk charts. Create a
|
|
59
|
+
`chartbook<T>(chunkSize)`, `keep(cell, make)` charts produced during growth,
|
|
60
|
+
then `read(box, visible, load)` to load only missing visible cells. A rejected
|
|
61
|
+
load can be tried again. `clear()` retires charts when the source designs
|
|
62
|
+
change. `cellsOf(box, chunkSize)` enumerates cells intersecting a square,
|
|
63
|
+
including negative coordinates. Boxes are `[x, z, side]` and cells are
|
|
64
|
+
`[ci, ck]`.
|
|
65
|
+
|
|
66
|
+
`@yaks/voxel/chartsheet` places chart pixels into larger sheets once. Supply the
|
|
67
|
+
sheet side and a canvas factory to `chartsheet(size, make)`. The factory returns
|
|
68
|
+
`{ image, put(pixels, x, z) }`; the package never creates or owns a DOM canvas.
|
|
69
|
+
The returned function accepts pixel charts and returns visible sheet charts,
|
|
70
|
+
reusing canvases and repainting a cell only when its pixel array changes.
|
|
71
|
+
|
|
72
|
+
In a hosted app, declare `"@yaks/voxel": "platform"` in `package.json` and
|
|
73
|
+
import the root or the subpaths above. The running platform compiler must carry
|
|
74
|
+
the package before deploying an app that imports it.
|
|
75
|
+
|
|
76
|
+
## Tests
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
deno task test packages/voxel
|
|
80
|
+
```
|
package/_dist/boxes.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Out, type Vec } from "./mesh.js";
|
|
2
|
+
/** A box: its low corner and its size, in metres, its colour, which says what
|
|
3
|
+
* it is made of too (mesh.ts `metal`), and how wide the rounding of its edges
|
|
4
|
+
* is. */ export type Box = [Vec, Vec, number, number?];
|
|
5
|
+
/** A box as its two corners, worn over those before it: what `drawn` draws. */ export type Solid = {
|
|
6
|
+
lo: Vec;
|
|
7
|
+
hi: Vec;
|
|
8
|
+
hex: number;
|
|
9
|
+
round: number;
|
|
10
|
+
};
|
|
11
|
+
type Rect = [number, number, number, number];
|
|
12
|
+
/** The boxes as solids, each worn over those before it and over `under`,
|
|
13
|
+
* solids drawn apart that it rests against (parts.ts `knit`): a side within
|
|
14
|
+
* a step of the same side of one it overlaps stands a step outside it, or
|
|
15
|
+
* flush with it where the two are of the same stuff, and so one surface;
|
|
16
|
+
* never so with what is drawn apart, since nothing cuts the two apart.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { assertEquals } from '@std/assert'
|
|
20
|
+
* import { STEP } from './mesh.ts'
|
|
21
|
+
* let tunic: Box = [[-0.2, 0, -0.15], [0.4, 0.5, 0.3], 0x4a7ab8]
|
|
22
|
+
* // A belt drawn round the tunic, in its planes, is worn over it.
|
|
23
|
+
* let [, belt] = worn([tunic, [[-0.2, 0.1, -0.15], [0.4, 0.06, 0.3], 0x3d2c20]])
|
|
24
|
+
* assertEquals(belt.hi[0], 0.2 + STEP)
|
|
25
|
+
* // A second piece of the tunic lies flush, a hair inside or not.
|
|
26
|
+
* let [, more] = worn([tunic, [[-0.198, 0.4, -0.1], [0.3, 0.2, 0.2], 0x4a7ab8]])
|
|
27
|
+
* assertEquals(more.lo[0], -0.2)
|
|
28
|
+
* ```
|
|
29
|
+
*/ export declare let worn: (boxes: Box[], round?: number, under?: Solid[]) => Solid[];
|
|
30
|
+
/** What shows of face `f` with `hidden` drawn over it: as few rectangles as
|
|
31
|
+
* cover the rest, runs along u stacked along v.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { assertEquals } from '@std/assert'
|
|
35
|
+
* assertEquals(shown([0, 0, 1, 1], []), [[0, 0, 1, 1]])
|
|
36
|
+
* // A post standing in the middle of a floor leaves a frame round it.
|
|
37
|
+
* assertEquals(shown([0, 0, 3, 3], [[1, 1, 2, 2]]), [
|
|
38
|
+
* [0, 0, 3, 1],
|
|
39
|
+
* [0, 1, 1, 2],
|
|
40
|
+
* [2, 1, 3, 2],
|
|
41
|
+
* [0, 2, 3, 3],
|
|
42
|
+
* ])
|
|
43
|
+
* assertEquals(shown([0, 0, 1, 1], [[-1, -1, 2, 2]]), [])
|
|
44
|
+
* ```
|
|
45
|
+
*/ export declare let shown: (f: Rect, hidden: Rect[]) => Rect[];
|
|
46
|
+
/** Solids moved by `f`, a turn by quarters, a scale and a shift that takes
|
|
47
|
+
* each corner where it goes.
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { assertEquals } from '@std/assert'
|
|
51
|
+
* let [s] = worn([[[0, 0, 0], [1, 2, 3], 0xffffff]])
|
|
52
|
+
* let [m] = moved([s], ([x, y, z]) => [2 - x, y + 1, z])
|
|
53
|
+
* assertEquals([m.lo, m.hi], [[1, 1, 0], [2, 3, 3]])
|
|
54
|
+
* ```
|
|
55
|
+
*/ export declare let moved: (solids: Solid[], f: (v: Vec) => Vec) => Solid[];
|
|
56
|
+
/** Solids drawn as one, soft on every edge, as if built of voxels `cell`
|
|
57
|
+
* across, of whatever each one's colour says it is made of (mesh.ts
|
|
58
|
+
* `metal`): each face only where it shows. */ export declare let drawn: (o: Out, solids: Solid[], cell?: number) => Out;
|
|
59
|
+
/**
|
|
60
|
+
* Boxes as one solid, each worn over those before it, soft on every edge
|
|
61
|
+
* (`round` metres wide, or as a box says) and drawn as if built of voxels
|
|
62
|
+
* `cell` across.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { assertEquals } from '@std/assert'
|
|
66
|
+
* import { metal, METAL, out } from './mesh.ts'
|
|
67
|
+
* let faces = (o: ReturnType<typeof out>) => o.pos.length / 12
|
|
68
|
+
* let blade = cuboids(out(), [[[0, 0, 0], [1, 1, 1], metal(0xdfe6ee)]])
|
|
69
|
+
* assertEquals(faces(blade), 6)
|
|
70
|
+
* // each vertex's edge ends in what it is made of
|
|
71
|
+
* assertEquals(blade.edge[3], METAL)
|
|
72
|
+
* // Two boxes side by side: the faces between them are not drawn.
|
|
73
|
+
* let pair = cuboids(out(), [
|
|
74
|
+
* [[0, 0, 0], [1, 1, 1], 0xffffff],
|
|
75
|
+
* [[1, 0, 0], [1, 1, 1], 0xff0000],
|
|
76
|
+
* ])
|
|
77
|
+
* assertEquals(faces(pair), 10)
|
|
78
|
+
* ```
|
|
79
|
+
*/ export declare let cuboids: (o: Out, boxes: Box[], cell?: number, round?: number) => Out;
|
|
80
|
+
//# sourceMappingURL=boxes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boxes.d.ts","sources":["../boxes.ts"],"names":[],"mappings":"AAiBA,SAGE,KAAK,GAAG,EAIR,KAAK,GAAG,oBACQ;AAElB;;OAEO,GACP,YAAY,OAAO,KAAK,KAAK,MAAM,EAAE,MAAM;AAE3C,6EAA6E,GAC7E,YAAY;EAAU,IAAI;EAAK,IAAI;EAAK,KAAK,MAAM;EAAE,OAAO,MAAM;;KAG7D,QAAQ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;AAe3C;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,OACT,OAAO,OACP,gBACA,QAAO,YACN,QA8BF;AAaD;;;;;;;;;;;;;;;CAeC,GACD,OAAO,YAAI,QAAS,GAAG,MAAM,QAAQ,WAAS,OAkC7C;AAED;;;;;;;;;CASC,GACD,OAAO,YAAI,QAAS,QAAQ,SAAS,IAAI,GAAG,QAAQ,QAAM,QActD;AAEJ;;4CAE4C,GAC5C,OAAO,YAAI,QAAS,GAAG,KAAK,QAAQ,SAAS,kBAAa,IA4CzD;AAED;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,YAAI,UAAW,GAAG,KAAK,OAAO,OAAO,eAAY,mBAAgB,IACpC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Cell = [number, number];
|
|
2
|
+
export type ChartBox = [number, number, number];
|
|
3
|
+
export type Chart<T> = {
|
|
4
|
+
image: T;
|
|
5
|
+
box: ChartBox;
|
|
6
|
+
};
|
|
7
|
+
/** Chunk cells intersecting a square, including negative coordinates. */ export declare let cellsOf: ([]: ChartBox, chunkSize: number) => Cell[];
|
|
8
|
+
/** A cache of completed and concurrent chunk charts. */ export type Chartbook<T> = {
|
|
9
|
+
keep: (cell: Cell, make: () => T | Promise<T>) => Promise<T>;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
read: (box: ChartBox, visible: (cell: Cell) => boolean, load: (cell: Cell) => Promise<T>) => Promise<Chart<T>[]>;
|
|
12
|
+
};
|
|
13
|
+
/** Keep both completed charts and concurrent requests until designs change. */ export declare let chartbook: <T>(chunkSize: number) => Chartbook<T>;
|
|
14
|
+
//# sourceMappingURL=chartbook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartbook.d.ts","sources":["../chartbook.ts"],"names":[],"mappings":"AAEA,YAAY,QAAQ,MAAM,EAAE,MAAM;AAClC,YAAY,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM;AAE9C,YAAY,MAAM;EAAO,OAAO;EAAG,KAAK;;AAExC,uEAAuE,GACvE,OAAO,YAAI,UAAW,IAAc,QAAQ,EAAE,WAAW,MAAM,KAAG,OAgBjE;AAED,sDAAsD,GACtD,YAAY,UAAU;EACpB,OAAO,MAAM,MAAM,YAAY,IAAI,QAAQ,OAAO,QAAQ;EAC1D,aAAa,IAAI;EACjB,OACE,KAAK,UACL,UAAU,MAAM,SAAS,OAAO,EAChC,OAAO,MAAM,SAAS,QAAQ,OAC3B,QAAQ,MAAM;;AAGrB,6EAA6E,GAC7E,OAAO,YAAI,YAAa,GAAG,WAAW,MAAM,KAAG,UAAU,GAiDxD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Chart } from "./chartbook.js";
|
|
2
|
+
type Pixels = Uint8ClampedArray<ArrayBuffer>;
|
|
3
|
+
type Canvas<T> = {
|
|
4
|
+
image: T;
|
|
5
|
+
put: (px: Pixels, x: number, z: number) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare let chartsheet: <T>(size: number, make: () => Canvas<T>) => (charts: Chart<Pixels>[]) => Chart<T>[];
|
|
8
|
+
//# sourceMappingURL=chartsheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartsheet.d.ts","sources":["../chartsheet.ts"],"names":[],"mappings":"AAEA,cAAc,KAAK,yBAAwB;KAEtC,SAAS,kBAAkB;KAC3B,OAAO;EAAO,OAAO;EAAG,MAAM,IAAI,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,KAAK,IAAI;;AAE5E,OAAO,YAAI,aAAc,GACvB,MAAM,MAAM,EACZ,YAAY,OAAO,QACjB,QAAQ,MAAM,cAAc,MAAM,KAqBrC"}
|
package/_dist/light.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Out, type Vec } from "./mesh.js";
|
|
2
|
+
export type LightSource = {
|
|
3
|
+
at: Vec;
|
|
4
|
+
size: number;
|
|
5
|
+
};
|
|
6
|
+
/** How much of the nearby lamps a face sees, before the day's light changes. */ export declare let warmth: (at: Vec, normal: Vec, glows: LightSource[]) => number;
|
|
7
|
+
/** A lamp lights the face toward it, strongest near its flame.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { assert, assertEquals } from '@std/assert'
|
|
11
|
+
* assert(warmth([0, 0, 0], [1, 0, 0], [{ at: [1, 0, 0], size: 2 }]) >
|
|
12
|
+
* warmth([-2, 0, 0], [1, 0, 0], [{ at: [1, 0, 0], size: 2 }]))
|
|
13
|
+
* assertEquals(warmth([0, 0, 0], [-1, 0, 0], [
|
|
14
|
+
* { at: [1, 0, 0], size: 2 },
|
|
15
|
+
* ]), 0)
|
|
16
|
+
* ```
|
|
17
|
+
*/ /** Store a building's warm light in each vertex's edge-flag high nibble. */ export declare let light: (mesh: Out, glows: LightSource[]) => Out;
|
|
18
|
+
//# sourceMappingURL=light.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.d.ts","sources":["../light.ts"],"names":[],"mappings":"AAKA,SAAS,KAAK,GAAG,EAAE,KAAK,GAAG,oBAAmB;AAE9C,YAAY;EAAgB,IAAI;EAAK,MAAM,MAAM;;AAEjD,8EAA8E,GAC9E,OAAO,YAAI,SAAU,IAAI,KAAK,QAAQ,KAAK,OAAO,kBAAgB,MAAM,CAevE;AAED;;;;;;;;;;CAUC,GAED,0EAA0E,GAC1E,OAAO,YAAI,QAAS,MAAM,KAAK,OAAO,kBAAgB,IAQrD"}
|
package/_dist/mesh.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export type Vec = [number, number, number];
|
|
2
|
+
/** The triangles being written, a vertex at a time: where it is (3 numbers,
|
|
3
|
+
* metres); which way its face looks (4: the normal and a 0); its colour (4:
|
|
4
|
+
* sRGB bytes and 255); where on its face it sits, which of the face's edges
|
|
5
|
+
* are rounded and what it is made of (4: u and v, 0 or 1, the edge flags as
|
|
6
|
+
* bits, and its material); and the rounding's widths across the face and the
|
|
7
|
+
* voxel edge (3). */ export type Out = {
|
|
8
|
+
pos: number[];
|
|
9
|
+
nrm: number[];
|
|
10
|
+
col: number[];
|
|
11
|
+
edge: number[];
|
|
12
|
+
bw: number[];
|
|
13
|
+
idx: number[];
|
|
14
|
+
};
|
|
15
|
+
export declare let out: () => Out;
|
|
16
|
+
/** Copy triangles into `into`, moved by `at`. */ export declare let place: (into: Out, from: Out, at: Vec) => void;
|
|
17
|
+
/** The compact bounds and face planes of a mesh, before it is placed. */ export type Profile = {
|
|
18
|
+
room: [Vec, Vec];
|
|
19
|
+
planes: [number[], number[], number[]];
|
|
20
|
+
};
|
|
21
|
+
export declare let profileOf: (o: Out) => Profile;
|
|
22
|
+
/** What a mesher wrote, in the typed arrays a GPU takes: what a worker hands
|
|
23
|
+
* the page without a copy (grow.ts). */ export type Packed = {
|
|
24
|
+
pos: Float32Array<ArrayBuffer>;
|
|
25
|
+
nrm: Int8Array<ArrayBuffer>;
|
|
26
|
+
col: Uint8Array<ArrayBuffer>;
|
|
27
|
+
edge: Uint8Array<ArrayBuffer>;
|
|
28
|
+
bw: Float32Array<ArrayBuffer>;
|
|
29
|
+
idx: Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>;
|
|
30
|
+
};
|
|
31
|
+
/** Triangles packed, with indices as narrow as the vertex count allows. A
|
|
32
|
+
* colour written as sRGB hex comes back as the same bytes.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { assertEquals } from '@std/assert'
|
|
36
|
+
* import { cuboids } from './boxes.ts'
|
|
37
|
+
* let p = pack(cuboids(out(), [[[0, 0, 0], [1, 1, 1], 0x80c020]]))
|
|
38
|
+
* assertEquals([p.pos.length / 3, p.idx.length / 3], [24, 12])
|
|
39
|
+
* assertEquals(p.idx instanceof Uint16Array, true)
|
|
40
|
+
* assertEquals([...p.col.slice(0, 4)], [0x80, 0xc0, 0x20, 255])
|
|
41
|
+
* ```
|
|
42
|
+
*/ export declare let pack: (o: Out) => Packed;
|
|
43
|
+
/** The buffers a packed mesh is made of, to hand over rather than copy. */ export declare let buffers: (p: Packed) => ArrayBuffer[];
|
|
44
|
+
/** The least distance two surfaces facing the same way keep apart, in metres,
|
|
45
|
+
* so the depth buffer always tells which is in front: a worn layer over what
|
|
46
|
+
* it covers (boxes.ts), a thing standing on the ground or in another
|
|
47
|
+
* (chunks.ts). A 24-bit depth buffer parts two surfaces d metres off when
|
|
48
|
+
* they are about d² / (near · 2²⁴) apart, near being the camera's near plane
|
|
49
|
+
* (cam.ts `NEAR`): a millimetre at 100 m, so a step holds out to the fog. */ export declare let STEP: number;
|
|
50
|
+
/** Every pair of faces in `p` the depth buffer could not tell apart, by their
|
|
51
|
+
* order in it: where they overlap, two looking the same way less than a step
|
|
52
|
+
* apart, or two back to back in one plane, where two solids meet and neither
|
|
53
|
+
* shows. Nothing a mesher writes ever does (boxes.ts, `blob`, ground.ts).
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { assertEquals } from '@std/assert'
|
|
57
|
+
* let white = Array(12).fill(1), plain: [0, 0, 0, 0] = [0, 0, 0, 0]
|
|
58
|
+
* let floor = (y: number, sign = 1, x = 0) => {
|
|
59
|
+
* let o = out()
|
|
60
|
+
* quad(o, [x, y, 0], 1, 1, 1, sign, white, plain, 0)
|
|
61
|
+
* return o
|
|
62
|
+
* }
|
|
63
|
+
* let both = (a: Out, b: Out) => {
|
|
64
|
+
* let o = out()
|
|
65
|
+
* place(o, a, [0, 0, 0])
|
|
66
|
+
* place(o, b, [0, 0, 0])
|
|
67
|
+
* return fights(pack(o))
|
|
68
|
+
* }
|
|
69
|
+
* assertEquals(both(floor(0), floor(0.002)), [[0, 1]])
|
|
70
|
+
* assertEquals(both(floor(0), floor(STEP)), [])
|
|
71
|
+
* assertEquals(both(floor(0), floor(0, -1)), [[0, 1]])
|
|
72
|
+
* assertEquals(both(floor(0), floor(0, 1, 1)), []) // side by side
|
|
73
|
+
* ```
|
|
74
|
+
*/ export declare let fights: (p: Packed) => [number, number][];
|
|
75
|
+
/** What a face is made of, besides its colour: matte, the soft look of
|
|
76
|
+
* everything in the vale, or metal, which mirrors the sky and catches the sun
|
|
77
|
+
* (soft.ts). A colour carries its material in the byte above its 24 bits of
|
|
78
|
+
* sRGB, so a model says what each box or voxel is made of where it says its
|
|
79
|
+
* colour; the byte has room for more materials than these. */ export declare let MATTE: number;
|
|
80
|
+
export declare let METAL: number;
|
|
81
|
+
/** A colour, in metal.
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { assertEquals } from '@std/assert'
|
|
85
|
+
* assertEquals([materialOf(metal(0x9aa2aa)), materialOf(0x9aa2aa)], [
|
|
86
|
+
* METAL,
|
|
87
|
+
* MATTE,
|
|
88
|
+
* ])
|
|
89
|
+
* // the colour itself is the same
|
|
90
|
+
* assertEquals(rgb(metal(0x9aa2aa)), rgb(0x9aa2aa))
|
|
91
|
+
* ```
|
|
92
|
+
*/ export declare let metal: (hex: number) => any;
|
|
93
|
+
/** What a colour is made of: `MATTE` or `METAL`. */ export declare let materialOf: (hex: number) => number;
|
|
94
|
+
/** A face's two in-plane axes, by the axis its normal lies on: x → (z, y),
|
|
95
|
+
* y → (x, z), z → (x, y). soft.ts derives the same pair from the normal. */ export declare let axes: (axis: number) => [number, number];
|
|
96
|
+
/**
|
|
97
|
+
* One face: `at` its minimum corner, `du` and `dv` its extent along its two
|
|
98
|
+
* axes (in metres), `sign` which way along `axis` it faces. `c` holds a colour
|
|
99
|
+
* per corner (r, g, b, in corner order: at, +u, +u+v, +v). `rim` flags its
|
|
100
|
+
* edges (−u, +u, −v, +v) for rounding, `round` is the rounding's width in
|
|
101
|
+
* metres, `ao` darkens the corners (0 dark to 3 open), `cell` is the edge of
|
|
102
|
+
* the voxels it is made of, and `material` what they are made of (`METAL`).
|
|
103
|
+
* The diagonal is flipped where that keeps the darkening smooth.
|
|
104
|
+
*/ export declare let quad: (o: Out, at: Vec, axis: number, du: number, dv: number, sign: number, c: number[], rim: [number, number, number, number], round: number, ao?: [number, number, number, number], cell?: number) => void;
|
|
105
|
+
/** A colour, written as sRGB hex, as three linear numbers in [0, 1]. */ export declare let rgb: (hex: number) => Vec;
|
|
106
|
+
/** A small voxel model: voxel coordinates, packed, to a colour, and what the
|
|
107
|
+
* voxel is made of (`metal`). */ export type Vox = Map<number, number>;
|
|
108
|
+
declare let B: number;
|
|
109
|
+
/** Coordinates in [−512, 512) as one key. */ export declare let key: (x: number, y: number, z: number) => any;
|
|
110
|
+
/** A key's coordinates. */ export declare let unkey: (k: number) => Vec;
|
|
111
|
+
/** Fill a box of voxels, corners inclusive. */ export declare let box: (v: Vox, []: Vec, []: Vec, color: number) => Vox;
|
|
112
|
+
/** Fill a ball of voxels, with `pick` choosing each one's colour (or none),
|
|
113
|
+
* given its coordinates. */ export declare let ball: (v: Vox, []: Vec, r: number, pick: (x: number, y: number, z: number) => number | null) => Vox;
|
|
114
|
+
/**
|
|
115
|
+
* Mesh a voxel model into `o`: voxel `size`, placed with its origin at `at`.
|
|
116
|
+
* Every exposed face is rounded along each edge that is convex; faces alike
|
|
117
|
+
* in colour, rounding and shade merge into rectangles. `cell` controls the
|
|
118
|
+
* visible shade grid on those faces without changing their outline.
|
|
119
|
+
*/ export declare let blob: (o: Out, v: Vox, size: number, at?: Vec, round?: number) => Out;
|
|
120
|
+
//# sourceMappingURL=mesh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh.d.ts","sources":["../mesh.ts"],"names":[],"mappings":"AAwBA,YAAY,OAAO,MAAM,EAAE,MAAM,EAAE,MAAM;AAEzC;;;;;mBAKmB,GACnB,YAAY;EACV,KAAK,MAAM;EACX,KAAK,MAAM;EACX,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,IAAI,MAAM;EACV,KAAK,MAAM;;AAGb,OAAO,YAAI,WAAU,IAOnB;AAKF,+CAA+C,GAC/C,OAAO,YAAI,QAAS,MAAM,KAAK,MAAM,KAAK,IAAI,QAAM,IAAI,CAcvD;AAED,uEAAuE,GACvE,YAAY;EACV,OAAO,KAAK;EACZ,SAAS,MAAM,IAAI,MAAM,IAAI,MAAM;;AAGrC,OAAO,YAAI,YAAa,GAAG,QAAM,QA6BhC;AAED;sCACsC,GACtC,YAAY;EACV,KAAK,aAAa;EAClB,KAAK,UAAU;EACf,KAAK,WAAW;EAChB,MAAM,WAAW;EACjB,IAAI,aAAa;EACjB,KAAK,YAAY,eAAe,YAAY;;AAG9C;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,OAAQ,GAAG,QAAM,OAS1B;AAEF,yEAAyE,GACzE,OAAO,YAAI,UAAW,GAAG,WAAS,cAC+B;AAEjE;;;;;2EAK2E,GAC3E,OAAO,YAAI,aAAY;AAqDvB;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,YAAI,SAAU,GAAG,YAAU,MAAM,EAAE,MAAM,IAgC/C;AAED;;;;4DAI4D,GAC5D,OAAO,YAAI,cAAS;AACpB,OAAO,YAAI,cAAS;AAEpB;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,QAAS,KAAK,MAAM,SAAwC;AAEvE,kDAAkD,GAClD,OAAO,YAAI,aAAc,KAAK,MAAM,KAAG,MAAM,CAA+B;AAE5E;0EAC0E,GAC1E,OAAO,YAAI,OAAQ,MAAM,MAAM,MAAI,MAAM,EAAE,MAAM,EACC;AAsBlD;;;;;;;;CAQC,GACD,OAAO,YAAI,OACT,GAAG,KACH,IAAI,KACJ,MAAM,MAAM,EACZ,IAAI,MAAM,EACV,IAAI,MAAM,EACV,MAAM,MAAM,EACZ,GAAG,MAAM,IACT,MAAM,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GACpC,OAAO,MAAM,EACb,MAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GACnC,kBAEC,IAAI,CAiCN;AAmBD,sEAAsE,GACtE,OAAO,YAAI,MAAO,KAAK,MAAM,KAAG,IAI/B;AAED;+BAC+B,GAC/B,YAAY,MAAM,IAAI,MAAM,EAAE,MAAM;AAEpC,YAAI;AACJ,2CAA2C,GAC3C,OAAO,YAAI,MAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,SACJ;AAE7C,yBAAyB,GACzB,OAAO,YAAI,QAAS,GAAG,MAAM,KAAG,IAI/B;AAED,6CAA6C,GAC7C,OAAO,YAAI,MACT,GAAG,KACH,IAAc,GAAG,EACjB,IAAc,GAAG,EACjB,OAAO,MAAM,KACZ,IAOF;AAED;0BAC0B,GAC1B,OAAO,YAAI,OACT,GAAG,KACH,IAAc,GAAG,EACjB,GAAG,MAAM,EACT,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAK,MAAM,GAAG,IAAI,KACvD,IAYF;AAcD;;;;;CAKC,GACD,OAAO,YAAI,OACT,GAAG,KACH,GAAG,KACH,MAAM,MAAM,EACZ,KAAI,KACJ,mBAEC,IA0IF"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Voxel geometry and chunk charts over plain values, without a renderer or a graph. */ export * from "./mesh.js";
|
|
2
|
+
export * from "./boxes.js";
|
|
3
|
+
export * from "./light.js";
|
|
4
|
+
export * from "./stream.js";
|
|
5
|
+
export * from "./chartbook.js";
|
|
6
|
+
export * from "./chartsheet.js";
|
|
7
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA,sFAAsF,GACtF,0BAAyB;AACzB,2BAA0B;AAC1B,2BAA0B;AAC1B,4BAA2B;AAC3B,+BAA8B;AAC9B,gCAA+B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** How near a chunk's nearest point must be, in metres, to be drawn at each
|
|
2
|
+
* detail: the finest within the first ring, the next within the second, and
|
|
3
|
+
* the coarsest out to the edge of sight. */ export declare let RINGS: readonly [number, number];
|
|
4
|
+
/** How much coarser each detail's voxels are than the finest's. */ export declare let COARSER: readonly [number, number, number];
|
|
5
|
+
/** A chunk to draw, `ci` across and `ck` down, at a detail (0 the finest),
|
|
6
|
+
* and how far its nearest point is, in metres. */ export type Want = {
|
|
7
|
+
ci: number;
|
|
8
|
+
ck: number;
|
|
9
|
+
lod: number;
|
|
10
|
+
d: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Every chunk of `chunkSize` metres to draw from (x, z), nearest first: each one within `sight`
|
|
14
|
+
* metres, at its detail, and each drawn one still within `sight` and SLACK,
|
|
15
|
+
* at the detail it has unless it strayed past its ring. `has` says what a
|
|
16
|
+
* chunk is drawn at now; `per`, when the world has edges, keeps to chunks 0
|
|
17
|
+
* to `per` − 1 each way.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { assertEquals } from '@std/assert'
|
|
21
|
+
* let of = (w: Want[], ci: number, ck: number) =>
|
|
22
|
+
* w.find((c) => c.ci == ci && c.ck == ck)?.lod
|
|
23
|
+
* // Standing in chunk (0, 0) of 32 m chunks: it is drawn finest, a chunk
|
|
24
|
+
* // 48 m off coarser, one 80 m off coarser again, and one past sight not at
|
|
25
|
+
* // all.
|
|
26
|
+
* let w = wanted(32, 16, 16, 110, () => undefined)
|
|
27
|
+
* assertEquals([of(w, 0, 0), of(w, 2, 0), of(w, 3, 0), of(w, 4, 0)], [0, 1, 2, undefined])
|
|
28
|
+
* assertEquals(w[0], { ci: 0, ck: 0, lod: 0, d: 0 })
|
|
29
|
+
* // A world with edges draws nothing past them.
|
|
30
|
+
* assertEquals(wanted(32, 16, 16, 110, () => undefined, 4).every((c) => c.ci >= 0 && c.ci < 4), true)
|
|
31
|
+
* ```
|
|
32
|
+
*/ export declare let wanted: (chunkSize: number, x: number, z: number, sight: number, has: (ci: number, ck: number) => number | undefined, per: number) => Want[];
|
|
33
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sources":["../stream.ts"],"names":[],"mappings":"AAOA;;0CAE0C,GAC1C,OAAO,YAAI,iCAAgB;AAC3B,iEAAiE,GACjE,OAAO,YAAI,2CAAmB;AAM9B;gDACgD,GAChD,YAAY;EAAS,IAAI,MAAM;EAAE,IAAI,MAAM;EAAE,KAAK,MAAM;EAAE,GAAG,MAAM;;AAuBnE;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,YAAI,SACT,WAAW,MAAM,EACjB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,OAAO,MAAM,EACb,MAAM,IAAI,MAAM,EAAE,IAAI,MAAM,KAAK,MAAM,GAAG,SAAS,EACnD,gBACC,OAcF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../../three/mod.ts"],"names":[],"mappings":"AAAA,sFAAsF,GACtF,0BAAyB;AACzB,2BAA0B;AAC1B,4BAA2B;AAG3B,4BAA2B"}
|