terrain-map
ARCHIVED - repo for blog post http://www.vogt.world/writing/procedural-terrain-generation/
git clone https://git.vogt.world/terrain-map.git
Log | Files | README.md
← Commit log
commit
message
Breaking down rows to show more examples with different parameters
author
Ben Vogt <[email protected]>
date
2016-05-15 16:18:36
stats
2 file(s) changed, 38 insertions(+), 7 deletions(-)
files
index.html
worker.js
 1diff --git a/index.html b/index.html
 2index e10d93a..0170972 100644
 3--- a/index.html
 4+++ b/index.html
 5@@ -25,13 +25,26 @@
 6       <div class="row">
 7         <h2>Standard Diamond-Square Algorithm</h2>
 8         <p>
 9-          Diamon-Square with smoothing of 10, and 20.
10+          Diamon-Square with several different deviation parameters.
11           <button class="run button-primary" id="standard">GENERATE</button>
12         </p>
13       </div>
14       <div class="set-of" id="container-standard"></div>
15       <hr>
16     </div>
17+    <!-- container-sadkajda -->
18+    <div class="container">
19+      <hr>
20+      <div class="row">
21+        <h2>Diamond-Square Algorithm with Smoothing Pass</h2>
22+        <p>
23+          Diamon-Square smoothed with average of neighbors in 10 point radius, and 20 point radius.
24+          <button class="run button-primary" id="smoothed">GENERATE</button>
25+        </p>
26+      </div>
27+      <div class="set-of" id="container-smoothed"></div>
28+      <hr>
29+    </div>
30     <!-- container-2 -->
31     <div class="container">
32       <div class="row">
33diff --git a/worker.js b/worker.js
34index 867ce7d..57c4db4 100644
35--- a/worker.js
36+++ b/worker.js
37@@ -195,23 +195,40 @@ self.addEventListener('message', function(e) {
38         result: "reversed"
39       });
40       break;
41-    case 'standard':
42+    case 'smoothed':
43       terrain = new LandMap({
44-        containerId: "container-standard"
45+        containerId: "container-smoothed"
46       });
47       terrain.generate({
48         deviation: 0.75,
49-        feature: "standard"
50+        feature: "p1"
51       });
52       terrain.smooth({
53         amount: 10,
54-        from: "standard",
55-        to: "standard-10"
56+        from: "p1",
57+        to: "p2"
58       });
59       terrain.smooth({
60         amount: 20,
61-        from: "standard",
62-        to: "standard-20"
63+        from: "p1",
64+        to: "p3"
65+      });
66+      break;
67+    case 'standard':
68+      terrain = new LandMap({
69+        containerId: "container-standard"
70+      });
71+      terrain.generate({
72+        deviation: 0.35,
73+        feature: "m1"
74+      });
75+      terrain.generate({
76+        deviation: 0.75,
77+        feature: "p1"
78+      });
79+      terrain.generate({
80+        deviation: 0.95,
81+        feature: "r1"
82       });
83       break;
84   };