mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: safer drag
This commit is contained in:
1 parent
5982fdde8c
commit
7a8f88f224
1 file changed
+35
-24
+35
-24
@@ -266,7 +266,7 @@ export function SceneProps() {
|
|||||||
return () => {
|
return () => {
|
||||||
dissectEvent.off(handleDissectEvent);
|
dissectEvent.off(handleDissectEvent);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [display]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -275,37 +275,48 @@ 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>
|
||||||
|
|
||||||
<group ref={dissector}>
|
{display === TankopediaDisplay.Dissector && (
|
||||||
<mesh
|
<group ref={dissector}>
|
||||||
position={[GRID_SIZE / 8, 0, 0]}
|
<mesh
|
||||||
rotation={[-Math.PI / 2, 0, Math.PI / 2]}
|
position={[GRID_SIZE / 8, 0, 0]}
|
||||||
onPointerDown={(event) => {
|
rotation={[-Math.PI / 2, 0, Math.PI / 2]}
|
||||||
if (display !== TankopediaDisplay.Dissector) return;
|
onPointerDown={(event) => {
|
||||||
|
if (
|
||||||
|
display !== TankopediaDisplay.Dissector ||
|
||||||
|
!dissector.current ||
|
||||||
|
event.point.distanceTo(dissector.current.position) > 1.5
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
position.current.set(
|
position.current.set(
|
||||||
event.nativeEvent.clientX,
|
event.nativeEvent.clientX,
|
||||||
event.nativeEvent.clientY,
|
event.nativeEvent.clientY,
|
||||||
);
|
);
|
||||||
mutateTankopediaEphemeral((draft) => {
|
mutateTankopediaEphemeral((draft) => {
|
||||||
draft.controlsEnabled = false;
|
draft.controlsEnabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('pointermove', handlePointerMove);
|
window.addEventListener('pointermove', handlePointerMove);
|
||||||
window.addEventListener('pointerup', handlePointerUp);
|
window.addEventListener('pointerup', handlePointerUp);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<planeGeometry args={[GRID_SIZE / 2, GRID_SIZE / 4]} />
|
<planeGeometry args={[GRID_SIZE / 2, GRID_SIZE / 4]} />
|
||||||
<meshStandardMaterial map={dragTexture} transparent />
|
<meshStandardMaterial map={dragTexture} transparent />
|
||||||
</mesh>
|
</mesh>
|
||||||
</group>
|
</group>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user