@margoengine/voxel-edit 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 +445 -2
- package/dist/animation.d.ts +50 -0
- package/dist/animation.js +88 -0
- package/dist/assist.d.ts +24 -0
- package/dist/assist.js +52 -0
- package/dist/brush-gpu.d.ts +62 -0
- package/dist/bytes.d.ts +55 -0
- package/dist/collab.d.ts +77 -0
- package/dist/collab.js +159 -0
- package/dist/edit.d.ts +30 -0
- package/dist/edit.js +361 -0
- package/dist/export.d.ts +58 -0
- package/dist/export.js +52 -0
- package/dist/file-colors-DHT5vrzW.js +55 -0
- package/dist/file-colors.d.ts +16 -0
- package/dist/format-plist.d.ts +4 -0
- package/dist/formats-extra.d.ts +20 -0
- package/dist/formats-extra.js +335 -0
- package/dist/formats.d.ts +96 -0
- package/dist/formats.js +924 -0
- package/dist/generate.d.ts +63 -0
- package/dist/generate.js +103 -0
- package/dist/gox.d.ts +60 -0
- package/dist/gpu.d.ts +74 -0
- package/dist/gpu.js +167 -0
- package/dist/grid-B2V0TGLV.js +120 -0
- package/dist/grid.d.ts +75 -0
- package/dist/history.d.ts +65 -0
- package/dist/history.js +75 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +631 -0
- package/dist/layout.d.ts +76 -0
- package/dist/library.d.ts +50 -0
- package/dist/library.js +89 -0
- package/dist/mesh.d.ts +128 -0
- package/dist/mesh.js +365 -0
- package/dist/model.d.ts +173 -0
- package/dist/pick.d.ts +34 -0
- package/dist/pick.js +122 -0
- package/dist/raster.d.ts +89 -0
- package/dist/rig.d.ts +88 -0
- package/dist/rig.js +216 -0
- package/dist/select.d.ts +50 -0
- package/dist/select.js +94 -0
- package/dist/shaders-BaY4gcm9.js +234 -0
- package/dist/shaders.d.ts +116 -0
- package/dist/shaders.js +1 -0
- package/dist/slices.d.ts +75 -0
- package/dist/smooth.d.ts +43 -0
- package/dist/smooth.js +212 -0
- package/dist/sparse.d.ts +239 -0
- package/dist/sparse.js +646 -0
- package/dist/stamp.d.ts +88 -0
- package/dist/vmax.d.ts +48 -0
- package/dist/vox-resolve.d.ts +64 -0
- package/dist/vox-scene.d.ts +51 -0
- package/dist/vox.d.ts +30 -0
- package/dist/vox.js +684 -0
- package/dist/voxelize.d.ts +70 -0
- package/dist/voxelize.js +249 -0
- package/dist/vxm.d.ts +54 -0
- package/package.json +130 -4
package/dist/mesh.js
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { c as e, d as t } from "./grid-B2V0TGLV.js";
|
|
2
|
+
import { SparseGrid as n } from "./sparse.js";
|
|
3
|
+
import { bevelQuads as r } from "@margoengine/voxel/bevel";
|
|
4
|
+
//#region src/mesh.ts
|
|
5
|
+
var i = 1e6, a = 134217728;
|
|
6
|
+
function o(r, o = {}) {
|
|
7
|
+
if (typeof o != "object" || !o) throw TypeError("meshGrid options are not an object; pass them");
|
|
8
|
+
let s = o.pivot ?? [
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
0
|
|
12
|
+
], c = o.maxQuads ?? i, l = o.maxCells ?? a, u = o.creaseAngle ?? 180;
|
|
13
|
+
if (t(s, "meshGrid pivot"), !Number.isInteger(c) || c < 0 || c > i) throw RangeError(`meshGrid maxQuads must be an integer from 0 to ${i}; pass one`);
|
|
14
|
+
if (!Number.isInteger(l) || l < 1 || l > a) throw RangeError(`meshGrid maxCells must be an integer from 1 to ${a}; pass one`);
|
|
15
|
+
if (!Number.isFinite(u) || u < 0 || u > 180) throw RangeError("meshGrid creaseAngle must be 0 to 180 degrees; pass one");
|
|
16
|
+
for (let e of ["ambientOcclusion", "smoothNormals"]) if (o[e] !== void 0 && typeof o[e] != "boolean") throw TypeError(`meshGrid ${e} is not a boolean; pass true or false`);
|
|
17
|
+
let d = r instanceof n;
|
|
18
|
+
d || e(r, a);
|
|
19
|
+
let [m, h, g] = r.size, _ = d ? (e, t, n) => e < 0 || t < 0 || n < 0 || e >= m || t >= h || n >= g ? 0 : r.get(e, t, n) : (e, t, n) => e < 0 || t < 0 || n < 0 || e >= m || t >= h || n >= g ? 0 : r.voxels[e + m * (n + g * t)], v = d ? r.windows() : [{
|
|
20
|
+
origin: [
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
0
|
|
24
|
+
],
|
|
25
|
+
size: r.size,
|
|
26
|
+
voxels: r.voxels
|
|
27
|
+
}], y = {
|
|
28
|
+
positions: [],
|
|
29
|
+
normals: [],
|
|
30
|
+
ao: [],
|
|
31
|
+
indices: [],
|
|
32
|
+
palette: []
|
|
33
|
+
}, b = {
|
|
34
|
+
voxels: 0,
|
|
35
|
+
quads: 0,
|
|
36
|
+
triangles: 0,
|
|
37
|
+
vertices: 0
|
|
38
|
+
}, x = 0;
|
|
39
|
+
for (let e of v) {
|
|
40
|
+
if (x += e.voxels.length, x > l) throw RangeError("meshGrid scans more than maxCells; mesh less or raise maxCells");
|
|
41
|
+
f(_, s, e.origin, e.size, e.voxels, o.ambientOcclusion ?? !1, c, y, b);
|
|
42
|
+
}
|
|
43
|
+
o.smoothNormals && y.indices.length && p(y, u);
|
|
44
|
+
let S = Float32Array.from(y.positions), C = [
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
0
|
|
48
|
+
], w = [
|
|
49
|
+
0,
|
|
50
|
+
0,
|
|
51
|
+
0
|
|
52
|
+
];
|
|
53
|
+
if (S.length) {
|
|
54
|
+
C.fill(Infinity), w.fill(-Infinity);
|
|
55
|
+
for (let e = 0; e < S.length; e++) {
|
|
56
|
+
let t = e % 3;
|
|
57
|
+
S[e] < C[t] && (C[t] = S[e]), S[e] > w[t] && (w[t] = S[e]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
mesh: {
|
|
62
|
+
positions: S,
|
|
63
|
+
normals: Float32Array.from(y.normals),
|
|
64
|
+
ao: Float32Array.from(y.ao),
|
|
65
|
+
indices: Uint32Array.from(y.indices),
|
|
66
|
+
paletteIndexes: Uint8Array.from(y.palette),
|
|
67
|
+
min: C,
|
|
68
|
+
max: w
|
|
69
|
+
},
|
|
70
|
+
stats: b
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function s(o, s) {
|
|
74
|
+
if (typeof s != "object" || !s) throw TypeError("chamferGrid options are not an object; pass {bevel}");
|
|
75
|
+
let c = s.bevel, l = s.pivot ?? [
|
|
76
|
+
0,
|
|
77
|
+
0,
|
|
78
|
+
0
|
|
79
|
+
], u = s.maxQuads ?? i, d = s.maxCells ?? a;
|
|
80
|
+
if (!(c > 0 && c < .5)) throw RangeError("chamferGrid bevel must be in (0, 0.5) cells");
|
|
81
|
+
if (t(l, "chamferGrid pivot"), !Number.isInteger(u) || u < 0 || u > i) throw RangeError(`chamferGrid maxQuads must be an integer from 0 to ${i}; pass one`);
|
|
82
|
+
if (!Number.isInteger(d) || d < 1 || d > a) throw RangeError(`chamferGrid maxCells must be an integer from 1 to ${a}; pass one`);
|
|
83
|
+
let p = o instanceof n;
|
|
84
|
+
p || e(o, a);
|
|
85
|
+
let [m, h, g] = o.size, _ = p ? (e, t, n) => e < 0 || t < 0 || n < 0 || e >= m || t >= h || n >= g ? 0 : o.get(e, t, n) : (e, t, n) => e < 0 || t < 0 || n < 0 || e >= m || t >= h || n >= g ? 0 : o.voxels[e + m * (n + g * t)], v = p ? o.windows() : [{
|
|
86
|
+
origin: [
|
|
87
|
+
0,
|
|
88
|
+
0,
|
|
89
|
+
0
|
|
90
|
+
],
|
|
91
|
+
size: o.size,
|
|
92
|
+
voxels: o.voxels
|
|
93
|
+
}], y = [], b = {
|
|
94
|
+
voxels: 0,
|
|
95
|
+
quads: 0,
|
|
96
|
+
triangles: 0,
|
|
97
|
+
vertices: 0
|
|
98
|
+
}, x = 0;
|
|
99
|
+
for (let e of v) {
|
|
100
|
+
if (x += e.voxels.length, x > d) throw RangeError("chamferGrid scans more than maxCells; mesh less or raise maxCells");
|
|
101
|
+
f(_, l, e.origin, e.size, e.voxels, !1, u, null, b, y);
|
|
102
|
+
}
|
|
103
|
+
let S = r(y, c), C = S.positions, w = C.length / 3;
|
|
104
|
+
for (let e = 0; e < w; e++) C[e * 3] -= l[0], C[e * 3 + 1] -= l[1], C[e * 3 + 2] -= l[2];
|
|
105
|
+
let T = S.indices.length / 3, E = new Uint8Array(T);
|
|
106
|
+
for (let e = 0; e < T; e++) E[e] = S.materials[S.indices[e * 3]];
|
|
107
|
+
let D = [
|
|
108
|
+
0,
|
|
109
|
+
0,
|
|
110
|
+
0
|
|
111
|
+
], O = [
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
0
|
|
115
|
+
];
|
|
116
|
+
if (C.length) {
|
|
117
|
+
D.fill(Infinity), O.fill(-Infinity);
|
|
118
|
+
for (let e = 0; e < C.length; e++) {
|
|
119
|
+
let t = e % 3;
|
|
120
|
+
C[e] < D[t] && (D[t] = C[e]), C[e] > O[t] && (O[t] = C[e]);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
mesh: {
|
|
125
|
+
positions: C,
|
|
126
|
+
normals: S.normals,
|
|
127
|
+
indices: S.indices,
|
|
128
|
+
trianglePalette: E,
|
|
129
|
+
min: D,
|
|
130
|
+
max: O
|
|
131
|
+
},
|
|
132
|
+
stats: {
|
|
133
|
+
voxels: b.voxels,
|
|
134
|
+
quads: y.length,
|
|
135
|
+
triangles: T,
|
|
136
|
+
clamped: 0
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
var c = 25e4;
|
|
141
|
+
function l(e, t = {}) {
|
|
142
|
+
if (typeof t != "object" || !t) throw TypeError("partitionMesh options are not an object; pass them");
|
|
143
|
+
let n = t.maxQuads ?? c;
|
|
144
|
+
if (!Number.isInteger(n) || n < 1 || n > c) throw RangeError(`partitionMesh maxQuads must be an integer from 1 to ${c}; pass one`);
|
|
145
|
+
if (typeof e != "object" || !e || !(e.paletteIndexes instanceof Uint8Array)) throw TypeError("partitionMesh mesh is not a GridMesh; pass what meshGrid returned");
|
|
146
|
+
let { positions: r, normals: i, ao: a, indices: o, paletteIndexes: s } = e, l = s.length;
|
|
147
|
+
if (!(r instanceof Float32Array) || !(i instanceof Float32Array) || !(a instanceof Float32Array) || !(o instanceof Uint32Array) || r.length !== 12 * l || i.length !== 12 * l || a.length !== 0 && a.length !== 4 * l || o.length !== 6 * l) throw RangeError("partitionMesh mesh arrays do not hold 4 vertices and 6 indexes per quad; pass meshGrid output");
|
|
148
|
+
for (let e = 0; e < l; e++) for (let t = 0; t < 6; t++) {
|
|
149
|
+
let n = o[e * 6 + t];
|
|
150
|
+
if (n < e * 4 || n >= e * 4 + 4) throw RangeError(`partitionMesh quad ${e} uses another quad's vertex; pass meshGrid output`);
|
|
151
|
+
}
|
|
152
|
+
let u = [], d = /* @__PURE__ */ new Map();
|
|
153
|
+
for (let e = 0; e < l; e++) {
|
|
154
|
+
let t = s[e], r = d.get(t);
|
|
155
|
+
r || (r = [], u.push(r), d.set(t, r)), r.push(e), r.length >= n && d.delete(t);
|
|
156
|
+
}
|
|
157
|
+
return u.map((e) => {
|
|
158
|
+
let t = e.length, n = {
|
|
159
|
+
paletteIndex: s[e[0]],
|
|
160
|
+
positions: new Float32Array(12 * t),
|
|
161
|
+
normals: new Float32Array(12 * t),
|
|
162
|
+
ao: new Float32Array(a.length ? 4 * t : 0),
|
|
163
|
+
indices: new Uint32Array(6 * t),
|
|
164
|
+
quads: Uint32Array.from(e)
|
|
165
|
+
};
|
|
166
|
+
return e.forEach((e, t) => {
|
|
167
|
+
n.positions.set(r.subarray(e * 12, e * 12 + 12), t * 12), n.normals.set(i.subarray(e * 12, e * 12 + 12), t * 12), a.length && n.ao.set(a.subarray(e * 4, e * 4 + 4), t * 4);
|
|
168
|
+
for (let r = 0; r < 6; r++) n.indices[t * 6 + r] = o[e * 6 + r] - e * 4 + t * 4;
|
|
169
|
+
}), n;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
var u = [
|
|
173
|
+
[0, 0],
|
|
174
|
+
[1, 0],
|
|
175
|
+
[1, 1],
|
|
176
|
+
[0, 1]
|
|
177
|
+
], d = [
|
|
178
|
+
[0, 0],
|
|
179
|
+
[0, 1],
|
|
180
|
+
[1, 1],
|
|
181
|
+
[1, 0]
|
|
182
|
+
];
|
|
183
|
+
function f(e, t, n, r, i, a, o, s, c, l) {
|
|
184
|
+
for (let e of i) e && c.voxels++;
|
|
185
|
+
let f = (t) => e(t[0] + n[0], t[1] + n[1], t[2] + n[2]), p = (e) => +!!f(e), m = [
|
|
186
|
+
0,
|
|
187
|
+
0,
|
|
188
|
+
0
|
|
189
|
+
], h = [
|
|
190
|
+
0,
|
|
191
|
+
0,
|
|
192
|
+
0
|
|
193
|
+
];
|
|
194
|
+
for (let e = 0; e < 3; e++) {
|
|
195
|
+
let i = (e + 1) % 3, g = (e + 2) % 3, _ = r[i], v = r[g], y = new Int16Array(_ * v), b = a ? new Uint8Array(_ * v) : void 0;
|
|
196
|
+
for (let a = 0; a <= r[e]; a++) {
|
|
197
|
+
for (let t = 0; t < v; t++) for (let n = 0; n < _; n++) {
|
|
198
|
+
m[i] = n, m[g] = t, m[e] = a - 1;
|
|
199
|
+
let o = f(m);
|
|
200
|
+
m[e] = a;
|
|
201
|
+
let s = f(m), c = o && !s && a > 0 ? o : s && !o && a < r[e] ? -s : 0;
|
|
202
|
+
if (y[n + t * _] = c, !b || !c) continue;
|
|
203
|
+
let l = 0;
|
|
204
|
+
for (let r = 0; r < 4; r++) {
|
|
205
|
+
let [o, s] = u[r];
|
|
206
|
+
h[e] = c > 0 ? a : a - 1, h[i] = n + (o ? 1 : -1), h[g] = t;
|
|
207
|
+
let d = p(h);
|
|
208
|
+
h[i] = n, h[g] = t + (s ? 1 : -1);
|
|
209
|
+
let f = p(h);
|
|
210
|
+
h[i] = n + (o ? 1 : -1);
|
|
211
|
+
let m = d && f ? 0 : 3 - d - f - p(h);
|
|
212
|
+
l |= m << r * 2;
|
|
213
|
+
}
|
|
214
|
+
b[n + t * _] = l;
|
|
215
|
+
}
|
|
216
|
+
for (let r = 0; r < v; r++) for (let f = 0; f < _;) {
|
|
217
|
+
let p = y[f + r * _];
|
|
218
|
+
if (!p) {
|
|
219
|
+
f++;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
let m = b?.[f + r * _] ?? 255, h = m === 0 || m === 85 || m === 170 || m === 255, x = (e) => y[e] === p && (!b || b[e] === m), S = 1, C = 1;
|
|
223
|
+
for (; h && f + S < _ && x(f + S + r * _);) S++;
|
|
224
|
+
grow: for (; h && r + C < v;) {
|
|
225
|
+
for (let e = 0; e < S; e++) if (!x(f + e + (r + C) * _)) break grow;
|
|
226
|
+
C++;
|
|
227
|
+
}
|
|
228
|
+
if (++c.quads > o) throw RangeError("meshGrid exceeds maxQuads; mesh a smaller grid or raise maxQuads");
|
|
229
|
+
if (l) {
|
|
230
|
+
let t = p > 0, i = (e + 1) % 3, o = (e + 2) % 3, s = [
|
|
231
|
+
0,
|
|
232
|
+
0,
|
|
233
|
+
0
|
|
234
|
+
];
|
|
235
|
+
s[e] = t ? a - 1 : a, s[i] = f, s[o] = r, l.push({
|
|
236
|
+
x: s[0] + n[0],
|
|
237
|
+
y: s[1] + n[1],
|
|
238
|
+
z: s[2] + n[2],
|
|
239
|
+
face: e * 2 + +!t,
|
|
240
|
+
w: e === 2 ? S : C,
|
|
241
|
+
h: e === 2 ? C : S,
|
|
242
|
+
material: Math.abs(p)
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (s) {
|
|
246
|
+
let o = s.positions.length / 3;
|
|
247
|
+
for (let [o, c] of p > 0 ? u : d) {
|
|
248
|
+
let l = [
|
|
249
|
+
0,
|
|
250
|
+
0,
|
|
251
|
+
0
|
|
252
|
+
];
|
|
253
|
+
l[e] = a, l[i] = f + o * S, l[g] = r + c * C;
|
|
254
|
+
for (let e = 0; e < 3; e++) s.positions.push(Math.fround(n[e] + l[e] - t[e]));
|
|
255
|
+
s.normals.push(e === 0 ? Math.sign(p) : 0, e === 1 ? Math.sign(p) : 0, e === 2 ? Math.sign(p) : 0), b && s.ao.push(.4 + (m >>> (o ? c ? 2 : 1 : c ? 3 : 0) * 2 & 3) * .2);
|
|
256
|
+
}
|
|
257
|
+
let l = (e) => Math.round((s.ao[s.ao.length - 4 + e] - .4) * 5);
|
|
258
|
+
b && l(0) + l(2) > l(1) + l(3) ? s.indices.push(o + 1, o + 2, o + 3, o + 1, o + 3, o) : s.indices.push(o, o + 1, o + 2, o, o + 2, o + 3), s.palette.push(Math.abs(p)), c.triangles += 2, c.vertices += 4;
|
|
259
|
+
}
|
|
260
|
+
for (let e = 0; e < C; e++) y.fill(0, f + (r + e) * _, f + S + (r + e) * _);
|
|
261
|
+
f += S;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function p(e, t) {
|
|
267
|
+
let { positions: n, normals: r } = e, i = e.palette.length, a = /* @__PURE__ */ new Map(), o = Array.from({ length: i }, () => []);
|
|
268
|
+
for (let e = 0; e < i; e++) for (let t = 0; t < 4; t++) {
|
|
269
|
+
let r = e * 12 + t * 3, i = e * 12 + (t + 1) % 4 * 3, o = [
|
|
270
|
+
0,
|
|
271
|
+
1,
|
|
272
|
+
2
|
|
273
|
+
].find((e) => n[r + e] !== n[i + e]), s = [
|
|
274
|
+
n[r],
|
|
275
|
+
n[r + 1],
|
|
276
|
+
n[r + 2]
|
|
277
|
+
];
|
|
278
|
+
s[o] = 0;
|
|
279
|
+
let c = `${o}:${s.join(",")}`, l = a.get(c);
|
|
280
|
+
l || a.set(c, l = {
|
|
281
|
+
axis: o,
|
|
282
|
+
fixed: s,
|
|
283
|
+
events: /* @__PURE__ */ new Map()
|
|
284
|
+
});
|
|
285
|
+
let u = Math.min(n[r + o], n[i + o]), d = Math.max(n[r + o], n[i + o]);
|
|
286
|
+
for (let [t, n] of [[u, !1], [d, !0]]) {
|
|
287
|
+
let r = l.events.get(t);
|
|
288
|
+
r || l.events.set(t, r = {
|
|
289
|
+
start: [],
|
|
290
|
+
end: []
|
|
291
|
+
}), (n ? r.end : r.start).push(e);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for (let { axis: e, fixed: t, events: n } of a.values()) {
|
|
295
|
+
let r = [...n.keys()].sort((e, t) => e - t), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
296
|
+
for (let s = 0; s < r.length - 1; s++) {
|
|
297
|
+
let c = n.get(r[s]);
|
|
298
|
+
for (let e of c.end) {
|
|
299
|
+
let t = i.get(e) - 1;
|
|
300
|
+
t ? i.set(e, t) : i.delete(e);
|
|
301
|
+
}
|
|
302
|
+
for (let e of c.start) i.set(e, (i.get(e) ?? 0) + 1);
|
|
303
|
+
if (i.size !== 2) continue;
|
|
304
|
+
let [l, u] = [...i.keys()];
|
|
305
|
+
for (let [n, i] of [[l, u], [u, l]]) {
|
|
306
|
+
let c = a.get(n);
|
|
307
|
+
c || (a.set(n, c = {
|
|
308
|
+
axis: e,
|
|
309
|
+
fixed: t,
|
|
310
|
+
segments: []
|
|
311
|
+
}), o[n].push(c)), c.segments.push({
|
|
312
|
+
face: i,
|
|
313
|
+
low: r[s],
|
|
314
|
+
high: r[s + 1]
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
let s = /* @__PURE__ */ new Map();
|
|
320
|
+
for (let e = 0; e < n.length; e += 3) {
|
|
321
|
+
let t = `${n[e]},${n[e + 1]},${n[e + 2]}`, r = s.get(t);
|
|
322
|
+
r || s.set(t, r = []), r.push(e);
|
|
323
|
+
}
|
|
324
|
+
let c = r.slice(), l = Math.cos(t * Math.PI / 180) - 1e-7, u = (e) => c.slice(e * 12, e * 12 + 3);
|
|
325
|
+
for (let e of s.values()) {
|
|
326
|
+
let t = n.slice(e[0], e[0] + 3), i = /* @__PURE__ */ new Map();
|
|
327
|
+
for (let n of e) {
|
|
328
|
+
let e = Math.floor(n / 12);
|
|
329
|
+
if (!i.has(e)) {
|
|
330
|
+
let n = /* @__PURE__ */ new Set([e]), r = [e], a = /* @__PURE__ */ new Set(), s = [
|
|
331
|
+
0,
|
|
332
|
+
0,
|
|
333
|
+
0
|
|
334
|
+
];
|
|
335
|
+
for (; r.length;) {
|
|
336
|
+
let e = r.pop(), i = u(e), c = i.join(",");
|
|
337
|
+
if (!a.has(c)) {
|
|
338
|
+
a.add(c);
|
|
339
|
+
for (let e = 0; e < 3; e++) s[e] += i[e];
|
|
340
|
+
}
|
|
341
|
+
for (let a of o[e]) {
|
|
342
|
+
if (!t.every((e, t) => t === a.axis || e === a.fixed[t])) continue;
|
|
343
|
+
let e = t[a.axis], o = 0, s = a.segments.length;
|
|
344
|
+
for (; o < s;) {
|
|
345
|
+
let t = o + s >>> 1;
|
|
346
|
+
a.segments[t].high < e ? o = t + 1 : s = t;
|
|
347
|
+
}
|
|
348
|
+
for (let t = o; t < a.segments.length && a.segments[t].low <= e; t++) {
|
|
349
|
+
let e = a.segments[t].face;
|
|
350
|
+
if (n.has(e)) continue;
|
|
351
|
+
let o = u(e);
|
|
352
|
+
i[0] * o[0] + i[1] * o[1] + i[2] * o[2] >= l && (n.add(e), r.push(e));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
let c = Math.hypot(s[0], s[1], s[2]);
|
|
357
|
+
for (let e of n) i.set(e, c > 1e-9 ? s.map((e) => e / c) : u(e));
|
|
358
|
+
}
|
|
359
|
+
let a = i.get(e);
|
|
360
|
+
r[n] = a[0], r[n + 1] = a[1], r[n + 2] = a[2];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
export { s as chamferGrid, o as meshGrid, l as partitionMesh };
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { Vec3 } from '@margoengine/math';
|
|
2
|
+
import { type GridEdit, type GridLimits, type VoxelGrid } from './grid.js';
|
|
3
|
+
/** Options of {@link combineGrids}. */
|
|
4
|
+
export interface CombineOptions extends GridLimits {
|
|
5
|
+
/**
|
|
6
|
+
* `'union'` adds the tool's filled cells, `'intersect'` keeps base cells only under filled tool cells, `'subtract'`
|
|
7
|
+
* empties base cells under filled tool cells. The result keeps the base's size.
|
|
8
|
+
*/
|
|
9
|
+
operation: 'union' | 'intersect' | 'subtract';
|
|
10
|
+
/** Where the tool's cell (0, 0, 0) lands in the base, in whole cells. Default [0, 0, 0]. */
|
|
11
|
+
offset?: Vec3;
|
|
12
|
+
/**
|
|
13
|
+
* Union only: the base palette index for each tool index, 256 entries. Entry 0 must stay 0 and every index the tool
|
|
14
|
+
* uses must map to 1-255; {@link mergePalettes} builds one.
|
|
15
|
+
*/
|
|
16
|
+
paletteMap?: Uint8Array;
|
|
17
|
+
/** Union only: the index a cell filled in both keeps. Default `'base'`. */
|
|
18
|
+
overlap?: 'base' | 'tool';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Combines a tool grid into a base grid (boolean union, intersection or subtraction). `clipped` counts filled tool
|
|
22
|
+
* cells that land outside the base.
|
|
23
|
+
*/
|
|
24
|
+
export declare function combineGrids(base: VoxelGrid, tool: VoxelGrid, options: CombineOptions): GridEdit;
|
|
25
|
+
/** Options of {@link shearGrid}. */
|
|
26
|
+
export interface ShearOptions extends GridLimits {
|
|
27
|
+
/** The axis cells move along. */
|
|
28
|
+
axis: 'x' | 'y' | 'z';
|
|
29
|
+
/** The axis whose coordinate sets how far: a cell moves `round(factor * (coordinate - pivot))` along `axis`. */
|
|
30
|
+
along: 'x' | 'y' | 'z';
|
|
31
|
+
/** Cells moved per cell of `along`, finite. */
|
|
32
|
+
factor: number;
|
|
33
|
+
/** The `along` coordinate that stays put, finite. Default 0. */
|
|
34
|
+
pivot?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Shears a grid by whole-cell layer shifts, keeping its size and colours (ties round up). `clipped` counts filled cells
|
|
38
|
+
* shifted out of the grid.
|
|
39
|
+
*/
|
|
40
|
+
export declare function shearGrid(grid: VoxelGrid, options: ShearOptions): GridEdit;
|
|
41
|
+
/** Options of {@link reflectDiagonal}. */
|
|
42
|
+
export interface DiagonalOptions extends GridLimits {
|
|
43
|
+
/** The plane holding the diagonal; its two axes must have the same size. */
|
|
44
|
+
plane: 'xy' | 'xz' | 'yz';
|
|
45
|
+
/** `'main'` swaps (a, b) to (b, a); `'anti'` maps (a, b) to (n - 1 - b, n - 1 - a). Default `'main'`. */
|
|
46
|
+
diagonal?: 'main' | 'anti';
|
|
47
|
+
/** `'mirror'` reflects every cell; `'symmetrize'` copies the `keep` half, air included, over the other. Default `'symmetrize'`. */
|
|
48
|
+
mode?: 'mirror' | 'symmetrize';
|
|
49
|
+
/**
|
|
50
|
+
* The half `'symmetrize'` keeps: `'lower'` is a <= b on the main diagonal and a + b <= n - 1 on the anti diagonal,
|
|
51
|
+
* `'upper'` the other side. Cells on the diagonal never change. Default `'lower'`.
|
|
52
|
+
*/
|
|
53
|
+
keep?: 'lower' | 'upper';
|
|
54
|
+
}
|
|
55
|
+
/** Reflects a grid across a diagonal of one of its planes, or makes it symmetric about one. */
|
|
56
|
+
export declare function reflectDiagonal(grid: VoxelGrid, options: DiagonalOptions): GridEdit;
|
|
57
|
+
/** Options of {@link wrapGrid}. */
|
|
58
|
+
export interface WrapOptions extends GridLimits {
|
|
59
|
+
/** Whole cells to move along x, y and z; cells leaving one side come back on the other. */
|
|
60
|
+
offset: Vec3;
|
|
61
|
+
}
|
|
62
|
+
/** Moves every cell by `offset` with wrap-around, so no cell is lost. */
|
|
63
|
+
export declare function wrapGrid(grid: VoxelGrid, options: WrapOptions): GridEdit;
|
|
64
|
+
/** Options of {@link repeatGrid}. */
|
|
65
|
+
export interface RepeatOptions extends GridLimits {
|
|
66
|
+
/** Copies along x, y and z, each a positive integer; the result is `size * counts`. */
|
|
67
|
+
counts: Vec3;
|
|
68
|
+
}
|
|
69
|
+
/** Tiles a grid `counts` times along each axis, air and repeated palette indexes included. */
|
|
70
|
+
export declare function repeatGrid(grid: VoxelGrid, options: RepeatOptions): GridEdit;
|
|
71
|
+
/** Options of {@link resampleGrid}. */
|
|
72
|
+
export interface ResampleOptions extends GridLimits {
|
|
73
|
+
/** Scale along x, y and z, positive and finite; each new size is `round(size * scale)`, at least 1. */
|
|
74
|
+
scale: Vec3;
|
|
75
|
+
}
|
|
76
|
+
/** Scales a grid by sampling the nearest source cell at each new cell's centre; palette indexes are never blended. */
|
|
77
|
+
export declare function resampleGrid(grid: VoxelGrid, options: ResampleOptions): GridEdit;
|
|
78
|
+
/** Options of {@link rotateGrid}. */
|
|
79
|
+
export interface RotateOptions extends GridLimits {
|
|
80
|
+
/** The axis to turn about, through the grid's centre. */
|
|
81
|
+
axis: 'x' | 'y' | 'z';
|
|
82
|
+
/** Right-handed turn in degrees, finite; any angle, not only quarter turns. */
|
|
83
|
+
degrees: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Rotates a grid about its centre inside its own box: each cell takes the source cell its centre turns back onto.
|
|
87
|
+
* Quarter turns of a grid whose turned axes have the same size are exact. `clipped` counts filled cells whose turned
|
|
88
|
+
* centre leaves the box.
|
|
89
|
+
*/
|
|
90
|
+
export declare function rotateGrid(grid: VoxelGrid, options: RotateOptions): GridEdit;
|
|
91
|
+
/** Directions and passes of {@link dilateGrid} and {@link erodeGrid}. */
|
|
92
|
+
export interface MorphologyOptions extends GridLimits {
|
|
93
|
+
/** Passes, 0 to 1024; each reads the result of the one before. Default 1. */
|
|
94
|
+
iterations?: number;
|
|
95
|
+
/** Unit axis vectors to grow toward or check, one to six. Default all six. */
|
|
96
|
+
directions?: readonly Vec3[];
|
|
97
|
+
}
|
|
98
|
+
/** Options of {@link dilateGrid}. */
|
|
99
|
+
export interface DilateOptions extends MorphologyOptions {
|
|
100
|
+
/** Palette index of the added cells, 1-255. Default: the index of the cell each one grew from. */
|
|
101
|
+
color?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Grows filled cells into neighbouring air along `directions`. An added cell takes `color`, or without it the index
|
|
105
|
+
* of the first cell (in grid order) that grew into it.
|
|
106
|
+
*/
|
|
107
|
+
export declare function dilateGrid(grid: VoxelGrid, options?: DilateOptions): GridEdit;
|
|
108
|
+
/** Empties filled cells that have air (or the grid's edge) next to them along any of `directions`. */
|
|
109
|
+
export declare function erodeGrid(grid: VoxelGrid, options?: MorphologyOptions): GridEdit;
|
|
110
|
+
/** Options of {@link fillEnclosed}. */
|
|
111
|
+
export interface FillOptions extends GridLimits {
|
|
112
|
+
/** Palette index for the filled air, 1-255. */
|
|
113
|
+
color: number;
|
|
114
|
+
}
|
|
115
|
+
/** Fills air that no face-connected path of air links to the grid's boundary (closed cavities) with `color`. */
|
|
116
|
+
export declare function fillEnclosed(grid: VoxelGrid, options: FillOptions): GridEdit;
|
|
117
|
+
/** Inputs of {@link mergePalettes}. */
|
|
118
|
+
export interface PaletteMergeOptions {
|
|
119
|
+
/** 256 identity strings of the base palette (colour plus material, say); equal strings mean the same entry. */
|
|
120
|
+
baseKeys: readonly string[];
|
|
121
|
+
/** 256 identity strings of the tool palette. */
|
|
122
|
+
toolKeys: readonly string[];
|
|
123
|
+
/** 256 entries, nonzero where the base grid uses that index; entry 0 must be 0. */
|
|
124
|
+
baseUsed: Uint8Array;
|
|
125
|
+
/** 256 entries, nonzero where the tool grid uses that index; entry 0 must be 0. */
|
|
126
|
+
toolUsed: Uint8Array;
|
|
127
|
+
}
|
|
128
|
+
/** What {@link mergePalettes} returns. */
|
|
129
|
+
export interface PaletteMerge {
|
|
130
|
+
/** Base index for each tool index, ready for {@link CombineOptions.paletteMap}. */
|
|
131
|
+
paletteMap: Uint8Array;
|
|
132
|
+
/** Each used tool index and the base index it maps to, in tool order; copy the tool's entry into new ones. */
|
|
133
|
+
assignments: {
|
|
134
|
+
from: number;
|
|
135
|
+
to: number;
|
|
136
|
+
}[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Maps a tool palette into a base palette for {@link combineGrids}: tool entries whose identity the base already uses
|
|
140
|
+
* reuse that index, the others take the lowest unused base indexes. Base entries in use never change. Throws a
|
|
141
|
+
* RangeError when the merged palette would need more than 255 entries; nothing is approximated.
|
|
142
|
+
*/
|
|
143
|
+
export declare function mergePalettes(options: PaletteMergeOptions): PaletteMerge;
|
|
144
|
+
/** Options of {@link generateMaze}. */
|
|
145
|
+
export interface MazeOptions extends GridLimits {
|
|
146
|
+
/** Rooms along x, a positive integer. */
|
|
147
|
+
columns: number;
|
|
148
|
+
/** Rooms along z, a positive integer. */
|
|
149
|
+
rows: number;
|
|
150
|
+
/** Wall height in cells, a positive integer. */
|
|
151
|
+
wallHeight: number;
|
|
152
|
+
/** Palette index of the walls, 1-255. */
|
|
153
|
+
wallIndex: number;
|
|
154
|
+
/** Palette index of a one-cell floor under the maze, 1-255, or 0 for none. Default 0. */
|
|
155
|
+
floorIndex?: number;
|
|
156
|
+
/** Unsigned 32-bit seed; the same seed gives the same maze. Default 0. */
|
|
157
|
+
seed?: number;
|
|
158
|
+
/** Open an entrance at (1, 0) and an exit at (width - 2, depth - 1). Default true. */
|
|
159
|
+
openings?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/** What {@link generateMaze} returns. */
|
|
162
|
+
export interface Maze {
|
|
163
|
+
/** `2 * columns + 1` by `wallHeight` (+ 1 with a floor) by `2 * rows + 1` cells. */
|
|
164
|
+
grid: VoxelGrid;
|
|
165
|
+
/** `columns * rows`. */
|
|
166
|
+
rooms: number;
|
|
167
|
+
/** Openings between rooms, always `rooms - 1`: every room is reachable by exactly one path. */
|
|
168
|
+
passages: number;
|
|
169
|
+
/** The seed used. */
|
|
170
|
+
seed: number;
|
|
171
|
+
}
|
|
172
|
+
/** Builds a perfect maze (seeded depth-first search) with one-cell walls and corridors, walls standing on y = 0 or the floor. */
|
|
173
|
+
export declare function generateMaze(options: MazeOptions): Maze;
|
package/dist/pick.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { MutableVec3, Vec3 } from '@margoengine/math';
|
|
2
|
+
import type { GridSource } from './edit.js';
|
|
3
|
+
import { type GridHit } from './grid.js';
|
|
4
|
+
/** A ray in a grid's local cells. */
|
|
5
|
+
export interface GridRay {
|
|
6
|
+
/** Start point. */
|
|
7
|
+
origin: Vec3;
|
|
8
|
+
/** Direction; any nonzero length. */
|
|
9
|
+
direction: Vec3;
|
|
10
|
+
}
|
|
11
|
+
/** Options of {@link pickRay}. */
|
|
12
|
+
export interface PickRayOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The backend the matrix was made for, `engine.backend`: `'webgpu'` (default) has reverse depth from 1 at the near
|
|
15
|
+
* plane to 0 at the far one; `'webgl2'` has OpenGL depth from -1 at the near plane to 1 at the far one.
|
|
16
|
+
*/
|
|
17
|
+
backend?: 'webgpu' | 'webgl2';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The ray under a pointer: `x` and `y` in normalized device coordinates (-1 to 1, y up) and `matrix` the camera's
|
|
21
|
+
* view-projection (`engine.camera.matrix`); pass `{ backend: engine.backend }` so a WebGL2 matrix's depth is read the
|
|
22
|
+
* right way round. The origin is on the near plane and the direction unit length. Null when the matrix cannot be
|
|
23
|
+
* inverted. Transform it into a model's cells before casting.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pickRay(matrix: ArrayLike<number>, x: number, y: number, options?: PickRayOptions): GridRay | null;
|
|
26
|
+
/**
|
|
27
|
+
* The first filled cell along `ray` within `maxDistance` (measured along the normalized direction), or null. A ray
|
|
28
|
+
* that only touches a cell's edge or corner misses it. Where a ray crosses an edge or corner of a filled cell, the
|
|
29
|
+
* reported normal is the exposed face (the neighbour is empty), so Face Attach and faceCells see that surface;
|
|
30
|
+
* among exposed faces, the one most head-on to the ray. Sparse grids visit only chunks the ray crosses.
|
|
31
|
+
*/
|
|
32
|
+
export declare function raycastGrid(source: GridSource, ray: GridRay, maxDistance?: number): GridHit | null;
|
|
33
|
+
/** The cell at y = 0 where `ray` meets the ground plane, inside a grid of `size` on x and z, or null. */
|
|
34
|
+
export declare function groundCell(size: Vec3, ray: GridRay): MutableVec3 | null;
|
package/dist/pick.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { _ as e, c as t, d as n, f as r, m as i, n as a } from "./grid-B2V0TGLV.js";
|
|
2
|
+
import { SparseGrid as o } from "./sparse.js";
|
|
3
|
+
import { invertMatrixStable as s } from "@margoengine/math/mat4";
|
|
4
|
+
//#region src/pick.ts
|
|
5
|
+
function c(e, t, n, i = {}) {
|
|
6
|
+
if (!Number.isFinite(t) || !Number.isFinite(n)) throw RangeError("pickRay x and y are not finite; pass NDC numbers");
|
|
7
|
+
if (typeof i != "object" || !i) throw TypeError("pickRay options are not an object; pass { backend: engine.backend }");
|
|
8
|
+
let [a, o] = r(i.backend, "pickRay"), c = s(e, /* @__PURE__ */ new Float64Array(16));
|
|
9
|
+
if (!c) return null;
|
|
10
|
+
let l = (e) => {
|
|
11
|
+
let r = c[3] * t + c[7] * n + c[11] * e + c[15];
|
|
12
|
+
return r ? [
|
|
13
|
+
0,
|
|
14
|
+
1,
|
|
15
|
+
2
|
|
16
|
+
].map((i) => (c[i] * t + c[4 + i] * n + c[8 + i] * e + c[12 + i]) / r) : null;
|
|
17
|
+
}, u = l(a), d = l(o);
|
|
18
|
+
if (!u || !d) return null;
|
|
19
|
+
let f = [
|
|
20
|
+
d[0] - u[0],
|
|
21
|
+
d[1] - u[1],
|
|
22
|
+
d[2] - u[2]
|
|
23
|
+
], p = Math.hypot(f[0], f[1], f[2]);
|
|
24
|
+
return !p || !Number.isFinite(p) ? null : {
|
|
25
|
+
origin: u,
|
|
26
|
+
direction: [
|
|
27
|
+
f[0] / p,
|
|
28
|
+
f[1] / p,
|
|
29
|
+
f[2] / p
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function l(r, s, c = Infinity) {
|
|
34
|
+
if (typeof s != "object" || !s) throw TypeError("raycastGrid ray is missing; pass {origin, direction}");
|
|
35
|
+
if (r instanceof o) return r.raycast(s.origin, s.direction, c);
|
|
36
|
+
if (t(r, a), n(s.origin, "raycastGrid origin"), n(s.direction, "raycastGrid direction"), !(c >= 0)) throw RangeError("raycastGrid maxDistance is negative; pass 0 or more");
|
|
37
|
+
let l = r.size, [u, , d] = l, f = s.origin, p = e(s.direction, "raycastGrid"), m = (e) => r.voxels[e[0] + u * (e[2] + d * e[1])], h = (e) => e[0] >= 0 && e[1] >= 0 && e[2] >= 0 && e[0] < l[0] && e[1] < l[1] && e[2] < l[2], g = [
|
|
38
|
+
Math.floor(f[0]),
|
|
39
|
+
Math.floor(f[1]),
|
|
40
|
+
Math.floor(f[2])
|
|
41
|
+
];
|
|
42
|
+
if (h(g) && m(g)) return {
|
|
43
|
+
cell: g,
|
|
44
|
+
adjacent: [...g],
|
|
45
|
+
normal: [
|
|
46
|
+
0,
|
|
47
|
+
0,
|
|
48
|
+
0
|
|
49
|
+
],
|
|
50
|
+
value: m(g),
|
|
51
|
+
distance: 0
|
|
52
|
+
};
|
|
53
|
+
let _ = 0, v = c, y = [
|
|
54
|
+
0,
|
|
55
|
+
0,
|
|
56
|
+
0
|
|
57
|
+
];
|
|
58
|
+
for (let e = 0; e < 3; e++) {
|
|
59
|
+
if (!p[e]) {
|
|
60
|
+
if (f[e] < 0 || f[e] >= l[e]) return null;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
let t = -f[e] / p[e], n = (l[e] - f[e]) / p[e], r = Math.min(t, n);
|
|
64
|
+
(r > _ || r === _ && !h(g)) && (_ = r, y = [
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0
|
|
68
|
+
], y[e] = -Math.sign(p[e])), v = Math.min(v, Math.max(t, n));
|
|
69
|
+
}
|
|
70
|
+
if (_ > v) return null;
|
|
71
|
+
let b = [
|
|
72
|
+
0,
|
|
73
|
+
1,
|
|
74
|
+
2
|
|
75
|
+
].map((e) => Math.min(l[e] - 1, Math.max(0, Math.floor(f[e] + p[e] * (_ + 1e-7))))), x = p.map(Math.sign), S = p.map((e) => e ? Math.abs(1 / e) : Infinity), C = p.map((e, t) => e ? (b[t] + +(e > 0) - f[t]) / e : Infinity), w = Math.max(0, _);
|
|
76
|
+
for (let e = 0; e <= l[0] + l[1] + l[2] + 3 && h(b); e++) {
|
|
77
|
+
let e = m(b);
|
|
78
|
+
if (e) return {
|
|
79
|
+
cell: [
|
|
80
|
+
b[0],
|
|
81
|
+
b[1],
|
|
82
|
+
b[2]
|
|
83
|
+
],
|
|
84
|
+
adjacent: [
|
|
85
|
+
b[0] + y[0],
|
|
86
|
+
b[1] + y[1],
|
|
87
|
+
b[2] + y[2]
|
|
88
|
+
],
|
|
89
|
+
normal: y,
|
|
90
|
+
value: e,
|
|
91
|
+
distance: w
|
|
92
|
+
};
|
|
93
|
+
let t = Math.min(C[0], C[1], C[2]);
|
|
94
|
+
if (t > v) break;
|
|
95
|
+
w = t;
|
|
96
|
+
let n = [];
|
|
97
|
+
for (let e = 0; e < 3; e++) C[e] > t + 1e-8 || (b[e] += x[e], C[e] += S[e], n.push(e));
|
|
98
|
+
y = i(b, n, p, (e, t, n) => h([
|
|
99
|
+
e,
|
|
100
|
+
t,
|
|
101
|
+
n
|
|
102
|
+
]) && m([
|
|
103
|
+
e,
|
|
104
|
+
t,
|
|
105
|
+
n
|
|
106
|
+
]) > 0);
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function u(e, t) {
|
|
111
|
+
if (n(t?.origin, "groundCell origin"), n(t.direction, "groundCell direction"), !t.direction[1]) return null;
|
|
112
|
+
let r = -t.origin[1] / t.direction[1];
|
|
113
|
+
if (r < 0) return null;
|
|
114
|
+
let i = Math.floor(t.origin[0] + t.direction[0] * r), a = Math.floor(t.origin[2] + t.direction[2] * r);
|
|
115
|
+
return i >= 0 && a >= 0 && i < e[0] && a < e[2] && e[1] > 0 ? [
|
|
116
|
+
i,
|
|
117
|
+
0,
|
|
118
|
+
a
|
|
119
|
+
] : null;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { u as groundCell, c as pickRay, l as raycastGrid };
|