Skip to content

Instantly share code, notes, and snippets.

@abberg
abberg / gist:5125157
Created March 9, 2013 18:29
Test gist to see about tumblr embed..
var foo = 100;
for(var i = 0; i < foo; i++){
var ci = items[i];
}
@abberg
abberg / volumetricLight.js
Last active April 30, 2020 15:05
Example of three.js setup for volumetric lighting
var scene, camera, renderer, composer, box, pointLight,
occlusionComposer, occlusionRenderTarget, occlusionBox, lightSphere,
angle = 0,
DEFAULT_LAYER = 0,
OCCLUSION_LAYER = 1;
// scene, camera, and renderer as normal for three.js
scene = new THREE.Scene();
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform vec2 lightPosition;
uniform float exposure;
uniform float decay;
uniform float density;
uniform float weight;
uniform int samples;
const int MAX_SAMPLES = 100;
void main(){
const Card = (props) =>
<div className="c-card">
<img src="{props.img}" className="c-card__img" />
<h2 className="c-card__title">{props.title}</h2>
<p className="c-card__desc">{props.desc}</p>
</div>
@abberg
abberg / mediaQueryChange.js
Last active June 13, 2017 02:29
get media queries from stylesheets and dispatch events when the change
var styleSheets = Array.from(document.styleSheets);
var cssRules = styleSheets.filter(function(styleSheet){
// cross domain stylesheets without a policy file will return false
return styleSheet.rules;
}).map(function(styleSheet){
var rules = Array.from(styleSheet.rules);
return rules.filter(function(rule){
// extract only the media query rules
return rule.type === CSSRule.MEDIA_RULE;
})
@abberg
abberg / .block
Last active July 2, 2017 02:49 — forked from mbostock/.block
Voronoi Flames Mouse Trailer
license: gpl-3.0