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
jntCount = ChainPose.count;
angles[] = new Array( jntCount ).fill( 0 )
loop
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Get world space transform (pos,rot,scl) of each bone in the chain
// Then preallocate space for the jacobian matrix
transforms[] = compute_WorldSpace_Transforms( ChainPose );
jacobian = Array( transforms.length * 3 * 3 ); // Each Joint gets 3 floats for 3 axes
@sketchpunk
sketchpunk / DynamicWorker.js
Last active February 6, 2023 22:51
Various Web Worker Wrappers
/*
const fnWorker = ( evt )=>{
const data = evt.data;
fnCreateVert( data );
};
async function fnCreateVert( y ){
const vert = new Float32Array( [0,y,0] );
console.log( 'Elevation Request', y, vert );
console.log( 'Size before post', vert.byteLength );
@sketchpunk
sketchpunk / _notes.txt
Created August 11, 2021 16:50
VSCode : Build Task with ctrl+shift+b
Create a folder called .vscode at the root of the project, add this file to it.
ctrl+shift-b will rust the quickstart script.
If you run the shortcut again, it will prompt you to terminate or restart the task. You will need to use a mouse to select the options.
----------
::FUTURE::
https://github.com/microsoft/vscode/pull/117129
instancePolicy doesn't work yet. Waiting on review/merge.
@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 {