Skip to content

Instantly share code, notes, and snippets.

View sortofsleepy's full-sized avatar

Joe sortofsleepy

View GitHub Profile
@sortofsleepy
sortofsleepy / gist:7477655
Last active December 28, 2015 09:19
Fragment shader study #1
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 resolution;
void main(void){
vec2 position = (gl_FragCoord.xy / resolution.xy);
float color = 0.0;
@sortofsleepy
sortofsleepy / gist:7847046
Last active December 30, 2015 15:18
Fragment shader study #2
/**
Slits
@sortofsleepy
*/
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
@sortofsleepy
sortofsleepy / canvasText.js
Last active March 26, 2016 03:28
Converts copy you write in a canvas 2D context to an array of THREE.Vector2s (but could easily be modded to just return a regular array)
/**
* Simple class for quickly creating positions
* for use in a mesh or for whatever other purpose you might want.
*/
class TypeBuilder {
constructor(string="Hello",width=140,height=100){
this.canvas = document.createElement("canvas");
this.canvas.width = width;
this.canvas.height = height;
this.canvas.style.cssText = "position:relative;z-index:999"
@sortofsleepy
sortofsleepy / demo.cljs
Created April 4, 2016 04:48
thi.ng demo - just saving some test code for reference
(ns ribbon-attractor.demo
(:require
[matchstick.Geometry :as mgeo]
[matchstick.custom-geometry.Plane :as pgeo]
[matchstick.SimpleGeometry :as sgeo]
[thi.ng.geom.mesh.polyhedra :as poly]
[thi.ng.glsl.core :as glsl :include-macros true :refer-macros [defglsl]]
[thi.ng.math.core :as m :refer [PI HALF_PI TWO_PI]]
[thi.ng.geom.webgl.constants :as glc]
[thi.ng.geom.webgl.animator :as anim]
@sortofsleepy
sortofsleepy / app.clj
Last active May 23, 2016 01:27
working with Processing in clojure (assumes Processing jars have been imported / specified on project.clj)
(ns processing-test.core
(:gen-class)
(:require
[processing-test.sketch :as sk])
(:import
[processing.core PApplet]))
(defn -main
"I don't do a whole lot ... yet."
[& args]
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/Rand.h"
#include "cinder/gl/gl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
@sortofsleepy
sortofsleepy / webpack.config.js
Created January 24, 2017 18:42
Shows webpack 2 hot reload working (adjust as necessary)
// configuration. Pass in your the path to your own file or it defaults to a default one
config = {
entry: default_entries,
performance:{
hints:false
},
output:{
path:OUTPUT,
filename:"app.js",
@sortofsleepy
sortofsleepy / test.py
Last active April 25, 2017 16:23
keras-test
from keras.layers import Lambda
from keras.models import Sequential
from keras.optimizers import RMSprop
# declares toy model that just multiplies input by 2
def mult(x):
return x * 2
# declare sequential layer
vec3 calcRayIntersection( vec3 pos )
{
vec3 retPos = pos;
if (rayPosition.x > pos.x - 1 &&
rayPosition.x < pos.x + 1 &&
rayPosition.y > pos.y - 1 &&
rayPosition.y < pos.y + 1 &&
rayPosition.z > pos.z - 1 &&
rayPosition.z < pos.z + 1 &&
connection[0] != -1 && connection[1] != -1 &&
// do this
vector<ARAnchor> mats;
for(int i = 0; i < session.currentFrame.anchors.count; ++i){
mats.push_back(session.currentFrame.anchors[i]);
}
// then access transforms from the "mats" variable.
// if you grab a transform from "mats", you shouldn't run into an out of bounds error because