Skip to content

Commit

Permalink
internationally renowned physics bro suggests hyperbolic trajectories
Browse files Browse the repository at this point in the history
  • Loading branch information
RidwanSharkar committed Nov 19, 2024
1 parent 63c2ced commit 998933b
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 79 deletions.
1 change: 1 addition & 0 deletions public/textures/BorrowedOrder_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion warpgate/CelestialObjectGlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface GlowProps {
export const CelestialObjectGlow: React.FC<GlowProps> = ({
color,
size,
intensity = 0.3,
intensity = 0.4,
isSelected = false,
}) => {
const glowRef = useRef<ShaderMaterial>(null);
Expand Down
40 changes: 33 additions & 7 deletions warpgate/EnhancedPlanet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ interface EnhancedPlanetProps extends PlanetData {
selected: boolean;
collisionTriggered: boolean;
startAngle?: number;
isBinary?: boolean;
binaryOffset?: number;
binarySpeed?: number;
}


Expand All @@ -54,6 +57,9 @@ const EnhancedPlanet = forwardRef<Mesh, EnhancedPlanetProps>(({
moons,
logoTexturePath,
startAngle = 0,
isBinary,
binaryOffset,
binarySpeed,
}, ref) => {
const atmosphereRef = useRef<Mesh>(null);
const [hovered, setHovered] = useState(false);
Expand Down Expand Up @@ -90,17 +96,37 @@ const EnhancedPlanet = forwardRef<Mesh, EnhancedPlanetProps>(({

useFrame(({ clock }) => {
const elapsed = clock.getElapsedTime();
if (meshRef.current) { // Update planet
const angle = elapsed * orbitSpeed + startAngle;
meshRef.current.position.x = orbitRadius * Math.cos(angle);
meshRef.current.position.z = orbitRadius * Math.sin(angle);
meshRef.current.rotation.y += rotationSpeed; // Planet rotation
if (meshRef.current) {
if (isBinary && binaryOffset !== undefined && binarySpeed !== undefined) {
// Calculate the binary orbit position
const binaryAngle = elapsed * binarySpeed;
const binaryX = Math.cos(binaryAngle) * binaryOffset;
const binaryZ = Math.sin(binaryAngle) * binaryOffset;

// Calculate the main orbit position
const orbitAngle = elapsed * orbitSpeed + startAngle;
const orbitX = orbitRadius * Math.cos(orbitAngle);
const orbitZ = orbitRadius * Math.sin(orbitAngle);

// Combine the positions
meshRef.current.position.x = orbitX + binaryX;
meshRef.current.position.z = orbitZ + binaryZ;
} else {
// Original single planet behavior
const angle = elapsed * orbitSpeed + startAngle;
meshRef.current.position.x = orbitRadius * Math.cos(angle);
meshRef.current.position.z = orbitRadius * Math.sin(angle);
}

meshRef.current.rotation.y += rotationSpeed;

// Update atmosphere and logo positions
if (atmosphereRef.current) {
atmosphereRef.current.position.copy(meshRef.current.position);
atmosphereRef.current.rotation.copy(meshRef.current.rotation);
}
if (logoRef.current) {
logoRef.current.rotation.y += 0.01; // Logo rotation speed
logoRef.current.rotation.y += 0.01;
}
}
});
Expand Down Expand Up @@ -158,7 +184,7 @@ const EnhancedPlanet = forwardRef<Mesh, EnhancedPlanetProps>(({
{/* Atmosphere layer */}
<mesh
ref={atmosphereRef}
scale={[1.18, 1.18, 1.18]}
scale={[1.225, 1.225, 1.225]}
>
<sphereGeometry args={[size, 64, 64]} />
<primitive object={atmosphereMaterial} attach="material" />
Expand Down
141 changes: 91 additions & 50 deletions warpgate/EnhancedPlanetGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export interface PlanetData {
moons?: MoonData[];
logoTexturePath?: string;
initialAngle?: number;
isBinary?: boolean;
binaryOffset?: number;
binarySpeed?: number;
}

interface ExplosionData {
Expand All @@ -68,7 +71,8 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
description: 'explore()',
orbitRadius: 2.33,
orbitSpeed: 0.775,
planetColor: '#B7D3F2',
startAngle: 0,
planetColor: '#C3F6EE',
size: 0.29,
rotationSpeed: 0.02,
moons: [
Expand All @@ -83,14 +87,31 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
],
logoTexturePath: '/textures/Fretboardx_logo.png',
},
// PLANET 1.5: Spotify
{
position: [0, 0, 0],
link: 'https://open.spotify.com/user/1268486981',
label: 'Spotify',
description: 'getPlaylists()',
orbitRadius: 2.33,
orbitSpeed: 0.775,
startAngle: (Math.PI),
planetColor: '#F9B9F2',
rings: [
{ color: 'white', innerScale: 1.2, outerScale: 1.5, inclination: Math.PI / 2 },
],
size: 0.225,
rotationSpeed: 0.02,
logoTexturePath: '/textures/Spotify_logo.svg',
},
// PLANET 2: LINKEDIN
{
position: [0, 0, 0],
link: 'https://www.linkedin.com/in/ridwansharkar',
label: 'LinkedIn',
description: 'connect()',
orbitRadius: 3.6,
orbitSpeed: 0.4,
orbitRadius: 3.9,
orbitSpeed: 0.45,
planetColor: '#4FB8FF',
size: 0.37,
rotationSpeed: 0.01,
Expand All @@ -99,13 +120,53 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
],
logoTexturePath: '/textures/LinkedIn_logo.svg',
},
// PLANET 3,25: BORROWED ORDER BINARY SYSTEM
{
position: [0, 0, 0],
link: 'https://ridwansharkar.github.io/Borrowed-Order/',
label: 'Borrowed Order',
description: 'visualize()',
orbitRadius: 6,
orbitSpeed: 0.125,
startAngle: (Math.PI),
planetColor: '#C89FD9',
size: 0.27,
rotationSpeed: 0.05,
rings: [
{ color: '#00FFFF', innerScale: 1.3, outerScale: 1.45, inclination: -Math.PI / 3 }
],
logoTexturePath: '/textures/BorrowedOrder_logo.svg',
isBinary: true,
binaryOffset: 0.5,
binarySpeed: 2.0,
},
// PLANET 3.5: Nutrimancer BINARY
{
position: [0, 0, 0],
link: 'https://github.com/RidwanSharkar/The-Nutrimancers-Codex',
label: "The Nutrimancer's Codex - Vol. II",
description: 'unknown()',
orbitRadius: 6,
orbitSpeed: 0.125,
startAngle: (Math.PI),
planetColor: '#84DCC6',
rings: [
{ color: '#7EE081', innerScale: 1.25, outerScale: 1.6, inclination: Math.PI / 4.5 },
],
size: 0.3,
rotationSpeed: 0.01,
logoTexturePath: '/textures/Nutrimancer_logo.svg',
isBinary: true,
binaryOffset: -0.5,
binarySpeed: 2.0,
},
// PLANET 3: GITHUB
{
position: [0, 0, 0],
link: 'https://github.com/RidwanSharkar',
label: 'GitHub',
description: 'collaborate()',
orbitRadius: 6.3,
orbitRadius: 6,
orbitSpeed: 0.125,
startAngle: 0,
planetColor: '#8980F5',
Expand All @@ -117,49 +178,33 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
rotationSpeed: 0.010,
moons: [
{
orbitRadius: 1.05,
orbitRadius: 1.12,
orbitSpeed: 2.25,
size: 0.11,
moonColor: '#F9B9F2',
moonColor: '#D9C6E8',
link: 'https://github.com/RidwanSharkar/Predictive-Analysis-of-MMA-Fights',
label: 'Predictive Analysis',
},
{
orbitRadius: 1.35,
orbitRadius: 1.43,
orbitSpeed: 1.5,
size: 0.1625,
moonColor: '#FFAAEE',
moonColor: '#F9B9F2',
link: 'https://github.com/RidwanSharkar/Pharmacological-Compound-Classifier',
label: 'Compound Classifier',
},
{
orbitRadius: 1.67,
orbitRadius: 1.76,
orbitSpeed: 2.2,
size: 0.13,
moonColor: '#D295BF',
size: 0.12,
moonColor: '#4FB8FF',
link: 'https://github.com/RidwanSharkar/Arbitrage-Better',
label: 'MMA Arbitrager',
},
],
logoTexturePath: '/textures/Github_logo.svg',
},
// PLANET 3.5: Nutrimancer
{
position: [0, 0, 0], // Starting on the opposite side of the orbit
link: 'https://github.com/RidwanSharkar/The-Nutrimancers-Codex',
label: "The Nutrimancer's Codex - Vol. II",
description: 'unknown()',
orbitRadius: 6.3,
orbitSpeed: 0.125,
startAngle: Math.PI,
planetColor: '#84DCC6', //85FFC7
rings: [
{ color: '#7EE081', innerScale: 1.25, outerScale: 1.6, inclination: Math.PI / 4.5 },
],
size: 0.325,
rotationSpeed: 0.01,
logoTexturePath: '/textures/Nutrimancer_logo.svg',
},

// PLANET 4: IG ART STATION
{
position: [0, 0, 0],
Expand Down Expand Up @@ -212,22 +257,7 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
],
logoTexturePath: '/textures/Mythos_logo.png',
},
// PLANET 6: Spotify
{
position: [0, 0, 0],
link: 'https://open.spotify.com/user/1268486981',
label: 'Spotify',
description: 'getPlaylists()',
orbitRadius: 4.7,
orbitSpeed: 0.47,
planetColor: '#F9B9F2',
rings: [
{ color: 'white', innerScale: 1.2, outerScale: 1.5, inclination: Math.PI / 2 },
],
size: 0.225,
rotationSpeed: 0.02,
logoTexturePath: '/textures/Spotify_logo.svg',
},

], []);

// Initialize refs for each planet
Expand Down Expand Up @@ -286,7 +316,7 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
useEffect(() => {
const interval = setInterval(() => {
setExoplanets(prev => [...prev, Date.now()]); // timestamp as unique ID
}, 15000); // 30000 ms = 30 seconds
}, 7500);

return () => clearInterval(interval);
}, []);
Expand All @@ -296,6 +326,11 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
setExoplanets(prev => prev.filter(exoId => exoId !== id));
};

const uniqueOrbitRadii = useMemo(() => {
const radii = planets.map(planet => planet.orbitRadius);
return Array.from(new Set(radii));
}, [planets]);

return (
<Suspense fallback={null}>
<Sun />
Expand All @@ -305,17 +340,23 @@ const EnhancedPlanetGroup: React.FC<EnhancedPlanetGroupProps> = ({ onSelectPlane
planetSizes={getPlanetSizes()}
onCollision={handleCollision}
/>
{/* Render orbit paths */}
{planets.map((planet, index) => (

{/* Render unique orbit paths */}
{uniqueOrbitRadii.map((orbitRadius, index) => (
<mesh key={`orbit-${index}`} rotation-x={Math.PI / 2}>
<ringGeometry
args={[
planet.orbitRadius,
planet.orbitRadius + 0.05,
orbitRadius,
orbitRadius + 0.05,
64,
]}
/>
<meshBasicMaterial color="#ffffff" opacity={0.08} transparent side={THREE.DoubleSide}/>
<meshBasicMaterial
color="#ffffff"
opacity={0.08}
transparent
side={THREE.DoubleSide}
/>
</mesh>
))}

Expand Down
Loading

0 comments on commit 998933b

Please sign in to comment.