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
+27 -15
View File
@@ -239,21 +239,33 @@ 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);
let element: THREE.Object3D | null = null; const triggerHit = triggerHits.find((h) => {
let modelId: string | null = null; const o = h.object;
while (cur) { if (!(o instanceof THREE.Mesh)) return false;
if (!element && cur.userData?.ifcElement) element = cur; if (o.userData.__edgeLine) return false;
if (!modelId && cur.userData?.modelId) modelId = cur.userData.modelId as string; if (o.geometry instanceof THREE.SphereGeometry) return false;
cur = cur.parent; if (o.geometry instanceof THREE.RingGeometry) return false;
} if (o.geometry instanceof THREE.PlaneGeometry) return false;
if (!element) element = hit.object; return true;
if (!modelId) modelId = st.activeModelId; });
if (modelId && element) { if (triggerHit && triggerHit.object instanceof THREE.Mesh) {
const id = element.userData?.ifcId ?? element.name ?? element.uuid; let cur: THREE.Object3D | null = triggerHit.object;
st.toggleElementSelection(`${modelId}:${id}`); let element: THREE.Object3D | null = null;
let modelId: string | null = null;
while (cur) {
if (!element && cur.userData?.ifcElement) element = cur;
if (!modelId && cur.userData?.modelId) modelId = cur.userData.modelId as string;
cur = cur.parent;
}
if (!element) element = triggerHit.object;
if (!modelId) modelId = st.activeModelId;
if (modelId && element) {
const id = element.userData?.ifcId ?? element.name ?? element.uuid;
st.toggleElementSelection(`${modelId}:${id}`);
}
} }
} else if (snappedPoint) { } else if (snappedPoint) {
st.addMeasurePoint({ st.addMeasurePoint({