Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -10,15 +10,35 @@ 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`,
|
function isPickableModelMesh(obj: THREE.Object3D): obj is THREE.Mesh {
|
||||||
* or the model root. Returns null if neither found. */
|
if (!(obj instanceof THREE.Mesh)) return false;
|
||||||
|
if (obj.userData.__edgeLine) return false;
|
||||||
|
if (obj.geometry instanceof THREE.SphereGeometry) return false;
|
||||||
|
if (obj.geometry instanceof THREE.RingGeometry) return false;
|
||||||
|
if (obj.geometry instanceof THREE.PlaneGeometry) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Walk up the parent chain until we find a node tagged as `ifcElement`.
|
||||||
|
* Falls back to the clicked mesh so older/demo GLBs without IFC metadata
|
||||||
|
* still support selection/highlight. */
|
||||||
export function findElementRoot(obj: THREE.Object3D | null): THREE.Object3D | null {
|
export function findElementRoot(obj: THREE.Object3D | null): THREE.Object3D | null {
|
||||||
|
const fallback = isPickableModelMesh(obj as THREE.Object3D) ? obj : null;
|
||||||
let cur: THREE.Object3D | null = obj;
|
let cur: THREE.Object3D | null = obj;
|
||||||
while (cur) {
|
while (cur) {
|
||||||
if (cur.userData?.ifcElement) return cur;
|
if (cur.userData?.ifcElement) return cur;
|
||||||
cur = cur.parent;
|
cur = cur.parent;
|
||||||
}
|
}
|
||||||
return null;
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasIfcAncestor(obj: THREE.Object3D): boolean {
|
||||||
|
let cur = obj.parent;
|
||||||
|
while (cur) {
|
||||||
|
if (cur.userData?.ifcElement) return true;
|
||||||
|
cur = cur.parent;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stable key for an element across reloads: prefers ifcId, falls back to name. */
|
/** Stable key for an element across reloads: prefers ifcId, falls back to name. */
|
||||||
|
|||||||
Reference in New Issue
Block a user