From 967623a95e512dedeeadd13e3427b89979097635 Mon Sep 17 00:00:00 2001 From: David Haddad Date: Thu, 29 Aug 2019 11:47:17 -0500 Subject: [PATCH 1/2] Add automatic random splats on timer. --- script.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/script.js b/script.js index dc428a78..969c596b 100644 --- a/script.js +++ b/script.js @@ -53,6 +53,9 @@ let config = { SUNRAYS: true, SUNRAYS_RESOLUTION: 196, SUNRAYS_WEIGHT: 1.0, + AUTOSPLAT_ENABLED: false, + AUTOSPLAT_DELAY: 1, + AUTOSPLAT_COUNT: 1 } function pointerPrototype () { @@ -194,6 +197,11 @@ function startGUI () { splatStack.push(parseInt(Math.random() * 20) + 5); } }, 'fun').name('Random splats'); + let autosplatFolder = gui.addFolder('Auto-splat'); + autosplatFolder.add(config, 'AUTOSPLAT_ENABLED').name('enable auto-splat').listen(); + autosplatFolder.add(config, 'AUTOSPLAT_DELAY', 0.1, 30.0).name('auto-splat interval seconds'); + autosplatFolder.add(config, 'AUTOSPLAT_COUNT', 1, 10, 1).name('number of auto-splats'); + let bloomFolder = gui.addFolder('Bloom'); bloomFolder.add(config, 'BLOOM').name('enabled').onFinishChange(updateKeywords); bloomFolder.add(config, 'BLOOM_INTENSITY', 0.1, 2.0).name('intensity'); @@ -1115,6 +1123,16 @@ updateKeywords(); initFramebuffers(); multipleSplats(parseInt(Math.random() * 20) + 5); +var autosplat = function() { + if(config.AUTOSPLAT_ENABLED) { + splatStack.push(config.AUTOSPLAT_COUNT); + } + + setTimeout(autosplat, config.AUTOSPLAT_DELAY*1000); +} + +setTimeout(autosplat, config.AUTOSPLAT_DELAY*1000); + let lastUpdateTime = Date.now(); let colorUpdateTimer = 0.0; update(); From 4679a2d32cf5a870c34d1153e9a27f111841978e Mon Sep 17 00:00:00 2001 From: David Haddad Date: Thu, 29 Aug 2019 13:13:43 -0500 Subject: [PATCH 2/2] Autosplat now respects Pause --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index 969c596b..a5ea2638 100644 --- a/script.js +++ b/script.js @@ -1124,7 +1124,7 @@ initFramebuffers(); multipleSplats(parseInt(Math.random() * 20) + 5); var autosplat = function() { - if(config.AUTOSPLAT_ENABLED) { + if(config.AUTOSPLAT_ENABLED && !config.PAUSED) { splatStack.push(config.AUTOSPLAT_COUNT); }