Skip to content

Commit

Permalink
local 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 94d7c4d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions warpgate/Exoplanet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ const Exoplanet: React.FC<ExoplanetProps> = ({ onRemove }) => {
const meshRef = useRef<Mesh>(null);
const velocityRef = useRef<Vector3>();

// Random size between 0.14 and 0.20
const size = 0.15 + Math.random() * (0.20 - 0.14);
// SIZE RANGE
const size = 0.15 + Math.random() * (0.20 - 0.16);
const colors = useMemo(() => ['#00ffff', '#ff00ff', '#FF7F11', '#ff3366', '#66ff33', '#B8B3E9', '#B8B3E9', '#F87666', '6EFAFB', 'BEEE62', 'CD9FCC', '93FF96', 'B2FFA8' ], []);
const color = useMemo(() => colors[Math.floor(Math.random() * colors.length)], [colors]);

// Constants for simulation
const SPAWN_RADIUS = 50;
const HYPERBOLIC_THRESHOLD = 40; // GRAVITY INFLUENCE
const MIN_DISTANCE = 2;
const BASE_GRAVITY_STRENGTH = 0.15; // GRAVITY STRENGTH
const BASE_GRAVITY_STRENGTH = 0.10; // GRAVITY STRENGTH
const CLOSE_APPROACH_THRESHOLD = 8; // APPROACH THRESHOLD

const targetPoint = useMemo(() => {
const radius = Math.random() * 8; // COLLISION ZONE
const radius = Math.random() * 7; // COLLISION ZONE
const theta = Math.random() * 2 * Math.PI;
const phi = Math.acos(2 * Math.random() - 1);
return new Vector3(
Expand Down Expand Up @@ -53,7 +53,7 @@ const Exoplanet: React.FC<ExoplanetProps> = ({ onRemove }) => {

// Velocity vector towards the solar system with variation
useEffect(() => {
const speed = Math.random() * 0.4 + 0.04;
const speed = Math.random() * 0.4 + 0.03;
const direction = targetPoint.clone().sub(initialPosition).normalize();

// Inclination variation ±5° to ±3°
Expand Down Expand Up @@ -102,7 +102,7 @@ const Exoplanet: React.FC<ExoplanetProps> = ({ onRemove }) => {
setShowExplosion(true);
setTimeout(() => {
onRemove();
}, 1500); // 1.5 seconds matching explosion duration
}, 2000); // 1.5 seconds matching explosion duration
return;
}

Expand Down Expand Up @@ -145,9 +145,9 @@ const Exoplanet: React.FC<ExoplanetProps> = ({ onRemove }) => {
<Explosion
position={collisionPoint}
color={color}
size={size * 2}
duration={1.5}
particleCount={30}
size={size * 4}
duration={2}
particleCount={120}
/>
)}
</group>
Expand Down

0 comments on commit 94d7c4d

Please sign in to comment.