Files
BrainWind/fix_warehouse.js
T

37 lines
2.0 KiB
JavaScript

const fs = require('fs');
let code = fs.readFileSync('app/src/components/Warehouse3D.tsx', 'utf8');
// Import AirflowSystem
if (!code.includes('AirflowSystem')) {
code = code.replace("import { useGalpaoStore } from '../store/galpaoStore';", "import { useGalpaoStore } from '../store/galpaoStore';\nimport { AirflowSystem } from './three/AirflowSystem';");
}
// Add viewMode to useGalpaoStore destructuring in WarehouseModel
if (!code.includes('viewMode = useGalpaoStore')) {
code = code.replace("const { width, length, height, roofPitch, wallCpe, roofCpe, template, extraHeight, skirtHeight } = useGalpaoStore();", "const { width, length, height, roofPitch, wallCpe, roofCpe, template, extraHeight, skirtHeight, viewMode } = useGalpaoStore();");
}
// Add viewMode to PressureArrow
if (!code.includes('const { viewMode } = useGalpaoStore();') && code.includes('function PressureArrow')) {
code = code.replace("const { q } = useWindStore();", "const { q } = useWindStore();\n const { viewMode } = useGalpaoStore();\n if (viewMode === 'airflow') return null;");
}
// Make meshStandardMaterial transparent
code = code.replace(/<meshStandardMaterial(?!\s*color=\{color\}\s*transparent\s*opacity=\{0\.6\})([^>]+)>/g, (match, p1) => {
// If it already has transparent, skip
if (match.includes("transparent={viewMode")) return match;
return `<meshStandardMaterial${p1} transparent={viewMode === 'airflow'} opacity={viewMode === 'airflow' ? 0.35 : 1} />`;
});
// Add AirflowSystem to the scene
if (!code.includes('<AirflowSystem')) {
code = code.replace("{/* === RÓTULOS 3D === */}", "{viewMode === 'airflow' && <AirflowSystem windAngle={windAngle} width={width} length={length} height={height} permeabilityCase={permeabilityCase} />}\n\n {/* === RÓTULOS 3D === */}");
}
// Rótulos 3D visibility
if (code.includes('{showMainWalls && (')) {
code = code.replace("{showMainWalls && (", "{showMainWalls && viewMode === 'solid' && (");
}
fs.writeFileSync('app/src/components/Warehouse3D.tsx', code);