Skip to content

Instantly share code, notes, and snippets.

View skrat's full-sized avatar

Dušan Maliarik skrat

View GitHub Profile
class Path {
Path() {}
Path.parse(String data) {
return null; // mock
}
}
Document SVG = null;
Document ensureSvg(Function cb(Document svg)) {
@skrat
skrat / injector.js
Created August 31, 2012 11:17 — forked from jankuca/injector.js
Injector.js
/**
* @constructor
*/
function Injector() {
/**
* @type {!Object.<string, function(Injector=): !Object>}
*/
this.factories = {};
/**
* @type {!Object.<string, !Object>}
@skrat
skrat / vsm.js
Created October 25, 2012 14:46
VSM 4 THREE
/**
* Extended version of THREE.ShadowMapPluginVSM using VSM shadow mapping.
* @author Dusan Maliarik
*/
THREE.ShadowMapPluginVSM = function ( ) {
var _gl,
_renderer,
_depthMaterial, _depthMaterialMorph, _depthMaterialSkin, _depthMaterialMorphSkin,
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class vec3i
X = 0
Y = 1
Z = 2
constructor: (x, y, z) ->
@data = new Uint32Array()
@data[X] = x
@skrat
skrat / vec3i.coffee
Last active December 18, 2015 16:39
Per class storage
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
typed_concat = (type, a, b) ->
alen = a.length
result = new type(alen + b.length)
result.set(a)
result.set(b, alen)
result
@skrat
skrat / gist:5821525
Last active December 18, 2015 17:49
<script>
//<![CDATA[
document.write("<script type='text/javascript' src='http://" + window.location.hostname + ":9810/compile?id=areas-serve&mode=RAW'><\/script>");
//]]>
</script>
@skrat
skrat / vec3i.coffee
Created June 21, 2013 05:26
Swizzling, dynamic instance methods
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
arrayExcept = (arr, idx) ->
res = arr[0..]
res.splice idx, 1
res
combine = (str) ->
fn = (active, rest, a) ->
return class Sun extends require('events')
constructor: (gui, @bounds, @orientation=104, @elevation=60) ->
gui.remember @
super()
folder = gui.addFolder('Sun')
folder.add(@, 'orientation', 0, 360).onChange(@update)
folder.add(@, 'elevation', 0, 90).onChange(@update)
@size = @bounds.size.length
@center = @bounds.min.add(@bounds.size.div 2, new Vec3)
return class AABB
@property 'size',
get: -> @max.sub(@min, new Vec3)
@property 'vertices',
get: -> [
new Vec3(new Float32Array([@min.x, @min.y, @min.z]))
new Vec3(new Float32Array([@max.x, @min.y, @min.z]))
new Vec3(new Float32Array([@max.x, @min.y, @max.z]))
new Vec3(new Float32Array([@min.x, @min.y, @max.z]))
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
cat > .git/hooks/pre-commit
#!/bin/sh
make test