diff --git a/vendor/clouds3d.js b/vendor/clouds3d.js index dfcce47..6d02357 100644 --- a/vendor/clouds3d.js +++ b/vendor/clouds3d.js @@ -139,7 +139,7 @@ var FRAG_SRC = [ 'float drift = uTime * uSpeed * 0.45;', // Fixed altitude well above the cloud ceiling (y=1.5). 'float camY = 2.2;', - 'vec3 ro = vec3(drift, camY, drift * 0.7);', + 'vec3 ro = vec3(0.0, camY, drift);', // Ray direction: tilt more downward so the visible ground fits // within the mosaic. At uv.y = 0 the ray goes ~26° below // horizontal, putting the visible ground at tGround < 5 @@ -271,12 +271,10 @@ function init(canvas) { var GROUND_TILE_URL = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/'; var GROUND_TILE_Z = 11; var GROUND_TILE_SIZE = 256; -// Camera travels at uTime * uSpeed * 0.45 in +X (and +X*0.7 in +Z). -// Travel angle: atan2(0.7, 1) ~ 35 deg. Normalised: cos=0.82, sin=0.57. -// The corridor is ROTATED to follow the actual travel direction so -// tiles aren't wasted in regions the camera never reaches. -var GROUND_TRAVEL_COS = 0.82; // cos(35 deg), = 1 / sqrt(1 + 0.49) -var GROUND_TRAVEL_SIN = 0.57; // sin(35 deg), = 0.7 / sqrt(1.49) +// Camera travels in +Z (forward) and looks in +Z (also forward). +// The corridor is aligned with both motion and look direction. +var GROUND_TRAVEL_COS = 0.0; // cos(90 deg) +var GROUND_TRAVEL_SIN = 1.0; // sin(90 deg) var GROUND_CORRIDOR_LONG = 15; // tiles along the travel direction var GROUND_CORRIDOR_PERP = 5; // tiles perpendicular to travel var GROUND_BUFFER_LONG = 2; // refetch when this close to forward edge @@ -369,6 +367,8 @@ function maybeRefetchGround(cameraWorldX, cameraWorldZ, gl) { var cameraTileX = GROUND_BASE_X + Math.floor(cameraWorldX); var cameraTileY = GROUND_BASE_Y + Math.floor(cameraWorldZ); // Project camera offset onto the corridor's rotated axes. + // With GROUND_TRAVEL_COS/SIN = (0, 1) the corridor runs along + // +Z (camera's motion + look direction). var dx = cameraTileX - groundCenterTile.x; var dy = cameraTileY - groundCenterTile.y; var projLong = dx * GROUND_TRAVEL_COS + dy * GROUND_TRAVEL_SIN;