Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-21 14:51:00 +00:00
parent e2b780e51b
commit adeab0acd1
+18
View File
@@ -10,6 +10,24 @@ interface ModelViewerProps {
url?: string; // legacy, ignored — uses store.models url?: string; // legacy, ignored — uses store.models
} }
/** Walk up the parent chain until we find a node tagged as `ifcElement`,
* or the model root. Returns null if neither found. */
export function findElementRoot(obj: THREE.Object3D | null): THREE.Object3D | null {
let cur: THREE.Object3D | null = obj;
while (cur) {
if (cur.userData?.ifcElement) return cur;
cur = cur.parent;
}
return null;
}
/** Stable key for an element across reloads: prefers ifcId, falls back to name. */
export function elementKey(modelId: string, el: THREE.Object3D): string {
const id = el.userData?.ifcId ?? el.name ?? el.uuid;
return `${modelId}:${id}`;
}
function LoadingFallback() { function LoadingFallback() {
return ( return (
<Html center> <Html center>