Skip to content

Instantly share code, notes, and snippets.

@manudurgoni
manudurgoni / gist:7e01a6dd32d487dea8d70f711579139b
Created July 30, 2021 09:19
Distance / speed / time calculator
distance = speed * time
speed = distance/time
time = distance/speed
var cameraZ = camera.position.z;
var planeZ = 5;
var distance = cameraZ - planeZ;
var aspect = viewWidth / viewHeight;
var vFov = camera.fov * Math.PI / 180;
var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance;
var planeWidthAtDistance = planeHeightAtDistance * aspect;
// or
@manudurgoni
manudurgoni / index.css
Created February 11, 2021 15:41
Three.js - Canvas Textured Cube
html, body {
height: 100%;
margin: 0;
}
#c {
width: 100%;
height: 100%;
display: block;
}
@manudurgoni
manudurgoni / getDistance.js
Created March 21, 2018 09:33
Calculate the distance between two GPS coordinates
var rad = function(x) {
return x * Math.PI / 180;
};
var getDistance = function(p1, p2) {
var R = 6378137; // Earth’s mean radius in meter
var dLat = rad(p2.lat() - p1.lat());
var dLong = rad(p2.lng() - p1.lng());
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) *
@manudurgoni
manudurgoni / meta_facebook.html
Last active November 25, 2017 21:01
Share a gif image on Facebook
<meta property="og:type" content="video.other"/>
<meta property="og:title" content="Title"/>
<meta property="og:url" content="name.gif"/>
<meta property="og:image" content="name.gif"/>
<meta property="og:image:type" content="image/gif"/>
var fragmentShader = `
precision mediump float;
uniform vec2 resolution;
uniform float time;
uniform float alpha;
uniform vec2 speed;
uniform float shift;
float rand(vec2 n) {