Skip to content

Instantly share code, notes, and snippets.

View mikolalysenko's full-sized avatar

Mikola Lysenko mikolalysenko

View GitHub Profile
@mikolalysenko
mikolalysenko / gist:8792059
Last active August 29, 2015 13:56
Sketch of glsl inlining
var shell = require('gl-shell')
var inlineGLSL = require('inline-glslify')
var createShadowMap = require('shadow-map')
var createShadowPassShader = inlineGLSL(
'attribute vec4 position;\
varying vec4 fragmentPosition;\
void main() {\
gl_Position = position;\
fragmentPosition = fragmentPosition;\
@mikolalysenko
mikolalysenko / simplePlot.js
Created February 3, 2014 23:02
Sketch of 3D plotting interface
var createViewer = require("plotly-viewer")
var createSurfacePlot = require("plotly-surface-plot")
var createAxes = require("plotly-axes")
var viewer = createViewer()
var surface
var axes
viewer.on("plotly-init", function() {
@mikolalysenko
mikolalysenko / index.js
Created March 17, 2014 23:39
requirebin sketch
//Load shell
var shell = require("gl-now")({ clearColor: [0,0,0,0] })
var camera = require("game-shell-orbit-camera")(shell)
//Mesh creation tools
var createMesh = require("gl-simplicial-complex")
var polygonize = require("isosurface").surfaceNets
var createAxes = require("gl-axes")
//Matrix math
@mikolalysenko
mikolalysenko / Chrome 34
Last active August 29, 2015 13:59
Preliminary benchmarks for static-kdtree
# Chrome 34
| Data Structure | [Linear scan](http://en.wikipedia.org/wiki/Brute-force_search) | [static-kdtree](https://github.com/mikolalysenko/static-kdtree) | [Ubilabs kdtree](https://github.com/ubilabs/kd-tree-javascript) |
| :--- | ---: | ---: | ---: |
| Dynamic? | ✓ | ✗ | ✓ |
| Works in browser? | ✓ | ✓ | ✓ |
| Construction: (n=100,d=2) | 0ms | 0.1376ms | 0.1204ms |
| Construction: (n=1000,d=2) | 0ms | 1.51ms | 3.102ms |
| Construction: (n=10000,d=2) | 0ms | 17.63ms | 58.74ms |
| Construction: (n=100000,d=2) | 0ms | 214.8ms | 1149.4ms |
@mikolalysenko
mikolalysenko / index.js
Created April 25, 2014 17:16
requirebin sketch
var shell = require("gl-now")({clearColor: [0,0,0,0]})
var camera = require("game-shell-orbit-camera")(shell)
var glm = require("gl-matrix")
var createMesh = require("gl-simplicial-complex")
var dup = require("dup")
var mat4 = glm.mat4
var NUM_POINTS = 1e6
var gl, mesh
This was wrong, never mind.
@mikolalysenko
mikolalysenko / Dreamy.glsl
Created May 21, 2014 14:55 — forked from glslioadmin/TEMPLATE.glsl
GLSL.io Transition (v1)
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
vec2 offset(float progress, float x, float theta) {
float phase = progress*progress + progress + theta;
float shifty = 0.03*progress*cos(10.0*(progress+x));
var shell = require("gl-now")
var camera = require("gl-camera")(shell)
var createPoints = require("gl-point-cloud")
var points, axes
shell.on("gl-init", function() {
var gl = shell.gl
points = createPoints(gl, {
positions: [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
@mikolalysenko
mikolalysenko / gist:d32cfb2c74dcdc2746ef
Last active August 29, 2015 14:02
Goat, Wolf, Lion Joke
//Solves that silly goat/wolf/lion problem
//
// From this challenge: http://unriskinsight.blogspot.dk/2014/06/fast-functional-goats-lions-and-wolves.html
//
// Example performance on input: 1017 1055 1006
//
// C++: 31.695 s
// JS: 0.059 s
//
// Checkmate C++?
@mikolalysenko
mikolalysenko / index.js
Created August 12, 2014 02:36
requirebin sketch
//Load shell
var shell = require("gl-now")({ clearColor: [0,0,0,0] })
var camera = require("game-shell-orbit-camera")(shell)
//Mesh creation tools
var createMesh = require("gl-simplicial-complex")
var polygonize = require("isosurface").surfaceNets
var createAxes = require("gl-axes")
//Matrix math