@y11i-3d/tsl
v0.4.0
Published
Collection of TSL (Three.js Shading Language) modules by y11i (Yuichiroh Arai).
Downloads
147
Maintainers
Readme
@y11i-3d/tsl
Collection of TSL (Three.js Shading Language) modules by y11i (Yuichiroh Arai).
Installation
npm install @y11i-3d/tslTSL Modules
- lerpDeg - Lerp for degrees (-180 ~ 180).
- lerpRad - Lerp for radians (-π ~ π).
- lerpRange - Lerp for cyclic range (center - range/2 ~ center + range/2).
- linearstep -
clamp((x - low) / (high - low), 0, 1). - mosaicCeil -
ceil(v * divs) / divs. - mosaicFloor -
floor(v * divs) / divs. - mosaicRound -
round(v * divs) / divs. - safeAtan -
atan(y, x)but safe for0, 0. - tri - Maps 0→1 to 0→1→0 (linear).
Inline vs shader functions
By default, functions are inlined into the shader code. If you call .fn(), the function is compiled as a shader function (via setLayout + overloadingFn), which can reduce code duplication when the same function is used multiple times.
import { linearstep } from "@y11i-3d/tsl";
// Inline (default)
const result = linearstep(low, high, x);
// Shader function
const linearstepFn = linearstep.fn();
const result = linearstepFn(low, high, x);