feat: Enhance wall asset interaction and management; implement position updates and add closest point calculation utility

This commit is contained in:
2025-06-30 17:48:29 +05:30
parent 1a9aef323a
commit 364b643c72
6 changed files with 135 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import { useSelectedItem, useSocketStore, useToggleView } from '../../../store/b
import useModuleStore from '../../../store/useModuleStore';
import { MathUtils, Vector3 } from 'three';
import { useSceneContext } from '../../scene/sceneContext';
import closestPointOnLineSegment from '../line/helpers/getClosestPointOnLineSegment';
function WallAssetCreator() {
const { socket } = useSocketStore();
@@ -14,17 +15,6 @@ function WallAssetCreator() {
const { addWallAsset } = wallAssetStore();
const { selectedItem, setSelectedItem } = useSelectedItem();
function closestPointOnLineSegment(p: Vector3, a: Vector3, b: Vector3) {
const ab = new Vector3().subVectors(b, a);
const ap = new Vector3().subVectors(p, a);
const abLengthSq = ab.lengthSq();
const dot = ap.dot(ab);
const t = Math.max(0, Math.min(1, dot / abLengthSq));
return new Vector3().copy(a).add(ab.multiplyScalar(t));
}
useEffect(() => {
const canvasElement = gl.domElement;