created points using pen icon

This commit is contained in:
2025-08-25 16:21:54 +05:30
parent fe95ea8d0b
commit 7b5486590a
4 changed files with 245 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
import { DragControls, Line } from "@react-three/drei";
import React, { useMemo, useState } from "react";
import { useActiveSubTool, useToolMode } from "../../../../store/builder/store";
import { useActiveTool, useToolMode } from "../../../../store/builder/store";
import { useThree } from "@react-three/fiber";
import { LineCurve3, Plane, Vector3 } from "three";
import { getPathsByPointId, setPathPosition } from "./function/getPaths";
@@ -49,7 +49,7 @@ export default function PathHandler({
paths?: any;
}>({});
const [isHovered, setIsHovered] = useState(false);
const { activeSubTool } = useActiveSubTool();
const { activeTool } = useActiveTool();
const plane = useMemo(() => new Plane(new Vector3(0, 1, 0), 0), []);
const path = useMemo(() => {
const [start, end] = points.map((p) => new Vector3(...p.position));
@@ -64,7 +64,7 @@ export default function PathHandler({
}
};
const handleDragStart = (points: [PointData, PointData]) => {
if (activeSubTool !== "free-hand") return;
if (activeTool !== "cursor") return;
const intersectionPoint = new Vector3();
const hit = raycaster.ray.intersectPlane(plane, intersectionPoint);
if (hit) {
@@ -106,6 +106,7 @@ export default function PathHandler({
// }
// }
// };
const handleDrag = (points: [PointData, PointData]) => {
if (isHovered && dragOffset) {
const intersectionPoint = new Vector3();