This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jax.getGlobal()['LoadedMesh'] = Jax.Model.create | |
after_initialize: -> | |
model_data = null | |
@mesh = new Jax.Mesh | |
init: (vertices, colors, texCoords, normals, indices) -> | |
if model_data | |
vertices.push datum for datum in model_data["vertices"][0]["values"] | |
normals.push datum for datum in model_data["vertices"][1]["values"] | |
indices.push datum for datum in model_data["connectivity"][0]["indices"] | |
update: ((updated_mesh) => model_data = updated_mesh; @mesh.rebuild()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jax.getGlobal().AsyncHelper = Jax.Helper.create | |
load_from_idb: (idb_name, os_name, key, onsuccess, onfailure) -> | |
indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB | |
IDBTransaction = IDBTransaction || window.webkitIDBTransaction | |
IDBKeyRange = IDBKeyRange || window.webkitIDBKeyRange | |
idb_request = indexedDB.open @indexedDB | |
idb_request.onsuccess = (e) => | |
idb = e.target.result | |
if idb.objectStoreNames.contains @objectStore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jax.Controller.create "Mybsp", ApplicationController, | |
index: -> | |
sphere = new Jax.Mesh.Sphere | |
this.ball1 = new Jax.Model({ mesh:sphere }) | |
this.ball2 = new Jax.Model({ mesh:sphere, position:[0,5,0] }) | |
this.ball1.bsp = new BSP | |
this.ball2.bsp = new BSP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jax.getGlobal().ApplicationHelper = Jax.Helper.create | |
patch_world: -> | |
Jax.World.prototype.pick_all_visible = () -> | |
context = this.context | |
w = context.canvas.width | |
h = context.canvas.height | |
data = new Uint8Array(w*h*4) | |
data.w = w | |
data.h = h | |
data.f = f = 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jax.getGlobal().ApplicationHelper = Jax.Helper.create | |
patch_world: -> | |
Jax.World.prototype.find_region_centers = () -> | |
context = this.context | |
w = context.canvas.width | |
h = context.canvas.height | |
f = 4 | |
wf = w*f | |
data = new Uint8Array(w*h*4) | |
pickBuffer = new Jax.Framebuffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Construct a chained array of callbacks that "thread" a sequence of async functions in the smallest possible code. | |
# tldr; call the next async function in fn, "wait" for its callback to store the result and call the next async callback in cb | |
# each async function | |
# accepts 1 callback argument | |
# passes 1 arg of result data to the callback | |
# construct the callback | |
# when callback in cb evaluates, replaces itself in cb array with the result | |
# calls the next callback in cb | |
# after last callback in cb, return joined results stored in cb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# | |
# Created by Nat Noordanus on 2012-10-20. | |
# | |
# requires a text file of digits of pi http://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt | |
def find_in_pi string, pi_file_path | |
# convert string to base 10 ascii |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import argparse | |
import collections | |
import numpy | |
import nibabel as nib | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A very light wrapper for the InsightToolkit Convert3D tool which must be downloaded seperately. | |
# See http://www.itksnap.org/pmwiki/pmwiki.php?n=Convert3D.Convert3D | |
# It is assumed that the Convert3D tool resides in the shall path as c3d. | |
# Otherwise Convert3D.path= must be used to set the location of the executable. | |
module Convert3D | |
@@c3d_path = "c3d" # assume c3d is in the environment path by default | |
@@Formats = [".nrrd", ".hdr", ".img", ".img.gz", ".dcm", ".cub", ".mha", ".df3", ".nii.gz"] | |
def self.path= path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Provides an efficiently searchable tree index of a given array of stringafiable objects. | |
# Is specifically designed to be much faster than using Array's _index_ or _include?_ methods for locating a numerical value within an Array. | |
# However it should work just as well with Arrays of strings or other objects that respond appropriately to _to_s_. | |
class QuickIndex | |
# @param ary [Array] of items to be indexed. | |
# @param stop_char (String) which should not occur as a substring in any of the stringified objects in ary. | |
# |
OlderNewer