Skip to content

Instantly share code, notes, and snippets.

@mrdoob
mrdoob / gist:1181630
Created August 30, 2011 18:30
(failed) http node.js server
var http = require( 'http' );
var url = require( 'url' );
var fs = require( 'fs' );
var path = require( 'path' );
var gzip = require( './lib/gzip' );
var VERBOSE = false;
var cache = {}, count = 0;
@mrdoob
mrdoob / gist:1224685
Created September 18, 2011 03:23
Create POT texture from a nonPOT
var texture = THREE.ImageUtils.loadTexture( 'nonPOT.png', new THREE.UVMapping(), function () {
var nextPOT = function ( value ) { var pot = 1; while ( pot < value ) pot <<= 1; return pot; };
var canvas = document.createElement( 'canvas' );
canvas.width = nextPOT( texture.image.width );
canvas.height = nextPOT( texture.image.height );
canvas.getContext( '2d' ).drawImage( texture.image, 0, 0, texture.image.width, texture.image.height, 0, 0, canvas.width, canvas.height );
@mrdoob
mrdoob / gist:1238790
Created September 24, 2011 00:47
Logging the Scene Graph
function logGraph( object, depth ) {
var depth = depth || 0, pad = '';
for ( var i = 0; i < depth; i ++ ) pad += ' ';
console.log( pad + object.name, object );
for ( var i = 0; i < object.children.length; i ++ ) {
@mrdoob
mrdoob / gist:1265705
Created October 5, 2011 20:58
yooouuutuuube.com effect in html5
<html>
<body>
<script>
var video = document.createElement( 'video' );
video.autoplay = true;
video.addEventListener( 'loadedmetadata', function ( event ) {
var scale = 0.5;
var width = video.videoWidth * scale;
gptsync
@mrdoob
mrdoob / gist:1325393
Created October 30, 2011 02:48
ffmpeg: recording the screen.
ffmpeg -f x11grab -b 1M -bt 2M -r 30 -s 512x512 -i :0.0+1,53 -an kinect.webm
@mrdoob
mrdoob / gist:1326080
Created October 30, 2011 16:25
modified glview.c
/*
* This file is part of the OpenKinect Project. http://www.openkinect.org
*
* Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
* for details.
*
* This code is licensed to you under the terms of the Apache License, version
* 2.0, or, at your option, the terms of the GNU General Public License,
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
* or the following URLs:
@mrdoob
mrdoob / gist:1339792
Created November 4, 2011 16:39
Transforming sphere geometry for mercator projected texture.
for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
for ( var j = 0, jl = geometry.faceVertexUvs[ 0 ][ i ].length; j < jl; j ++ ) {
var uv = geometry.faceVertexUvs[ 0 ][ i ][ j ];
var a = uv.v * Math.PI - Math.PI / 2;
a = Math.sin(a);
uv.v = Math.log( ( 1 + a ) / ( 1 - a ) ) / ( 4 * Math.PI );
uv.v += 0.5;
@mrdoob
mrdoob / sublime.desktop
Created November 21, 2011 20:51
Ubuntu 11.10 now requires a .desktop for the "Open With Other Application..." feature :S
[Desktop Entry]
Version=2.0
Name=Sublime Text
Exec=bash -c "~/Downloads/Sublime\ Text\ 2/sublime_text %f"
Icon=Sublime
Terminal=false
Type=Application
Categories=Motif;Utility;TextTools;
GenericName=Text editor
GenericName[en]=Text editor
@mrdoob
mrdoob / gist:1385689
Created November 22, 2011 13:43
Minecraft look
var texture = THREE.ImageUtils.loadTexture( file );
texture.wrapS = THREE.ClampToEdgeWrapping;
texture.wrapT = THREE.ClampToEdgeWrapping;
texture.magFilter = THREE.NearestFilter;
texture.minFilter = THREE.LinearMipMapLinearFilter;