Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
donmccurdy / THREE_COLORSPACE_MANAGEMENT.md
Last active January 2, 2023 08:07
Color management in three.js
@donmccurdy
donmccurdy / FOO2GLTF.js
Last active August 1, 2023 06:53
Example Node.js glTF conversion script, using three.js.
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const THREE = require('three');
const program = require('commander');
const Canvas = require('canvas');
const { Blob, FileReader } = require('vblob');
// Patch global scope to imitate browser environment.
@kig
kig / gzip.js
Last active August 1, 2019 08:59
TarGZ = function(){};
// Load and parse archive, calls onload after loading all files.
TarGZ.load = function(url, onload, onstream, onerror) {
var o = new TarGZ();
o.onload = onload;
o.onerror = onerror;
o.onstream = onstream;
o.load(url);
return o;
#!/usr/bin/ruby
USAGE = "dataurize filename [mimetype] > filename.dataURI"
require 'base64'
mime = ARGV[1] || `file -ib '#{ARGV[0].gsub(/'/, "'\\\\''")}'`.strip
STDOUT.write("data:#{mime};base64,")
File.open(ARGV[0], 'rb') {|f|
STDOUT.write(Base64.encode64(f.read(4500))) until f.eof?
/* MultiFile - A JavaScript library to load multiple files from
tar archives and json_packed files (see http://gist.github.com/407595)
Example: Loading multiple images from a tarball.
MultiFile.load('images.tar', function(xhr) {
this.files.forEach(function(f) {
var e = document.createElement('div');
document.body.appendChild(e);
var p = document.createElement('p');