Skip to content

Instantly share code, notes, and snippets.

@slawo-ch
Created December 23, 2019 11:27
Show Gist options
  • Save slawo-ch/e004af717a654f6e86e0fe977202736e to your computer and use it in GitHub Desktop.
Save slawo-ch/e004af717a654f6e86e0fe977202736e to your computer and use it in GitHub Desktop.
// offsets for moving height maps
let dx1 = 0;
let dy1 = 0;
let dx2 = 0;
let dy2 = 0;
// adjust height maps offsets
const moveHeightMaps = t => {
dx1 = Math.floor(
(((Math.cos(t * 0.0002 + 0.4 + Math.PI) + 1) / 2) * mapSize) / 2
);
dy1 = Math.floor(
(((Math.cos(t * 0.0003 - 0.1) + 1) / 2) * mapSize) / 2
);
dx2 = Math.floor(
(((Math.cos(t * -0.0002 + 1.2) + 1) / 2) * mapSize) / 2
);
dy2 = Math.floor(
(((Math.cos(t * -0.0003 - 0.8 + Math.PI) + 1) / 2) * mapSize) / 2
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment