summaryrefslogtreecommitdiff
path: root/src/SomhairlesDream.Frontend/App.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 23:52:23 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 23:52:23 +0800
commit027025e4af3217bd1e026f614f47a1c92fcbd8b9 (patch)
tree9b1247fc4938e5c7f8159ccebc6a4efaafbc6d63 /src/SomhairlesDream.Frontend/App.fs
parent5d73943e584b1c0c0753dda85fbda34d27726986 (diff)
downloadsomhairles-dream-fsharp-027025e4af3217bd1e026f614f47a1c92fcbd8b9.tar.gz
feat(viewer): starfield backdrop for deep-space context
Diffstat (limited to 'src/SomhairlesDream.Frontend/App.fs')
-rw-r--r--src/SomhairlesDream.Frontend/App.fs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/SomhairlesDream.Frontend/App.fs b/src/SomhairlesDream.Frontend/App.fs
index 72d1be2..2aa78eb 100644
--- a/src/SomhairlesDream.Frontend/App.fs
+++ b/src/SomhairlesDream.Frontend/App.fs
@@ -210,7 +210,7 @@ let frameObject (view: ViewState) (node: ThreeNode) =
camera.position.set(dirX / norm * distance, dirY / norm * distance, dirZ / norm * distance)
|> ignore
camera.near <- max 1.0 (distance * 0.05)
- camera.far <- distance + longest * 3.0
+ camera.far <- max 700.0 (distance + longest * 3.0)
camera.lookAt(0.0, 0.0, 0.0)
camera.updateProjectionMatrix ()
@@ -277,6 +277,26 @@ let initializeView () =
let bounceLight = createHemisphereLight("#3d4a56", "#141a1e", 0.9)
scene.add(bounceLight)
+ // Starfield: gives deep-space context so the vehicle reads as a ship in
+ // the void instead of a model on a grey stage.
+ let starCount = 2600
+ let starPositions = Array.zeroCreate (starCount * 3)
+ let starRng = System.Random(4242)
+
+ for index in 0 .. starCount - 1 do
+ let theta = starRng.NextDouble() * 2.0 * System.Math.PI
+ let phi = System.Math.Acos(2.0 * starRng.NextDouble() - 1.0)
+ let radius = 260.0 + starRng.NextDouble() * 90.0
+ starPositions.[index * 3] <- radius * System.Math.Sin(phi) * System.Math.Cos(theta)
+ starPositions.[index * 3 + 1] <- radius * System.Math.Cos(phi)
+ starPositions.[index * 3 + 2] <- radius * System.Math.Sin(phi) * System.Math.Sin(theta)
+
+ let starGeometry = createBufferGeometry ()
+ starGeometry.setAttribute("position", createFloat32BufferAttribute(starPositions, 3)) |> ignore
+ let starMaterial = createPointsMaterial "#c9d6e6" 1.7 0.9
+ let stars = createPoints starGeometry starMaterial
+ scene.add(stars)
+
// Coordinate ground grid so the model reads as anchored in a workspace
// instead of floating in a void.
let grid = createGridHelper (24.0, 48, "#5a4a2a", "#2a2f33")