Extracted from https://github.com/rpavlik/maya2osg/tree/master/src/GLSL
varying vec2 vTexCoord;
varying vec3 vNormal;
varying vec3 vEye;
void main() {
/** round n down to nearest multiple of m */ | |
long roundDown(long n, long m) { | |
return n >= 0 ? (n / m) * m : ((n - m + 1) / m) * m; | |
} | |
/** round n up to nearest multiple of m */ | |
long roundUp(long n, long m) { | |
return n >= 0 ? ((n + m - 1) / m) * m : (n / m) * m; | |
} |
import THREE from 'three'; | |
import CANNON from 'cannon'; | |
export const generateThreeVertices = (rawVerts) => { | |
let verts = []; | |
for(let v = 0; v < rawVerts.length; v+=3){ | |
verts.push(new THREE.Vector3(rawVerts[v], | |
rawVerts[v+1], | |
rawVerts[v+2])); |
Extracted from https://github.com/rpavlik/maya2osg/tree/master/src/GLSL
varying vec2 vTexCoord;
varying vec3 vNormal;
varying vec3 vEye;
void main() {
/* | |
Uploads to GPU immediately when the image is ready, then fires callback. | |
//takes a string path or image/canvas/video/ImageData | |
uploadTexture(renderer, pathOrImage, function(err, texture) { | |
if (err) console.error(err) | |
//do something with the ThreeJS 'texture' result | |
}) | |
*/ | |
var THREE = require('three'); |
fluid-aspect is a Sass mixin for creating intrinsic ratios in CSS. Intrinsic ratios allow elements to fill the width of their containing block and resize on the fly while maintaining their aspect ratio.
@include fluid-aspect($ratio, [$target]);
// An implementation of CSS `background-size: cover` | |
// using http://stackoverflow.com/a/6565988 and my own crappy math | |
vec2 s = uScreenSize; // Screen | |
vec2 i = uBGSize; // Image | |
float rs = s.x / s.y; | |
float ri = i.x / i.y; | |
vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x); | |
vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new; | |
vec2 uv = vTexCoord * s / new + offset; | |
gl_FragColor = texture2D(uBGTex, uv); |
var collision = {}; | |
// aabb: <THREE.Box3> | |
// Plane: <THREE.Plane> | |
collision.isIntersectionAABBPlane = function ( aabb, Plane ) { | |
var center = new THREE.Vector3().addVectors( aabb.max, aabb.min ).multiplyScalar( 0.5 ), | |
extents = new THREE.Vector3().subVectors( aabb.max, center ); |
#version 400 | |
layout( location = 0 ) out vec4 frag_main; | |
struct PointLight{ | |
vec3 position; | |
vec3 ambient; | |
vec3 diffuse; | |
vec3 specular; | |
float shininess; | |
float intensity; | |
}; |
#!/usr/bin/env python | |
# coding: UTF-8 | |
import cv2 | |
import numpy as np | |
def make_lut256x16(exportPath): | |
''' 256 x 16 LUT ''' | |
colors = [] |
//JSON object | |
"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(t){return 10>t?"0"+t:t}function this_value(){return this.valueOf()}function quote(t){return rx_escapable.lastIndex=0,rx_escapable.test(t)?'"'+t.replace(rx_escapable,function(t){var e=meta[t];return"string"==typeof e?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function str(t,e){var r,n,o,u,f,a=gap,i=e[t];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(t)),"function"==typeof rep&&(i=rep.call(e,t,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?i+"":"null";case"boolean":case"null":return i+"";case"object":if(!i)return"null";if(gap+=indent,f=[],"[object Array]"===Object.prototype.toString.apply(i)){for(u=i.length,r=0;u>r;r+=1)f[r]=str(r,i)||"null";return o=0===f.length?"[]":gap?"[\n"+gap+f.join(",\n"+gap)+"\n"+a+"]":"["+f.join(",")+"]",gap=a,o}if(rep&&"object"==typeof rep)for(u=rep.length,r=0;u>r;r+=1)"string"==typeof rep[r]&&(n=rep[r],o=str(n,i),o&&f.push |