Skip to content

Instantly share code, notes, and snippets.

View sketchpunk's full-sized avatar
🏠
Working from home

Pedro sketchpunk

🏠
Working from home
View GitHub Profile
@sketchpunk
sketchpunk / StateProxy.js
Created June 30, 2021 21:13
StateProxy.js
/*
let myData = { woot:0 };
let state = StateProxy.new( myData );
state.$.dynamicProperties = false;
state.$
.converter( "woot", "int" )
.on( "wootChange", (e)=>{ console.log( "wootChange", e.detail ) } );
state.woot = "500.5"; // Converter will change data to int( 500 )
@sketchpunk
sketchpunk / frag_shader.c
Created May 19, 2021 22:14
Rotation Widget Design GLSL
#version 300 es
precision mediump float;
out vec4 out_color;
//-------------------------
in vec3 frag_wpos;
in vec3 frag_norm;
in vec3 frag_cam;
@sketchpunk
sketchpunk / iterators.js
Created February 11, 2021 17:09
Javascript Iterators
// DEFAULT CLASS ITERATOR
[Symbol.iterator](){
let n = this.head;
let result = { value:null, done:false };
return { next:()=>{
if( !n ) result.done = true;
else{
result.value = n.value;
n = n.next;
@sketchpunk
sketchpunk / Vec3_90d_Rotations.js
Created January 24, 2021 01:28
Rotate 3D Vertices by 90 degree increments without the need of Trig, Quaternions or Matrices
class VRot90{
// #region SINGLE AXIS ROTATION
static xp( v, o ){ let x = v[0], y = v[1], z = v[2]; o[0] = x; o[1] = -z; o[2] = y; return o; } // x-zy rot x+90
static xn( v, o ){ let x = v[0], y = v[1], z = v[2]; o[0] = x; o[1] = z; o[2] = -y; return o; } // xz-y rot x-90
static yp( v, o ){ let x = v[0], y = v[1], z = v[2]; o[0] = -z; o[1] = y; o[2] = x; return o; } // -zyx rot y+90
static yn( v, o ){ let x = v[0], y = v[1], z = v[2]; o[0] = z; o[1] = y; o[2] = -x; return o; } // zy-x rot y-90
static zp( v, o ){ let x = v[0], y = v[1], z = v[2]; o[0] = y; o[1] = -x; o[2] = z; return o; } // y-xz rot z+90
static zn( v, o ){ let x = v[0], y = v[1], z = v[2]; o[0] = -y; o[1] = x; o[2] = z; return o; } // -yxz rot z-90
@sketchpunk
sketchpunk / TriMesh.js
Created January 12, 2021 18:49
TriMesh
window.onload = function(){
let mesh = new TriMesh();
mesh.add(
[-0.1, 0.0, 0.1],
[0.1, 0.0, 0.1],
[0.1, 0.0, 0.-1],
).add(
[0.1, 0.0, 0.-1],
[-0.1, 0.0, 0.-1],
@sketchpunk
sketchpunk / QuadTreeID.html
Created January 7, 2021 20:59
Quad Tree Node ID
<html>
<script>
window.onload = function(){
let qID = 0;
qID = QuadTreeID.set( qID, 2, QuadTreeID.A );
qID = QuadTreeID.set( qID, 0, QuadTreeID.C );
qID = QuadTreeID.set( qID, 3, QuadTreeID.D );
qID = QuadTreeID.set( qID, 1, QuadTreeID.B );
@sketchpunk
sketchpunk / RowSets.java
Last active July 29, 2020 21:59
JSON Format CachedRowSet : Array Of Structs, Array Of Arrays and Struct Of Arrays
package dao;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.text.SimpleDateFormat;
import javax.json.Json;
import javax.sql.rowset.CachedRowSet;
public class RowSets {
@sketchpunk
sketchpunk / _glsl_code
Last active November 27, 2023 20:42
GLSL Shader Snippets
GLSL Code
@sketchpunk
sketchpunk / uuid.js
Created June 11, 2020 16:14
Generate UUID in javascript
function uuid(){
let dt = new Date().getTime();
if( window.performance && typeof window.performance.now === "function" ) dt += performance.now(); //use high-precision timer if available
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (dt + Math.random()*16)%16 | 0;
dt = Math.floor(dt/16);
return (c=='x' ? r : (r&0x3|0x8)).toString(16);
});
return uuid;
@sketchpunk
sketchpunk / gaea_interface.html
Created June 2, 2020 13:55
Quick recreation of the Gaea application's design Layout
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
html, body{ margin:0px; padding:0px; width:100%; height:100%;
background-color:#2E2D2E;
}
*{ color:white; font-size:14px; font-family: monospace; }