Skip to content

Instantly share code, notes, and snippets.

View michaeldll's full-sized avatar

Michael michaeldll

View GitHub Profile
declare module 'virtual-scroll' {
export type VirtualScrollEvent = {
x: number // total distance scrolled on the x axis
y: number // total distance scrolled on the y axis
deltaX: number // distance scrolled since the last event on the x axis
deltaY: number // distance scrolled since the last event on the y axis
originalEvent: Event // the native event triggered by the pointer device or keyboard
}
export type VirtualScrollCallback = (e: VirtualScrollEvent) => void
@raphaelameaume
raphaelameaume / uvCover.glsl
Created May 29, 2020 15:01
Simulate background:size cover in fragment shader
vec2 uvCover (vec2 uv, vec2 size, vec2 resolution) {
vec2 coverUv = uv;
vec2 s = resolution; // Screen
vec2 i = size; // 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;
@zadvorsky
zadvorsky / 01_load_basic.js
Last active August 12, 2020 03:23
Three.js Promise Loading
const material = new THREE.MeshStandardMaterial({
map: new THREE.TextureLoader().load('map.jpg'),
normalMap: new THREE.TextureLoader().load('normalMap.jpg')
});
const loader = new THREE.JSONLoader();
loader.load('geometry.json', geometry => {
const mesh = new THREE.Mesh(geometry, material);