@nika-js/onlymap 0.9.0 → 0.9.1
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/CHANGELOG.md +20 -0
- package/README.md +25 -2
- package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
- package/dist/{basemap-m98j2wxG.js → basemap-DL0mk9Bf.js} +1 -1
- package/dist/dem-decode.d.ts +58 -0
- package/dist/elements/om-map.d.ts +2 -0
- package/dist/{geoparquet-XOwOmChh.js → geoparquet-DJxZA0if.js} +1 -1
- package/dist/hillshade-DR3TxO1a.js +186 -0
- package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
- package/dist/hillshade-apron.d.ts +54 -0
- package/dist/hillshade-shader-n_zManfZ.js +160 -0
- package/dist/hillshade-shader.d.ts +152 -0
- package/dist/hillshade.d.ts +133 -0
- package/dist/html-data.d.ts +1 -1
- package/dist/{index-HZWdgtm4.js → index-BjcPjICh.js} +59 -59
- package/dist/{index-DzOvV-O7.js → index-CvuDsvnk.js} +22 -22
- package/dist/{index-CfPbQUqO.js → index-DO_w0tqR.js} +86 -83
- package/dist/{index-DDNElBTs.js → index-DdTZSuAb.js} +106 -106
- package/dist/{index-BSAY6CWm.js → index-oY3XHIux.js} +9843 -9623
- package/dist/{index-BMbpftvm.js → index-vLXZuog4.js} +1 -1
- package/dist/lerc-Bph62dCb.js +22 -0
- package/dist/onlymap.standalone.js +21279 -20558
- package/dist/onlymapjs.js +37 -37
- package/dist/{raster-Dg5p_99H.js → raster-D-eTzCE3.js} +609 -499
- package/dist/raster-hillshade.d.ts +119 -0
- package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-BlOnMPJe.js} +510 -484
- package/dist/raster-pipeline.d.ts +10 -0
- package/dist/raster.d.ts +5 -0
- package/dist/terrain-heightfield.d.ts +0 -16
- package/dist/terrain-sample.d.ts +0 -13
- package/dist/version.d.ts +1 -1
- package/dist/volumetrics.d.ts +7 -0
- package/dist/{zarr-D3CzK1Zm.js → zarr-BGDoEtFb.js} +2 -2
- package/docs/cartograph.md +2 -2
- package/docs/design/hillshade.md +290 -0
- package/docs/effects.md +11 -0
- package/docs/hillshade.md +203 -0
- package/llms.txt +2 -1
- package/onlymapjs.attributes.json +27 -2
- package/onlymapjs.html-data.json +44 -6
- package/package.json +13 -9
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/syntax.md +11 -3
- package/dist/lerc-qK-nhCaB.js +0 -30
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
1
|
+
import { M as k, G as M, u as j, P as L, i as F, o as z, a as E, b as O, E as R, c as I } from "./index-oY3XHIux.js";
|
|
2
|
+
import { e as ao, O as fo, h as uo, j as po } from "./index-oY3XHIux.js";
|
|
3
|
+
const B = (
|
|
4
4
|
/* wgsl */
|
|
5
5
|
`struct VertexInputs {
|
|
6
6
|
@location(0) clipSpacePositions: vec2<f32>,
|
|
@@ -25,7 +25,7 @@ fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
|
|
|
25
25
|
return outputs;
|
|
26
26
|
}
|
|
27
27
|
`
|
|
28
|
-
),
|
|
28
|
+
), N = (
|
|
29
29
|
/* glsl */
|
|
30
30
|
`#version 300 es
|
|
31
31
|
in vec2 clipSpacePositions;
|
|
@@ -44,16 +44,16 @@ void main(void) {
|
|
|
44
44
|
}
|
|
45
45
|
`
|
|
46
46
|
), $ = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
47
|
-
class
|
|
47
|
+
class U extends k {
|
|
48
48
|
constructor(e, t) {
|
|
49
49
|
const n = $.map((r) => r === -1 ? 0 : r);
|
|
50
|
-
t.source && (t = { ...t, source: `${
|
|
50
|
+
t.source && (t = { ...t, source: `${B}
|
|
51
51
|
${t.source}` }), super(e, {
|
|
52
|
-
id: t.id ||
|
|
52
|
+
id: t.id || j("clip-space"),
|
|
53
53
|
...t,
|
|
54
|
-
vs:
|
|
54
|
+
vs: N,
|
|
55
55
|
vertexCount: 4,
|
|
56
|
-
geometry: new
|
|
56
|
+
geometry: new M({
|
|
57
57
|
topology: "triangle-strip",
|
|
58
58
|
vertexCount: 4,
|
|
59
59
|
attributes: {
|
|
@@ -68,14 +68,14 @@ ${t.source}` }), super(e, {
|
|
|
68
68
|
const D = `layout(std140) uniform screenUniforms {
|
|
69
69
|
vec2 texSize;
|
|
70
70
|
} screen;
|
|
71
|
-
`,
|
|
71
|
+
`, G = {
|
|
72
72
|
name: "screen",
|
|
73
73
|
fs: D,
|
|
74
74
|
uniformTypes: {
|
|
75
75
|
texSize: "vec2<f32>"
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
class
|
|
78
|
+
class V extends L {
|
|
79
79
|
constructor(e, t) {
|
|
80
80
|
super(e, t);
|
|
81
81
|
const { module: n, fs: r, id: i } = t, c = {
|
|
@@ -90,7 +90,7 @@ class U extends M {
|
|
|
90
90
|
blendColorOperation: "add",
|
|
91
91
|
blendAlphaOperation: "add"
|
|
92
92
|
};
|
|
93
|
-
this.model = new
|
|
93
|
+
this.model = new U(e, { id: i, fs: r, modules: [n, G], parameters: c });
|
|
94
94
|
}
|
|
95
95
|
render(e) {
|
|
96
96
|
this._renderPass(this.device, e);
|
|
@@ -124,12 +124,12 @@ class U extends M {
|
|
|
124
124
|
this.model.draw(l), l.end();
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
class
|
|
127
|
+
class P {
|
|
128
128
|
constructor(e, t) {
|
|
129
|
-
this.id = `${e.name}-pass`, this.props = t,
|
|
129
|
+
this.id = `${e.name}-pass`, this.props = t, F(e), this.module = e;
|
|
130
130
|
}
|
|
131
131
|
setup({ device: e }) {
|
|
132
|
-
this.passes =
|
|
132
|
+
this.passes = q(e, this.module, this.id);
|
|
133
133
|
}
|
|
134
134
|
setProps(e) {
|
|
135
135
|
this.props = e;
|
|
@@ -143,8 +143,8 @@ class S {
|
|
|
143
143
|
for (let c = 0; c < t.length; c++) {
|
|
144
144
|
const s = c === t.length - 1, l = n !== void 0 && s;
|
|
145
145
|
l && (i = n);
|
|
146
|
-
const f = !l || !!e.clearCanvas, u = {},
|
|
147
|
-
u[this.module.name] = { ...this.props, ...
|
|
146
|
+
const f = !l || !!e.clearCanvas, u = {}, m = this.module.passes[c].uniforms;
|
|
147
|
+
u[this.module.name] = { ...this.props, ...m }, t[c].render({ clearCanvas: f, inputBuffer: r, outputBuffer: i, moduleProps: u });
|
|
148
148
|
const v = i;
|
|
149
149
|
i = r, r = v;
|
|
150
150
|
}
|
|
@@ -158,13 +158,13 @@ class S {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function q(o, e, t) {
|
|
162
162
|
return e.passes.map((n, r) => {
|
|
163
|
-
const i =
|
|
164
|
-
return new
|
|
163
|
+
const i = H(e, n), c = `${t}-${r}`;
|
|
164
|
+
return new V(o, { id: c, module: e, fs: i });
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const C = `#version 300 es
|
|
168
168
|
uniform sampler2D texSrc;
|
|
169
169
|
|
|
170
170
|
in vec2 position;
|
|
@@ -172,31 +172,31 @@ in vec2 coordinate;
|
|
|
172
172
|
in vec2 uv;
|
|
173
173
|
|
|
174
174
|
out vec4 fragColor;
|
|
175
|
-
`,
|
|
175
|
+
`, J = (o) => `${C}
|
|
176
176
|
void main() {
|
|
177
177
|
fragColor = texture(texSrc, coordinate);
|
|
178
178
|
fragColor = ${o}(fragColor, screen.texSize, coordinate);
|
|
179
179
|
}
|
|
180
|
-
`,
|
|
180
|
+
`, X = (o) => `${C}
|
|
181
181
|
void main() {
|
|
182
182
|
fragColor = ${o}(texSrc, screen.texSize, coordinate);
|
|
183
183
|
}
|
|
184
184
|
`;
|
|
185
|
-
function
|
|
185
|
+
function H(o, e) {
|
|
186
186
|
if (e.filter) {
|
|
187
187
|
const t = typeof e.filter == "string" ? e.filter : `${o.name}_filterColor_ext`;
|
|
188
|
-
return
|
|
188
|
+
return J(t);
|
|
189
189
|
}
|
|
190
190
|
if (e.sampler) {
|
|
191
191
|
const t = typeof e.sampler == "string" ? e.sampler : `${o.name}_sampleColor`;
|
|
192
|
-
return
|
|
192
|
+
return X(t);
|
|
193
193
|
}
|
|
194
194
|
return "";
|
|
195
195
|
}
|
|
196
|
-
const
|
|
196
|
+
const W = `
|
|
197
197
|
float omfx_lum(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
|
|
198
198
|
float omfx_hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
|
|
199
|
-
`,
|
|
199
|
+
`, S = {
|
|
200
200
|
tint: (o) => `
|
|
201
201
|
{
|
|
202
202
|
float L = omfx_lum(color.rgb);
|
|
@@ -300,10 +300,12 @@ float omfx_hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 4375
|
|
|
300
300
|
}`
|
|
301
301
|
};
|
|
302
302
|
function x(o) {
|
|
303
|
-
const e =
|
|
303
|
+
const e = z(o), t = Object.prototype.hasOwnProperty.call(S, o) ? S[o] : void 0;
|
|
304
304
|
return e && t ? { ...e, glsl: t } : void 0;
|
|
305
305
|
}
|
|
306
|
-
|
|
306
|
+
const _ = ` float omfxAlpha = inColor.a;
|
|
307
|
+
vec4 color = vec4(omfxAlpha > 0.0 ? inColor.rgb / omfxAlpha : vec3(0.0), omfxAlpha);`, w = " return vec4(color.rgb * omfxAlpha, omfxAlpha);";
|
|
308
|
+
function Y(o) {
|
|
307
309
|
const e = [];
|
|
308
310
|
let t = [];
|
|
309
311
|
const n = () => {
|
|
@@ -317,14 +319,14 @@ function H(o) {
|
|
|
317
319
|
n(), e.push({ kind: "neighbourhood", op: i });
|
|
318
320
|
}), n(), e;
|
|
319
321
|
}
|
|
320
|
-
function
|
|
322
|
+
function K(o, e) {
|
|
321
323
|
if (o.length === 0) return null;
|
|
322
324
|
const t = [], n = [], r = /* @__PURE__ */ new Map();
|
|
323
325
|
o.forEach((a, p) => {
|
|
324
326
|
for (const g of a.def.params) {
|
|
325
327
|
const h = a.values[g.name];
|
|
326
|
-
let
|
|
327
|
-
g.kind === "color" ? (
|
|
328
|
+
let d;
|
|
329
|
+
g.kind === "color" ? (d = `c${t.length}`, t.push({ key: d, value: Array.isArray(h) ? h : [0, 0, 0, 1] })) : (d = `f${n.length}`, n.push({ key: d, value: typeof h == "number" ? h : 0 })), r.set(`${p}:${g.name}`, `${e}.${d}`);
|
|
328
330
|
}
|
|
329
331
|
});
|
|
330
332
|
const i = {}, c = {}, s = [];
|
|
@@ -332,35 +334,36 @@ function W(o, e) {
|
|
|
332
334
|
i[a] = p, c[a] = "vec4<f32>", s.push(` vec4 ${a};`);
|
|
333
335
|
for (const { key: a, value: p } of n)
|
|
334
336
|
i[a] = p, c[a] = "f32", s.push(` float ${a};`);
|
|
335
|
-
i.pxPerMm =
|
|
336
|
-
const l = `${e}.pxPerMm`, f = (a) => (p) => r.get(`${a}:${p}`) ?? "0.0", u = [],
|
|
337
|
-
|
|
337
|
+
i.pxPerMm = E, c.pxPerMm = "f32", s.push(" float pxPerMm;");
|
|
338
|
+
const l = `${e}.pxPerMm`, f = (a) => (p) => r.get(`${a}:${p}`) ?? "0.0", u = [], m = [];
|
|
339
|
+
Y(o).forEach((a, p) => {
|
|
338
340
|
if (a.kind === "pointwise") {
|
|
339
|
-
const
|
|
341
|
+
const d = `${e}_p${p}`, T = a.ops.map((b) => o[b].def.glsl(f(b), l)).join(`
|
|
340
342
|
`);
|
|
341
343
|
u.push(
|
|
342
|
-
`vec4 ${
|
|
343
|
-
|
|
344
|
-
${
|
|
345
|
-
|
|
344
|
+
`vec4 ${d}(vec4 inColor, vec2 texSize, vec2 coord) {
|
|
345
|
+
${_}
|
|
346
|
+
${T}
|
|
347
|
+
${w}
|
|
346
348
|
}`
|
|
347
|
-
),
|
|
349
|
+
), m.push({ filter: d });
|
|
348
350
|
return;
|
|
349
351
|
}
|
|
350
352
|
const g = `${e}_n${p}`, h = o[a.op].def.glsl(f(a.op), l);
|
|
351
353
|
u.push(
|
|
352
354
|
`vec4 ${g}(sampler2D src, vec2 texSize, vec2 coord) {
|
|
353
|
-
vec4
|
|
355
|
+
vec4 inColor = texture(src, coord);
|
|
356
|
+
${_}
|
|
354
357
|
${h}
|
|
355
|
-
|
|
358
|
+
${w}
|
|
356
359
|
}`
|
|
357
|
-
),
|
|
360
|
+
), m.push({ sampler: g });
|
|
358
361
|
});
|
|
359
362
|
const v = [
|
|
360
363
|
`layout(std140) uniform ${e}Uniforms {`,
|
|
361
364
|
...s,
|
|
362
365
|
`} ${e};`,
|
|
363
|
-
|
|
366
|
+
W,
|
|
364
367
|
...u
|
|
365
368
|
].join(`
|
|
366
369
|
`);
|
|
@@ -369,21 +372,21 @@ ${h}
|
|
|
369
372
|
// runtime reads (`typeof pass.filter === 'string' ? pass.filter : …`) but
|
|
370
373
|
// its `ShaderSubPass` type declares as a boolean — a deck typing gap, not
|
|
371
374
|
// a runtime one, the same shape as `maxZoom` on the standalone controller.
|
|
372
|
-
module: { name: e, fs: v, uniformTypes: c, passes:
|
|
375
|
+
module: { name: e, fs: v, uniformTypes: c, passes: m },
|
|
373
376
|
uniforms: i,
|
|
374
|
-
passCount:
|
|
377
|
+
passCount: m.length
|
|
375
378
|
};
|
|
376
379
|
}
|
|
377
|
-
const
|
|
378
|
-
function
|
|
380
|
+
const Q = /^\s*(-?[\d.]+)\s*(mm)?\s*$/i, Z = /^\s*(-?[\d.]+)\s*(deg)?\s*$/i;
|
|
381
|
+
function A(o, e) {
|
|
379
382
|
if (o.kind === "color") {
|
|
380
|
-
const n =
|
|
383
|
+
const n = I(e);
|
|
381
384
|
if (!n) return;
|
|
382
385
|
const [r, i, c, s] = n;
|
|
383
386
|
return [r / 255, i / 255, c / 255, s === void 0 ? 1 : s > 1 ? s / 255 : s];
|
|
384
387
|
}
|
|
385
388
|
if (o.kind === "length" || o.kind === "angle") {
|
|
386
|
-
const n = (o.kind === "length" ?
|
|
389
|
+
const n = (o.kind === "length" ? Q : Z).exec(e);
|
|
387
390
|
if (!n) return;
|
|
388
391
|
const r = Number(n[1]);
|
|
389
392
|
return Number.isFinite(r) ? r : void 0;
|
|
@@ -391,36 +394,36 @@ function E(o, e) {
|
|
|
391
394
|
const t = Number(e);
|
|
392
395
|
return Number.isFinite(t) ? t : void 0;
|
|
393
396
|
}
|
|
394
|
-
function
|
|
395
|
-
return
|
|
397
|
+
function oo(o) {
|
|
398
|
+
return A(o, String(o.default)) ?? 0;
|
|
396
399
|
}
|
|
397
|
-
function
|
|
400
|
+
function y(o, e) {
|
|
398
401
|
const t = x(o);
|
|
399
402
|
if (!t) return null;
|
|
400
403
|
const n = {};
|
|
401
404
|
for (const r of t.params) {
|
|
402
|
-
const i = e(r.name), c = i === null ? void 0 :
|
|
403
|
-
n[r.name] = c ??
|
|
405
|
+
const i = e(r.name), c = i === null ? void 0 : A(r, i);
|
|
406
|
+
n[r.name] = c ?? oo(r);
|
|
404
407
|
}
|
|
405
408
|
return { op: o, values: n };
|
|
406
409
|
}
|
|
407
|
-
function
|
|
410
|
+
function eo(o) {
|
|
408
411
|
if (!o || typeof o != "object") return !1;
|
|
409
412
|
const e = o;
|
|
410
413
|
return typeof e.name == "string" && typeof e.fs == "string" && Array.isArray(e.passes) && e.passes.length > 0;
|
|
411
414
|
}
|
|
412
|
-
function
|
|
415
|
+
function no(o) {
|
|
413
416
|
const e = [];
|
|
414
417
|
for (const t of Array.from(o.querySelectorAll(":scope > om-effect"))) {
|
|
415
418
|
const n = t.getAttribute("preset"), r = t.getAttribute("op"), i = t.querySelector(":scope > script[type='application/json']");
|
|
416
419
|
if (n !== null && n !== "") {
|
|
417
|
-
if (!
|
|
420
|
+
if (!O(n)) {
|
|
418
421
|
console.warn(`[onlymapjs] <om-effect preset="${n}"> is not a known preset — skipped.`, t);
|
|
419
422
|
continue;
|
|
420
423
|
}
|
|
421
|
-
const c =
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
+
const c = R[n].map(({ op: s, params: l }) => x(s) ? y(s, (u) => {
|
|
425
|
+
const m = t.getAttribute(`${s}-${u}`);
|
|
426
|
+
if (m !== null) return m;
|
|
424
427
|
const v = l[u];
|
|
425
428
|
return v === void 0 ? null : String(v);
|
|
426
429
|
}) : null).filter((s) => s !== null);
|
|
@@ -428,7 +431,7 @@ function ro(o) {
|
|
|
428
431
|
continue;
|
|
429
432
|
}
|
|
430
433
|
if (r !== null && r !== "") {
|
|
431
|
-
const c =
|
|
434
|
+
const c = y(r, (s) => t.getAttribute(s));
|
|
432
435
|
if (!c) {
|
|
433
436
|
console.warn(`[onlymapjs] <om-effect op="${r}"> is not a known op — skipped.`, t);
|
|
434
437
|
continue;
|
|
@@ -444,7 +447,7 @@ function ro(o) {
|
|
|
444
447
|
console.warn(`[onlymapjs] <om-effect>'s inline module is not valid JSON — skipped. ${String(f)}`, t);
|
|
445
448
|
continue;
|
|
446
449
|
}
|
|
447
|
-
if (!
|
|
450
|
+
if (!eo(c)) {
|
|
448
451
|
console.warn(
|
|
449
452
|
"[onlymapjs] <om-effect>'s inline module needs `name`, `fs` and a non-empty `passes` — skipped.",
|
|
450
453
|
t
|
|
@@ -466,16 +469,16 @@ function ro(o) {
|
|
|
466
469
|
}
|
|
467
470
|
return e;
|
|
468
471
|
}
|
|
469
|
-
let
|
|
470
|
-
const
|
|
471
|
-
function
|
|
472
|
+
let to = 0;
|
|
473
|
+
const ro = () => to++;
|
|
474
|
+
function co(o, e = E) {
|
|
472
475
|
const t = [], n = [];
|
|
473
476
|
let r = [];
|
|
474
|
-
const i =
|
|
477
|
+
const i = ro(), c = () => {
|
|
475
478
|
if (r.length === 0) return;
|
|
476
|
-
const s =
|
|
479
|
+
const s = K(r, `omfx${i}_${t.length}`);
|
|
477
480
|
if (r = [], !s) return;
|
|
478
|
-
const l = { ...s.uniforms, pxPerMm: e }, f = new
|
|
481
|
+
const l = { ...s.uniforms, pxPerMm: e }, f = new P(s.module, l);
|
|
479
482
|
n.push({ effect: f, uniforms: s.uniforms }), t.push(f);
|
|
480
483
|
};
|
|
481
484
|
for (const s of o) {
|
|
@@ -486,7 +489,7 @@ function so(o, e = w) {
|
|
|
486
489
|
}
|
|
487
490
|
continue;
|
|
488
491
|
}
|
|
489
|
-
s.raw && (c(), t.push(new
|
|
492
|
+
s.raw && (c(), t.push(new P(s.raw.module, s.raw.uniforms)));
|
|
490
493
|
}
|
|
491
494
|
return c(), {
|
|
492
495
|
effects: t,
|
|
@@ -496,16 +499,16 @@ function so(o, e = w) {
|
|
|
496
499
|
};
|
|
497
500
|
}
|
|
498
501
|
export {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
502
|
+
E as CSS_PX_PER_MM,
|
|
503
|
+
R as EFFECT_PRESETS,
|
|
504
|
+
ao as EFFECT_PRESET_NAMES,
|
|
505
|
+
fo as OP_META,
|
|
506
|
+
uo as OP_NAMES,
|
|
507
|
+
co as buildPostProcessEffects,
|
|
508
|
+
A as coerceParam,
|
|
509
|
+
po as expandPreset,
|
|
510
|
+
O as isEffectPreset,
|
|
508
511
|
x as opDef,
|
|
509
|
-
|
|
510
|
-
|
|
512
|
+
z as opMeta,
|
|
513
|
+
no as parseEffectEls
|
|
511
514
|
};
|