Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -215,12 +215,29 @@ export function XRControllerMeasure() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Right trigger: add point ──────────────────────────────────────
|
||||
// ── Right trigger: add point (measure) OR toggle selection ────────
|
||||
const trigVal = gp?.buttons?.[0]?.value ?? (gp?.buttons?.[0]?.pressed ? 1 : 0);
|
||||
if (!trigState.current && trigVal > TRIG_ON) {
|
||||
trigState.current = true;
|
||||
if (snappedPoint) {
|
||||
useModelStore.getState().addMeasurePoint({
|
||||
const st = useModelStore.getState();
|
||||
if (st.selectionMode && hit && hit.object instanceof THREE.Mesh) {
|
||||
// Walk up to find ifcElement + modelId
|
||||
let cur: THREE.Object3D | null = hit.object;
|
||||
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 = hit.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) {
|
||||
st.addMeasurePoint({
|
||||
x: snappedPoint.x, y: snappedPoint.y, z: snappedPoint.z,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user