main
mula.liu 2025-12-02 12:58:00 +08:00
parent 667538e5fe
commit 8817389cab
2 changed files with 65 additions and 3 deletions

View File

@ -2,7 +2,8 @@
* CelestialBody component - renders a planet or probe with textures
*/
import { useRef, useMemo, useState, useEffect } from 'react';
import { Mesh, DoubleSide } from 'three';
import { Mesh, DoubleSide } from 'three'; // Removed AdditiveBlending here
import * as THREE from 'three'; // Imported as * to access AdditiveBlending, SpriteMaterial, CanvasTexture
import { useFrame } from '@react-three/fiber';
import { useTexture, Html } from '@react-three/drei';
import type { CelestialBody as CelestialBodyType } from '../types';
@ -139,6 +140,52 @@ function Planet({ body, size, emissive, emissiveIntensity, allBodies, isSelected
/>;
}
// Comet Particles Component
function CometParticles({ radius, count = 6, color = '#88ccff' }: { radius: number; count?: number; color?: string }) {
const positions = useMemo(() => {
const p = new Float32Array(count * 3);
for (let i = 0; i < count; i++) {
// Random spherical distribution
const r = radius * (1.2 + Math.random() * 2.0); // Spread: 1.2x to 3.2x radius
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
p[i * 3] = r * Math.sin(phi) * Math.cos(theta);
p[i * 3 + 1] = r * Math.sin(phi) * Math.sin(theta);
p[i * 3 + 2] = r * Math.cos(phi);
}
return p;
}, [radius, count]);
// Ref for animation
const pointsRef = useRef<THREE.Points>(null);
useFrame((_, delta) => {
if (pointsRef.current) {
// Subtle rotation
pointsRef.current.rotation.y += delta * 0.1;
pointsRef.current.rotation.z += delta * 0.05;
}
});
return (
<points ref={pointsRef}>
<bufferGeometry>
<bufferAttribute attach="position" args={[positions, 3]} />
</bufferGeometry>
<pointsMaterial
size={radius * 0.4} // Particle size relative to comet size
color={color}
transparent
opacity={0.6}
sizeAttenuation={true}
blending={THREE.AdditiveBlending}
depthWrite={false}
/>
</points>
);
}
// Separate component to handle texture loading
function PlanetMesh({ body, size, emissive, emissiveIntensity, scaledPos, texturePath, position, meshRef, hasOffset, allBodies, isSelected = false }: {
body: CelestialBodyType;
@ -199,6 +246,11 @@ function PlanetMesh({ body, size, emissive, emissiveIntensity, scaledPos, textur
{/* Saturn Rings */}
{body.id === '699' && <SaturnRings />}
{/* Comet Particles */}
{body.type === 'comet' && (
<CometParticles radius={size} count={6} />
)}
{/* Sun glow effect */}
{body.type === 'star' && (
<>
@ -216,7 +268,7 @@ function PlanetMesh({ body, size, emissive, emissiveIntensity, scaledPos, textur
center
distanceFactor={10}
style={{
color: body.type === 'star' ? '#FDB813' : '#ffffff',
color: body.type === 'star' ? '#FDB813' : (body.type === 'comet' ? '#88ccff' : '#ffffff'),
fontSize: '9px', // 从 11px 减小到 9px
fontWeight: 'bold',
textShadow: '0 0 4px rgba(0,0,0,0.8)',
@ -265,6 +317,15 @@ export function CelestialBody({ body, allBodies, isSelected = false }: Celestial
};
}
// Comet - bright core with glow
if (body.type === 'comet') {
return {
size: getCelestialSize(body.name, body.type),
emissive: '#000000', // Revert to no special emissive color for texture
emissiveIntensity: 0, // Revert to no special emissive intensity
};
}
// Satellite (natural moons) - small size with slight glow for visibility
if (body.type === 'satellite') {
return {

View File

@ -2,7 +2,8 @@
* User Management Page
*/
import { useState, useEffect } from 'react';
import { Modal, Button, Popconfirm } from 'antd';
import { Button, Popconfirm } from 'antd';
import { ReloadOutlined } from '@ant-design/icons';
import type { ColumnsType } from 'antd/es/table';
import { request } from '../../utils/request';
import { DataTable } from '../../components/admin/DataTable';