Skip to content

Instantly share code, notes, and snippets.

@mrdoob
mrdoob / convert.bash
Last active Jun 7, 2020
Batch convert draco/basis
View convert.bash
for i in *.obj; do ../../draco/draco_encoder -i "$i"; done
for i in *.jpg; do sips -Z 2048 -s format png "$i" --out "$i".png; done
for i in *.png; do ../../basis/basisu -file "$i"; done
@mrdoob
mrdoob / stack.js
Created Jun 4, 2020
Log the stack trace of a function
View stack.js
try { throw new Error; }
catch(e) {
console.log(e.stack);
}
@mrdoob
mrdoob / html2canvas.js
Created Mar 9, 2020
Paints a HTML node into a <canvas> (Very basic CSS support)
View html2canvas.js
/**
* @author mrdoob / http://mrdoob.com/
*/
function html2canvas( element ) {
var range = document.createRange();
function Clipper( context ) {
View css3drenderer.md
@mrdoob
mrdoob / adjoint.glsl
Created Sep 19, 2019
Matrix3.getNormalMatrix()
View adjoint.glsl
// Use to transform normals with transformation of
// arbitrary non-uniform scales (including negative)
// and skewing. The code assumes the last column of m is
// [0,0,0,1]. More info here:
// https://github.com/graphitemaster/normals_revisited
mat3 adjoint( in mat4 m )
{
return mat3(
m[1][1]*m[2][2]-m[1][2]*m[2][1],
@mrdoob
mrdoob / mov2gif.sh
Created Jun 10, 2019
ffmpeg: mov to gif
View mov2gif.sh
#!/bin/sh
palette="/tmp/palette.png"
filters="fps=25,scale=640:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
View JSONParseAsync.js
function JSONParseAsync( text, callback ) {
var code = 'onmessage = function ( e ) { postMessage( JSON.parse( e.data ) ); close(); }';
var blob = new Blob( [ code ], { type: 'text/plain' } );
var worker = new Worker( window.URL.createObjectURL( blob ) );
worker.addEventListener( 'message', function ( e ) { callback( e.data ); } );
worker.postMessage( text );
}
View Layers.js
/**
* @author mrdoob / http://mrdoob.com/
*/
function Layers() {
this.mask = 1;
}
You can’t perform that action at this time.