This file contains 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
vec2 rotate(vec2 v, float a) { | |
float s = sin(a); | |
float c = cos(a); | |
mat2 m = mat2(c, -s, s, c); | |
return m * v; | |
} |
This file contains 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
import _ from 'underscore'; | |
export default class TextureAtlas { | |
constructor(json, image) { | |
this._textures = {}; | |
let texture = new THREE.Texture(image); | |
texture.needsUpdate = true; | |
let frames = json.frames; | |
_.keys(frames).forEach(function(key, i) { |
This file contains 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
vec3 vWorldPosition = (modelViewMatrix * position).xyz;' |
This file contains 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
function loop(val, min, max) { | |
return ((val - min) % (max - min + 1) + (max - min + 1)) % (max - min + 1) + min; | |
} |
This file contains 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
// Also see https://github.com/Phrogz/context-blender | |
function multiply(R, G, B) { | |
var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height); | |
var data = imgData.data; | |
for (var i = 0; i < data.length; i += 4) { | |
data[i ] = R * data[i ] / 255; | |
data[i + 1] = G * data[i + 1] / 255; | |
data[i + 2] = B * data[i + 2] / 255; |
This file contains 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
// Check FPS estimate over an interval of time and trigger callback if it becomes too slow. | |
// Ideally callback turn quality settings down (canvas dpr, post process, number of particles, ...) | |
// See also | |
// https://mrnmnm.com/ | |
// http://findinglove.activetheory.net | |
const PAST_FRAMES = 60; // Memorize 1s of render time | |
const BAD_FRAMES = 30; // Max number of slow frame before downgrade | |
export default class PerformanceMonitor { |
This file contains 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
vec2 rotateUV(vec2 uv, float rotation) | |
{ | |
float mid = 0.5; | |
return vec2( | |
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid, | |
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid | |
); | |
} | |
vec2 rotateUV(vec2 uv, float rotation, vec2 mid) |
This file contains 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
var fs = require('fs'); | |
var argv = require('minimist')(process.argv.slice(2)); | |
let data = JSON.parse(fs.readFileSync('./' + argv.input, 'utf8')); | |
Object.keys(data).forEach(function(key) { | |
if (data[key] instanceof Array) { | |
data[key].forEach(function(value, i) { | |
data[key][i] = parseFloat(parseFloat(value).toFixed(3 || argv.cs)); | |
}); | |
} |
This file contains 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
// https://stackoverflow.com/questions/24480901/libgdx-overlay-texture-above-another-texture-using-shader | |
vec4 layer(vec4 foreground, vec4 background) { | |
return foreground * foreground.a + background * (1.0 - foreground.a); | |
} | |
#pragma glslify: export(layer); |
This file contains 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
font-feature-settings: "tnum"; | |
font-variant-numeric: tabular-nums; |