Skip to content

Instantly share code, notes, and snippets.

@akella
Created February 16, 2025 08:58
Show Gist options
  • Save akella/dcece171c925d7b63dbe36f994fb6896 to your computer and use it in GitHub Desktop.
Save akella/dcece171c925d7b63dbe36f994fb6896 to your computer and use it in GitHub Desktop.
useful
import * as THREE from 'three';
const { cos, sin, PI } = Math;
const TEXTURE_OFFSET = -1.855;
export const latlong2xyz = (R, longitude, latitude)=> {
let lon = longitude * PI / 180 + 1.87;
const lat = latitude * PI / 180;
lon = -lon;
const x = R * cos(lat) * cos(lon);
const y = R * sin(lat);
const z = R * cos(lat) * sin(lon);
let finalCoord = new THREE.Vector3(x, y, z);
finalCoord.applyAxisAngle(new THREE.Vector3(0, 1, 0), TEXTURE_OFFSET);
return finalCoord;
}
import {
vec4,
vec3,
Fn,
uv,
texture,
uniform,
normalLocal,
mul,
positionLocal,
pass,
overlay,
refract,
positionWorld,
cameraPosition,
normalize,
length,
screenUV,
normalWorld,
vec2,
textureBicubic,
float,
negate,
smoothstep,
attribute,
sin,
cos,
instancedBufferAttribute,
mat4,
div,
modelWorldMatrix,
transformedNormalWorld,
cameraProjectionMatrix,
cameraViewMatrix,
Loop,
} from "three/tsl";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment