train 3d visualizations

This commit is contained in:
Marshal
2026-08-02 21:48:22 +00:00
parent 6d8e5551ad
commit c055abe8c1

View File

@@ -113,7 +113,7 @@ function buildAcacia(rng: () => number): THREE.Group {
tree.add(branch); tree.add(branch);
} }
const canopyMat = new THREE.MeshStandardMaterial({ const canopyMat = new THREE.MeshStandardMaterial({
color: rng() > 0.5 ? 0x5d7a35 : 0x6b8342, color: rng() > 0.5 ? 0x2f7d32 : 0x3c8d40,
roughness: 1, roughness: 1,
}); });
const canopy = new THREE.Mesh(new THREE.SphereGeometry(2.6 + rng() * 1.6, 10, 8), canopyMat); const canopy = new THREE.Mesh(new THREE.SphereGeometry(2.6 + rng() * 1.6, 10, 8), canopyMat);
@@ -124,7 +124,7 @@ function buildAcacia(rng: () => number): THREE.Group {
} }
function buildShrub(rng: () => number): THREE.Mesh { function buildShrub(rng: () => number): THREE.Mesh {
const dry = [0x9c8a4d, 0x8f7a3e, 0xa89a5e, 0x7d8a4a]; const dry = [0x3c7d33, 0x4f9e3f, 0x2e6b28, 0x5da84a];
const shrub = new THREE.Mesh( const shrub = new THREE.Mesh(
new THREE.SphereGeometry(0.5 + rng() * 0.8, 7, 6), new THREE.SphereGeometry(0.5 + rng() * 0.8, 7, 6),
new THREE.MeshStandardMaterial({ color: dry[Math.floor(rng() * dry.length)], roughness: 1 }), new THREE.MeshStandardMaterial({ color: dry[Math.floor(rng() * dry.length)], roughness: 1 }),
@@ -196,8 +196,8 @@ function buildScenery(scene: THREE.Scene, trackLen: number) {
const rng = makeRng(1234567); const rng = makeRng(1234567);
buildClouds(scene, rng); buildClouds(scene, rng);
const spread = Math.max(trackLen, 600); const spread = Math.max(trackLen, 600);
// sand variation: lighter wind-blown patches // grass variation: darker meadow patches
const patchMat = new THREE.MeshStandardMaterial({ color: 0xe6cfa3, roughness: 1 }); const patchMat = new THREE.MeshStandardMaterial({ color: 0x4f8f3a, roughness: 1 });
const patchGeo = new THREE.CircleGeometry(4, 8); const patchGeo = new THREE.CircleGeometry(4, 8);
const patches = new THREE.InstancedMesh(patchGeo, patchMat, 160); const patches = new THREE.InstancedMesh(patchGeo, patchMat, 160);
const m4 = new THREE.Matrix4(); const m4 = new THREE.Matrix4();
@@ -212,8 +212,8 @@ function buildScenery(scene: THREE.Scene, trackLen: number) {
patches.setMatrixAt(i, m4); patches.setMatrixAt(i, m4);
} }
scene.add(patches); scene.add(patches);
// low dunes on the horizon sides // low green hills on the horizon sides
const duneMat = new THREE.MeshStandardMaterial({ color: 0xcaa878, roughness: 1 }); const duneMat = new THREE.MeshStandardMaterial({ color: 0x4a8a38, roughness: 1 });
for (let i = 0; i < 12; i++) { for (let i = 0; i < 12; i++) {
const dune = new THREE.Mesh(new THREE.SphereGeometry(30 + rng() * 50, 12, 8), duneMat); const dune = new THREE.Mesh(new THREE.SphereGeometry(30 + rng() * 50, 12, 8), duneMat);
dune.scale.set(1.6 + rng(), 0.12 + rng() * 0.08, 1 + rng()); dune.scale.set(1.6 + rng(), 0.12 + rng() * 0.08, 1 + rng());
@@ -289,7 +289,7 @@ function buildTrack(scene: THREE.Scene, length: number) {
// ground // ground
const ground = new THREE.Mesh( const ground = new THREE.Mesh(
new THREE.PlaneGeometry(4000, 1600), new THREE.PlaneGeometry(4000, 1600),
new THREE.MeshStandardMaterial({ color: 0xd8b98a, roughness: 1 }), new THREE.MeshStandardMaterial({ color: 0x5da043, roughness: 1 }),
); );
ground.rotation.x = -Math.PI / 2; ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.02; ground.position.y = -0.02;
@@ -593,7 +593,7 @@ export function Train3DVisualization({ schedule, onClose }: Train3DVisualization
host.appendChild(renderer.domElement); host.appendChild(renderer.domElement);
// lights: bright sunny day // lights: bright sunny day
scene.add(new THREE.HemisphereLight(0xcfe8ff, 0xcaa878, 1.0)); scene.add(new THREE.HemisphereLight(0xcfe8ff, 0x6f9c4e, 1.0));
const sun = new THREE.DirectionalLight(0xfff4d6, 2.4); const sun = new THREE.DirectionalLight(0xfff4d6, 2.4);
sun.position.set(-120, 180, 90); sun.position.set(-120, 180, 90);
scene.add(sun); scene.add(sun);