added screenSpace for point

This commit is contained in:
2025-09-11 18:33:16 +05:30
parent 2d72a939ad
commit 7081aa1d50
3 changed files with 31 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
import { DragControls } from "@react-three/drei"; import { Box, DragControls, ScreenSizer } from "@react-three/drei";
import * as Constants from "../../../types/world/worldConstants"; import * as Constants from "../../../types/world/worldConstants";
import BoxMaterial from "../wrappers/materials/boxMaterial"; import BoxMaterial from "../wrappers/materials/boxMaterial";
@@ -49,17 +49,18 @@ function Point({ point }: { readonly point: Point }) {
<> <>
{!isSelected ? ( {!isSelected ? (
<DragControls axisLock="y" autoTransform={false} onDragStart={handleDragStart} onDrag={handleDrag} onDragEnd={handleDragEnd}> <DragControls axisLock="y" autoTransform={false} onDragStart={handleDragStart} onDrag={handleDrag} onDragEnd={handleDragEnd}>
<mesh <ScreenSizer
key={point.pointUuid} key={point.pointUuid}
uuid={point.pointUuid} uuid={point.pointUuid}
name={`${point.pointType}-Point`} name={`${point.pointType}-Point`}
scale={1}
position={[...point.position]} position={[...point.position]}
onClick={handlePointClick} onClick={handlePointClick}
onPointerOver={handlePointerOver} onPointerOver={handlePointerOver}
onPointerOut={handlePointerOut} onPointerOut={handlePointerOut}
userData={point} userData={point}
> >
<boxGeometry args={boxScale} /> <Box args={boxScale}>
<BoxMaterial <BoxMaterial
variant="box1" variant="box1"
uOuterColor={colors.defaultOuterColor} uOuterColor={colors.defaultOuterColor}
@@ -68,7 +69,8 @@ function Point({ point }: { readonly point: Point }) {
isHovered={isHovered} isHovered={isHovered}
isDeleteHovered={isDeleteHovered} isDeleteHovered={isDeleteHovered}
/> />
</mesh> </Box>
</ScreenSizer>
</DragControls> </DragControls>
) : ( ) : (
<group <group

View File

@@ -278,7 +278,14 @@ function MoveControls2D({ movedObjects, setMovedObjects, pastedObjects, setPaste
type: "Aisle", type: "Aisle",
lineData: { lineData: {
...updatedAisle, ...updatedAisle,
points: [initialStates[updatedAisle.points[0].pointUuid] ? { ...updatedAisle.points[0], position: initialStates[updatedAisle.points[0].pointUuid].position } : updatedAisle.points[0], initialStates[updatedAisle.points[1].pointUuid] ? { ...updatedAisle.points[1], position: initialStates[updatedAisle.points[1].pointUuid].position } : updatedAisle.points[1]] as [Point, Point], points: [
initialStates[updatedAisle.points[0].pointUuid]
? { ...updatedAisle.points[0], position: initialStates[updatedAisle.points[0].pointUuid].position }
: updatedAisle.points[0],
initialStates[updatedAisle.points[1].pointUuid]
? { ...updatedAisle.points[1], position: initialStates[updatedAisle.points[1].pointUuid].position }
: updatedAisle.points[1],
] as [Point, Point],
}, },
newData: updatedAisle, newData: updatedAisle,
timeStamp: new Date().toISOString(), timeStamp: new Date().toISOString(),
@@ -330,7 +337,14 @@ function MoveControls2D({ movedObjects, setMovedObjects, pastedObjects, setPaste
type: "Wall", type: "Wall",
lineData: { lineData: {
...updatedWall, ...updatedWall,
points: [initialStates[updatedWall.points[0].pointUuid] ? { ...updatedWall.points[0], position: initialStates[updatedWall.points[0].pointUuid].position } : updatedWall.points[0], initialStates[updatedWall.points[1].pointUuid] ? { ...updatedWall.points[1], position: initialStates[updatedWall.points[1].pointUuid].position } : updatedWall.points[1]] as [Point, Point], points: [
initialStates[updatedWall.points[0].pointUuid]
? { ...updatedWall.points[0], position: initialStates[updatedWall.points[0].pointUuid].position }
: updatedWall.points[0],
initialStates[updatedWall.points[1].pointUuid]
? { ...updatedWall.points[1], position: initialStates[updatedWall.points[1].pointUuid].position }
: updatedWall.points[1],
] as [Point, Point],
}, },
newData: updatedWall, newData: updatedWall,
timeStamp: new Date().toISOString(), timeStamp: new Date().toISOString(),

View File

@@ -316,7 +316,7 @@ export const pointConfig: PointConfig = {
defaultInnerColor: "#ffffff", // Default inner color of the points defaultInnerColor: "#ffffff", // Default inner color of the points
defaultOuterColor: "#ffffff", // Default outer color of the points defaultOuterColor: "#ffffff", // Default outer color of the points
deleteColor: "#ff0000", // Color of the points when deleting deleteColor: "#ff0000", // Color of the points when deleting
boxScale: [0.5, 0.5, 0.5], // Scale of the points boxScale: [20, 20, 20], // Scale of the points
wallOuterColor: "#C7C7C7", // Outer color of the wall points wallOuterColor: "#C7C7C7", // Outer color of the wall points
floorOuterColor: "#808080", // Outer color of the floor points floorOuterColor: "#808080", // Outer color of the floor points
aisleOuterColor: "#FBBC05", // Outer color of the aisle points aisleOuterColor: "#FBBC05", // Outer color of the aisle points