@shopware-ag/dive
Version:
Shopware Spatial Framework
31 lines (30 loc) • 930 B
JavaScript
import { Node as G } from "three/webgpu";
import { positionWorld as u, abs as m, fract as p, fwidth as b, min as r, float as s, max as z, smoothstep as M, cameraPosition as C, mix as y, step as L, vec4 as N } from "three/tsl";
class F extends G {
constructor(o) {
super(), this.name = "GridNode";
const i = u.xz, t = i.div(o.uGridSize), e = m(p(t.sub(0.5)).sub(0.5)).div(
b(t)
), x = r(e.x, e.y), h = o.uGridSize.mul(o.uMajorLineEvery), n = i.div(h), a = m(p(n.sub(0.5)).sub(0.5)).div(
b(n)
), j = r(a.x, a.y), d = s(1).sub(r(x, 1)), c = s(1).sub(r(j.div(2), 1)), l = z(d, c).mul(
s(1).sub(
M(
o.uFadeDistance.mul(0.5),
o.uFadeDistance,
u.xz.sub(C.xz).length()
)
)
);
l.lessThan(s(1e-3)).discard();
const v = y(
o.uMinorLineColor,
o.uMajorLineColor,
L(d, c)
);
return N(v, l);
}
}
export {
F as G
};