From bc7e77b0078130ecd7481616e671d4f96a634837 Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Fri, 11 Sep 2026 15:39:38 -0300 Subject: [PATCH] fix membrana --- frontend/src/components/viewer/Scene.tsx | 11 +++++++++-- frontend/src/components/viewer/SystemModel.tsx | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/viewer/Scene.tsx b/frontend/src/components/viewer/Scene.tsx index d8f6773..17ff7ee 100644 --- a/frontend/src/components/viewer/Scene.tsx +++ b/frontend/src/components/viewer/Scene.tsx @@ -3,7 +3,7 @@ import { Canvas, useThree } from "@react-three/fiber"; import { CameraControls, Grid } from "@react-three/drei"; import * as THREE from "three"; import { useAtlasStore, type BodyRegion, type ClipAxis } from "../../store/useAtlasStore.js"; -import { SystemModel } from "./SystemModel.js"; +import { SystemModel, CELL_MEMBRANE_SLUG } from "./SystemModel.js"; import type { Structure } from "../../lib/api.js"; // Sistemas apresentados como diagrama 2D (fotomicrografia real com @@ -260,7 +260,14 @@ function ClickSelector({ ndc.set(x, y); raycaster.setFromCamera(ndc, camera); const hits = raycaster.intersectObjects(scene.children, true); - const hit = hits.find((h) => h.object.visible && h.object.name && bySlug.has(h.object.name)); + const valid = hits.filter((h) => h.object.visible && h.object.name && bySlug.has(h.object.name)); + // A membrana plasmática da célula é semitransparente de propósito + // (ver SystemModel.tsx) justamente pra deixar ver as organelas por + // dentro — clicar nela não pode "capturar" o clique antes de + // chegar na organela real por trás; só vira o resultado do clique + // se não houver mais nada na frente/atrás dela nesse raio. + const hit = + valid.find((h) => h.object.name !== CELL_MEMBRANE_SLUG) ?? valid[0]; if (hit && (!best || hit.distance < best.distance)) { best = { distance: hit.distance, slug: hit.object.name }; } diff --git a/frontend/src/components/viewer/SystemModel.tsx b/frontend/src/components/viewer/SystemModel.tsx index bf78085..9348211 100644 --- a/frontend/src/components/viewer/SystemModel.tsx +++ b/frontend/src/components/viewer/SystemModel.tsx @@ -17,6 +17,13 @@ interface Props { const HIGHLIGHT = new THREE.Color("#22d3ee"); const BLACK = new THREE.Color(0x000000); +// A membrana plasmática é a malha REAL (FIB-SEM) de fora de uma célula +// HeLa cultivada — achatada e irregular (célula aderente em cultura, não +// uma bolinha lisa), não um erro. Mas sólida e opaca ela cobria e escondia +// as organelas de dentro (núcleo, mitocôndrias etc.), que é o oposto do +// que se quer pra estudar a célula — por isso ela é semitransparente. +export const CELL_MEMBRANE_SLUG = "celula-membrana-plasmatica"; + export function SystemModel({ modelFile, structuresInFile, @@ -120,6 +127,13 @@ export function SystemModel({ const isSelected = structure.slug === selectedSlug; mat.emissive = isSelected ? HIGHLIGHT : BLACK; mat.emissiveIntensity = isSelected ? 0.6 : 0; + + if (structure.slug === CELL_MEMBRANE_SLUG) { + mat.transparent = true; + mat.opacity = 0.18; + mat.depthWrite = false; + mat.side = THREE.DoubleSide; + } }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [root, bySlugInFile, byMeshNameInFile, visibleSystems, selectedSlug, clippingPlanes]);