Skip to content

Commit 2441183

Browse files
committed
🌈🎛️ ↝ [SSM-176 SSM-169]: New planet generator, needs settings & prop imports
1 parent 0fad762 commit 2441183

29 files changed

+3911
-2927
lines changed

app/planets/[id]/page.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { Edit, Map, ArrowLeft, Info, FileText, Droplets, Thermometer, Globe } fr
1717
import SimplePlanetGenerator from "@/components/Data/Generator/Astronomers/PlanetHunters/SimplePlanetGenerator";
1818
import { Button } from "@/components/ui/button"
1919
import BiomassStats from "@/components/Structures/Missions/Biologists/BiomassOnPlanet";
20+
import WeatherGenerator from "@/components/Data/Generator/Weather/SimpleWeatherEvents";
21+
import { PlanetGenerator } from "@/components/Data/Generator/Astronomers/PlanetHunters/PlanetGenerator";
2022

2123
export interface Classification {
2224
id: number;
@@ -408,7 +410,7 @@ export default function ClassificationDetail({ params }: { params: { id: string
408410
</div>
409411
</div>
410412
</div>
411-
)
413+
);
412414

413415
// Component for the Climate information
414416
const ClimateComponent = () => (
@@ -422,7 +424,7 @@ export default function ClassificationDetail({ params }: { params: { id: string
422424
/>
423425
)}
424426
</div>
425-
)
427+
);
426428

427429
// Component for the atmosphere information
428430
const AtmosphereComponent = () => (
@@ -587,12 +589,13 @@ export default function ClassificationDetail({ params }: { params: { id: string
587589
<div>
588590
{classification && (
589591
<>
590-
<SimplePlanetGenerator
592+
{/* <SimplePlanetGenerator
591593
classificationId={String(classification.id)}
592594
classificationConfig={classification.classificationConfiguration}
593595
author={classification.author || ''}
594596
biome={dominantBiome ?? undefined}
595-
/>
597+
/> */}
598+
<PlanetGenerator />
596599
</>
597600
)}
598601
</div>
@@ -617,8 +620,8 @@ export default function ClassificationDetail({ params }: { params: { id: string
617620
default:
618621
return <PlanetComponent />
619622
}
623+
};
620624

621-
}
622625
return (
623626
<div className="relative min-h-screen w-full overflow-hidden bg-black text-white">
624627
<Navbar />
@@ -633,6 +636,10 @@ export default function ClassificationDetail({ params }: { params: { id: string
633636
<div className="absolute inset-0 bg-black/30" />
634637
</div>
635638

639+
{dominantBiome && (
640+
<><WeatherGenerator biome={dominantBiome} /></>
641+
)}
642+
636643
{/* Navigation */}
637644
{/* <header className="relative z-10 p-4 md:p-6">
638645
<nav className="hidden md:flex justify-between items-center">

app/planets/jupiter/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React, { useEffect, useState } from "react";
44
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
55
import Navbar from "@/components/Layout/Navbar";
6-
import { PlanetScene } from "@/components/Data/Generator/Astronomers/PlanetHunters/V2/planet-scene";
6+
// import { PlanetScene } from "@/components/Data/Generator/Astronomers/PlanetHunters/V2/planet-scene";
77
import { calculatePlanetStats, calculateTerrainHeight } from "@/utils/planet-physics";
88
import Link from "next/link";
99
import JVHCloudAggregator from "@/components/Structures/Missions/Meteorologists/JVH/JVHCloudAggregator";
@@ -158,10 +158,10 @@ export default function JupiterClassifications() {
158158
<Navbar />
159159
<div className="py-10">
160160
<h1 className="text-xl font-bold mb-4">Jupiter Discoveries</h1>
161-
<PlanetScene
161+
{/* <PlanetScene
162162
stats={stats}
163163
terrainHeight={terrainHeight}
164-
/>
164+
/> */}
165165
<button
166166
onClick={toggleMetadataVisibility}
167167
className="ml-4 px-4 bg-green-500 text-white rounded-sm"

app/planets/mars/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CloudClassificationSummary from "@/components/Structures/Missions/Meteoro
77
import SatellitePlanetFourAggregator from "@/components/Structures/Missions/Astronomers/SatellitePhotos/P4/P4Aggregator";
88
import AI4MAggregator from "@/components/Structures/Missions/Astronomers/SatellitePhotos/AI4M/AI4MAggregator";
99
import { AggregatedCloud, AggregatedBalloon, AggregatedAI4M, AggregatedP4 } from "../[id]/page";
10-
import { PlanetScene } from "@/components/Data/Generator/Astronomers/PlanetHunters/V2/planet-scene";
10+
// import { PlanetScene } from "@/components/Data/Generator/Astronomers/PlanetHunters/V2/planet-scene";
1111
import { calculatePlanetStats, calculateTerrainHeight } from "@/utils/planet-physics";
1212
import MarsCloudsShapesAggregator from "@/components/Structures/Missions/Meteorologists/Cloudspotting/Shapes/ShapesAggregator";
1313

@@ -194,13 +194,13 @@ export default function MarsClassifications() {
194194
<Navbar />
195195
<div className="py-10">
196196
<h1 className="text-xl font-bold mb-4">Mars Classifications</h1>
197-
<PlanetScene
197+
{/* <PlanetScene
198198
stats={
199199
stats
200200
}
201201
terrainHeight={terrainHeight}
202202
203-
/>
203+
/> */}
204204
<button
205205
onClick={toggleMetadataVisibility}
206206
className="ml-4 px-4 bg-green-500 text-white rounded-md"

app/posts/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react";
44
import { useSupabaseClient } from "@supabase/auth-helpers-react";
55
import { SimplePostSingle } from "@/content/Posts/SimplePostSingle";
66
import StructuresOnPlanet from "@/components/Structures/Structures";
7-
import PlanetGenerator from "@/components/Data/Generator/Astronomers/PlanetHunters/PlanetGenerator";
7+
// import PlanetGenerator from "@/components/Data/Generator/Astronomers/PlanetHunters/PlanetGenerator";
88
import Navbar from "@/components/Layout/Navbar";
99

1010
interface Classification {

app/scenes/desert/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ interface Project {
3737
title: string
3838
icon: React.ElementType
3939
completedCount: number
40-
internalComponent?: React.ElementType
41-
color: string
40+
internalComponent?: React.ComponentType<Record<string, never>>
41+
color: string; // Ensure this is explicitly typed as a string
4242
images?: string[]
4343
stats?: {
4444
cameras: number
@@ -277,7 +277,7 @@ function MainView({ projects, archiveImages, onProjectClick }: MainViewProps): R
277277
<CardHeader className="p-4 pb-2 pt-4">
278278
<CardTitle className="text-lg flex items-center justify-between">
279279
<div className="flex items-center">
280-
<Icon className={`h-5 w-5 ${project.color}`} />
280+
{/* <Icon className={`h-5 w-5 ${project.color as string}`} /> */}
281281
<span className="ml-2">{project.title}</span>
282282
{project.completedCount > 0 && (
283283
<Badge variant="secondary" className="ml-2 text-xs">
@@ -391,7 +391,7 @@ function ProjectDetailView({ project, onBack }: ProjectDetailViewProps): ReactEl
391391
<ChevronLeft className="h-5 w-5" />
392392
</Button>
393393
<h2 className="text-lg font-semibold flex items-center">
394-
<Icon className={`h-5 w-5 ${project.color}`} />
394+
{/* <Icon className={`h-5 w-5 ${project.color}`} /> */}
395395
<span className="ml-2">{project.title}</span>
396396
</h2>
397397
</div>

app/tests/page.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
"use client";
22

3-
import { FullPlanetGenerator } from "@/components/Data/Generator/Astronomers/PlanetHunters/V2/full-planet-generator";
4-
import { SimplePlanetGenerator } from "@/components/Data/Generator/Astronomers/PlanetHunters/Simple/simple-planet-generator";
5-
import ChatGPTComponent from "./pleaseWork";
6-
73
export default function TestPage() {
84
return (
95
<div className="min-h-screen bg-black text-white p-4 space-y-8">
10-
<ChatGPTComponent />
116
</div>
127
);
138
};
Lines changed: 54 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,60 @@
1-
import { useState, useEffect } from 'react';
2-
import { PlanetScene } from './planet-scene';
3-
import { PlanetControls } from './planet-controls';
4-
import { PlanetImportExport } from './planet-import-export';
5-
import { calculatePlanetStats } from '@/utils/planet-physics';
6-
import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react';
7-
import type { PlanetStats } from '@/utils/planet-physics';
1+
"use client"
82

9-
const TERRESTRIAL_THRESHOLD = 7.5; // Earth masses
10-
const GASEOUS_THRESHOLD = 2.0; // Earth radii
3+
import { useState, useEffect } from "react"
4+
import { Canvas } from "@react-three/fiber"
5+
import { OrbitControls, Stars, Environment } from "@react-three/drei"
6+
import { PlanetShader } from "./PlanetShader"
7+
import { SettingsPanel } from "./SettingsPanel";
8+
import { Cog } from "lucide-react"
9+
import { Button } from "@/components/ui/button"
10+
import { type PlanetStats, calculateDensity, defaultPlanetStats } from "@/lib/planet-physics"
1111

1212
export interface PlanetGeneratorProps {
13-
classificationConfig?: any;
14-
content?: string;
15-
classificationId: string;
16-
author: string;
17-
type?: string;
18-
biome?: string;
19-
};
20-
21-
export default function PlanetGenerator({ classificationConfig, author, classificationId }: PlanetGeneratorProps) {
22-
const supabase = useSupabaseClient();
23-
const session = useSession();
24-
25-
const initialMass = classificationConfig?.exportedValue?.mass ?? 1;
26-
const initialRadius = classificationConfig?.exportedValue?.radius ?? 1;
27-
28-
const [mass, setMass] = useState(initialMass);
29-
const [radius, setRadius] = useState(initialRadius);
30-
const [typeOverride, setTypeOverride] = useState<'terrestrial' | 'gaseous' | null>(null);
31-
32-
const stats = calculatePlanetStats(mass, radius, undefined, undefined, typeOverride);
33-
34-
const handleMassChange = (newMass: number) => {
35-
if (typeOverride === 'terrestrial' && newMass > TERRESTRIAL_THRESHOLD) {
36-
setMass(TERRESTRIAL_THRESHOLD);
37-
} else if (typeOverride === 'gaseous' && newMass <= TERRESTRIAL_THRESHOLD) {
38-
setMass(TERRESTRIAL_THRESHOLD + 0.1);
39-
} else {
40-
setMass(newMass);
41-
}
42-
};
43-
44-
const handleRadiusChange = (newRadius: number) => {
45-
if (typeOverride === 'terrestrial' && newRadius > GASEOUS_THRESHOLD) {
46-
setRadius(GASEOUS_THRESHOLD);
47-
} else if (typeOverride === 'gaseous' && newRadius <= GASEOUS_THRESHOLD) {
48-
setRadius(GASEOUS_THRESHOLD + 0.1);
49-
} else {
50-
setRadius(newRadius);
51-
}
52-
};
53-
54-
const handleTypeOverride = (type: 'terrestrial' | 'gaseous' | null) => {
55-
setTypeOverride(type);
56-
if (type === 'terrestrial') {
57-
if (mass > TERRESTRIAL_THRESHOLD) setMass(TERRESTRIAL_THRESHOLD);
58-
if (radius > GASEOUS_THRESHOLD) setRadius(GASEOUS_THRESHOLD);
59-
} else if (type === 'gaseous') {
60-
if (mass <= TERRESTRIAL_THRESHOLD) setMass(TERRESTRIAL_THRESHOLD + 0.1);
61-
if (radius <= GASEOUS_THRESHOLD) setRadius(GASEOUS_THRESHOLD + 0.1);
62-
};
63-
};
64-
65-
const handleImport = (importedStats: Partial<PlanetStats>) => {
66-
if (importedStats.mass !== undefined) {
67-
setMass(importedStats.mass);
68-
};
69-
if (importedStats.radius !== undefined) {
70-
setRadius(importedStats.radius);
71-
};
72-
73-
setTypeOverride(null);
74-
};
75-
76-
const handleSave = async () => {
77-
if (!classificationId) {
78-
console.error('Classification ID is missing.');
79-
return;
80-
};
81-
82-
const idToQuery = typeof classificationId === 'string' ? classificationId : String(classificationId);
83-
84-
try {
85-
const { data, error } = await supabase
86-
.from('classifications')
87-
.select('classificationConfiguration')
88-
.eq('id', idToQuery)
89-
.single();
90-
91-
if (error) throw error;
92-
93-
const currentConfig = data?.classificationConfiguration || {};
94-
const newConfig = {
95-
...currentConfig,
96-
exportedValue: { mass, radius },
97-
};
98-
99-
const { error: updateError } = await supabase
100-
.from('classifications')
101-
.update({ classificationConfiguration: newConfig })
102-
.eq('id', idToQuery);
103-
104-
if (updateError) throw updateError;
105-
106-
alert('Planet configuration saved successfully!');
107-
} catch (err) {
108-
console.error('Error saving planet configuration:', err);
109-
alert('Failed to save planet configuration.');
110-
};
111-
};
13+
classificationId?: string;
14+
author?: string;
15+
classificationConfig?: JSON;
16+
};
17+
18+
export function PlanetGenerator() {
19+
const [showSettings, setShowSettings] = useState(false)
20+
const [planetStats, setPlanetStats] = useState<PlanetStats>(defaultPlanetStats)
21+
22+
// Update density when mass or radius changes
23+
useEffect(() => {
24+
setPlanetStats((prev) => ({
25+
...prev,
26+
density: calculateDensity(prev.mass, prev.radius),
27+
}))
28+
}, [planetStats.mass, planetStats.radius])
11229

11330
return (
114-
<div className="bg-black p-6">
115-
<div className="max-w-5xl mx-auto">
116-
<h1 className="text-3xl font-bold text-white mb-6">Procedural Planet Generator</h1>
117-
<div className="flex flex-row gap-6 items-start">
118-
<PlanetScene stats={stats} />
119-
<div className="flex flex-col gap-4 w-full">
120-
<PlanetControls
121-
stats={stats}
122-
onMassChange={handleMassChange}
123-
onRadiusChange={handleRadiusChange}
124-
onTypeOverride={handleTypeOverride}
125-
/>
126-
<PlanetImportExport stats={stats} onImport={handleImport} onSave={handleSave} />
127-
</div>
128-
</div>
129-
</div>
31+
<div className="w-full h-screen relative">
32+
<Canvas camera={{ position: [0, 0, 10], fov: 45 }}>
33+
{/* <color attach="background" args={["#020209"]} /> */}
34+
<ambientLight intensity={0.4} />
35+
<pointLight position={[10, 10, 10]} intensity={2} />
36+
<pointLight position={[-10, -10, -10]} intensity={0.5} color="#b0c4de" />
37+
<directionalLight position={[5, 5, 5]} intensity={1.5} castShadow />
38+
<Environment preset="sunset" />
39+
<PlanetShader planetStats={planetStats} />
40+
<Stars radius={100} depth={50} count={5000} factor={4} saturation={0} fade speed={1} />
41+
<OrbitControls enableZoom={true} enablePan={true} enableRotate={true} />
42+
<mesh position={[0, 0, -15]}>
43+
<sphereGeometry args={[5, 32, 32]} />
44+
<meshBasicMaterial color="#4060ff" transparent opacity={0.03} />
45+
</mesh>
46+
</Canvas>
47+
48+
<Button
49+
variant="outline"
50+
size="icon"
51+
className="absolute top-4 right-4 bg-black/50 hover:bg-black/70 text-white"
52+
onClick={() => setShowSettings(!showSettings)}
53+
>
54+
<Cog className="h-4 w-4" />
55+
</Button>
56+
57+
{showSettings && <SettingsPanel planetStats={planetStats} setPlanetStats={setPlanetStats} />}
13058
</div>
131-
);
132-
};
59+
)
60+
}

0 commit comments

Comments
 (0)