videx-3d
Version:
React 3D component library designed for sub surface visualizations in the browser
6,767 lines • 207 kB
JavaScript
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("svg.well-map g.tracks g.track:hover{cursor:help}svg.well-map g.tracks g.track.interactive:hover{cursor:pointer;filter:brightness(1.1)}svg.well-map g.tracks g.track.interactive.selected:hover{cursor:pointer;filter:none}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
var xo = Object.defineProperty;
var yo = (t, n, e) => n in t ? xo(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
var se = (t, n, e) => yo(t, typeof n != "symbol" ? n + "" : n, e);
import { createRef as bo, forwardRef as ye, useCallback as ae, useRef as j, useMemo as C, useEffect as L, useLayoutEffect as _o, createContext as Ae, useContext as ne, useState as F, startTransition as nn, Fragment as Nt, useImperativeHandle as Ee } from "react";
import { create as xt, useStore as wo } from "zustand";
import { subscribeWithSelector as To } from "zustand/middleware";
import { jsx as T, Fragment as ze, jsxs as H } from "react/jsx-runtime";
import { useThree as yt, useFrame as De, extend as Fn } from "@react-three/fiber";
import { createRoot as Ao } from "react-dom/client";
import * as X from "three";
import { Vector3 as $, Vector2 as he, createCanvasElement as Mo, OrthographicCamera as Co, MeshBasicMaterial as bt, Scene as Po, PlaneGeometry as ko, Mesh as ht, CanvasTexture as Gn, Color as Q, ShaderMaterial as Je, Ray as So, Plane as Lo, Uniform as R, BackSide as Yt, DoubleSide as Ie, FrontSide as mt, WebGLRenderTarget as Bn, HalfFloatType as zo, LinearFilter as Ze, Box3 as Un, DepthTexture as Ro, UnsignedByteType as Eo, RGBAFormat as Hn, SRGBColorSpace as jn, InstancedBufferAttribute as Vn, AdditiveBlending as $n, Matrix4 as Kt, InstancedMesh as Ht, Line as Nn, NearestFilter as Do, UniformsUtils as Re, ShaderLib as qt, MultiplyOperation as Io, TangentSpaceNormalMap as Oo, Layers as Wo, LineBasicMaterial as Fo, MeshStandardMaterial as pe, MeshLambertMaterial as Go, ConeGeometry as Yn, CylinderGeometry as Bo, Sphere as Uo, InstancedInterleavedBuffer as Ho, InstancedBufferGeometry as jo, BufferAttribute as on, InterleavedBufferAttribute as st } from "three";
import { createEndpoint as Xt, transfer as Vo, proxy as $o } from "comlink";
import { n as No, s as Yo, P as Xe, a as rn, b as Qe, c as Ko, d as xe, m as Kn, e as qo, f as Xo, g as Qo, T as Zo, L as oe, r as Jo, h as qn, i as Xn, j as Qn, k as Zn, l as Te, q as le, o as ei, p as ti, u as Oe, t as ni, v as sn, w as an, x as oi, y as ii } from "./chunk-CPDkHB2U.js";
import { z as za, C as Ra } from "./chunk-CPDkHB2U.js";
import "curve-interpolator";
import "three/src/math/MathUtils.js";
import "proj4";
import Jn from "rbush";
import { Text as ln, useTexture as ri } from "@react-three/drei";
import { i as cn, c as eo, t as un, g as si, C as ai, T as Qt, W as li, a as ci, b as ui } from "./chunk-Bv7spTT9.js";
import { f as Da, d as Ia, e as Oa, w as Wa } from "./chunk-Bv7spTT9.js";
import fi from "react-use-measure";
import { range as di, group as fn } from "d3-array";
import { axisLeft as dn } from "d3-axis";
import { pointer as pi, select as jt } from "d3-selection";
import { path as et } from "d3-path";
import { scaleLinear as We } from "d3-scale";
import { drag as hi } from "d3-drag";
import { format as mi } from "d3-format";
import { nanoid as vt } from "nanoid";
import { piecewise as vi, interpolateHcl as gi } from "d3-interpolate";
import { c as xi, a as yi } from "./chunk-BX-cez1_.js";
import { b as Ga, d as Ba } from "./chunk-BX-cez1_.js";
const me = xt(
To((t, n) => ({
visible: !0,
update: {
required: !1,
ref: null,
setRef: (e) => t((i) => ({ update: { ...i.update, ref: e } }))
},
layers: {},
annotations: {},
instances: [],
clear: () => t({
layers: {},
annotations: {},
instances: []
}),
setInstances: (e) => t({ instances: e }),
layerExist: (e) => !!n().layers[e],
toggleVisibility: () => {
t((e) => ({
visible: !e.visible,
update: { ...e.update, required: !0 }
}));
},
createLayer: (e) => {
const i = e.id;
return t((o) => {
const r = o.layers;
if (r[i])
throw Error("Layer already exist!");
return { layers: { ...r, [i]: e } };
}), () => {
t((o) => {
const r = { ...o.layers };
return delete r[i], {
layers: r,
update: { ...o.update, required: !0 }
};
});
};
},
updateLayer: (e, i) => {
t((o) => {
const r = o.layers;
if (!r[e])
throw Error("Layer does not exist!");
return {
layers: { ...r, [e]: { ...r[e], ...i } },
update: { ...o.update, required: !0 }
};
});
},
addLayerAnnotations: (e, i, o) => {
t((r) => {
o.forEach((s) => {
s.scope = i;
});
const a = r.annotations, l = a[e] ? a[e].filter((s) => s.scope !== i) : [];
return {
annotations: {
...a,
[e]: [...l, ...o]
},
update: { ...r.update, required: !0 }
};
});
},
removeLayerAnnotations: (e, i) => {
t((o) => {
const r = o.annotations, a = r[e] ? r[e].filter((l) => l.scope !== i) : [];
return {
annotations: {
...r,
[e]: a
},
update: { ...o.update, required: !0 }
};
});
}
}))
), bi = () => {
me.setState((t) => {
if (!t.visible)
return {
instances: [],
update: { ...t.update, required: !1, ref: null }
};
const n = t.layers, e = new Map(t.instances.map((a) => [a.id, a])), i = [], o = [0, 0];
Object.keys(n).forEach((a) => {
var u;
const l = n[a];
l.visible && ((u = t.annotations[a]) == null || u.forEach((s) => {
const c = `${a}_${s.scope}_${s.id}`;
let f;
const y = e.get(c);
y ? (f = y, f.annotation.name = s.name, f.annotation.data = s.data, f.annotation.direction = s.direction, f.annotation.position = s.position, f.annotation.priority = s.priority) : f = {
id: c,
ref: l.labelComponent ? bo() : null,
layer: l,
annotation: s,
priority: 0,
rank: 0,
state: {
visible: !1,
distance: 1 / 0,
health: 0,
labelWidht: 0,
labelHeight: 0,
screenPosition: [0, 0, 0],
zIndex: 0
}
}, f.priority = (s.priority || 0) + (l.priority || 0), o[0] = Math.min(o[0], f.priority), o[1] = Math.max(o[1], f.priority), i.push(f);
}));
});
const r = Math.abs(o[1] - o[0]);
return i.forEach((a) => {
a.priority = r > 0 ? (a.priority - o[0]) / r : 0;
}), {
instances: i,
update: { ...t.update, required: !1, ref: null }
};
});
};
me.subscribe(
(t) => t.update.required,
(t) => {
if (t) {
const n = me.getState().update;
n.ref && clearTimeout(n.ref);
const e = setTimeout(() => bi(), 500);
n.setRef(e);
}
}
);
const Ve = (t, n) => {
const e = me((o) => o.addLayerAnnotations), i = me((o) => o.removeLayerAnnotations);
return {
addAnnotations: (o) => (e(t, n, o), () => i(t, n))
};
}, _i = {
pointerEvents: "none",
width: "100%",
height: "100%"
}, wi = {
position: "absolute",
top: 0,
left: 0,
visibility: "hidden",
userSelect: "none",
cursor: "pointer",
pointerEvents: "visible"
}, Ti = ye(({ id: t, state: n, layer: e, annotation: i }, o) => {
const r = ae(() => {
e.onClick && e.onClick({ instanceId: t, ...i });
}, [i, t, e]), a = ae(() => {
n.labelHovered = !0;
}, [n]), l = ae(() => {
n.labelHovered = !1;
}, [n]);
return /* @__PURE__ */ T(
"div",
{
ref: o,
style: wi,
onClick: r,
onPointerEnter: a,
onPointerLeave: l,
children: e.labelComponent && /* @__PURE__ */ T(
e.labelComponent,
{
instanceId: t,
...i
}
)
}
);
}), Ai = () => {
const t = wo(me, (n) => n.instances);
return /* @__PURE__ */ T("div", { style: _i, children: t.map(
(n) => /* @__PURE__ */ T(
Ti,
{
ref: n.ref,
id: n.id,
state: n.state,
layer: n.layer,
annotation: n.annotation
},
n.id
)
) });
}, at = new $(), Mi = [
/* 0 */
0,
/* 1 */
Xe,
/* 2 */
rn,
/* 3 */
Qe - Xe,
/* 4 */
Qe,
/* 5 */
-Qe + Xe,
/* 6 */
-rn,
/* 7 */
-Xe
], Ci = [
[2, 6],
[7, 3],
[0, 4],
[1, 5]
], Pi = (t, n, e, i) => {
at.set(
n[0] + e[0] * 100,
n[1] + e[1] * 100,
n[2] + e[2] * 100
), at.project(i);
const o = No(
Yo([at.x, at.y], [t[0], t[1]])
);
let r = Math.atan2(o[1], o[0]);
return r < 0 && (r = Qe + r), Math.floor((r + Ko) / Xe) % 4;
}, ki = (t, n, e, i) => {
const o = Math.floor((t[0] * 0.5 + 0.5) * n), r = Math.floor((t[1] * 0.5 + 0.5) * e), a = i[r * n + o];
return a > -1 && a < t[2];
}, pn = [-0.99, 0.99], hn = [-0.99, 0.99], Vt = 1, mn = Vt * 2, vn = 3, Si = 5, Li = new $(), He = new $();
let gn = 0, St, Lt, zt, Rt, Et;
const xn = new Jn(), yn = new Jn();
function bn(t, n, e) {
const i = t.state.scaleFactor, o = Ci[t.state.quadrant], r = Mi[o[n]], a = t.state.labelWidht || 0, l = t.state.labelHeight || 0, u = a * i, s = l * i, c = qo([u, s], r), f = [Math.cos(r), -Math.sin(r)], y = t.layer.labelOffset * i, m = [
(t.state.screenPosition[0] * 0.5 + 0.5) * e.x + f[0] * y,
(-t.state.screenPosition[1] * 0.5 + 0.5) * e.y + f[1] * y
];
t.state.anchorPosition = m, t.state.scaledOffset = [
(a - u) / 2,
(l - s) / 2
], t.state.labelPosition = [
m[0] - u / 2 + c[0],
m[1] - s / 2 + c[1]
];
}
function _n(t, n, e, i) {
t.state.visible && (t.state.positionSlot !== n || t.state.prevQuadrant && t.state.prevQuadrant !== t.state.quadrant) && e && (t.state.inTransition = !0, t.state.transitionTime = 0, t.state.prevLabelPosition = e, i && (t.state.prevAnchorPosition = i));
}
function zi(t, n, e, i) {
const o = e.elapsedTime - gn, a = n.fov * Qe / 180;
n.getWorldDirection(Li);
let l = 0;
const u = [];
return t.forEach((s, c) => {
s.state.capped = !1, s.state._needsUpdate = !1, s.state.visible || (s.state.health = 0, s.state.prevAnchorPosition = void 0, s.state.prevLabelPosition = void 0), s.state.kill ? s.state.health === 0 ? (s.state.kill = !1, s.state.visible = !1) : s.state.health > 0 && (s.state.health = Math.max(
0,
s.state.health - o * vn
)) : s.state.health < 1 && (s.state.health = Math.min(
1,
Math.max(0, s.state.health + o * vn)
)), s.state.inTransition && (s.state.transitionTime += o * Si, s.state.transitionTime >= 1 && (s.state.inTransition = !1, s.state.transitionTime = 0, s.state.prevAnchorPosition = void 0, s.state.prevLabelPosition = void 0)), He.set(...s.annotation.position);
const f = He.distanceTo(n.position), y = Math.max(
0.25,
Math.min(
1,
1 / (2 * Math.tan(a / 2) * f) * s.layer.distanceFactor
)
);
He.project(n);
const m = [He.x, He.y, He.z], g = m[2] >= 0 && m[2] <= 1 && m[0] >= pn[0] && m[0] <= pn[1] && m[1] >= hn[0] && m[1] <= hn[1] && (!s.layer.minDistance || f >= s.layer.minDistance) && (!s.layer.maxDistance || f <= s.layer.maxDistance);
if (s.state.screenPosition = m, s.state.distance = f, s.state.scaleFactor = y, s.state.inViewSpace = g, s.state.cooldown && s.state.visible === !1)
s.state.cooldown = Math.max(0, s.state.cooldown - o), s.rank = 0;
else {
const p = xe(
(m[0] ** 2 + m[1] ** 2) / 2,
0,
1
), x = Math.min(f, 1e3);
s.rank = 1e3, s.rank += s.priority * 1e3 - (p * 100 + x), s.state.visible ? s.rank += 100 : s.rank -= 100, g && l < i ? (l++, s.state.prevQuadrant = s.state.quadrant, s.state.quadrant = s.annotation.direction ? Pi(
m,
s.annotation.position,
s.annotation.direction,
n
) : 0) : (s.state.quadrant = 0, s.state.visible = !1, c >= i && (s.state.capped = !0));
}
s.state.boost && (s.state.kill = !1, s.state.cooldown = 0, s.state.visible = !0, s.rank += 1e5, s.state.positionSlot = 0, s.state.boost = !1), s.state.inViewSpace && !s.state.capped ? u.push(s) : s.state._visibility !== "hidden" && (s.state.visible = !1, s.state._visibility = "hidden", s.state._needsUpdate = !0);
}), gn = e.elapsedTime, u.sort((s, c) => c.rank - s.rank), u;
}
async function Ri(t, n, e, i) {
t.forEach((o) => {
const r = ki(
o.position,
e,
i,
n
);
!o.instance.state.occluded && r && (o.instance.state.kill = !0), o.instance.state.occluded = r;
});
}
function Ei(t, n) {
xn.clear(), yn.clear(), t.forEach((e) => {
var l;
const i = e.state.labelPosition ? [...e.state.labelPosition] : null, o = e.state.anchorPosition ? [...e.state.anchorPosition] : null, r = e.state.positionSlot || 0, a = (l = e.ref) == null ? void 0 : l.current;
if (a && (e.state.labelWidht = a.clientWidth, e.state.labelHeight = a.clientHeight), e.state.kill || e.state.occluded)
bn(e, r, n), _n(
e,
r,
i,
o
);
else if (e.state.cooldown)
e.state.visible = !1;
else {
let u = !1;
const s = r === 0 ? [0, 1] : [1, 0], c = e.state.labelWidht, f = e.state.labelHeight, y = c * e.state.scaleFactor, m = f * e.state.scaleFactor;
for (let g = 0; g < s.length; g++) {
bn(e, s[g], n);
const p = {
minX: e.state.labelPosition[0] - Vt,
minY: e.state.labelPosition[1] - Vt,
maxX: e.state.labelPosition[0] + y + mn,
maxY: e.state.labelPosition[1] + m + mn
}, x = e.state.scaleFactor >= 0.5 ? xn : yn;
if (!x.collides(p)) {
x.insert(p), u = !0, _n(
e,
s[g],
i,
o
), e.state.positionSlot = s[g];
break;
}
}
u ? e.state.visible = !0 : (e.state.kill = !0, e.state.cooldown = 2.5);
}
e.state.visible ? (e.state.zIndex = e.state.labelHovered ? 1e6 : e.state.kill ? 0 : Math.round(1 / e.state.distance * 1e5), e.state.opacity = Math.max(0.75, e.state.scaleFactor) * e.state.health, e.state.inTransition && e.state.prevLabelPosition ? [Rt, Et] = Kn(
e.state.prevLabelPosition,
e.state.labelPosition,
e.state.transitionTime
) : [Rt, Et] = e.state.labelPosition, e.state.labelX = Rt - e.state.scaledOffset[0], e.state.labelY = Et - e.state.scaledOffset[1], a && (St = `translate(${e.state.labelX}px,${e.state.labelY}px) scale(${e.state.scaleFactor})`, St !== e.state._transform && (e.state._transform = St, e.state._needsUpdate = !0), Lt = `${e.state.opacity}`, Lt !== e.state._opacity && (e.state._opacity = Lt, e.state._needsUpdate = !0), zt = `${e.state.zIndex}`, zt !== e.state._zIndex && (e.state._zIndex = zt, e.state._needsUpdate = !0), e.state._visibility !== "visible" && (e.state._visibility = "visible", e.state._needsUpdate = !0))) : e.state._visibility !== "hidden" && (e.state._visibility = "hidden", e.state._needsUpdate = !0);
});
}
function wn(t) {
t.filter((n) => n.state._needsUpdate).forEach((n) => {
var i;
const e = (i = n.ref) == null ? void 0 : i.current;
e && (n.state._transform && (e.style.transform = n.state._transform), n.state._opacity && (e.style.opacity = n.state._opacity), n.state._zIndex && (e.style.zIndex = n.state._zIndex), n.state._visibility && (e.style.visibility = n.state._visibility));
});
}
const Tn = 512, An = 512, Dt = new $(), fe = new he();
let lt, It, ct, Ot;
const Es = ({ maxVisible: t = 100, children: n }) => {
const { gl: e } = yt(), i = me((u) => u.instances), o = j(!1), r = me((u) => u.clear), a = C(() => {
const u = Mo().getContext("2d");
if (!u) return null;
const s = new Co(-1, 1, 1, -1, 0, 1), c = new bt({ transparent: !0 }), f = new Po(), y = new ko(2, 2), m = new ht(y, c);
return f.add(m), {
postCamera: s,
postScene: f,
postMaterial: c,
size: new he(),
texture: null,
ctx: u
};
}, []), l = C(() => {
const u = e.domElement.parentElement;
let s = null;
if (!u) throw Error("Unable to create root!");
return s = document.createElement("div"), s.setAttribute("id", "annotations"), s.setAttribute("style", "position:absolute;top:0;left:0;z-index: 1;pointer-events:none;padding:0;width:100%;height:100%;user-select:none"), u.appendChild(s), Ao(s);
}, [e]);
return L(() => (l.render(/* @__PURE__ */ T(Ai, {})), () => {
l.unmount(), r();
}), [l, r]), De(({ gl: u, camera: s, scene: c, clock: f, pointer: y }) => {
var m;
if (u.getSize(fe), u.clear(), u.render(c, s), a) {
const { postCamera: g, postScene: p, ctx: x, postMaterial: v } = a;
if (x.clearRect(0, 0, fe.x, fe.y), !i.length) return;
const _ = zi(
i,
s,
f,
t
);
if (!_.length) {
wn(i);
return;
}
Ei(
_,
fe
), o.current || requestAnimationFrame(() => {
o.current = !0;
const d = _.map((A) => {
const w = A.layer.anchorOcclusionRadius, P = Xo([
s.position.x - A.annotation.position[0],
s.position.y - A.annotation.position[1],
s.position.z - A.annotation.position[2]
]);
return Dt.set(
A.annotation.position[0] + P[0] * w,
A.annotation.position[1] + P[1] * w,
A.annotation.position[2] + P[2] * w
), Dt.project(s), { instance: A, position: Dt.toArray() };
});
Qo(
u,
c,
s,
Tn,
An
).then((A) => {
if (A)
return Ri(
d,
A,
Tn,
An
);
}).finally(() => {
o.current = !1;
});
}), wn(i), (a.texture === null || a.texture.image.width !== fe.x || a.texture.image.height !== fe.y) && (x.canvas.width = fe.x, x.canvas.height = fe.y, (m = a.texture) == null || m.dispose(), a.texture = new Gn(x.canvas), v.map = a.texture);
const b = [
(y.x * 0.5 + 0.5) * fe.x,
(-y.y * 0.5 + 0.5) * fe.y
];
_.filter((d) => !d.state.occluded && !d.state.capped).sort((d, A) => A.state.distance - d.state.distance).forEach((d) => {
lt = (d.state.screenPosition[0] * 0.5 + 0.5) * fe.x, ct = (-d.state.screenPosition[1] * 0.5 + 0.5) * fe.y;
let A = d.layer.anchorSize * d.state.scaleFactor, w = !1;
if (Math.abs(b[0] - lt) <= A && Math.abs(b[1] - ct) <= A && (d.state.visible ? w = !0 : d.state.boost = !0), (d.state.labelHovered || w) && (A *= 1.5), d.layer.labelOffset > 0 && d.state.visible) {
d.state.inTransition && d.state.prevAnchorPosition ? [It, Ot] = Kn(
d.state.prevAnchorPosition,
d.state.anchorPosition,
d.state.transitionTime
) : [It, Ot] = d.state.anchorPosition;
let P = Math.max(
0.1,
d.layer.connectorWidth * d.state.scaleFactor
);
(d.state.labelHovered || w) && (P *= 2), x.globalAlpha = d.state.opacity || 0, x.beginPath(), x.moveTo(lt, ct), x.lineTo(It, Ot), x.strokeStyle = d.layer.connectorColor, x.lineWidth = P, x.stroke();
}
x.beginPath(), x.arc(lt, ct, A, 0, Zo), x.globalAlpha = d.state.visible ? 1 : 0.5, x.fillStyle = d.layer.anchorColor, x.fill(), x.globalAlpha = d.state.opacity || 0, x.strokeStyle = "black", x.lineWidth = 0.75, x.stroke();
}), a.texture.needsUpdate = !0, u.render(p, g);
}
}, 1), /* @__PURE__ */ T(ze, { children: n });
}, Di = ({ id: t, name: n }) => /* @__PURE__ */ T(
"div",
{
id: `annotation_${t}`,
style: {
minWidth: "150px",
background: "#33333390",
color: "white",
textAlign: "center",
overflow: "hidden",
borderRadius: "4px",
padding: "1px 6px",
fontFamily: "sans-serif",
fontSize: "12pt"
},
children: /* @__PURE__ */ T("div", { style: { whiteSpace: "nowrap" }, children: n })
},
t
), Ds = ({
id: t,
name: n,
priority: e = 0,
visible: i = !0,
distanceFactor: o = 100,
minDistance: r = 10,
maxDistance: a = 5e3,
anchorOcclusionRadius: l = 15,
anchorSize: u = 0.25,
anchorColor: s = "white",
connectorWidth: c = 1,
connectorColor: f = s || "white",
labelOffset: y = 100,
labelComponent: m = Di,
onClick: g,
children: p
}) => {
const x = me((d) => d.createLayer), v = me((d) => d.updateLayer), h = me((d) => d.layerExist), _ = j(null), b = C(() => ({
id: t,
name: n,
priority: e,
visible: i,
distanceFactor: o,
minDistance: r,
maxDistance: a,
labelOffset: y,
anchorOcclusionRadius: l,
anchorSize: u,
anchorColor: s,
connectorWidth: c,
connectorColor: f,
labelComponent: m,
onClick: g
}), [
t,
n,
e,
i,
l,
u,
s,
c,
f,
r,
a,
y,
o,
m,
g
]);
return _o(() => {
h(b.id) ? v(b.id, b) : _.current = x(b);
}, [
x,
v,
h,
b
]), L(() => () => {
_.current && _.current();
}, []), /* @__PURE__ */ T("group", { children: p });
}, ut = new $(), Is = ({ radius: t = 3, opacity: n = 0.1, color: e, fixedX: i, fixedY: o, fixedZ: r, renderOrder: a = 1e3 }) => {
const { controls: l } = yt(), u = j(null);
return L(() => {
function s() {
const c = l;
c && u.current ? (c.getTarget(ut), u.current.position.set(i || ut.x, o || ut.y, r || ut.z), u.current.visible = !0) : u.current && (u.current.visible = !1);
}
return l && l.addEventListener("update", s), s(), () => {
l && l.removeEventListener("update", s);
};
}, [l, i, o, r]), /* @__PURE__ */ T("group", { ref: u, visible: !1, renderOrder: a, children: /* @__PURE__ */ H("mesh", { children: [
/* @__PURE__ */ T("sphereGeometry", { args: [t] }),
/* @__PURE__ */ T("meshBasicMaterial", { color: e, transparent: !0, opacity: n, depthTest: !1, depthWrite: !1 })
] }) });
}, to = Ae({ current: 1 / 0 }), Os = ({ min: t = 0, max: n, onDemand: e = !1, children: i }) => {
const o = ne(to), r = j(null), [a, l] = F(!e);
return De(() => {
if (o && r.current) {
const u = o.current >= t && o.current < n;
e && u && !a ? nn(() => l(!0)) : e && !u && a ? nn(() => l(!1)) : r.current.visible !== u && (r.current.visible = u);
}
}), /* @__PURE__ */ T("group", { ref: r, visible: !1, children: a && i });
}, Ii = (t, n, e, i, o) => {
const r = e[0] * 0.5, a = e[1] * 0.5, [l, u] = o, s = t * e[0], c = n * e[1], f = (s - (r + l)) * i[0], y = (c - (a + u)) * i[1];
return [f, y];
}, ve = new $(), Oi = ({
scale: t,
start: n,
size: e,
units: i,
originOffset: o,
axesOffset: r,
axesTickSize: a,
plane: l,
color: u,
side: s,
trimAxesLabels: c = !1,
renderOrder: f = 2
}) => {
const [y, m] = F({ x: 0, y: 0, flipped: !1 });
De(({ camera: v }) => {
v.getWorldDirection(ve);
const h = {
x: 0,
y: 0,
flipped: !1
};
l === "xz" ? (h.flipped = ve.y > 0, h.flipped ? (h.x = ve.z < 0 ? Math.PI : 0, h.y = ve.x < 0 ? Math.PI : 0) : (h.x = ve.z > 0 ? Math.PI : 0, h.y = ve.x > 0 ? Math.PI : 0)) : l === "xy" ? (h.flipped = ve.z > 0, h.x = 0, h.y = ve.x > 0 ? Math.PI : 0) : l === "zy" && (h.flipped = ve.x > 0, h.x = 0, h.y = ve.z < 0 ? Math.PI : 0), (y.x !== h.x || y.y !== h.y || y.flipped !== h.flipped) && m(h);
});
const g = C(() => i / 7.5, [i]), p = C(() => new Q(u || "#fff"), [u]), x = C(() => {
const v = [
e[0] * 0.5,
e[1] * 0.5
], h = [
v[0] + o[0],
v[1] + o[1]
], _ = [
h[0] + xe(r[0], -v[0], v[0]),
h[1] + xe(r[1], -v[1], v[1])
], b = [
Math.floor((h[0] - h[0] % i) / i),
Math.floor((h[1] - h[1] % i) / i)
], d = [
-v[0] + h[0] % i,
-v[1] + h[1] % i
], A = [
Math.min(1e3, Math.floor((e[0] - h[0] % i) / i) + 1),
Math.min(1e3, Math.floor((e[1] - h[1] % i) / i) + 1)
], w = [], P = [], z = a * i + g * 0.6, E = [
xe(r[1] + o[1], -v[1], +v[1]),
xe(r[0] + o[0], -v[0], +v[0])
];
for (let M = c ? 1 : 0; M < A[0] - (c ? 1 : 0); M++) {
const k = [
d[0] + M * i,
E[0] + z
], I = Math.round(10 * (n[0] + (M - b[0]) * i * t[0])) / 10;
Math.abs(_[0] - (k[0] + v[0])) > i / 4 && w.push({
pos: k,
value: I,
index: `x${M}`
});
}
for (let M = c ? 1 : 0; M < A[1] - (c ? 1 : 0); M++) {
const k = [
E[1] - z,
d[1] + M * i
], I = Math.round(10 * (n[1] + (M - b[1]) * i * t[1])) / 10;
Math.abs(_[1] - (k[1] + v[1])) > i / 4 && P.push({
pos: k,
value: I,
index: `y${M}`
});
}
return { xAxis: w, yAxis: P };
}, [
e,
i,
o,
r,
a,
g,
t,
n,
c
]);
return /* @__PURE__ */ H(
"group",
{
renderOrder: f,
position: [0, 0, (y.flipped ? -1 : 1) * (i / 1e3)],
visible: s === "both" || s === "front" && !y.flipped || s === "back" && y.flipped,
children: [
x.xAxis.map((v) => /* @__PURE__ */ T(
ln,
{
characters: "123456789,.0",
position: [...v.pos, 0],
fontSize: g,
textAlign: "center",
anchorX: "center",
anchorY: "middle",
"rotation-z": y.x,
"rotation-y": y.flipped ? Math.PI : 0,
color: p,
"material-depthWrite": !1,
children: v.value
},
v.index
)),
x.yAxis.map((v) => /* @__PURE__ */ T(
ln,
{
characters: "123456789,.0",
position: [...v.pos, 0],
fontSize: g,
textAlign: "center",
anchorX: "center",
anchorY: "middle",
"rotation-z": y.y + Math.PI / 2,
"rotation-x": y.flipped ? Math.PI : 0,
color: p,
"material-depthWrite": !1,
children: v.value
},
v.index
))
]
}
);
};
var Wi = `precision highp float;
#include <common>
#include <logdepthbuf_pars_fragment>
uniform vec3 uBackground;
uniform float uBackgroundOpacity;
uniform vec2 uSize;
uniform float uCellSize;
uniform float uSubDivisions;
uniform float uOpacity;
uniform vec3 uGridColorMajor;
uniform vec3 uGridColorMinor;
uniform float uGridLineWidth;
uniform vec2 uAxesOffset;
uniform vec3 uAxesColor;
uniform float uAxesLineWidth;
uniform float uAxesTickSize;
uniform vec2 uOriginOffset;
uniform vec2 uCursorPosition;
uniform vec3 uRulerColor;
uniform float uRulerLineWidth;
uniform float uRulerOpacity;
uniform sampler2D uProjectionTexture;
uniform vec3 uProjectionColor;
uniform sampler2D uTexture;
uniform float uTextureMix;
varying vec2 vUv;
float pristineGrid(vec2 uv, vec2 lineWidth) {
vec2 uvDeriv = fwidth(uv * 2.0);
vec2 drawWidth = clamp(lineWidth, uvDeriv, vec2(0.5));
vec2 lineAA = uvDeriv * 1.5;
vec2 gridUV = 1.0 - abs(fract(uv) * 2.0 - 1.0);
vec2 grid2 = smoothstep(drawWidth + lineAA, drawWidth - lineAA, gridUV);
grid2 *= saturate(lineWidth / drawWidth);
grid2 = mix(grid2, lineWidth, clamp(uvDeriv * 2.0 - 1.0, 0.0, 1.0));
return max(grid2.x, grid2.y);
}
float pristineRadialGrid(vec2 _uv, vec2 _lineWidth, float _segments, float _cutoff) {
float angle = atan(_uv.y, _uv.x) / PI2;
float angleFrac = fract(angle);
float ddAngle = fwidth(angle * 2.0);
float ddAngleFrac = fwidth(angleFrac * 2.0);
ddAngle = ddAngle - 0.00001 < ddAngleFrac ? ddAngle : ddAngleFrac;
float dist = length(_uv);
#ifdef DYNAMICSEGMENTS
float logDist = log2(dist);
float segments = pow(2.0, max(2.0, ceil(logDist) + 2.0));
#else
float segments = max(1.0, round(_segments));
#endif
vec2 lineWidth = vec2(_lineWidth.x * segments / (dist * PI2), _lineWidth.y);
vec2 uv = vec2(angle * segments, dist);
vec2 uvDeriv = vec2(ddAngle * segments, fwidth(dist * 2.0));
vec2 drawWidth = clamp(lineWidth, uvDeriv, vec2(0.5));
vec2 lineAA = uvDeriv * 1.5;
vec2 gridUV = 1.0 - abs(fract(uv) * 2.0 - 1.0);
vec2 grid2 = smoothstep(drawWidth + lineAA, drawWidth - lineAA, gridUV);
#ifdef SATURATE
grid2 *= saturate(lineWidth / drawWidth);
#endif
grid2 *= step(_cutoff, dist);
return max(grid2.x, grid2.y);
}
float lines(vec2 uv, vec2 lineWidth) {
vec2 uvDeriv = fwidth(uv * 2.0);
vec2 drawWidth = clamp(lineWidth * uvDeriv, uvDeriv, vec2(0.5));
vec2 lineAA = uvDeriv * 1.5;
vec2 axisLine2 = smoothstep(drawWidth + lineAA, drawWidth - lineAA, abs(uv * 2.0));
axisLine2 *= saturate(lineWidth / drawWidth);
return max(axisLine2.x, axisLine2.y);
}
float ticklines(vec2 uv, vec2 offset, vec2 lineWidth, float tickSize) {
vec2 uvDeriv = fwidth(uv * 2.0);
vec2 drawWidth = clamp(lineWidth * uvDeriv, uvDeriv, vec2(0.5));
vec2 lineAA = uvDeriv * 1.5;
vec2 tickUV = 1.0 - abs(fract(uv) * 2.0 - 1.0);
vec2 tickLine2 = smoothstep(drawWidth + lineAA, drawWidth - lineAA, tickUV);
tickLine2 *= saturate(lineWidth / drawWidth);
tickLine2 *= 1.0 - step( tickSize, abs( uv.yx - offset.yx));
return max(tickLine2.x, tickLine2.y);
}
vec4 drawGrid(vec4 color, vec2 uv, vec3 lineColor, vec2 lineWidth) {
float grid = pristineGrid(uv, lineWidth);
color = mix(color, vec4(lineColor, uOpacity), grid);
return color;
}
vec4 drawRadialGrid(vec4 color, vec2 uv, vec3 lineColor, vec2 lineWidth, float segments, float cutoff) {
float grid = pristineRadialGrid(uv, lineWidth, segments, cutoff);
color = mix(color, vec4(lineColor, uOpacity), grid);
return color;
}
vec4 drawAxisLines(vec4 color, vec2 uv, vec2 originOffset, vec2 axesOffset, vec3 lineColor, vec2 lineWidth, float tickSize) {
vec2 tickOffset = axesOffset;
float axesLines = lines(uv - originOffset - axesOffset, lineWidth);
vec2 tickLineWidth = lineWidth;
float majorTicks = ticklines(uv - originOffset, tickOffset, tickLineWidth, tickSize);
float minorTicks = ticklines((uv - originOffset) * uSubDivisions, tickOffset * uSubDivisions, tickLineWidth * uSubDivisions * 0.5, tickSize * uSubDivisions * 0.5);
float lines = max(axesLines, max(minorTicks, majorTicks));
color = mix(color, vec4(lineColor, uOpacity), lines);
return color;
}
vec4 drawRulerLines(vec4 color, vec2 uv, vec3 lineColor, vec2 lineWidth, float opacity) {
float rulerLines = lines(uv, lineWidth) * opacity;
color = mix(color, vec4(lineColor, uOpacity), rulerLines);
return color;
}
void main() {
#include <logdepthbuf_fragment>
vec2 originOffset = clamp(uOriginOffset, -uSize / 2.0, uSize / 2.0) / uCellSize;
vec2 axesOffset = uAxesOffset / uCellSize;
vec2 uv = (vUv.xy - 0.5) * (uSize / uCellSize);
vec2 uvMaj = uv - originOffset;
vec2 uvMin = uvMaj * uSubDivisions;
vec4 color = vec4(uBackground, uBackgroundOpacity * uOpacity);
vec2 projectionUv = vec2(1.0 - vUv.x, vUv.y);
vec4 textureColor = texture2D(uTexture, vUv);
color = mix(color, textureColor, textureColor.a * uTextureMix);
float projection = texture2D(uProjectionTexture, projectionUv).a;
color = mix(color, vec4(uProjectionColor, uOpacity), projection);
#ifdef RADIAL
color = drawRadialGrid(color, uvMin, uGridColorMinor, vec2(uGridLineWidth * uSubDivisions * 0.75), 16.0 * uSubDivisions, 0.0);
color = drawRadialGrid(color, uvMaj, uGridColorMajor, vec2(uGridLineWidth), 16.0, 0.0);
#else
color = drawGrid(color, uvMin, uGridColorMinor, vec2(uGridLineWidth * uSubDivisions * 0.75));
color = drawGrid(color, uvMaj, uGridColorMajor, vec2(uGridLineWidth));
#endif
#ifdef RULERS
if (uCursorPosition.x > 0.0 && uCursorPosition.y > 0.0) {
color = drawRulerLines(color, vUv - uCursorPosition, uRulerColor, vec2(uRulerLineWidth), uRulerOpacity);
}
#endif
#ifdef AXES
color = drawAxisLines(color, uv, originOffset, axesOffset, uAxesColor, vec2(uAxesLineWidth), uAxesTickSize);
#endif
gl_FragColor = color;
}`, Fi = `#include <common>
#include <logdepthbuf_pars_vertex>
varying vec2 vUv;
void main() {
vec4 mvPosition = vec4(position, 1.0);
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;
vUv = uv;
#include <logdepthbuf_vertex>
}`;
const Gi = new Je(), Mn = new $(), Cn = new So(), Bi = [
[0, 0.1],
[2.5, 0.25],
[5, 0.5],
[10, 1],
[25, 2.5],
[50, 5],
[100, 10],
[250, 25],
[500, 50],
[999, 100]
], je = ({
plane: t,
size: n,
position: e = [0, 0, 0],
gridOrigin: i,
gridScale: o = [1, 1],
cellSize: r = 10,
subDivisions: a = 0,
background: l = 1056816,
backgroundOpacity: u = 1,
opacity: s = 1,
gridColorMajor: c = "#89a",
gridColorMinor: f = "#789",
gridLineWidth: y = 0.05,
showAxes: m = !0,
showAxesLabels: g = !0,
trimAxesLabels: p = !1,
axesOffset: x = void 0,
axesColor: v = "#fff",
axesLineWidth: h = y || 0.05,
axesTickSize: _ = 0.1,
originValue: b = [0, 0],
radial: d = !1,
dynamicSegments: A = !1,
showRulers: w = !1,
rulerColor: P = "#c59797",
rulerLineWidth: z = 1,
rulerOpacity: E = 0.5,
planeOffset: M = 0,
dynamicCellSize: k = !1,
cellSizeDistanceFactors: I = Bi,
side: G = "both",
onRulerUpdate: K = null,
texture: S,
textureMix: O = 1,
enableProjection: D = !1,
projectionDistance: V = 1e3,
projectionColor: Y = "#456",
projectionResolution: te = 1024,
projectionRefreshRate: _e = 100,
name: q,
userData: At,
renderOrder: Fe,
visible: B,
castShadow: Mt,
receiveShadow: Ne,
layers: ie
}) => {
const [ee, Ge] = F({ originOffset: [0, 0], axesOffset: [0, 0] }), [Ye, tt] = F(1), ue = C(() => new Lo(), []), we = C(() => new $(), []), ke = j(null), Ct = j(null), Pt = j(null), N = j({
uSize: new R(new he(0, 0)),
uBackground: new R(new Q(1056816)),
uBackgroundOpacity: new R(1),
uOpacity: new R(1),
uCellSize: new R(10),
uSubDivisions: new R(0),
uOriginOffset: new R(new he(0, 0)),
uDistanceFactor: new R(0),
uGridColorMajor: new R(new Q("#abc")),
uGridColorMinor: new R(new Q("#789")),
uGridLineWidth: new R(0.05),
uAxesOffset: new R(new he(0, 0)),
uAxesColor: new R(new Q("#fff")),
uAxesLineWidth: new R(1),
uAxesTickSize: new R(0.1),
uCursorPosition: new R(new he()),
uRulerColor: new R(new Q("#fff")),
uRulerLineWidth: new R(1),
uRulerOpacity: new R(0.5),
uProjectionTexture: new R(void 0),
uProjectionColor: new R(new Q("#456")),
uTexture: new R(void 0),
uTextureMix: new R(1)
}), { controls: Be, camera: nt, gl: Ue, scene: ot } = yt(), ho = C(() => [
(t === "zy" ? M : 0) + e[0],
(t === "xz" ? M : 0) + e[1],
(t === "xy" ? M : 0) + e[2]
], [t, M, e]), kt = C(() => t === "xz" ? [o[0], -o[1]] : t === "zy" ? [-o[0], o[1]] : [...o], [o, t]), mo = C(() => G === "back" ? Yt : G === "both" ? Ie : mt, [G]);
L(() => {
const Z = ke.current;
if (Z) {
Z.getWorldPosition(we);
const W = { originOffset: [0, 0], axesOffset: [0, 0] };
i ? t === "xz" ? (W.originOffset[0] = i[0] - we.x, W.originOffset[1] = -(i[1] - we.z)) : t === "xy" ? (W.originOffset[0] = i[0] - we.x, W.originOffset[1] = i[1] - we.y) : t === "zy" && (W.originOffset[0] = -(i[0] - we.z), W.originOffset[1] = i[1] - we.y) : (W.originOffset[0] = 0, W.originOffset[1] = 0), x ? t === "xz" ? (W.axesOffset[0] = x[0] * o[0] - W.originOffset[0], W.axesOffset[1] = -x[1] * o[1] - W.originOffset[1]) : t === "xy" ? (W.axesOffset[0] = x[0] * o[0] - W.originOffset[0], W.axesOffset[1] = x[1] * o[1] - W.originOffset[1]) : t === "zy" && (W.axesOffset[0] = -x[0] * o[0] - W.originOffset[0], W.axesOffset[1] = x[1] * o[1] - W.originOffset[1]) : (W.axesOffset[0] = 0, W.axesOffset[1] = 0), t === "xz" ? ue.normal.set(0, 1, 0) : t === "xy" ? ue.normal.set(0, 0, 1) : t === "zy" && ue.normal.set(1, 0, 0), ue.constant = we.length(), Ge((de) => de.axesOffset[0] !== W.axesOffset[0] || de.axesOffset[1] !== W.axesOffset[1] || de.originOffset[0] !== W.originOffset[0] || de.originOffset[1] !== W.originOffset[1] ? W : de);
}
}, [t, i, x, o, ue, we]), L(() => {
N.current.uBackground.value = new Q(l ?? 7368816), N.current.uBackgroundOpacity.value = u, N.current.uSize.value.set(...n), N.current.uOpacity.value = Number.isFinite(s) ? xe(s, 0, 1) : 1, N.current.uCellSize.value = r * Ye, N.current.uSubDivisions.value = a, N.current.uGridColorMajor.value.set(c), N.current.uGridColorMinor.value.set(f), N.current.uGridLineWidth.value = y, N.current.uAxesLineWidth.value = h, N.current.uAxesColor.value.set(v), N.current.uAxesTickSize.value = _, N.current.uAxesOffset.value.set(...ee.axesOffset), N.current.uOriginOffset.value.set(...ee.originOffset), N.current.uRulerLineWidth.value = z, N.current.uRulerColor.value.set(P), N.current.uRulerOpacity.value = E, N.current.uTexture.value = S, N.current.uTextureMix.value = O, N.current.uProjectionColor.value.set(Y);
}, [
n,
r,
Ye,
a,
l,
u,
s,
c,
f,
v,
h,
_,
y,
P,
z,
E,
ee,
S,
O,
Y
]), L(() => {
function Z() {
if (ke.current && nt) {
nt.getWorldDirection(Mn), Cn.set(nt.position, Mn);
const W = Cn.distanceToPlane(ue);
if (W) {
const de = Math.min(W, 1e3 * r) / r;
let Me = I.findIndex((rt) => rt[0] >= de);
Me === -1 ? Me = I.length - 1 : Me--, Me = Math.max(0, Me);
const it = I[Me][1];
tt((rt) => rt !== it ? it : rt);
}
}
}
return ke.current && Be && k ? (Be.addEventListener("update", Z), Z()) : tt(1), () => {
Be == null || Be.removeEventListener("update", Z);
};
}, [Be, nt, ue, k, r, I, n]), L(() => {
Ct.current && (Ct.current.needsUpdate = !0);
}, [d, m, A, w]), L(() => {
let Z = null, W = null;
return D && (Z = new Bn(te, te, {
minFilter: Ze,
magFilter: Ze,
type: zo
}), N.current.uProjectionTexture.value = Z.texture, W = setInterval(() => {
if (Z && ke.current && Pt.current) {
const Me = Pt.current, it = Ue.getRenderTarget();
Ue.setRenderTarget(Z), ot.overrideMaterial = Gi, ke.current.visible = !1, Ue.clear(), Ue.render(ot, Me), ot.overrideMaterial = null, Ue.setRenderTarget(it), ke.current.visible = !0;
}
}, _e)), () => {
W && clearInterval(W), Z == null || Z.dispose();
};
}, [D, Ue, ot, n, V, te, _e]);
const vo = ae((Z) => {
var W, de;
N.current.uCursorPosition.value.set(((W = Z.uv) == null ? void 0 : W.x) || 0, ((de = Z.uv) == null ? void 0 : de.y) || 0), K && Z.uv && K(Ii(Z.uv.x, Z.uv.y, n, kt, ee.originOffset));
}, [n, kt, ee.originOffset, K]), go = ae(() => {
N.current.uCursorPosition.value.set(0, 0), K && K(null);
}, [K]);
return /* @__PURE__ */ H(
"group",
{
ref: ke,
name: q,
userData: At,
visible: B,
"rotation-x": t === "xz" ? -Math.PI / 2 : 0,
"rotation-y": t === "zy" ? Math.PI / 2 : 0,
position: ho,
renderOrder: Fe,
children: [
/* @__PURE__ */ H(
"mesh",
{
"position-z": -1e-3 * r,
onPointerMove: w ? vo : void 0,
onPointerLeave: w ? go : void 0,
renderOrder: 1,
castShadow: Mt,
receiveShadow: Ne,
layers: ie,
children: [
/* @__PURE__ */ T(
"planeGeometry",
{
args: n
}
),
/* @__PURE__ */ T(
"shaderMaterial",
{
ref: Ct,
uniforms: N.current,
defines: {
RADIAL: d,
DYNAMICSEGMENTS: A,
AXES: !!m,
RULERS: !!w,
SATURATE: !0
},
vertexShader: Fi,
fragmentShader: Wi,
side: mo,
depthWrite: !0,
depthTest: !0,
forceSinglePass: !0,
transparent: !0
}
),
m && g && /* @__PURE__ */ T(
Oi,
{
originOffset: ee.originOffset,
axesOffset: ee.axesOffset,
trimAxesLabels: p,
scale: kt,
size: n,
start: b,
units: r * Ye,
axesTickSize: _,
plane: t,
color: v,
side: G,
renderOrder: Fe !== void 0 && Number.isFinite(Fe) ? Fe + 1 : void 0
}
)
]
}
),
D && /* @__PURE__ */ T(
"orthographicCamera",
{
ref: Pt,
args: G === "back" ? [n[0] / 2, n[0] / -2, n[1] / 2, n[1] / -2, 1, V] : [n[0] / -2, n[0] / 2, n[1] / 2, n[1] / -2, 1, V],
"rotation-y": G === "back" ? 0 : Math.PI
}
)
]
}
);
}, _t = Ae(null), Ws = (t) => {
const n = ne(_t), [e, i] = F({
origin: [0, 0],
originValue: [0, 0],
gridScale: [1, 1]
});
return L(() => {
const o = n.getWorldPosition();
let r, a, l;
t.plane === "xz" ? (r = [o[0], o[2]], l = [1, -1], a = t.relativeValues ? [0, 0] : [n.originUtm[0], n.originUtm[1]]) : t.plane === "xy" ? (r = [o[0], o[1]], l = [1, 1], a = t.relativeValues ? [0, 0] : [n.originUtm[0], 0]) : (r = [o[2], o[1]], l = [-1, 1], a = t.relativeValues ? [0, 0] : [n.originUtm[1], 0]), i({ origin: r, originValue: a, gridScale: l });
}, [n, t.plane, t.relativeValues]), /* @__PURE__ */ T(je, { ...t, gridOrigin: e.origin, originValue: e.originValue, gridScale: e.gridScale });
}, Se = new Un();
function no(t, n) {
t.updateWorldMatrix(!1, !1);
const e = t.geometry;
e !== void 0 && (t.boundingBox !== void 0 ? (t.boundingBox === null && t.computeBoundingBox(), Se.copy(t.boundingBox)) : (e.boundingBox === null && e.computeBoundingBox(), Se.copy(e.boundingBox)), isNaN(Se.min.x) || isNaN(Se.min.y) || isNaN(Se.min.z) || (Se.applyMatrix4(t.matrixWorld), n.union(Se)));
const i = t.children;
for (let o = 0, r = i.length; o < r; o++)
no(i[o], n);
return n;
}
const Ke = new $(), qe = new $(), J = new Un(), Ui = (t) => {
const n = j(null), e = j({ center: [0, 0, 0], size: [0, 0, 0] }), {
padding: i = [0, 0, 0],
snapTo: o,
updateRate: r = 1e3,
enabled: a = !0,
onChange: l
} = t, u = C(() => {
if (Number.isFinite(i)) {
const s = i;
return {
x0: s,
x1: s,
y0: s,
y1: s,
z0: s,
z1: s
};
} else if (Array.isArray(i)) {
const s = i;
return {
x0: s[0],
x1: s[0],
y0: s[1],
y1: s[1],
z0: s[2],
z1: s[2]
};
} else if (i !== void 0) {
const s = i;
return {
x0: s.x0 || 0,
x1: s.x1 || 0,
y0: s.y0 || 0,
y1: s.y1 || 0,
z0: s.z0 || 0,
z1: s.z1 || 0
};
}
return {
x0: 0,
x1: 0,
y0: 0,
y1: 0,
z0: 0,
z1: 0
};
}, [i]);
return L(() => {
let s = null;
return l && a && (s = setInterval(() => {
l && n.current && n.current.children.length && (J.makeEmpty(), no(n.current, J), o ? (J.min.set(
Math.floor((J.min.x - u.x0) / o) * o,
Math.floor((J.min.y - u.y0) / o) * o,
Math.floor((J.min.z - u.z0) / o) * o
), J.max.set(
Math.ceil((J.max.x + u.x1) / o) * o,
Math.ceil((J.max.y + u.y1) / o) * o,
Math.ceil((J.max.z + u.z1) / o) * o
)) : (J.min.set(
J.min.x - u.x0,
J.min.y - u.y0,
J.min.z - u.z0
), J.max.set(
J.max.x + u.x1,
J.max.y + u.y1,
J.max.z + u.z1
)), J.getCenter(Ke), J.getSize(qe), (Ke.x !== e.current.center[0] || Ke.y !== e.current.center[1] || Ke.z !== e.current.center[2] || qe.x !== e.current.size[0] || qe.y !== e.current.size[1] || qe.z !== e.current.size[2]) && (e.current.center = Ke.toArray(), e.current.size = qe.toArray(), l(e.current)));
}, r)), () => {
s && clearInterval(s);
};
}, [u, o, r, a, l]), /* @__PURE__ */ T("group", { ...t, ref: n });
}, Pn = new $(), Fs = ({
name: t,
visible: n,
castShadow: e,
receiveShadow: i,
layers: o,
renderOrder: r,
userData: a,
size: l = [0, 0, 0],
cellSize: u = 10,
gridScale: s = [1, 1, 1],
gridOrigin: c = [0, 0, 0],
originValue: f = [0, 0, 0],
subDivisions: y = 5,
position: m = [0, 0, 0],
gridLineWidth: g = 0.02,
background: p = 1056816,
backgroundOpacity: x = 1,
opacity: v = 1,
gridColorMajor: h = "#89a",
gridColorMinor: _ = "#789",
axesColor: b = "#fff",
axesLineWidth: d = g || 0.05,
axesTickSize: A = 0.1,
enableProjection: w,
projectionColor: P,
projectionResolution: z = 2048,
projectionRefreshRate: E,
showRulers: M = !1,
autoSize: k = !1,
autoSizePadding: I = 0,
autoSizeUpdateRate: G = 1e3,
children: K
}) => {
const [S, O] = F(m), [D, V] = F(l), Y = j(null), [te, _e] = F(S);
return L(() => {
k || (O((q) => q[0] !== m[0] || q[1] !== m[1] || q[2] !== m[2] ? m : q), V((q) => q[0] !== l[0] || q[1] !== l[1] || q[2] !== l[2] ? l : q));
}, [l, m, k]), L(() => {
Y.current && (Y.current.getWorldPosition(Pn), _e(Pn.toArray()));
}, [S]), /* @__PURE__ */ H(
"group",
{
ref: Y,
name: t,
userData: a,
visible: n,
renderOrder: r,
children: [
/* @__PURE__ */ T(
je,
{
plane: "xz",
originValue: [f[0], f[2]],
cellSize: u,
size: [D[0], D[2]],
position: [S[0], S[1] - D[1] * 0.5, S[2]],
gridScale: [s[0], s[2]],
gridOrigin: [c[0], c[2]],
subDivisions: y,
gridLineWidth: g,
background: p,
backgroundOpacity: x,
gridColorMajor: h,
gridColorMinor: _,
opacity: v,
axesColor: b,
axesLineWidth: d,
axesTickSize: A,
trimAxesLabels: !0,
side: "both",
enableProjection: w,
projectionResolution: z,
projectionColor: P,
projectionDistance: D[1],
projectionRefreshRate: E,
showRulers: M,
castShadow: e,
receiveShadow: i,
layers: o
}
),
/* @__PURE__ */ T(
je,
{
plane: "xy",
originValue: [f[0], f[1]],
cellSize: u,
size: [D[0], D[1]],
position: [S[0], S[1], S[2] - D[2] * 0.5],
gridScale: [s[0], s[1]],
axesOffset: [(-te[0] - S[0]) / s[0], D[1] * 0.5 * s[1]],
gridOrigin: [c[0], c[1]],
subDivisions: y,
gridLineWidth: g,
background: p,
backgroundOpacity: x,
gridColorMajor: h,
gridColorMinor: _,
opacity: v,
axesColor: b,
axesLineWidth: d,
axesTickSize: A,
trimAxesLabels: !0,
side: "front",
enableProjection: w,
projectionResolution: z,
projectionColor: P,
projectionDistance: D[2],
projectionRefreshRate: E,
showRulers: M,
castShadow: e,
receiveShadow: i,
layers: o
}
),
/* @__PURE__ */ T(
je,
{
plane: "zy",
originValue: [f[2], f[1]],
cellSize: u,
size: [D[2], D[1]],
position: [S[0] - D[0] * 0.5, S[1], S[2]],
gridScale: [s[2], s[1]],
axesOffset: [(-te[2] - S[2]) / s[2], D[1] * 0.5 * s[1]],
gridOrigin: [c[2], c[1]],
subDivisions: y,
gridLineWidth: g,
background: p,
backgroundOpacity: x,
gridColorMajor: h,
gridColorMinor: _,
opacity: v,
axesColor: b,
axesLineWidth: d,
axesTickSize: A,
trimAxesLabels: !0,
side: "front",
enableProjection: w,
projectionResolution: z,
projectionColor: P,
projectionDistance: D[0],
projectionRefreshRate: E,
showRulers: M,
castShadow: e,
receiveShadow: i,
layers: o
}
),
/* @__PURE__ */ T(
je,
{
plane: "xy",
originValue: [f[0], f[1]],
cellSize: u,
size: [D[0], D[1]],
position: [S[0], S[1], S[2] + D[2] * 0.5],
gridScale: [s[0], s[1]],
axesOffset: [(-te[0] - S[0]) / s[0], D[1] * 0.5 * s[1]],
gridOrigin: [c[0], c[1]],
subDivisions: y,
gridLineWidth: g,
background: p,
backgroundOpacity: x,
gridColorMajor: h,
gridColorMinor: _,
opacity: v,
axesColor: b,
axesLineWidth: d,
axesTickSize: A,
trimAxesLabels: !0,
side: "back",
enableProjection: w,
projectionResolution: z,
projectionColor: P,
projectionDistance: D[2],
projectionRefreshRate: E,
showRulers: M,
castShadow: e,
receiveShadow: i,
layers: o
}
),
/* @__PURE__ */ T(
je,
{
plane: "zy",
originValue: [f[2], f[1]],
cellSize: u,
size: [D[2], D[1]],
position: [S[0] + D[0] * 0.5, S[1], S[2]],
gridScale: [s[2], s[1]],
axesOffset: [(-te[2] - S[2]) / s[2], D[1] * 0.5 * s[1]],
gridOrigin: [c[2], c[1]],
subDivisions: y,
gridLineWidth: g,
background: p,
backgroundOpacity: x,
gridColorMajor: h,
gridColorMinor: _,
opacity: v,
axesColor: b,
axesLineWidth: d,
axesTickSize: A,
trimAxesLabels: !0,
side: "back",
enableProjection: w,
projectionResolution: z,
projectionColor: P,
projectionDistance: D[0],
projectionRefreshRate: E,
showRulers: M,
castShadow: e,
receiveShadow: i,
layers: o
}
),
k && /* @__PURE__ */ T(
Ui,
{
padding: I,
updateRate: G,
snapTo: u,
onChange: (q) => {
V(q.size), O(q.center);
},
children: K
}
),
!k && K
]
}
);
}, oo = Ae(null), Zt = () => ne(oo), Hi = (t, n = 1, e = 1) => [
t[0] / n * 2 - 1,
-(t[1] / e) * 2 + 1
], ji = (t, n = 1, e = 1) => [
(t[0] + 1) / 2 * n,
(1 - t[1]) / 2 * e
], Wt = new $(), Vi = [
[0],
[4, 3, 1, 5, 7, 0, 2, 6, 8],
[
12,
11,
7,
13,
17,
6,
8,
16,
18,
10,
2,
14,
22,
5,
1,
3,
9,
15,
21,
19,
23,
0,
4,
20,
24
],
[
24,
23,
17,
25,
31,
16,
18,
30,
32,
22,
10,
26,
38,
15,
9,
11,
19,
33,
39,
37,
28,
8,
12,
40,
36,
21,
3,
27,
45,
28,
14,
2,
4,
20,
34,
46,
44,
7,
1,
5,
13,
41,
47,
43,
35,
0,
6,
48,
42
]
], $i = {
threshold: 2
};
class io {
constructor(n = {}) {
se(this, "_size");
se(this, "_threshold");
se(this, "_renderTarget");
se(this, "_pixelBuffer");
se(this, "_currentId", 0);
const { threshold: e } = { ...$i, ...n };
this._threshold = Math.max(Math.min(3, e), 0), this._size = 2 * this._threshold + 1;
const i = new Ro(this._size, this._size);
this._renderTarget = new Bn(this._size, this._size, {
colorSpace: jn,
format: Hn,
type: Eo,
generateMipmaps: !1,
stencilBuffer: !1,
depthBuffer: !0,
depthTexture: i
}), this._pixelBuffer = new Uint8Array(4 * this._size ** 2);
}
async pick(n, e, i, o, r, a, l = !0) {
const u = (this._currentId + 1) % 1e4;
this._currentId = u;
const { _renderTarget: s, _pixelBuffer: c, _threshold: f, _size: y } = this, m = e.getContext().drawingBufferWidth, g = e.getContext().drawingBufferHeight, p = ji(n, m, g), x = p[0] - f, v = p[1] - f;
r.forEach((d) => {
const A = d.source.material;
if (d.source.material = d.material, d.material = A, d.instanced) {
const w = d.source, P = new Float32Array(w.instanceColor.array);
w.instanceColor.set(d.instanceColor), w.instanceColor.needsUpdate = !0, d.instanceColor = P;
}
}), o.setViewOffset(m, g, x, v, y, y);
const h = o.layers.mask;
if (o.layers.disableAll(), o.layers.set(oe.EMITTER), e.setRenderTarget(s), e.clear(), e.render(i, o), e.setRenderTarget(null), o.clearViewOffset(), o.layers.mask = h, r.forEach((d) => {
if (d.source.material = d.material, d.instanced) {
const A = d.source;
A.instanceColor.set(d.instanceColor), A.instanceColor.needsUpdate = !0, d.instanceColor = void 0;
}
}), await e.readRenderTargetPixelsAsync(
s,
0,
// x
0,
// y
y,
// width
y,
// height
c
), !l && u !== this._currentId) return !1;
const _ = Vi[f], b = {
match: null,
position: null
};
for (let d = 0; d < _.length; d++) {
const A = _[d], w = A * 4, P = c[w] << 16 | c[w + 1] << 8 | c[w + 2], z = a.map.get(P);
if (z) {
b.match = z;
const E = A % y - f, M = f - ~~(A / y), k = Hi(
[p[0] + E, p[1] + M],
m,
g
), I = Jo(
this._renderTarget.depthTexture,
e,
o,
w
).then((G) => {
const K = G;
return Wt.set(k[0], k[1], K), Wt.unproject(o), Wt.toArray();
});
b.position = I;
break;
}
}
return b;
}
dispose() {
this._renderTarget.dispose();
}
}
const Gs = new io({ threshold: 3 }), Ni = 300, kn = 10, Sn = (t) => {
t.emitters.clear(), t.objectMap.map.clear(), t.objectMap.index = 1, t.pickingMaterials.index = 0, t.listeners.forEach((n) => ro(n.object, t, n.object.id, 0));
};
function ro(t, n, e, i) {
if (t.visible && !t.layers.isEnabled(oe.NOT_EMITTER)) {
if (t.type === "Mesh" || t.type === "Line" || t.type === "Points") {
let o = n.emitters.get(t.id);
if (!o) {
if (n.pickingMaterials.index >= n.pickingMaterials.pool.length) {
const a = n.pickingMaterials.pool.length || 100;
for (let l = 0; l < a; l++)
n.pickingMaterials.pool.push(new bt());
}
const r = n.pickingMaterials.pool[n.pickingMaterials.index];
if (o = {
source: t,
material: r,
depth: i,
listener: null
}, r.side = o.source.material.side, t.isInstancedMesh) {
const a = t;
o.instanced = !0, o.instanceColor = new Float32Array(a.count * 3), t.frustumCulled = !1, r.color.set(16777215);
for (let l = 0; l < a.count; l++) {
const u = n.objectMap.index++;
n.objectMap.map.set(u, { emitter: o, index: l }), new Q(cn(u)).toArray(o.instanceColor, l * 3);
}
a.instanceColor || (a.instanceColor = new Vn(new Float32Array(o.instanceColor.length).fill(1), 3));
} else {
const a = n.objectMap.index++;
r.color.set(cn(a)), n.objectMap.map.set(a, { emitter: o });
}
n.emitters.set(t.id, o), n.pickingMaterials.index++;
}
(!o.listener || o.depth > i) && (o.listener = e, o.depth = i), t.layers.enable(oe.EMITTER);
}
for (let o = 0; o < t.children.length; o++)
ro(t.children[o], n, e, i + 1);
}
}
const Bs = ({ children: t }) => {
const { gl: n, camera: e, scene: i, pointer: o } = yt(), r = C(() => ({
current: null,
previous: null,
buttonDown: !1,
needCheckOnMove: !1,
posX: -1,
posY: -1,
deltaTime: 0,
pickingHelper: new io(),
emitters: /* @__PURE__ */ new Map(),
listeners: /* @__PURE__ */ new Map(),
objectMap: { map: /* @__PURE__ */ new Map(), index: 0 },
pickingMaterials: { index: 0, pool: [] },
moveTest: !1
}), []), a = C(() => ({
register: (s, c, f) => (r.listeners.set(s.id, { object: s, handlers: c, ref: f }), (c.enter || c.leave || c.move) && (r.needCheckOnMove = !0), () => {
s.traverse((y) => y.layers.disable(oe.EMITTER)), r.listeners.delete(s.id);
})
}), [r]), l = ae((s, c, f, y, m) => {
r.moveTest = !0, Sn(r), r.pickingHelper.pick(y, s, f, c, r.emitters, r.objectMap).then((g) => {
if (g) {
if (r.current = g.match, r.previous && (!r.current || r.current.emitter.listener !== r.previous.emitter.listener || r.current.emitter.listener === r.previous.emitter.listener && r.current.index !== r.previous.index)) {
const p = r.listeners.get(r.previous.emitter.listener);
p && p.handlers.leave && (p.handlers.leave({
target: p.object,
source: r.previous.emitter.source,
ref: p.ref,
instanceIndex: r.previous.index,
keys: m
}), s.domElement.style.cursor = "");
}
if (r.current && (!r.previous || r.previous.emitter.listener !== r.current.emitter.listener || r.current.emitter.listener === r.previous.emitter.listener && r.current.index !== r.previous.index)) {
const p = r.listeners.get(r.current.emitter.listener);
p && p.handlers.enter && (p.handlers.enter({
target: p.object,
source: r.current.emitter.source,
ref: p.ref,
instanceIndex: r.current.index,
keys: m
}), s.domElement.style.cursor = p.handlers.click ? "pointer" : "");
}
if (r.current && (r.previous === null || r.previous.emitter.listener === r.current.emitter.listener && (!r.previous.index || r.previous.index === r.current.index))) {
const p = r.listeners.get(r.current.emitter.listener);
if (p && p.handlers.move) {
const x = r.current.emitter.source, v = r.current.index;
g.position && g.position.then((h) => {
p.handlers.move({
target: p.object,
source: x,
ref: p.ref,
instanceIndex: v,
position: h,
keys: m
});
});
}
}
r.previous = r.current, r.moveTest = !1;
}
});
}, [r]), u = ae((s, c, f, y, m) => {
Sn(r), r.pickingHelper.pick(y, s, f, c, r.emitters, r.objectMap, !0).then((g) => {
if (g && g.match) {
const p = g.match, x = r.listeners.get(p.emitter.listener);
x && x.handlers.click && g.position && g.position.then((v) => {
x.handlers.click({
position: v,
target: x.object,
source: p.emitter.source,
ref: x.ref,
instanceIndex: p.index,
keys: m
});
});
}
});
}, [r]);
return L(() => {
function s(g) {
if (!r.moveTest && r.needCheckOnMove && !r.buttonDown) {
const p = {
ctrlKey: g.ctrlKey,
shiftKey: g.shiftKey,
altKey: g.altKey
};
l(n, e, i, o.toArray(), p);
}
}
function c(g) {
g.isPrimary && (r.buttonDown = !0, r.posX = g.pageX, r.posY = g.pageY, r.deltaTime = performance.now());
}
function f(g) {
if (g.isPrimary) {
const p = performance.now();
if (r.buttonDown && p - r.deltaTime < Ni && Math.abs(g.pageX - r.posX) < kn && Math.abs(g.pageY - r.posY) < kn) {
const x = {
ctrlKey: g.ctrlKey,
shiftKey: g.shiftKey,
altKey: g.altKey
};
u(n, e, i, o.toArray(), x);
}
r.buttonDown = !1;
}
}
function y() {
r.current = null, r.previous = null;
}
function m(g) {
const p = {
ctrlKey: g.ctrlKey,
shiftKey: g.shiftKey,
altKey: g.altKey
};
setTimeout(() => {
r.needCheckOnMove && !r.buttonDown && !r.moveTest && l(n, e, i, o.toArray(), p);
}, 250);
}
return n.domElement.addEventListener("pointermove", s, { passive: !0, capture: !0 }), n.domElement.addEventListener("pointerdown", c, { passive: !0, capture: !0 }), n.domElement.addEventListener("pointerup", f, { passive: !0, capture: !0 }), n.domElement.addEventListener("pointercancel", y, { passive: !0, capture: !0 }), n.domElement.addEventListener("pointerenter", s, { passive: !0, capture: !0 }), n.domElement.addEventListener("pointerleave", s, { passive: !0, capture: !0 }), n.domElement.addEventListener("wheel", m, { passive: !0, capture: !0 }), () => {
n.domElement.removeEventListener("pointermove", s), n.domElement.removeEventListener("pointerdown", c), n.domElement.removeEventListener("pointerup", f), n.domElement.removeEventListener("pointercancel", y), n.domElement.removeEventListener("pointerenter", s), n.domElement.removeEventListener("pointerleave", s), n.domElement.removeEventListener("wheel", m);
};
}, [n, o, e, i, l, u, r]), L(() => () => {
r.current = null, r.previous = null, r.listeners.clear(), r.pickingHelper.dispose(), r.pickingMaterials.pool.splice(0, r.pickingMaterials.pool.length);
}, [r]), /* @__PURE__ */ T(oo.Provider, { value: a, children: t });
}, gt = (t, n) => n ? `${t.id}_${n}` : `${t.id}`;
function Yi(t, n, e) {
t.traverseVisible((i) => {
i.layers.isEnabled(oe.NOT_EMITTER) || (i.type === "Mesh" || i.type === "Line") && (n[gt(i, e)] = { object: i, instanceIndex: e });
});
}
function Ki(t, n, e) {
t.traverse((i) => {
(i.type === "Mesh" || i.type === "Line") && delete n[gt(i, e)];
});
}
const so = xt((t) => ({
highlighted: [],
set: t
})), Us = () => {
const t = so((n) => n.set);
return {
highlight: (n, e) => t((i) => {
const o = i.highlighted.reduce((r, a) => ({ ...r, [gt(a.object, a.instanceIndex)]: a }), {});
return Yi(n, o, e), {
highlighted: Object.values(o).filter(
(r) => r.object.layers.isEnabled(oe.EMITTER) && r.object.visible
)
};
}),
removeHighlight: (n, e) => t((i) => {
const o = i.highlighted.reduce((r, a) => ({ ...r, [gt(a.object, a.instanceIndex)]: a }), {});
return Ki(n, o, e), {
highlighted: Object.values(o).filter(
(r) => r.object.layers.isEnabled(oe.EMITTER) && r.object.visible
)
};
}),
removeAll: () => {
t({ highlighted: [] });
}
};
}, ft = new bt({
color: 4210752,
depthTest: !0,
depthWrite: !1,
transparent: !0,
opacity: 1,
blending: $n,
side: Ie
}), Ln = new Kt(), Hs = () => {
const { highlighted: t } = so(), n = C(() => t.map((e) => {
let i;
const o = e.object.geometry;
if (e.object instanceof Ht) {
const r = e.object;
if (e.instanceIndex)
i = new ht(o, ft), e.object.getWorldPosition(i.position), r.getMatrixAt(e.instanceIndex, Ln), i.applyMatrix4(Ln);
else {
const a = new Ht(o, ft, r.count);
e.object.getWorldPosition(a.position), a.instanceMatrix = r.instanceMatrix, i = a;
}
} else e.object instanceof ht ? (i = new ht(o, ft), e.object.getWorldPosition(i.position)) : (i = new Nn(o, ft), e.object.getWorldPosition(i.position));
return i.visible = e.object.visible, i;
}), [t]);
return /* @__PURE__ */ T("group", { renderOrder: 999, children: n.map((e) => /* @__PURE__ */ T("primitive", { object: e }, e.uuid)) });
}, qi = ye(({
origin: t = "bottom-left",
width: n = 400,
height: e = 600,
offset: i = [10, 10],
opacity: o = 0.8,
padding: r = 0,
children: a = null
}, l) => {
const [u, s, c, f] = C(() => t === "top-left" ? [
`${i[0]}px`,
void 0,
void 0,
`${i[1]}px`
] : t === "top-right" ? [
void 0,
void 0,
`${i[0]}px`,
`${i[1]}px`
] : t === "bottom-right" ? [
void 0,
`${i[1]}px`,
`${i[0]}px`,
void 0
] : [
`${i[0]}px`,
`${i[1]}px`,
void 0,
void 0
], [t, i]);
return /* @__PURE__ */ T(
"div",
{
ref: l,
style: {
borderRadius: 8,
position: "absolute",
display: "inline-block",
left: u,
bottom: s,
right: c,
top: f,
padding: r,
color: "white",
fontFamily: "verdana",
width: `${n}px`,
maxHeight: `${e}px`,
zIndex: 10,
pointerEvents: "none",
background: `#000000${Math.round(o * 256).toString(16).padStart(2, "0")}`
},
children: a
}
);
}), $t = xt((t, n) => ({
groups: {},
set: t,
has: (e) => n().groups[e] !== void 0
})), js = () => {
const t = $t((e) => e.set), n = $t((e) => e.has);
return {
add: (e, i) => t((o) => o.groups[e] ? o.groups : { groups: { ...o.groups, [e]: i } }),
remove: (e) => t((i) => {
const o = { ...i.groups };
return delete o[e], { groups: o };
}),
removeAll: () => t({ groups: {} }),
update: (e, i, o) => t((r) => {
const a = r.groups[e];
if (a) {
const l = a.details ? { ...a.details } : void 0;
return l && o && Object.keys(o).forEach((u) => {
l[u] && (l[u].value = o[u]);
}), { groups: {
...r.groups,
[e]: {
...a,
value: i,
details: o === null ? void 0 : l
}
} };
}
return { groups: r.groups };
}),
has: n
};
}, Vs = (t) => {
const n = $t((i) => i.groups), e = C(() => Object.values(n).sort((i, o) => (i.order || 0) - (o.order || 0)), [n]);
return /* @__PURE__ */ T(qi, { ...t, children: /* @__PURE__ */ T("div", { style: {
display: "flex",
flexDirection: "column",
padding: "0.5em 1em",
overflow: "auto"
}, children: e.map((i) => /* @__PURE__ */ H("div", { style: {
display: "flex",
flexDirection: "column",
marginTop: "0.5em",
marginBottom: "0.5em"
}, children: [
/* @__PURE__ */ T("div", { style: {
fontSize: "16px",
fontWeight: "bold",
paddingBottom: "0.2em",
borderBottom: "1px solid gray",
marginBottom: "0.25em",
color: i.color || "white"
}, children: i.label }),
i.value && /* @__PURE__ */ T("div", { style: {
fontSize: "14px"
}, children: i.value }),
i.details && /* @__PURE__ */ T("div", { style: {
display: "grid",
color: "#ccc",
gridTemplateColumns: "auto auto",
fontSize: "12px",
padding: "0.25em",
marginTop: "0.25em"
}, children: i.details && Object.keys(i.details).map((o) => /* @__PURE__ */ H(Nt, { children: [
/* @__PURE__ */ T("div", { children: i.details[o].label }),
/* @__PURE__ */ T("div", { style: { textAlign: "right" }, children: i.details[o].value })
] }, o)) })
] }, i.label)) }) });
}, wt = Ae(null), Xi = ({ depth: t, color: n }) => /* @__PURE__ */ H("div", { style: {
textAlign: "center",
fontSize: "90%",
fontFamily: "monospace",
color: n
}, children: [
t.toFixed(1),
" mD MSL"
] }), ao = Ae(null), Ce = () => {
const t = ne(ao);
if (!t) throw Error("WellMapState can only be used by children of the WellMap component!");
return t;
}, Qi = ({
wellboreId: t,
slot: n,
isSelected: e,
setSelected: i,
setDepth: o,
interactive: r,
color: a = "white"
}) => {
const l = Ce(), u = l((S) => S.wellboresById), s = l((S) => S.wellboresByName), c = l((S) => S.measures.ratio), f = l((S) => S.domain), y = l((S) => S.measures.range), m = l((S) => S.activeDepths), g = l((S) => S.slotsById), p = l((S) => S.styles), x = l((S) => S.measures.getSlotPosition), v = C(() => u[t] || null, [t, u]), h = C(() => {
var S;
if (v && v.parent) {
const O = (S = s[v.parent]) == null ? void 0 : S.id;
return O ? g[O] : 0;
}
return null;
}, [v, s, g]), _ = C(() => We().domain(f).range(y), [f, y]), [b, d] = C(() => [
x(h !== null ? h : n),
x(n)
], [n, h, x]), A = C(() => c ? Math.min(15, c * 24) : 0, [c]), w = C(() => c > 0 ? c * 10 : 0, [c]), P = ae((S, O, D, V) => {
const Y = et();
if (Y.moveTo(S, D), S !== O)
if (V - D > w) {
const te = D + w;
Y.arcTo(O, D, O, te, w);
} else
Y.lineTo(O, D);
return Y.lineTo(O, V), Y.toString();
}, [w]), { active: z, inactive: E, kickoff: M, termination: k } = C(() => {
let S = null, O = null, D = 0, V = 0, Y = null;
if (v) {
const te = m[v.id];
let _e = -v.depthReferenceElevation;
if (v.kickoffDepthMsl !== null && (_e = v.kickoffDepthMsl, Y = _(v.kickoffDepthMsl)), V = _(_e), D = _(v.depthMdMsl), te !== void 0) {
const q = _(te);
S = [b, d, V, q], q > V && (O = [d, d, q, D]);
} else
O = [b, d, V, D];
}
return { active: S, inactive: O, kickoff: Y, termination: D };
}, [_, v, m, b, d]), I = C(() => {
const S = p.darkMode ? 0 : 240;
return `rgba(${S}, ${S}, ${S}, .9)`;
}, [p.darkMode]);
if (!v) return null;
const G = w / 2, K = `${G},${G / 2}`;
return /* @__PURE__ */ H(
"g",
{
className: `track ${e ? "selected" : ""} ${r ? "interactive" : ""}`,
style: { pointerEvents: "painted", opacity: !r || e ? 1 : 0.75 },
onClick: r ? (S) => {
let O = 0;
if (o && S && S.clientY) {
const [, D] = pi(S), V = xe(D, y[0], y[1]);
O = _.invert(V), o(O);
}
i && !e && i(t, O);
} : void 0,
children: [
/* @__PURE__ */ T("title", { children: v.name }),
z && /* @__PURE__ */ T(ze, { children: /* @__PURE__ */ T(
"path",
{
d: P(...z),
stroke: a,
strokeWidth: w,
fill: "none",
style: { filter: `drop-shadow( 1px 1px 2px ${I})` }
}
) }),
E && /* @__PURE__ */ H(ze, { children: [
/* @__PURE__ */ T(
"path",
{
d: P(...E),
stroke: a,
strokeWidth: w,
fill: "none",
strokeDasharray: K,
style: { filter: `drop-shadow( 1px 1px 2px ${I})`, pointerEvents: "none" }
}
),
/* @__PURE__ */ T(
"path",
{
d: P(...E),
stroke: a,
strokeWidth: w,
strokeOpacity: 0,
fill: "none"
}
)
] }),
M && /* @__PURE__ */ T(
"circle",
{
cx: b,
cy: M,
r: w * 0.8,
fill: a,
stroke: "#00000080",
strokeWidth: 0.5,
style: { filter: `drop-shadow( 1px 1px 1px ${I})` }
}
),
A >= 8 && /* @__PURE__ */ T(
"text",
{
x: d,
y: k + A,
fontSize: `${A - 2}px`,
fill: p.textColor,
fillOpacity: e ? 1 : 0.75,
textAnchor: "middle",
dominantBaseline: "middle",
fontFamily: "monospace",
fontWeight: "bold",
style: {
textDecoration: e ? "underline" : ""
},
children: v.name.replace(v.well, "") || "Main"
}
),
c >= 0.5 && /* @__PURE__ */ H(
"text",
{
x: d,
y: k + A * 2,
fontSize: `${A * 0.75 - 2}px`,
fill: p.textColor,
fillOpacity: e ? 1 : 0.75,
textAnchor: "middle",
dominantBaseline: "top",
fontFamily: "monospace",
children: [
v.depthMdMsl,
"m"
]
}
)
]
}
);
}, Zi = ({
depth: t,
setDepth: n,
ruler: e = !0,
rulerWidth: i = 4.5
}) => {
const o = j(null), r = Ce(), a = r((v) => v.domain), l = r((v) => v.measures.range), u = r((v) => v.measures.tracksWidth), s = r((v) => v.styles), [c, f] = F(!1), y = C(() => We().domain(a).range(l), [a, l]), m = C(() => {
const v = s.depthAxisWidth * 0.65, h = et();
return h.moveTo(0, -v / 2), h.lineTo(s.depthAxisWidth / 2, -v / 2), h.lineTo(s.depthAxisWidth, 0), h.lineTo(s.depthAxisWidth / 2, v / 2), h.lineTo(0, v / 2), h.lineTo(0, -v / 2), h.toString();
}, [s.depthAxisWidth]), g = C(() => y(t), [t, y]), p = C(() => {
const v = s.darkMode ? 0 : 240;
return `rgba(${v}, ${v}, ${v}, .7)`;
}, [s.darkMode]);
L(() => {
function v(b) {
if (!o.current) return;
const d = y.range(), A = xe(b.y, d[0], d[1]), w = y.invert(A);
n && n(w);
}
function h() {
f(!0), document.body.style.cursor = "grab";
}
function _() {
f(!1), document.body.style.cursor = "";
}
if (o.current && n) {
const b = hi();
b.on("drag", v), b.on("start", h), b.on("end", _), jt(o.current).call(b);
}
}, [n, y]);
const x = ae((v) => {
if (n)
if (v.key === "ArrowDown" || v.key === "ArrowUp") {
const h = t !== void 0 ? t : a[0];
let _ = 1;
v.shiftKey ? _ *= 25 : v.ctrlKey && (_ *= 0.1);
const b = v.key === "ArrowDown" ? h + _ : h - _;
n(xe(b, a[0], a[1]));
} else v.key === "End" ? n(a[1]) : v.key === "Home" && n(a[0]);
}, [t, n, a]);
return /* @__PURE__ */ H(
"g",
{
ref: o,
tabIndex: 0,
onKeyDown: x,
style: {
pointerEvents: "painted",
cursor: "grab",
transform: `translate(0,${g}px)`,
outline: "none"
},
children: [
/* @__PURE__ */ T(
"path",
{
d: m,
stroke: s.cursorColor,
strokeWidth: 2,
fill: "rgba(256,256,256,0.25)",
filter: `drop-shadow( 1px 1px 2px ${p})`,
opacity: 0.9
}
),
e && /* @__PURE__ */ H(ze, { children: [
/* @__PURE__ */ T(
"line",
{
x1: s.depthAxisWidth,
y1: 0,
x2: s.depthAxisWidth + u,
y2: 0,
stroke: s.rulerColor,
strokeWidth: i,
strokeOpacity: 0.25
}
),
c && /* @__PURE__ */ T(
"text",
{
x: s.depthAxisWidth + u,
textAnchor: "end",
fontFamily: "monospace",
fill: s.cursorColor,
children: t.toFixed(1)
}
)
] })
]
}
);
}, Ji = ({ wellboreId: t, opacity: n = 0.75, width: e = 3, dashed: i = !1 }) => {
const o = Ce(), r = o((d) => d.wellboresById), a = o((d) => d.wellboresByName), l = o((d) => d.measures.ratio), u = o((d) => d.domain), s = o((d) => d.measures.range), c = o((d) => d.slotsById), f = o((d) => d.styles), y = o((d) => d.measures.getSlotPosition), m = C(() => r[t] || null, [t, r]), g = C(() => We().domain(u).range(s), [u, s]), p = C(() => l > 0 ? l * 10 : 0, [l]), x = C(() => {
const d = [];
if (m) {
let A = c[m.id], w = m;
const P = y(A), z = g(m.depthMdMsl);
for (d.push([P, z]); w; ) {
const E = w.parent ? a[w.parent] : void 0, M = w.kickoffDepthMsl !== null ? w.kickoffDepthMsl : -w.depthReferenceElevation, k = E ? c[E.id] : A, I = y(k), G = g(M);
d.push([I, G]), A = k, w = E;
}
}
return d.reverse();
}, [m, g, y, c, a]), v = C(() => {
if (m) {
const d = m.kickoffDepthMsl !== null ? m.kickoffDepthMsl : -m.depthReferenceElevation;
return g(d);
}
return null;
}, [m, g]), h = ae((d) => {
const A = et();
if (d.length < 2) return "";
let w = d[0][0], P = d[0][1];
A.moveTo(w, P);
for (let z = 1; z < d.length; z++) {
const E = d[z][0], M = d[z][1];
if (A.lineTo(w, P), w !== E)
if (M - P > p) {
const k = P + p;
A.arcTo(E, P, E, k, p);
} else
A.lineTo(E, P);
A.lineTo(E, M), w = E, P = M;
}
return A.toString();
}, [p]), _ = p / 2, b = `${_},${_ / 2}`;
return x.length < 2 ? null : /* @__PURE__ */ H("g", { style: { filter: "drop-shadow( 0px 0px 1px rgba(0,0,0,0.7))", pointerEvents: "none" }, children: [
/* @__PURE__ */ T(
"path",
{
d: h(x),
stroke: f.activeTrackColor,
strokeWidth: l * e,
fill: "none",
strokeDasharray: i ? b : "",
strokeOpacity: n
}
),
/* @__PURE__ */ T(
"line",
{
x1: x[x.length - 1][0] - p * 0.5,
x2: x[x.length - 1][0] + p * 0.5,
y1: x[x.length - 1][1],
y2: x[x.length - 1][1],
stroke: f.activeTrackColor,
strokeWidth: l * e * 0.75,
strokeOpacity: n
}
),
v !== null && /* @__PURE__ */ T(
"circle",
{
cx: x[x.length - 2][0],
cy: x[x.length - 2][1],
r: p * 1,
fill: "none",
stroke: f.activeTrackColor,
strokeWidth: l,
strokeOpacity: n
}
),
/* @__PURE__ */ T(
"line",
{
x1: x[0][0] - p * 0.5,
x2: x[0][0] + p * 0.5,
y1: x[0][1],
y2: x[0][1],
stroke: f.activeTrackColor,
strokeWidth: l * e * 0.75,
strokeOpacity: n
}
)
] });
}, er = ({
selected: t,
setSelected: n,
depth: e,
setDepth: i,
color: o,
colorMap: r,
interactive: a,
depthCursor: l,
children: u
}) => {
const [s, c] = fi(), f = Ce(), y = f((M) => M.wellboreIds), m = f((M) => M.wellboresById), g = f((M) => M.setMeasure), p = f((M) => M.domain), x = f((M) => M.measures.range), v = f((M) => M.measures.trackWidth), h = f((M) => M.slotsById), _ = f((M) => M.styles), b = j(null), d = j(null), A = j(null);
L(() => {
g(c.width, c.height);
}, [c, g, y]);
const w = C(() => We().domain(p).range(x), [p, x]), P = C(() => {
const M = Math.floor(w.domain()[0] / 100) * 100, k = Math.ceil((w.domain()[1] - M) / 100);
return dn(w).tickValues(di(0, k).map((G) => G * 100 + M)).tickSizeInner(_.depthAxisWidth);
}, [w, _]), z = C(() => {
const M = /* @__PURE__ */ new Set();
y.forEach((S) => {
const O = m[S];
O && O.kickoffDepthMsl && M.add(O.kickoffDepthMsl);
});
const k = 5.5, I = Array.from(M).sort((S, O) => S - O), G = /* @__PURE__ */ new Set();
return I.forEach((S, O) => {
const D = O > 0 ? I[O - 1] : null;
if (D) {
const V = w(D), Y = w(S);
Math.abs(Y - V) < k && G.add(S);
}
}), dn(w).tickValues(I).tickSizeInner(-c.width).tickSizeOuter(2).offset(0).tickPadding(4).tickFormat((S) => G.has(S.valueOf()) ? "" : mi(",.0f")(S));
}, [w, y, c.width, m]), E = C(
() => y.map((M) => ({
wellboreId: M,
slot: h[M]
})).sort((M, k) => (M.wellboreId === t ? 1 / 0 : 0) - (k.wellboreId === t ? 1 / 0 : 0) || M.slot - k.slot),
[y, h, t]
);
return L(() => {
if (d.current) {
const M = jt(d.current);
M.call(P), M.selectAll(".tick>text").remove(), M.selectAll("path.domain").remove(), M.selectAll(".tick>line").attr("stroke", _.depthAxisColor);
}
}, [P, _]), L(() => {
if (A.current) {
const M = jt(A.current);
M.call(z), M.selectAll(".tick").attr("stroke-width", 0.5), M.selectAll("path.domain").attr("stroke", _.kickoffAxisColor);
}
}, [z, _]), /* @__PURE__ */ T(
"svg",
{
ref: s,
style: {
flex: "1 1 auto",
width: "100%",
height: "100%"
},
className: "well-map",
children: v > 0 && c.height > 0 && /* @__PURE__ */ H(ze, { children: [
/* @__PURE__ */ T("g", { className: "data-layer", transform: `translate(${_.depthAxisWidth}, 0)`, children: u }),
/* @__PURE__ */ T("g", { ref: d, transform: `translate(${_.depthAxisWidth}, 0)` }),
/* @__PURE__ */ T("g", { ref: A, transform: `translate(${_.depthAxisWidth}, 0)` }),
/* @__PURE__ */ T("g", { ref: b, className: "tracks", transform: `translate(${_.depthAxisWidth}, 0)`, children: E.map((M) => /* @__PURE__ */ T(
Qi,
{
wellboreId: M.wellboreId,
slot: M.slot,
color: r && r[M.wellboreId] || o || "silver",
isSelected: !!(t && t === M.wellboreId),
setSelected: n,
interactive: !!a,
setDepth: i
},
M.wellboreId
)) }),
/* @__PURE__ */ T("g", { className: "active-track", transform: `translate(${_.depthAxisWidth}, 0)`, children: t && /* @__PURE__ */ T(Ji, { wellboreId: t, opacity: 0.8 }) }),
a && l && e !== void 0 && /* @__PURE__ */ T(
Zi,
{
depth: e,
setDepth: i
}
)
] })
}
);
}, lo = {
depthAxisWidth: 30,
depthAxisColor: "#555",
kickoffAxisColor: "#aaa",
cursorColor: "white",
readoutColor: "orange",
rulerColor: "red",
activeTrackColor: "white",
textColor: "white",
darkMode: !0
}, $s = {
depthAxisWidth: 30,
depthAxisColor: "#ddd",
kickoffAxisColor: "#aaa",
cursorColor: "#aaa",
readoutColor: "orange",
rulerColor: "red",
activeTrackColor: "white",
textColor: "#555",
darkMode: !1
}, tr = 50, nr = 30, or = () => xt((t, n) => ({
_allWellbores: [],
wellbores: [],
wellboreIds: [],
wellboresByName: {},
wellboresById: {},
segments: {},
slotsById: {},
activeDepths: {},
tracksOrder: [],
depth: 0,
domain: [0, 0],
styles: lo,
setStyles: (e) => t({ styles: e }),
measures: {
padding: { top: 0, bottom: 0, left: 0, right: 0 },
ratio: 0,
svgWidth: 0,
svgHeight: 0,
tracksWidth: 0,
trackWidth: 0,
range: [0, 0],
getSlotPosition: () => 0
},
setDepth: (e) => {
t({ depth: e });
},
setMeasure: (e, i) => {
const o = n().wellbores.length, r = e, a = i, l = e - nr, u = o > 0 ? l / o : 0, s = Math.min(1, u / tr), c = {
top: 20 * s + 5,
bottom: 20 * s + 20,
left: 0,
right: 0
}, f = [
0 + c.top,
i - (c.top + c.bottom)
];
t({ measures: {
padding: c,
ratio: s,
svgWidth: r,
svgHeight: a,
tracksWidth: l,
trackWidth: u,
range: f,
getSlotPosition: (g) => g * u + u / 2
} });
},
setWellbores: (e) => {
const i = e, o = i.filter((g) => g.drilled), r = o.map((g) => g.id), a = i.reduce(
(g, p) => ({
...g,
[p.id]: p
}),
{}
), l = i.reduce(
(g, p) => ({
...g,
[p.name]: p
}),
{}
), u = eo(l, o), s = Object.keys(u).map((g) => ({ sq: u[g][1], id: g })).sort((g, p) => p.sq - g.sq).map((g) => g.id), c = {};
for (let g = 0; g < s.length; g++) {
const p = s[g];
if (c[p] !== void 0) continue;
const x = a[p];
if (x && (x.status === "operating" || x.status === "drilling")) {
c[p] = x.depthMdMsl;
let v = x;
for (; v && v.kickoffDepthMsl !== null && v.parent; ) {
const h = l[v.parent];
if (!h) break;
c[h.id] ? c[h.id] = Math.max(c[h.id], v.kickoffDepthMsl) : c[h.id] = v.kickoffDepthMsl, v = h;
}
}
}
const f = s.reduce(
(g, p, x) => ({ ...g, [p]: x }),
{}
), y = r.reduce(
(g, p) => {
const x = a[p];
if (x) {
let v = -x.depthReferenceElevation;
x.kickoffDepthMsl && (v = x.kickoffDepthMsl), v < g[0] && (g[0] = v), x.depthMdMsl > g[1] && (g[1] = x.depthMdMsl);
}
return g;
},
[1 / 0, -1 / 0]
);
t({
_allWellbores: i,
wellbores: o,
wellboreIds: r,
wellboresById: a,
wellboresByName: l,
segments: u,
tracksOrder: s,
slotsById: f,
activeDepths: c,
domain: y
});
}
})), Ns = ({
wellIdentifier: t,
selected: n,
onSelect: e,
depth: i,
onDepthChanged: o,
color: r,
colors: a,
interactive: l = !0,
headless: u = !1,
depthCursor: s = !0,
theme: c = { ...lo },
children: f
}) => {
const y = ne(wt), m = C(() => or(), []), g = m((w) => w.setWellbores), p = m((w) => w.wellbores), x = m((w) => w.slotsById), v = m((w) => w.measures.svgWidth), h = m((w) => w.domain), _ = m((w) => w.setStyles), b = m((w) => w.setDepth), d = C(() => {
let w = i;
return w !== void 0 && (w = xe(w, h[0], h[1])), w;
}, [i, h]);
L(() => {
_(c);
}, [c, _]), L(() => {
b(d);
}, [d, b]), L(() => {
if (y) {
const w = y.connect();
w && w.query("wellbore-headers", { well: t }).then((P) => {
P && Array.isArray(P) && g(P);
});
}
}, [y, t, g]);
const A = C(() => {
if (a)
return typeof a == "function" ? p.reduce((w, P) => ({
...w,
[P.id]: a(P, x[P.id])
}), {}) : a;
}, [p, x, a]);
return /* @__PURE__ */ T("div", { style: {
flex: "1 1 auto",
display: "flex",
flexDirection: "column",
userSelect: "none",
boxSizing: "border-box",
height: "100%",
fontFamily: "sans-serif",
color: c.textColor,
zIndex: 10
}, children: /* @__PURE__ */ H(ao.Provider, { value: m, children: [
!u && /* @__PURE__ */ H("div", { style: { textAlign: "center", fontSize: `${Math.min(15, 0.15 * v)}px` }, children: [
/* @__PURE__ */ T("div", { style: { textTransform: "uppercase", fontSize: "9pt", textAlign: "left", opacity: 0.5 }, children: "Well Map" }),
/* @__PURE__ */ T("div", { children: t }),
l && d !== void 0 && /* @__PURE__ */ T(Xi, { depth: d, color: c.readoutColor })
] }),
/* @__PURE__ */ T(
er,
{
selected: n,
setSelected: e,
depth: d,
setDepth: o,
color: r,
colorMap: A,
interactive: l,
depthCursor: s,
children: f
}
)
] }) });
}, $e = () => {
const t = ne(wt), [n, e] = F(null);
return L(() => {
if (t) {
const i = t.connect();
e(() => i);
}
}, [t]), n;
}, Ys = ({ color: t = "#ccc" }) => {
const n = $e(), [e, i] = F(null), o = Ce(), r = o((h) => h.wellboreIds), a = o((h) => h.wellboresById), l = o((h) => h.domain), u = o((h) => h.measures.range), s = o((h) => h.measures.ratio), c = o((h) => h.measures.tracksWidth), f = o((h) => h.slotsById), y = o((h) => h.styles), m = o((h) => h.measures.getSlotPosition), g = C(() => We().domain(l).range(u), [l, u]);
L(() => {
if (n) {
const h = r.map((_) => n.get("casings", _));
Promise.all(h).then((_) => {
const b = _.reduce((d, A, w) => ({
...d,
[r[w]]: A
}), {});
i(b);
});
}
}, [r, n]);
const p = C(() => {
const h = [];
return e && r.forEach((_) => {
const b = a[_], d = b.kickoffDepthMsl !== null ? b.kickoffDepthMsl : b.depthReferenceElevation, A = f[_], w = m(A);
e[_] && e[_].filter((P) => P.type === "Shoe" && (d === null || P.mdBottomMsl > d)).forEach((P) => {
const z = g(P.mdBottomMsl);
h.push({
id: vt(),
name: `${P.properties.Diameter} ${P.properties.Type}`,
x: w,
y: z
});
});
}), h;
}, [e, g, m, f, r, a]), x = C(() => {
if (s) {
const h = 7 * s, _ = 16 * s, b = _ - h, d = et();
return d.moveTo(-h, -b * 2), d.lineTo(-h, 0), d.lineTo(-_, 0), d.lineTo(-h - 2, -b), d.lineTo(-h - 2, -b * 2), d.lineTo(-h, -b * 2), d.closePath(), d.moveTo(h, -b * 2), d.lineTo(h, 0), d.lineTo(_, 0), d.lineTo(h + 2, -b), d.lineTo(h + 2, -b * 2), d.lineTo(h, -b * 2), d.closePath(), d.toString();
}
return "";
}, [s]), v = C(() => {
const h = y.darkMode ? 0 : 240;
return `rgba(${h}, ${h}, ${h}, .9)`;
}, [y.darkMode]);
return p ? /* @__PURE__ */ T("g", { children: p.map((h) => /* @__PURE__ */ H(Nt, { children: [
/* @__PURE__ */ T("line", { x1: 0, y1: h.y, x2: c, y2: h.y, stroke: t, strokeOpacity: 0.25, strokeDasharray: "2,2" }),
/* @__PURE__ */ T(
"path",
{
d: x,
stroke: "black",
strokeWidth: 0.25,
fill: t,
transform: `translate(${h.x},${h.y})`,
style: {
filter: `drop-shadow( 1px 1px 2px ${v})`,
pointerEvents: "painted",
cursor: "help"
},
children: /* @__PURE__ */ T("title", { children: h.name })
},
h.id
)
] }, h.id)) }) : null;
}, Ks = ({ colorScreen: t = "gray", colorPerforation: n = "orange" }) => {
const e = $e(), [i, o] = F(null), [r, a] = F(null), l = Ce(), u = l((b) => b.wellboreIds), s = l((b) => b.wellboresById), c = l((b) => b.domain), f = l((b) => b.measures.range), y = l((b) => b.measures.ratio), m = l((b) => b.slotsById), g = l((b) => b.styles), p = l((b) => b.measures.getSlotPosition), x = C(() => We().domain(c).range(f), [c, f]);
L(() => {
if (e) {
const b = u.map((A) => e.get("completion-tools", A)), d = u.map((A) => e.get("perforations", A));
Promise.all(b).then((A) => {
if (A) {
const w = A.reduce((P, z, E) => ({
...P,
[u[E]]: z !== null ? z.filter((M) => M.category === "screen") : []
}), {});
o(w);
}
}), Promise.all(d).then((A) => {
const w = A.reduce((P, z, E) => ({
...P,
[u[E]]: z || []
}), {});
a(w);
});
}
}, [u, e]);
const v = C(() => {
const b = [];
return i && r && u.forEach((d) => {
const A = s[d], w = A.kickoffDepthMsl !== null ? A.kickoffDepthMsl : A.depthReferenceElevation, P = m[d], z = p(P);
(i[d] ? un(
i[d].filter((k) => w === void 0 || k.mdBottomMsl > w),
(k) => k.mdTopMsl,
(k) => k.mdBottomMsl
) : []).forEach((k) => {
b.push({
id: vt(),
type: "screen",
x: z,
y1: x(k.start),
y2: x(k.end)
});
}), (r[d] ? un(
r[d].filter((k) => k.status === "Open" && (w === void 0 || k.mdBottomMsl > w)),
(k) => k.mdTopMsl,
(k) => k.mdBottomMsl
) : []).forEach((k) => {
b.push({
id: vt(),
type: "perforation",
x: z,
y1: x(k.start),
y2: x(k.end)
});
});
}), b;
}, [i, r, x, p, m, u, s]), h = ae((b) => {
if (y) {
const d = 10 * y, A = 18 * y, w = et();
return w.moveTo(b.x - A, b.y1), w.lineTo(b.x - d, b.y1), w.lineTo(b.x - d, b.y2), w.lineTo(b.x - A, b.y2), w.moveTo(b.x + A, b.y1), w.lineTo(b.x + d, b.y1), w.lineTo(b.x + d, b.y2), w.lineTo(b.x + A, b.y2), w.toString();
}
return "";
}, [y]), _ = C(() => {
const b = g.darkMode ? 0 : 240;
return `rgba(${b}, ${b}, ${b}, .9)`;
}, [g.darkMode]);
return v ? /* @__PURE__ */ T("g", { children: v.map((b) => /* @__PURE__ */ H(
"g",
{
style: {
cursor: "help",
filter: `drop-shadow( 1px 1px 2px ${_})`,
// @ts-expect-error bounding-box is valid on svg elements
pointerEvents: "bounding-box"
},
children: [
/* @__PURE__ */ T("title", { children: b.type }),
/* @__PURE__ */ T(
"path",
{
d: h(b),
stroke: b.type === "perforation" ? n : t,
strokeWidth: 1.5,
fill: "none"
}
)
]
},
b.id
)) }) : null;
}, qs = ({ stratColumnId: t }) => {
const n = $e(), [e, i] = F(null), o = Ce(), r = o((p) => p.wellboreIds), a = o((p) => p.domain), l = o((p) => p.measures.range), u = o((p) => p.measures.ratio), s = o((p) => p.slotsById), c = o((p) => p.styles), f = o((p) => p.measures.getSlotPosition), y = C(() => We().domain(a).range(l), [a, l]);
L(() => {
if (n) {
const p = r.map((x) => qn(x, t, n, !0));
Promise.all(p).then((x) => {
if (x) {
const v = x.reduce((h, _, b) => {
let d = [];
if (_ != null && _.matched) {
const A = Xn(_.matched, _.wellbore.depthMdMsl);
d = Qn(A);
}
return {
...h,
[r[b]]: d
};
}, {});
i(v);
}
});
}
}, [r, t, n]);
const m = C(() => {
const p = [];
return e && r.forEach((x) => {
if (e[x]) {
const v = s[x], h = f(v);
e[x].forEach((_) => {
const b = {
id: vt(),
formation: _.unit.name,
color: _.unit.color,
level: _.unit.level,
x: h,
y1: y(_.mdMslTop),
y2: y(_.mdMslBottom)
};
p.push(b);
});
}
}), p;
}, [e, y, f, s, r]), g = C(() => {
const p = c.darkMode ? 0 : 240;
return `rgba(${p}, ${p}, ${p}, .9)`;
}, [c.darkMode]);
return m ? /* @__PURE__ */ T("g", { children: m.map((p) => {
const x = u * 30;
return /* @__PURE__ */ H(
"g",
{
style: {
cursor: "help",
filter: `drop-shadow( 1px 1px 2px ${g})`,
// @ts-expect-error bounding-box is valid on svg elements
pointerEvents: "bounding-box"
},
children: [
/* @__PURE__ */ T("title", { children: p.formation }),
/* @__PURE__ */ T(
"rect",
{
x: p.x - x / 2,
y: p.y1,
width: x,
rx: x * 0.05,
ry: x * 0.05,
height: Math.max(1, p.y2 - p.y1),
fill: p.color,
fillOpacity: 0.1,
stroke: p.color,
strokeWidth: 0.5,
strokeOpacity: 0.75,
style: { filter: `drop-shadow( 1px 1px 2px ${g})` }
}
),
/* @__PURE__ */ T(
"line",
{
x1: p.x - x * 1.5 / 2,
x2: p.x + x * 1.5 / 2,
y1: p.y1,
y2: p.y1,
stroke: p.color,
strokeWidth: 1.5,
strokeOpacity: 1,
style: { filter: `drop-shadow( 1px 1px 2px ${g})` }
}
)
]
},
p.id
);
}) }) : null;
}, Xs = ({ color: t = "rgb(113, 216, 253)" }) => {
const n = $e(), [e, i] = F(null), o = Ce(), r = o((m) => m.tracksOrder), a = o((m) => m.depth), l = o((m) => m.measures.ratio), u = o((m) => m.measures.trackWidth), s = o((m) => m.measures.svgHeight), c = o((m) => m.measures.getSlotPosition);
L(() => {
if (n) {
const m = r.map((g) => n.get("position-logs", g));
Promise.all(m).then((g) => {
const p = g.reduce((x, v, h) => ({
...x,
[r[h]]: Zn(r[h], v)
}), {});
i(p);
});
}
}, [r, n]);
const f = C(() => {
const m = [];
return e && r.forEach((g, p) => {
const v = [c(p), null];
if (a !== void 0 && e[g]) {
const h = e[g].getPointAtDepth(a, !1);
if (h) {
const _ = -h[1];
v[1] = _;
}
}
m.push(v);
}), m;
}, [a, c, r, e]), y = C(() => s - l * 15, [l, s]);
return !f || u < 50 ? null : /* @__PURE__ */ H("g", { children: [
/* @__PURE__ */ T(
"text",
{
style: { fontSize: "12px" },
fill: t,
fillOpacity: 0.75,
x: -30,
y,
textAnchor: "left",
alignmentBaseline: "after-edge",
children: "TVD:"
}
),
/* @__PURE__ */ T(
"text",
{
style: { fontSize: "10px" },
fill: t,
fillOpacity: 0.5,
x: -30,
y: y + 10,
textAnchor: "left",
alignmentBaseline: "after-edge",
children: "(Msl)"
}
),
f.map(
(m) => /* @__PURE__ */ T(
"text",
{
style: { fontSize: "12px" },
fill: t,
fillOpacity: m[1] === null ? 0.5 : 1,
alignmentBaseline: "after-edge",
textAnchor: "middle",
x: m[0],
y,
children: m[1] !== null && m[1].toFixed(1) + "m" || "---"
},
m.toString()
)
)
] });
};
var ir = Object.defineProperty, rr = (t, n, e) => n in t ? ir(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e, U = (t, n, e) => (rr(t, typeof n != "symbol" ? n + "" : n, e), e);
function Ft(t, n, e, i, o) {
let r;
if (t = t.subarray || t.slice ? t : t.buffer, e = e.subarray || e.slice ? e : e.buffer, t = n ? t.subarray ? t.subarray(n, o && n + o) : t.slice(n, o && n + o) : t, e.set)
e.set(t, i);
else
for (r = 0; r < t.length; r++)
e[r + i] = t[r];
return e;
}
function sr(t) {
return t instanceof Float32Array ? t : t instanceof X.BufferGeometry ? t.getAttribute("position").array : t.map((n) => {
const e = Array.isArray(n);
return n instanceof X.Vector3 ? [n.x, n.y, n.z] : n instanceof X.Vector2 ? [n.x, n.y, 0] : e && n.length === 3 ? [n[0], n[1], n[2]] : e && n.length === 2 ? [n[0], n[1], 0] : n;
}).flat();
}
class ar extends X.BufferGeometry {
constructor() {
super(), U(this, "type", "MeshLine"), U(this, "isMeshLine", !0), U(this, "positions", []), U(this, "previous", []), U(this, "next", []), U(this, "side", []), U(this, "width", []), U(this, "indices_array", []), U(this, "uvs", []), U(this, "counters", []), U(this, "widthCallback", null), U(this, "_attributes"), U(this, "_points", []), U(this, "points"), U(this, "matrixWorld", new X.Matrix4()), Object.defineProperties(this, {
points: {
enumerable: !0,
get() {
return this._points;
},
set(n) {
this.setPoints(n, this.widthCallback);
}
}
});
}
setMatrixWorld(n) {
this.matrixWorld = n;
}
setPoints(n, e) {
if (n = sr(n), this._points = n, this.widthCallback = e ?? null, this.positions = [], this.counters = [], n.length && n[0] instanceof X.Vector3)
for (let i = 0; i < n.length; i++) {
const o = n[i], r = i / (n.length - 1);
this.positions.push(o.x, o.y, o.z), this.positions.push(o.x, o.y, o.z), this.counters.push(r), this.counters.push(r);
}
else
for (let i = 0; i < n.length; i += 3) {
const o = i / (n.length - 1);
this.positions.push(n[i], n[i + 1], n[i + 2]), this.positions.push(n[i], n[i + 1], n[i + 2]), this.counters.push(o), this.counters.push(o);
}
this.process();
}
compareV3(n, e) {
const i = n * 6, o = e * 6;
return this.positions[i] === this.positions[o] && this.positions[i + 1] === this.positions[o + 1] && this.positions[i + 2] === this.positions[o + 2];
}
copyV3(n) {
const e = n * 6;
return [this.positions[e], this.positions[e + 1], this.positions[e + 2]];
}
process() {
const n = this.positions.length / 6;
this.previous = [], this.next = [], this.side = [], this.width = [], this.indices_array = [], this.uvs = [];
let e, i;
this.compareV3(0, n - 1) ? i = this.copyV3(n - 2) : i = this.copyV3(0), this.previous.push(i[0], i[1], i[2]), this.previous.push(i[0], i[1], i[2]);
for (let o = 0; o < n; o++) {
if (this.side.push(1), this.side.push(-1), this.widthCallback ? e = this.widthCallback(o / (n - 1)) : e = 1, this.width.push(e), this.width.push(e), this.uvs.push(o / (n - 1), 0), this.uvs.push(o / (n - 1), 1), o < n - 1) {
i = this.copyV3(o), this.previous.push(i[0], i[1], i[2]), this.previous.push(i[0], i[1], i[2]);
const r = o * 2;
this.indices_array.push(r, r + 1, r + 2), this.indices_array.push(r + 2, r + 1, r + 3);
}
o > 0 && (i = this.copyV3(o), this.next.push(i[0], i[1], i[2]), this.next.push(i[0], i[1], i[2]));
}
this.compareV3(n - 1, 0) ? i = this.copyV3(1) : i = this.copyV3(n - 1), this.next.push(i[0], i[1], i[2]), this.next.push(i[0], i[1], i[2]), !this._attributes || this._attributes.position.count !== this.counters.length ? this._attributes = {
position: new X.BufferAttribute(new Float32Array(this.positions), 3),
previous: new X.BufferAttribute(new Float32Array(this.previous), 3),
next: new X.BufferAttribute(new Float32Array(this.next), 3),
side: new X.BufferAttribute(new Float32Array(this.side), 1),
width: new X.BufferAttribute(new Float32Array(this.width), 1),
uv: new X.BufferAttribute(new Float32Array(this.uvs), 2),
index: new X.BufferAttribute(new Uint16Array(this.indices_array), 1),
counters: new X.BufferAttribute(new Float32Array(this.counters), 1)
} : (this._attributes.position.copyArray(new Float32Array(this.positions)), this._attributes.position.needsUpdate = !0, this._attributes.previous.copyArray(new Float32Array(this.previous)), this._attributes.previous.needsUpdate = !0, this._attributes.next.copyArray(new Float32Array(this.next)), this._attributes.next.needsUpdate = !0, this._attributes.side.copyArray(new Float32Array(this.side)), this._attributes.side.needsUpdate = !0, this._attributes.width.copyArray(new Float32Array(this.width)), this._attributes.width.needsUpdate = !0, this._attributes.uv.copyArray(new Float32Array(this.uvs)), this._attributes.uv.needsUpdate = !0, this._attributes.index.copyArray(new Uint16Array(this.indices_array)), this._attributes.index.needsUpdate = !0), this.setAttribute("position", this._attributes.position), this.setAttribute("previous", this._attributes.previous), this.setAttribute("next", this._attributes.next), this.setAttribute("side", this._attributes.side), this.setAttribute("width", this._attributes.width), this.setAttribute("uv", this._attributes.uv), this.setAttribute("counters", this._attributes.counters), this.setAttribute("position", this._attributes.position), this.setAttribute("previous", this._attributes.previous), this.setAttribute("next", this._attributes.next), this.setAttribute("side", this._attributes.side), this.setAttribute("width", this._attributes.width), this.setAttribute("uv", this._attributes.uv), this.setAttribute("counters", this._attributes.counters), this.setIndex(this._attributes.index), this.computeBoundingSphere(), this.computeBoundingBox();
}
advance({ x: n, y: e, z: i }) {
const o = this._attributes.position.array, r = this._attributes.previous.array, a = this._attributes.next.array, l = o.length;
Ft(o, 0, r, 0, l), Ft(o, 6, o, 0, l - 6), o[l - 6] = n, o[l - 5] = e, o[l - 4] = i, o[l - 3] = n, o[l - 2] = e, o[l - 1] = i, Ft(o, 6, a, 0, l - 6), a[l - 6] = n, a[l - 5] = e, a[l - 4] = i, a[l - 3] = n, a[l - 2] = e, a[l - 1] = i, this._attributes.position.needsUpdate = !0, this._attributes.previous.needsUpdate = !0, this._attributes.next.needsUpdate = !0;
}
}
const lr = `
#include <common>
#include <logdepthbuf_pars_vertex>
#include <fog_pars_vertex>
#include <clipping_planes_pars_vertex>
attribute vec3 previous;
attribute vec3 next;
attribute float side;
attribute float width;
attribute float counters;
uniform vec2 resolution;
uniform float lineWidth;
uniform vec3 color;
uniform float opacity;
uniform float sizeAttenuation;
varying vec2 vUV;
varying vec4 vColor;
varying float vCounters;
vec2 fix(vec4 i, float aspect) {
vec2 res = i.xy / i.w;
res.x *= aspect;
return res;
}
void main() {
float aspect = resolution.x / resolution.y;
vColor = vec4(color, opacity);
vUV = uv;
vCounters = counters;
mat4 m = projectionMatrix * modelViewMatrix;
vec4 finalPosition = m * vec4(position, 1.0) * aspect;
vec4 prevPos = m * vec4(previous, 1.0);
vec4 nextPos = m * vec4(next, 1.0);
vec2 currentP = fix(finalPosition, aspect);
vec2 prevP = fix(prevPos, aspect);
vec2 nextP = fix(nextPos, aspect);
float w = lineWidth * width;
vec2 dir;
if (nextP == currentP) dir = normalize(currentP - prevP);
else if (prevP == currentP) dir = normalize(nextP - currentP);
else {
vec2 dir1 = normalize(currentP - prevP);
vec2 dir2 = normalize(nextP - currentP);
dir = normalize(dir1 + dir2);
vec2 perp = vec2(-dir1.y, dir1.x);
vec2 miter = vec2(-dir.y, dir.x);
//w = clamp(w / dot(miter, perp), 0., 4. * lineWidth * width);
}
//vec2 normal = (cross(vec3(dir, 0.), vec3(0., 0., 1.))).xy;
vec4 normal = vec4(-dir.y, dir.x, 0., 1.);
normal.xy *= .5 * w;
//normal *= projectionMatrix;
if (sizeAttenuation == 0.) {
normal.xy *= finalPosition.w;
normal.xy /= (vec4(resolution, 0., 1.) * projectionMatrix).xy * aspect;
}
finalPosition.xy += normal.xy * side;
gl_Position = finalPosition;
#include <logdepthbuf_vertex>
#include <fog_vertex>
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
#include <clipping_planes_vertex>
#include <fog_vertex>
}
`, cr = parseInt(X.REVISION.replace(/\D+/g, "")), ur = cr >= 154 ? "colorspace_fragment" : "encodings_fragment", fr = `
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
uniform sampler2D map;
uniform sampler2D alphaMap;
uniform float useGradient;
uniform float useMap;
uniform float useAlphaMap;
uniform float useDash;
uniform float dashArray;
uniform float dashOffset;
uniform float dashRatio;
uniform float visibility;
uniform float alphaTest;
uniform vec2 repeat;
uniform vec3 gradient[2];
varying vec2 vUV;
varying vec4 vColor;
varying float vCounters;
void main() {
#include <logdepthbuf_fragment>
vec4 diffuseColor = vColor;
if (useGradient == 1.) diffuseColor = vec4(mix(gradient[0], gradient[1], vCounters), 1.0);
if (useMap == 1.) diffuseColor *= texture2D(map, vUV * repeat);
if (useAlphaMap == 1.) diffuseColor.a *= texture2D(alphaMap, vUV * repeat).a;
if (diffuseColor.a < alphaTest) discard;
if (useDash == 1.) diffuseColor.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
diffuseColor.a *= step(vCounters, visibility);
#include <clipping_planes_fragment>
gl_FragColor = diffuseColor;
#include <fog_fragment>
#include <tonemapping_fragment>
#include <${ur}>
}
`;
class dr extends X.ShaderMaterial {
constructor(n) {
super({
uniforms: {
...X.UniformsLib.fog,
lineWidth: { value: 1 },
map: { value: null },
useMap: { value: 0 },
alphaMap: { value: null },
useAlphaMap: { value: 0 },
color: { value: new X.Color(16777215) },
gradient: { value: [new X.Color(16711680), new X.Color(65280)] },
opacity: { value: 1 },
resolution: { value: new X.Vector2(1, 1) },
sizeAttenuation: { value: 1 },
dashArray: { value: 0 },
dashOffset: { value: 0 },
dashRatio: { value: 0.5 },
useDash: { value: 0 },
useGradient: { value: 0 },
visibility: { value: 1 },
alphaTest: { value: 0 },
repeat: { value: new X.Vector2(1, 1) }
},
vertexShader: lr,
fragmentShader: fr
}), U(this, "lineWidth"), U(this, "map"), U(this, "useMap"), U(this, "alphaMap"), U(this, "useAlphaMap"), U(this, "color"), U(this, "gradient"), U(this, "resolution"), U(this, "sizeAttenuation"), U(this, "dashArray"), U(this, "dashOffset"), U(this, "dashRatio"), U(this, "useDash"), U(this, "useGradient"), U(this, "visibility"), U(this, "repeat"), this.type = "MeshLineMaterial", Object.defineProperties(this, {
lineWidth: {
enumerable: !0,
get() {
return this.uniforms.lineWidth.value;
},
set(e) {
this.uniforms.lineWidth.value = e;
}
},
map: {
enumerable: !0,
get() {
return this.uniforms.map.value;
},
set(e) {
this.uniforms.map.value = e;
}
},
useMap: {
enumerable: !0,
get() {
return this.uniforms.useMap.value;
},
set(e) {
this.uniforms.useMap.value = e;
}
},
alphaMap: {
enumerable: !0,
get() {
return this.uniforms.alphaMap.value;
},
set(e) {
this.uniforms.alphaMap.value = e;
}
},
useAlphaMap: {
enumerable: !0,
get() {
return this.uniforms.useAlphaMap.value;
},
set(e) {
this.uniforms.useAlphaMap.value = e;
}
},
color: {
enumerable: !0,
get() {
return this.uniforms.color.value;
},
set(e) {
this.uniforms.color.value = e;
}
},
gradient: {
enumerable: !0,
get() {
return this.uniforms.gradient.value;
},
set(e) {
this.uniforms.gradient.value = e;
}
},
opacity: {
enumerable: !0,
get() {
return this.uniforms.opacity.value;
},
set(e) {
this.uniforms.opacity.value = e;
}
},
resolution: {
enumerable: !0,
get() {
return this.uniforms.resolution.value;
},
set(e) {
this.uniforms.resolution.value.copy(e);
}
},
sizeAttenuation: {
enumerable: !0,
get() {
return this.uniforms.sizeAttenuation.value;
},
set(e) {
this.uniforms.sizeAttenuation.value = e;
}
},
dashArray: {
enumerable: !0,
get() {
return this.uniforms.dashArray.value;
},
set(e) {
this.uniforms.dashArray.value = e, this.useDash = e !== 0 ? 1 : 0;
}
},
dashOffset: {
enumerable: !0,
get() {
return this.uniforms.dashOffset.value;
},
set(e) {
this.uniforms.dashOffset.value = e;
}
},
dashRatio: {
enumerable: !0,
get() {
return this.uniforms.dashRatio.value;
},
set(e) {
this.uniforms.dashRatio.value = e;
}
},
useDash: {
enumerable: !0,
get() {
return this.uniforms.useDash.value;
},
set(e) {
this.uniforms.useDash.value = e;
}
},
useGradient: {
enumerable: !0,
get() {
return this.uniforms.useGradient.value;
},
set(e) {
this.uniforms.useGradient.value = e;
}
},
visibility: {
enumerable: !0,
get() {
return this.uniforms.visibility.value;
},
set(e) {
this.uniforms.visibility.value = e;
}
},
alphaTest: {
enumerable: !0,
get() {
return this.uniforms.alphaTest.value;
},
set(e) {
this.uniforms.alphaTest.value = e;
}
},
repeat: {
enumerable: !0,
get() {
return this.uniforms.repeat.value;
},
set(e) {
this.uniforms.repeat.value.copy(e);
}
}
}), this.setValues(n);
}
copy(n) {
return super.copy(n), this.lineWidth = n.lineWidth, this.map = n.map, this.useMap = n.useMap, this.alphaMap = n.alphaMap, this.useAlphaMap = n.useAlphaMap, this.color.copy(n.color), this.gradient = n.gradient, this.opacity = n.opacity, this.resolution.copy(n.resolution), this.sizeAttenuation = n.sizeAttenuation, this.dashArray = n.dashArray, this.dashOffset = n.dashOffset, this.dashRatio = n.dashRatio, this.useDash = n.useDash, this.useGradient = n.useGradient, this.visibility = n.visibility, this.alphaTest = n.alphaTest, this.repeat.copy(n.repeat), this;
}
}
var pr = `#include <common>
#include <logdepthbuf_pars_fragment>
uniform float time;
uniform float fontSize;
uniform float rotation;
uniform float spacing;
uniform float verticalAlign;
uniform float horizontalAlign;
uniform vec2 size;
uniform sampler2D glyphAtlas;
uniform float in_bias;
uniform float out_bias;
uniform GlyphData {
vec4 glyphPosition[GLYPHS_LENGTH];
vec3 glyphOffset[GLYPHS_LENGTH];
vec2 glyphTextureSize;
float glyphFontSize;
float glyphPixelRange;
float glyphLineHeight;
float glyphBaseLine;
};
varying vec2 vUv;
struct GlyphParams {
vec2 position;
uint index;
};
uint _numDigits(float number) {
float log10 = 0.4342944819032518 * log(number);
return uint(max(trunc(log10), 0.0) + 1.0);
}
uint _getDigit(float number, uint position) {
return uint(trunc(mod(number / pow(10.0, float(position - 1u)), 10.0)));
}
float _median(float r, float g, float b) {
return max(min(r, g), min(max(r, g), b));
}
vec2 _calcGlyphUv(vec2 texPos) {
vec2 glyphUv = vec2(texPos.x / glyphTextureSize.x, (glyphTextureSize.y - texPos.y) / glyphTextureSize.y);
return clamp(glyphUv, 0.0, 1.0);
}
float _calculateGlyphVerticalOffset(float vAlign) {
float pxRangeOffset = floor(glyphPixelRange / 2.0);
float lineHightOffset = glyphLineHeight / 2.0;
float vAlignOffset = (glyphFontSize / 2.0) * vAlign;
return lineHightOffset + pxRangeOffset + vAlignOffset;
}
float _screenPixelRange(float scale) {
vec2 scaledSize = size * scale;
vec2 screenPxRange = glyphPixelRange / fwidth(vUv * scaledSize);
return max(min(screenPxRange.x, screenPxRange.y), 1.0);
}
float _sdfGlyph(vec2 p, uint glyphId) {
vec2 offset = vec2(p.x - glyphOffset[glyphId].x, p.y - glyphOffset[glyphId].y);
vec2 uv = glyphPosition[glyphId].xy + offset;
float sigDist = -0.5;
if(offset.x >= 0.0 && offset.y >= 0.0 && offset.x <= glyphPosition[glyphId].z && offset.y <= glyphPosition[glyphId].w) {
vec2 TexCoord = _calcGlyphUv(uv);
vec3 mdf = texture2D(glyphAtlas, TexCoord).rgb;
sigDist = _median(mdf.r, mdf.g, mdf.b);
}
return sigDist;
}
void renderGlyph(inout vec3 outColor, vec2 position, uint glyphId, vec3 glyphColor, float pxRange) {
float dist = _sdfGlyph(position, glyphId);
float e = pxRange * (dist - 0.5 + in_bias) + 0.5 + out_bias;
float contour = clamp(e, 0.0, 1.0);
outColor = mix(outColor, glyphColor, contour);
}
uniform usampler2D textTexture;
uniform uint textPointersCount;
uniform uint textPointersOffset;
uint _readGlyphIdFromTexture(uint index) {
uint value = texelFetch(textTexture, ivec2(index, 0), 0).r;
return value;
}
GlyphParams _findGlyph(vec2 pixelCoords, uvec3 textPointer, float spacing) {
uint id = _readGlyphIdFromTexture(textPointer.x);
float width = glyphOffset[id].z + spacing;
vec2 position = pixelCoords.xy;
uint i = textPointer.x;
while(position.x >= width && i++ < textPointer.y - 1u) {
position.x -= width;
uint j = _readGlyphIdFromTexture(i);
id = j;
width = glyphOffset[id].z + spacing;
};
return GlyphParams(position, id);
}
uvec3 readTextPointerFromTexture(uint index) {
uvec3 pointer = uvec3(0u);
uint pos = (index * 3u) + textPointersOffset;
pointer.x = texelFetch(textTexture, ivec2(pos, 0), 0).r;
pointer.y = texelFetch(textTexture, ivec2(pos + 1u, 0), 0).r;
pointer.z = texelFetch(textTexture, ivec2(pos + 2u, 0), 0).r;
return pointer;
}
void renderText(
inout vec3 outColor,
vec2 position,
uvec3 textPointer,
float verticalAlign,
float horizontalAlign,
vec3 textColor,
float spacing,
float scale
) {
if(textPointer.z == 0u)
return;
float spacingWidth = spacing * float(textPointer.y - textPointer.x - 1u);
position.x += (float(textPointer.z) + spacingWidth) * horizontalAlign;
vec2 pos = position;
pos.y += _calculateGlyphVerticalOffset(verticalAlign);
if(pos.x < 0.0)
return;
GlyphParams params = _findGlyph(pos, textPointer, spacing);
renderGlyph(outColor, params.position, params.index, textColor, _screenPixelRange(scale));
}
uniform uint digits[12];
float renderNumber(
inout vec3 outColor,
vec2 position,
float number,
uint decimals,
float verticalAlign,
float horizontalAlign,
vec3 textColor,
float spacing,
float scale
) {
float width = 0.0;
float totalWidth = 0.0;
float offset = 0.0;
uvec2 temp[30];
uint glyphId;
uint nDigits;
vec2 pos = position.xy;
uint c = 0u;
if (number < 0.0) {
glyphId = digits[11];
width = glyphOffset[glyphId].z + spacing;
offset = width;
temp[c++] = uvec2(glyphId, width);
number = -number;
}
float intPart;
float fractPart = modf(number, intPart);
fractPart *= pow(10.0, float(decimals));
nDigits = _numDigits(intPart);
for(uint n = 0u; n < nDigits; n++) {
glyphId = digits[_getDigit(intPart, nDigits - n)];
width = glyphOffset[glyphId].z + spacing;
temp[c++] = uvec2(glyphId, width);
totalWidth += width;
}
if(decimals > 0u) {
glyphId = digits[10];
width = glyphOffset[glyphId].z + spacing;
temp[c++] = uvec2(glyphId, width);
totalWidth += width;
nDigits = _numDigits(fractPart);
for(uint n = 0u; n < decimals; n++) {
glyphId = digits[_getDigit(fractPart, nDigits - n)];
width = glyphOffset[glyphId].z + spacing;
temp[c++] = uvec2(glyphId, width);
totalWidth += width;
}
}
if(c > 0u) {
pos.x += (totalWidth - spacing) * horizontalAlign + offset;
pos.y += _calculateGlyphVerticalOffset(verticalAlign);
uint n = 0u;
while (n < c && pos.x > float(temp[n].y)) pos.x -= float(temp[n++].y);
if (n < c) renderGlyph(outColor, pos, temp[n].x, textColor, _screenPixelRange(scale));
}
return totalWidth;
}
mat2 rotation2d(float angle) {
float s = sin(angle);
float c = cos(angle);
return mat2(c, -s, s, c);
}
mat4 rotation3d(vec3 axis, float angle) {
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(
oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0
);
}
float sdfLine(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a;
vec2 ba = b - a;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
return length(pa - ba * h);
}
float sdfBox(vec2 p, vec2 b) {
vec2 d = abs(p) - b;
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
}
float sdfCircle(vec2 p, float r) {
return length(p) - r;
}
void textGuides(inout vec3 outColor, vec2 position) {
float helper;
helper = sdfLine(position + vec2(0.0, glyphLineHeight / 2.0), vec2(0.0), vec2(size.x, 0.0));
outColor = mix(outColor, vec3(1.0, 0.0, 0.0), smoothstep(1.0, -1.0, helper));
helper = sdfLine(position - vec2(0.0, glyphLineHeight / 2.0), vec2(0.0), vec2(size.x, 0.0));
outColor = mix(outColor, vec3(1.0, 0.0, 0.0), smoothstep(1.0, -1.0, helper));
helper = sdfLine(position + vec2(0.0, glyphLineHeight / 2.0 - glyphBaseLine), vec2(0.0), vec2(size.x, 0.0));
outColor = mix(outColor, vec3(0.0, 0.0, 1.0), smoothstep(1.0, -1.0, helper));
helper = sdfLine(position, vec2(0.0), vec2(size.x, 0.0));
outColor = mix(outColor, vec3(0.0, 1.0, 0.0), smoothstep(1.0, -1.0, helper));
}
void example1(inout vec3 color, vec2 pixelCoords) {
float scale = glyphFontSize / fontSize;
mat2 rotationMatrix = rotation2d(rotation);
float lineSpacing = (glyphLineHeight + 10.0);
vec2 textPosition = vec2(size.x / 2.0, glyphLineHeight);
pixelCoords = (pixelCoords - textPosition) * scale * rotationMatrix;
uint i = uint(round(pixelCoords.y / lineSpacing));
i = clamp(i, 0u, textPointersCount - 1u);
uvec3 textPointer = readTextPointerFromTexture(i);
pixelCoords.y -= float(i) * lineSpacing;
renderText(color, pixelCoords, textPointer, verticalAlign, horizontalAlign, vec3(0.09, 0.74, 0.51), spacing, scale);
}
void example2(inout vec3 color, vec2 pixelCoords) {
uint i = 0u;
uvec3 textPointer = readTextPointerFromTexture(i);
float width = size.x / 2.0;
float scale = float(textPointer.z) / width;
mat2 rotationMatrix = rotation2d(rotation);
vec2 textPosition = vec2(size.x / 2.0, size.y / 2.0);
pixelCoords = (pixelCoords - textPosition) * scale * rotationMatrix;
vec3 textColor = vec3(0.74, 0.09, 0.58);
renderText(color, pixelCoords, textPointer, verticalAlign, horizontalAlign, textColor, spacing, scale);
}
void exmaple3(inout vec3 color, vec2 pixelCoords) {
float scale = glyphFontSize / fontSize;
float number = time;
vec3 textColor = vec3(0.0, 0.5, 0.0);
mat2 rotationMatrix = rotation2d(rotation);
pixelCoords = pixelCoords * scale * rotationMatrix;
renderNumber(color, pixelCoords, number, 3u, verticalAlign, horizontalAlign, textColor, spacing, scale);
pixelCoords.y -= 80.0;
renderNumber(color, pixelCoords, -number * 100.0, 3u, verticalAlign, horizontalAlign, textColor, spacing, scale);
}
void main() {
#include <logdepthbuf_fragment>
vec3 color = vec3(1.0);
vec2 uv = vUv.xy;
if(!gl_FrontFacing) {
uv.x = 1.0 - uv.x;
}
vec2 pixelCoords = vec2(uv.x, 1.0 - uv.y) * size;
if(pixelCoords.x >= size.x / 2.0) {
color = vec3(0.9);
}
example1(color, pixelCoords);
example2(color, pixelCoords);
pixelCoords -= vec2(size.x / 2.0, size.y - 100.0);
exmaple3(color, pixelCoords);
gl_FragColor = vec4(color, 1.0);
#include <colorspace_fragment>
}`, hr = `#include <common>
#include <logdepthbuf_pars_vertex>
varying vec2 vUv;
void main() {
vec4 mvPosition = vec4(position, 1.0);
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;
vUv = uv;
#include <logdepthbuf_vertex>
}`;
Fn({ MeshLineGeometry: ar, MeshLineMaterial: dr });
const zn = 800, Rn = 600, Qs = ({ text: t, inBias: n = 0, outBias: e = 0, fontSize: i = 32, rotation: o = 0, spacing: r = 0, verticalAlign: a = 0, horizontalAlign: l = 0 }) => {
const u = ne(Tt), s = C(() => ({
time: new R(0),
size: new R(new he(zn, Rn)),
textPointersOffset: new R(0),
textPointersCount: new R(0),
glyphAtlas: new R(null),
textTexture: new R(null),
in_bias: new R(0),
out_bias: new R(0),
fontSize: new R(32),
rotation: new R(0),
spacing: new R(0),
verticalAlign: new R(0),
horizontalAlign: new R(0),
digits: new R([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
}), []);
return L(() => {
u && (s.glyphAtlas.value = u.glyphAtlas);
}, [s, u]), L(() => {
if (u) {
s.textTexture.value && s.textTexture.value.dispose();
const { texture: c, textPointersOffset: f, textPointersCount: y } = u.encodeTextTexture(t.split(`
`));
s.textTexture.value = c, s.textPointersOffset.value = f, s.textPointersCount.value = y, s.digits.value = [...u.encodeText("0123456789.-").indices];
}
return () => {
u && u.dispose();
};
}, [s, u, t]), L(() => {
s.in_bias.value = n, s.out_bias.value = e, s.fontSize.value = i, s.rotation.value = o, s.spacing.value = r, s.verticalAlign.value = a, s.horizontalAlign.value = l;
}, [s, n, e, i, o, r, a, l]), De(({ clock: c }) => {
s.time.value = c.elapsedTime;
}), u ? /* @__PURE__ */ T("group", { children: /* @__PURE__ */ H("mesh", { children: [
/* @__PURE__ */ T("planeGeometry", { args: [zn, Rn] }),
/* @__PURE__ */ T(
"shaderMaterial",
{
defines: {
GLYPHS_LENGTH: u.glyphsCount
},
uniforms: s,
uniformsGroups: [u.glyphData],
vertexShader: hr,
fragmentShader: pr,
side: Ie
}
)
] }) }) : null;
};
function mr(t, n) {
const e = t.length, i = document.createElement("canvas");
i.width = n, i.height = e, i.style.imageRendering = "-moz-crisp-edges", i.style.imageRendering = "pixelated";
const o = i.getContext("2d");
if (o)
for (let r = 0; r < t.length; r++)
t[r](o, r);
return i;
}
function ge(t, n) {
return (e, i) => {
const o = e.canvas.width, r = e.canvas.width / (o - 1);
for (let a = 0; a < o; ++a)
e.fillStyle = t(a / (o - 1)), e.fillRect(a * r, i, r + 1, 1);
};
}
const be = (t) => (n) => vi(gi, t)(Math.min(Math.max(0, n), 1)), vr = be(["#5d198e", "#2319a1", "#185db6", "#16c1ca", "#14e083", "#19ef20", "#88f427", "#f5f835", "#fca245", "#ff5555"]), gr = be(["#000083", "#001e97", "#003caa", "#0163bb", "#028acc", "#03b1dd", "#04d8ee", "#05ffff", "#37ffcc", "#69ff99", "#9bff66", "#cdff33", "#ffff00", "#fecc00", "#fd9900", "#fc6600", "#fb3300", "#fa0000", "#bd0000", "#800000"]), xr = be(["#0c3383", "#0c448e", "#0b5599", "#0b66a4", "#0a77af", "#0a88ba", "#3897a0", "#67a686", "#95b56c", "#c4c452", "#f2d338", "#f2c238", "#f2b138", "#f2a038", "#f28f38", "#ed7833", "#e8622e", "#e34b28", "#de3523", "#d91e1e"]), yr = be(["#000082", "#005a9b", "#00b4b4", "#14c36e", "#28d228", "#58d72b", "#87dc2d", "#b7e130", "#e6e632", "#c1b128", "#9d7b1e", "#784614", "#895d31", "#9a744f", "#ab8b6c", "#bca38a", "#ccbaa7", "#ddd1c4", "#eee8e2", "#ffffff"]), br = be(["#0d0887", "#2c0694", "#4b03a1", "#5c03a3", "#6c03a6", "#7d03a8", "#93139f", "#a82296", "#b42e8c", "#bf3a83", "#cb4679", "#d8596b", "#e56b5d", "#ef804f", "#f89441", "#faa439", "#fbb330", "#fdc328", "#f7de25", "#f0f921"]), _r = be(["#2a186c", "#262587", "#2132a2", "#1b3f9c", "#154d97", "#0f5a91", "#1c688d", "#287689", "#2e7f88", "#358988", "#3b9287", "#45a183", "#4faf7e", "#64bd73", "#78cb68", "#90d167", "#a9d765", "#c1dd64", "#dfe67f", "#fdef9a"]), wr = be(["#ffe700", "#ffdf00", "#ffd600", "#ffce00", "#ffc500", "#ffbc00", "#ffb400", "#ffab00", "#ffa200", "#ff9a00", "#ff9100", "#ff8900", "#ff8000", "#ff7700", "#ff6f00", "#ff6600", "#ff5e00", "#ff5500", "#f55400", "#ea5200", "#e05100", "#d55000", "#cb4e00", "#c04d00", "#b64b00", "#ab4a00", "#a14900", "#964700", "#8c4600", "#925213", "#975d25", "#9d6938", "#a2744a", "#a8805d", "#ad8b6f", "#b39782", "#b8a294", "#beaea7", "#c3b9b9", "#b7aeae", "#aaa2a2", "#9e9797", "#918b8b", "#858080", "#787474", "#6c6969", "#5f5d5d", "#535252", "#464646", "#404057", "#393968", "#333378", "#2d2d89", "#26269a", "#2020ab", "#1919bc", "#1313cd", "#0d0ddd", "#0606ee", "#0000ff", "#000cff", "#0018ff", "#0024ff", "#0030ff", "#003cff", "#0048ff", "#0054ff", "#0060ff", "#006cff", "#0078ff", "#0084ff", "#0090ff", "#009cff", "#00a8ff", "#00b4ff", "#00c0ff", "#00ccff", "#00d8ff", "#00e4ff", "#00f0ff"]), Tr = be(["#00004c", "#000092", "#0000db", "#3131ff", "#9999ff", "#fdfdff", "#ff9999", "#ff3535", "#e60000", "#b30000", "#800000"]), Ar = be(["#ffffff", "#FFFFBD", "#FFFF71", "#FFFF24", "#FFE300", "#FF9100", "#F90600", "#DB2400", "#C03F00", "#A45B00", "#6D9200", "#3AD500", "#00FF00", "#00EA1E", "#00C03F", "#009F60", "#00AF87", "#00CCB3", "#00ECD9", "#03FBFF", "#19F0FF", "#2ED1FF", "#44BBFF", "#4F9EFF", "#3870FF", "#2143FF", "#0B15FF", "#180CFF", "#4623FF", "#7038FF", "#A150FF", "#BA45FF", "#D12EFF", "#E817FF", "#FF00FF", "#CD00D7", "#9900AE", "#660085", "#300059", "#0B003C"]), Mr = be(["#000", "#fff"]), co = [
ge((t) => vr(1 - t)),
ge((t) => gr(1 - t)),
ge((t) => xr(1 - t)),
ge((t) => yr(1 - t)),
ge((t) => br(1 - t)),
ge((t) => _r(1 - t)),
ge((t) => wr(1 - t)),
ge((t) => Tr(1 - t)),
ge((t) => Ar(1 - t)),
ge((t) => Mr(1 - t))
], uo = Ae(null), re = (t) => {
const n = ne(uo), e = ae((...i) => n.invoke(t, ...i), [t, n]);
return n ? e : () => Promise.resolve(null);
}, Cr = "surfaceGeometry", Pr = "surfaceTextures";
var kr = `#define MESH_SURFACE_MATERIAL
uniform sampler2D normalTexture;
uniform mat3 normalMatrix;
uniform float referenceDepth;
uniform sampler2D depthTexture;
#ifdef USE_COLOR_RAMP
uniform sampler2D colorRampTexture;
uniform int colorRampIndex;
uniform float colorRampMin;
uniform float colorRampMax;
uniform bool colorRampReverse;
uniform int colorRamps;
#endif
#ifdef USE_CONTOURS
uniform float contoursInterval;
uniform int contoursColorMode;
uniform float contoursColorModeFactor;
uniform float contoursThickness;
uniform vec3 contoursColor;
#endif
uniform float saturation;
uniform float brightness;
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#ifndef FLAT_SHADED
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
vec3 hue2rgb(in float H) {
float R = abs(H * 6. - 3.) - 1.;
float G = 2. - abs(H * 6. - 2.);
float B = 2. - abs(H * 6. - 4.);
return saturate(vec3(R, G, B));
}
vec3 hsl2rgb(in vec3 HSL) {
vec3 RGB = hue2rgb(HSL.x);
float C = (1. - abs(2. * HSL.z - 1.)) * HSL.y;
return (RGB - 0.5) * C + HSL.z;
}
vec3 rgb2hsv(in vec3 RGB) {
vec4 P = (RGB.g < RGB.b) ? vec4(RGB.bg, -1.0, 2.0 / 3.0) : vec4(RGB.gb, 0.0, -1.0 / 3.0);
vec4 Q = (RGB.r < P.x) ? vec4(P.xyw, RGB.r) : vec4(RGB.r, P.yzx);
float C = Q.x - min(Q.w, Q.y);
float H = abs((Q.w - Q.y) / (6. * C + EPSILON) + Q.z);
return vec3(H, C, Q.x);
}
vec3 rgb2hsl(in vec3 RGB) {
vec3 HCV = rgb2hsv(RGB);
float L = HCV.z - HCV.y * 0.5;
float S = HCV.y / (1. - abs(L * 2. - 1.) + EPSILON);
return vec3(HCV.x, S, L);
}
vec3 hsv2rgb(in vec3 HSV) {
vec3 RGB = hue2rgb(HSV.x);
return ((RGB - 1.) * HSV.y + 1.) * HSV.z;
}
vec3 adjustColor(vec3 color, float saturation, float brightness) {
vec3 hsl = rgb2hsl(color);
hsl.y = hsl.y * saturation;
vec3 rgb = hsl2rgb(hsl);
rgb += vec3(brightness);
return clamp(rgb, 0.0, 1.0);
}
#ifdef USE_COLOR_RAMP
vec3 getColor(float v) {
float min = colorRampMin;
float max = colorRampMax;
float t = clamp((v - min) / (max - min), 0.0, 1.0);
if(colorRampReverse) {
t = 1.0 - t;
}
vec4 texel = texture2D(colorRampTexture, vec2(t, (float(colorRampIndex) + 0.5) / float(colorRamps)));
return texel.rgb;
}
#endif
float getPointValue(vec2 pos) {
vec4 pixel = texture2D(depthTexture, pos);
if(pixel.a == 0.)
return -1.;
return (referenceDepth - ((pixel.r * 256. * 256. * 256.) + (pixel.g * 256. * 256.) + (pixel.b * 256.)) / 1000.);
}
#ifdef USE_CONTOURS
float contourLine(float v) {
float f = abs(fract(v) - .5);
float df = fwidth(v) * contoursThickness;
return smoothstep(0., df, f);
}
#endif
void main() {
vec3 textureNormal = texture2D(normalTexture, vUv).rgb * 2. - 1.;
vec3 vNormal = normalize(normalMatrix * textureNormal);
#include <clipping_planes_fragment>
vec4 diffuseColor = vec4(diffuse, opacity);
float texDepth = getPointValue(vUv.xy);
if(texDepth <= -1.) {
discard;
}
#ifdef USE_COLOR_RAMP
vec3 sampledColor = getColor(texDepth);
diffuseColor = vec4(sampledColor, opacity);
#endif
#ifdef USE_CONTOURS
float h = (texDepth + contoursInterval / 2.) / contoursInterval;
float t = contourLine(h);
float colorMod = 1.;
if (contoursColorMode == 0) {
colorMod = 1. - (1. - t) * contoursColorModeFactor;
} else if (contoursColorMode == 1) {
colorMod = 1.0 + (1. - t) * contoursColorModeFactor;
}
#endif
ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
diffuseColor = vec4(adjustColor(diffuseColor.rgb, saturation, brightness), diffuseColor.w);
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#ifdef USE_CONTOURS
outgoingLight *= colorMod;
if (contoursColorMode == 2) {
outgoingLight = mix(outgoingLight, contoursColor, (1. - t) * contoursColorModeFactor);
}
#endif
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`, Sr = `#define MESH_SURFACE_MATERIAL
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`;
const Lr = mr(co, 512), Pe = new Gn(Lr);
Pe.magFilter = Ze;
Pe.minFilter = Do;
Pe.flipY = !1;
Pe.generateMipmaps = !1;
Pe.colorSpace = jn;
Pe.format = Hn;
Pe.anisotropy = 4;
var fo = /* @__PURE__ */ ((t) => (t[t.darken = 0] = "darken", t[t.lighten = 1] = "lighten", t[t.mixed = 2] = "mixed", t))(fo || {});
const dt = {
defines: {
USE_COLOR_RAMP: !1,
USE_CONTOURS: !1,
USE_UV: !0
},
uniforms: Re.merge([
Re.clone(qt.lambert.uniforms),
{
colorRampIndex: { value: 0 },
colorRamps: { value: co.length },
colorRampReverse: { value: !0 },
colorRampMin: { value: 800 },
colorRampMax: { value: 1e3 },
colorRampTexture: { value: null },
referenceDepth: { value: 1e3 },
saturation: { value: 1 },
brightness: { value: 0 },
depthTexture: { value: null },
normalTexture: { value: null },
contoursInterval: { value: 100 },
contoursColorMode: { value: 0 },
contoursColorModeFactor: { value: 0.5 },
contoursColor: { value: new Q("black") },
contoursThickness: { value: 0.8 },
size: { value: new he() }
}
]),
vertexShader: Sr,
fragmentShader: kr
};
class zr extends Je {
constructor(e) {
super();
se(this, "isMeshSurfaceShader", !0);
se(this, "normalScale");
se(this, "map");
se(this, "normalMap");
se(this, "wireframeLinecap");
se(this, "wireframeLinejoin");
se(this, "flatShading");
se(this, "combine");
se(this, "normalMapType");
this.defines = Object.assign({}, dt.defines), this.uniforms = Re.clone(dt.uniforms), this.vertexShader = dt.vertexShader, this.fragmentShader = dt.fragmentShader, this.combine = Io, this.normalMapType = Oo, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.lights = !0, this.clipping = !0, this.fog = !0;
const i = [
"map",
"lightMap",
"lightMapIntensity",
"aoMap",
"aoMapIntensity",
"emissive",
"emissiveIntensity",
"emissiveMap",
"specularMap",
"alphaMap",
"envMap",
"reflectivity",
"refractionRatio",
"opacity",
"diffuse",
"normalMap",
"normalScale",
"referenceDepth",
"colorRampIndex",
"colorRampMin",
"colorRampMax",
"colorRampReverse",
"saturation",
"brightness",
"contoursInterval",
"contoursColorMode",
"contoursColorModeFactor",
"contoursThickness",
"normalTexture",
"depthTexture"
];
for (const o of i)
Object.defineProperty(this, o, {
get: function() {
return this.uniforms[o].value;
},
set: function(r) {
this.uniforms[o].value = r;
}
});
this.normalScale = new he(0.25, 0.25), this.color = "white", this.setValues(e);
}
get color() {
return "#" + this.uniforms.diffuse.value.getHexString();
}
set color(e) {
this.uniforms.diffuse.value = new Q(e);
}
get contoursColor() {
return "#" + this.uniforms.contoursColor.value.getHexString();
}
set contoursColor(e) {
this.uniforms.contoursColor.value = new Q(e);
}
get useColorRamp() {
return this.defines.USE_COLOR_RAMP || !1;
}
set useColorRamp(e) {
this.defines.USE_COLOR_RAMP = !!e, this.uniforms.colorRampTexture.value = this.defines.USE_COLOR_RAMP ? Pe : null, this.needsUpdate = !0;
}
get showContours() {
return this.defines.USE_CONTOURS || !1;
}
set showContours(e) {
this.defines.USE_CONTOURS = !!e, this.needsUpdate = !0;
}
// @ignore
dispose() {
var e;
super.dispose(), (e = this.uniforms.depthTexture.value) == null || e.dispose();
}
// @ignore
onBeforeCompile() {
this.map && (this.map.matrixAutoUpdate === !0 && this.map.updateMatrix(), this.uniforms.mapTransform.value.copy(this.map.matrix)), this.normalMap && (this.normalMap.matrixAutoUpdate === !0 && this.normalMap.updateMatrix(), this.uniforms.normalMapTransform.value.copy(this.normalMap.matrix));
}
}
const Zs = ({
meta: t,
color: n,
colorRamp: e = 0,
rampMin: i,
rampMax: o,
reverseRamp: r = !1,
useColorRamp: a = !0,
showContours: l = !1,
contoursInterval: u = 100,
contoursColorMode: s = fo.darken,
contoursColorModeFactor: c = 0.5,
contoursThickness: f = 0.8,
contoursColor: y = "black",
opacity: m = 1,
priority: g = 0,
maxError: p = 5,
doubleSide: x = m === 1 || !1,
wireframe: v = !1,
normalMap: h,
normalScale: _,
name: b,
userData: d,
receiveShadow: A,
castShadow: w,
layers: P = Te(oe.OCCLUDER),
position: z,
renderOrder: E = 10,
visible: M = !0,
onPointerClick: k,
onPointerEnter: I,
onPointerLeave: G,
onPointerMove: K
}) => {
const S = j(null), O = re(Cr), D = re(Pr), [V, Y] = F(null), [te, _e] = F(null), [q, At] = F(null), Fe = C(() => Te(oe.NOT_EMITTER), []), B = C(() => new zr({
useColorRamp: !0,
forceSinglePass: !0,
saturation: 1,
brightness: 0,
colorRampIndex: 0,
colorRampReverse: !1,
colorRampMin: 0,
colorRampMax: 0,
referenceDepth: 0,
side: mt,
wireframe: !1,
flatShading: !1,
transparent: !0,
opacity: 1
}), []), Mt = C(() => new bt({
transparent: !0,
side: Yt,
colorWrite: !1,
depthWrite: !0
}), []), Ne = Zt();
return L(() => {
let ie = null;
if (Ne && S.current) {
const ee = {};
k && (ee.click = k), I && (ee.enter = I), G && (ee.leave = G), K && (ee.move = K), Object.keys(ee).length && (ie = Ne.register(S.current, ee, t.id));
}
return () => {
ie && ie();
};
}, [Ne, k, I, G, K, t.id]), L(() => {
B.uniforms.colorRampIndex.value = e, B.uniforms.opacity.value = m, B.uniforms.contoursColorMode.value = s, B.uniforms.contoursColorModeFactor.value = c, B.uniforms.contoursInterval.value = u, B.uniforms.contoursThickness.value = f, B.uniforms.colorRampMin.value = i, B.uniforms.colorRampMax.value = o, B.uniforms.colorRampReverse.value = r, B.uniforms.referenceDepth.value = t.max, _ && B.uniforms.normalScale.value.set(..._);
}, [
B,
t.max,
e,
m,
l,
s,
c,
u,
f,
i,
o,
r,
_
]), L(() => {
B.wireframe = v, B.showContours = l, B.contoursColor = y, B.useColorRamp = a, B.color = n || B.color, B.side = x ? Ie : mt, h && (B.normalMap = h);
}, [
B,
a,
l,
v,
y,
n,
x,
h
]), L(() => {
D && le(() => D(t.id).then((ie) => {
if (ie) {
const {
elevationImageBuffer: ee,
normalsImageBuffer: Ge
} = ie, Ye = ei(
ee,
t.header.nx,
t.header.ny
), tt = ti(
Ge,
t.header.nx - 1,
t.header.ny - 1
);
_e((ue) => (ue && ue.dispose(), Ye)), At((ue) => (ue && ue.dispose(), tt));
}
}), g);
}, [D, t.id, t.header.nx, t.header.ny, g]), L(() => {
O && le(() => O(t.id, p).then((ie) => {
let ee = null;
ie && (ee = Oe(ie)), Y((Ge) => (Ge && Ge.dispose(), ee));
}), g);
}, [O, t.id, p, g]), L(() => {
te && B && (B.uniforms.depthTexture.value = te);
}, [te, B]), L(() => {
q && B && (B.uniforms.normalTexture.value = q);
}, [q, B]), L(() => () => {
var ie;
(ie = B.normalMap) == null || ie.dispose(), B.dispose();
}, [B]), /* @__PURE__ */ H(
"group",
{
name: b,
userData: d,
visible: M,
renderOrder: E,
position: z,
children: [
V && m < 1 && /* @__PURE__ */ T(
"mesh",
{
ref: S,
geometry: V,
material: Mt,
renderOrder: 1,
layers: Fe
}
),
V && /* @__PURE__ */ T(
"mesh",
{
ref: S,
castShadow: w,
receiveShadow: A,
geometry: V,
material: B,
layers: P,
renderOrder: 2
}
)
]
}
);
}, Jt = ye(({
name: t,
position: n,
userData: e,
castShadow: i,
receiveShadow: o,
renderOrder: r,
visible: a,
data: l,
geometry: u,
material: s,
layers: c,
onPointerClick: f,
onPointerEnter: y,
onPointerLeave: m,
onPointerMove: g
}, p) => {
const x = Zt(), v = C(() => {
const h = l.transformations.length / 16, _ = new Ht(u, s, h);
if (_.instanceMatrix.set(l.transformations), _.instanceMatrix.needsUpdate = !0, l.colors && (_.instanceColor = new Vn(l.colors, 3), _.instanceColor.needsUpdate = !0), c) {
const b = c instanceof Wo ? c.mask : c;
_.layers.mask = b;
}
return _.castShadow = !!i, _.receiveShadow = !!o, _;
}, [u, s, l, c, i, o]);
return Ee(p, () => v), L(() => {
let h = null;
if (x) {
const _ = {};
f && (_.click = f), y && (_.enter = y), m && (_.leave = m), g && (_.move = g), Object.keys(_).length && (h = x.register(v, _));
}
return () => {
h && h();
};
}, [x, v, f, y, m, g]), L(() => {
}, []), /* @__PURE__ */ T(
"group",
{
name: t,
userData: e,
renderOrder: r,
position: n,
visible: a,
children: /* @__PURE__ */ T("primitive", { object: v })
}
);
}), Js = ye(({ utmZone: t, origin: n, originUnits: e = "utm", offset: i = [0, 0, 0], children: o }, r) => {
const a = j(null), l = C(() => {
const s = si(t.toUpperCase());
return new ai(s, n, e);
}, [t, n, e]);
Ee(r, () => l, [l]);
const u = C(() => {
const s = (v, h, _ = 0) => {
const b = l.utmToWorld(v, h, _);
return [b.x, b.y, b.z];
}, c = (v, h, _ = 0) => {
const b = l.wgs84ToWorld(v, h, _);
return [b.x, b.y, b.z];
}, f = (v, h, _) => l.worldToUtm(v, h, _), y = (v, h, _) => {
if (!a.current) throw Error("Missing reference!");
const b = new $();
return a.current.getWorldPosition(b), l.worldToUtm(-b.x + v, -b.y + h, -b.z + _);
}, m = (v, h, _) => l.worldToWgs84(v, h, _), g = (v, h, _) => {
if (!a.current) throw Error("Missing reference!");
const b = new $();
return a.current.getWorldPosition(b), l.worldToWgs84(-b.x + v, -b.y + h, -b.z + _);
}, p = () => {
if (!a.current) throw Error("Missing reference!");
const v = new $();
return a.current.getWorldPosition(v), [v.x, v.y, v.z];
}, x = () => {
const v = p();
return [
v[0] - l.originUtm[0],
-v[1],
v[2] + l.originUtm[1]
];
};
return {
originUtm: l.originUtm,
originWgs84: l.originWgs84,
utmToArea: s,
wgs84ToArea: c,
areaToUtm: f,
worldToUtm: y,
areaToWgs84: m,
worldToWgs84: g,
getWorldPosition: p,
getUtmOrigin: x
};
}, [l]);
return /* @__PURE__ */ T("group", { ref: a, position: i, children: /* @__PURE__ */ T(_t.Provider, { value: u, children: o }) });
}), ea = ({ easting: t, northing: n, altitude: e = 0, children: i }) => {
const o = ne(_t), r = C(() => o.utmToArea(t, n, e), [t, n, e, o]);
return /* @__PURE__ */ T("group", { position: r, children: i });
}, ta = ({ long: t, lat: n, altitude: e = 0, children: i }) => {
const o = ne(_t), r = C(() => o.wgs84ToArea(t, n, e), [t, n, e, o]);
return /* @__PURE__ */ T("group", { position: r, children: i });
}, en = Ae(null), ce = () => {
const t = ne(en);
if (!t)
throw Error("useWellboreContext may only be used within a Wellbore component!");
return t;
}, Rr = "basicTrajectory";
Fn({ ThreeLine: Nn });
const na = ({
name: t,
userData: n,
position: e,
castShadow: i,
receiveShadow: o,
layers: r,
renderOrder: a,
visible: l,
customDepthMaterial: u,
customDistanceMaterial: s,
customMaterial: c,
onMaterialPropertiesChange: f,
color: y = "red",
priority: m = 0
}) => {
const { id: g, fromMsl: p, segmentsPerMeter: x, simplificationThreshold: v } = ce(), h = re(Rr), [_, b] = F(null), d = C(() => f || ((w, P) => {
const z = P;
z.color = new Q(w.color);
}), [f]), A = C(() => c || new Fo({ transparent: !0, opacity: 0.8 }), [c]);
return L(() => {
d({
color: y
}, A);
}, [y, A, d]), L(() => {
h && le(() => h(g, x, v, p, !!c).then((w) => {
if (w) {
const P = Oe(w);
b((z) => (z && z.dispose(), P));
} else
b(null);
}), m);
}, [h, g, p, x, v, c, m]), _ ? /* @__PURE__ */ T(
"threeLine",
{
name: t,
position: e,
userData: n,
renderOrder: a,
layers: r,
castShadow: i,
receiveShadow: o,
visible: l,
geometry: _,
material: A,
customDepthMaterial: u,
customDistanceMaterial: s
}
) : null;
}, oa = ye(({
name: t,
userData: n,
renderOrder: e = 2,
layers: i = Te(oe.OCCLUDER),
position: o,
visible: r,
castShadow: a,
receiveShadow: l,
customMaterial: u,
customDepthMaterial: s,
customDistanceMaterial: c,
onMaterialPropertiesChange: f,
radialSegments: y = 16,
sizeMultiplier: m = 1,
shoeFactor: g = 1,
overrideSegmentsPerMeter: p,
overrideSimplificationThreshold: x,
opacity: v = 1,
fallback: h,
priority: _ = 0
}, b) => {
const {
id: d,
fromMsl: A,
segmentsPerMeter: w,
simplificationThreshold: P
} = ce(), z = re(xi), [E, M] = F(null), [k, I] = F(!1), { segmentsPerMeter: G, simplificationThreshold: K } = C(() => ({
segmentsPerMeter: p !== void 0 ? p : w || 0.1,
simplificationThreshold: x !== void 0 ? x : P || 0
}), [w, P, p, x]), S = C(() => u || [
new pe({
color: "black",
metalness: 0,
roughness: 1
}),
new pe({
color: "#555",
metalness: 1,
roughness: 0.5,
transparent: !0,
opacity: 1
}),
new pe({
color: "#9a9a98",
metalness: 1,
roughness: 0.5,
transparent: !0,
opacity: 1
})
], [u]), O = C(() => f || ((D, V) => {
const Y = V;
Y[1].opacity = D.opacity, Y[2].opacity = D.opacity;
}), [f]);
return L(() => {
O({ opacity: v }, S);
}, [v, S, O]), L(() => {
z && d && le(() => z(
d,
A,
y,
m,
g,
G,
K
).then((D) => {
M((V) => (V && V.dispose(), D != null && D.geometry ? Oe(D.geometry) : null)), D || I(!0);
}), _);
}, [z, d, A, y, m, g, G, K, _]), /* @__PURE__ */ H(
"group",
{
ref: b,
name: t,
userData: n,
renderOrder: e,
visible: r,
position: o,
children: [
E && /* @__PURE__ */ T(ze, { children: /* @__PURE__ */ T("group", { children: E && /* @__PURE__ */ T(
"mesh",
{
geometry: E,
material: S,
layers: i,
castShadow: a,
receiveShadow: l,
customDepthMaterial: s,
customDistanceMaterial: c
},
E.uuid
) }) }),
k && h && h()
]
}
);
}), Er = "casingToolAnnotations", ia = () => {
const { id: t } = ce(), n = j(null), e = re(Er), { addAnnotations: i } = Ve("casings", t);
return L(() => {
let o = null;
if (e && t) {
const r = new $();
le(() => e(t).then((a) => {
a && n.current && (a.forEach((l, u) => {
r.set(...l.position), n.current.localToWorld(r), l.position = r.toArray(), l.id = u.toString();
}), o = i(a || []));
}), 1);
}
return () => {
o && o();
};
}, [i, t, e, n]), /* @__PURE__ */ T("object3D", { ref: n, visible: !1 });
}, ra = ({ id: t, name: n, data: e }) => {
const i = C(() => e.type === "Shoe" ? "#00ffa2" : "#00d0ff", [e]);
return /* @__PURE__ */ T(
"div",
{
style: {
padding: "0.25em 1em",
minWidth: "200px",
borderRadius: "6px",
background: "#181e249f",
fontFamily: "tahoma"
},
children: /* @__PURE__ */ T("div", { style: {
fontSize: "18pt",
whiteSpace: "nowrap",
color: i,
fontWeight: "bold",
overflow: "hidden"
}, children: n })
},
t
);
};
var Dr = `#define LAMBERT
attribute float curveLength;
varying vec3 vViewPosition;
varying vec2 vUv;
varying float vCurveLength;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
vUv = uv;
vCurveLength = curveLength;
}`, Ir = `#define LAMBERT
uniform vec3 uColor1;
uniform vec3 uColor2;
uniform vec3 emissive;
uniform float opacity;
varying vec2 vUv;
varying float vCurveLength;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
float strength = mod(vCurveLength + vUv.x * 2.0, 2.0);
strength = step(1.5, strength);
vec4 diffuseColor = vec4( uColor1 * strength + uColor2 * (1.0 - strength), opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`;
class En extends Je {
constructor(n = {}) {
super({
uniforms: Re.merge([
Re.clone(qt.lambert.uniforms),
{
uColor1: new R(new Q(n.color || "white")),
uColor2: new R(new Q(n.color || "black"))
}
]),
vertexShader: Dr,
fragmentShader: Ir
}), this.setValues(n), this.lights = !0;
}
get color1() {
return this.uniforms.uColor1.value;
}
set color1(n) {
this.uniforms.uColor1.value.set(n);
}
get color2() {
return this.uniforms.uColor2.value;
}
set color2(n) {
this.uniforms.uColor2.value.set(n);
}
}
const sa = ({
name: t,
userData: n,
renderOrder: e = 1,
layers: i = Te(oe.OCCLUDER),
position: o,
visible: r,
castShadow: a,
receiveShadow: l,
customMaterial: u,
customDepthMaterial: s,
customDistanceMaterial: c,
radialSegments: f = 16,
sizeMultiplier: y = 1,
overrideSegmentsPerMeter: m,
overrideSimplificationThreshold: g,
priority: p = 0,
fallback: x
}) => {
const {
id: v,
fromMsl: h,
segmentsPerMeter: _,
simplificationThreshold: b
} = ce(), d = re(yi), [A, w] = F(null), [P, z] = F(!1), { segmentsPerMeter: E, simplificationThreshold: M } = C(() => ({
segmentsPerMeter: m !== void 0 ? m : _ || 0.1,
simplificationThreshold: g !== void 0 ? g : b || 0
}), [_, b, m, g]), k = C(() => u || [
// blank pipe
new pe({
color: "#999",
metalness: 1,
roughness: 0.25
}),
// tube
new pe({
color: "#999",
metalness: 0.8,
roughness: 0.5
}),
// packer
new pe({
color: "#000",
metalness: 0,
roughness: 0.95
}),
// gauge
new pe({
color: "#097",
metalness: 0,
roughness: 1
}),
// plug
new pe({
color: "#444",
metalness: 0.2,
roughness: 1
}),
// pbr
new pe({
color: "#ccc",
metalness: 0,
roughness: 1,
transparent: !0,
opacity: 0.9
}),
// safety valve
new pe({
color: "#c00",
metalness: 0.5,
roughness: 0.75
}),
// spm
new pe({
color: "#4e3e86",
metalness: 0.5,
roughness: 0.75
}),
// screen
new En({
color1: "#777",
color2: "#fff"
}),
// tracer
new En({
color1: "#777",
color2: "orange"
}),
// unknown
new Go({
color: "#ccc"
})
], [u]);
return L(() => {
d && v && le(() => d(v, h, f, y, E, M).then((I) => {
w((G) => (G && G.dispose(), I ? Oe(I) : null)), I || z(!0);
}), p);
}, [d, v, h, y, E, M, p, f]), /* @__PURE__ */ H(
"group",
{
name: t,
userData: n,
renderOrder: e,
visible: r,
position: o,
children: [
A && /* @__PURE__ */ T(
"mesh",
{
geometry: A,
material: k,
layers: i,
castShadow: a,
receiveShadow: l,
customDepthMaterial: s,
customDistanceMaterial: c
},
A.uuid
),
P && x && x()
]
}
);
}, Or = "completionToolAnnotations", Gt = new $(), aa = () => {
const { id: t } = ce(), n = j(null), e = re(Or), { addAnnotations: i } = Ve("completion", t);
return L(() => {
let o = null;
return e && t && le(() => e(t).then((r) => {
r && n.current && (r.forEach((a, l) => {
Gt.set(...a.position), n.current.localToWorld(Gt), a.position = Gt.toArray(), a.id = l.toString();
}), o = i(r || []));
}), 0), () => {
o && o();
};
}, [t, e, i]), /* @__PURE__ */ T("object3D", { ref: n, visible: !1 });
}, Wr = "depth-markers", la = ye(({
depthReferencePoint: t = "MSL",
interval: n = 100,
priority: e = 0
}, i) => {
const o = j(null), { id: r, fromMsl: a } = ce(), l = re(Wr), { addAnnotations: u } = Ve("depth-markers", r);
return Ee(i, () => o.current), L(() => {
let s = null;
if (l && r) {
const c = new $();
le(() => l(r, n, t, a).then((f) => {
f && o.current && (f.forEach((y) => {
c.set(...y.position), o.current.localToWorld(c), y.position = c.toArray();
}), s = u(f || []));
}), e);
}
return () => {
s && s();
};
}, [u, r, l, t, a, n, o, e]), /* @__PURE__ */ T("object3D", { ref: o, visible: !1 });
}), ca = ({ id: t, name: n }) => /* @__PURE__ */ T("div", { style: {
color: "#ccc",
fontFamily: "monospace",
background: "#00000040",
padding: "0 2px",
borderRadius: "4px",
textShadow: "-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000"
}, children: n }, t), Fr = "perforationSymbols";
var Gr = `#include <common>
#include <logdepthbuf_pars_vertex>
varying vec3 vPosition;
varying vec3 vCamera;
void main() {
mat4 instanceModelMatrix = modelMatrix * instanceMatrix;
vec4 modelPosition = instanceModelMatrix * vec4(position.xyz, 1.0);
vec4 cameraPosition = inverse(instanceModelMatrix) * vec4(cameraPosition, 1.0);
vec4 viewPosition = viewMatrix * modelPosition;
gl_Position = projectionMatrix * viewPosition;
#include <logdepthbuf_vertex>
vPosition = position.xyz;
vCamera = cameraPosition.xyz;
}`, Br = `#include <common>
#include <logdepthbuf_pars_fragment>
uniform float uTime;
uniform float uRadius;
uniform float uLength;
varying vec3 vPosition;
varying vec3 vCamera;
vec3 outer = vec3(1.0, 0.2, 0.0);
vec3 inner = vec3(1.0, 1.0, .8);
bool isInside(vec3 pos, float radius) {
if(pos.y < 0.0 || pos.y > uLength)
return false;
return length(pos.xz) < radius;
}
float energyAtPosition(vec3 pos, float radius) {
return pow(1.0 - (length(pos.xz) / radius), 2.0) * smoothstep(1.0, 0.8, pos.y);
}
void main() {
#include <logdepthbuf_fragment>
float STEP_SIZE = uRadius / 20.0;
vec3 viewVector = vPosition - vCamera;
if(length(viewVector) > 500.0) {
gl_FragColor = vec4(mix(vec3(0.8, 0.5, 0.5), vec3(1.0), 0.5), 0.25);
} else {
vec3 direction = normalize(viewVector);
vec3 pos = vPosition.xyz;
float t = 0.0;
float e = 0.0;
float radius = ((uLength - pos.y) / uLength) * uRadius;
do {
float calculatedE = energyAtPosition(pos, radius);
if(calculatedE < e)
break;
e = calculatedE;
t += STEP_SIZE;
pos = vPosition.xyz + direction * t;
radius = ((uLength - pos.y) / uLength) * uRadius;
} while(isInside(pos, radius) && e < 1.0);
e = e + (sin((-vPosition.y + uTime) * 20.0) * 0.003);
float strength = clamp(e, 0.0, 1.0);
vec3 col = mix(outer, inner, strength);
gl_FragColor = vec4(col, strength);
}
}`;
const ua = ye(({
name: t,
userData: n,
renderOrder: e = 11,
layers: i = Te(oe.NOT_EMITTER),
position: o,
visible: r,
castShadow: a,
receiveShadow: l,
customMaterial: u,
customDepthMaterial: s,
customDistanceMaterial: c,
onMaterialPropertiesChange: f,
radialSegments: y = 8,
baseRadius: m = 0.1,
length: g = 1,
sizeMultiplier: p = 1,
priority: x = 0
}, v) => {
const h = j(null), _ = j({
time: 0,
baseRadius: 0,
lenght: 0
}), { id: b, fromMsl: d } = ce(), A = re(Fr), [w, P] = F(null);
Ee(v, () => h.current);
const z = C(() => {
const k = new Yn(m, g, y);
return k.translate(0, g / 2, 0), k;
}, [m, g, y]), E = C(() => u || new Je({
uniforms: {
uTime: new R(0),
uRadius: new R(0),
uLength: new R(0)
},
vertexShader: Gr,
fragmentShader: Br,
depthTest: !0,
depthWrite: !1,
blending: $n,
transparent: !0
}), [u]), M = C(() => f || ((k, I) => {
const G = I;
G.uniforms.uTime.value = k.time, G.uniforms.uRadius.value = k.baseRadius, G.uniforms.uLength.value = k.length;
}), [f]);
return L(() => {
_.current.baseRadius = m, _.current.length = g, M(_.current, E);
}, [m, g, E, M]), L(() => {
A && b && le(() => A(
b,
d,
p
).then((k) => {
P(k);
}), x);
}, [A, b, d, p, x]), De(({ clock: k }) => {
_.current.time = k.elapsedTime, M(_.current, E);
}), /* @__PURE__ */ T("group", { ref: h, children: w && /* @__PURE__ */ T(
Jt,
{
name: t,
userData: n,
renderOrder: e,
visible: r,
position: o,
data: w,
geometry: z,
material: E,
layers: i,
castShadow: a,
receiveShadow: l,
customDepthMaterial: s,
customDistanceMaterial: c
}
) });
}), Ur = "perimeterGeometry";
var Hr = `uniform float uTime;
uniform float uFrom;
uniform float uTo;
uniform float uOpacity;
uniform vec3 uColor;
varying float vLength;
varying vec2 vUv;
#include <common>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
float uDensity = 300.0;
float modulatedLength = mod(vLength - uFrom, uDensity);
float coord1 = modulatedLength / 10.0;
float coord2 = vUv.x * 20.0;
float line1 = abs(fract(coord1 - 0.5) - 0.5) / fwidth(coord1);
float line2 = abs(fract(coord2 - 0.5) - 0.5) / fwidth(coord2);
float line = min(line1, line2);
float strength = 1.0 - min(line, 1.0);
strength = pow(strength, 1.0 / 2.2);
if (vLength < uFrom || vLength > uTo || uOpacity < 0.01) discard;
vec3 color = uColor;
if (!gl_FrontFacing) {
color = mix(color, vec3(0.0), 0.75);
}
gl_FragColor = vec4(color * strength, uOpacity);
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`, jr = `attribute float curveLength;
varying float vLength;
varying vec2 vUv;
varying vec3 vModelPosition;
#include <common>
#include <logdepthbuf_pars_vertex>
void main() {
vec4 modelPosition = modelViewMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelPosition;
#include <logdepthbuf_vertex>
vModelPosition = vModelPosition.xyz;
vLength = curveLength;
vUv = uv;
}`;
const fa = ({
color: t = "#56af3b",
radius: n,
from: e,
to: i,
opacity: o = 0.5,
name: r,
userData: a,
visible: l,
layers: u = Te(oe.NOT_EMITTER),
position: s,
renderOrder: c = 3,
castShadow: f,
receiveShadow: y,
customDepthMaterial: m,
customDistanceMaterial: g,
customMaterial: p,
onMaterialPropertiesChange: x
}) => {
const { id: v, segmentsPerMeter: h, simplificationThreshold: _ } = ce(), b = j(null), d = j({
color: t,
opacity: o,
from: e,
to: i,
time: 0
}), A = re(Ur), [w, P] = F(null);
L(() => {
A && ni(() => A(v, n, h, _)).then((M) => {
if (M) {
const k = Oe(M);
k.computeBoundingBox(), P((I) => (I && I.dispose(), k));
}
});
}, [A, v, n, h, _]);
const z = C(() => x || ((M, k) => {
const I = k;
I.uniforms.uColor.value = new Q(M.color), I.uniforms.uFrom.value = M.from, I.uniforms.uTo.value = M.to, I.uniforms.uOpacity.value = M.opacity, I.uniforms.uTime.value = M.time;
}), [x]), E = C(() => p || new Je({
transparent: !0,
side: Ie,
vertexShader: jr,
fragmentShader: Hr,
uniforms: {
uTime: new R(0),
uFrom: new R(0),
uTo: new R(0),
uOpacity: new R(0),
uColor: new R(new Q("#56af3b"))
}
}), [p]);
return L(() => {
d.current.color = t, d.current.opacity = o, d.current.from = e, d.current.to = i, z(d.current, E);
}, [e, i, o, t, E, z]), De(({ clock: M }) => {
d.current.time = M.getElapsedTime(), z(d.current, E);
}), w ? /* @__PURE__ */ T(
"group",
{
ref: b,
name: r,
userData: a,
visible: l,
position: s,
renderOrder: c,
children: /* @__PURE__ */ T(
"mesh",
{
geometry: w,
material: E,
customDepthMaterial: m,
customDistanceMaterial: g,
layers: u,
castShadow: f,
receiveShadow: y
}
)
}
) : null;
}, Vr = "pickSymbols", Dn = new Kt(), Bt = new $(), In = new Q(), da = ye(({
radialSegments: t = 8,
baseRadius: n = 10,
stratColumnId: e,
showAnnotations: i = !0,
name: o,
userData: r,
position: a,
visible: l,
renderOrder: u,
layers: s = Te(oe.NOT_EMITTER),
castShadow: c,
receiveShadow: f,
priority: y = 0
}, m) => {
const g = j(null), { id: p, fromMsl: x } = ce(), v = re(Vr), { addAnnotations: h } = Ve("picks", p), [_, b] = F(null);
Ee(m, () => g.current);
const d = C(() => new Bo(1, 1, 0.1, t, 1, !1), [t]), A = C(() => new Qt(), []);
return L(() => {
v && p && le(() => v(
p,
e,
x,
n
).then((w) => {
b(w);
}), y);
}, [v, p, x, n, e, y]), L(() => {
let w = null;
if (i && _ && _.data && h) {
const P = _.data.map((z, E) => {
var k;
return Dn.fromArray(_.transformations, E * 16), Bt.setFromMatrixPosition(Dn), (k = g.current) == null || k.localToWorld(Bt), In.fromArray(_.colors, E * 3), {
id: z.id,
name: z.name,
position: Bt.toArray(),
direction: z.direction,
priority: z.level,
data: {
depth: z.depth,
tvd: z.tvd,
color: In.getHexString()
}
};
});
w = h(P);
}
return () => {
w && w();
};
}, [_, h, i]), /* @__PURE__ */ T("group", { ref: g, children: _ && /* @__PURE__ */ T(
Jt,
{
name: o,
userData: r,
renderOrder: u,
visible: l,
position: a,
data: _,
geometry: d,
material: A,
layers: s,
castShadow: c,
receiveShadow: f
}
) });
}), pa = ({ id: t, name: n, data: e }) => {
const i = C(() => `#${e.color}`, [e]);
return /* @__PURE__ */ T(
"div",
{
style: {
padding: "0.25em 0.5em",
borderRadius: "6px",
background: "#000000a0",
fontFamily: "sans-serif",
borderStyle: "solid",
borderColor: `${i}c0`,
borderWidth: "1px 1px 1px 1px"
},
children: /* @__PURE__ */ H("div", { style: {
fontSize: "12pt",
whiteSpace: "nowrap",
color: "white",
overflow: "hidden",
textShadow: "-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000"
}, children: [
n,
/* @__PURE__ */ H("div", { style: { textAlign: "center", fontSize: "9pt", color: "#ffffffc0", textShadow: "none", fontFamily: "monospace" }, children: [
/* @__PURE__ */ T("span", { style: { color: "#ffffff90" }, children: "TVD:" }),
" ",
e.tvd,
" ",
/* @__PURE__ */ T("span", { style: { color: "#ffffff90" }, children: "MD:" }),
" ",
e.depth,
" ",
/* @__PURE__ */ T("span", { style: { color: "#ffffff90" }, children: "Msl" })
] })
] })
},
t
);
}, $r = "shoeSymbols", On = new Kt(), Ut = new $(), ha = ye(({
name: t,
userData: n,
position: e,
visible: i,
renderOrder: o,
layers: r,
castShadow: a,
receiveShadow: l,
radialSegments: u = 16,
sizeMultiplier: s = 10,
color: c = "#ffbb00",
priority: f = 0
}, y) => {
const m = j(null), { id: g, fromMsl: p } = ce(), x = re($r), { addAnnotations: v } = Ve("shoes", g), [h, _] = F(null);
Ee(y, () => m.current);
const b = C(() => {
const A = new Yn(1, 2, u || 16, 1, !1);
return A.translate(0, 1, 0), A;
}, [u]), d = C(() => {
const A = new Qt();
return A.color.set(c), A;
}, [c]);
return L(() => {
x && g && le(() => x(
g,
p,
s
).then((A) => {
_(A);
}), f);
}, [x, g, p, s, f]), L(() => {
let A = null;
if (h) {
const w = h.data.map((P, z) => {
var M;
return On.fromArray(h.transformations, z * 16), Ut.setFromMatrixPosition(On), (M = m.current) == null || M.localToWorld(Ut), {
id: P.id,
name: P.name,
position: Ut.toArray(),
direction: P.direction
};
});
A = v(w);
}
return () => {
A && A();
};
}, [h, v]), /* @__PURE__ */ T("group", { ref: m, children: h && /* @__PURE__ */ T(
Jt,
{
name: t,
userData: n,
renderOrder: o,
visible: i,
position: e,
data: h,
geometry: b,
material: d,
layers: r,
castShadow: a,
receiveShadow: l
}
) });
}), Nr = "tubeTrajectory", ma = ({
name: t,
userData: n,
position: e,
castShadow: i,
receiveShadow: o,
layers: r = Te(oe.OCCLUDER),
renderOrder: a,
visible: l,
customDepthMaterial: u,
customDistanceMaterial: s,
customMaterial: c,
onMaterialPropertiesChange: f,
color: y = "red",
radius: m = 0.5,
radialSegments: g = 16,
priority: p = 0
}) => {
const { id: x, fromMsl: v, segmentsPerMeter: h, simplificationThreshold: _ } = ce(), b = re(Nr), [d, A] = F(null), w = C(() => f || ((z, E) => {
const M = E;
M.color = new Q(z.color);
}), [f]), P = C(() => c || new Qt(), [c]);
return L(() => {
w({
color: y,
radius: m
}, P);
}, [y, m, P, w]), L(() => {
b && le(() => b(x, h, _, v, m, g).then((z) => {
let E = null;
z && (E = Oe(z)), A((M) => (M && M.dispose(), E));
}), p);
}, [b, x, v, h, _, m, g, p]), d ? /* @__PURE__ */ T(
"mesh",
{
name: t,
position: e,
userData: n,
renderOrder: a,
layers: r,
castShadow: i,
receiveShadow: o,
visible: l,
geometry: d,
material: P,
customDepthMaterial: u,
customDistanceMaterial: s
}
) : null;
}, Wn = new $(), va = ({
id: t,
fromMsl: n,
segmentsPerMeter: e = 0.1,
simplificationThreshold: i = 0,
position: o = [0, 0, 0],
visible: r = !0,
onPointerClick: a,
onPointerEnter: l,
onPointerLeave: u,
onPointerMove: s,
children: c
}) => {
const f = j(null), y = C(() => ({
id: t,
fromMsl: n,
segmentsPerMeter: e,
simplificationThreshold: i
}), [n, t, e, i]), m = Zt();
return L(() => {
let g = null;
if (m) {
const p = {};
a && (p.click = a), l && (p.enter = l), u && (p.leave = u), s && (p.move = s), Object.keys(p).length && (g = m.register(f.current, p, t));
}
return () => {
g && g();
};
}, [m, a, l, u, s, t]), L(() => (f.current.getWorldPosition(Wn), dispatchEvent(new li({
id: t,
position: Wn.toArray(),
objectId: f.current.id,
objectUuid: f.current.uuid
})), () => {
dispatchEvent(new ci({ id: t }));
}), [t]), /* @__PURE__ */ T(en.Provider, { value: y, children: /* @__PURE__ */ T("object3D", { position: o, visible: r, ref: f, children: c }) });
}, Yr = "wellboreBounds", pt = new $(), Le = new Uo(), ga = ({
id: t,
fromMsl: n,
boundsSampleSize: e = 250,
visible: i = !1,
children: o
}) => {
const r = j(null), a = re(Yr), [l, u] = F(null), s = C(() => ({ current: 1 / 0 }), []), c = ae((f, y) => {
pt.copy(y.position), r.current.worldToLocal(pt), Le.center.set(...f.main.center), Le.radius = f.main.radius;
const m = Le.distanceToPoint(pt) / y.zoom;
let g = f.sampled.length ? Math.max(Le.radius, m) : Math.max(0, m);
m <= 0 && f.sampled.length && (g = f.sampled.reduce((p, x) => {
Le.center.set(...x.center), Le.radius = x.radius;
const v = Math.max(0, Le.distanceToPoint(pt) / y.zoom);
return Math.min(p, v);
}, f.main.radius)), s.current = g;
}, [s]);
return L(() => {
a && le(() => a(t, n, e), 0).then((f) => {
if (f) {
const y = {
main: {
center: [f[0], f[1], f[2]],
radius: f[3]
},
sampled: []
};
for (let m = 4; m < f.length; m += 4)
y.sampled.push({
center: [f[m], f[m + 1], f[m + 2]],
radius: f[m + 3]
});
u(y);
}
});
}, [t, a, n, e]), De(({ camera: f }) => {
l && c(l, f);
}), /* @__PURE__ */ H("object3D", { ref: r, children: [
/* @__PURE__ */ T(to.Provider, { value: s, children: o }),
// for debug purposes
i && l && /* @__PURE__ */ H("mesh", { position: l.main.center, children: [
/* @__PURE__ */ T("sphereGeometry", { args: [l.main.radius, 32, 16] }),
/* @__PURE__ */ T("meshBasicMaterial", { color: "green", wireframe: !0, transparent: !0, opacity: 0.1 })
] }),
i && l && l.sampled.map((f, y) => /* @__PURE__ */ H("mesh", { position: f.center, children: [
/* @__PURE__ */ T("sphereGeometry", { args: [f.radius, 16, 8] }),
/* @__PURE__ */ T("meshBasicMaterial", { color: "gray", wireframe: !0, transparent: !0, opacity: 0.25 })
] }, y))
] });
}, Kr = "wellboreFormationColumn";
var qr = `#define WELLBORE_RIBBON_MATERIAL
uniform vec3 diffuse;
uniform float opacity;
varying float vLength;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
float aaf = fwidth(vLength);
float seperator = smoothstep(0.0, 2.0 * aaf, vLength) + 0.5;
vec4 diffuseColor = vec4( mix(vec3(0.0), diffuse, seperator), opacity );
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`, Xr = `#define WELLBORE_RIBBON_MATERIAL
attribute float curveRelativeLength;
varying float vLength;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
vLength = curveRelativeLength;
}`;
const xa = ({
name: t,
userData: n,
position: e,
opacity: i = 1,
castShadow: o,
receiveShadow: r,
renderOrder: a,
layers: l = Te(oe.NOT_EMITTER, oe.OCCLUDER),
visible: u,
stratColumnId: s,
units: c,
unitTypes: f,
inverted: y = !0,
radialSegments: m = 16,
startRadius: g = 0.5,
formationWidth: p = 1,
priority: x = 0
}) => {
const { id: v, fromMsl: h, segmentsPerMeter: _, simplificationThreshold: b } = ce(), d = re(Kr), [A, w] = F(null), P = C(() => Re.merge([
Re.clone(qt.basic.uniforms),
{
opacity: new R(1)
}
]), []);
return L(() => {
P.opacity.value = i;
}, [i, P]), L(() => {
d && le(() => d(
v,
s,
_,
h,
c,
f,
g,
p,
!y,
m,
b
).then((z) => {
let E = null;
z && (E = Oe(z)), w((M) => (M && M.dispose(), E));
}), x);
}, [
d,
v,
s,
h,
c,
f,
_,
b,
g,
p,
m,
x,
y
]), A ? /* @__PURE__ */ T(
"mesh",
{
name: t,
position: e,
userData: n,
renderOrder: a,
castShadow: o,
receiveShadow: r,
visible: u,
layers: l,
geometry: A,
children: /* @__PURE__ */ T(
"shaderMaterial",
{
vertexColors: !0,
side: y ? Yt : mt,
vertexShader: Xr,
fragmentShader: qr,
uniforms: P,
transparent: i === void 0 || i < 1,
opacity: i,
depthTest: !0
}
)
}
) : null;
}, ya = ({ id: t, name: n, data: e }) => /* @__PURE__ */ T("div", { style: {
color: e.color || "#ccc",
fontSize: `${e.size || 12}pt`,
fontFamily: "monospace",
background: "#00000040",
padding: "0 2px",
borderRadius: "4px",
textShadow: "-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000"
}, children: n }, t), Qr = "wellboreLabel", ba = ({ size: t = 12, color: n = "white", position: e = "bottom" }) => {
const { id: i, fromMsl: o } = ce(), r = j(null), a = re(Qr), { addAnnotations: l } = Ve("wellbore-labels", i);
return L(() => {
let u = null;
if (a && i) {
const s = new $();
le(() => a(i, e, o).then((c) => {
c && r.current && (c.forEach((f) => {
s.set(...f.position), r.current.localToWorld(s), f.position = s.toArray(), f.data = { color: n, size: t };
}), u = l(c || []));
}), 1);
}
return () => {
u && u();
};
}, [l, i, a, o, e, r, n, t]), /* @__PURE__ */ T("object3D", { ref: r, visible: !1 });
}, tn = Ae(null);
function Zr(t, n, e, i) {
const o = new Float32Array([
0,
-0.5,
1,
-0.5,
1,
0.5,
0,
0.5
]), r = i !== void 0 ? t.getPositionAtDepth(i, !0) : 0, a = oi(
t.curve,
r,
1,
n,
e
), l = ii(t.curve, a), u = new Float32Array(l.length * 7);
for (let f = 0; f < l.length; f++) {
const y = l[f], m = f * 7;
u[m] = y.position[0], u[m + 1] = y.position[1], u[m + 2] = y.position[2], u[m + 3] = y.curvePosition, u[m + 4] = y.tangent[0], u[m + 5] = y.tangent[1], u[m + 6] = y.tangent[2];
}
const s = new Ho(u, 7, 1), c = new jo();
return c.instanceCount = l.length - 1, c.setIndex(new on(new Uint8Array([0, 1, 2, 0, 2, 3]), 1)), c.setAttribute("position2", new on(o, 2)), c.setAttribute("point0", new st(s, 4, 0)), c.setAttribute("point1", new st(s, 4, 7)), c.setAttribute("tangent0", new st(s, 3, 4)), c.setAttribute("tangent1", new st(s, 3, 11)), c;
}
const _a = ({ children: t }) => {
const n = $e(), { id: e, fromMsl: i, segmentsPerMeter: o, simplificationThreshold: r } = ce(), [a, l] = F(null), [u, s] = F([0, -1, 0]), c = C(() => a ? Zr(a, o, r, i) : null, [a, o, r, i]), f = C(() => a && c ? {
trajectory: a,
direction: u,
geometry: c
} : null, [a, u, c]);
return L(() => {
function y(g) {
if (a) {
const p = a.curve.nearest(g.detail);
s(a.curve.getTangentAt(p.position));
}
}
function m(g) {
if (a) {
const p = a.curve.nearest(g.detail.point);
s(a.curve.getTangentAt(p.position));
}
}
return addEventListener(sn, y), addEventListener(an, m), () => {
removeEventListener(sn, y), removeEventListener(an, m);
};
}, [a]), L(() => {
n && n.get("position-logs", e).then((y) => {
const m = Zn(e, y);
l(m);
}).catch((y) => console.error(y));
}, [n, e]), a ? /* @__PURE__ */ T(tn, { value: f, children: t }) : null;
}, Tt = Ae(null);
var Jr = `#include <common>
#include <logdepthbuf_pars_fragment>
uniform vec2 size;
uniform sampler2D glyphAtlas;
uniform float in_bias;
uniform float out_bias;
uniform GlyphData {
vec4 glyphPosition[GLYPHS_LENGTH];
vec3 glyphOffset[GLYPHS_LENGTH];
vec2 glyphTextureSize;
float glyphFontSize;
float glyphPixelRange;
float glyphLineHeight;
float glyphBaseLine;
};
varying vec2 vUv;
struct GlyphParams {
vec2 position;
uint index;
};
uint _numDigits(float number) {
float log10 = 0.4342944819032518 * log(number);
return uint(max(trunc(log10), 0.0) + 1.0);
}
uint _getDigit(float number, uint position) {
return uint(trunc(mod(number / pow(10.0, float(position - 1u)), 10.0)));
}
float _median(float r, float g, float b) {
return max(min(r, g), min(max(r, g), b));
}
vec2 _calcGlyphUv(vec2 texPos) {
vec2 glyphUv = vec2(texPos.x / glyphTextureSize.x, (glyphTextureSize.y - texPos.y) / glyphTextureSize.y);
return clamp(glyphUv, 0.0, 1.0);
}
float _calculateGlyphVerticalOffset(float vAlign) {
float pxRangeOffset = floor(glyphPixelRange / 2.0);
float lineHightOffset = glyphLineHeight / 2.0;
float vAlignOffset = (glyphFontSize / 2.0) * vAlign;
return lineHightOffset + pxRangeOffset + vAlignOffset;
}
float _screenPixelRange(float scale) {
vec2 scaledSize = size * scale;
vec2 screenPxRange = glyphPixelRange / fwidth(vUv * scaledSize);
return max(min(screenPxRange.x, screenPxRange.y), 1.0);
}
float _sdfGlyph(vec2 p, uint glyphId) {
vec2 offset = vec2(p.x - glyphOffset[glyphId].x, p.y - glyphOffset[glyphId].y);
vec2 uv = glyphPosition[glyphId].xy + offset;
float sigDist = -0.5;
if(offset.x >= 0.0 && offset.y >= 0.0 && offset.x <= glyphPosition[glyphId].z && offset.y <= glyphPosition[glyphId].w) {
vec2 TexCoord = _calcGlyphUv(uv);
vec3 mdf = texture2D(glyphAtlas, TexCoord).rgb;
sigDist = _median(mdf.r, mdf.g, mdf.b);
}
return sigDist;
}
void renderGlyph(inout vec3 outColor, vec2 position, uint glyphId, vec3 glyphColor, float pxRange) {
float dist = _sdfGlyph(position, glyphId);
float e = pxRange * (dist - 0.5 + in_bias) + 0.5 + out_bias;
float contour = clamp(e, 0.0, 1.0);
outColor = mix(outColor, glyphColor, contour);
}
uniform usampler2D textTexture;
uniform uint textPointersCount;
uniform uint textPointersOffset;
uint _readGlyphIdFromTexture(uint index) {
uint value = texelFetch(textTexture, ivec2(index, 0), 0).r;
return value;
}
GlyphParams _findGlyph(vec2 pixelCoords, uvec3 textPointer, float spacing) {
uint id = _readGlyphIdFromTexture(textPointer.x);
float width = glyphOffset[id].z + spacing;
vec2 position = pixelCoords.xy;
uint i = textPointer.x;
while(position.x >= width && i++ < textPointer.y - 1u) {
position.x -= width;
uint j = _readGlyphIdFromTexture(i);
id = j;
width = glyphOffset[id].z + spacing;
};
return GlyphParams(position, id);
}
uvec3 readTextPointerFromTexture(uint index) {
uvec3 pointer = uvec3(0u);
uint pos = (index * 3u) + textPointersOffset;
pointer.x = texelFetch(textTexture, ivec2(pos, 0), 0).r;
pointer.y = texelFetch(textTexture, ivec2(pos + 1u, 0), 0).r;
pointer.z = texelFetch(textTexture, ivec2(pos + 2u, 0), 0).r;
return pointer;
}
void renderText(
inout vec3 outColor,
vec2 position,
uvec3 textPointer,
float verticalAlign,
float horizontalAlign,
vec3 textColor,
float spacing,
float scale
) {
if(textPointer.z == 0u)
return;
float spacingWidth = spacing * float(textPointer.y - textPointer.x - 1u);
position.x += (float(textPointer.z) + spacingWidth) * horizontalAlign;
vec2 pos = position;
pos.y += _calculateGlyphVerticalOffset(verticalAlign);
if(pos.x < 0.0)
return;
GlyphParams params = _findGlyph(pos, textPointer, spacing);
renderGlyph(outColor, params.position, params.index, textColor, _screenPixelRange(scale));
}
float sdfLine(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a;
vec2 ba = b - a;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
return length(pa - ba * h);
}
float sdfBox(vec2 p, vec2 b) {
vec2 d = abs(p) - b;
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
}
float sdfCircle(vec2 p, float r) {
return length(p) - r;
}
mat2 rotation2d(float angle) {
float s = sin(angle);
float c = cos(angle);
return mat2(c, -s, s, c);
}
mat4 rotation3d(vec3 axis, float angle) {
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(
oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0
);
}
const vec3 BLACK = vec3(0.0);
const vec3 WHITE = vec3(1.0);
const vec3 GRAY = vec3(0.5);
const vec3 LIGHTGRAY = vec3(0.75);
const vec3 RED = vec3(0.8, 0.0, 0.0);
const vec3 GREEN = vec3(0.0, 0.8, 0.0);
const vec3 BLUE = vec3(0.0, 0.0, 0.8);
struct Unit {
uint index;
vec3 color;
};
uniform vec3 intervals[INTERVALS_LENGTH];
uniform Unit units[UNITS_LENGTH];
uniform float startDepth;
const float padding = 0.9;
float lines(float v, float lineWidth) {
float uvDeriv = fwidth(v * 2.0);
float drawWidth = clamp(lineWidth, uvDeriv, 0.5);
float lineAA = uvDeriv * 1.5;
float fraction = 1.0 - abs(fract(v) * 2.0 - 1.0);
float line = smoothstep(drawWidth + lineAA, drawWidth - lineAA, abs(fraction * 2.0));
line *= saturate(lineWidth / drawWidth);
return line;
}
vec3 currentInterval(vec2 position) {
int index = 0;
int nIntervals = int(INTERVALS_LENGTH);
vec3 interval = intervals[index];
while (position.y > interval.y && index < nIntervals - 1) {
index++;
interval = intervals[index];
}
return interval;
}
void main() {
#include <logdepthbuf_fragment>
vec3 color = LIGHTGRAY;
float colorMultiplier = 1.0;
vec2 uv = vUv.xy;
if (!gl_FrontFacing) {
colorMultiplier = 0.5;
uv.x = 1.0 - uv.x;
}
float alpha = 0.95;
vec2 pixelCoords = vec2(uv.x, 1.0 - uv.y) * size;
pixelCoords.y += startDepth;
vec3 interval = currentInterval(pixelCoords);
float intervalLength = interval.y - interval.x;
Unit unit = units[int(interval.z)];
if (pixelCoords.y < interval.x || pixelCoords.y > interval.y) {
discard;
}
uvec3 textPointer = readTextPointerFromTexture(unit.index);
float rotation = 0.0;
float span = size.x * padding;
float vscale = glyphLineHeight / (intervalLength * padding);
if (intervalLength > size.x) {
span = intervalLength * padding;
vscale = glyphLineHeight / (size.x * padding);
rotation = (-PI / 2.0);
}
float hscale = float(textPointer.z) / span;
float scale = max(hscale, vscale);
scale = max(scale, glyphLineHeight / (size.x * 0.5));
vec2 pos = pixelCoords.xy;
pos.x -= size.x / 2.0;
pos.y -= ((interval.x + intervalLength / 2.0));
float frame = sdfBox(pos, vec2(size.x / 2.0, intervalLength / 2.0));
float frameAA = min(fwidth(pixelCoords.y), fwidth(pixelCoords.x));
color = mix( color, BLACK, smoothstep(1.5 * frameAA,0.0,frame) );
color = mix( color, unit.color, smoothstep(0.0,-frameAA * 1.5,frame) );
pos *= scale;
pos *= rotation2d(rotation);
float luminance = (0.299 * unit.color.r + 0.587 * unit.color.g + 0.114 * unit.color.b);
vec3 textColor = luminance < 0.25 ? LIGHTGRAY : BLACK;
renderText(
color,
pos,
textPointer,
0.17,
0.5,
textColor,
0.0,
scale
);
gl_FragColor = vec4(color * colorMultiplier, alpha);
#include <colorspace_fragment>
}`, po = `#include <common>
#include <logdepthbuf_pars_vertex>
mat2 rotation2d(float angle) {
float s = sin(angle);
float c = cos(angle);
return mat2(c, -s, s, c);
}
mat4 rotation3d(vec3 axis, float angle) {
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(
oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0
);
}
uniform vec3 direction;
uniform float width;
uniform float offset;
attribute vec2 position2;
attribute vec4 point0;
attribute vec4 point1;
attribute vec3 tangent0;
attribute vec3 tangent1;
varying vec2 vUv;
varying vec3 vNormal;
varying vec3 vTangent;
flat varying int instanceID;
void main() {
vec4 curveDirection = modelViewMatrix * vec4(direction, 0.0);
vec4 p0 = modelViewMatrix * vec4(point0.xyz, 1.0);
vec4 p1 = modelViewMatrix * vec4(point1.xyz, 1.0);
vec3 tangent = (modelViewMatrix * vec4(mix(tangent0, tangent1, position2.x), 0.0)).xyz;
vec3 binormal = normalize(cross(normalize(curveDirection.xyz), vec3(0.0, 0.0, -1.0)));
vec3 normal = normalize(cross(tangent, binormal));
vec3 point = mix(p0.xyz, p1.xyz, position2.x) + binormal * position2.y * width + binormal * offset;
gl_Position = projectionMatrix * vec4(point, 1.0);
vUv = vec2(position2.y + 0.5, 1.0 - mix(point0.w, point1.w, position2.x));
vNormal = normal;
vTangent = tangent;
instanceID = gl_InstanceID;
#include <logdepthbuf_vertex>
}`;
const wa = ({ width: t, offset: n, stratColumnId: e, level: i }) => {
const o = $e(), r = ne(tn), a = ne(Tt), { id: l } = ne(en), [u, s] = F(null), c = C(() => ({
size: new R(new he()),
direction: new R(new $(0, -1, 0)),
startDepth: new R(0),
width: new R(20),
offset: new R(0),
glyphAtlas: new R(null),
textTexture: new R(null),
textPointersCount: new R(0),
textPointersOffset: new R(0),
intervals: new R([new $()]),
units: new R([{ index: 0, color: new Q() }])
}), []);
return L(() => {
o && a && qn(l, e, o, !0).then((f) => {
if (f) {
const y = Xn(f.matched, f.wellbore.depthMdMsl);
let m = y;
i !== void 0 && (m = y.filter((b) => b.unit.level === i));
const g = Qn(m), p = /* @__PURE__ */ new Map(), x = [], v = [], h = [];
g.forEach((b) => {
const d = b.unit.name;
let A = p.get(d);
if (A === void 0) {
A = x.length;
const w = {
index: A,
color: new Q(b.unit.color)
};
p.set(d, A), x.push(w), v.push(d);
}
h.push(new $(b.mdMslTop, b.mdMslBottom, A));
});
const _ = a.encodeTextTexture(v);
s((b) => (b && b.text.texture.dispose(), {
intervals: h,
text: _,
units: x
}));
}
}).catch(console.error);
}, [o, e, l, a, i]), L(() => {
c.offset.value = n, c.width.value = t, r && (c.size.value.set(t, r.trajectory.measuredLength), c.direction.value.set(...r.direction), c.startDepth.value = r.trajectory.measuredTop), u && (c.intervals.value = u.intervals, c.units.value = u.units, c.textTexture.value = u.text.texture, c.textPointersCount.value = u.text.textPointersCount, c.textPointersOffset.value = u.text.textPointersOffset);
}, [c, t, n, u, r]), L(() => {
a && (c.glyphAtlas.value = a.glyphAtlas);
}, [c, a]), L(() => {
}, [r, c, t]), !r || !a || !u ? null : /* @__PURE__ */ T("mesh", { frustumCulled: !1, geometry: r.geometry, children: /* @__PURE__ */ T(
"shaderMaterial",
{
defines: {
GLYPHS_LENGTH: a.glyphsCount,
INTERVALS_LENGTH: u.intervals.length,
UNITS_LENGTH: u.units.length
},
uniforms: c,
uniformsGroups: [a.glyphData],
vertexShader: po,
fragmentShader: Jr,
side: Ie,
transparent: !0
}
) });
};
var es = `#include <common>
#include <logdepthbuf_pars_fragment>
uniform float fontSize;
uniform float stepSize;
uniform float startDepth;
uniform vec2 size;
uniform sampler2D glyphAtlas;
uniform float in_bias;
uniform float out_bias;
uniform GlyphData {
vec4 glyphPosition[GLYPHS_LENGTH];
vec3 glyphOffset[GLYPHS_LENGTH];
vec2 glyphTextureSize;
float glyphFontSize;
float glyphPixelRange;
float glyphLineHeight;
float glyphBaseLine;
};
varying vec2 vUv;
struct GlyphParams {
vec2 position;
uint index;
};
uint _numDigits(float number) {
float log10 = 0.4342944819032518 * log(number);
return uint(max(trunc(log10), 0.0) + 1.0);
}
uint _getDigit(float number, uint position) {
return uint(trunc(mod(number / pow(10.0, float(position - 1u)), 10.0)));
}
float _median(float r, float g, float b) {
return max(min(r, g), min(max(r, g), b));
}
vec2 _calcGlyphUv(vec2 texPos) {
vec2 glyphUv = vec2(texPos.x / glyphTextureSize.x, (glyphTextureSize.y - texPos.y) / glyphTextureSize.y);
return clamp(glyphUv, 0.0, 1.0);
}
float _calculateGlyphVerticalOffset(float vAlign) {
float pxRangeOffset = floor(glyphPixelRange / 2.0);
float lineHightOffset = glyphLineHeight / 2.0;
float vAlignOffset = (glyphFontSize / 2.0) * vAlign;
return lineHightOffset + pxRangeOffset + vAlignOffset;
}
float _screenPixelRange(float scale) {
vec2 scaledSize = size * scale;
vec2 screenPxRange = glyphPixelRange / fwidth(vUv * scaledSize);
return max(min(screenPxRange.x, screenPxRange.y), 1.0);
}
float _sdfGlyph(vec2 p, uint glyphId) {
vec2 offset = vec2(p.x - glyphOffset[glyphId].x, p.y - glyphOffset[glyphId].y);
vec2 uv = glyphPosition[glyphId].xy + offset;
float sigDist = -0.5;
if(offset.x >= 0.0 && offset.y >= 0.0 && offset.x <= glyphPosition[glyphId].z && offset.y <= glyphPosition[glyphId].w) {
vec2 TexCoord = _calcGlyphUv(uv);
vec3 mdf = texture2D(glyphAtlas, TexCoord).rgb;
sigDist = _median(mdf.r, mdf.g, mdf.b);
}
return sigDist;
}
void renderGlyph(inout vec3 outColor, vec2 position, uint glyphId, vec3 glyphColor, float pxRange) {
float dist = _sdfGlyph(position, glyphId);
float e = pxRange * (dist - 0.5 + in_bias) + 0.5 + out_bias;
float contour = clamp(e, 0.0, 1.0);
outColor = mix(outColor, glyphColor, contour);
}
uniform uint digits[12];
float renderNumber(
inout vec3 outColor,
vec2 position,
float number,
uint decimals,
float verticalAlign,
float horizontalAlign,
vec3 textColor,
float spacing,
float scale
) {
float width = 0.0;
float totalWidth = 0.0;
float offset = 0.0;
uvec2 temp[30];
uint glyphId;
uint nDigits;
vec2 pos = position.xy;
uint c = 0u;
if (number < 0.0) {
glyphId = digits[11];
width = glyphOffset[glyphId].z + spacing;
offset = width;
temp[c++] = uvec2(glyphId, width);
number = -number;
}
float intPart;
float fractPart = modf(number, intPart);
fractPart *= pow(10.0, float(decimals));
nDigits = _numDigits(intPart);
for(uint n = 0u; n < nDigits; n++) {
glyphId = digits[_getDigit(intPart, nDigits - n)];
width = glyphOffset[glyphId].z + spacing;
temp[c++] = uvec2(glyphId, width);
totalWidth += width;
}
if(decimals > 0u) {
glyphId = digits[10];
width = glyphOffset[glyphId].z + spacing;
temp[c++] = uvec2(glyphId, width);
totalWidth += width;
nDigits = _numDigits(fractPart);
for(uint n = 0u; n < decimals; n++) {
glyphId = digits[_getDigit(fractPart, nDigits - n)];
width = glyphOffset[glyphId].z + spacing;
temp[c++] = uvec2(glyphId, width);
totalWidth += width;
}
}
if(c > 0u) {
pos.x += (totalWidth - spacing) * horizontalAlign + offset;
pos.y += _calculateGlyphVerticalOffset(verticalAlign);
uint n = 0u;
while (n < c && pos.x > float(temp[n].y)) pos.x -= float(temp[n++].y);
if (n < c) renderGlyph(outColor, pos, temp[n].x, textColor, _screenPixelRange(scale));
}
return totalWidth;
}
const vec3 BLACK = vec3(0.0);
const vec3 WHITE = vec3(1.0);
const vec3 GRAY = vec3(0.5);
const vec3 LIGHTGRAY = vec3(0.75);
const vec3 RED = vec3(0.8, 0.0, 0.0);
const vec3 GREEN = vec3(0.0, 0.8, 0.0);
const vec3 BLUE = vec3(0.0, 0.0, 0.8);
float lines(float v, float lineWidth) {
float uvDeriv = fwidth(v * 2.0);
float drawWidth = clamp(lineWidth, uvDeriv, 0.5);
float lineAA = uvDeriv * 1.5;
float fraction = 1.0 - abs(fract(v) * 2.0 - 1.0);
float line = smoothstep(drawWidth + lineAA, drawWidth - lineAA, abs(fraction * 2.0));
line *= saturate(lineWidth / drawWidth);
return line;
}
void main() {
#include <logdepthbuf_fragment>
vec3 color = WHITE;
vec2 uv = vUv.xy;
if(!gl_FrontFacing) {
color = LIGHTGRAY;
uv.x = 1.0 - uv.x;
}
vec2 pixelCoords = vec2(uv.x, 1.0 - uv.y) * size;
pixelCoords.y += startDepth;
float scale = glyphFontSize / fontSize;
float ticks = ceil((size.y + 1.0 + startDepth) / stepSize);
float spacing = stepSize * scale;
float y = pixelCoords.y;
y *= scale;
float iy = round(y / spacing);
iy = clamp(iy, 0.0, ticks - 1.0);
float number = iy * stepSize;
float x = pixelCoords.x - size.x * 0.65;
x *= scale;
vec2 p = vec2(x, y - spacing * iy);
renderNumber(color, p, number, 0u, 0.17, 1.0, BLACK, 0.0, scale);
float minY = ((1.0 - vUv.y) * size.y + startDepth) / (stepSize / 10.0);
float minLines = lines(minY, fontSize * 0.05 / (stepSize / 10.0));
minLines = minLines * step(size.x * 0.75, pixelCoords.x);
color = mix(color, GRAY, minLines);
float majY = ((1.0 - vUv.y) * size.y + startDepth) / stepSize;
float majLines = lines(majY, fontSize * 0.1 / stepSize);
majLines = majLines * step(size.x * 0.7, pixelCoords.x);
color = mix(color, BLACK, majLines);
gl_FragColor = vec4(color, 0.95);
#include <colorspace_fragment>
}`;
const Ta = ({ width: t, offset: n, stepSize: e = 50 }) => {
const i = ne(tn), o = ne(Tt), r = C(() => ({
direction: new R(new $(0, -1, 0)),
width: new R(20),
offset: new R(0),
fontSize: new R(3),
size: new R(new he()),
startDepth: new R(0),
stepSize: new R(50),
glyphAtlas: new R(null),
digits: new R([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
}), []);
return L(() => {
o && (r.glyphAtlas.value = o.glyphAtlas, r.digits.value = [...o.encodeText("0123456789.-").indices]);
}, [r, o]), L(() => {
r.width.value = t, r.offset.value = n, r.stepSize.value = e;
}, [r, t, n, e]), L(() => {
i && (r.size.value.set(t, i.trajectory.measuredLength), r.startDepth.value = i.trajectory.measuredTop);
}, [r, i, t]), L(() => {
i && r.direction.value.set(...i.direction);
}, [i, r]), !i || !o ? null : /* @__PURE__ */ T("mesh", { frustumCulled: !1, geometry: i.geometry, children: /* @__PURE__ */ T(
"shaderMaterial",
{
defines: {
GLYPHS_LENGTH: o.glyphsCount
},
uniforms: r,
uniformsGroups: [o.glyphData],
vertexShader: po,
fragmentShader: es,
side: Ie,
transparent: !0
}
) });
};
function ts(t, n, e) {
const i = new Map(t.map((l) => [l.id, l])), o = fn(t, (l) => l.well), r = fn(n.filter((l) => i.has(l)).map((l) => i.get(l)), (l) => l.well);
let a = {};
return o.forEach((l, u) => {
const s = r.get(u) || [], c = l.reduce((y, m) => ({ ...y, [m.name]: m }), {}), f = eo(c, s, e);
a = { ...a, ...f };
}), a;
}
const Aa = ye(({
wellbores: t,
included: n = t.map((a) => a.id),
selected: e,
renderWellbore: i,
children: o
}, r) => {
const a = C(() => t.reduce((c, f) => ({ ...c, [f.id]: f }), {}), [t]), l = C(() => ts(t, n, e), [t, n, e]), u = C(() => {
if (!e) return null;
const c = t.find((f) => f.id === e);
return c ? c.well : null;
}, [e, t]), s = C(() => ({
getHeader: (f) => a[f]
}), [a]);
return Ee(r, () => s, [s]), l && /* @__PURE__ */ H(ze, { children: [
i && n.map((c, f) => /* @__PURE__ */ T(Nt, { children: a[c] && l[c] && i(
a[c],
l[c][0],
e === c,
a[c].well === u,
l[c][1],
f
) }, c)),
o
] });
});
function ns(t) {
return !!t[Xt];
}
const Ma = ({ store: t, children: n }) => {
const e = C(() => ns(t), [t]), i = ae(() => t, [t]), o = ae(() => e ? t[Xt]() : Promise.reject("Unable to connect to store!"), [t, e]);
return /* @__PURE__ */ T(wt.Provider, { value: { isRemote: e, connect: i, connectByMessagePort: o }, children: n });
};
function os(t) {
return !!t[Xt];
}
const Ca = ({ registry: t, children: n }) => {
const [e, i] = F(!1), o = ne(wt), r = C(() => os(t), [t]);
return L(() => {
if (o)
if (o.isRemote && r)
o.connectByMessagePort().then((a) => {
if (a)
t.connectRemoteStore(Vo(a, [a])).then(() => i(!0));
else
throw Error("Unable to get port!");
});
else {
const a = o.connect();
a && (t.setStore(r ? $o(a) : a), i(!0));
}
}, [o, t, r]), /* @__PURE__ */ T(uo.Provider, { value: t, children: e && n });
};
async function is(t) {
const n = await fetch(
t,
{
method: "GET",
credentials: "omit",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
}
), { status: e } = n;
if ([404, 202, 204].includes(e))
return null;
if (n.ok)
return await n.json();
throw new Error(n.toString());
}
const Pa = ({ fontAtlasUrl: t, fontConfigUrl: n, children: e }) => {
const i = ri(t, (l) => {
l.generateMipmaps = !1, l.magFilter = Ze, l.minFilter = Ze, l.flipY = !0;
}), [o, r] = F(null);
L(() => {
is(`${n}`).then((l) => {
r(ui(l));
}).catch((l) => console.error(l));
}, [n]);
const a = C(() => o ? {
glyphAtlas: i,
encodeText: (l) => o.encodeText(l),
encodeTextTexture: (l) => o.encodeTextTexture(l),
glyphData: o.glyphData,
glyphsCount: o.glyphsCount,
dispose: o.dispose
} : null, [o, i]);
return L(() => () => {
a && (a.glyphAtlas.dispose(), a.dispose());
}, [a]), /* @__PURE__ */ T(Tt.Provider, { value: a, children: e });
}, rs = "depth-changed";
class ka extends CustomEvent {
constructor(n) {
super(rs, { detail: n });
}
}
export {
Es as Annotations,
Ds as AnnotationsLayer,
na as BasicTrajectory,
Fs as BoxGrid,
za as CameraFocusAtPointEvent,
Ra as CameraSetPositionEvent,
Is as CameraTargetMarker,
ia as CasingAnnotations,
ra as CasingLabel,
oa as Casings,
aa as CompletionAnnotations,
sa as CompletionTools,
fo as ContourColorMode,
lo as DarkTheme,
wt as DataContext,
Ma as DataProvider,
ka as DepthChangedEvent,
ca as DepthMarkerLabel,
la as DepthMarkers,
Os as Distance,
to as DistanceContext,
Bs as EventEmitter,
oo as EventEmitterContext,
wa as FormationsStripe,
uo as GeneratorsContext,
Ca as GeneratorsProvider,
Tt as GlyphsContext,
Pa as GlyphsProvider,
je as Grid,
Oi as GridAxesLabels,
Hs as Highlighter,
oe as LAYERS,
$s as LightTheme,
Ta as MeasuredDepthStripe,
Ui as ObservableGroup,
Vs as OutputPanel,
qi as Panel,
ua as Perforations,
fa as Perimeter,
io as PickingHelper,
da as Picks,
pa as PicksLabel,
Qs as SDFTest,
En as ScreenMaterial,
ha as Shoes,
Zs as Surface,
zr as SurfaceMaterial,
Jt as Symbols,
ma as TubeTrajectory,
Js as UtmArea,
_t as UtmAreaContext,
Ws as UtmGrid,
ea as UtmPosition,
Ns as WellMap,
Ys as WellMapCasingShoes,
Ks as WellMapCompletionIntervals,
ao as WellMapContext,
qs as WellMapFormations,
Xs as WellMapTvd,
va as Wellbore,
li as WellboreAddedEvent,
ya as WellboreAnnotationLabel,
ga as WellboreBounds,
en as WellboreContext,
xa as WellboreFormationColumn,
ba as WellboreLabel,
ci as WellboreRemovedEvent,
_a as WellboreRibbon,
tn as WellboreRibbonContext,
Da as WellboreSelectedEvent,
Aa as Wells,
ta as Wgs84Position,
Rr as basicTrajectory,
an as cameraFocusAtPointEventType,
sn as cameraSetPositionEventType,
Er as casingAnnotations,
xi as casings,
Ga as casingsMaterialIndices,
co as colorRamps,
Or as completionToolAnnotations,
yi as completionTools,
Ba as completionToolsMaterialIndices,
mr as createColorRamps,
Te as createLayers,
or as createWellMapState,
rs as depthChangedType,
Wr as depthMarkers,
Ii as getGridPositionFromUV,
Fr as perforationSymbols,
Ur as perimeterGeometry,
Vr as pickSymbols,
$r as shoeSymbols,
Cr as surfaceGeometry,
Pr as surfaceTextures,
Nr as tubeTrajectory,
Ve as useAnnotations,
me as useAnnotationsState,
$e as useData,
Zt as useEventEmitter,
re as useGenerator,
Us as useHighlighter,
js as useOutputPanel,
$t as useOutputPanelState,
Ce as useWellMapState,
ce as useWellboreContext,
Ia as wellboreAddedEventType,
Yr as wellboreBounds,
Kr as wellboreFormationColumn,
Qr as wellboreLabel,
Gs as wellborePickingHelper,
Oa as wellboreRemovedEventType,
Wa as wellboreSelectedEventType
};