Skip to content

Commit

Permalink
Merge branch 'master' into fix-object-locking
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry authored Oct 10, 2024
2 parents 3fcefd7 + f4cf9c7 commit ca6d9f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 7 additions & 5 deletions example/imagery/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/

import { seededRandom } from 'utils/random.js';

const DEFAULT_IMAGE_SAMPLES = [
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18731.jpg',
'https://www.nasa.gov/wp-content/uploads/static/history/alsj/a16/AS16-117-18732.jpg',
Expand Down Expand Up @@ -162,8 +164,8 @@ export default function () {
};
}

function getCompassValues(min, max) {
return min + Math.random() * (max - min);
function getCompassValues(min, max, timestamp) {
return min + seededRandom(timestamp) * (max - min);
}

function getImageSamples(configuration) {
Expand Down Expand Up @@ -283,9 +285,9 @@ function pointForTimestamp(timestamp, name, imageSamples, delay) {
utc: Math.floor(timestamp / delay) * delay,
local: Math.floor(timestamp / delay) * delay,
url,
sunOrientation: getCompassValues(0, 360),
cameraAzimuth: getCompassValues(0, 360),
heading: getCompassValues(0, 360),
sunOrientation: getCompassValues(0, 360, timestamp),
cameraAzimuth: getCompassValues(0, 360, timestamp),
heading: getCompassValues(0, 360, timestamp),
transformations: navCamTransformations,
imageDownloadName
};
Expand Down
12 changes: 12 additions & 0 deletions src/utils/random.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generates a pseudo-random number based on a seed.
*
* @param {number} seed - The seed value to generate the random number.
* @returns {number} A pseudo-random number between 0 (inclusive) and 1 (exclusive).
*/
function seededRandom(seed = Date.now()) {
const x = Math.sin(seed) * 10000;
return x - Math.floor(x);
}

export { seededRandom };

0 comments on commit ca6d9f4

Please sign in to comment.