npm i --save @trinketmage/sword
- lerp: Linear interpolation.
- angleToVector: Calculate a 2d vector on unit circle from an angle in degree.
- vectorToAngle: Calculate an angle in degree from a 2d vector (with optional pivot).
- getScreenPos: Screen position (2d vector) of position (3d vector).
- getFovHeigth: Get height of frustrum (y) at a specific depth (z).
- stagger: glsl implementation of staggers
#pragma glslify: stagger = require(@trinketmage/sword/src/glsl/stagger)- backgroundCover: glsl UV calculation for background cover for fullscreen texture
#pragma glslify: backgroundCover = require(@trinketmage/sword/src/glsl/backgroundCover)- rotate2d: rotate matrix2d (be mindful of rotateUV)
const rotatedUV = rotate2d(rotation).mul(uv);- responsive: homothetic helper to match two ratios
// example center an image
const res = responsive(ratio1, ratio2);
let st = uv().mul(res).add(res.oneMinus().mul(0.5));- sdBox: ..
- sdRoundedBox: ..
- sdCircle: ..
- sdGlyph: render a glyph from a sdf/msdf texture
// render a glyph from an msdf atlas
// luv is local uv computed in geometry attribute
var sample = texture(atlas, luv);
var alpha = sdGlyph(sample);- notEqual: ..
- greater: ..
- lesser: ..
- greaterEqual: ..
- lesserEqual: ..
- and: ..
- or: ..
- xor: ..
- not: ..