@equinor/videx-3d 1.1.1 → 2.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/README.md +120 -120
- package/dist/chunk-61X6qE5N.js +981 -0
- package/dist/chunk-ChG5d4HC.js +675 -0
- package/dist/{chunk-BlPg4RjP.js → chunk-M-Pcc_Yg.js} +19 -19
- package/dist/generators.js +271 -260
- package/dist/main.js +4919 -3344
- package/dist/sdk.js +92 -90
- package/dist/shaderLib/oit.glsl +106 -0
- package/dist/types/components/Annotations/AutoUpdate.d.ts +1 -1
- package/dist/types/components/Annotations/index.d.ts +2 -2
- package/dist/types/components/Annotations/types.d.ts +3 -1
- package/dist/types/components/Annotations/update-annotations.d.ts +10 -0
- package/dist/types/components/EventEmitter/picking-helper.d.ts +23 -1
- package/dist/types/components/Surfaces/Surface.d.ts +8 -1
- package/dist/types/components/Surfaces/SurfaceMaterial.d.ts +3 -0
- package/dist/types/components/Surfaces/surface-defs.d.ts +1 -0
- package/dist/types/generators/surface-generator.d.ts +1 -1
- package/dist/types/layers/layers.d.ts +4 -0
- package/dist/types/rendering/OitMaterial.d.ts +59 -0
- package/dist/types/rendering/Pass.d.ts +7 -0
- package/dist/types/rendering/RenderingPipeline.d.ts +37 -0
- package/dist/types/rendering/fullscreen-renderer.d.ts +1 -0
- package/dist/types/rendering/gpu-timer.d.ts +46 -0
- package/dist/types/rendering/index.d.ts +7 -1
- package/dist/types/rendering/oit-material.d.ts +122 -0
- package/dist/types/{components/Annotations/annotations-renderer.d.ts → rendering/passes/AnnotationsPass.d.ts} +13 -4
- package/dist/types/rendering/passes/FXAAPass.d.ts +12 -0
- package/dist/types/rendering/passes/OITRenderPass.d.ts +282 -0
- package/dist/types/rendering/passes/OutputPass.d.ts +10 -0
- package/dist/types/rendering/passes/RenderPass.d.ts +8 -0
- package/dist/types/rendering/passes/SMAAPass.d.ts +40 -0
- package/dist/types/rendering/passes/TAAPass.d.ts +94 -0
- package/dist/types/rendering/passes/index.d.ts +6 -0
- package/dist/types/rendering/rendering-state.d.ts +59 -0
- package/dist/types/sdk/utils/elevation-map.d.ts +23 -0
- package/dist/types/sdk/utils/trigonometry.d.ts +4 -1
- package/package.json +1 -1
- package/dist/chunk-CnY6Tmof.js +0 -358
- package/dist/chunk-iY0wQ9Z6.js +0 -887
- package/dist/types/rendering/render-passes.d.ts +0 -16
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
import R from "proj4";
|
|
2
|
+
import { UniformsGroup as I, Uniform as p, Vector4 as k, Vector3 as H, Vector2 as P, DataTexture as B, RedIntegerFormat as G, UnsignedShortType as N, Material as L, ShaderMaterial as y, CustomBlending as W, NoBlending as Z, AddEquation as _, SrcAlphaFactor as Q, OneMinusSrcAlphaFactor as w, OneFactor as S, MinEquation as O, UniformsUtils as q, ShaderLib as $ } from "three";
|
|
3
|
+
function cn(n, e, t) {
|
|
4
|
+
const o = /* @__PURE__ */ new Map(), r = {};
|
|
5
|
+
e.sort((i, c) => i.id === t ? -1 : c.id === t ? 1 : i.drilled && c.drilled ? c.drilled.getTime() - i.drilled.getTime() : i.name.localeCompare(c.name));
|
|
6
|
+
for (let i = 0; i < e.length; i++) {
|
|
7
|
+
const c = e[i];
|
|
8
|
+
if (!c) continue;
|
|
9
|
+
let l = c.parent && c.kickoffDepthMsl !== null ? c.kickoffDepthMsl : -c.depthReferenceElevation;
|
|
10
|
+
if (o.has(c.id))
|
|
11
|
+
l = o.get(c.id);
|
|
12
|
+
else {
|
|
13
|
+
let g = c.parent;
|
|
14
|
+
for (; g; ) {
|
|
15
|
+
const u = n[g];
|
|
16
|
+
if (!u) break;
|
|
17
|
+
if (o.has(u.id)) {
|
|
18
|
+
const s = o.get(u.id);
|
|
19
|
+
l >= s && (o.set(u.id, l), l = s);
|
|
20
|
+
break;
|
|
21
|
+
} else
|
|
22
|
+
o.set(u.id, l), l = u.parent && u.kickoffDepthMsl !== null ? u.kickoffDepthMsl : -u.depthReferenceElevation;
|
|
23
|
+
g = u.parent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
r[c.id] = [l, i], o.set(c.id, c.depthMdMsl);
|
|
27
|
+
}
|
|
28
|
+
return r;
|
|
29
|
+
}
|
|
30
|
+
const j = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
|
|
31
|
+
class ln {
|
|
32
|
+
utmDef;
|
|
33
|
+
originWgs84;
|
|
34
|
+
originUtm;
|
|
35
|
+
_projection;
|
|
36
|
+
constructor(e, t, o = "lnglat") {
|
|
37
|
+
this.utmDef = e, this._projection = R(j, e), o === "lnglat" ? (this.originWgs84 = t, this.originUtm = this.wgs84ToUtm(t)) : (this.originWgs84 = this.utmToWgs84(t), this.originUtm = t);
|
|
38
|
+
}
|
|
39
|
+
utmToWgs84(e) {
|
|
40
|
+
return this._projection.inverse(e);
|
|
41
|
+
}
|
|
42
|
+
wgs84ToUtm(e) {
|
|
43
|
+
return this._projection.forward(e);
|
|
44
|
+
}
|
|
45
|
+
utmToWorld(e, t, o) {
|
|
46
|
+
return {
|
|
47
|
+
x: e - this.originUtm[0],
|
|
48
|
+
y: o,
|
|
49
|
+
z: this.originUtm[1] - t
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
worldToUtm(e, t, o) {
|
|
53
|
+
return {
|
|
54
|
+
easting: e + this.originUtm[0],
|
|
55
|
+
altitude: t,
|
|
56
|
+
northing: this.originUtm[1] - o
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
wgs84ToWorld(e, t, o = 0) {
|
|
60
|
+
const r = this.wgs84ToUtm([e, t]);
|
|
61
|
+
return this.utmToWorld(r[0], r[1], o);
|
|
62
|
+
}
|
|
63
|
+
worldToWgs84(e, t, o) {
|
|
64
|
+
const r = this.worldToUtm(e, t, o), i = this.utmToWgs84([r.easting, r.northing]);
|
|
65
|
+
return {
|
|
66
|
+
lng: i[0],
|
|
67
|
+
lat: i[1],
|
|
68
|
+
alt: t
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function fn(n) {
|
|
73
|
+
const [, e, t] = new RegExp(/^([0-9]{2})([N|S]?)$/).exec(n) || [];
|
|
74
|
+
return `+proj=utm +zone=${e}${t === "S" ? " +south" : ""} +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs`;
|
|
75
|
+
}
|
|
76
|
+
function un([n, e]) {
|
|
77
|
+
if (e > 55 && e < 64 && n > 2 && n < 6)
|
|
78
|
+
return "32N";
|
|
79
|
+
if (e > 71 && n >= 6 && n < 9)
|
|
80
|
+
return "31N";
|
|
81
|
+
if (e > 71 && (n >= 9 && n < 12 || n >= 18 && n < 21))
|
|
82
|
+
return "33N";
|
|
83
|
+
if (e > 71 && (n >= 21 && n < 24 || n >= 30 && n < 33))
|
|
84
|
+
return "35N";
|
|
85
|
+
if (n >= -180 && n <= 180) {
|
|
86
|
+
const t = Math.floor((n + 180) / 6) % 60 + 1;
|
|
87
|
+
return e < 0 ? `${t}S` : `${t}N`;
|
|
88
|
+
}
|
|
89
|
+
throw new Error(
|
|
90
|
+
`getUtmZoneFromLatLng: Cannot figure out UTM zone from give Lat: ${e}, Lng: ${n}`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function an(n) {
|
|
94
|
+
const e = new Map(
|
|
95
|
+
n.chars.map((s, f) => [s.id, { index: f, spacing: s.xadvance }])
|
|
96
|
+
), t = 32, o = (s) => {
|
|
97
|
+
const f = [];
|
|
98
|
+
let a = 0;
|
|
99
|
+
for (let m = 0; m < s.length; m++) {
|
|
100
|
+
let h = s.charCodeAt(m);
|
|
101
|
+
e.has(h) || (h = t);
|
|
102
|
+
const d = e.get(h);
|
|
103
|
+
d && (f.push(d.index), a += d.spacing);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
indices: f,
|
|
107
|
+
width: a
|
|
108
|
+
};
|
|
109
|
+
}, r = (s) => {
|
|
110
|
+
s = Array.isArray(s) ? s : [s];
|
|
111
|
+
const f = [], a = [];
|
|
112
|
+
for (let d = 0; d < s.length; d++) {
|
|
113
|
+
const V = s[d], x = o(V), z = a.length;
|
|
114
|
+
a.push(...x.indices), f.push([z, a.length, x.width]);
|
|
115
|
+
}
|
|
116
|
+
a.length || a.push(0);
|
|
117
|
+
const m = a.length;
|
|
118
|
+
f.forEach((d) => a.push(...d));
|
|
119
|
+
const h = new B(
|
|
120
|
+
new Uint16Array(a),
|
|
121
|
+
a.length,
|
|
122
|
+
1,
|
|
123
|
+
G,
|
|
124
|
+
N
|
|
125
|
+
);
|
|
126
|
+
return h.needsUpdate = !0, { texture: h, textPointersOffset: m, textPointersCount: f.length };
|
|
127
|
+
}, i = new I();
|
|
128
|
+
i.setName("GlyphData");
|
|
129
|
+
const c = [], l = [];
|
|
130
|
+
n.chars.forEach((s) => {
|
|
131
|
+
c.push(
|
|
132
|
+
new p(new k(s.x, s.y, s.width, s.height))
|
|
133
|
+
), l.push(
|
|
134
|
+
new p(new H(s.xoffset, s.yoffset, s.xadvance))
|
|
135
|
+
);
|
|
136
|
+
}), i.add(c), i.add(l), i.add(
|
|
137
|
+
new p(new P(n.common.scaleW, n.common.scaleH))
|
|
138
|
+
), i.add(new p(n.info.size)), i.add(new p(n.distanceField.distanceRange)), i.add(new p(n.common.lineHeight)), i.add(new p(n.common.base));
|
|
139
|
+
const g = () => {
|
|
140
|
+
i.dispose();
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
glyphsCount: n.chars.length,
|
|
144
|
+
glyphData: i,
|
|
145
|
+
encodeText: o,
|
|
146
|
+
encodeTextTexture: r,
|
|
147
|
+
dispose: g
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function dn(n, e, t) {
|
|
151
|
+
if (n.length === 0) return [];
|
|
152
|
+
n.sort((i, c) => e(i) - e(c));
|
|
153
|
+
const o = [];
|
|
154
|
+
let r = { start: e(n[0]), end: t(n[0]) };
|
|
155
|
+
for (let i = 1; i < n.length; i += 1)
|
|
156
|
+
e(n[i]) === r.end ? r.end = t(n[i]) : (o.push(r), r = { start: e(n[i]), end: t(n[i]) });
|
|
157
|
+
return o.push(r), o;
|
|
158
|
+
}
|
|
159
|
+
var J = `#ifdef USE_OIT
|
|
160
|
+
|
|
161
|
+
uniform float oitDepthFar;
|
|
162
|
+
uniform vec2 oitScreenSize;
|
|
163
|
+
uniform sampler2D oitMinDepthTexture;
|
|
164
|
+
uniform int oitSkipFront;
|
|
165
|
+
uniform float oitOcclusionThreshold;
|
|
166
|
+
|
|
167
|
+
vec4 oitProcess(vec4 color) {
|
|
168
|
+
#ifdef OIT_OCCLUSION_PASS
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
if(color.a < oitOcclusionThreshold)
|
|
175
|
+
discard;
|
|
176
|
+
return color;
|
|
177
|
+
#endif
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
float linZ = abs(vViewPosition.z) / oitDepthFar;
|
|
182
|
+
|
|
183
|
+
#ifdef OIT_DEPTH_PASS
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
return vec4(linZ, 0.0, 0.0, 1.0);
|
|
187
|
+
|
|
188
|
+
#else
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
vec2 uv = gl_FragCoord.xy / oitScreenSize;
|
|
194
|
+
float minZ = texture2D(oitMinDepthTexture, uv).r;
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
float tol = minZ * 1e-3 + 1e-6;
|
|
202
|
+
bool isFront = (linZ - minZ) <= tol;
|
|
203
|
+
|
|
204
|
+
#ifdef OIT_FRONT_PASS
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if(!isFront)
|
|
208
|
+
discard;
|
|
209
|
+
return color;
|
|
210
|
+
|
|
211
|
+
#else
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if(isFront && oitSkipFront == 0)
|
|
216
|
+
discard;
|
|
217
|
+
|
|
218
|
+
float alpha = color.a;
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
float b = -log(1.0 - clamp(alpha, 0.0, 0.9999));
|
|
226
|
+
return vec4(color.rgb * b, b);
|
|
227
|
+
|
|
228
|
+
#endif
|
|
229
|
+
#endif
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
#endif`;
|
|
233
|
+
const pn = [
|
|
234
|
+
"color",
|
|
235
|
+
"emissive",
|
|
236
|
+
"emissiveIntensity",
|
|
237
|
+
"metalness",
|
|
238
|
+
"roughness"
|
|
239
|
+
];
|
|
240
|
+
function hn(n) {
|
|
241
|
+
return !!n && typeof n.getOitVariants == "function" && typeof n.getOitUniforms == "function";
|
|
242
|
+
}
|
|
243
|
+
function b(n) {
|
|
244
|
+
return n.isShaderMaterial === !0;
|
|
245
|
+
}
|
|
246
|
+
function D(n) {
|
|
247
|
+
return typeof n == "object" && n !== null && typeof n.copy == "function";
|
|
248
|
+
}
|
|
249
|
+
function M() {
|
|
250
|
+
return {
|
|
251
|
+
oitDepthFar: new p(1),
|
|
252
|
+
oitScreenSize: new p(new P(1, 1)),
|
|
253
|
+
oitMinDepthTexture: new p(null),
|
|
254
|
+
oitSkipFront: new p(0),
|
|
255
|
+
oitOcclusionThreshold: new p(1)
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const Y = {
|
|
259
|
+
depthMin: "OIT_DEPTH_PASS",
|
|
260
|
+
accum: null,
|
|
261
|
+
front: "OIT_FRONT_PASS",
|
|
262
|
+
occlusion: "OIT_OCCLUSION_PASS"
|
|
263
|
+
};
|
|
264
|
+
function K(n, e, t) {
|
|
265
|
+
switch (n.transparent = !0, n.depthTest = !0, n.depthWrite = !1, n.blending = W, n.toneMapped = !1, t !== void 0 && (n.side = t), e) {
|
|
266
|
+
case "depthMin":
|
|
267
|
+
n.blendEquation = O, n.blendSrc = S, n.blendDst = S, n.blendEquationAlpha = O, n.blendSrcAlpha = S, n.blendDstAlpha = S;
|
|
268
|
+
break;
|
|
269
|
+
case "accum":
|
|
270
|
+
n.blendEquation = _, n.blendSrc = S, n.blendDst = S, n.blendEquationAlpha = _, n.blendSrcAlpha = S, n.blendDstAlpha = S;
|
|
271
|
+
break;
|
|
272
|
+
case "front":
|
|
273
|
+
n.blendEquation = _, n.blendSrc = Q, n.blendDst = w, n.blendEquationAlpha = _, n.blendSrcAlpha = S, n.blendDstAlpha = w;
|
|
274
|
+
break;
|
|
275
|
+
case "occlusion":
|
|
276
|
+
n.transparent = !1, n.depthWrite = !0, n.colorWrite = !1, n.blending = Z;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function C(n) {
|
|
281
|
+
const e = n;
|
|
282
|
+
return [
|
|
283
|
+
JSON.stringify(e.defines ?? {}),
|
|
284
|
+
e.wireframe ? 1 : 0,
|
|
285
|
+
e.flatShading ? 1 : 0,
|
|
286
|
+
e.uniformsGroups ? e.uniformsGroups.length : 0,
|
|
287
|
+
n.vertexColors ? 1 : 0
|
|
288
|
+
].join("|");
|
|
289
|
+
}
|
|
290
|
+
function A(n, e, t) {
|
|
291
|
+
const o = e, r = n, i = {
|
|
292
|
+
...o.defines ?? {},
|
|
293
|
+
USE_OIT: ""
|
|
294
|
+
}, c = Y[t];
|
|
295
|
+
c && (i[c] = ""), r.defines = i, "wireframe" in o && (r.wireframe = o.wireframe), "flatShading" in o && (r.flatShading = o.flatShading), o.uniformsGroups && (r.uniformsGroups = o.uniformsGroups), n.vertexColors = e.vertexColors, n.needsUpdate = !0;
|
|
296
|
+
}
|
|
297
|
+
function v(n, e, t) {
|
|
298
|
+
let o;
|
|
299
|
+
if (b(n)) {
|
|
300
|
+
const r = new y();
|
|
301
|
+
r.copy(n), r.uniforms = n.uniforms, o = r;
|
|
302
|
+
} else
|
|
303
|
+
o = n.clone();
|
|
304
|
+
if (t?.shareUniforms) {
|
|
305
|
+
const r = n, i = o;
|
|
306
|
+
for (const c of t.shareUniforms)
|
|
307
|
+
i[c] = r[c];
|
|
308
|
+
}
|
|
309
|
+
return o.onBeforeCompile = n.onBeforeCompile, o.customProgramCacheKey = n.customProgramCacheKey, K(o, e, t?.side), A(o, n, e), o;
|
|
310
|
+
}
|
|
311
|
+
const T = ["depthMin", "accum", "front", "occlusion"];
|
|
312
|
+
function U(n, e, t) {
|
|
313
|
+
const o = n;
|
|
314
|
+
let r = null, i = "";
|
|
315
|
+
const c = !b(n), l = n, g = c && t?.syncProperties ? t.syncProperties.filter((s) => s !== "opacity" && s in l) : [];
|
|
316
|
+
o.getOitUniforms = () => e, o.getOitVariants = () => {
|
|
317
|
+
if (!r)
|
|
318
|
+
r = {
|
|
319
|
+
depthMin: v(n, "depthMin", t),
|
|
320
|
+
accum: v(n, "accum", t),
|
|
321
|
+
front: v(n, "front", t),
|
|
322
|
+
occlusion: v(n, "occlusion", t)
|
|
323
|
+
}, i = C(n);
|
|
324
|
+
else {
|
|
325
|
+
const s = C(n);
|
|
326
|
+
if (s !== i) {
|
|
327
|
+
i = s;
|
|
328
|
+
for (const f of T)
|
|
329
|
+
A(r[f], n, f);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (c)
|
|
333
|
+
for (const s of T) {
|
|
334
|
+
const f = r[s];
|
|
335
|
+
if (f.opacity = n.opacity, g.length) {
|
|
336
|
+
const a = f;
|
|
337
|
+
for (const m of g) {
|
|
338
|
+
const h = l[m], d = a[m];
|
|
339
|
+
D(d) && D(h) && d.constructor === h.constructor ? d.copy(h) : a[m] = h;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return r;
|
|
344
|
+
};
|
|
345
|
+
const u = n.dispose.bind(n);
|
|
346
|
+
return n.dispose = () => {
|
|
347
|
+
if (r) {
|
|
348
|
+
for (const s of T)
|
|
349
|
+
L.prototype.dispose.call(r[s]);
|
|
350
|
+
r = null;
|
|
351
|
+
}
|
|
352
|
+
u();
|
|
353
|
+
}, o;
|
|
354
|
+
}
|
|
355
|
+
function X(n, e) {
|
|
356
|
+
const t = M(), o = n.uniforms;
|
|
357
|
+
o.oitDepthFar ??= t.oitDepthFar, o.oitScreenSize ??= t.oitScreenSize, o.oitMinDepthTexture ??= t.oitMinDepthTexture, o.oitSkipFront ??= t.oitSkipFront, o.oitOcclusionThreshold ??= t.oitOcclusionThreshold;
|
|
358
|
+
const r = {
|
|
359
|
+
oitDepthFar: o.oitDepthFar,
|
|
360
|
+
oitScreenSize: o.oitScreenSize,
|
|
361
|
+
oitMinDepthTexture: o.oitMinDepthTexture,
|
|
362
|
+
oitSkipFront: o.oitSkipFront,
|
|
363
|
+
oitOcclusionThreshold: o.oitOcclusionThreshold
|
|
364
|
+
};
|
|
365
|
+
return U(n, r, e);
|
|
366
|
+
}
|
|
367
|
+
const E = /\bvoid\s+main\s*\(\s*\)\s*\{/;
|
|
368
|
+
function nn(n) {
|
|
369
|
+
return /\bvViewPosition\b/.test(n);
|
|
370
|
+
}
|
|
371
|
+
function en(n) {
|
|
372
|
+
const e = E.exec(n);
|
|
373
|
+
if (!e) return null;
|
|
374
|
+
const t = e.index + e[0].length;
|
|
375
|
+
let o = 1;
|
|
376
|
+
for (let r = t; r < n.length; r++) {
|
|
377
|
+
const i = n[r];
|
|
378
|
+
if (i === "{") o++;
|
|
379
|
+
else if (i === "}" && (o--, o === 0))
|
|
380
|
+
return { open: t, close: r };
|
|
381
|
+
}
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
function F(n, e, t) {
|
|
385
|
+
const o = E.exec(n);
|
|
386
|
+
if (!o) return n;
|
|
387
|
+
const r = n.slice(0, o.index) + e + n.slice(o.index), i = en(r);
|
|
388
|
+
return i ? r.slice(0, i.close) + t + r.slice(i.close) : r;
|
|
389
|
+
}
|
|
390
|
+
function gn(n, e) {
|
|
391
|
+
const t = M(), o = b(n) ? n : null;
|
|
392
|
+
if (o) {
|
|
393
|
+
const i = o.uniforms;
|
|
394
|
+
i.oitDepthFar ??= t.oitDepthFar, i.oitScreenSize ??= t.oitScreenSize, i.oitMinDepthTexture ??= t.oitMinDepthTexture, i.oitSkipFront ??= t.oitSkipFront, i.oitOcclusionThreshold ??= t.oitOcclusionThreshold;
|
|
395
|
+
}
|
|
396
|
+
const r = n.onBeforeCompile;
|
|
397
|
+
return n.onBeforeCompile = function(i, c) {
|
|
398
|
+
r?.call(this, i, c), i.uniforms.oitDepthFar = t.oitDepthFar, i.uniforms.oitScreenSize = t.oitScreenSize, i.uniforms.oitMinDepthTexture = t.oitMinDepthTexture, i.uniforms.oitSkipFront = t.oitSkipFront, i.uniforms.oitOcclusionThreshold = t.oitOcclusionThreshold;
|
|
399
|
+
const l = !nn(i.fragmentShader), g = (l ? `#ifdef USE_OIT
|
|
400
|
+
varying vec3 vViewPosition;
|
|
401
|
+
#endif
|
|
402
|
+
` : "") + `#ifdef USE_OIT
|
|
403
|
+
` + J + `
|
|
404
|
+
#endif
|
|
405
|
+
`, u = `
|
|
406
|
+
#ifdef USE_OIT
|
|
407
|
+
gl_FragColor = oitProcess(gl_FragColor);
|
|
408
|
+
#endif
|
|
409
|
+
`;
|
|
410
|
+
if (i.fragmentShader = F(
|
|
411
|
+
i.fragmentShader,
|
|
412
|
+
g,
|
|
413
|
+
u
|
|
414
|
+
), l) {
|
|
415
|
+
const s = `#ifdef USE_OIT
|
|
416
|
+
varying vec3 vViewPosition;
|
|
417
|
+
#endif
|
|
418
|
+
`, f = `
|
|
419
|
+
#ifdef USE_OIT
|
|
420
|
+
vViewPosition = -(modelViewMatrix * vec4(position, 1.0)).xyz;
|
|
421
|
+
#endif
|
|
422
|
+
`;
|
|
423
|
+
i.vertexShader = F(
|
|
424
|
+
i.vertexShader,
|
|
425
|
+
s,
|
|
426
|
+
f
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
}, n.needsUpdate = !0, U(n, t, e);
|
|
430
|
+
}
|
|
431
|
+
var on = `#define TRAJECTORY_MATERIAL
|
|
432
|
+
|
|
433
|
+
uniform vec3 diffuse;
|
|
434
|
+
uniform float opacity;
|
|
435
|
+
|
|
436
|
+
#ifndef FLAT_SHADED
|
|
437
|
+
varying vec3 vNormal;
|
|
438
|
+
#endif
|
|
439
|
+
varying vec3 vViewPosition;
|
|
440
|
+
#include <common>
|
|
441
|
+
#include <color_pars_fragment>
|
|
442
|
+
#include <uv_pars_fragment>
|
|
443
|
+
#include <map_pars_fragment>
|
|
444
|
+
#include <fog_pars_fragment>
|
|
445
|
+
#include <logdepthbuf_pars_fragment>
|
|
446
|
+
#include <clipping_planes_pars_fragment>
|
|
447
|
+
|
|
448
|
+
vec3 hue2rgb(in float H) {
|
|
449
|
+
float R = abs(H * 6. - 3.) - 1.;
|
|
450
|
+
float G = 2. - abs(H * 6. - 2.);
|
|
451
|
+
float B = 2. - abs(H * 6. - 4.);
|
|
452
|
+
return saturate(vec3(R, G, B));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
vec3 hsl2rgb(in vec3 HSL) {
|
|
456
|
+
vec3 RGB = hue2rgb(HSL.x);
|
|
457
|
+
float C = (1. - abs(2. * HSL.z - 1.)) * HSL.y;
|
|
458
|
+
return (RGB - 0.5) * C + HSL.z;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
vec3 rgb2hsv(in vec3 RGB) {
|
|
462
|
+
|
|
463
|
+
vec4 P = (RGB.g < RGB.b) ? vec4(RGB.bg, -1.0, 2.0 / 3.0) : vec4(RGB.gb, 0.0, -1.0 / 3.0);
|
|
464
|
+
vec4 Q = (RGB.r < P.x) ? vec4(P.xyw, RGB.r) : vec4(RGB.r, P.yzx);
|
|
465
|
+
float C = Q.x - min(Q.w, Q.y);
|
|
466
|
+
float H = abs((Q.w - Q.y) / (6. * C + EPSILON) + Q.z);
|
|
467
|
+
return vec3(H, C, Q.x);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
vec3 rgb2hsl(in vec3 RGB) {
|
|
471
|
+
vec3 HCV = rgb2hsv(RGB);
|
|
472
|
+
float L = HCV.z - HCV.y * 0.5;
|
|
473
|
+
float S = HCV.y / (1. - abs(L * 2. - 1.) + EPSILON);
|
|
474
|
+
return vec3(HCV.x, S, L);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
vec3 hsv2rgb(in vec3 HSV) {
|
|
478
|
+
vec3 RGB = hue2rgb(HSV.x);
|
|
479
|
+
return ((RGB - 1.) * HSV.y + 1.) * HSV.z;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
#ifdef USE_OIT
|
|
483
|
+
#ifdef USE_OIT
|
|
484
|
+
|
|
485
|
+
uniform float oitDepthFar;
|
|
486
|
+
uniform vec2 oitScreenSize;
|
|
487
|
+
uniform sampler2D oitMinDepthTexture;
|
|
488
|
+
uniform int oitSkipFront;
|
|
489
|
+
uniform float oitOcclusionThreshold;
|
|
490
|
+
|
|
491
|
+
vec4 oitProcess(vec4 color) {
|
|
492
|
+
#ifdef OIT_OCCLUSION_PASS
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
if(color.a < oitOcclusionThreshold)
|
|
499
|
+
discard;
|
|
500
|
+
return color;
|
|
501
|
+
#endif
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
float linZ = abs(vViewPosition.z) / oitDepthFar;
|
|
506
|
+
|
|
507
|
+
#ifdef OIT_DEPTH_PASS
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
return vec4(linZ, 0.0, 0.0, 1.0);
|
|
511
|
+
|
|
512
|
+
#else
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
vec2 uv = gl_FragCoord.xy / oitScreenSize;
|
|
518
|
+
float minZ = texture2D(oitMinDepthTexture, uv).r;
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
float tol = minZ * 1e-3 + 1e-6;
|
|
526
|
+
bool isFront = (linZ - minZ) <= tol;
|
|
527
|
+
|
|
528
|
+
#ifdef OIT_FRONT_PASS
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
if(!isFront)
|
|
532
|
+
discard;
|
|
533
|
+
return color;
|
|
534
|
+
|
|
535
|
+
#else
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
if(isFront && oitSkipFront == 0)
|
|
540
|
+
discard;
|
|
541
|
+
|
|
542
|
+
float alpha = color.a;
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
float b = -log(1.0 - clamp(alpha, 0.0, 0.9999));
|
|
550
|
+
return vec4(color.rgb * b, b);
|
|
551
|
+
|
|
552
|
+
#endif
|
|
553
|
+
#endif
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
#endif
|
|
557
|
+
#endif
|
|
558
|
+
|
|
559
|
+
void main() {
|
|
560
|
+
#include <clipping_planes_fragment>
|
|
561
|
+
|
|
562
|
+
vec3 color = diffuse.rgb;
|
|
563
|
+
|
|
564
|
+
vec4 diffuseColor = vec4(color.rgb, opacity);
|
|
565
|
+
|
|
566
|
+
#include <logdepthbuf_fragment>
|
|
567
|
+
#include <map_fragment>
|
|
568
|
+
#include <color_fragment>
|
|
569
|
+
#include <normal_fragment_begin>
|
|
570
|
+
|
|
571
|
+
#ifdef DEPTH_SHADE
|
|
572
|
+
float ndv = clamp(dot(normalize(vNormal), normalize(vViewPosition)), 0.0, 1.0);
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
float ndvAA = max(ndv, fwidth(ndv));
|
|
581
|
+
float depthFactor = pow(ndvAA, 0.8);
|
|
582
|
+
float darkenFactor = clamp(vViewPosition.z / 5000.0, 0.1, 0.8);
|
|
583
|
+
vec3 hsv = rgb2hsv(diffuseColor.rgb);
|
|
584
|
+
hsv.z = hsv.z * darkenFactor;
|
|
585
|
+
vec3 mixColor = hsv2rgb(hsv);
|
|
586
|
+
diffuseColor.rgb = mix(mixColor, diffuseColor.rgb, depthFactor);
|
|
587
|
+
#else
|
|
588
|
+
float alphaFactor = clamp(vViewPosition.z / 100000.0, 0.0, 0.9);
|
|
589
|
+
|
|
590
|
+
diffuseColor.a = 1.0 - alphaFactor;
|
|
591
|
+
#endif
|
|
592
|
+
|
|
593
|
+
gl_FragColor = diffuseColor.rgba;
|
|
594
|
+
|
|
595
|
+
#include <tonemapping_fragment>
|
|
596
|
+
#include <colorspace_fragment>
|
|
597
|
+
#include <fog_fragment>
|
|
598
|
+
|
|
599
|
+
#ifdef OPAQUE
|
|
600
|
+
|
|
601
|
+
gl_FragColor.a = 1.0;
|
|
602
|
+
|
|
603
|
+
#endif
|
|
604
|
+
|
|
605
|
+
#ifdef USE_OIT
|
|
606
|
+
gl_FragColor = oitProcess(gl_FragColor);
|
|
607
|
+
#endif
|
|
608
|
+
}`, tn = `#define TRAJECTORY_MATERIAL
|
|
609
|
+
|
|
610
|
+
varying vec3 vViewPosition;
|
|
611
|
+
|
|
612
|
+
#include <common>
|
|
613
|
+
#include <batching_pars_vertex>
|
|
614
|
+
#include <uv_pars_vertex>
|
|
615
|
+
#include <envmap_pars_vertex>
|
|
616
|
+
#include <color_pars_vertex>
|
|
617
|
+
#include <fog_pars_vertex>
|
|
618
|
+
#include <normal_pars_fragment>
|
|
619
|
+
#include <logdepthbuf_pars_vertex>
|
|
620
|
+
#include <clipping_planes_pars_vertex>
|
|
621
|
+
|
|
622
|
+
void main() {
|
|
623
|
+
|
|
624
|
+
#include <uv_vertex>
|
|
625
|
+
#include <color_vertex>
|
|
626
|
+
#include <batching_vertex>
|
|
627
|
+
#include <beginnormal_vertex>
|
|
628
|
+
#include <defaultnormal_vertex>
|
|
629
|
+
#include <normal_vertex>
|
|
630
|
+
|
|
631
|
+
#include <begin_vertex>
|
|
632
|
+
#include <project_vertex>
|
|
633
|
+
#include <logdepthbuf_vertex>
|
|
634
|
+
#include <clipping_planes_vertex>
|
|
635
|
+
|
|
636
|
+
vViewPosition = - mvPosition.xyz;
|
|
637
|
+
|
|
638
|
+
#include <worldpos_vertex>
|
|
639
|
+
#include <fog_vertex>
|
|
640
|
+
}`;
|
|
641
|
+
class mn extends y {
|
|
642
|
+
isTubeMaterial = !0;
|
|
643
|
+
constructor(e) {
|
|
644
|
+
super({
|
|
645
|
+
vertexShader: tn,
|
|
646
|
+
fragmentShader: on,
|
|
647
|
+
uniforms: q.clone($.basic.uniforms),
|
|
648
|
+
defines: {
|
|
649
|
+
DEPTH_SHADE: !0
|
|
650
|
+
},
|
|
651
|
+
clipping: !0,
|
|
652
|
+
fog: !0
|
|
653
|
+
}), e && this.setValues(e), X(this);
|
|
654
|
+
}
|
|
655
|
+
get color() {
|
|
656
|
+
return this.uniforms.diffuse.value;
|
|
657
|
+
}
|
|
658
|
+
set color(e) {
|
|
659
|
+
this.uniforms.diffuse.value.set(e);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
export {
|
|
663
|
+
ln as C,
|
|
664
|
+
mn as T,
|
|
665
|
+
X as a,
|
|
666
|
+
an as b,
|
|
667
|
+
cn as c,
|
|
668
|
+
pn as d,
|
|
669
|
+
un as e,
|
|
670
|
+
fn as g,
|
|
671
|
+
hn as i,
|
|
672
|
+
gn as m,
|
|
673
|
+
dn as t,
|
|
674
|
+
j as w
|
|
675
|
+
};
|