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 / _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; }
@sketchpunk
sketchpunk / Timeline.js
Created May 27, 2020 23:10
Animation Timeline Web Component
let $config = {
bg_color : "#424242",
div_color : "#323232",
sub_div_color : "#383838",
txt_color : "#c0c0c0",
marker_color : "#00ffff",
};
class Timeline extends HTMLElement{
constructor(){
@sketchpunk
sketchpunk / gtlf.js
Created May 16, 2020 03:18
GLTF Geometry Loading
class Gltf{
static TYPE_BYTE = 5120;
static TYPE_UNSIGNED_BYTE = 5121;
static TYPE_SHORT = 5122;
static TYPE_UNSIGNED_SHORT = 5123;
static TYPE_UNSIGNED_INT = 5125;
static TYPE_FLOAT = 5126;
static MODE_POINTS = 0; // Mode Constants for GLTF and WebGL are identical
static MODE_LINES = 1; // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants
@sketchpunk
sketchpunk / ScrollToElement.html
Created April 20, 2020 20:50
Scroll to an Element on a page.
<!DOCTYPE html>
<html>
<head>
<title>Scroll</title>
</head>
<body>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<div name="spot">001</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
@sketchpunk
sketchpunk / EventManager.js
Last active April 18, 2020 16:47
Event Manager - Handle Instant Event Broadcasting or Queue to Manual Broadcast
let e = new EventManager();
let xxx = (x)=>console.log("x",x);
// EVENT NAME, SIZE, ALLOW_LISTENERS
// Size = 0, Event will broadcast instantly
// Size = 1, Single Item Event Queue, Manaual Broadcast
// Size > 1, Ring Event Queue, Manual Broadcast
e.reg( "test", 1, true );
// Assign Listeners
@sketchpunk
sketchpunk / Router.js
Last active April 22, 2020 15:58
Simple Javascript Router
/*
Router.on( "/page/:id/:other", ( params )=>{
console.log( "Param Test", params );
document.getElementById("lbl").innerHTML = params.id + "-" + params.other;
});
Router.on( "/page/test", ( params )=>{
console.log( "test", params );
document.getElementById("lbl").innerHTML = "Test";
});
https://manga.madokami.al/Manga/B/BE/BEAS/Beastars
https://mangadex.org/title/16411/enen-no-shouboutai
https://ww2.mangacruzers.com/hajimete-no-gal-manga-chapter-69-download/
http://manga.watchgoblinslayer.com/manga/goblin-slayer-side-story-year-one/
http://manga.watchgoblinslayer.com/
https://ww2.mangacruzers.com/tag/monster-musume-no-iru-nichijou-manga/
https://mangadex.org/title/16444/radiant
https://ww5.readmha.com/manga/vigilante-boku-no-hero-academia-illegals/
@sketchpunk
sketchpunk / VarBuffer.js
Created March 6, 2020 21:16
VarBuffer.js - Field Access to slices from Byte Array, useful to manage UBOs for WebGL or WebGPU
/*
let b = VarBuffer.config([
{ name:"num", type:"int32", size:1 }, // Int
{ name:"pos", type:"float", size:3 }, // Vec3
{ name:"scale", type:"float", size:1 }, // Float
{ name:"sign", type:"uint32", size:1 }, // Test Unsign
]);
b.pos[0] = 0.5;
b.pos[2] = 2.5;