Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -41,12 +41,8 @@ export function ViewerControls() {
|
||||
|
||||
const handleExportSelection = useCallback(async () => {
|
||||
if (!activeModel || selectedElementKeys.size === 0) return;
|
||||
const canvas = document.querySelector('canvas') as HTMLCanvasElement | null;
|
||||
if (!canvas) { toast.error('Canvas não encontrado'); return; }
|
||||
// Walk the global scene to find selected element nodes
|
||||
const scene = (canvas as unknown as { __r3f?: { fiber?: { scene?: THREE.Scene } } }).__r3f?.fiber?.scene
|
||||
?? (window as unknown as { __r3fScene?: THREE.Scene }).__r3fScene;
|
||||
// Fallback: scan via DOM-attached three scene exposed by drei? Use traversal of stored models — use document approach
|
||||
const scene = sceneRef.current;
|
||||
if (!scene) { toast.error('Cena 3D não disponível'); return; }
|
||||
const objects: THREE.Object3D[] = [];
|
||||
const collect = (root: THREE.Object3D) => {
|
||||
const modelId = root.userData?.modelId as string | undefined;
|
||||
@@ -56,7 +52,7 @@ export function ViewerControls() {
|
||||
if (selectedElementKeys.has(elementKey(modelId, el))) objects.push(el);
|
||||
});
|
||||
};
|
||||
if (scene) collect(scene);
|
||||
collect(scene);
|
||||
if (objects.length === 0) {
|
||||
toast.error('Não foi possível localizar elementos selecionados. Use IFC para seleção persistente.');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user