331 lines
7.3 KiB
JavaScript
331 lines
7.3 KiB
JavaScript
// constants.js - Global constants and configuration
|
|
|
|
// Scene configuration
|
|
export const CONFIG = {
|
|
defaultCameraZ: 300,
|
|
minZoom: 0.5,
|
|
maxZoom: 5.0,
|
|
earthRadius: 100,
|
|
rotationSpeed: 0.0005,
|
|
dragRotationFactorBase: 0.005,
|
|
dragRotationScaleMin: 0.28,
|
|
dragRotationScaleMax: 2.0,
|
|
};
|
|
|
|
export const HUD_CONFIG = {
|
|
scaleReferenceWidth: 1920,
|
|
scaleReferenceHeight: 1080,
|
|
minScale: 0.7,
|
|
maxScale: 1,
|
|
brandLanguage: "zh",
|
|
};
|
|
|
|
// Earth coordinate constants
|
|
export const EARTH_CONFIG = {
|
|
tilt: 23.5, // earth tilt angle (degrees)
|
|
tiltRad: 23.5 * Math.PI / 180, // earth tilt angle (radians)
|
|
|
|
// hangzhou coordinates
|
|
chinaLat: 30.2741,
|
|
chinaLon: 120.1552,
|
|
chinaRotLon: 120.1552 - 270, // for rotation calculation (chinaLon - 270)
|
|
|
|
// view reset coefficient
|
|
latCoefficient: 0.5
|
|
};
|
|
|
|
export const CELESTIAL_CONFIG = {
|
|
enabled: true,
|
|
updateIntervalMs: 10_000,
|
|
skyRadius: 2600,
|
|
skyOpacity: 1,
|
|
starMapUrl: "./assets/celestial/starmap_equatorial_4k.jpg",
|
|
brightStarsUrl: "./assets/celestial/bright-stars.json",
|
|
orientationEulerRad: {
|
|
x: 0.46,
|
|
y: 1.18,
|
|
z: -0.08,
|
|
},
|
|
followEarthRotation: {
|
|
enabled: true,
|
|
x: true,
|
|
y: true,
|
|
z: false,
|
|
invertX: true,
|
|
invertY: false,
|
|
invertZ: false,
|
|
},
|
|
sunDistance: 2150,
|
|
moonDistance: 2050,
|
|
sunScale: 78,
|
|
moonScale: 38,
|
|
sunHaloScale: 136,
|
|
moonHaloScale: 62,
|
|
brightStarDistance: 2350,
|
|
brightStarMinMag: 2.1,
|
|
brightStarMaxCount: 36,
|
|
brightStarMinScale: 2.4,
|
|
brightStarMaxScale: 6.8,
|
|
brightStarOpacity: 0.88,
|
|
sunLightDistance: 460,
|
|
sunLightIntensity: 1.02,
|
|
sunLightColor: 0xfff4df,
|
|
backLightIntensity: 0.3,
|
|
backLightColor: 0x2b4c78,
|
|
};
|
|
|
|
export const TERRAIN_CONFIG = {
|
|
enabled: true,
|
|
tileSize: 256,
|
|
baseZoom: 4,
|
|
geometryWidthSegments: 320,
|
|
geometryHeightSegments: 320,
|
|
baseRadiusOffset: 0.04,
|
|
exaggeration: 34,
|
|
landRevealFadeMeters: 220,
|
|
maxConcurrentRequests: 10,
|
|
opacity: 0.62,
|
|
color: 0x7f9d7f,
|
|
emissive: 0x061008,
|
|
specular: 0x233126,
|
|
shininess: 10,
|
|
urlTemplate:
|
|
"/api/v1/visualization/terrain/terrarium/{z}/{x}/{y}.png",
|
|
};
|
|
|
|
export const PATHS = {
|
|
cablesApi: '/api/v1/visualization/geo/cables',
|
|
landingPointsApi: '/api/v1/visualization/geo/landing-points',
|
|
bgpApi: '/api/v1/visualization/geo/bgp-anomalies',
|
|
bgpIncidentsApi: '/api/v1/visualization/geo/bgp-incidents',
|
|
bgpCollectorsApi: '/api/v1/visualization/geo/bgp-collectors',
|
|
};
|
|
|
|
// Cable colors mapping
|
|
export const CABLE_COLORS = {
|
|
'Americas II': 0xff4444,
|
|
'AU Aleutian A': 0x44ff44,
|
|
'AU Aleutian B': 0x4444ff,
|
|
'default': 0xffff44
|
|
};
|
|
|
|
export const CABLE_CONFIG = {
|
|
lockedOpacityMin: 0.2,
|
|
lockedOpacityMax: 1.0,
|
|
otherOpacity: 0.5,
|
|
otherBrightness: 0.6,
|
|
pulseSpeed: 0.008,
|
|
pulseCoefficient: 0.4,
|
|
line: {
|
|
altitudeOffset: 0.2,
|
|
greatCircleSegments: 50,
|
|
nearPointThreshold: 0.01,
|
|
lineWidth: 1,
|
|
opacity: 1.0,
|
|
renderOrder: 1,
|
|
},
|
|
landingPoint: {
|
|
altitudeOffset: 0.1,
|
|
radius: 0.4,
|
|
widthSegments: 16,
|
|
heightSegments: 16,
|
|
baseScale: 2.5,
|
|
color: 0xffaa00,
|
|
emissive: 0x442200,
|
|
emissiveIntensity: 0.5,
|
|
opacity: 1.0,
|
|
},
|
|
landingPointSizeStabilization: {
|
|
enabled: true,
|
|
referenceFov: 75,
|
|
min: 0.12,
|
|
max: 3.0,
|
|
},
|
|
landingPointVisual: {
|
|
pulseSpeed: 0.003,
|
|
dimBrightness: 0.3,
|
|
related: {
|
|
emissiveIntensityBase: 0.5,
|
|
emissiveIntensityPulse: 0.5,
|
|
opacityBase: 0.8,
|
|
opacityPulse: 0.2,
|
|
scaleBase: 1.2,
|
|
scalePulse: 0.3,
|
|
},
|
|
dimmed: {
|
|
colorRGB: { r: 255, g: 170, b: 0 },
|
|
emissive: 0x000000,
|
|
emissiveIntensity: 0,
|
|
opacity: 0.3,
|
|
},
|
|
},
|
|
};
|
|
|
|
export const CABLE_STATE = {
|
|
NORMAL: 'normal',
|
|
HOVERED: 'hovered',
|
|
LOCKED: 'locked'
|
|
};
|
|
|
|
export const SATELLITE_CONFIG = {
|
|
maxCount: -1,
|
|
trailLength: 10,
|
|
dotSize: 4,
|
|
ringSize: 0.07,
|
|
apiPath: '/api/v1/visualization/geo/satellites',
|
|
breathingSpeed: 0.08,
|
|
breathingScaleAmplitude: 0.15,
|
|
breathingOpacityMin: 0.5,
|
|
breathingOpacityMax: 0.8,
|
|
dotBreathingSpeed: 0.12,
|
|
dotBreathingScaleAmplitude: 0.2,
|
|
dotOpacityMin: 0.7,
|
|
dotOpacityMax: 1.0
|
|
};
|
|
|
|
export const BGP_CONFIG = {
|
|
defaultFetchLimit: 200,
|
|
maxRenderedMarkers: 200,
|
|
altitudeOffset: 2.1,
|
|
collectorAltitudeOffset: 1.6,
|
|
marker: {
|
|
eventBaseScale: 6.2,
|
|
collectorBaseScale: 7.4,
|
|
hoverScale: 1.16,
|
|
dimmedScale: 0.92,
|
|
collectorStatusCoreBaseScale: 0.12,
|
|
collectorStatusCoreMinScale: 1.2,
|
|
},
|
|
pulse: {
|
|
eventSpeed: 0.0045,
|
|
collectorSpeed: 0.0024,
|
|
normalAmplitude: 0.03,
|
|
lockedAmplitude: 0.16,
|
|
},
|
|
regionScale: 11.5,
|
|
opacity: {
|
|
normal: 0.78,
|
|
hover: 1.0,
|
|
dimmed: 0.24,
|
|
collector: 0.62,
|
|
collectorHover: 0.9,
|
|
lockedMin: 0.65,
|
|
lockedMax: 1.0
|
|
},
|
|
severityColors: {
|
|
critical: 0xff4d4f,
|
|
high: 0xff9f43,
|
|
medium: 0xffd166,
|
|
low: 0x4dabf7
|
|
},
|
|
severityScales: {
|
|
critical: 1.18,
|
|
high: 1.08,
|
|
medium: 1.0,
|
|
low: 0.94
|
|
},
|
|
collectorColor: 0x6db7ff,
|
|
collectorHeatColors: {
|
|
idle: 0x6db7ff,
|
|
low: 0x60a5fa,
|
|
medium: 0xfbbf24,
|
|
high: 0xfb923c,
|
|
hot: 0xff5f57
|
|
},
|
|
collectorIcon: {
|
|
ringStroke: "rgba(111, 160, 197, 0.34)",
|
|
ringLineWidth: 1.2,
|
|
ringRadius: 22,
|
|
pathStroke: "rgba(64, 106, 136, 0.74)",
|
|
pathLineWidth: 0.9,
|
|
pathFill: "rgba(214,224,233,0.88)",
|
|
centerFill: "rgba(222,231,239,0.72)",
|
|
centerRadius: 0.85,
|
|
idleBaseColor: 0xb7c4cf,
|
|
idleBlend: 0.56,
|
|
idleOpacity: 0.74,
|
|
hoverBlend: 0.42,
|
|
hoverNeutralColor: 0xc8d5e0,
|
|
lockedBlend: 0.48,
|
|
lockedNeutralColor: 0xd8e4ed,
|
|
dimmedColor: 0x7d8ca3,
|
|
},
|
|
regionColor: 0x2dd4bf,
|
|
ring: {
|
|
scaleA: 2.5,
|
|
scaleB: 3.4,
|
|
opacity: 0.5,
|
|
speed: 0.001,
|
|
},
|
|
halo: {
|
|
collectorScale: 11.5,
|
|
collectorPulseScale: 16.5,
|
|
collectorCoverageScale: 22.5,
|
|
},
|
|
sizeStabilization: {
|
|
enabled: true,
|
|
collectorMin: 0.12,
|
|
collectorMax: 3.0,
|
|
eventMin: 0.12,
|
|
eventMax: 3.0,
|
|
},
|
|
};
|
|
|
|
export const PREDICTED_ORBIT_CONFIG = {
|
|
sampleInterval: 10,
|
|
opacity: 0.8
|
|
};
|
|
|
|
export const GRID_CONFIG = {
|
|
latitudeStep: 10,
|
|
longitudeStep: 30,
|
|
gridStep: 5
|
|
};
|
|
|
|
export const EARTH_MATERIAL_CONFIG = {
|
|
// Diffuse color multiplies with texture — pure white = full saturation,
|
|
// slightly grey-blue pulls perceived saturation down without a custom shader.
|
|
color: 0xcdd8e6,
|
|
specular: 0x1a2d45,
|
|
shininess: 12,
|
|
emissive: 0x050a12,
|
|
opacity: 0.96,
|
|
|
|
// Depth-mask occluder keeps far-side objects hidden behind the earth
|
|
occluderRadiusFactor: 0.999,
|
|
occluderSegments: 48,
|
|
|
|
// Fresnel atmosphere glow — inner rim
|
|
atmosInnerRadiusFactor: 1.01,
|
|
atmosInnerSegments: 64,
|
|
atmosInnerColor: [0.25, 0.62, 1.0],
|
|
atmosInnerRimPower: 3.2,
|
|
atmosInnerIntensity: 0.18,
|
|
|
|
// Fresnel atmosphere glow — outer corona
|
|
atmosOuterRadiusFactor: 1.016,
|
|
atmosOuterSegments: 48,
|
|
atmosOuterColor: [0.18, 0.45, 0.9],
|
|
atmosOuterRimPower: 5.0,
|
|
atmosOuterIntensity: 0.02,
|
|
|
|
// Texture candidates — tried in order, first success wins
|
|
textureUrls: [
|
|
'./assets/8k_earth_daymap.jpg',
|
|
'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_atmos_2048.jpg',
|
|
'https://threejs.org/examples/textures/planets/earth_atmos_2048.jpg',
|
|
],
|
|
|
|
dayNight: {
|
|
enabled: true,
|
|
sunDirection: { x: 1, y: 0.2, z: 0.4 },
|
|
nightFloor: 0.32,
|
|
dayBoost: 0.94,
|
|
twilightWidth: 0.24,
|
|
twilightIntensity: 0.14,
|
|
twilightColor: 0x4ea0ff,
|
|
nightTintColor: 0x0b1830,
|
|
nightTintIntensity: 0.05,
|
|
},
|
|
};
|