Skip to content

Instantly share code, notes, and snippets.

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

SketchPunk sketchpunk

🏠
Working from home
View GitHub Profile
@sketchpunk
sketchpunk / dev links.txt
Last active April 15, 2024 20:12
Web Developer and Designer Links
@sketchpunk
sketchpunk / _CURVES_IN_JS.md
Last active April 5, 2024 18:42
Curves in Javascript

Curves in Javascript

Collection of algorithms related to using curves written in javascript.

Curve Types

  • Cubic Bezier Splines : inc. derivative, 2nd derivative, normals, easing
  • Catmull Rom
  • Kochanek Bartels ( TCB Splines ) : inc. derivative
  • Lemniscate of Bernoulli and Gerono : inc. derivative
  • Watt's Curve
  • Torus Knot : inc. derivative, 2nd derivative
@sketchpunk
sketchpunk / FetchBatch.js
Last active April 4, 2024 02:16
Various Fetch / Downloading functions or Objects
function nanoID( t=21 ){
const r = crypto.getRandomValues( new Uint8Array( t ) );
let n, e = '';
for( ;t--; ){
n = 63 & r[ t ];
e += ( n < 36 )? n.toString( 36 ) :
( n < 62 )? ( n - 26 ).toString( 36 ).toUpperCase() :
( n < 63 )? '_' : '-';
}
return e;
audioContainer: {
height: '30px',
overflow: 'hidden',
backgroundColor: '#26476F',
boxShadow: '0px 0px 5px 2px rgba( 0,0,0,0.55 )',
borderRadius: '4px',
color: '#ffffff',
},
audio: {
/**
* \brief Returns positional offset for a given point as a result of summing 4 gerstner waves
* \param positionWS point in world space
* \param wavelengths wavelength of each of the 4 waves
* \param amplitudes amplitudes of each of the 4 waves
* \param directions direction of each of the 4 waves (each row = one direction). MUST BE NORMALIZED!
* \param speed global speed multiplier. Individual wave speed depends on Wavelength
* \param steepness Gerstner wave 'Steepness' parameter. Modulates the horizontal offset of points
* \param normal returns the normal of given point.
* \return positional offset of the given point
@sketchpunk
sketchpunk / color_ramp.txt
Last active February 1, 2024 23:10
WebGL : Blender 4.0 GLSL Nodes
// #region CUSTOM - NON-BLENDER CODE
/*
USAGE
vec3 ramp_col[9] = vec3[](
rgb(0x0F2936),
rgb(0x123243),
rgb(0x24525D),
rgb(0x437274),
rgb(0x263F41),
@sketchpunk
sketchpunk / Float32_Base64_Encoding_Decoding.js
Last active December 23, 2023 08:51
Encode Float32Array to base64 , then decode it back
let verts = new Float32Array( [ 0, 2, 0, -1, 0.2, 0, 1, 0.2, 0 ] );
let v = base64_test( verts );
function base64_test( fary ){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ENCODING TEST
console.log("Origin Data", fary );
let uint = new Uint8Array( fary.buffer );
console.log( "Convert F32 to Uint8 : Byte Length Test", fary.length * 4, uint.length );
@sketchpunk
sketchpunk / _glsl_code
Last active November 27, 2023 20:42
GLSL Shader Snippets
GLSL Code
@sketchpunk
sketchpunk / pipeGenerator.cs
Created September 27, 2023 12:05 — forked from antonkudin/pipeGenerator.cs
Generates pipe mesh from mesh segments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pipeGenerator : MonoBehaviour
{
[SerializeField] Mesh straightMesh;
[SerializeField] Mesh elbowMesh;
[Space]
[SerializeField] Vector3[] pathPoints;
@sketchpunk
sketchpunk / arcball.js
Last active July 22, 2023 06:24
Maths for various camera movement ( Orbit, Arcball, FPS, Zoom, etc )
/** Using a faux sphere in screen space, determine the arc transform to orbit
* the camera around a target position. A continuous orientation will
* be provided for further calls.
*/
function arcBallTransform(
scrSize, // Screen size, vec2
scrPos0, // Starting mouse position, vec2
scrPos1, // Ending Mouse Positiong, vec2
rotOrientation, // Current arc orientation, quaternion
targetPos, // Position to orbit around