Skip to content

Instantly share code, notes, and snippets.

View spite's full-sized avatar
📦
i'm a smaller box

Jaume Sanchez spite

📦
i'm a smaller box
View GitHub Profile
// if an invalidate mechanism is in place
// easings based on expressions might have
// a bit of zeno's paradox, in which the
// value infinitesimally converges to the
// target value
var value = 0;
var nValue = 1;
function animate() {
function hashRenderParams() {
var hash;
// hash your render values
//e.g, camera parameters: camera.position.x + '|' + camera.position.y + '|' + camera.position.z
return hash;
}
var hash = '';
@spite
spite / gist:58dd1f12e97fedcdc222
Created March 29, 2016 15:32
updating htc vive
- panel says one station needs to update, doesn't tell which one
- i unscrew both, try one, doesn't update. try the other one, it updates
- try the second one -which didn't update before- and it updates
- screw them again
- tells me to set up the room, i do that
- tells me a controller needs update, doesn't tell me which
- try one, it doesn't update, try the other one, it updates
- tells me to set up the room again, i do it and tells me the other controller needs update
- i plug the other controller, it updates
- after all this, with exactly the same setup, it tells me some station has visibility problems, tracking is now spotty
@spite
spite / gist:0b84c9a0310d91e0bd89
Created November 30, 2015 14:08
Keep camera between reloads
// save camera views
const savedCamera = JSON.parse( localStorage.getItem( 'savedCamera' ) );
if( savedCamera ){
camera.position.copy( savedCamera.cameraPosition );
controls.target.copy( savedCamera.targetPosition );
}
document.addEventListener( 'unload', function(){
localStorage.savedCamera = JSON.stringify({
cameraPosition: camera.position,
@spite
spite / gist:952643a464583adc25b1
Created June 25, 2015 20:26
Base64 encode/decode UTF-8
function b64EncodeUnicode(str) {
return btoa( unescape( encodeURIComponent( str ) ) );
}
function b64DecodeUnicode(str) {
return decodeURIComponent( escape( atob( str ) ) );
}
@spite
spite / gist:7ae92212b4f28076ba29
Last active August 29, 2015 14:23
A Modest Proposal: Standard for naming shaders and programs

##A Modest Proposal##

As per version 1.0.13 of the Shader Editor Extension, it will look for #define SHADERNAME name in both the vertex shader code and the fragment shader code.

If name is defined for both shaders, and it's the same string, the name of the program is that string, e.g.: "Shadertoy". common-name

If only one of the two is defined, the name of the program is "vs_name / fs_name", e.g.: "Quad / Shadertoy" mixed-name

@spite
spite / gist:a5d4388c01ba59cc879a
Created June 16, 2015 00:05
ShaderToy wrapper
// VERTEX SHADER
attribute vec2 pos;
void main() {
gl_Position = vec4(pos.xy,0.0,1.0);
}
// FRAGMENT SHADER
#ifdef GL_ES
@spite
spite / gist:f6c9addcfce71a0bb688
Created May 5, 2015 00:22
Private THREE objects
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js"></script>
<script>
var scene = new THREE.Scene();
function Private() {
var scene = new THREE.Scene();
function render() {}
@spite
spite / gist:10ff99d4f85a87abad7f
Last active August 29, 2015 14:19
Converting a video captured with Quicktime to GIF (for posting to twitter)
ffmpeg -i input2.mov -vf "setpts=(1/2)*PTS" output.mov
ffmpeg -ss 00:00:00.000 -i output.mov -pix_fmt rgb24 -vf scale=506:-1 -r 10 output.gif
@spite
spite / gist:93883bb7ad7de7b9bc62
Last active May 28, 2020 14:15
console.log for HTMLCanvasElement
/*
add this code
run console.log( canvas );
see the canvas
if the canvas is running a webgl context, it'll need the preserveDrawingBuffer flag set to true
*/
( function() {