Skip to content

Instantly share code, notes, and snippets.

Avatar
📦
i'm a smaller box

Jaume Sanchez spite

📦
i'm a smaller box
View GitHub Profile
@spite
spite / gist:8506285
Created Jan 19, 2014
Going Fullscreen
View gist:8506285
var c = document.body;
document.getElementById( 'fullscreenBtn' ).addEventListener( 'click', function( e ) {
c.onwebkitfullscreenchange = function(e) {
c.onwebkitfullscreenchange = function() {
};
};
c.onmozfullscreenchange = function(e) {
c.onmozfullscreenchange = function() {
};
};
@spite
spite / gist:8835249
Last active Aug 29, 2015
AudioContext playback without preloading
View gist:8835249
/*
Demo here: http://www.clicktorelease.com/tmp/fastload/
The MP3 file is 5.2MB
*/
/*
For some reason, probably because the spec has changed since the article
"Getting Started with Web Audio API" in http://www.html5rocks.com/en/tutorials/webaudio/intro/
was published, the most common way of loading a file sound is something like:
*/
@spite
spite / 0_reuse_code.js
Created Feb 11, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@spite
spite / gist:9110247
Last active Jun 9, 2018
Pass Inverse of ModelView Matrix to Vertex Shader
View gist:9110247
/*
uniform types: https://github.com/mrdoob/three.js/wiki/Uniforms-types
THREE.Matrix4: http://threejs.org/docs/#Reference/Math/Matrix4
https://github.com/mrdoob/three.js/issues/1188
*/
/*
on Init();
Add this uniform to your uniforms
View gist:9667071
<!doctype html>
<html lang="en">
<head>
<title>Wagner - Minefield!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
color: #ffffff;
font-family: 'roboto condensed', tahoma;
View gist:11320599
function exportZipToSketchfab( zip ) {
setLoadingText( 'Uploading...' );
showLoading( true );
var fd = new FormData();
fd.append('token', settings.sketchfabToken );
fd.append('fileModel', zip );
View gist:11328874
function f() { var a = [].slice.apply( document.querySelectorAll( 'a' ) ); a.forEach( function( e ) { e.click(); } ) }
var s = setInterval( f, 100 )
View autopilot.js
var ctx1 = document.getElementById( 'color-1' ).getContext( '2d' ),
ctx2 = document.getElementById( 'color-2' ).getContext( '2d' );
function simulateClick( target ) {
var evt = document.createEvent("Events");
evt.initEvent("click", true, true);
target.dispatchEvent(evt);
}
setInterval( function() {
@spite
spite / gist:c5527fcc07429ca0b044
Created Oct 26, 2014
THREE.DecalGeometry loading OBJ file
View gist:c5527fcc07429ca0b044
<!doctype html>
<html lang="en">
<head>
<title>Decal Splatter</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
*{ box-sizing: border-box; margin: 0; padding: 0 }
body {
color: #888;
@spite
spite / sugarifyNew
Last active Aug 29, 2015
Makes creating canvas, audio, video and other HTML elements less verbose
View sugarifyNew
( function() {
function sugarifyNew( id ) {
var name = id + '';
var fnName = name.charAt( 0 ).toUpperCase() + name.substr( 1 );
window[ fnName ] = function() {
return document.createElement( id );
}