@margoengine/voxel 0.0.0-stage → 1.0.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 +201 -0
- package/NOTICE +4 -0
- package/README.md +1670 -2
- package/dist/bevel.d.ts +79 -0
- package/dist/bevel.js +453 -0
- package/dist/blocks-BabtpQT-.js +179 -0
- package/dist/blocks.d.ts +220 -0
- package/dist/border.d.ts +9 -0
- package/dist/chunk-BCoaKSn4.js +158 -0
- package/dist/chunk.d.ts +112 -0
- package/dist/codec-BmXhcsFt.js +412 -0
- package/dist/codec.d.ts +125 -0
- package/dist/codec.js +1 -0
- package/dist/debris.d.ts +114 -0
- package/dist/debris.js +387 -0
- package/dist/faces-DUR7LhrN.js +146 -0
- package/dist/faces.d.ts +7 -0
- package/dist/fluids.d.ts +74 -0
- package/dist/fluids.js +226 -0
- package/dist/generate.d.ts +78 -0
- package/dist/generate.js +99 -0
- package/dist/gi.d.ts +76 -0
- package/dist/gi.js +264 -0
- package/dist/gpu-mesher.d.ts +77 -0
- package/dist/gpu-mesher.js +461 -0
- package/dist/granular-mpm.d.ts +40 -0
- package/dist/granular-mpm.js +46 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/light-rgb.d.ts +71 -0
- package/dist/light-rgb.js +287 -0
- package/dist/light-worker.d.ts +84 -0
- package/dist/light-worker.js +110 -0
- package/dist/light.d.ts +108 -0
- package/dist/light.js +332 -0
- package/dist/light.worker.d.ts +1 -0
- package/dist/lightmap.d.ts +50 -0
- package/dist/lightmap.js +68 -0
- package/dist/lod.d.ts +87 -0
- package/dist/lod.js +182 -0
- package/dist/mesher.d.ts +214 -0
- package/dist/mesher.js +539 -0
- package/dist/mesher.worker.d.ts +1 -0
- package/dist/model-data-D_rIKJCQ.js +41 -0
- package/dist/model-data.d.ts +21 -0
- package/dist/model-mesh-C4Gi6bMM.js +122 -0
- package/dist/model-mesh.d.ts +21 -0
- package/dist/model-surface.d.ts +5 -0
- package/dist/models.d.ts +74 -0
- package/dist/models.js +308 -0
- package/dist/objects.d.ts +73 -0
- package/dist/objects.js +152 -0
- package/dist/octants-C_Ic7gdn.js +10 -0
- package/dist/octants.d.ts +16 -0
- package/dist/origin-DsMelUxs.js +23 -0
- package/dist/origin.d.ts +7 -0
- package/dist/physics.d.ts +147 -0
- package/dist/physics.js +486 -0
- package/dist/query.d.ts +166 -0
- package/dist/query.js +305 -0
- package/dist/render-post.d.ts +6 -0
- package/dist/render.d.ts +296 -0
- package/dist/render.js +1616 -0
- package/dist/shared/borrowed.d.ts +44 -0
- package/dist/smooth-CEwHkXli.js +968 -0
- package/dist/smooth-clip.d.ts +24 -0
- package/dist/smooth-lod.d.ts +118 -0
- package/dist/smooth-lod.js +244 -0
- package/dist/smooth.d.ts +171 -0
- package/dist/smooth.js +1 -0
- package/dist/stream.d.ts +201 -0
- package/dist/stream.js +402 -0
- package/dist/terrain.worker.d.ts +1 -0
- package/dist/textures.d.ts +86 -0
- package/dist/ticks.d.ts +126 -0
- package/dist/ticks.js +239 -0
- package/dist/unit-light-Ch7roJgB.js +7 -0
- package/dist/vox.d.ts +237 -0
- package/dist/vox.js +780 -0
- package/dist/wind-data.d.ts +13 -0
- package/dist/wind.d.ts +68 -0
- package/dist/wind.js +170 -0
- package/dist/worker-DlGRxlc4.js +44 -0
- package/dist/worker-pool-sPyC6jCE.js +93 -0
- package/dist/workers/light.js +1 -0
- package/dist/workers/mesher.js +1 -0
- package/dist/workers/terrain.js +1 -0
- package/dist/world-CelTlft2.js +153 -0
- package/dist/world.d.ts +117 -0
- package/package.json +173 -4
package/dist/light.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
|
+
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
+
|
|
4
|
+
import { i as e, r as t } from "./octants-C_Ic7gdn.js";
|
|
5
|
+
import { i as n } from "./chunk-BCoaKSn4.js";
|
|
6
|
+
import { n as r, t as i } from "./world-CelTlft2.js";
|
|
7
|
+
import { MargoError as a } from "@margoengine/math/errors";
|
|
8
|
+
//#region src/light.ts
|
|
9
|
+
var o = 15, s = -32768, c = 8192, l = (1 << 27) - 1, u = [
|
|
10
|
+
0,
|
|
11
|
+
10,
|
|
12
|
+
5
|
|
13
|
+
], d = 1, f = 2, p = 4, m = 256, h = 512, g = 4096, _ = Uint8Array.from({ length: 256 }, (e, t) => {
|
|
14
|
+
let n = 0;
|
|
15
|
+
for (let e = 0; e < 6; e++) {
|
|
16
|
+
let r = 1 << (e >> 1), i = e & 1 ? 0 : r, a = !0;
|
|
17
|
+
for (let e = 0; e < 8; e++) (e & r) === i && !(t >> e & 1) && (a = !1);
|
|
18
|
+
a && (n |= 1 << e);
|
|
19
|
+
}
|
|
20
|
+
return n;
|
|
21
|
+
}), v = /* @__PURE__ */ new WeakSet(), y = (e) => {
|
|
22
|
+
if (typeof e != "number") throw TypeError("VoxelLighting budget must be a number; pass cells per update");
|
|
23
|
+
if (!(e === Infinity || Number.isInteger(e) && e >= 1)) throw RangeError(`VoxelLighting budget ${e} is not an integer >= 1; pass cells per update or Infinity`);
|
|
24
|
+
return e;
|
|
25
|
+
}, b = (e) => {
|
|
26
|
+
let t = e & 31, n = e >> 10, r = e >> 5 & 31;
|
|
27
|
+
if (t && t < 31 && n && n < 31 && r && r < 31) return c;
|
|
28
|
+
let i = (e) => e ? e === 31 ? 6 : 2 : 3, a = i(t), o = i(n), s = i(r), l = 0;
|
|
29
|
+
for (let e = 0; e < 3; e++) for (let t = 0; t < 3; t++) for (let n = 0; n < 3; n++) a >> e & o >> t & s >> n & 1 && (l |= 1 << e + 3 * t + 9 * n);
|
|
30
|
+
return l;
|
|
31
|
+
}, x = class o {
|
|
32
|
+
static attach(e, t = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
33
|
+
return new o(e, t);
|
|
34
|
+
}
|
|
35
|
+
constructor(e, t) {
|
|
36
|
+
if (this.flags = /* @__PURE__ */ new Uint16Array(65536), this.parts = !1, this.wet = /* @__PURE__ */ new Uint8Array(65536), this.types = 0, this.disposed = !1, this.sections = /* @__PURE__ */ new Map(), this.columns = /* @__PURE__ */ new Map(), this.loads = [], this.loadHead = 0, this.edits = [], this.editHead = 0, this.addS = [], this.addI = [], this.addHead = 0, this.cutS = [], this.cutE = [], this.cutHead = 0, this.touched = [], this.j = 0, !(e instanceof i)) throw TypeError("VoxelLighting.attach expects a VoxelWorld; pass new VoxelWorld({blocks})");
|
|
37
|
+
if (!t || typeof t != "object") throw TypeError("VoxelLighting options must be an object");
|
|
38
|
+
if (this.limit = y(t.budget ?? 4096), v.has(e)) throw new a("attached", "VoxelWorld already has a VoxelLighting; dispose() it before attaching another");
|
|
39
|
+
v.add(e), this.world = e, this.refresh(), this.offChunk = e.onChunk((e, t, n, r) => {
|
|
40
|
+
this.loads.push([
|
|
41
|
+
e,
|
|
42
|
+
t,
|
|
43
|
+
n,
|
|
44
|
+
r
|
|
45
|
+
]);
|
|
46
|
+
}), this.offChange = e.onChange((t, n, r, i, a) => {
|
|
47
|
+
this.types !== e.blocks.table.length && this.refresh();
|
|
48
|
+
let o = this.flags[i & 65535], s = this.flags[a & 65535];
|
|
49
|
+
if ((o | s) & m && i !== a) return void this.edits.push(t, n, r, 7);
|
|
50
|
+
if (o === s) return;
|
|
51
|
+
let c = (o & 15) - (s & 15);
|
|
52
|
+
this.edits.push(t, n, r, (c ? d : 0) | (c > 0 ? 6 : 0) | (o >> 4 < s >> 4 ? p : 0));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
get budget() {
|
|
56
|
+
return this.limit;
|
|
57
|
+
}
|
|
58
|
+
set budget(e) {
|
|
59
|
+
this.limit = y(e);
|
|
60
|
+
}
|
|
61
|
+
skyLight(e, t, n) {
|
|
62
|
+
let r = this.chunkAt(e, t, n);
|
|
63
|
+
if (r) return r.getLight(e & 31, t & 31, n & 31) >> 4;
|
|
64
|
+
let i = this.world.heightmap(e >> 5, n >> 5);
|
|
65
|
+
return i && t <= i[e & 31 | (n & 31) << 5] ? 0 : 15;
|
|
66
|
+
}
|
|
67
|
+
blockLight(e, t, n) {
|
|
68
|
+
let r = this.chunkAt(e, t, n);
|
|
69
|
+
return r ? r.getLight(e & 31, t & 31, n & 31) & 15 : 0;
|
|
70
|
+
}
|
|
71
|
+
update() {
|
|
72
|
+
if (this.disposed) throw new a("disposed", "VoxelLighting is disposed; attach a new one with VoxelLighting.attach(world)");
|
|
73
|
+
this.types !== this.world.blocks.table.length && this.refresh();
|
|
74
|
+
let { limit: e, loads: t, edits: n } = this, r = 0;
|
|
75
|
+
for (; r < e && this.loadHead < t.length;) r += this.load(t[this.loadHead++]);
|
|
76
|
+
if (this.loadHead === t.length) {
|
|
77
|
+
for (t.length = this.loadHead = 0; r < e && this.editHead < n.length; this.editHead += 4) {
|
|
78
|
+
let e = this.editHead;
|
|
79
|
+
r += this.edit(n[e], n[e + 1], n[e + 2], n[e + 3]);
|
|
80
|
+
}
|
|
81
|
+
if (this.editHead === n.length) {
|
|
82
|
+
for (n.length = this.editHead = 0; r < e && this.cutHead < this.cutE.length; r++) this.unspread();
|
|
83
|
+
if (this.cutHead === this.cutE.length) {
|
|
84
|
+
for (this.cutS.length = this.cutE.length = this.cutHead = 0; r < e && this.addHead < this.addI.length; r++) this.spread();
|
|
85
|
+
this.addHead === this.addI.length && (this.addS.length = this.addI.length = this.addHead = 0);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return this.flush(), r;
|
|
90
|
+
}
|
|
91
|
+
dispose() {
|
|
92
|
+
this.disposed || (this.disposed = !0, this.offChange(), this.offChunk(), v.delete(this.world), this.loads.length = this.edits.length = this.addI.length = this.addS.length = this.cutE.length = 0, this.cutS.length = this.touched.length = 0, this.sections.clear(), this.columns.clear());
|
|
93
|
+
}
|
|
94
|
+
[Symbol.dispose ?? Symbol()]() {
|
|
95
|
+
this.dispose();
|
|
96
|
+
}
|
|
97
|
+
chunkAt(e, t, n) {
|
|
98
|
+
if ((e | 0) !== e || (t | 0) !== t || (n | 0) !== n) throw [
|
|
99
|
+
e,
|
|
100
|
+
t,
|
|
101
|
+
n
|
|
102
|
+
].every((e) => typeof e == "number") ? /* @__PURE__ */ RangeError(`Cell (${e}, ${t}, ${n}) is not three 32-bit integers; floor positions to cells first`) : /* @__PURE__ */ TypeError("Cell coordinates must be numbers");
|
|
103
|
+
return this.world.getChunk(e >> 5, t >> 5, n >> 5);
|
|
104
|
+
}
|
|
105
|
+
refresh() {
|
|
106
|
+
let e = this.world.blocks.table;
|
|
107
|
+
for (let t of e) {
|
|
108
|
+
let n = t.model || t.shape === "slab" ? m : t.shape === "stair" ? 768 : 0;
|
|
109
|
+
this.flags[t.id] = t.opacity | t.light << 4 | n, this.wet[t.id] = t.waterlog ? e[t.waterlog]?.opacity ?? 0 : 0, n && (this.parts = !0);
|
|
110
|
+
}
|
|
111
|
+
this.types = e.length;
|
|
112
|
+
}
|
|
113
|
+
state(n, r) {
|
|
114
|
+
let i = n.chunk.get(r & 31, r >> 10, r >> 5 & 31), a = this.flags[i & 65535];
|
|
115
|
+
if (!(a & m)) return a;
|
|
116
|
+
let o = this.world.blocks.table[i & 65535]?.model;
|
|
117
|
+
if (o) return a | o[(i >>> 16) % o.length].covered << 10;
|
|
118
|
+
let s = i >>> 16, c = s & 32768 ? Math.max(a & 15, this.wet[i & 65535]) : a & 15;
|
|
119
|
+
return a & -16 | c | _[a & h ? e(s) : t(s)] << 10;
|
|
120
|
+
}
|
|
121
|
+
shut(e, t, n) {
|
|
122
|
+
return (e >> 10 + n & 1) == 1 || (t >> 10 + (n ^ 1) & 1) == 1;
|
|
123
|
+
}
|
|
124
|
+
top(e, t, n) {
|
|
125
|
+
!(n & m) || n & g || (this.put(e, t, 240 | this.light(e, t) & 15), this.push(e, t));
|
|
126
|
+
}
|
|
127
|
+
cover(e, t, n) {
|
|
128
|
+
if (this.parts && n !== s) {
|
|
129
|
+
for (let r of e) if (n >> 5 === r.cy) {
|
|
130
|
+
let e = t | (n & 31) << 10;
|
|
131
|
+
this.state(r, e) & m && this.clear(r, e, 0);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
light(e, t) {
|
|
136
|
+
return e.chunk.getLight(t & 31, t >> 10, t >> 5 & 31);
|
|
137
|
+
}
|
|
138
|
+
put(e, t, n) {
|
|
139
|
+
e.chunk.setLight(t & 31, t >> 10, t >> 5 & 31, n), e.uniform = -1, e.touched || this.touched.push(e), e.touched |= b(t);
|
|
140
|
+
}
|
|
141
|
+
push(e, t) {
|
|
142
|
+
this.addS.push(e), this.addI.push(t);
|
|
143
|
+
}
|
|
144
|
+
cut(e, t, n, r) {
|
|
145
|
+
this.cutS.push(e), this.cutE.push(t | r << 15 | n << 19);
|
|
146
|
+
}
|
|
147
|
+
near(e, t, n) {
|
|
148
|
+
let r = u[n >> 1], i = t >> r & 31;
|
|
149
|
+
if (n & 1) {
|
|
150
|
+
if (i) return this.j = t - (1 << r), e;
|
|
151
|
+
this.j = t + (31 << r);
|
|
152
|
+
} else {
|
|
153
|
+
if (i < 31) return this.j = t + (1 << r), e;
|
|
154
|
+
this.j = t - (31 << r);
|
|
155
|
+
}
|
|
156
|
+
return e.links[n];
|
|
157
|
+
}
|
|
158
|
+
relax(e, t, n, r) {
|
|
159
|
+
let i = this.light(t, n);
|
|
160
|
+
if ((e >> 4) - 1 <= i >> 4 && (e & 15) - 1 <= (i & 15)) return;
|
|
161
|
+
let a = this.state(t, n);
|
|
162
|
+
if (a >> 10 + r & 1) return;
|
|
163
|
+
let o = a & 15, s = (e >> 4) - 1 - o, c = (e & 15) - 1 - o;
|
|
164
|
+
(s > i >> 4 || c > (i & 15)) && (this.put(t, n, Math.max(s, i >> 4) << 4 | Math.max(c, i & 15)), this.push(t, n));
|
|
165
|
+
}
|
|
166
|
+
spread() {
|
|
167
|
+
let e = this.addHead++, t = this.addS[e], n = this.addI[e];
|
|
168
|
+
if (t.removed) return;
|
|
169
|
+
let r = this.light(t, n);
|
|
170
|
+
if (r >> 4 <= 1 && (r & 15) <= 1) return;
|
|
171
|
+
let i = this.parts ? this.state(t, n) >> 10 : 0;
|
|
172
|
+
for (let e = 0; e < 6; e++) {
|
|
173
|
+
let a = i >> e & 1 ? void 0 : this.near(t, n, e);
|
|
174
|
+
a && this.relax(r, a, this.j, e ^ 1);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
unspread() {
|
|
178
|
+
let e = this.cutHead++, t = this.cutS[e], n = this.cutE[e], r = n & 32767, i = n >> 15 & 15, a = n >> 19, o = this.parts && !t.removed ? this.state(t, r) : 0;
|
|
179
|
+
for (let e = 0; e < 6; e++) {
|
|
180
|
+
let n = this.near(t, r, e);
|
|
181
|
+
if (!n || n.removed) continue;
|
|
182
|
+
let s = this.j, c = this.light(n, s), l = a ? c & 15 : c >> 4;
|
|
183
|
+
if (!l) continue;
|
|
184
|
+
let u = this.state(n, s);
|
|
185
|
+
if (this.parts && this.shut(o, u, e)) continue;
|
|
186
|
+
let d = a ? u >> 4 & 15 : 0;
|
|
187
|
+
l < i && d < l ? (this.put(n, s, a ? c & 240 | d : c & 15), this.cut(n, s, a, l), d && this.push(n, s)) : t.removed || this.push(n, s);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
clear(e, t, n) {
|
|
191
|
+
let r = this.light(e, t), i = n ? r & 15 : r >> 4;
|
|
192
|
+
i && (this.put(e, t, n ? r & 240 : r & 15), this.cut(e, t, n, i));
|
|
193
|
+
}
|
|
194
|
+
pull(e, t) {
|
|
195
|
+
for (let n = 0; n < 6; n++) {
|
|
196
|
+
let r = this.near(e, t, n);
|
|
197
|
+
r && this.push(r, this.j);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
shade(e, t, n, r) {
|
|
201
|
+
let i = 0;
|
|
202
|
+
for (let a of e) {
|
|
203
|
+
let e = Math.max(n, a.cy << 5), o = Math.min(r, (a.cy << 5) + 31);
|
|
204
|
+
for (let n = e; n <= o; n++, i++) this.clear(a, t | (n & 31) << 10, 0);
|
|
205
|
+
}
|
|
206
|
+
return i;
|
|
207
|
+
}
|
|
208
|
+
open(e, t, n, r) {
|
|
209
|
+
let i = 0;
|
|
210
|
+
for (let a of e) {
|
|
211
|
+
let e = a.cy << 5;
|
|
212
|
+
if (!(e > r)) for (let o = Math.min(r, e + 31); o >= e; o--, i++) {
|
|
213
|
+
let e = n | (o & 31) << 10, r = this.state(a, e);
|
|
214
|
+
if (r & 271) return t[n] = o, this.top(a, e, r), i;
|
|
215
|
+
this.put(a, e, 240 | this.light(a, e) & 15), this.push(a, e);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return t[n] = s, i;
|
|
219
|
+
}
|
|
220
|
+
edit(e, t, n, i) {
|
|
221
|
+
let a = e >> 5, o = n >> 5, s = this.sections.get(r(a, t >> 5, o));
|
|
222
|
+
if (!s) return 1;
|
|
223
|
+
let c = e & 31 | (n & 31) << 5 | (t & 31) << 10, l = this.state(s, c), u = 1;
|
|
224
|
+
if (i & d) {
|
|
225
|
+
let e = this.world.heightmap(a, o), n = this.columns.get(`${a},${o}`), r = c & 1023, d = e[r];
|
|
226
|
+
l & 271 && t > d ? (this.cover(n, r, d), u += this.shade(n, r, d + 1, t), e[r] = t) : !(l & 271) && t === d ? u += this.open(n, e, r, t) : t <= d && i & f && this.clear(s, c, 0), t === e[r] && this.top(s, c, l);
|
|
227
|
+
}
|
|
228
|
+
i & p && this.clear(s, c, 1), this.pull(s, c);
|
|
229
|
+
let m = this.light(s, c);
|
|
230
|
+
return (l >> 4 & 15) > (m & 15) && (this.put(s, c, m & 240 | l >> 4 & 15), this.push(s, c)), u;
|
|
231
|
+
}
|
|
232
|
+
load([e, t, i, a]) {
|
|
233
|
+
let o = r(e, t, i);
|
|
234
|
+
if (!a) return this.unload(o);
|
|
235
|
+
if (this.world.getChunk(e, t, i) !== a) return 1;
|
|
236
|
+
let { flags: c } = this, d = this.world.heightmap(e, i), f = `${e},${i}`, p = this.columns.get(f) ?? [], m = t << 5, h = m + 31;
|
|
237
|
+
a.fillLight(0);
|
|
238
|
+
let g = !1, _ = !1, v = 1, y = 1024;
|
|
239
|
+
for (let e of n(a)) g ||= (c[e & 65535] & 271) > 0, _ ||= (c[e & 65535] & 240) > 0;
|
|
240
|
+
for (let e = 0; e < 1024; e++) {
|
|
241
|
+
let t = s;
|
|
242
|
+
if (g) {
|
|
243
|
+
for (let n = 31; n >= 0; n--, y++) if (c[a.get(e & 31, n, e >> 5) & 65535] & 271) {
|
|
244
|
+
t = m + n;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
let n = d[e];
|
|
249
|
+
n > h || (n >= m ? t === s ? v += this.open(p, d, e, m - 1) : d[e] = t : t !== s && (this.cover(p, e, n), v += this.shade(p, e, n + 1, m - 1), d[e] = t));
|
|
250
|
+
}
|
|
251
|
+
let b = {
|
|
252
|
+
chunk: a,
|
|
253
|
+
cx: e,
|
|
254
|
+
cy: t,
|
|
255
|
+
cz: i,
|
|
256
|
+
links: [],
|
|
257
|
+
removed: !1,
|
|
258
|
+
touched: 0,
|
|
259
|
+
uniform: -1
|
|
260
|
+
};
|
|
261
|
+
this.sections.set(o, b);
|
|
262
|
+
let x = 0;
|
|
263
|
+
for (; x < p.length && p[x].cy > t;) x++;
|
|
264
|
+
p.splice(x, 0, b), this.columns.set(f, p);
|
|
265
|
+
for (let n = 0; n < 6; n++) {
|
|
266
|
+
let a = n & 1 ? -1 : 1, o = this.sections.get(r(e + (n < 2 ? a : 0), t + (n >> 1 == 1 ? a : 0), i + (n > 3 ? a : 0)));
|
|
267
|
+
b.links[n] = o, o && (o.links[n ^ 1] = b);
|
|
268
|
+
}
|
|
269
|
+
let S = (e) => Math.min(32, Math.max(0, d[e] + 1 - m)), C = !0, w = !0;
|
|
270
|
+
for (let e = 0; e < 1024; e++) C &&= S(e) === 0, w &&= S(e) === 32;
|
|
271
|
+
if (a.fillLight(C ? 240 : 0), b.uniform = C ? 240 : w ? 0 : -1, !C) for (let e = 0; e < 1024; e++) {
|
|
272
|
+
let t = S(e), n = e & 31, r = e >> 5;
|
|
273
|
+
for (let e = t; e < 32; e++, y++) a.setLight(n, e, r, 240);
|
|
274
|
+
if (this.parts && t && d[e] === m + t - 1 && this.top(b, e | t - 1 << 10, this.state(b, e | t - 1 << 10)), !(t > 31)) {
|
|
275
|
+
t && this.push(b, e | t << 10);
|
|
276
|
+
for (let i of [
|
|
277
|
+
n < 31 ? e + 1 : -1,
|
|
278
|
+
n ? e - 1 : -1,
|
|
279
|
+
r < 31 ? e + 32 : -1,
|
|
280
|
+
r ? e - 32 : -1
|
|
281
|
+
]) if (i >= 0) for (let n = t; n < S(i); n++) this.push(b, e | n << 10);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (_) for (let e = 0; e < 32768; e++, y++) {
|
|
285
|
+
let t = this.state(b, e) >> 4 & 15;
|
|
286
|
+
t && (this.put(b, e, this.light(b, e) & 240 | t), this.push(b, e));
|
|
287
|
+
}
|
|
288
|
+
for (let e = 0; e < 6; e++) {
|
|
289
|
+
let t = b.links[e];
|
|
290
|
+
if (!t || b.uniform >= 0 && t.uniform === b.uniform) continue;
|
|
291
|
+
let n = u[e >> 1], [r, i] = u.filter((e) => e !== n), a = e & 1 ? 0 : 31 << n, o = e & 1 ? 31 << n : 0;
|
|
292
|
+
for (let n = 0; n < 32; n++) for (let s = 0; s < 32; s++) {
|
|
293
|
+
let c = n << r | s << i, l = this.parts ? this.state(t, c | o) >> 10 & 1 << (e ^ 1) : 0, u = this.parts ? this.state(b, c | a) >> 10 & 1 << e : 0;
|
|
294
|
+
l || this.relax(this.light(t, c | o), b, c | a, e), u || this.relax(this.light(b, c | a), t, c | o, e ^ 1);
|
|
295
|
+
}
|
|
296
|
+
y += 2048;
|
|
297
|
+
}
|
|
298
|
+
return b.touched || this.touched.push(b), b.touched = l, v + (y >> 3);
|
|
299
|
+
}
|
|
300
|
+
unload(e) {
|
|
301
|
+
let t = this.sections.get(e);
|
|
302
|
+
if (!t) return 1;
|
|
303
|
+
this.sections.delete(e), t.removed = !0;
|
|
304
|
+
let n = `${t.cx},${t.cz}`, r = this.columns.get(n);
|
|
305
|
+
r.splice(r.indexOf(t), 1), r.length || this.columns.delete(n);
|
|
306
|
+
let i = 1;
|
|
307
|
+
for (let e = 0; e < 6; e++) {
|
|
308
|
+
let n = t.links[e];
|
|
309
|
+
if (!n) continue;
|
|
310
|
+
n.links[e ^ 1] = void 0;
|
|
311
|
+
let r = u[e >> 1], [a, o] = u.filter((e) => e !== r), s = e & 1 ? 0 : 31 << r;
|
|
312
|
+
for (let e = 0; e < 32; e++) for (let n = 0; n < 32; n++) {
|
|
313
|
+
let r = e << a | n << o | s, i = this.light(t, r);
|
|
314
|
+
i >> 4 && this.cut(t, r, 0, i >> 4), i & 15 && this.cut(t, r, 1, i & 15);
|
|
315
|
+
}
|
|
316
|
+
i += 128;
|
|
317
|
+
}
|
|
318
|
+
return i;
|
|
319
|
+
}
|
|
320
|
+
flush() {
|
|
321
|
+
for (let e of this.touched) {
|
|
322
|
+
for (let t = 0; t < 27; t++) if (!e.removed && e.touched >> t & 1) {
|
|
323
|
+
let n = r(e.cx + t % 3 - 1, e.cy + (t / 3 | 0) % 3 - 1, e.cz + (t / 9 | 0) - 1);
|
|
324
|
+
this.sections.has(n) && this.world.dirty.add(n);
|
|
325
|
+
}
|
|
326
|
+
e.touched = 0;
|
|
327
|
+
}
|
|
328
|
+
this.touched.length = 0;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
//#endregion
|
|
332
|
+
export { o as MAX_LIGHT, x as VoxelLighting };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Borrowable } from './shared/borrowed.js';
|
|
2
|
+
/** Options of {@link voxelLightmap}: an atlas from `@margoengine/lightmap` and the quads it was baked for. */
|
|
3
|
+
export interface VoxelLightmapOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The atlas: a 2D texture with TEXTURE_BINDING usage holding linear light (not sRGB), or `(device) => texture`,
|
|
6
|
+
* called once per device, so the baked light comes back by itself after a device restore. Borrowed, never
|
|
7
|
+
* destroyed. A plain texture is lost with its device: the renderer goes on with live lighting, `engine.onError`
|
|
8
|
+
* hears of it once (`'state'`, #borrowed-lost), and assigning a new `voxelLightmap` brings the baked light back.
|
|
9
|
+
*/
|
|
10
|
+
texture: Borrowable<GPUTexture>;
|
|
11
|
+
/**
|
|
12
|
+
* The charts: 12 numbers per quad, corners p0 to p3 counterclockwise from outside, axis-aligned rectangles on integer
|
|
13
|
+
* world cells in [-16,777,215, 16,777,215]. At most 32,768 quads covering 1,048,576 cell faces, no two on one face.
|
|
14
|
+
*/
|
|
15
|
+
positions: ArrayLike<number>;
|
|
16
|
+
/** Atlas coordinates in [0, 1]: 8 numbers per quad, in the corner order of `positions`. */
|
|
17
|
+
uv: ArrayLike<number>;
|
|
18
|
+
/** Decode multiplier of the atlas (`lightmapScale` of the bake), >= 1. Default 1. */
|
|
19
|
+
scale?: number;
|
|
20
|
+
/**
|
|
21
|
+
* What the atlas holds, as the bake's `radiometry`: `'legacy'` light is multiplied by the diffuse colour as is,
|
|
22
|
+
* `'physical'` irradiance is divided by pi first (Lambertian diffuse). Default `'legacy'`.
|
|
23
|
+
*/
|
|
24
|
+
radiometry?: 'legacy' | 'physical';
|
|
25
|
+
}
|
|
26
|
+
/** Baked light ready for `VoxelRenderer.lightmap`, from {@link voxelLightmap}. */
|
|
27
|
+
export interface VoxelLightmap {
|
|
28
|
+
/** The atlas texture or the function that makes it per device, as given (borrowed). */
|
|
29
|
+
readonly texture: Borrowable<GPUTexture>;
|
|
30
|
+
/** A header, then 24 floats per chart: corner, u and v edges with inverse squared lengths, normal, atlas corners. */
|
|
31
|
+
readonly charts: Float32Array;
|
|
32
|
+
/** Hash index of every covered cell face: x, y, z, (chart + 1) << 3 | face; at most 16 probes per lookup. */
|
|
33
|
+
readonly index: Int32Array;
|
|
34
|
+
/** @internal A voxel beauty shader with the baked light composed in. */
|
|
35
|
+
shader(code: string): string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Prepares baked light for `VoxelRenderer.lightmap`: the charts are copied and indexed. Fragments on a chart then take
|
|
39
|
+
* the atlas's light times their diffuse colour instead of the sun and ambient terms; emission still adds.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const atlas = await bakeLightmap({ positions, albedo }, { radiometry: 'physical' });
|
|
43
|
+
* voxels.lightmap = voxelLightmap({ texture: (device) => uploadAtlas(device), positions, uv: atlas.uv, scale: atlas.lightmapScale, radiometry: 'physical' });
|
|
44
|
+
* ```
|
|
45
|
+
* @throws TypeError without a texture or texture function, for a `radiometry` other than `'legacy'` or `'physical'`, or a chart that is
|
|
46
|
+
* not an axis-aligned rectangle.
|
|
47
|
+
* @throws RangeError for chart counts, coordinates, UVs or `scale` out of range, overlapping charts, or an index that
|
|
48
|
+
* cannot meet its 16-probe budget in 64 MiB.
|
|
49
|
+
*/
|
|
50
|
+
export declare function voxelLightmap(options: VoxelLightmapOptions): VoxelLightmap;
|
package/dist/lightmap.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/lightmap.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return {
|
|
4
|
+
texture: e?.texture,
|
|
5
|
+
...t(e),
|
|
6
|
+
shader: n
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function t(e) {
|
|
10
|
+
if (!e || typeof e.texture != "function" && typeof e.texture?.createView != "function") throw TypeError("voxelLightmap needs {texture, positions, uv}; pass the uploaded atlas or (device) => GPUTexture");
|
|
11
|
+
let { positions: t, uv: n } = e, r = e.scale ?? 1, i = t?.length / 12;
|
|
12
|
+
if (!(r >= 1 && Math.fround(r) < Infinity)) throw RangeError(`voxelLightmap scale ${r} must be finite and at least 1`);
|
|
13
|
+
if (e.radiometry !== void 0 && e.radiometry !== "legacy" && e.radiometry !== "physical") throw TypeError("voxelLightmap radiometry must be 'legacy' or 'physical', as the bake's");
|
|
14
|
+
if (!Number.isInteger(i) || i < 1 || i > 32768 || n?.length !== i * 8) throw RangeError("voxelLightmap needs 1 to 32,768 quads: 12 positions and 8 uv numbers per quad");
|
|
15
|
+
let a = new Float32Array(4 + i * 24), o = [], s = /* @__PURE__ */ new Set();
|
|
16
|
+
a[0] = i, a[1] = e.radiometry === "physical" ? r / Math.PI : r;
|
|
17
|
+
for (let e = 0; e < i; e++) {
|
|
18
|
+
let r = e * 12, i = 4 + e * 24, c = [
|
|
19
|
+
t[r],
|
|
20
|
+
t[r + 1],
|
|
21
|
+
t[r + 2]
|
|
22
|
+
], l = c.map((e, n) => t[r + 3 + n] - e), u = c.map((e, n) => t[r + 9 + n] - e), d = l.findIndex((e) => e !== 0), f = u.findIndex((e) => e !== 0);
|
|
23
|
+
for (let e = 0; e < 12; e++) if (!Number.isInteger(t[r + e]) || Math.abs(t[r + e]) > 16777215) throw RangeError("voxelLightmap charts must use integer cells in [-16777215, 16777215]");
|
|
24
|
+
if (d < 0 || f < 0 || d === f || l.some((e, t) => t !== d && e !== 0) || u.some((e, t) => t !== f && e !== 0) || c.some((e, n) => t[r + 6 + n] - e !== l[n] + u[n])) throw TypeError("voxelLightmap charts must be axis-aligned rectangles; pass voxel mesh quads");
|
|
25
|
+
let p = [
|
|
26
|
+
l[1] * u[2] - l[2] * u[1],
|
|
27
|
+
l[2] * u[0] - l[0] * u[2],
|
|
28
|
+
l[0] * u[1] - l[1] * u[0]
|
|
29
|
+
], m = p.findIndex((e) => e !== 0), h = m * 2 + +(p[m] < 0), g = c.map((e, t) => Math.min(e, e + l[t] + u[t])), _ = c.map((e, t) => Math.max(e, e + l[t] + u[t]));
|
|
30
|
+
if (o.length / 4 + Math.abs(l[d] * u[f]) > 1048576) throw RangeError("voxelLightmap charts cover over 1,048,576 cell faces; bake fewer surfaces");
|
|
31
|
+
_[m] = g[m] + 1;
|
|
32
|
+
for (let t = g[1]; t < _[1]; t++) for (let n = g[2]; n < _[2]; n++) for (let r = g[0]; r < _[0]; r++) {
|
|
33
|
+
let i = `${r},${t},${n},${h}`;
|
|
34
|
+
if (s.has(i)) throw RangeError(`voxelLightmap charts overlap at cell ${r},${t},${n}; give each face one chart`);
|
|
35
|
+
s.add(i), o.push(r, t, n, e + 1 << 3 | h);
|
|
36
|
+
}
|
|
37
|
+
for (let t = 0; t < 8; t++) if (!(n[e * 8 + t] >= 0 && n[e * 8 + t] <= 1)) throw RangeError("voxelLightmap uv coordinates must be in [0, 1]");
|
|
38
|
+
let v = Math.hypot(p[0], p[1], p[2]);
|
|
39
|
+
a.set(c, i), a.set(l, i + 4), a[i + 7] = 1 / (l[d] * l[d]), a.set(u, i + 8), a[i + 11] = 1 / (u[f] * u[f]), a.set(p.map((e) => e / v), i + 12);
|
|
40
|
+
for (let t = 0; t < 8; t++) a[i + 16 + t] = n[e * 8 + t];
|
|
41
|
+
}
|
|
42
|
+
for (let e = 16; e <= 4194304; e *= 2) if (!(e < o.length / 2)) for (let t = 0; t < 8; t++) {
|
|
43
|
+
let n = new Int32Array(e * 4), r = e - 1, i = !0;
|
|
44
|
+
for (let e = 0; e < o.length && i; e += 4) {
|
|
45
|
+
let a = o[e], s = o[e + 1], c = o[e + 2], l = o[e + 3], u = (Math.imul(a, 73856093) ^ Math.imul(s, 19349663) ^ Math.imul(c, 83492791) ^ Math.imul(l & 7, 2654435761) ^ t) >>> 0;
|
|
46
|
+
u = Math.imul(u ^ u >>> 16, 2146121005) >>> 0, u = Math.imul(u ^ u >>> 15, 2221713035) >>> 0, u = (u ^ u >>> 16) & r, i = !1;
|
|
47
|
+
for (let e = 0; e < 16 && !i; e++) {
|
|
48
|
+
let t = (u + e & r) * 4;
|
|
49
|
+
n[t + 3] || (n.set([
|
|
50
|
+
a,
|
|
51
|
+
s,
|
|
52
|
+
c,
|
|
53
|
+
l
|
|
54
|
+
], t), i = !0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (i) return a[2] = r, a[3] = t, {
|
|
58
|
+
charts: a,
|
|
59
|
+
index: n
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
throw RangeError("voxelLightmap index needs over 64 MiB for 16 probes; bake fewer surfaces");
|
|
63
|
+
}
|
|
64
|
+
function n(e) {
|
|
65
|
+
return "\n@group(0) @binding(8) var voxelLightmap:texture_2d<f32>;\n@group(0) @binding(9) var<storage,read> voxelCharts:array<vec4f>;\n@group(0) @binding(10) var<storage,read> voxelChartIndex:array<vec4i>;\nvar<private> voxelBaked:vec4f;\nfn voxelAtlas(uv:vec2f)->vec3f {\n let size=vec2i(textureDimensions(voxelLightmap));let p=uv*vec2f(size)-0.5;let b=vec2i(floor(p));let f=fract(p);\n let a=textureLoad(voxelLightmap,clamp(b,vec2i(0),size-1),0).rgb;\n let c=textureLoad(voxelLightmap,clamp(b+vec2i(1,0),vec2i(0),size-1),0).rgb;\n let d=textureLoad(voxelLightmap,clamp(b+vec2i(0,1),vec2i(0),size-1),0).rgb;\n let e=textureLoad(voxelLightmap,clamp(b+vec2i(1,1),vec2i(0),size-1),0).rgb;\n return mix(mix(a,c,f.x),mix(d,e,f.x),f.y)*voxelCharts[0].y;\n}\nfn voxelChartCell(cell:vec3i,face:u32)->i32 {\n var hash=(bitcast<u32>(cell.x)*73856093u)^(bitcast<u32>(cell.y)*19349663u)^(bitcast<u32>(cell.z)*83492791u)^(face*2654435761u)^u32(voxelCharts[0].w);\n hash=(hash^(hash>>16u))*0x7feb352du;hash=(hash^(hash>>15u))*0x846ca68bu;hash=hash^(hash>>16u);let mask=u32(voxelCharts[0].z);\n for(var probe=0u;probe<16u;probe++) {let entry=voxelChartIndex[(hash+probe)&mask];if(entry.w==0){break;}if(all(entry.xyz==cell)&&(u32(entry.w)&7u)==face){return i32((u32(entry.w)>>3u)-1u);}}\n return -1;\n}\nfn voxelBakeAt(p:vec3f,n:vec3f)->vec4f {\n var result=vec4f(0);var nearest=0.501;\n\n for(var axis=0u;axis<3u;axis++) {\n if(abs(n[axis])<0.1){continue;}\n let face=axis*2u+select(0u,1u,n[axis]<0.0);let ua=(axis+1u)%3u;let va=(axis+2u)%3u;\n var cell=vec3i(floor(p));cell[axis]=i32(round(p[axis]));\n for(var corner=0u;corner<4u;corner++) {\n var atCell=cell;\n if((corner&1u)!=0u){if(fract(p[ua])>0.00001){continue;}atCell[ua]-=1;}\n if((corner&2u)!=0u){if(fract(p[va])>0.00001){continue;}atCell[va]-=1;}\n let chart=voxelChartCell(atCell,face);if(chart<0){continue;}\n let at=1u+u32(chart)*6u;let d=p-voxelCharts[at].xyz;let normal=voxelCharts[at+3u].xyz;let distance=abs(dot(d,normal));\n let u=voxelCharts[at+1u];let v=voxelCharts[at+2u];let r=vec2f(dot(d,u.xyz)*u.w,dot(d,v.xyz)*v.w);\n if(dot(n,normal)>0.1&&distance<nearest&&all(r>=vec2f(-0.00001))&&all(r<=vec2f(1.00001))) {\n let a=voxelCharts[at+4u];let b=voxelCharts[at+5u];let uv=mix(mix(a.xy,a.zw,r.x),mix(b.zw,b.xy,r.x),r.y);\n result=vec4f(voxelAtlas(uv),1);nearest=distance;\n }\n }\n }\n return result;\n}\n" + e.replace("fn ambient(s:Surface)->vec3f {", "fn ambient(s:Surface)->vec3f {if(voxelBaked.a>0.0){return s.base.rgb*(1.0-s.metal)*voxelBaked.rgb;}").replace(" let v=normalize(f.eye.xyz-i.position);", " voxelBaked=voxelBakeAt(i.position,outward);\n let v=normalize(f.eye.xyz-i.position);").replace(/var color=([^;]+);/, "$&if(voxelBaked.a>0.0){color=s.base.rgb*(1.0-s.metal)*voxelBaked.rgb+s.emissive;}");
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { e as voxelLightmap };
|
package/dist/lod.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { VoxelChunk } from './chunk.js';
|
|
2
|
+
import type { NoiseTerrainOptions, VoxelGenerateContext } from './generate.js';
|
|
3
|
+
import { VoxelWorld } from './world.js';
|
|
4
|
+
type Vec3 = readonly [number, number, number] | ArrayLike<number>;
|
|
5
|
+
/**
|
|
6
|
+
* Fills `chunk`, a new air chunk, with node (x, y, z) of a far level: its cell (i, j, k) covers the `scale`-cubed
|
|
7
|
+
* blocks from (32 x + i) * scale, (32 y + j) * scale, (32 z + k) * scale. It must give the same cells for the same
|
|
8
|
+
* node every time. Light can stay 0 (attach `VoxelLighting` to the level's world).
|
|
9
|
+
*/
|
|
10
|
+
export type VoxelLodGenerate = (chunk: VoxelChunk, x: number, y: number, z: number, scale: number, context: VoxelGenerateContext) => void;
|
|
11
|
+
/** Options of {@link VoxelLod}. */
|
|
12
|
+
export interface VoxelLodOptions {
|
|
13
|
+
/** The real world (level 0): level 1 leaves its loaded chunks' cells empty. Its `blocks` are the levels' blocks. */
|
|
14
|
+
world: VoxelWorld;
|
|
15
|
+
/** Fills far nodes, such as {@link noiseTerrainLod} with the streamer's terrain options. */
|
|
16
|
+
generate: VoxelLodGenerate;
|
|
17
|
+
/** Far levels, an integer in 1..12. Default 4. */
|
|
18
|
+
levels?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Nodes of a level from the eye before the next coarser level takes over, an integer in 2..32: level L reaches
|
|
21
|
+
* `radius * 32 * 2^L` blocks, so the view reaches `radius * 32 * 2^levels`. Level 1 must cover the chunks the real
|
|
22
|
+
* world streams: keep `2 * radius` above the streamer's `distance` + 1. Default 8 (4,096 blocks with 4 levels).
|
|
23
|
+
*/
|
|
24
|
+
radius?: number;
|
|
25
|
+
/** Lowest block y the far levels hold. Default -64. */
|
|
26
|
+
minY?: number;
|
|
27
|
+
/** Highest block y the far levels hold. Default 255. */
|
|
28
|
+
maxY?: number;
|
|
29
|
+
/** Most nodes generated or re-masked per {@link VoxelLod.update}, an integer >= 1 or Infinity. Default 8. */
|
|
30
|
+
budget?: number;
|
|
31
|
+
}
|
|
32
|
+
/** One far level of a {@link VoxelLod}. */
|
|
33
|
+
export interface VoxelLodLevel {
|
|
34
|
+
/** 1 to `levels`. */
|
|
35
|
+
readonly level: number;
|
|
36
|
+
/** Blocks per cell: 2^level. Pass it as `VoxelRenderer` option `scale`. */
|
|
37
|
+
readonly scale: number;
|
|
38
|
+
/** The level's coarse world: its chunks are the level's nodes on show. */
|
|
39
|
+
readonly world: VoxelWorld;
|
|
40
|
+
}
|
|
41
|
+
/** What a {@link VoxelLod} holds. */
|
|
42
|
+
export interface VoxelLodStats {
|
|
43
|
+
/** Nodes on show per level (index 0 is level 1). */
|
|
44
|
+
readonly nodes: readonly number[];
|
|
45
|
+
/** Wanted nodes not generated yet. */
|
|
46
|
+
readonly pending: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Far chunk levels of detail for a block world: coarse copies of the terrain around the eye, each level's cells twice
|
|
50
|
+
* the size of the one before, kept as `VoxelWorld`s that `VoxelRenderer` draws with `scale` and `VoxelLighting`
|
|
51
|
+
* lights. Call {@link VoxelLod.update} every frame with the eye.
|
|
52
|
+
*/
|
|
53
|
+
export declare class VoxelLod {
|
|
54
|
+
#private;
|
|
55
|
+
/** Far levels, coarsest last. */
|
|
56
|
+
readonly levels: readonly VoxelLodLevel[];
|
|
57
|
+
/** Most nodes generated or re-masked per update. Live. */
|
|
58
|
+
budget: number;
|
|
59
|
+
/**
|
|
60
|
+
* @throws TypeError when `world` is not a VoxelWorld, `generate` not a function or an option not a number.
|
|
61
|
+
* @throws RangeError for an option out of range, or `minY` above `maxY`.
|
|
62
|
+
*/
|
|
63
|
+
constructor(options: VoxelLodOptions);
|
|
64
|
+
/** Nodes on show per level and wanted nodes still to generate. */
|
|
65
|
+
get stats(): VoxelLodStats;
|
|
66
|
+
/**
|
|
67
|
+
* Chooses the nodes for `eye` (blocks) and generates or re-masks up to `budget` of the missing ones, nearest first.
|
|
68
|
+
* A node no longer wanted leaves its level once no missing node overlaps it, so a level change never opens a hole.
|
|
69
|
+
* Returns the nodes generated or re-masked: 0 once everything is current.
|
|
70
|
+
* @throws TypeError when `eye` is not three numbers or after `dispose()`; errors of `generate` propagate.
|
|
71
|
+
*/
|
|
72
|
+
update(eye: Vec3): number;
|
|
73
|
+
/** Stops following the real world's chunk loads and drops every node. */
|
|
74
|
+
dispose(): void;
|
|
75
|
+
/** {@link VoxelLod.dispose}, for `using`. */
|
|
76
|
+
[Symbol.dispose](): void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The far-level form of `noiseTerrain` (`@margoengine/voxel/generate`) with the same options: the same ground and sea,
|
|
80
|
+
* each coarse column taking the ground height at its centre block, rounded to the nearest whole cell (so a coarse
|
|
81
|
+
* surface is within half a cell of the real one there). Caves and trees are left out: from where a level is drawn a
|
|
82
|
+
* cave is not seen and a tree is under a cell.
|
|
83
|
+
* @throws TypeError or RangeError as `noiseTerrain` for the options; the returned function throws RangeError for a
|
|
84
|
+
* block name the context does not define.
|
|
85
|
+
*/
|
|
86
|
+
export declare function noiseTerrainLod(options?: NoiseTerrainOptions): VoxelLodGenerate;
|
|
87
|
+
export {};
|