fix clique

This commit is contained in:
Rodrigo Bertoldo de Sousa Martins committed 2026-09-11 11:30:46 -03:00
1 parent 3710c18825
commit 4542e8fda0
2 files changed
+64 -14

No files matched your search

+5 -10
View File
@@ -1,7 +1,6 @@
import { useEffect, useMemo, useRef } from "react";
import { useGLTF } from "@react-three/drei";
import * as THREE from "three";
import type { ThreeEvent } from "@react-three/fiber";
import { modelUrl, type Structure } from "../../lib/api.js";
interface Props {
@@ -12,7 +11,6 @@ interface Props {
structuresInFile: Structure[];
visibleSystems: Set<string>;
selectedSlug: string | null;
onSelect: (slug: string) => void;
clippingPlanes: THREE.Plane[];
}
@@ -24,7 +22,6 @@ export function SystemModel({
structuresInFile,
visibleSystems,
selectedSlug,
onSelect,
clippingPlanes,
}: Props) {
const { scene } = useGLTF(modelUrl(modelFile));
@@ -127,11 +124,9 @@ export function SystemModel({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [root, bySlugInFile, byMeshNameInFile, visibleSystems, selectedSlug, clippingPlanes]);
const handleClick = (e: ThreeEvent<MouseEvent>) => {
e.stopPropagation();
const name = e.object.name;
if (name) onSelect(name);
};
return <primitive object={root} onClick={handleClick} />;
// Seleção por clique agora é feita centralizadamente em Scene.tsx
// (ClickSelector) — um "clique gordo" com vários raios em vez de só o
// pixel exato, bem mais tolerante com ossos finos (costela de perfil,
// falange etc.) do que o onClick padrão por malha.
return <primitive object={root} />;
}