@margoengine/tiles 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 +437 -2
- package/dist/bounds-CgKJT3Pg.js +161 -0
- package/dist/bounds.d.ts +66 -0
- package/dist/data-uri-DbGLVHq5.js +132 -0
- package/dist/data-uri.d.ts +2 -0
- package/dist/errors-D5_2oB8I.js +7 -0
- package/dist/fade.d.ts +34 -0
- package/dist/fade.js +129 -0
- package/dist/feature-texture.d.ts +19 -0
- package/dist/features.d.ts +78 -0
- package/dist/features.js +401 -0
- package/dist/formats-NNuOXg-1.js +390 -0
- package/dist/formats.d.ts +124 -0
- package/dist/glb-BU81jlYZ.js +25 -0
- package/dist/height.d.ts +20 -0
- package/dist/height.js +31 -0
- package/dist/i3dm.d.ts +16 -0
- package/dist/i3dm.js +85 -0
- package/dist/imagery.d.ts +108 -0
- package/dist/imagery.js +325 -0
- package/dist/implicit.d.ts +42 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +849 -0
- package/dist/ion.d.ts +106 -0
- package/dist/ion.js +152 -0
- package/dist/json-BQoirgm5.js +4 -0
- package/dist/matrix-DcI5oFrD.js +89 -0
- package/dist/matrix.d.ts +32 -0
- package/dist/memory.d.ts +44 -0
- package/dist/metadata.d.ts +147 -0
- package/dist/metadata.js +285 -0
- package/dist/properties.d.ts +94 -0
- package/dist/properties.js +320 -0
- package/dist/queue.d.ts +37 -0
- package/dist/raw-accessor.d.ts +4 -0
- package/dist/renderer.d.ts +193 -0
- package/dist/s2.d.ts +37 -0
- package/dist/s2.js +181 -0
- package/dist/scene-scope-DufD_3B6.js +42 -0
- package/dist/screen-door-CMv5Jko4.js +11 -0
- package/dist/shared/screen-door.d.ts +9 -0
- package/dist/splats.d.ts +80 -0
- package/dist/splats.js +187 -0
- package/dist/style.d.ts +61 -0
- package/dist/style.js +609 -0
- package/dist/terrain.d.ts +96 -0
- package/dist/terrain.js +434 -0
- package/dist/tileset.d.ts +316 -0
- package/dist/uv-transform.d.ts +11 -0
- package/dist/wgs84-C5btsGGY.js +18 -0
- package/dist/wgs84.d.ts +24 -0
- package/package.json +122 -4
package/dist/style.js
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import { readStructuralMetadata as e } from "./metadata.js";
|
|
2
|
+
import { MargoError as t } from "@margoengine/math/errors";
|
|
3
|
+
import { SRGBToLinear as n } from "@margoengine/math/color";
|
|
4
|
+
//#region ../shared/style-expression.js
|
|
5
|
+
var r = class extends Array {}, i = (e) => {
|
|
6
|
+
throw new t("state", `Style: ${e}; use an OGC 3D Tiles style expression`);
|
|
7
|
+
}, a = (e) => typeof e == "number" ? e : i("expected a number"), o = (e) => typeof e == "boolean" ? e : i("expected a boolean"), s = (e) => e instanceof r ? `(${e.join(", ")})` : Array.isArray(e) ? `[${e.map(s).join(", ")}]` : String(e);
|
|
8
|
+
function c(e, t) {
|
|
9
|
+
let n = t.find((e) => e instanceof r);
|
|
10
|
+
return n ? (t.some((e) => e instanceof r && e.length !== n.length) && i("vector dimensions differ"), r.from(n, (n, i) => e(...t.map((e) => a(e instanceof r ? e[i] : e))))) : e(...t.map(a));
|
|
11
|
+
}
|
|
12
|
+
function l(e, t) {
|
|
13
|
+
if (e instanceof r && typeof t == "string" && "xyzwrgba".includes(t) && t.length === 1) return e["xyzw".includes(t) ? "xyzw".indexOf(t) : "rgba".indexOf(t)];
|
|
14
|
+
if (typeof e == "object" && e && Object.hasOwn(e, String(t))) return e[String(t)];
|
|
15
|
+
}
|
|
16
|
+
function u(e, t) {
|
|
17
|
+
/^(?:[^.\[\]\s]+)(?:(?:\.[^.\[\]\s]+)|(?:\[(?:'[^']*'|"[^"]*"|\d+)\]))*$/.test(e) || i("invalid property path");
|
|
18
|
+
let n = e.match(/(?:[^.\[\]\s]+)|(?:\[(?:'[^']*'|"[^"]*"|\d+)\])/g).map((e) => e.startsWith("[") ? e.slice(1, -1).replace(/^['"]|['"]$/g, "") : e);
|
|
19
|
+
n.length > 1 && n[0] === "feature" && n.shift();
|
|
20
|
+
let a = n.shift(), o = t(a);
|
|
21
|
+
[
|
|
22
|
+
"POSITION",
|
|
23
|
+
"POSITION_ABSOLUTE",
|
|
24
|
+
"NORMAL",
|
|
25
|
+
"COLOR"
|
|
26
|
+
].includes(a) && Array.isArray(o) && (o = r.from(o));
|
|
27
|
+
for (let e of n) o = l(o, e);
|
|
28
|
+
return o;
|
|
29
|
+
}
|
|
30
|
+
var d = {
|
|
31
|
+
abs: Math.abs,
|
|
32
|
+
sqrt: Math.sqrt,
|
|
33
|
+
cos: Math.cos,
|
|
34
|
+
sin: Math.sin,
|
|
35
|
+
tan: Math.tan,
|
|
36
|
+
acos: Math.acos,
|
|
37
|
+
asin: Math.asin,
|
|
38
|
+
atan: Math.atan,
|
|
39
|
+
atan2: Math.atan2,
|
|
40
|
+
radians: (e) => e * Math.PI / 180,
|
|
41
|
+
degrees: (e) => e * 180 / Math.PI,
|
|
42
|
+
sign: Math.sign,
|
|
43
|
+
floor: Math.floor,
|
|
44
|
+
ceil: Math.ceil,
|
|
45
|
+
round: Math.round,
|
|
46
|
+
exp: Math.exp,
|
|
47
|
+
log: Math.log,
|
|
48
|
+
exp2: (e) => 2 ** e,
|
|
49
|
+
log2: Math.log2,
|
|
50
|
+
fract: (e) => e - Math.floor(e),
|
|
51
|
+
pow: Math.pow,
|
|
52
|
+
min: Math.min,
|
|
53
|
+
max: Math.max,
|
|
54
|
+
clamp: (e, t, n) => Math.max(t, Math.min(n, e)),
|
|
55
|
+
mix: (e, t, n) => e * (1 - n) + t * n
|
|
56
|
+
}, f = {
|
|
57
|
+
black: "000000",
|
|
58
|
+
silver: "c0c0c0",
|
|
59
|
+
gray: "808080",
|
|
60
|
+
white: "ffffff",
|
|
61
|
+
maroon: "800000",
|
|
62
|
+
red: "ff0000",
|
|
63
|
+
purple: "800080",
|
|
64
|
+
fuchsia: "ff00ff",
|
|
65
|
+
green: "008000",
|
|
66
|
+
lime: "00ff00",
|
|
67
|
+
olive: "808000",
|
|
68
|
+
yellow: "ffff00",
|
|
69
|
+
navy: "000080",
|
|
70
|
+
blue: "0000ff",
|
|
71
|
+
teal: "008080",
|
|
72
|
+
aqua: "00ffff",
|
|
73
|
+
orange: "ffa500",
|
|
74
|
+
aliceblue: "f0f8ff",
|
|
75
|
+
antiquewhite: "faebd7",
|
|
76
|
+
aquamarine: "7fffd4",
|
|
77
|
+
azure: "f0ffff",
|
|
78
|
+
beige: "f5f5dc",
|
|
79
|
+
bisque: "ffe4c4",
|
|
80
|
+
blanchedalmond: "ffebcd",
|
|
81
|
+
blueviolet: "8a2be2",
|
|
82
|
+
brown: "a52a2a",
|
|
83
|
+
burlywood: "deb887",
|
|
84
|
+
cadetblue: "5f9ea0",
|
|
85
|
+
chartreuse: "7fff00",
|
|
86
|
+
chocolate: "d2691e",
|
|
87
|
+
coral: "ff7f50",
|
|
88
|
+
cornflowerblue: "6495ed",
|
|
89
|
+
cornsilk: "fff8dc",
|
|
90
|
+
crimson: "dc143c",
|
|
91
|
+
cyan: "00ffff",
|
|
92
|
+
darkblue: "00008b",
|
|
93
|
+
darkcyan: "008b8b",
|
|
94
|
+
darkgoldenrod: "b8860b",
|
|
95
|
+
darkgray: "a9a9a9",
|
|
96
|
+
darkgreen: "006400",
|
|
97
|
+
darkkhaki: "bdb76b",
|
|
98
|
+
darkmagenta: "8b008b",
|
|
99
|
+
darkolivegreen: "556b2f",
|
|
100
|
+
darkorange: "ff8c00",
|
|
101
|
+
darkorchid: "9932cc",
|
|
102
|
+
darkred: "8b0000",
|
|
103
|
+
darksalmon: "e9967a",
|
|
104
|
+
darkseagreen: "8fbc8f",
|
|
105
|
+
darkslateblue: "483d8b",
|
|
106
|
+
darkslategray: "2f4f4f",
|
|
107
|
+
darkturquoise: "00ced1",
|
|
108
|
+
darkviolet: "9400d3",
|
|
109
|
+
deeppink: "ff1493",
|
|
110
|
+
deepskyblue: "00bfff",
|
|
111
|
+
dimgray: "696969",
|
|
112
|
+
dodgerblue: "1e90ff",
|
|
113
|
+
firebrick: "b22222",
|
|
114
|
+
floralwhite: "fffaf0",
|
|
115
|
+
forestgreen: "228b22",
|
|
116
|
+
gainsboro: "dcdcdc",
|
|
117
|
+
ghostwhite: "f8f8ff",
|
|
118
|
+
gold: "ffd700",
|
|
119
|
+
goldenrod: "daa520",
|
|
120
|
+
greenyellow: "adff2f",
|
|
121
|
+
honeydew: "f0fff0",
|
|
122
|
+
hotpink: "ff69b4",
|
|
123
|
+
indianred: "cd5c5c",
|
|
124
|
+
indigo: "4b0082",
|
|
125
|
+
ivory: "fffff0",
|
|
126
|
+
khaki: "f0e68c",
|
|
127
|
+
lavender: "e6e6fa",
|
|
128
|
+
lavenderblush: "fff0f5",
|
|
129
|
+
lawngreen: "7cfc00",
|
|
130
|
+
lemonchiffon: "fffacd",
|
|
131
|
+
lightblue: "add8e6",
|
|
132
|
+
lightcoral: "f08080",
|
|
133
|
+
lightcyan: "e0ffff",
|
|
134
|
+
lightgoldenrodyellow: "fafad2",
|
|
135
|
+
lightgray: "d3d3d3",
|
|
136
|
+
lightgreen: "90ee90",
|
|
137
|
+
lightpink: "ffb6c1",
|
|
138
|
+
lightsalmon: "ffa07a",
|
|
139
|
+
lightseagreen: "20b2aa",
|
|
140
|
+
lightskyblue: "87cefa",
|
|
141
|
+
lightslategray: "778899",
|
|
142
|
+
lightsteelblue: "b0c4de",
|
|
143
|
+
lightyellow: "ffffe0",
|
|
144
|
+
limegreen: "32cd32",
|
|
145
|
+
linen: "faf0e6",
|
|
146
|
+
magenta: "ff00ff",
|
|
147
|
+
mediumaquamarine: "66cdaa",
|
|
148
|
+
mediumblue: "0000cd",
|
|
149
|
+
mediumorchid: "ba55d3",
|
|
150
|
+
mediumpurple: "9370db",
|
|
151
|
+
mediumseagreen: "3cb371",
|
|
152
|
+
mediumslateblue: "7b68ee",
|
|
153
|
+
mediumspringgreen: "00fa9a",
|
|
154
|
+
mediumturquoise: "48d1cc",
|
|
155
|
+
mediumvioletred: "c71585",
|
|
156
|
+
midnightblue: "191970",
|
|
157
|
+
mintcream: "f5fffa",
|
|
158
|
+
mistyrose: "ffe4e1",
|
|
159
|
+
moccasin: "ffe4b5",
|
|
160
|
+
navajowhite: "ffdead",
|
|
161
|
+
oldlace: "fdf5e6",
|
|
162
|
+
olivedrab: "6b8e23",
|
|
163
|
+
orangered: "ff4500",
|
|
164
|
+
orchid: "da70d6",
|
|
165
|
+
palegoldenrod: "eee8aa",
|
|
166
|
+
palegreen: "98fb98",
|
|
167
|
+
paleturquoise: "afeeee",
|
|
168
|
+
palevioletred: "db7093",
|
|
169
|
+
papayawhip: "ffefd5",
|
|
170
|
+
peachpuff: "ffdab9",
|
|
171
|
+
peru: "cd853f",
|
|
172
|
+
pink: "ffc0cb",
|
|
173
|
+
plum: "dda0dd",
|
|
174
|
+
powderblue: "b0e0e6",
|
|
175
|
+
rosybrown: "bc8f8f",
|
|
176
|
+
royalblue: "4169e1",
|
|
177
|
+
saddlebrown: "8b4513",
|
|
178
|
+
salmon: "fa8072",
|
|
179
|
+
sandybrown: "f4a460",
|
|
180
|
+
seagreen: "2e8b57",
|
|
181
|
+
seashell: "fff5ee",
|
|
182
|
+
sienna: "a0522d",
|
|
183
|
+
skyblue: "87ceeb",
|
|
184
|
+
slateblue: "6a5acd",
|
|
185
|
+
slategray: "708090",
|
|
186
|
+
snow: "fffafa",
|
|
187
|
+
springgreen: "00ff7f",
|
|
188
|
+
steelblue: "4682b4",
|
|
189
|
+
tan: "d2b48c",
|
|
190
|
+
thistle: "d8bfd8",
|
|
191
|
+
tomato: "ff6347",
|
|
192
|
+
turquoise: "40e0d0",
|
|
193
|
+
violet: "ee82ee",
|
|
194
|
+
wheat: "f5deb3",
|
|
195
|
+
whitesmoke: "f5f5f5",
|
|
196
|
+
yellowgreen: "9acd32",
|
|
197
|
+
rebeccapurple: "663399"
|
|
198
|
+
};
|
|
199
|
+
function p(e) {
|
|
200
|
+
let t = String(e[0] ?? "#fff").toLowerCase().replaceAll("grey", "gray"), n = f[t] ?? t.replace(/^#/, "");
|
|
201
|
+
return t === "transparent" ? new r(0, 0, 0, 0) : (n.length === 3 && (n = [...n].map((e) => e + e).join("")), /^[\da-f]{6}$/i.test(n) ? new r(...[
|
|
202
|
+
0,
|
|
203
|
+
2,
|
|
204
|
+
4
|
|
205
|
+
].map((e) => parseInt(n.slice(e, e + 2), 16) / 255), e[1] === void 0 ? 1 : a(e[1])) : i("invalid CSS colour"));
|
|
206
|
+
}
|
|
207
|
+
function m(e, t) {
|
|
208
|
+
if (Object.hasOwn(d, e)) return c(d[e], t);
|
|
209
|
+
if (/^vec[234]$/.test(e)) {
|
|
210
|
+
let n = Number(e[3]), o = t.flatMap((e) => e instanceof r ? [...e] : [a(e)]);
|
|
211
|
+
return o.length === 1 ? r.from({ length: n }, () => o[0]) : o.length < n ? i("vector constructor needs more components") : r.from(o.slice(0, n));
|
|
212
|
+
}
|
|
213
|
+
if (e === "color") return p(t);
|
|
214
|
+
if (e === "rgb" || e === "rgba") return new r(a(t[0]) / 255, a(t[1]) / 255, a(t[2]) / 255, t[3] === void 0 ? 1 : a(t[3]));
|
|
215
|
+
if (e === "hsl" || e === "hsla") {
|
|
216
|
+
let e = a(t[0]), n = a(t[1]), i = a(t[2]), o = (t) => {
|
|
217
|
+
let r = ((t + e * 12) % 12 + 12) % 12;
|
|
218
|
+
return i - n * Math.min(i, 1 - i) * Math.max(-1, Math.min(r - 3, 9 - r, 1));
|
|
219
|
+
};
|
|
220
|
+
return new r(o(0), o(8), o(4), t[3] === void 0 ? 1 : a(t[3]));
|
|
221
|
+
}
|
|
222
|
+
if (e === "Boolean") return !!t[0];
|
|
223
|
+
if (e === "Number") return Number(t[0]);
|
|
224
|
+
if (e === "String") return s(t[0]);
|
|
225
|
+
if (e === "isNaN") return Number.isNaN(a(t[0]));
|
|
226
|
+
if (e === "isFinite") return Number.isFinite(a(t[0]));
|
|
227
|
+
if (e === "regExp") return new RegExp(String(t[0] ?? "(?:)"), t[1] === void 0 ? void 0 : String(t[1]));
|
|
228
|
+
let n = t[0], o = t[1];
|
|
229
|
+
return e === "length" ? n instanceof r ? Math.hypot(...n) : Math.abs(a(n)) : e === "distance" ? m("length", [c((e, t) => e - t, t)]) : e === "normalize" ? c((e, t) => e / t, [n, m("length", [n])]) : e === "dot" || e === "cross" ? !(n instanceof r) || !(o instanceof r) || n.length !== o.length ? i("expected matching vectors") : e === "dot" ? n.reduce((e, t, n) => e + t * o[n], 0) : n.length === 3 ? new r(n[1] * o[2] - n[2] * o[1], n[2] * o[0] - n[0] * o[2], n[0] * o[1] - n[1] * o[0]) : i("cross needs vec3 arguments") : i(`unknown function ${e}`);
|
|
230
|
+
}
|
|
231
|
+
function h(e, t, n) {
|
|
232
|
+
if (e === "===" || e === "!==") {
|
|
233
|
+
let i = t instanceof r && n instanceof r ? t.length === n.length && t.every((e, t) => e === n[t]) : t === n;
|
|
234
|
+
return e === "===" ? i : !i;
|
|
235
|
+
}
|
|
236
|
+
if (e === "=~" || e === "!~") {
|
|
237
|
+
let r = t instanceof RegExp ? t : n instanceof RegExp ? n : i("match needs a regular expression");
|
|
238
|
+
r.lastIndex = 0;
|
|
239
|
+
let a = r.test(s(t instanceof RegExp ? n : t));
|
|
240
|
+
return e === "=~" ? a : !a;
|
|
241
|
+
}
|
|
242
|
+
if (e === "+" && (typeof t == "string" || typeof n == "string")) return s(t) + s(n);
|
|
243
|
+
let o = {
|
|
244
|
+
"+": (e, t) => e + t,
|
|
245
|
+
"-": (e, t) => e - t,
|
|
246
|
+
"*": (e, t) => e * t,
|
|
247
|
+
"/": (e, t) => e / t,
|
|
248
|
+
"%": (e, t) => e % t
|
|
249
|
+
};
|
|
250
|
+
if (Object.hasOwn(o, e)) return c(o[e], [t, n]);
|
|
251
|
+
let l = a(t), u = a(n);
|
|
252
|
+
return e === "<" ? l < u : e === ">" ? l > u : e === "<=" ? l <= u : l >= u;
|
|
253
|
+
}
|
|
254
|
+
function g(e) {
|
|
255
|
+
if (e.length > 65536) return i("expression exceeds 65536 characters");
|
|
256
|
+
let t = e.match(/\$\{[^}]*\}|'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`|(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?|[\p{L}_$][\p{L}\p{N}_$]*|===|!==|<=|>=|&&|\|\||=~|!~|[^\s]/giu) ?? [];
|
|
257
|
+
if (t.length > 4096) return i("expression exceeds 4096 tokens");
|
|
258
|
+
let n = 0, r = 0, a = (e) => t[n] === e && ++n > 0, d = (e) => {
|
|
259
|
+
a(e) || i(`expected ${e} at token ${n}`);
|
|
260
|
+
}, f = (e) => {
|
|
261
|
+
let t = [];
|
|
262
|
+
if (!a(e)) {
|
|
263
|
+
do
|
|
264
|
+
t.push(_(0));
|
|
265
|
+
while (a(","));
|
|
266
|
+
d(e);
|
|
267
|
+
}
|
|
268
|
+
return t;
|
|
269
|
+
}, p = () => {
|
|
270
|
+
let e = t[n++], r;
|
|
271
|
+
if (e === "(") r = _(0), d(")");
|
|
272
|
+
else if (e === "[") {
|
|
273
|
+
let e = f("]");
|
|
274
|
+
r = (t) => e.map((e) => e(t));
|
|
275
|
+
} else if (e === "!" || e === "+" || e === "-") {
|
|
276
|
+
let t = _(7);
|
|
277
|
+
r = (n) => e === "!" ? !o(t(n)) : c((t) => e === "-" ? -t : t, [t(n)]);
|
|
278
|
+
} else if (e?.startsWith("${")) r = (t) => u(e.slice(2, -1), t);
|
|
279
|
+
else if (/^['"`]/.test(e ?? "")) {
|
|
280
|
+
let t = e.slice(1, -1).replace(/\\(u[\da-f]{4}|x[\da-f]{2}|.)/gi, (e, t) => t[0] === "u" || t[0] === "x" ? String.fromCharCode(parseInt(t.slice(1), 16)) : {
|
|
281
|
+
n: "\n",
|
|
282
|
+
r: "\r",
|
|
283
|
+
t: " ",
|
|
284
|
+
b: "\b",
|
|
285
|
+
f: "\f",
|
|
286
|
+
v: "\v"
|
|
287
|
+
}[t] ?? t);
|
|
288
|
+
r = (e) => t.replace(/\$\{([^}]+)\}/g, (t, n) => s(u(n, e)));
|
|
289
|
+
} else if (/^(?:\d|\.\d)/.test(e ?? "")) r = () => Number(e);
|
|
290
|
+
else if (e === "Math") {
|
|
291
|
+
d(".");
|
|
292
|
+
let e = t[n++];
|
|
293
|
+
e !== "PI" && e !== "E" && i("only Math.PI and Math.E are constants"), r = () => e === "PI" ? Math.PI : Math.E;
|
|
294
|
+
} else if ([
|
|
295
|
+
"true",
|
|
296
|
+
"false",
|
|
297
|
+
"null",
|
|
298
|
+
"undefined",
|
|
299
|
+
"NaN",
|
|
300
|
+
"Infinity"
|
|
301
|
+
].includes(e)) r = () => ({
|
|
302
|
+
true: !0,
|
|
303
|
+
false: !1,
|
|
304
|
+
null: null,
|
|
305
|
+
undefined: void 0,
|
|
306
|
+
NaN: NaN,
|
|
307
|
+
Infinity: Infinity
|
|
308
|
+
})[e];
|
|
309
|
+
else if (/^[\p{L}_$]/u.test(e ?? "") && a("(")) {
|
|
310
|
+
let t = f(")");
|
|
311
|
+
r = (n) => m(e, t.map((e) => e(n)));
|
|
312
|
+
} else return i(`unexpected token ${e ?? "end"}`);
|
|
313
|
+
for (; t[n] === "." || t[n] === "[";) {
|
|
314
|
+
let e = r;
|
|
315
|
+
if (a("[")) {
|
|
316
|
+
let t = _(0);
|
|
317
|
+
d("]"), r = (n) => l(e(n), t(n));
|
|
318
|
+
} else {
|
|
319
|
+
d(".");
|
|
320
|
+
let o = t[n++];
|
|
321
|
+
if (a("(")) {
|
|
322
|
+
let t = f(")");
|
|
323
|
+
[
|
|
324
|
+
"test",
|
|
325
|
+
"exec",
|
|
326
|
+
"toString"
|
|
327
|
+
].includes(o) || i(`method ${o} is unavailable`), r = (n) => {
|
|
328
|
+
let r = e(n);
|
|
329
|
+
return o === "toString" ? s(r) : r instanceof RegExp ? (r.lastIndex = 0, o === "test" ? r.test(s(t[0]?.(n))) : r.exec(s(t[0]?.(n)))?.[1] ?? null) : i("test/exec needs a regular expression");
|
|
330
|
+
};
|
|
331
|
+
} else r = (t) => l(e(t), o);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return r;
|
|
335
|
+
}, g = {
|
|
336
|
+
"||": 1,
|
|
337
|
+
"&&": 2,
|
|
338
|
+
"===": 3,
|
|
339
|
+
"!==": 3,
|
|
340
|
+
"=~": 3,
|
|
341
|
+
"!~": 3,
|
|
342
|
+
"<": 4,
|
|
343
|
+
">": 4,
|
|
344
|
+
"<=": 4,
|
|
345
|
+
">=": 4,
|
|
346
|
+
"+": 5,
|
|
347
|
+
"-": 5,
|
|
348
|
+
"*": 6,
|
|
349
|
+
"/": 6,
|
|
350
|
+
"%": 6
|
|
351
|
+
}, _ = (e) => {
|
|
352
|
+
if (++r > 128) return i("expression nesting exceeds 128");
|
|
353
|
+
let s = p();
|
|
354
|
+
for (; Object.hasOwn(g, t[n]) && g[t[n]] >= e;) {
|
|
355
|
+
let e = t[n++], r = s, i = _(g[e] + 1);
|
|
356
|
+
s = (t) => e === "&&" ? o(r(t)) && o(i(t)) : e === "||" ? o(r(t)) || o(i(t)) : h(e, r(t), i(t));
|
|
357
|
+
}
|
|
358
|
+
if (e === 0 && a("?")) {
|
|
359
|
+
let e = s, t = _(0);
|
|
360
|
+
d(":");
|
|
361
|
+
let n = _(0);
|
|
362
|
+
s = (r) => o(e(r)) ? t(r) : n(r);
|
|
363
|
+
}
|
|
364
|
+
return r--, s;
|
|
365
|
+
}, v = _(0);
|
|
366
|
+
return n !== t.length && i(`unexpected token ${t[n]}`), v;
|
|
367
|
+
}
|
|
368
|
+
function _(e, n) {
|
|
369
|
+
if (e === void 0) return () => n;
|
|
370
|
+
if (typeof e == "string") return g(e);
|
|
371
|
+
if (typeof e != "object" || !e) return () => e;
|
|
372
|
+
let r = e.conditions.map(([e, t]) => [g(e), _(t, void 0)]);
|
|
373
|
+
return (e) => {
|
|
374
|
+
for (let [n, i] of r) {
|
|
375
|
+
let r = n(e);
|
|
376
|
+
if (typeof r != "boolean") throw new t("state", "Style condition must return a boolean; compare the property explicitly");
|
|
377
|
+
if (r) return i(e);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/style.ts
|
|
383
|
+
var v = _;
|
|
384
|
+
function y(e, t) {
|
|
385
|
+
let n = e.featureTable, r = n?.json?.POSITION === void 0 && n?.json?.POSITION_QUANTIZED !== void 0 ? n.global("QUANTIZED_VOLUME_OFFSET", "FLOAT", 3) : void 0, i = r ?? e.rtcCenter ?? [
|
|
386
|
+
0,
|
|
387
|
+
0,
|
|
388
|
+
0
|
|
389
|
+
], a = t?.length === 16 ? t : [
|
|
390
|
+
1,
|
|
391
|
+
0,
|
|
392
|
+
0,
|
|
393
|
+
0,
|
|
394
|
+
0,
|
|
395
|
+
1,
|
|
396
|
+
0,
|
|
397
|
+
0,
|
|
398
|
+
0,
|
|
399
|
+
0,
|
|
400
|
+
1,
|
|
401
|
+
0,
|
|
402
|
+
0,
|
|
403
|
+
0,
|
|
404
|
+
0,
|
|
405
|
+
1
|
|
406
|
+
];
|
|
407
|
+
return (t, n) => {
|
|
408
|
+
let o = e.positions;
|
|
409
|
+
if (t === "POSITION") return [
|
|
410
|
+
0,
|
|
411
|
+
1,
|
|
412
|
+
2
|
|
413
|
+
].map((e) => o[n * 3 + e] - (r ? r[e] : 0));
|
|
414
|
+
if (t === "POSITION_ABSOLUTE") {
|
|
415
|
+
let [e, t, s] = [
|
|
416
|
+
0,
|
|
417
|
+
1,
|
|
418
|
+
2
|
|
419
|
+
].map((e) => o[n * 3 + e] + (r ? 0 : i[e]));
|
|
420
|
+
return [
|
|
421
|
+
0,
|
|
422
|
+
1,
|
|
423
|
+
2
|
|
424
|
+
].map((n) => a[n] * e + a[4 + n] * t + a[8 + n] * s + a[12 + n]);
|
|
425
|
+
}
|
|
426
|
+
if (t === "COLOR") return e.colors ? Array.from(e.colors.subarray(n * 4, n * 4 + 4), (e) => e / 255) : e.constantColor ? e.constantColor.map((e) => e / 255) : [
|
|
427
|
+
1,
|
|
428
|
+
1,
|
|
429
|
+
1,
|
|
430
|
+
1
|
|
431
|
+
];
|
|
432
|
+
if (t === "NORMAL") return e.normals ? Array.from(e.normals.subarray(n * 3, n * 3 + 3)) : void 0;
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
var b = (e) => Math.max(0, Math.min(1, e)), x = (e) => e.map((e, t) => t < 3 ? n(b(e)) : b(e));
|
|
436
|
+
function S(e, n, r) {
|
|
437
|
+
let i = !1, a = {
|
|
438
|
+
update(n) {
|
|
439
|
+
if (i) throw new t("disposed", "Style binding is disposed; create a new binding");
|
|
440
|
+
e(n);
|
|
441
|
+
},
|
|
442
|
+
dispose() {
|
|
443
|
+
i ||= (n(), !0);
|
|
444
|
+
},
|
|
445
|
+
[Symbol.dispose]() {
|
|
446
|
+
this.dispose();
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
return a.update(r), a;
|
|
450
|
+
}
|
|
451
|
+
var C = class {
|
|
452
|
+
constructor(n = {}) {
|
|
453
|
+
this.decorate = (n) => {
|
|
454
|
+
let r = [], i = 0, a = n.content;
|
|
455
|
+
if (n.kind === "points") {
|
|
456
|
+
let e = n.cloud, t = n.content, a = y(t, n.tile?.transform);
|
|
457
|
+
r.push(this.bindPoints(e, (n) => {
|
|
458
|
+
let r = e.sourceIndex?.[n] ?? n, i = t.batchIds?.[r] ?? r;
|
|
459
|
+
return (e) => a(e, r) ?? t.batchTable?.get(i, e);
|
|
460
|
+
})), i = e.count * (4 + (t.colors ? 0 : 4));
|
|
461
|
+
} else if (n.kind === "instances") {
|
|
462
|
+
let e = n.model, t = n.content, i = t.featureTable.property("BATCH_ID", t.length, 1, t.featureTable.json.BATCH_ID?.componentType ?? "UNSIGNED_SHORT");
|
|
463
|
+
for (let n of new Set(e.primitives.map((e) => e.instances).filter((e) => e !== void 0))) r.push(this.bindInstances(n, (e) => (n) => t.batchTable?.get(i?.[e] ?? e, n)));
|
|
464
|
+
let a = e.primitives.map((e) => ({
|
|
465
|
+
material: e.material,
|
|
466
|
+
extension: e.extension
|
|
467
|
+
}));
|
|
468
|
+
e.primitives.forEach((e) => {
|
|
469
|
+
e.material = {
|
|
470
|
+
...e.material,
|
|
471
|
+
settings: [2, ...e.material.settings.slice(1)]
|
|
472
|
+
}, e.extension = {
|
|
473
|
+
...e.extension,
|
|
474
|
+
wgsl: (e.extension?.wgsl ?? "") + "\nif(i.color.a <= 0.0){discard;}"
|
|
475
|
+
};
|
|
476
|
+
}), r.push({
|
|
477
|
+
update() {},
|
|
478
|
+
dispose() {
|
|
479
|
+
e.primitives.forEach((e, t) => Object.assign(e, a[t]));
|
|
480
|
+
},
|
|
481
|
+
[Symbol.dispose]() {
|
|
482
|
+
this.dispose();
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
} else {
|
|
486
|
+
let i = n.model;
|
|
487
|
+
if (!i.asset || !Array.isArray(i.primitives)) throw new t("unsupported", "Tile styling needs PBRModel primitives and asset; return a gltf/pbr model from loadModel");
|
|
488
|
+
let o = e(n.content.gltf, { buffer: (e) => i.asset.buffers[e] }), s = /* @__PURE__ */ new Map();
|
|
489
|
+
for (let e of i.primitives) {
|
|
490
|
+
let t = i.asset.doc.meshes?.findIndex((t) => t.primitives.includes(e.definition)) ?? -1, n = i.asset.doc.meshes?.[t]?.primitives.indexOf(e.definition) ?? -1, r = e.definition.attributes?._BATCHID ?? e.definition.attributes?._BATCH_ID, c = r === void 0 ? void 0 : i.asset.accessor(r, "SCALAR");
|
|
491
|
+
s.set(e, (e) => c ? (t) => a.batchTable?.get(c[e], t) : o.feature(t, n, e)?.properties ?? a.batchTable?.feature(0) ?? {});
|
|
492
|
+
}
|
|
493
|
+
r.push(this.bindModel(i, (e, t) => s.get(e)(t)));
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
bytes: i,
|
|
497
|
+
dispose: () => {
|
|
498
|
+
for (let e of r) e.dispose();
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
}, this.color = v(n.color, [
|
|
502
|
+
1,
|
|
503
|
+
1,
|
|
504
|
+
1,
|
|
505
|
+
1
|
|
506
|
+
]), this.show = v(n.show, !0), this.pointSize = v(n.pointSize, 1), this.defines = new Map(Object.entries(n.defines ?? {}).map(([e, t]) => [e, g(t)])), this.meta = new Map(Object.entries(n.meta ?? {}).map(([e, t]) => [e, v(t, void 0)]));
|
|
507
|
+
}
|
|
508
|
+
evaluate(e = {}) {
|
|
509
|
+
let n = typeof e == "function" ? e : (t) => Object.hasOwn(e, t) ? e[t] : void 0, r = (e) => this.defines.has(e) ? this.defines.get(e)(n) : n(e), i = this.color(r), a = this.show(r), o = this.pointSize(r);
|
|
510
|
+
if (i !== void 0 && (!Array.isArray(i) || i.length !== 4 || i.some((e) => typeof e != "number" || !Number.isFinite(e)))) throw new t("state", "Style color must return four finite components; use color(), rgb() or vec4()");
|
|
511
|
+
if (a !== void 0 && typeof a != "boolean") throw new t("state", "Style show must return a boolean; compare the property explicitly");
|
|
512
|
+
if (o !== void 0 && (typeof o != "number" || !Number.isFinite(o) || o < 0)) throw new t("state", "Style pointSize must return a finite non-negative number; clamp its expression");
|
|
513
|
+
return {
|
|
514
|
+
color: i === void 0 ? void 0 : Array.from(i),
|
|
515
|
+
show: a,
|
|
516
|
+
pointSize: o,
|
|
517
|
+
meta: Object.fromEntries([...this.meta].map(([e, t]) => [e, t(r)]))
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
bindModel(e, t) {
|
|
521
|
+
let n = e.primitives.map((e) => ({
|
|
522
|
+
vertices: e.vertices.slice(),
|
|
523
|
+
indices: e.indices,
|
|
524
|
+
uvs: e.uvs,
|
|
525
|
+
material: e.material,
|
|
526
|
+
extension: e.extension
|
|
527
|
+
}));
|
|
528
|
+
return S((r) => {
|
|
529
|
+
let i = e.primitives.map((e, i) => {
|
|
530
|
+
let a = n[i], o = a.vertices.slice(), s = !1;
|
|
531
|
+
for (let n = 0; n < o.length / 20; n++) {
|
|
532
|
+
let i = r.evaluate(t(e, n)), a = x(i.color ?? [
|
|
533
|
+
1,
|
|
534
|
+
1,
|
|
535
|
+
1,
|
|
536
|
+
1
|
|
537
|
+
]);
|
|
538
|
+
i.show === !1 && (a[3] = 0), a[3] < 1 && (s = !0);
|
|
539
|
+
for (let e = 0; e < 4; e++) o[n * 20 + 16 + e] *= a[e];
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
...a,
|
|
543
|
+
vertices: o,
|
|
544
|
+
alpha: s
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
e.writeGeometry(i), e.primitives.forEach((e, t) => {
|
|
548
|
+
let r = n[t];
|
|
549
|
+
e.material = {
|
|
550
|
+
...r.material,
|
|
551
|
+
settings: r.material.settings.slice()
|
|
552
|
+
}, i[t].alpha && (e.material.settings[0] = 2), e.extension = {
|
|
553
|
+
...r.extension,
|
|
554
|
+
wgsl: (r.extension?.wgsl ?? "") + "\nif(i.color.a <= 0.0){discard;}"
|
|
555
|
+
};
|
|
556
|
+
});
|
|
557
|
+
}, () => {
|
|
558
|
+
e.primitives.forEach((e, t) => {
|
|
559
|
+
e.material = n[t].material, e.extension = n[t].extension;
|
|
560
|
+
}), e.writeGeometry(n);
|
|
561
|
+
}, this);
|
|
562
|
+
}
|
|
563
|
+
bindPoints(e, t) {
|
|
564
|
+
let r = e.colors?.slice() ?? null, i = e.sizes?.slice() ?? null, a = e.floatColors?.slice() ?? null, o = e.colorComponents, s = {
|
|
565
|
+
size: e.material.size,
|
|
566
|
+
minPixelSize: e.material.minPixelSize,
|
|
567
|
+
maxPixelSize: e.material.maxPixelSize,
|
|
568
|
+
sizeUnits: e.material.sizeUnits,
|
|
569
|
+
vertexColors: e.material.vertexColors,
|
|
570
|
+
transparent: e.material.transparent,
|
|
571
|
+
alphaTest: e.material.alphaTest
|
|
572
|
+
};
|
|
573
|
+
return S((r) => {
|
|
574
|
+
let a = new Float32Array(e.count * 4), o = new Float32Array(e.count);
|
|
575
|
+
for (let n = 0; n < e.count; n++) {
|
|
576
|
+
let e = r.evaluate(t(n)), c = e.color ?? [
|
|
577
|
+
1,
|
|
578
|
+
1,
|
|
579
|
+
1,
|
|
580
|
+
1
|
|
581
|
+
];
|
|
582
|
+
for (let e = 0; e < 4; e++) a[n * 4 + e] = c[e];
|
|
583
|
+
e.show === !1 && (a[n * 4 + 3] = 0), o[n] = e.show === !1 ? 0 : e.pointSize ?? s.size * (i?.[n] ?? 1);
|
|
584
|
+
}
|
|
585
|
+
e.setColors(e.colorFormat === "float" ? Float32Array.from(a, (t, r) => r % 4 < 3 && e.colorSpace === "linear" ? n(b(t)) : b(t)) : Uint8Array.from(a, (e) => Math.round(b(e) * 255)), 4), e.setSizes(o), e.material.size = 1, e.material.sizeUnits = "pixels", e.material.minPixelSize = 0, e.material.maxPixelSize = o.reduce((e, t) => Math.max(e, t), 1), e.material.vertexColors = !0, e.material.transparent = !0, e.material.alphaTest = Math.max(2 ** -126, s.alphaTest);
|
|
586
|
+
}, () => {
|
|
587
|
+
e.setColors(a ?? (r && new Uint8Array(r.buffer)), 4), e.colorComponents = o, e.setSizes(i), Object.assign(e.material, s);
|
|
588
|
+
}, this);
|
|
589
|
+
}
|
|
590
|
+
bindInstances(e, t) {
|
|
591
|
+
let n = e.data.slice();
|
|
592
|
+
return S((r) => {
|
|
593
|
+
Array.from({ length: e.count }, (e, n) => r.evaluate(t(n))).forEach((t, r) => {
|
|
594
|
+
let i = n.slice(r * 24, r * 24 + 16), a = x(t.color ?? [
|
|
595
|
+
1,
|
|
596
|
+
1,
|
|
597
|
+
1,
|
|
598
|
+
1
|
|
599
|
+
]);
|
|
600
|
+
if (t.show === !1) for (let e = 0; e < 12; e++) i[e] = 0;
|
|
601
|
+
e.setMatrixAt(r, i), e.setColorAt(r, a.map((e, t) => e * n[r * 24 + 16 + t]));
|
|
602
|
+
});
|
|
603
|
+
}, () => {
|
|
604
|
+
for (let t = 0; t < e.count; t++) e.setMatrixAt(t, n.subarray(t * 24, t * 24 + 16)), e.setColorAt(t, n.subarray(t * 24 + 16, t * 24 + 20));
|
|
605
|
+
}, this);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
//#endregion
|
|
609
|
+
export { C as TilesStyle };
|