Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-21 21:25:21 +00:00
parent 16c1e7b755
commit 085184ba41
+16 -4
View File
@@ -239,9 +239,20 @@ export function XRControllerMeasure() {
if (!trigState.current && trigVal > TRIG_ON) { if (!trigState.current && trigVal > TRIG_ON) {
trigState.current = true; trigState.current = true;
const st = useModelStore.getState(); const st = useModelStore.getState();
if (st.selectionMode && hit && hit.object instanceof THREE.Mesh) { if (st.selectionMode) {
// Walk up to find ifcElement + modelId // Fresh raycast on the press itself (not every frame) for selection
let cur: THREE.Object3D | null = hit.object; const triggerHits = raycaster.current.intersectObjects(scene.children, true);
const triggerHit = triggerHits.find((h) => {
const o = h.object;
if (!(o instanceof THREE.Mesh)) return false;
if (o.userData.__edgeLine) return false;
if (o.geometry instanceof THREE.SphereGeometry) return false;
if (o.geometry instanceof THREE.RingGeometry) return false;
if (o.geometry instanceof THREE.PlaneGeometry) return false;
return true;
});
if (triggerHit && triggerHit.object instanceof THREE.Mesh) {
let cur: THREE.Object3D | null = triggerHit.object;
let element: THREE.Object3D | null = null; let element: THREE.Object3D | null = null;
let modelId: string | null = null; let modelId: string | null = null;
while (cur) { while (cur) {
@@ -249,12 +260,13 @@ export function XRControllerMeasure() {
if (!modelId && cur.userData?.modelId) modelId = cur.userData.modelId as string; if (!modelId && cur.userData?.modelId) modelId = cur.userData.modelId as string;
cur = cur.parent; cur = cur.parent;
} }
if (!element) element = hit.object; if (!element) element = triggerHit.object;
if (!modelId) modelId = st.activeModelId; if (!modelId) modelId = st.activeModelId;
if (modelId && element) { if (modelId && element) {
const id = element.userData?.ifcId ?? element.name ?? element.uuid; const id = element.userData?.ifcId ?? element.name ?? element.uuid;
st.toggleElementSelection(`${modelId}:${id}`); st.toggleElementSelection(`${modelId}:${id}`);
} }
}
} else if (snappedPoint) { } else if (snappedPoint) {
st.addMeasurePoint({ st.addMeasurePoint({
x: snappedPoint.x, y: snappedPoint.y, z: snappedPoint.z, x: snappedPoint.x, y: snappedPoint.y, z: snappedPoint.z,