Skip to content

Instantly share code, notes, and snippets.

View morganherlocker's full-sized avatar
☠️
computing

Morgan Herlocker morganherlocker

☠️
computing
View GitHub Profile
@morganherlocker
morganherlocker / index.js
Created June 4, 2014 19:58
requirebin sketch
var domify = require('domify');
var THREE = require('three')
var html = '<style>canvas { width: 100%; height: 100% }</style>'
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
@morganherlocker
morganherlocker / index.js
Created June 5, 2014 15:07
requirebin sketch
var line = require('test-linestring')
var d3 = require('d3')
var buffer = require('turf-buffer')
var lineBuffer = buffer(line, .1, 'miles')
d3.select('body')
.append('div')
.text(JSON.stringify(lineBuffer))
@morganherlocker
morganherlocker / index.js
Created June 5, 2014 18:14
requirebin sketch
var line = require('test-linestring')
var domify = require('domify')
var d3 = require('d3')
var buffer = require('turf-buffer')
var lineBuffer = buffer(line, .5, 'miles')
d3.select('body')
.append('div')
.text(JSON.stringify(lineBuffer))
{
"type": "Feature",
"properties": {
"scalerank": 1,
"featurecla": "Admin-0 country",
"labelrank": 4.000000,
"sovereignt": "Antarctica",
"sov_a3": "ATA",
"adm0_dif": 0.000000,
"level": 2.000000,
function(direction){
if (collision().hasOwnProperty(direction)) {
if (collision()[direction].func == "I") {
var width = collision()[direction].Width;
var height = collision()[direction].Height;
var do = create("i", width, image_height, "cyan");
collision()[direction].elk.doit(do, collision()[direction]);
} else if (collision()[direction].finish_it.indexOf("xd") == -1) {
collision()[direction].it_is = "&nbsp;";
}
@morganherlocker
morganherlocker / voxel-openstreetmap.md
Last active August 29, 2015 14:05
voxel osm vector tile algo

This is a rough spec for an implementation of a realtime virtual world using OpenStreetMap data and voxel.js. The basic idea is to encode feature data pulled from Mapbox vector tiles as overzoomed tiles, which can be represented as voxels. This allows for easy scalability, since it utilizes existing algorithms and architecture.

The initial implementation is going on here.

###general

  • 1 voxel = 1 tile at zoom 17 = 1.1943 sq meters
  • the world is a 33,554,432 x 33,554,432 voxel grid
  • assume that a server is serving up vector tile pbfs at z15 (mapbox.com, local, etc.)
  • vector tiles are loaded at zoom 15 and geometry is encoded as 4096x4096 pixel coordinates, which is equivalent to tiles at zoom 24
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"type":"Polygon","coordinates":[[[-7256939.98003115,-2522902.50786552],[-7319040.78248458,-2524937.60125926],[-7371911.41803938,-2485194.4667966],[-7478846.81332676,-2610466.47710187],[-7555966.73015852,-2611238.12096672],[-7590721.78837908,-2427321.7716211],[-7653989.5530545,-2321302.33099756],[-7618427.65116466,-2205660.38268823],[-7670780.20580932,-2161445.2038644],[-7689023.24396052,-2042101.17023232],[-7734880.30631738,-1994935.09991547],[-7736673.99727254,-1979722.79940425],[-7749940.05230987,-1945834.68063856],[-7661286.76831498,-1844098.53865494],[-7728016.23519559,-1760533.51976823],[-7696289.84636103,-1717548.01276508],[-7721831.65824558,-1666449.66241667],[-7664687.35611973,-1597076.41086745],[-7678201.43098255,-1444852.20887968],[-7644744.02406615,-1402796.31587473],[-7744322.87080444,-1226560.94622088],[-7634674.73084592,-1244145.3464742],[-7417712.48669239,-1108372.95214612],[-7278286.2716272,-1084743.60685021],[-7279492.30699046,-1262330.00144749],[-7234839.49888498,-1346625.36055829],[-716832
/**
* BezierSpline
* http://leszekr.github.com/
*
* @copyright
* Copyright (C) 2012 Leszek Rybicki.
*
* @license
* This file is part of BezierSpline
@morganherlocker
morganherlocker / index.js
Created September 16, 2014 20:15
requirebin sketch
var tilebelt = require('tilebelt');
var badTile = tilebelt.bboxToTile([100, 0, 101, 2]),
goodTile = tilebelt.bboxToTile([100, 1, 101, 2]);
console.log(goodTile, badTile);