aboutsummaryrefslogtreecommitdiff
path: root/mountains.js
diff options
context:
space:
mode:
authorroot <root@caddy-256phi.local>2026-03-22 22:36:36 +0100
committerroot <root@caddy-256phi.local>2026-03-22 22:36:36 +0100
commitf6d1edb5e928b260afc8363b184123e017783285 (patch)
tree51ad4e06b71e333797d052e8088e0327d4ca17ba /mountains.js
parent5c6f7592a7a81c98a8179ebbfa9546405ac1b576 (diff)
Initial commit of the original website
Diffstat (limited to 'mountains.js')
-rw-r--r--mountains.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/mountains.js b/mountains.js
new file mode 100644
index 0000000..27cea87
--- /dev/null
+++ b/mountains.js
@@ -0,0 +1,40 @@
+import * as THREE from 'https://unpkg.com/three@0.160.0/build/three.module.js';
+
+export function createMountains() {
+ const mountainCount = 100; // number of peaks
+ const mountainWidth = 2; // horizontal spacing
+ const mountainHeight = 5; // max height of peaks
+ const baseHeight = 0; // ground level
+ const mountainDepth = -50; // far behind grid
+
+ // Create a 2D shape for the mountain silhouette
+ const shape = new THREE.Shape();
+ shape.moveTo(-mountainCount * mountainWidth / 2, baseHeight);
+
+ for (let i = -mountainCount / 2; i <= mountainCount / 2; i++) {
+ const x = i * mountainWidth;
+ const y = Math.random() * mountainHeight + 5; // peak height
+ shape.lineTo(x, y);
+ }
+
+ // Close shape at the far right base
+ shape.lineTo(mountainCount * mountainWidth / 2, baseHeight);
+ shape.lineTo(-mountainCount * mountainWidth / 2, baseHeight);
+
+ // Convert shape to geometry
+ const geometry = new THREE.ShapeGeometry(shape);
+
+ // Rotate so it lies in XZ plane
+ // geometry.rotateX(-Math.PI / 2);
+ geometry.translate(0, 0, mountainDepth);
+
+ const material = new THREE.MeshBasicMaterial({
+ color: 0xff0077,
+ side: THREE.DoubleSide,
+ transparent: true,
+ opacity: 1
+ });
+
+ const mesh = new THREE.Mesh(geometry, material);
+ return mesh;
+}