videx-3d
Version:
React 3D component library designed for sub surface visualizations in the browser
852 lines (839 loc) • 23.1 kB
JavaScript
var bt = Object.defineProperty;
var Pt = (t, n, r) => n in t ? bt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[n] = r;
var K = (t, n, r) => Pt(t, typeof n != "symbol" ? n + "" : n, r);
import { BufferGeometry as ut, BufferAttribute as q, Vector3 as R, Layers as Tt, MeshDepthMaterial as kt, RGBADepthPacking as It, WebGLRenderTarget as ft, UnsignedByteType as dt, ShaderMaterial as pt, OrthographicCamera as Ft, Scene as vt, PlaneGeometry as Ut, Mesh as Dt, RGBAFormat as Et, DataTexture as mt, LinearFilter as _ } from "three";
import "comlink";
import Bt from "p-limit";
import Rt from "p-queue";
import { CurveInterpolator as Vt, EPS as zt } from "curve-interpolator";
import "three/src/math/MathUtils.js";
import "proj4";
const Ct = Bt(50), Lt = new Rt({ concurrency: 20 }), X = (t) => Ct(t), gn = (t, n = 0) => Lt.add(t, { priority: n });
async function yn(t, n, r, e = !0, a) {
const [s, o] = await X(
() => Promise.all([
r.get("wellbore-headers", t),
r.get("strat-columns", n)
])
);
if (!s || !o) return null;
const i = /* @__PURE__ */ new Map();
s.parent && e && (await X(
() => r.query("wellbore-headers", { well: s.well })
)).forEach((g) => {
i.set(g.name, g);
});
const l = o.units.reduce(
(m, g) => (m.set(g.top, g), m.set(g.base, g), m),
/* @__PURE__ */ new Map()
), c = [], f = [], d = /* @__PURE__ */ new Set();
a = a === void 0 ? -1 / 0 : a;
let u = 1 / 0, p = 1 / 0, k = [];
const x = async (m) => {
let g = a !== void 0 ? a : -1 / 0;
m.kickoffDepthMsl !== null && m.kickoffDepthMsl > g && (g = m.kickoffDepthMsl);
let b = null;
if (k && k.length > 0 && k[0].mdMsl < p)
b = k;
else if (b = await X(() => r.get("picks", m.id)), b)
k = b;
else
return;
const F = b.filter(
(y) => y.mdMsl <= p && y.mdMsl >= g
);
F.sort((y, A) => A.mdMsl - y.mdMsl);
for (let y = 0; y < F.length; y++) {
const A = F[y];
if (A.mdMsl <= u && !d.has(A.id)) {
const V = l.get(A.pickIdentifier);
V ? c.push({
pick: A,
unit: V
}) : f.push(A), d.add(A.id), u = A.mdMsl;
}
}
if (p = g, e && m.parent && u > a) {
const y = i.get(m.parent);
y && await x(y);
}
};
return await x(s), { matched: c, unmatched: f, wellbore: s };
}
function Mn(t, n = 1 / 0) {
const r = [];
if (!Array.isArray(t) || t.length < 2) return r;
let e = t.map((s) => ({
...s,
deleted: !1
}));
e.sort(
(s, o) => s.unit.level - o.unit.level || s.pick.mdMsl - o.pick.mdMsl || s.unit.topAge - o.unit.topAge
);
const a = () => {
let s = null;
const o = e.shift();
if (o) {
for (let i = 0; i < e.length; i++) {
const l = e[i];
if (o.unit.level < l.unit.level)
break;
if (l.unit.name === o.unit.name)
if (l.pick.pickIdentifier !== o.pick.pickIdentifier) {
e[i].deleted = !0, s = {
entry: o.pick,
exit: l.pick,
unit: o.unit
};
break;
} else
e[i].deleted = !0;
}
e = e.filter((i) => !i.deleted);
}
return s;
};
for (; e.length; ) {
const s = a();
s && s.entry.mdMsl !== s.exit.mdMsl && s.entry.mdMsl < n && (s.exit.mdMsl > n && (s.exit.mdMsl = n), r.push(s));
}
return r;
}
function An(t) {
if (!t.length) return [];
const n = [], r = [...t].sort(
(o, i) => o.entry.mdMsl - i.entry.mdMsl || o.unit.level - i.unit.level
), e = r[0], a = [e];
let s = e.entry.mdMsl;
for (let o = 1; o < r.length; o++) {
const i = r[o];
if (i.entry.mdMsl > s) {
const l = i.entry.mdMsl;
for (; a.length && s < l; ) {
const c = a.pop();
if (c.exit.mdMsl > s) {
const f = Math.min(c.exit.mdMsl, l);
n.push({
mdMslTop: s,
mdMslBottom: f,
unit: c.unit
}), s = f, c.exit.mdMsl > l && a.push(c);
}
}
s = l;
}
a.push(i);
}
for (; a.length; ) {
const o = a.pop();
if (o.exit.mdMsl > s) {
const i = o.exit.mdMsl;
n.push({
mdMslTop: s,
mdMslBottom: i,
unit: o.unit
}), s = i;
}
}
return n;
}
function wn(t) {
const n = [], r = [...t].sort(
(s, o) => s.entry.mdMsl - o.entry.mdMsl || o.unit.level - s.unit.level
);
let e = null, a = -1 / 0;
for (let s = 0; s < r.length; s++) {
const o = r[s];
o.entry.mdMsl > a && (a = o.entry.mdMsl, e && e.exit.mdMsl < a && n.push({
color: e.unit.color,
name: e.unit.name,
type: "base",
mdMsl: e.exit.mdMsl,
tvdMsl: e.exit.tvdMsl,
level: e.unit.level
}), n.push({
color: o.unit.color,
name: o.unit.name,
type: "top",
mdMsl: a,
tvdMsl: o.entry.tvdMsl,
level: o.unit.level
}), e = o);
}
return e && n.push({
color: e.unit.color,
name: e.unit.name,
type: "base",
mdMsl: e.exit.mdMsl,
tvdMsl: e.exit.tvdMsl,
level: e.unit.level
}), n;
}
function W(t, n = 0, r = 1) {
return t < n ? n : t > r ? r : t;
}
function Nt(t, n, r) {
return r = W(r, 0, 1), (1 - r) * t + r * n;
}
function St(t, n, r) {
return (t - n) / (r - n);
}
function xn(t, n, r, e, a) {
const s = St(t, n, r);
return Nt(e, a, s);
}
const Gt = (t) => {
if (t < 0) return [0, 0, 0];
if (t > 1677.215) return [255, 255, 255];
const n = Math.round(t * 1e3), r = Math.floor(n / 65536), e = Math.floor(n / 256) - r * 256, a = Math.floor(n) - r * 65536 - e * 256;
return [r, e, a];
}, bn = Math.PI, ot = 2 * Math.PI, qt = Math.PI / 2, Pn = Math.PI / 4, Tn = Math.PI / 8;
function kn(t, n) {
for (; n < -Math.PI; )
n += ot;
for (; n > Math.PI; )
n -= ot;
const r = Math.atan2(t[1], t[0]), e = Math.tan(n);
let a;
n > -r && n <= r ? a = 1 : n > r && n <= Math.PI - r ? a = 2 : n > Math.PI - r || n <= -(Math.PI - r) ? a = 3 : a = 4;
const s = [0, 0];
let o = 1, i = 1;
switch (a) {
case 1:
i = -1;
break;
case 2:
i = -1;
break;
case 3:
o = -1;
break;
case 4:
o = -1;
break;
}
return a === 1 || a === 3 ? (s[0] += o * (t[0] / 2), s[1] += i * (t[0] / 2) * e) : (s[0] += o * (t[1] / (2 * e)), s[1] += i * (t[1] / 2)), s;
}
function In(t) {
return t[0] = -t[0], t[1] = -t[1], t[2] = -t[2], t;
}
function Fn(t, n) {
return [t[n], t[n + 1], t[n + 2]];
}
function vn(t, n, r) {
t[n] = r[0], t[n + 1] = r[1], t[n + 2] = r[2];
}
function Un(t, n) {
return [t[0] + n[0], t[1] + n[1], t[2] + n[2]];
}
function it(t, n) {
return [t[0] - n[0], t[1] - n[1], t[2] - n[2]];
}
function Dn(t, n) {
return t[0] = t[0] * n, t[1] = t[1] * n, t[2] = t[2] * n, t;
}
function _t(t) {
const n = t[0] ** 2 + t[1] ** 2 + t[2] ** 2;
return n > 0 ? Math.sqrt(n) : 0;
}
function v(t, n) {
return [
t[1] * n[2] - t[2] * n[1],
t[2] * n[0] - t[0] * n[2],
t[0] * n[1] - t[1] * n[0]
];
}
function ht(t, n) {
return t[0] * n[0] + t[1] * n[1] + t[2] * n[2];
}
function j(t) {
const n = Math.sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]);
return t[0] = t[0] / n, t[1] = t[1] / n, t[2] = t[2] / n, t;
}
function En(t, n, r = 0.5) {
const e = 1 - r;
return [
t[0] * e + n[0] * r,
t[1] * e + n[1] * r,
t[2] * e + n[2] * r
];
}
function jt(t) {
return [
t[0],
t[1],
t[2]
];
}
function Bn(t, n) {
const r = Math.sqrt((t[0] ** 2 + t[1] ** 2 + t[2] ** 2) * (n[0] ** 2 + n[1] ** 2 + n[2] ** 2));
if (r === 0) return qt;
const e = ht(t, n) / r;
return Math.acos(W(e, -1, 1));
}
function gt(t, n = [0, 1, 0], r = 0) {
const e = Math.cos(r), a = Math.sin(r), s = 1 - e, o = t[0], i = t[1], l = t[2], c = n[0], f = n[1], d = n[2], u = s * c, p = s * f;
return [
(u * c + e) * o + (u * f - a * d) * i + (u * d + a * f) * l,
(u * f + a * d) * o + (p * f + e) * i + (p * d - a * c) * l,
(u * d - a * f) * o + (p * d + a * c) * i + (s * d * d + e) * l
];
}
function Rn(t, n) {
return [t[n], t[n + 1]];
}
function Vn(t, n, r) {
t[n] = r[0], t[n + 1] = r[1];
}
function zn(t) {
const n = Math.sqrt(t[0] * t[0] + t[1] * t[1]);
return t[0] = t[0] / n, t[1] = t[1] / n, t;
}
function Cn(t, n) {
return [t[0] + n[0], t[1] + n[1]];
}
function Ln(t, n) {
return [t[0] - n[0], t[1] - n[1]];
}
function Nn(t) {
return t[0] = -t[0], t[1] = -t[1], t;
}
function Sn(t, n) {
return t[0] = t[0] * n, t[1] = t[1] * n, t;
}
function Gn(t) {
const n = t[0] ** 2 + t[1] ** 2;
return n > 0 ? Math.sqrt(n) : 0;
}
function qn(t, n, r = 0.5) {
const e = 1 - r;
return [
t[0] * e + n[0] * r,
t[1] * e + n[1] * r
];
}
function Ot(t, n = !1) {
const r = {
alpha: 1,
tension: 0,
closed: n
}, e = new Vt(t, r);
return {
getPointAt: (s) => e.getPointAt(s),
getPoints: (s, o = 0, i = 1) => e.getPoints(s, null, o, i),
getTangentAt: (s) => e.getTangentAt(s),
getNormalAt: (s) => e.getNormalAt(s),
getBoundingBox: (s = 0, o = 1) => {
const i = e.getBoundingBox(s, o);
return {
min: i.min,
max: i.max
};
},
nearest: (s) => {
const o = e.getNearestPosition(s);
return {
position: o.u,
point: o.point,
distance: o.distance
};
},
get length() {
return e.length;
},
closed: n
};
}
function _n(t, n) {
const r = n.length, e = new Array(r);
if (!e.length) return [];
n.forEach((c, f) => {
e[f] = {
curvePosition: c,
position: t.getPointAt(c),
tangent: t.getTangentAt(c),
normal: [0, 0, 0],
binormal: [0, 0, 0]
};
});
let a = [0, 1, 0], s = Math.abs(e[0].tangent[1]);
const o = Math.abs(e[0].tangent[0]), i = Math.abs(e[0].tangent[2]);
o <= s && (s = o, a = [1, 0, 0]), i <= s && (a = [0, 0, 1]);
let l = j(v(e[0].tangent, a));
e[0].normal = v(e[0].tangent, l), e[0].binormal = v(e[0].tangent, e[0].normal);
for (let c = 1; c < n.length; c++) {
if (l = v(e[c - 1].tangent, e[c].tangent), e[c].normal = jt(e[c - 1].normal), _t(l) > zt) {
j(l);
const f = Math.acos(W(ht(e[c - 1].tangent, e[c].tangent), -1, 1));
e[c].normal = gt(e[c - 1].normal, l, f);
}
e[c].binormal = v(e[c].tangent, e[c].normal);
}
return e;
}
function O(t) {
if (t.constructor === Uint8Array) return "Uint8Array";
if (t.constructor === Uint16Array) return "Uint16Array";
if (t.constructor === Uint32Array) return "Uint32Array";
if (t.constructor === Int8Array) return "Int8Array";
if (t.constructor === Int16Array) return "Int16Array";
if (t.constructor === Int32Array) return "Int32Array";
if (t.constructor === Float32Array) return "Float32Array";
if (t.constructor === Float64Array) return "Float64Array";
throw Error("Unsupported typed array!");
}
function $(t, n) {
switch (n) {
case "Uint8Array":
return new Uint8Array(t);
case "Uint16Array":
return new Uint16Array(t);
case "Uint32Array":
return new Uint32Array(t);
case "Int8Array":
return new Int8Array(t);
case "Int16Array":
return new Int16Array(t);
case "Int32Array":
return new Int32Array(t);
case "Float32Array":
return new Float32Array(t);
case "Float64Array":
return new Float64Array(t);
default:
throw Error("Unsupported typed array!");
}
}
function $t(t, n = 1) {
return { buffer: t.buffer, attributeType: O(t), itemSize: n };
}
function jn(t) {
const n = [], r = {
drawRange: t.drawRange || { start: 0, count: 1 / 0 },
groups: t.groups || [],
attributes: {},
index: t.index,
indexType: t.index ? O(t.index) : void 0,
userData: t.userData ? structuredClone(t.userData) : void 0
};
for (const e in t.attributes)
r.attributes[e] = $t(t.attributes[e].array, t.attributes[e].itemSize), n.push(r.attributes[e].buffer);
return [r, n];
}
function Wt(t) {
const n = [], r = {
drawRange: t.drawRange,
groups: t.groups,
attributes: {},
index: void 0,
indexType: void 0
}, e = t.getIndex();
e && (r.index = e.array.buffer, r.indexType = O(e.array));
for (const a in t.attributes) {
const s = t.getAttribute(a);
r.attributes[a] = { buffer: s.array.buffer, attributeType: O(s.array), itemSize: s.itemSize }, n.push(r.attributes[a].buffer);
}
return t.userData && (r.userData = structuredClone(t.userData)), [r, n];
}
function On(t) {
const n = {}, r = [];
for (const e in t) {
const a = t[e], s = Wt(a);
n[e] = s[0], s[1].length && r.push(...s[1]);
}
return { data: n, transferrables: r };
}
function $n(t) {
const n = new ut();
if (t.index) {
const r = $(t.index, t.indexType || "Uint32Array"), e = new q(r, 1);
n.setIndex(e);
}
for (const r in t.attributes) {
const e = new q(
$(t.attributes[r].buffer, t.attributes[r].attributeType),
t.attributes[r].itemSize
);
n.setAttribute(r, e);
}
return n.drawRange = t.drawRange, n.groups = t.groups, t.userData && (n.userData = t.userData), n;
}
function Wn(t) {
const n = {};
for (const r in t) {
const e = new ut();
if (t[r].index) {
const a = $(t[r].index, t[r].indexType || "Uint32Array"), s = new q(a, 1);
e.setIndex(s);
}
for (const a in t[r].attributes) {
const s = new q(
$(t[r].attributes[a].buffer, t[r].attributes[a].attributeType),
t[r].attributes[a].itemSize
);
e.setAttribute(a, s);
}
e.drawRange = t[r].drawRange, e.groups = t[r].groups, n[r] = e;
}
return n;
}
const tt = "camera-set-position", nt = "camera-focus-point";
class Zn extends CustomEvent {
constructor(n) {
super(tt, { detail: n });
}
}
class Hn extends CustomEvent {
constructor(n) {
super(nt, { detail: n });
}
}
const M = new R(), h = new R(), U = new R(), D = new R(), ct = new R();
async function Zt(t, n, r) {
const e = Math.min(r.distance, n);
return M.set(...t), r.getPosition(h), U.subVectors(M, h), n = Math.min(U.length() * 1.5, e), U.normalize(), h.copy(M).addScaledVector(U, -e), r.setLookAt(h.x, h.y, h.z, M.x, M.y, M.z, !0);
}
function Ht(t, n) {
D.set(...t), n.getTarget(M), ct.subVectors(M, D), n.getPosition(h), h.sub(ct), n.setPosition(h.x, h.y, h.z), n.setTarget(D.x, D.y, D.z);
}
class Yt {
constructor() {
K(this, "controls", null);
K(this, "removeEventlisteners", null);
this.setControls = this.setControls.bind(this);
}
addEventListeners() {
const n = (e) => {
this.controls && Ht(e.detail, this.controls);
}, r = (e) => {
if (this.controls) {
const a = e.detail.callback;
Zt(
e.detail.point,
e.detail.distance || 200,
this.controls
).then(() => {
a && a();
});
}
};
addEventListener(tt, n), addEventListener(nt, r), this.removeEventlisteners = () => {
removeEventListener(tt, n), removeEventListener(nt, r);
};
}
async setTarget(n) {
const r = this.controls;
return r ? (M.set(...n), r.getPosition(h), U.subVectors(M, h), U.normalize(), r.setLookAt(h.x, h.y, h.z, M.x, M.y, M.z, !0)) : null;
}
setControls(n) {
this.controls = n, this.removeEventlisteners && this.removeEventlisteners(), this.addEventListeners();
}
dispose() {
this.controls = null, this.removeEventlisteners && this.removeEventlisteners();
}
}
const Yn = new Yt(), Qt = {
NOT_EMITTER: 29,
// can be used to exclude an object from being used as an event emitter
EMITTER: 30,
// used internally to flag an object as an event emitter
OCCLUDER: 31
// object will be considered in occlusion checks in the annotations system
};
function Qn(...t) {
const n = new Tt();
return t.forEach((r) => n.enable(r)), n;
}
const Jt = new kt({ depthPacking: It }), C = 255 / 256, L = new Float32Array([
C,
C / 256,
C / 256 ** 2,
C / 256 ** 3
]);
function Kt(t, n, r, e) {
return t / 255 * L[0] + n / 255 * L[1] + r / 255 * L[2] + e / 255 * L[3];
}
let P = null, I = null, E = null;
async function Jn(t, n, r, e, a) {
const s = r.layers.mask;
if (r.layers.disableAll(), r.layers.set(Qt.OCCLUDER), (!P || P.width !== e || P.height !== a) && (P == null || P.dispose(), I = new Uint8Array(4 * e * a), E = new Float32Array(e * a), P = new ft(e, a, {
type: dt
})), t.setRenderTarget(P), n.overrideMaterial = Jt, t.clear(), t.render(n, r), n.overrideMaterial = null, t.setRenderTarget(null), r.layers.mask = s, await t.readRenderTargetPixelsAsync(
P,
0,
0,
e,
a,
I
), I && E)
for (let o = 0; o < E.length; o++) {
const i = o * 4, l = Kt(
I[i],
I[i + 1],
I[i + 2],
I[i + 3]
);
E[o] = l * 2 - 1;
}
return E;
}
var Xt = `#include <common>
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}`, tn = `#include <common>
#include <packing>
varying vec2 vUv;
uniform sampler2D depthTexture;
uniform float cameraFar;
uniform float cameraNear;
float linearizeDepth(in float depth) {
float a = cameraFar / (cameraFar - cameraNear);
float b = cameraFar * cameraNear / (cameraNear - cameraFar);
return a + b / depth;
}
float reconstructDepth(const in float depth) {
return pow(2.0, depth * log2(cameraFar + 1.0)) - 1.0;
}
float getDepth(vec2 uv) {
float depth = texture2D(depthTexture, uv).x;
#if defined( USE_LOGDEPTHBUF )
return linearizeDepth(reconstructDepth(depth));
#else
return texture2D(depthTexture, uv).x;
#endif
}
void main() {
gl_FragColor = packDepthToRGBA(getDepth(vUv));
}`;
class nn extends pt {
constructor() {
super({
vertexShader: Xt,
fragmentShader: tn,
uniforms: {
cameraNear: { value: 0 },
cameraFar: { value: 1 },
depthTexture: { value: null },
cameraWasPerspective: { value: null }
},
toneMapped: !1,
depthWrite: !1,
depthTest: !1
});
}
}
const N = 255 / 256, S = new Float32Array([
N,
N / 256,
N / 256 ** 2,
N / 256 ** 3
]);
function lt(t) {
return t[0] / 255 * S[0] + t[1] / 255 * S[1] + t[2] / 255 * S[2] + t[3] / 255 * S[3];
}
const en = new Ft(-1, 1, 1, -1, 0, 1), B = new nn(), yt = new vt(), rn = new Ut(2, 2), sn = new Dt(rn, B);
let T = null, w = null;
yt.add(sn);
async function Kn(t, n, r, e) {
if (!t) return null;
try {
const { width: a, height: s } = t.image;
if ((!T || !w || T.width !== a || T.height !== s) && (T == null || T.dispose(), w = new Uint8Array(4 * a * s), T = new ft(a, s, {
type: dt,
format: Et,
depthBuffer: !1,
stencilBuffer: !1
})), B.uniforms.depthTexture.value = t, B.uniforms.cameraNear.value = r.near, B.uniforms.cameraFar.value = r.far, B.uniforms.cameraWasPerspective.value = r.isPerspectiveCamera, n.setRenderTarget(T), n.clear(), n.render(yt, en), n.setRenderTarget(null), await n.readRenderTargetPixelsAsync(
T,
0,
// x
0,
// y
a,
s,
w
), e !== void 0 && Number.isFinite(e)) {
const o = [
w[e],
w[e + 1],
w[e + 2],
w[e + 3]
];
return lt(o) * 2 - 1;
} else {
const o = new Array(w.length / 4);
for (let i = 0; i < o.length; i++) {
const l = i * 4, c = [
w[l],
w[l + 1],
w[l + 2],
w[l + 3]
];
o[i] = lt(c) * 2 - 1;
}
return o;
}
} catch (a) {
return console.error(a), null;
}
}
function G(t, n, r) {
const e = it(t, n), a = it(t, r);
return j(v(e, a));
}
function Xn(t, n = -1) {
const r = new Uint8Array(t.length * 4);
for (let e = 0; e < t.length; e++) {
const a = t[e], s = a === n ? [0, 0, 0] : Gt(a), o = e * 4;
r[o] = s[0], r[o + 1] = s[1], r[o + 2] = s[2], r[o + 3] = a === -1 ? 0 : 255;
}
return r;
}
function te(t, n, r, e, a = 0, s = -1) {
const o = t.length / n, i = n - 1, l = o - 1, c = new Uint8Array(i * l * 4);
let f = 0;
const d = (u, p) => t[p * n + u];
for (let u = 0; u < l; u++) {
const p = u + 1, k = u + 0.5;
for (let x = 0; x < i; x++) {
const m = x + 1, g = x + 0.5, b = d(x, u);
if (b !== s) {
const F = d(x, p), y = d(m, u), A = d(m, p), V = (b + F + y + A) / 4, et = [x * r, u * e, b], rt = [x * r, p * e, F], st = [m * r, u * e, y], at = [m * r, p * e, A], z = [g * r, k * e, V], Z = G(z, et, st), H = G(z, st, at), Y = G(z, at, rt), Q = G(z, rt, et), Mt = j([
Z[0] + H[0] + Y[0] + Q[0],
Z[2] + H[2] + Y[2] + Q[2],
Z[1] + H[1] + Y[1] + Q[1]
]), J = gt(Mt, [0, 1, 0], a * (Math.PI / 180)), At = Math.floor((J[0] + 1) / 2 * 255), wt = Math.floor((J[1] + 1) / 2 * 255), xt = Math.floor((J[2] + 1) / 2 * 255);
c[f] = At, c[f + 1] = wt, c[f + 2] = xt, c[f + 3] = 255;
} else
c[f] = 0, c[f + 1] = 0, c[f + 2] = 0, c[f + 3] = 0;
f += 4;
}
}
return c;
}
function ne(t, n, r) {
const e = new mt(t, n, r);
return e.minFilter = _, e.magFilter = _, e.flipY = !0, e.anisotropy = 4, e.needsUpdate = !0, e;
}
function ee(t, n, r) {
const e = new mt(t, n, r);
return e.minFilter = _, e.magFilter = _, e.needsUpdate = !0, e.flipY = !0, e;
}
function re(t, n) {
if (!n || n.length < 2 * 4) return null;
const [r, , e] = n, a = new Array(n.length / 4);
for (let d = 0, u = 0; d < a.length; d++, u += 4)
a[d] = [
n[u] - r,
-n[u + 1],
e - n[u + 2]
];
const s = Ot(a, !1);
if (!s) return null;
const o = n[3], i = n[n.length - 1], l = i - o, c = (d, u = !1) => {
let p = (d - o) / l;
return u && (p = W(p, 0, 1)), p < 0 || p > 1 ? null : p;
};
return {
id: t,
curve: s,
get measuredLength() {
return l;
},
get measuredTop() {
return o;
},
get measuredBottom() {
return i;
},
getPositionAtDepth: c,
getPointAtDepth: (d, u = !1) => {
const p = c(d, u);
return p !== null ? s.getPointAt(p) : null;
}
};
}
var an = `varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}`, on = `varying vec2 vUv;
void main() {
gl_FragColor = vec4(vUv, 1.0, 1.0);
}`;
const se = new pt({
vertexShader: an,
fragmentShader: on
});
export {
_t as $,
Ot as A,
O as B,
Zn as C,
$ as D,
$t as E,
jn as F,
Wt as G,
On as H,
Wn as I,
Yt as J,
Yn as K,
Qt as L,
G as M,
Xn as N,
te as O,
Pn as P,
Nt as Q,
St as R,
xn as S,
ot as T,
Gt as U,
In as V,
Fn as W,
vn as X,
Un as Y,
it as Z,
Dn as _,
qt as a,
v as a0,
ht as a1,
En as a2,
jt as a3,
Bn as a4,
gt as a5,
Rn as a6,
Vn as a7,
Cn as a8,
Nn as a9,
Sn as aa,
Gn as ab,
nn as ac,
se as ad,
bn as b,
Tn as c,
W as d,
kn as e,
j as f,
Jn as g,
yn as h,
Mn as i,
An as j,
re as k,
Qn as l,
qn as m,
zn as n,
ee as o,
ne as p,
gn as q,
Kn as r,
Ln as s,
X as t,
$n as u,
tt as v,
nt as w,
Hn as x,
_n as y,
wn as z
};