Skip to content

Instantly share code, notes, and snippets.

Justin Sermeno jsermeno

  • Mountain View, CA
View GitHub Profile
@jsermeno
jsermeno / cube.js
Created Sep 19, 2011
Three.js Infinite Terrain
View cube.js
cube = new THREE.CubeGeometry( block_size, block_size, block_size, 1, 1, 1, materials, false, { px: px, nx: nx, py: py, ny: ny, pz: pz, nz: nz });
View copy_railscast.sh
cp ~/Downloads/railscasts.vim ~/.vim/colors
@jsermeno
jsermeno / avoid_window.js
Created Sep 11, 2011
Window, Self, and Web Workers
View avoid_window.js
if ( window.Blob === undefined ) {
// attach library custom implementation
} else {
// use native implementation
}
@jsermeno
jsermeno / animation.html
Created Aug 24, 2011
Three.js Troll Animation Morph Targets
View animation.html
<!doctype html>
<html>
<head>
<title>Three.js - Game</title>
<meta charset="utf-8">
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
@jsermeno
jsermeno / perlin_noise_indices.js
Created Aug 9, 2011
Perlin Noise Negative Coordinates
View perlin_noise_indices.js
noise: function (x, y, z) {
// Find unit cube that contains point
var xFloor = ~~x;
var yFloor = ~~y;
var zFloor = ~~z;
var iX = xFloor & 255;
var iY = yFloor & 255;
var iZ = zFloor & 255;
@jsermeno
jsermeno / config-haproxy.sh
Created Jun 20, 2011
Node.js server and Web Sockets on Amazon EC2 with Express.js and Socket.IO - http://catchvar.com/nodejs-server-and-web-sockets-on-amazon-ec2-w
View config-haproxy.sh
# HAProxy config
mkdir /etc/haproxy
cat > /etc/haproxy/haproxy.cfg << EOF
global
maxconn 4096
defaults
mode http
View app-controller-init.js
// Bind context
_.bindAll( this, "animate", "render", "update" );
// Initialize camera
this.camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, -2000, 10000 );
this.camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -2000, 10000 );
this.camera.position.y = 70.711;
this.camera.position.x = 100;
this.camera.position.z = 100;
@jsermeno
jsermeno / perspectiveProject.js
Created Jun 5, 2011
Three.js Transform 3D coordinates to screen coordinates and back in perspective projection - http://catchvar.com/threejs-game-transforming-isometric-screen-co
View perspectiveProject.js
var
projector = new THREE.Projector(),
p3D = new THREE.Vector3(25, 15, 9),
p2D;
p2D = projector.projectVector(p3D, camera);
p3D = projector.unprojectVector(p2D, camera);
View initialize.js
var
camera,
scene,
renderer;
function initialize() {
var
grass,
meshCanvas,
plane,
View handlebars-example.js
<!-- templates -->
<script id="summary" type="text/x-handlebars-template">
{{#users}}
{{>summaryItem}}
{{/users}}
</script>
<script id="summaryItem" class="partial" type="text/x-handlebars-template">
<li id="user_{{id}}" class="summary_item">
<p>{{name}}</p>
You can’t perform that action at this time.