Skip to content

Instantly share code, notes, and snippets.

@sketchpunk
sketchpunk / Voxel Ray Cast _ Intersection
Last active December 31, 2022 17:53
Voxel Chunk Raycasting using "Fast Voxel Traversal Algorithm" in javascript
// http://www.cse.chalmers.se/edu/year/2010/course/TDA361/grid.pdf
function voxel_raycast_min(ray,chunk,aabb){
//..................................................
// Determine if the voxel chunk has an intersection.
var tBox = {};
if(!Ray.inAABB(aabb,ray,tBox)){ return null; }
//..................................................
var inPos = ray.getPos(tBox.min).nearZero(), // entry point for chunk, Clean up vals near zero.
cellSize = chunk.scale,
@jarek-przygodzki
jarek-przygodzki / dfs-recursive-generator.js
Created June 13, 2016 10:53
Recursive DFS using ES6 generator
class Node {
constructor(name, childNodes) {
this.name = name;
this.childNodes = childNodes;
this.visited = false;
}
}
function *dfs(u) {
u.visited = true;
@NYKevin
NYKevin / accounting.sql
Last active April 3, 2024 15:46
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@szimek
szimek / webgl-constants-by-name
Created January 3, 2011 21:28
WebGL context constants
ACTIVE_ATTRIBUTES: 35721
ACTIVE_ATTRIBUTE_MAX_LENGTH: 35722
ACTIVE_TEXTURE: 34016
ACTIVE_UNIFORMS: 35718
ACTIVE_UNIFORM_MAX_LENGTH: 35719
ALIASED_LINE_WIDTH_RANGE: 33902
ALIASED_POINT_SIZE_RANGE: 33901
ALPHA: 6406
ALPHA_BITS: 3413
ALWAYS: 519