Matt Hayes: fArt.ts Continued

The week before last I did a bunch of work on wave and step related functions and continued pushing forward on my WebGL helpers. Mostly I’m working with updating position vectors (using the wave and step functions), but I’m pretty pleased with the little demo I whipped together.

Week 35: August 20 – 27

This past week I’ve been working on a vector implementation that’ll let me do a thing called “swizzling” that’s standard in GLSL (the language of WebGL) but actually really hard to do in TypeScript. What it means is that I can get from and assign into vectors just by remixing their keys.

For example, a 3 dimensional vector (a vec3) has keys x, y, and z … in a normal (non-swizzled) implementation, switching x and z would require storing one or the other in a temporary variable, like:

“`
temp = vec3.x;
vec3.x = vec3.z;
vec3.z = temp;
“`

In my swizzled implementation I can do this in one line, like:

“`
vec3.xz = vec3.zx;
“`

This is kind of just a simple contrived example, it opens up a lot of other really nice possibilities. Anyway, it’s been a surprisingly difficult concept to implement, so I don’t have a demo using it this week but I’m excited about what I might do next.