feat: safer drag

This commit is contained in:
tresabhi committed 2025-03-23 17:22:42 -05:00
1 parent 5982fdde8c
commit 7a8f88f224
1 file changed
+14 -3
@@ -266,7 +266,7 @@ export function SceneProps() {
return () => { return () => {
dissectEvent.off(handleDissectEvent); dissectEvent.off(handleDissectEvent);
}; };
}, []); }, [display]);
return ( return (
<> <>
@@ -275,18 +275,28 @@ export function SceneProps() {
<mesh rotation={[-Math.PI / 2, 0, 0]}> <mesh rotation={[-Math.PI / 2, 0, 0]}>
<planeGeometry args={[GRID_SIZE, GRID_SIZE]} /> <planeGeometry args={[GRID_SIZE, GRID_SIZE]} />
<meshStandardMaterial <meshStandardMaterial
clippingPlanes={[clippingPlane.current]} clippingPlanes={
display === TankopediaDisplay.Dissector
? [clippingPlane.current]
: []
}
map={gridTexture} map={gridTexture}
transparent transparent
/> />
</mesh> </mesh>
{display === TankopediaDisplay.Dissector && (
<group ref={dissector}> <group ref={dissector}>
<mesh <mesh
position={[GRID_SIZE / 8, 0, 0]} position={[GRID_SIZE / 8, 0, 0]}
rotation={[-Math.PI / 2, 0, Math.PI / 2]} rotation={[-Math.PI / 2, 0, Math.PI / 2]}
onPointerDown={(event) => { onPointerDown={(event) => {
if (display !== TankopediaDisplay.Dissector) return; if (
display !== TankopediaDisplay.Dissector ||
!dissector.current ||
event.point.distanceTo(dissector.current.position) > 1.5
)
return;
event.stopPropagation(); event.stopPropagation();
@@ -306,6 +316,7 @@ export function SceneProps() {
<meshStandardMaterial map={dragTexture} transparent /> <meshStandardMaterial map={dragTexture} transparent />
</mesh> </mesh>
</group> </group>
)}
</> </>
)} )}