|
|
|
@@ -66,8 +66,64 @@ const SATELLITE_CONSTELLATION_LABELS = Object.freeze({
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const TRAIL_LENGTH = SATELLITE_CONFIG.trailLength;
|
|
|
|
|
|
|
|
|
|
const TRAIL_RIBBON_VERTEX_SHADER = /* glsl */ `
|
|
|
|
|
attribute vec3 instanceStart;
|
|
|
|
|
attribute vec3 instanceEnd;
|
|
|
|
|
attribute vec3 instanceColorStart;
|
|
|
|
|
attribute vec3 instanceColorEnd;
|
|
|
|
|
uniform vec2 resolution;
|
|
|
|
|
uniform float lineWidth;
|
|
|
|
|
varying vec3 vColor;
|
|
|
|
|
void main() {
|
|
|
|
|
float t = position.x;
|
|
|
|
|
float side = position.y;
|
|
|
|
|
|
|
|
|
|
vec4 clipStart = projectionMatrix * modelViewMatrix * vec4(instanceStart, 1.0);
|
|
|
|
|
vec4 clipEnd = projectionMatrix * modelViewMatrix * vec4(instanceEnd, 1.0);
|
|
|
|
|
|
|
|
|
|
vec2 screenStart = (clipStart.xy / clipStart.w * 0.5 + 0.5) * resolution;
|
|
|
|
|
vec2 screenEnd = (clipEnd.xy / clipEnd.w * 0.5 + 0.5) * resolution;
|
|
|
|
|
vec2 dir = screenEnd - screenStart;
|
|
|
|
|
float segLen = length(dir);
|
|
|
|
|
|
|
|
|
|
vec4 clipPos = mix(clipStart, clipEnd, t);
|
|
|
|
|
|
|
|
|
|
if (segLen > 0.001) {
|
|
|
|
|
dir /= segLen;
|
|
|
|
|
vec2 normal = vec2(-dir.y, dir.x);
|
|
|
|
|
clipPos.xy += normal * side * lineWidth * 0.5 / resolution * 2.0 * clipPos.w;
|
|
|
|
|
vColor = mix(instanceColorStart, instanceColorEnd, t);
|
|
|
|
|
} else {
|
|
|
|
|
vColor = vec3(0.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gl_Position = clipPos;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const TRAIL_RIBBON_FRAGMENT_SHADER = /* glsl */ `
|
|
|
|
|
varying vec3 vColor;
|
|
|
|
|
void main() {
|
|
|
|
|
gl_FragColor = vec4(vColor, 1.0);
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const TRAIL_INSTANCE_ATTRIBUTE_NAMES = [
|
|
|
|
|
"instanceStart",
|
|
|
|
|
"instanceEnd",
|
|
|
|
|
"instanceColorStart",
|
|
|
|
|
"instanceColorEnd",
|
|
|
|
|
];
|
|
|
|
|
const FALLBACK_ORBIT_DAY_MS = 24 * 60 * 60 * 1000;
|
|
|
|
|
const FALLBACK_MIN_MEAN_MOTION = 12;
|
|
|
|
|
const FALLBACK_MEAN_MOTION_SPREAD = 4;
|
|
|
|
|
const FALLBACK_TRAIL_TIP_LENGTH = 0.004;
|
|
|
|
|
const FALLBACK_TRAIL_ALPHA_START = 0.2;
|
|
|
|
|
const FALLBACK_TRAIL_ALPHA_END = 0.8;
|
|
|
|
|
const DOT_TEXTURE_SIZE = 32;
|
|
|
|
|
const POSITION_UPDATE_INTERVAL_MS = 250;
|
|
|
|
|
const BACKGROUND_TRAIL_RESET_DELTA_MS = 2000;
|
|
|
|
|
const DIMMED_SATELLITE_BRIGHTNESS = 0.42;
|
|
|
|
|
const DIMMED_SATELLITE_TRAIL_BRIGHTNESS = 0.24;
|
|
|
|
|
const DIMMED_SATELLITE_POINT_OPACITY = 0.62;
|
|
|
|
@@ -81,8 +137,10 @@ const LOCKED_HALO_CORE_PIXEL_RADIUS = 8;
|
|
|
|
|
const LOCKED_HALO_PIXEL_RADIUS = 24;
|
|
|
|
|
const FILLED_TEXTURE_RADIUS_RATIO = 0.28;
|
|
|
|
|
const LOCKED_RING_IDLE_SCALE = 0.68;
|
|
|
|
|
const LOCKED_RING_HOVER_SCALE = 1.32;
|
|
|
|
|
const LOCKED_RING_HOVER_LINE_WIDTH = 5;
|
|
|
|
|
const HOVER_RING_LINE_WIDTH = 3;
|
|
|
|
|
const LOCKED_RING_IDLE_OPACITY = 0.92;
|
|
|
|
|
const DOT_ZOOM_SCALE_POWER = 1;
|
|
|
|
|
const EARTH_RADIUS_KM = 6378.137;
|
|
|
|
|
const GROUND_FOOTPRINT_MIN_ELEVATION_DEG = 25;
|
|
|
|
|
const GROUND_FOOTPRINT_RADIUS_OFFSET = 0.72;
|
|
|
|
@@ -112,6 +170,71 @@ const satelliteSunDirection = new THREE.Vector3(1, 0.2, 0.4).normalize();
|
|
|
|
|
|
|
|
|
|
export let breathingPhase = 0;
|
|
|
|
|
|
|
|
|
|
function getPointPixelRatio() {
|
|
|
|
|
return typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSatelliteDotBaseSize() {
|
|
|
|
|
return SATELLITE_CONFIG.dotBaseSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSatelliteDotBackdropSize() {
|
|
|
|
|
return getSatelliteDotBaseSize() * SATELLITE_CONFIG.dotBackdropScale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSatelliteDotZoomScale(cameraDistance) {
|
|
|
|
|
return Math.pow(CONFIG.defaultCameraZ / Math.max(cameraDistance, 1), SATELLITE_CONFIG.dotZoomScalePower);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createSatellitePointMaterial({
|
|
|
|
|
texture,
|
|
|
|
|
size,
|
|
|
|
|
opacity = 1,
|
|
|
|
|
useVertexColor = true,
|
|
|
|
|
baseColor = 0xffffff,
|
|
|
|
|
alphaTest = 0.04,
|
|
|
|
|
}) {
|
|
|
|
|
return new THREE.ShaderMaterial({
|
|
|
|
|
uniforms: {
|
|
|
|
|
pointTexture: { value: texture },
|
|
|
|
|
size: { value: size * getPointPixelRatio() },
|
|
|
|
|
opacity: { value: opacity },
|
|
|
|
|
baseColor: { value: new THREE.Color(baseColor) },
|
|
|
|
|
},
|
|
|
|
|
transparent: true,
|
|
|
|
|
depthTest: true,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
vertexShader: `
|
|
|
|
|
uniform float size;
|
|
|
|
|
uniform vec3 baseColor;
|
|
|
|
|
attribute float alpha;
|
|
|
|
|
${useVertexColor ? "attribute vec3 color;" : ""}
|
|
|
|
|
varying float vAlpha;
|
|
|
|
|
varying vec3 vColor;
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
vAlpha = alpha;
|
|
|
|
|
vColor = ${useVertexColor ? "color" : "baseColor"};
|
|
|
|
|
gl_PointSize = size;
|
|
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
fragmentShader: `
|
|
|
|
|
uniform sampler2D pointTexture;
|
|
|
|
|
uniform float opacity;
|
|
|
|
|
varying float vAlpha;
|
|
|
|
|
varying vec3 vColor;
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
vec4 texel = texture2D(pointTexture, gl_PointCoord);
|
|
|
|
|
float alphaValue = texel.a * opacity * vAlpha;
|
|
|
|
|
if (alphaValue < ${alphaTest.toFixed(3)}) discard;
|
|
|
|
|
gl_FragColor = vec4(vColor * texel.rgb, alphaValue);
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SATELLITE_LEGEND_RULES = [
|
|
|
|
|
{
|
|
|
|
|
key: "equatorial",
|
|
|
|
@@ -197,9 +320,22 @@ export function updateBreathingPhase(deltaTime = 16) {
|
|
|
|
|
export function updateSatellitePointSize() {
|
|
|
|
|
if (!satellitePoints || !cameraRef) return;
|
|
|
|
|
const camDist = cameraRef.position.length();
|
|
|
|
|
const zoomScale = Math.pow(CONFIG.defaultCameraZ / Math.max(camDist, 1), DOT_ZOOM_SCALE_POWER);
|
|
|
|
|
satellitePoints.material.size = SATELLITE_CONFIG.dotSize * zoomScale;
|
|
|
|
|
satelliteBackdropPoints.material.size = SATELLITE_CONFIG.dotSize * 1.28 * zoomScale;
|
|
|
|
|
const zoomScale = getSatelliteDotZoomScale(camDist);
|
|
|
|
|
const pointPixelRatio = getPointPixelRatio();
|
|
|
|
|
const dotSize = getSatelliteDotBaseSize() * zoomScale;
|
|
|
|
|
const backdropSize = getSatelliteDotBackdropSize() * zoomScale;
|
|
|
|
|
const shaderDotSize = dotSize * pointPixelRatio;
|
|
|
|
|
const shaderBackdropSize = backdropSize * pointPixelRatio;
|
|
|
|
|
if (satellitePoints.material.uniforms?.size) {
|
|
|
|
|
satellitePoints.material.uniforms.size.value = shaderDotSize;
|
|
|
|
|
} else {
|
|
|
|
|
satellitePoints.material.size = dotSize;
|
|
|
|
|
}
|
|
|
|
|
if (satelliteBackdropPoints.material.uniforms?.size) {
|
|
|
|
|
satelliteBackdropPoints.material.uniforms.size.value = shaderBackdropSize;
|
|
|
|
|
} else {
|
|
|
|
|
satelliteBackdropPoints.material.size = backdropSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getBreathingPulse(phase) {
|
|
|
|
@@ -338,7 +474,7 @@ function createBackdropDotTexture() {
|
|
|
|
|
return texture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createRingTexture(innerRadius, outerRadius, color = "#ffffff") {
|
|
|
|
|
function createRingTexture(innerRadius, outerRadius, color = "#ffffff", lineWidth = 3) {
|
|
|
|
|
const size = DOT_TEXTURE_SIZE * 2;
|
|
|
|
|
const canvas = document.createElement("canvas");
|
|
|
|
|
canvas.width = size;
|
|
|
|
@@ -347,7 +483,7 @@ function createRingTexture(innerRadius, outerRadius, color = "#ffffff") {
|
|
|
|
|
const center = size / 2;
|
|
|
|
|
|
|
|
|
|
ctx.strokeStyle = color;
|
|
|
|
|
ctx.lineWidth = 3;
|
|
|
|
|
ctx.lineWidth = lineWidth;
|
|
|
|
|
ctx.beginPath();
|
|
|
|
|
ctx.arc(center, center, (innerRadius + outerRadius) / 2, 0, Math.PI * 2);
|
|
|
|
|
ctx.stroke();
|
|
|
|
@@ -384,26 +520,21 @@ export function createSatellites(scene, earthObj) {
|
|
|
|
|
const pointsGeometry = new THREE.BufferGeometry();
|
|
|
|
|
const backdropGeometry = new THREE.BufferGeometry();
|
|
|
|
|
|
|
|
|
|
const backdropMaterial = new THREE.PointsMaterial({
|
|
|
|
|
size: SATELLITE_CONFIG.dotSize * 1.28,
|
|
|
|
|
map: backdropTexture,
|
|
|
|
|
color: 0x0b1626,
|
|
|
|
|
transparent: true,
|
|
|
|
|
const backdropMaterial = createSatellitePointMaterial({
|
|
|
|
|
size: getSatelliteDotBackdropSize(),
|
|
|
|
|
texture: backdropTexture,
|
|
|
|
|
useVertexColor: false,
|
|
|
|
|
baseColor: 0x0b1626,
|
|
|
|
|
opacity: 0.42,
|
|
|
|
|
sizeAttenuation: false,
|
|
|
|
|
alphaTest: 0.04,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const pointsMaterial = new THREE.PointsMaterial({
|
|
|
|
|
size: SATELLITE_CONFIG.dotSize,
|
|
|
|
|
map: dotTexture,
|
|
|
|
|
vertexColors: true,
|
|
|
|
|
transparent: true,
|
|
|
|
|
const pointsMaterial = createSatellitePointMaterial({
|
|
|
|
|
size: getSatelliteDotBaseSize(),
|
|
|
|
|
texture: dotTexture,
|
|
|
|
|
useVertexColor: true,
|
|
|
|
|
opacity: 0.9,
|
|
|
|
|
sizeAttenuation: false,
|
|
|
|
|
alphaTest: 0.1,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
satelliteBackdropPoints = new THREE.Points(backdropGeometry, backdropMaterial);
|
|
|
|
@@ -444,16 +575,32 @@ export function createSatellites(scene, earthObj) {
|
|
|
|
|
earthObj.add(satelliteBackdropPoints);
|
|
|
|
|
earthObj.add(satellitePoints);
|
|
|
|
|
|
|
|
|
|
const trailGeometry = new THREE.BufferGeometry();
|
|
|
|
|
// Instanced screen-space ribbon: one quad instance per trail segment.
|
|
|
|
|
// Single mesh / single draw call for all satellite trails.
|
|
|
|
|
const ribbonGeometry = new THREE.InstancedBufferGeometry();
|
|
|
|
|
// Base quad: position.x = t (0=seg-start, 1=seg-end), position.y = side (-1/+1)
|
|
|
|
|
ribbonGeometry.setAttribute(
|
|
|
|
|
"position",
|
|
|
|
|
new THREE.BufferAttribute(new Float32Array([0, -1, 0, 0, 1, 0, 1, -1, 0, 1, 1, 0]), 3),
|
|
|
|
|
);
|
|
|
|
|
ribbonGeometry.setIndex(new THREE.BufferAttribute(new Uint16Array([0, 2, 1, 2, 3, 1]), 1));
|
|
|
|
|
|
|
|
|
|
const trailMaterial = new THREE.LineBasicMaterial({
|
|
|
|
|
vertexColors: true,
|
|
|
|
|
const trailResolution = new THREE.Vector2(window.innerWidth, window.innerHeight);
|
|
|
|
|
const trailMaterial = new THREE.ShaderMaterial({
|
|
|
|
|
uniforms: {
|
|
|
|
|
lineWidth: { value: SATELLITE_CONFIG.trailLineWidth },
|
|
|
|
|
resolution: { value: trailResolution },
|
|
|
|
|
},
|
|
|
|
|
vertexShader: TRAIL_RIBBON_VERTEX_SHADER,
|
|
|
|
|
fragmentShader: TRAIL_RIBBON_FRAGMENT_SHADER,
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.3,
|
|
|
|
|
blending: THREE.AdditiveBlending,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
satelliteTrails = new THREE.LineSegments(trailGeometry, trailMaterial);
|
|
|
|
|
satelliteTrails = new THREE.Mesh(ribbonGeometry, trailMaterial);
|
|
|
|
|
satelliteTrails.onBeforeRender = (renderer) => renderer.getSize(trailResolution);
|
|
|
|
|
satelliteTrails.frustumCulled = false;
|
|
|
|
|
satelliteTrails.visible = false;
|
|
|
|
|
satelliteTrails.userData = { type: "satelliteTrails" };
|
|
|
|
|
earthObj.add(satelliteTrails);
|
|
|
|
@@ -481,6 +628,31 @@ function createSatellitePositionState() {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetSatelliteTrailState() {
|
|
|
|
|
satellitePositions.forEach((position) => {
|
|
|
|
|
position.trail = [];
|
|
|
|
|
position.trailIndex = 0;
|
|
|
|
|
position.trailCount = 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearSatelliteTrailGeometry() {
|
|
|
|
|
if (!satelliteTrails) return;
|
|
|
|
|
|
|
|
|
|
for (const name of TRAIL_INSTANCE_ATTRIBUTE_NAMES) {
|
|
|
|
|
const attr = satelliteTrails.geometry.attributes[name];
|
|
|
|
|
if (attr?.array) {
|
|
|
|
|
attr.array.fill(0);
|
|
|
|
|
attr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearSatelliteTrails() {
|
|
|
|
|
resetSatelliteTrailState();
|
|
|
|
|
clearSatelliteTrailGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ensureSatelliteCapacity(count) {
|
|
|
|
|
if (!satellitePoints || !satelliteBackdropPoints || !satelliteTrails) return;
|
|
|
|
|
|
|
|
|
@@ -492,16 +664,27 @@ function ensureSatelliteCapacity(count) {
|
|
|
|
|
const previousBackdropPositions =
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.position?.array || null;
|
|
|
|
|
const previousColors = satellitePoints.geometry.attributes.color?.array || null;
|
|
|
|
|
const previousTrailPositions =
|
|
|
|
|
satelliteTrails.geometry.attributes.position?.array || null;
|
|
|
|
|
const previousTrailColors =
|
|
|
|
|
satelliteTrails.geometry.attributes.color?.array || null;
|
|
|
|
|
const previousPointAlphas = satellitePoints.geometry.attributes.alpha?.array || null;
|
|
|
|
|
const previousBackdropAlphas =
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.alpha?.array || null;
|
|
|
|
|
const previousInstanceStarts =
|
|
|
|
|
satelliteTrails.geometry.attributes.instanceStart?.array || null;
|
|
|
|
|
const previousInstanceEnds =
|
|
|
|
|
satelliteTrails.geometry.attributes.instanceEnd?.array || null;
|
|
|
|
|
const previousInstanceColorStarts =
|
|
|
|
|
satelliteTrails.geometry.attributes.instanceColorStart?.array || null;
|
|
|
|
|
const previousInstanceColorEnds =
|
|
|
|
|
satelliteTrails.geometry.attributes.instanceColorEnd?.array || null;
|
|
|
|
|
const previousSatellitePositions = satellitePositions;
|
|
|
|
|
const previousCapacity = satelliteCapacity;
|
|
|
|
|
|
|
|
|
|
const positions = new Float32Array(nextCapacity * 3);
|
|
|
|
|
const backdropPositions = new Float32Array(nextCapacity * 3);
|
|
|
|
|
const colors = new Float32Array(nextCapacity * 3);
|
|
|
|
|
const pointAlphas = new Float32Array(nextCapacity);
|
|
|
|
|
const backdropAlphas = new Float32Array(nextCapacity);
|
|
|
|
|
pointAlphas.fill(1);
|
|
|
|
|
backdropAlphas.fill(1);
|
|
|
|
|
if (previousPointPositions) {
|
|
|
|
|
positions.set(
|
|
|
|
|
previousPointPositions.subarray(0, Math.min(previousPointPositions.length, positions.length)),
|
|
|
|
@@ -518,10 +701,27 @@ function ensureSatelliteCapacity(count) {
|
|
|
|
|
if (previousColors) {
|
|
|
|
|
colors.set(previousColors.subarray(0, Math.min(previousColors.length, colors.length)));
|
|
|
|
|
}
|
|
|
|
|
if (previousPointAlphas) {
|
|
|
|
|
pointAlphas.set(
|
|
|
|
|
previousPointAlphas.subarray(0, Math.min(previousPointAlphas.length, pointAlphas.length)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (previousBackdropAlphas) {
|
|
|
|
|
backdropAlphas.set(
|
|
|
|
|
previousBackdropAlphas.subarray(
|
|
|
|
|
0,
|
|
|
|
|
Math.min(previousBackdropAlphas.length, backdropAlphas.length),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
satelliteBackdropPoints.geometry.setAttribute(
|
|
|
|
|
"position",
|
|
|
|
|
new THREE.BufferAttribute(backdropPositions, 3),
|
|
|
|
|
);
|
|
|
|
|
satelliteBackdropPoints.geometry.setAttribute(
|
|
|
|
|
"alpha",
|
|
|
|
|
new THREE.BufferAttribute(backdropAlphas, 1),
|
|
|
|
|
);
|
|
|
|
|
satelliteBackdropPoints.geometry.setDrawRange(
|
|
|
|
|
0,
|
|
|
|
|
Math.min(previousCapacity, nextCapacity),
|
|
|
|
@@ -534,34 +734,54 @@ function ensureSatelliteCapacity(count) {
|
|
|
|
|
"color",
|
|
|
|
|
new THREE.BufferAttribute(colors, 3),
|
|
|
|
|
);
|
|
|
|
|
satellitePoints.geometry.setAttribute(
|
|
|
|
|
"alpha",
|
|
|
|
|
new THREE.BufferAttribute(pointAlphas, 1),
|
|
|
|
|
);
|
|
|
|
|
satellitePoints.geometry.setDrawRange(0, Math.min(previousCapacity, nextCapacity));
|
|
|
|
|
|
|
|
|
|
const trailPositions = new Float32Array(nextCapacity * TRAIL_LENGTH * 3);
|
|
|
|
|
const trailColors = new Float32Array(nextCapacity * TRAIL_LENGTH * 3);
|
|
|
|
|
if (previousTrailPositions) {
|
|
|
|
|
trailPositions.set(
|
|
|
|
|
previousTrailPositions.subarray(
|
|
|
|
|
0,
|
|
|
|
|
Math.min(previousTrailPositions.length, trailPositions.length),
|
|
|
|
|
),
|
|
|
|
|
const segCount = nextCapacity * (TRAIL_LENGTH - 1);
|
|
|
|
|
const instanceStarts = new Float32Array(segCount * 3);
|
|
|
|
|
const instanceEnds = new Float32Array(segCount * 3);
|
|
|
|
|
const instanceColorStarts = new Float32Array(segCount * 3);
|
|
|
|
|
const instanceColorEnds = new Float32Array(segCount * 3);
|
|
|
|
|
if (previousInstanceStarts) {
|
|
|
|
|
instanceStarts.set(
|
|
|
|
|
previousInstanceStarts.subarray(0, Math.min(previousInstanceStarts.length, instanceStarts.length)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (previousTrailColors) {
|
|
|
|
|
trailColors.set(
|
|
|
|
|
previousTrailColors.subarray(
|
|
|
|
|
0,
|
|
|
|
|
Math.min(previousTrailColors.length, trailColors.length),
|
|
|
|
|
),
|
|
|
|
|
if (previousInstanceEnds) {
|
|
|
|
|
instanceEnds.set(
|
|
|
|
|
previousInstanceEnds.subarray(0, Math.min(previousInstanceEnds.length, instanceEnds.length)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (previousInstanceColorStarts) {
|
|
|
|
|
instanceColorStarts.set(
|
|
|
|
|
previousInstanceColorStarts.subarray(0, Math.min(previousInstanceColorStarts.length, instanceColorStarts.length)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (previousInstanceColorEnds) {
|
|
|
|
|
instanceColorEnds.set(
|
|
|
|
|
previousInstanceColorEnds.subarray(0, Math.min(previousInstanceColorEnds.length, instanceColorEnds.length)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
satelliteTrails.geometry.setAttribute(
|
|
|
|
|
"position",
|
|
|
|
|
new THREE.BufferAttribute(trailPositions, 3),
|
|
|
|
|
"instanceStart",
|
|
|
|
|
new THREE.InstancedBufferAttribute(instanceStarts, 3),
|
|
|
|
|
);
|
|
|
|
|
satelliteTrails.geometry.setAttribute(
|
|
|
|
|
"color",
|
|
|
|
|
new THREE.BufferAttribute(trailColors, 3),
|
|
|
|
|
"instanceEnd",
|
|
|
|
|
new THREE.InstancedBufferAttribute(instanceEnds, 3),
|
|
|
|
|
);
|
|
|
|
|
satelliteTrails.geometry.setAttribute(
|
|
|
|
|
"instanceColorStart",
|
|
|
|
|
new THREE.InstancedBufferAttribute(instanceColorStarts, 3),
|
|
|
|
|
);
|
|
|
|
|
satelliteTrails.geometry.setAttribute(
|
|
|
|
|
"instanceColorEnd",
|
|
|
|
|
new THREE.InstancedBufferAttribute(instanceColorEnds, 3),
|
|
|
|
|
);
|
|
|
|
|
satelliteTrails.geometry.instanceCount = segCount;
|
|
|
|
|
|
|
|
|
|
satellitePositions = Array.from({ length: nextCapacity }, (_, index) => {
|
|
|
|
|
const previousState = previousSatellitePositions[index];
|
|
|
|
@@ -579,6 +799,25 @@ function ensureSatelliteCapacity(count) {
|
|
|
|
|
satelliteCapacity = nextCapacity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shouldHideSatellitePoint(index) {
|
|
|
|
|
return index === hoveredSatelliteIndex || index === lockedSatelliteIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateSatellitePointVisibilityAttributes(count = satelliteData.length) {
|
|
|
|
|
const pointAlphaAttr = satellitePoints?.geometry?.attributes?.alpha;
|
|
|
|
|
const backdropAlphaAttr = satelliteBackdropPoints?.geometry?.attributes?.alpha;
|
|
|
|
|
if (!pointAlphaAttr?.array || !backdropAlphaAttr?.array) return;
|
|
|
|
|
|
|
|
|
|
const visibleCount = Math.min(count, pointAlphaAttr.array.length, backdropAlphaAttr.array.length);
|
|
|
|
|
for (let i = 0; i < visibleCount; i++) {
|
|
|
|
|
const alpha = shouldHideSatellitePoint(i) ? 0 : 1;
|
|
|
|
|
pointAlphaAttr.array[i] = alpha;
|
|
|
|
|
backdropAlphaAttr.array[i] = alpha;
|
|
|
|
|
}
|
|
|
|
|
pointAlphaAttr.needsUpdate = true;
|
|
|
|
|
backdropAlphaAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function computeSatellitePosition(satellite, time) {
|
|
|
|
|
try {
|
|
|
|
|
const props = satellite.properties;
|
|
|
|
@@ -752,7 +991,7 @@ function buildTleLinesFromElements(props, fallbackTime) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateFallbackPosition(satellite, index, total) {
|
|
|
|
|
function generateFallbackPosition(satellite, index, total, time = new Date()) {
|
|
|
|
|
const radius = CONFIG.earthRadius + SATELLITE_CONFIG.displayAltitudeOffset;
|
|
|
|
|
|
|
|
|
|
const noradId = satellite.properties?.norad_cat_id || index;
|
|
|
|
@@ -764,9 +1003,21 @@ function generateFallbackPosition(satellite, index, total) {
|
|
|
|
|
.split("")
|
|
|
|
|
.reduce((a, b) => a + b.charCodeAt(0), 0);
|
|
|
|
|
const randomOffset = (hash % 1000) / 1000;
|
|
|
|
|
const rawMeanMotion = Number(satellite.properties?.mean_motion);
|
|
|
|
|
const meanMotion =
|
|
|
|
|
Number.isFinite(rawMeanMotion) && rawMeanMotion > 0
|
|
|
|
|
? rawMeanMotion
|
|
|
|
|
: FALLBACK_MIN_MEAN_MOTION + randomOffset * FALLBACK_MEAN_MOTION_SPREAD;
|
|
|
|
|
|
|
|
|
|
const normalizedIndex = index / total;
|
|
|
|
|
const theta = normalizedIndex * Math.PI * 2 * 10 + (raan * Math.PI) / 180;
|
|
|
|
|
const elapsedDays = Number.isFinite(time?.getTime?.())
|
|
|
|
|
? time.getTime() / FALLBACK_ORBIT_DAY_MS
|
|
|
|
|
: Date.now() / FALLBACK_ORBIT_DAY_MS;
|
|
|
|
|
const fallbackPhase = elapsedDays * meanMotion * Math.PI * 2;
|
|
|
|
|
const theta =
|
|
|
|
|
normalizedIndex * Math.PI * 2 * 10 +
|
|
|
|
|
(raan * Math.PI) / 180 +
|
|
|
|
|
fallbackPhase;
|
|
|
|
|
const phi =
|
|
|
|
|
(inclination * Math.PI) / 180 + ((meanAnomaly * Math.PI) / 180) * 0.1;
|
|
|
|
|
|
|
|
|
@@ -795,6 +1046,7 @@ export async function loadSatellites(options = {}) {
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
satelliteData = data.features || [];
|
|
|
|
|
satelliteSatrecCache = new Map();
|
|
|
|
|
resetSatelliteTrailState();
|
|
|
|
|
ensureSatelliteCapacity(satelliteData.length);
|
|
|
|
|
positionUpdateAccumulator = POSITION_UPDATE_INTERVAL_MS;
|
|
|
|
|
return {
|
|
|
|
@@ -803,31 +1055,49 @@ export async function loadSatellites(options = {}) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function updateSatellitePositions(deltaTime = 0, force = false) {
|
|
|
|
|
export function updateSatellitePositions(deltaTime = 0, force = false, options = {}) {
|
|
|
|
|
if (!satellitePoints || !satelliteBackdropPoints || satelliteData.length === 0) return;
|
|
|
|
|
|
|
|
|
|
const shouldUpdateTrails =
|
|
|
|
|
showSatellites || showTrails || lockedSatelliteIndex !== null;
|
|
|
|
|
positionUpdateAccumulator += deltaTime;
|
|
|
|
|
showSatellites ||
|
|
|
|
|
showTrails ||
|
|
|
|
|
lockedSatelliteIndex !== null;
|
|
|
|
|
const shouldResetTrails =
|
|
|
|
|
options.resetTrails ||
|
|
|
|
|
(!force && deltaTime >= BACKGROUND_TRAIL_RESET_DELTA_MS);
|
|
|
|
|
|
|
|
|
|
if (shouldResetTrails) {
|
|
|
|
|
clearSatelliteTrails();
|
|
|
|
|
positionUpdateAccumulator = POSITION_UPDATE_INTERVAL_MS;
|
|
|
|
|
} else {
|
|
|
|
|
positionUpdateAccumulator += deltaTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!force && positionUpdateAccumulator < POSITION_UPDATE_INTERVAL_MS) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const elapsedMs = Math.max(
|
|
|
|
|
positionUpdateAccumulator,
|
|
|
|
|
POSITION_UPDATE_INTERVAL_MS,
|
|
|
|
|
);
|
|
|
|
|
const elapsedMs = shouldResetTrails
|
|
|
|
|
? 0
|
|
|
|
|
: Math.max(
|
|
|
|
|
positionUpdateAccumulator,
|
|
|
|
|
POSITION_UPDATE_INTERVAL_MS,
|
|
|
|
|
);
|
|
|
|
|
positionUpdateAccumulator = 0;
|
|
|
|
|
|
|
|
|
|
const positions = satellitePoints.geometry.attributes.position.array;
|
|
|
|
|
const backdropPositions =
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.position.array;
|
|
|
|
|
const colors = satellitePoints.geometry.attributes.color.array;
|
|
|
|
|
const trailPositions = satelliteTrails.geometry.attributes.position.array;
|
|
|
|
|
const trailColors = satelliteTrails.geometry.attributes.color.array;
|
|
|
|
|
const pointAlphas = satellitePoints.geometry.attributes.alpha.array;
|
|
|
|
|
const backdropAlphas = satelliteBackdropPoints.geometry.attributes.alpha.array;
|
|
|
|
|
const instanceStarts = satelliteTrails.geometry.attributes.instanceStart.array;
|
|
|
|
|
const instanceEnds = satelliteTrails.geometry.attributes.instanceEnd.array;
|
|
|
|
|
const instanceColorStarts = satelliteTrails.geometry.attributes.instanceColorStart.array;
|
|
|
|
|
const instanceColorEnds = satelliteTrails.geometry.attributes.instanceColorEnd.array;
|
|
|
|
|
const baseTime = new Date(Date.now() + elapsedMs);
|
|
|
|
|
const count = Math.min(satelliteData.length, satelliteCapacity);
|
|
|
|
|
let trailSegmentCount = 0;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
|
const satellite = satelliteData[i];
|
|
|
|
@@ -839,16 +1109,30 @@ export function updateSatellitePositions(deltaTime = 0, force = false) {
|
|
|
|
|
|
|
|
|
|
let pos = computeSatellitePosition(satellite, adjustedTime);
|
|
|
|
|
if (!pos) {
|
|
|
|
|
pos = generateFallbackPosition(satellite, i, count);
|
|
|
|
|
pos = generateFallbackPosition(satellite, i, count, adjustedTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
satellitePositions[i].current.copy(pos);
|
|
|
|
|
|
|
|
|
|
if (shouldUpdateTrails && i !== lockedSatelliteIndex) {
|
|
|
|
|
if (shouldUpdateTrails) {
|
|
|
|
|
const satPos = satellitePositions[i];
|
|
|
|
|
satPos.trail[satPos.trailIndex] = pos.clone();
|
|
|
|
|
satPos.trailIndex = (satPos.trailIndex + 1) % TRAIL_LENGTH;
|
|
|
|
|
if (satPos.trailCount < TRAIL_LENGTH) satPos.trailCount++;
|
|
|
|
|
if (satPos.trailCount === 0 && TRAIL_LENGTH > 1) {
|
|
|
|
|
for (let k = 0; k < TRAIL_LENGTH; k++) {
|
|
|
|
|
const offsetMs = (TRAIL_LENGTH - 1 - k) * POSITION_UPDATE_INTERVAL_MS;
|
|
|
|
|
const pastTime = new Date(adjustedTime.getTime() - offsetMs);
|
|
|
|
|
let pastPos = computeSatellitePosition(satellite, pastTime);
|
|
|
|
|
if (!pastPos) {
|
|
|
|
|
pastPos = generateFallbackPosition(satellite, i, count, pastTime);
|
|
|
|
|
}
|
|
|
|
|
satPos.trail[satPos.trailIndex] = pastPos;
|
|
|
|
|
satPos.trailIndex = (satPos.trailIndex + 1) % TRAIL_LENGTH;
|
|
|
|
|
}
|
|
|
|
|
satPos.trailCount = TRAIL_LENGTH;
|
|
|
|
|
} else {
|
|
|
|
|
satPos.trail[satPos.trailIndex] = pos.clone();
|
|
|
|
|
satPos.trailIndex = (satPos.trailIndex + 1) % TRAIL_LENGTH;
|
|
|
|
|
if (satPos.trailCount < TRAIL_LENGTH) satPos.trailCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
positions[i * 3] = pos.x;
|
|
|
|
@@ -871,34 +1155,64 @@ export function updateSatellitePositions(deltaTime = 0, force = false) {
|
|
|
|
|
colors[i * 3] = r * pointBrightness;
|
|
|
|
|
colors[i * 3 + 1] = g * pointBrightness;
|
|
|
|
|
colors[i * 3 + 2] = b * pointBrightness;
|
|
|
|
|
const pointAlpha = shouldHideSatellitePoint(i) ? 0 : 1;
|
|
|
|
|
pointAlphas[i] = pointAlpha;
|
|
|
|
|
backdropAlphas[i] = pointAlpha;
|
|
|
|
|
|
|
|
|
|
const satPosition = satellitePositions[i];
|
|
|
|
|
for (let j = 0; j < TRAIL_LENGTH; j++) {
|
|
|
|
|
const trailIdx = (i * TRAIL_LENGTH + j) * 3;
|
|
|
|
|
|
|
|
|
|
if (j < satPosition.trailCount) {
|
|
|
|
|
const idx =
|
|
|
|
|
(satPosition.trailIndex - satPosition.trailCount + j + TRAIL_LENGTH) %
|
|
|
|
|
TRAIL_LENGTH;
|
|
|
|
|
const trailPoint = satPosition.trail[idx];
|
|
|
|
|
if (trailPoint) {
|
|
|
|
|
trailPositions[trailIdx] = trailPoint.x;
|
|
|
|
|
trailPositions[trailIdx + 1] = trailPoint.y;
|
|
|
|
|
trailPositions[trailIdx + 2] = trailPoint.z;
|
|
|
|
|
const alpha = (j + 1) / satPosition.trailCount;
|
|
|
|
|
trailColors[trailIdx] = r * alpha * trailBrightness;
|
|
|
|
|
trailColors[trailIdx + 1] = g * alpha * trailBrightness;
|
|
|
|
|
trailColors[trailIdx + 2] = b * alpha * trailBrightness;
|
|
|
|
|
continue;
|
|
|
|
|
const tc = satPosition.trailCount;
|
|
|
|
|
let hasVisibleTrail = false;
|
|
|
|
|
for (let j = 0; j < TRAIL_LENGTH - 1; j++) {
|
|
|
|
|
if (j + 1 < tc) {
|
|
|
|
|
const idxA =
|
|
|
|
|
(satPosition.trailIndex - tc + j + TRAIL_LENGTH) % TRAIL_LENGTH;
|
|
|
|
|
const idxB =
|
|
|
|
|
(satPosition.trailIndex - tc + j + 1 + TRAIL_LENGTH) % TRAIL_LENGTH;
|
|
|
|
|
const ptA = satPosition.trail[idxA];
|
|
|
|
|
const ptB = satPosition.trail[idxB];
|
|
|
|
|
if (ptA && ptB && ptA.distanceToSquared(ptB) > 1e-8) {
|
|
|
|
|
const base = trailSegmentCount * 3;
|
|
|
|
|
instanceStarts[base] = ptA.x;
|
|
|
|
|
instanceStarts[base + 1] = ptA.y;
|
|
|
|
|
instanceStarts[base + 2] = ptA.z;
|
|
|
|
|
instanceEnds[base] = ptB.x;
|
|
|
|
|
instanceEnds[base + 1] = ptB.y;
|
|
|
|
|
instanceEnds[base + 2] = ptB.z;
|
|
|
|
|
const alphaA = (j + 1) / tc;
|
|
|
|
|
const alphaB = (j + 2) / tc;
|
|
|
|
|
instanceColorStarts[base] = r * alphaA * trailBrightness;
|
|
|
|
|
instanceColorStarts[base + 1] = g * alphaA * trailBrightness;
|
|
|
|
|
instanceColorStarts[base + 2] = b * alphaA * trailBrightness;
|
|
|
|
|
instanceColorEnds[base] = r * alphaB * trailBrightness;
|
|
|
|
|
instanceColorEnds[base + 1] = g * alphaB * trailBrightness;
|
|
|
|
|
instanceColorEnds[base + 2] = b * alphaB * trailBrightness;
|
|
|
|
|
hasVisibleTrail = true;
|
|
|
|
|
trailSegmentCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trailPositions[trailIdx] = pos.x;
|
|
|
|
|
trailPositions[trailIdx + 1] = pos.y;
|
|
|
|
|
trailPositions[trailIdx + 2] = pos.z;
|
|
|
|
|
trailColors[trailIdx] = 0;
|
|
|
|
|
trailColors[trailIdx + 1] = 0;
|
|
|
|
|
trailColors[trailIdx + 2] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!hasVisibleTrail) {
|
|
|
|
|
const base = trailSegmentCount * 3;
|
|
|
|
|
const dist = Math.sqrt(pos.x * pos.x + pos.y * pos.y + pos.z * pos.z) || 1;
|
|
|
|
|
const nx = pos.x / dist;
|
|
|
|
|
const ny = pos.y / dist;
|
|
|
|
|
const nz = pos.z / dist;
|
|
|
|
|
const tip = FALLBACK_TRAIL_TIP_LENGTH;
|
|
|
|
|
instanceStarts[base] = pos.x + nx * tip;
|
|
|
|
|
instanceStarts[base + 1] = pos.y + ny * tip;
|
|
|
|
|
instanceStarts[base + 2] = pos.z + nz * tip;
|
|
|
|
|
instanceEnds[base] = pos.x;
|
|
|
|
|
instanceEnds[base + 1] = pos.y;
|
|
|
|
|
instanceEnds[base + 2] = pos.z;
|
|
|
|
|
const fallbackAlphaStart = FALLBACK_TRAIL_ALPHA_START * trailBrightness;
|
|
|
|
|
const fallbackAlphaEnd = FALLBACK_TRAIL_ALPHA_END * trailBrightness;
|
|
|
|
|
instanceColorStarts[base] = r * fallbackAlphaStart;
|
|
|
|
|
instanceColorStarts[base + 1] = g * fallbackAlphaStart;
|
|
|
|
|
instanceColorStarts[base + 2] = b * fallbackAlphaStart;
|
|
|
|
|
instanceColorEnds[base] = r * fallbackAlphaEnd;
|
|
|
|
|
instanceColorEnds[base + 1] = g * fallbackAlphaEnd;
|
|
|
|
|
instanceColorEnds[base + 2] = b * fallbackAlphaEnd;
|
|
|
|
|
trailSegmentCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -909,23 +1223,40 @@ export function updateSatellitePositions(deltaTime = 0, force = false) {
|
|
|
|
|
backdropPositions[i * 3] = 0;
|
|
|
|
|
backdropPositions[i * 3 + 1] = 0;
|
|
|
|
|
backdropPositions[i * 3 + 2] = 0;
|
|
|
|
|
pointAlphas[i] = 0;
|
|
|
|
|
backdropAlphas[i] = 0;
|
|
|
|
|
|
|
|
|
|
for (let j = 0; j < TRAIL_LENGTH; j++) {
|
|
|
|
|
const trailIdx = (i * TRAIL_LENGTH + j) * 3;
|
|
|
|
|
trailPositions[trailIdx] = 0;
|
|
|
|
|
trailPositions[trailIdx + 1] = 0;
|
|
|
|
|
trailPositions[trailIdx + 2] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const trailArrayLength = instanceStarts.length / 3;
|
|
|
|
|
for (let i = trailSegmentCount; i < trailArrayLength; i++) {
|
|
|
|
|
const base = i * 3;
|
|
|
|
|
instanceStarts[base] = 0;
|
|
|
|
|
instanceStarts[base + 1] = 0;
|
|
|
|
|
instanceStarts[base + 2] = 0;
|
|
|
|
|
instanceEnds[base] = 0;
|
|
|
|
|
instanceEnds[base + 1] = 0;
|
|
|
|
|
instanceEnds[base + 2] = 0;
|
|
|
|
|
instanceColorStarts[base] = 0;
|
|
|
|
|
instanceColorStarts[base + 1] = 0;
|
|
|
|
|
instanceColorStarts[base + 2] = 0;
|
|
|
|
|
instanceColorEnds[base] = 0;
|
|
|
|
|
instanceColorEnds[base + 1] = 0;
|
|
|
|
|
instanceColorEnds[base + 2] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
satellitePoints.geometry.attributes.position.needsUpdate = true;
|
|
|
|
|
satellitePoints.geometry.attributes.color.needsUpdate = true;
|
|
|
|
|
satellitePoints.geometry.attributes.alpha.needsUpdate = true;
|
|
|
|
|
satellitePoints.geometry.setDrawRange(0, count);
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.position.needsUpdate = true;
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.alpha.needsUpdate = true;
|
|
|
|
|
satelliteBackdropPoints.geometry.setDrawRange(0, count);
|
|
|
|
|
|
|
|
|
|
satelliteTrails.geometry.attributes.position.needsUpdate = true;
|
|
|
|
|
satelliteTrails.geometry.attributes.color.needsUpdate = true;
|
|
|
|
|
for (const name of TRAIL_INSTANCE_ATTRIBUTE_NAMES) {
|
|
|
|
|
satelliteTrails.geometry.attributes[name].needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
satelliteTrails.geometry.instanceCount = trailSegmentCount;
|
|
|
|
|
|
|
|
|
|
// Keep the hover ring synced with the propagated satellite position even
|
|
|
|
|
// when the pointer stays still and no new hover event is emitted.
|
|
|
|
@@ -1014,10 +1345,12 @@ export function setSatelliteSunDirection(direction) {
|
|
|
|
|
|
|
|
|
|
export function setLockedSatelliteIndex(index) {
|
|
|
|
|
lockedSatelliteIndex = index;
|
|
|
|
|
updateSatellitePointVisibilityAttributes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function setHoveredSatelliteIndex(index) {
|
|
|
|
|
hoveredSatelliteIndex = index;
|
|
|
|
|
updateSatellitePointVisibilityAttributes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeSatelliteDisplayStyle(nextStyle) {
|
|
|
|
@@ -1190,7 +1523,7 @@ export function isSatelliteFrontFacing(index, camera = cameraRef) {
|
|
|
|
|
function createLockedHaloMaterial(color = "#ffbf47") {
|
|
|
|
|
return new THREE.ShaderMaterial({
|
|
|
|
|
transparent: true,
|
|
|
|
|
depthTest: false,
|
|
|
|
|
depthTest: true,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
side: THREE.DoubleSide,
|
|
|
|
|
uniforms: {
|
|
|
|
@@ -1397,6 +1730,7 @@ function clearLockedSatelliteStyleVisuals() {
|
|
|
|
|
|
|
|
|
|
function updateLockedDotWorldTransform(position) {
|
|
|
|
|
if (!lockedDotSprite || !position || !earthObjRef) return;
|
|
|
|
|
earthObjRef.updateMatrixWorld(true);
|
|
|
|
|
const worldPosition = position.clone().applyMatrix4(earthObjRef.matrixWorld);
|
|
|
|
|
lockedDotSprite.position.copy(worldPosition);
|
|
|
|
|
if (cameraRef) {
|
|
|
|
@@ -1417,6 +1751,7 @@ function updateLockedDotWorldTransform(position) {
|
|
|
|
|
|
|
|
|
|
function updateLockedHaloWorldTransform(position) {
|
|
|
|
|
if (!position || !earthObjRef || !lockedHaloMesh) return;
|
|
|
|
|
earthObjRef.updateMatrixWorld(true);
|
|
|
|
|
const worldPosition = position.clone().applyMatrix4(earthObjRef.matrixWorld);
|
|
|
|
|
const viewDirection = cameraRef
|
|
|
|
|
? scratchToCamera.subVectors(cameraRef.position, worldPosition).normalize()
|
|
|
|
@@ -1764,7 +2099,7 @@ function showSelfGlowStyle(position, color = "#ffd25a") {
|
|
|
|
|
color: new THREE.Color(color),
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.96,
|
|
|
|
|
depthTest: false,
|
|
|
|
|
depthTest: true,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
side: THREE.DoubleSide,
|
|
|
|
|
});
|
|
|
|
@@ -1824,6 +2159,7 @@ function createRingSprite(position, isLocked = false, color = "#ffcc00") {
|
|
|
|
|
8,
|
|
|
|
|
12,
|
|
|
|
|
isLocked ? color : "#ffffff",
|
|
|
|
|
isLocked ? LOCKED_RING_HOVER_LINE_WIDTH : HOVER_RING_LINE_WIDTH,
|
|
|
|
|
);
|
|
|
|
|
const filledTexture = isLocked
|
|
|
|
|
? createFilledCircleTexture(color)
|
|
|
|
@@ -1832,7 +2168,9 @@ function createRingSprite(position, isLocked = false, color = "#ffcc00") {
|
|
|
|
|
map: ringTexture,
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
depthTest: false,
|
|
|
|
|
depthTest: true,
|
|
|
|
|
depthWrite: false,
|
|
|
|
|
alphaTest: 0.01,
|
|
|
|
|
sizeAttenuation: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@@ -1866,24 +2204,8 @@ function updateLockedMarkerVisual(isHovered) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createRelatedSatelliteSprite(position, color = "#7dd3fc") {
|
|
|
|
|
if (!earthObjRef) return null;
|
|
|
|
|
|
|
|
|
|
const ringTexture = createRingTexture(7, 11, color);
|
|
|
|
|
const spriteMaterial = new THREE.SpriteMaterial({
|
|
|
|
|
map: ringTexture,
|
|
|
|
|
transparent: true,
|
|
|
|
|
opacity: 0.55,
|
|
|
|
|
depthTest: false,
|
|
|
|
|
sizeAttenuation: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const sprite = new THREE.Sprite(spriteMaterial);
|
|
|
|
|
sprite.position.copy(position);
|
|
|
|
|
sprite.scale.set(SATELLITE_CONFIG.ringSize * 0.8, SATELLITE_CONFIG.ringSize * 0.8, 1);
|
|
|
|
|
sprite.renderOrder = SATELLITE_CONFIG.overlayRenderOrder;
|
|
|
|
|
earthObjRef.add(sprite);
|
|
|
|
|
return sprite;
|
|
|
|
|
function createRelatedSatelliteSprite(position) {
|
|
|
|
|
return createRingSprite(position, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function showHoverRing(position, isLocked = false) {
|
|
|
|
@@ -1962,7 +2284,7 @@ export function updateLockedRingPosition(position) {
|
|
|
|
|
1 +
|
|
|
|
|
(ringPulse * 2 - 1) * SATELLITE_CONFIG.breathingScaleAmplitude;
|
|
|
|
|
const markerSize = isHovered
|
|
|
|
|
? SATELLITE_CONFIG.ringSize
|
|
|
|
|
? SATELLITE_CONFIG.ringSize * LOCKED_RING_HOVER_SCALE
|
|
|
|
|
: SATELLITE_CONFIG.ringSize * LOCKED_RING_IDLE_SCALE;
|
|
|
|
|
lockedRingSprite.scale.set(
|
|
|
|
|
markerSize * breathScale,
|
|
|
|
@@ -2026,26 +2348,38 @@ export function setSatelliteRingState(index, state, position) {
|
|
|
|
|
hoveredSatelliteIndex = index;
|
|
|
|
|
hideHoverRings();
|
|
|
|
|
showHoverRing(position, false);
|
|
|
|
|
updateSatellitePointVisibilityAttributes();
|
|
|
|
|
break;
|
|
|
|
|
case "locked":
|
|
|
|
|
hoveredSatelliteIndex = null;
|
|
|
|
|
hideHoverRings();
|
|
|
|
|
showHoverRing(position, true);
|
|
|
|
|
updateSatellitePointVisibilityAttributes();
|
|
|
|
|
break;
|
|
|
|
|
case "none":
|
|
|
|
|
hoveredSatelliteIndex = null;
|
|
|
|
|
hideHoverRings();
|
|
|
|
|
hideLockedRing();
|
|
|
|
|
updateSatellitePointVisibilityAttributes();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function applyDimMaterialState(isDimmed) {
|
|
|
|
|
if (satellitePoints) {
|
|
|
|
|
satellitePoints.material.opacity = isDimmed ? DIMMED_SATELLITE_POINT_OPACITY : 0.9;
|
|
|
|
|
const opacity = isDimmed ? DIMMED_SATELLITE_POINT_OPACITY : 0.9;
|
|
|
|
|
if (satellitePoints.material.uniforms?.opacity) {
|
|
|
|
|
satellitePoints.material.uniforms.opacity.value = opacity;
|
|
|
|
|
} else {
|
|
|
|
|
satellitePoints.material.opacity = opacity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (satelliteBackdropPoints) {
|
|
|
|
|
satelliteBackdropPoints.material.opacity = isDimmed ? DIMMED_SATELLITE_BACKDROP_OPACITY : 0.42;
|
|
|
|
|
const opacity = isDimmed ? DIMMED_SATELLITE_BACKDROP_OPACITY : 0.42;
|
|
|
|
|
if (satelliteBackdropPoints.material.uniforms?.opacity) {
|
|
|
|
|
satelliteBackdropPoints.material.uniforms.opacity.value = opacity;
|
|
|
|
|
} else {
|
|
|
|
|
satelliteBackdropPoints.material.opacity = opacity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2069,7 +2403,7 @@ export function highlightRelatedSatellites(indices, color = "#7dd3fc") {
|
|
|
|
|
indices.forEach((index) => {
|
|
|
|
|
const pos = satellitePositions?.[index]?.current;
|
|
|
|
|
if (!pos) return;
|
|
|
|
|
const sprite = createRelatedSatelliteSprite(pos, color);
|
|
|
|
|
const sprite = createRelatedSatelliteSprite(pos);
|
|
|
|
|
if (!sprite) return;
|
|
|
|
|
relatedSatelliteSprites.push({ index, sprite, color });
|
|
|
|
|
});
|
|
|
|
@@ -2234,14 +2568,13 @@ export function clearSatelliteData() {
|
|
|
|
|
|
|
|
|
|
satellitePositions.forEach((position) => {
|
|
|
|
|
position.current.set(0, 0, 0);
|
|
|
|
|
position.trail = [];
|
|
|
|
|
position.trailIndex = 0;
|
|
|
|
|
position.trailCount = 0;
|
|
|
|
|
});
|
|
|
|
|
resetSatelliteTrailState();
|
|
|
|
|
|
|
|
|
|
if (satellitePoints) {
|
|
|
|
|
const positionAttr = satellitePoints.geometry.attributes.position;
|
|
|
|
|
const colorAttr = satellitePoints.geometry.attributes.color;
|
|
|
|
|
const alphaAttr = satellitePoints.geometry.attributes.alpha;
|
|
|
|
|
if (positionAttr?.array) {
|
|
|
|
|
positionAttr.array.fill(0);
|
|
|
|
|
positionAttr.needsUpdate = true;
|
|
|
|
@@ -2250,31 +2583,30 @@ export function clearSatelliteData() {
|
|
|
|
|
colorAttr.array.fill(0);
|
|
|
|
|
colorAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
if (alphaAttr?.array) {
|
|
|
|
|
alphaAttr.array.fill(0);
|
|
|
|
|
alphaAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
satellitePoints.geometry.setDrawRange(0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (satelliteBackdropPoints) {
|
|
|
|
|
const backdropPositionAttr =
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.position;
|
|
|
|
|
const backdropAlphaAttr =
|
|
|
|
|
satelliteBackdropPoints.geometry.attributes.alpha;
|
|
|
|
|
if (backdropPositionAttr?.array) {
|
|
|
|
|
backdropPositionAttr.array.fill(0);
|
|
|
|
|
backdropPositionAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
if (backdropAlphaAttr?.array) {
|
|
|
|
|
backdropAlphaAttr.array.fill(0);
|
|
|
|
|
backdropAlphaAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
satelliteBackdropPoints.geometry.setDrawRange(0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (satelliteTrails) {
|
|
|
|
|
const trailPositionAttr = satelliteTrails.geometry.attributes.position;
|
|
|
|
|
const trailColorAttr = satelliteTrails.geometry.attributes.color;
|
|
|
|
|
if (trailPositionAttr?.array) {
|
|
|
|
|
trailPositionAttr.array.fill(0);
|
|
|
|
|
trailPositionAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
if (trailColorAttr?.array) {
|
|
|
|
|
trailColorAttr.array.fill(0);
|
|
|
|
|
trailColorAttr.needsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
clearSatelliteTrailGeometry();
|
|
|
|
|
|
|
|
|
|
hideHoverRings();
|
|
|
|
|
hideLockedRing();
|
|
|
|
|