fix: update distance text calculation to include cone height in MeasurementTool

This commit is contained in:
Jerald-Golden-B 2025-05-22 16:37:02 +05:30
parent 73bb37e083
commit c2d952c190
3 changed files with 6 additions and 21 deletions

View File

@ -10,7 +10,7 @@ function updateDistanceText(
////////// Updating the Distance Texts of the lines that are affected during drag ////////// ////////// Updating the Distance Texts of the lines that are affected during drag //////////
const DistanceGroup = scene.children.find((child) => child.name === "Distance_Text") as THREE.Group; const DistanceGroup = scene.getObjectByName('Distance_Text') as THREE.Group;
affectedLines.forEach((lineIndex) => { affectedLines.forEach((lineIndex) => {
const mesh = floorPlanGroupLine.current.children[lineIndex] as THREE.Mesh; const mesh = floorPlanGroupLine.current.children[lineIndex] as THREE.Mesh;

View File

@ -10,7 +10,6 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
const [selectedComment, setSelectedComment] = useState<CommentSchema | null>(null); const [selectedComment, setSelectedComment] = useState<CommentSchema | null>(null);
const [transformMode, setTransformMode] = useState<"translate" | "rotate" | null>(null); const [transformMode, setTransformMode] = useState<"translate" | "rotate" | null>(null);
useEffect(() => { useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => { const handleKeyDown = (e: KeyboardEvent) => {
const keyCombination = detectModifierKeys(e); const keyCombination = detectModifierKeys(e);
@ -22,13 +21,13 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
setTransformMode((prev) => (prev === "rotate" ? null : "rotate")); setTransformMode((prev) => (prev === "rotate" ? null : "rotate"));
} }
}; };
window.addEventListener("keydown", handleKeyDown); window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown);
}, [selectedComment]); }, [selectedComment]);
if (comment.state === 'inactive' || isPlaying) return null; if (comment.state === 'inactive' || isPlaying) return null;
return ( return (
<> <>
@ -37,26 +36,12 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
zIndexRange={[1, 0]} zIndexRange={[1, 0]}
prepend prepend
sprite sprite
center center
position={comment.position} position={comment.position}
rotation={comment.rotation} rotation={comment.rotation}
className='comments-main-wrapper' className='comments-main-wrapper'
> >
<CommentThreads /> <CommentThreads />
{/* <div
className='outer'
onClick={(e) => {
e.stopPropagation();
setSelectedComment(comment);
console.log("down");
}}
onPointerOver={(e) => {
e.stopPropagation();
}}>
<div>
hii
</div>
</div> */}
</Html> </Html>
{CommentRef.current && transformMode && ( {CommentRef.current && transformMode && (
<TransformControls <TransformControls

View File

@ -218,7 +218,7 @@ const MeasurementTool = () => {
sprite sprite
> >
<div> <div>
{startConePosition.distanceTo(endConePosition).toFixed(2)} m {(startConePosition.distanceTo(endConePosition) + (coneSize.height)).toFixed(2)} m
</div> </div>
</Html> </Html>
)} )}