Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,24 @@ interface ModelViewerProps {
|
||||
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() {
|
||||
return (
|
||||
<Html center>
|
||||
|
||||
Reference in New Issue
Block a user