This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * vec[index] throws an error: | |
| * '[]' : Index expression must be constant | |
| * get(vec, index) works fine | |
| * branchless implementation | |
| **/ | |
| float get(vec2 vec, int index) { | |
| vec2 mult = vec2(float(index == 0), float(index == 1)); | |
| vec2 bet = mult * vec; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* original */ | |
| export function fromOrientation({ alpha, beta, gamma }, orientation) { | |
| let rot = iquaternion(UP, degree(alpha)) | |
| .mul(RIGHT, degree(beta)) | |
| .mul(FORWARD, degree(gamma)) | |
| .mul(LEFT90); | |
| rot = iquaternion(rot.dir, degree(orientation)) | |
| .mul(rot); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const REV_FORM = Symbol("reverse-formula"); | |
| const SCALE = 10; | |
| function createReverseFormula(formula) { | |
| const list = new Array(SCALE + 1).fill(0).map((_, i) => { | |
| const inp = i / SCALE; | |
| const out = formula(inp); | |
| return { inp, out }; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| const packs = new Map(); | |
| let currentPack; | |
| function dynamicImport(path) { | |
| let pack = packs.get(path); | |
| if (!pack) { | |
| let load; | |
| const prom = new Promise((resolve) => load = resolve); | |
| pack = { path, load, prom }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2D | 3D | Mutable | Immutable | ||
|---|---|---|---|---|---|
| Vector | ✅ | ✅ |