feat: Enhance wall asset interaction and management; implement position updates and add closest point calculation utility
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user