🚀 Auto-deploy: BrainWind atualizado em 30/07/2026 11:01:30
This commit is contained in:
@@ -7,6 +7,7 @@ interface ResizableBox3DProps {
|
|||||||
l1: number;
|
l1: number;
|
||||||
l2: number;
|
l2: number;
|
||||||
h: number;
|
h: number;
|
||||||
|
viewMode?: 'solid' | 'airflow';
|
||||||
}
|
}
|
||||||
|
|
||||||
function WindParticles({ l1, l2, h }: { l1: number, l2: number, h: number }) {
|
function WindParticles({ l1, l2, h }: { l1: number, l2: number, h: number }) {
|
||||||
@@ -79,7 +80,7 @@ function WindParticles({ l1, l2, h }: { l1: number, l2: number, h: number }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ResizableBox3D({ l1, l2, h }: ResizableBox3DProps) {
|
export function ResizableBox3D({ l1, l2, h, viewMode = 'solid' }: ResizableBox3DProps) {
|
||||||
const meshRef = useRef<THREE.Mesh>(null);
|
const meshRef = useRef<THREE.Mesh>(null);
|
||||||
|
|
||||||
// Create target scale and position based on inputs
|
// Create target scale and position based on inputs
|
||||||
@@ -109,12 +110,12 @@ export function ResizableBox3D({ l1, l2, h }: ResizableBox3DProps) {
|
|||||||
{/* The Animated Box */}
|
{/* The Animated Box */}
|
||||||
<mesh ref={meshRef} castShadow receiveShadow>
|
<mesh ref={meshRef} castShadow receiveShadow>
|
||||||
<boxGeometry args={[1, 1, 1]} />
|
<boxGeometry args={[1, 1, 1]} />
|
||||||
<meshStandardMaterial color="#4f46e5" transparent opacity={0.7} roughness={0.2} metalness={0.8} />
|
<meshStandardMaterial color="#4f46e5" transparent opacity={viewMode === 'airflow' ? 0.3 : 0.7} roughness={0.2} metalness={0.8} />
|
||||||
<Edges scale={1} threshold={15} color="#818cf8" />
|
<Edges scale={1} threshold={15} color="#818cf8" />
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
{/* Wind Flow Animation */}
|
{/* Wind Flow Animation */}
|
||||||
<WindParticles l1={l1} l2={l2} h={h} />
|
{viewMode === 'airflow' && <WindParticles l1={l1} l2={l2} h={h} />}
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+109
-116
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { getDragCoefficient } from '@/lib/drag';
|
import { getDragCoefficient } from '@/lib/drag';
|
||||||
import { useI18n } from '@/store/i18nStore';
|
import { useI18n } from '@/store/i18nStore';
|
||||||
import { DragCoefficientChart } from '@/components/DragCoefficientChart';
|
import { DragCoefficientChart } from '@/components/DragCoefficientChart';
|
||||||
@@ -7,8 +7,8 @@ import SceneCanvas from '@/components/SceneCanvas';
|
|||||||
import { Environment } from '@react-three/drei';
|
import { Environment } from '@react-three/drei';
|
||||||
import { ViewerOrbitControls as OrbitControls } from '@/components/three/ViewerOrbitControls';
|
import { ViewerOrbitControls as OrbitControls } from '@/components/three/ViewerOrbitControls';
|
||||||
import { EducationalManual } from '@/components/EducationalManual';
|
import { EducationalManual } from '@/components/EducationalManual';
|
||||||
import { Calculator, Info } from 'lucide-react';
|
import { Wind, Box } from 'lucide-react';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Slider } from '@/components/ui/slider';
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
|
|
||||||
export default function CalcCaModule() {
|
export default function CalcCaModule() {
|
||||||
@@ -16,6 +16,7 @@ export default function CalcCaModule() {
|
|||||||
const [l1, setL1] = useState<number>(20);
|
const [l1, setL1] = useState<number>(20);
|
||||||
const [l2, setL2] = useState<number>(40);
|
const [l2, setL2] = useState<number>(40);
|
||||||
const [h, setH] = useState<number>(10);
|
const [h, setH] = useState<number>(10);
|
||||||
|
const [viewMode, setViewMode] = useState<'solid' | 'airflow'>('solid');
|
||||||
|
|
||||||
// Clamp inputs to avoid Infinity or negative values breaking the UI
|
// Clamp inputs to avoid Infinity or negative values breaking the UI
|
||||||
const safeL1 = Math.max(0.1, l1 || 1);
|
const safeL1 = Math.max(0.1, l1 || 1);
|
||||||
@@ -26,128 +27,120 @@ export default function CalcCaModule() {
|
|||||||
const caHigh = getDragCoefficient(safeL1, safeL2, safeH, 'high');
|
const caHigh = getDragCoefficient(safeL1, safeL2, safeH, 'high');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
<div className="flex flex-col lg:flex-row h-full w-full gap-4 p-4 lg:p-6 bg-muted/30">
|
||||||
<header className="flex items-center gap-4 mb-8">
|
{/* Coluna Esquerda: Controles */}
|
||||||
<div className="p-3 bg-primary/10 rounded-xl">
|
<div className="w-full lg:w-80 shrink-0 flex flex-col gap-4 overflow-y-auto pb-8 lg:pb-0">
|
||||||
<Calculator className="w-8 h-8 text-primary" />
|
<Card className="shadow-sm border-border">
|
||||||
</div>
|
<CardHeader className="pb-3 flex flex-row items-start justify-between space-y-0 pr-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-3xl font-bold tracking-tight">{t('nav_calc_ca')}</h1>
|
<CardTitle className="text-lg">Calc_Ca</CardTitle>
|
||||||
<p className="text-muted-foreground">
|
<CardDescription>Cálculo rápido de Coeficiente de Arrasto (Ca)</CardDescription>
|
||||||
Cálculo rápido de Coeficiente de Arrasto (Ca) - NBR 6123:2023, Fig. 4 e 5.
|
</div>
|
||||||
</p>
|
</CardHeader>
|
||||||
</div>
|
<CardContent className="space-y-6">
|
||||||
</header>
|
<div className="space-y-3">
|
||||||
|
<div className="flex justify-between">
|
||||||
|
<label className="text-sm font-medium">L₁ (Largura)</label>
|
||||||
|
<span className="font-mono text-sm">{l1} m</span>
|
||||||
|
</div>
|
||||||
|
<Slider min={1} max={100} step={1} value={[l1]} onValueChange={(v) => setL1(v[0])} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
|
<div className="space-y-3">
|
||||||
{/* Left Column: Inputs & Results */}
|
<div className="flex justify-between">
|
||||||
<div className="lg:col-span-4 space-y-6">
|
<label className="text-sm font-medium">L₂ (Profundidade)</label>
|
||||||
<Card>
|
<span className="font-mono text-sm">{l2} m</span>
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="text-lg">Entrada de Dados</CardTitle>
|
|
||||||
<CardDescription>Dimensões da edificação retangular</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="space-y-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label htmlFor="l1" className="text-sm font-medium leading-none">L₁ (Largura perpendicular ao vento - m)</label>
|
|
||||||
<Input
|
|
||||||
id="l1"
|
|
||||||
type="number"
|
|
||||||
min="0.1"
|
|
||||||
step="0.1"
|
|
||||||
value={l1}
|
|
||||||
onChange={(e) => setL1(parseFloat(e.target.value))}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<Slider min={1} max={100} step={1} value={[l2]} onValueChange={(v) => setL2(v[0])} />
|
||||||
<label htmlFor="l2" className="text-sm font-medium leading-none">L₂ (Profundidade paralela ao vento - m)</label>
|
</div>
|
||||||
<Input
|
|
||||||
id="l2"
|
|
||||||
type="number"
|
|
||||||
min="0.1"
|
|
||||||
step="0.1"
|
|
||||||
value={l2}
|
|
||||||
onChange={(e) => setL2(parseFloat(e.target.value))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label htmlFor="h" className="text-sm font-medium leading-none">H (Altura - m)</label>
|
|
||||||
<Input
|
|
||||||
id="h"
|
|
||||||
type="number"
|
|
||||||
min="0.1"
|
|
||||||
step="0.1"
|
|
||||||
value={h}
|
|
||||||
onChange={(e) => setH(parseFloat(e.target.value))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card className="border-primary/50 shadow-sm bg-primary/5">
|
<div className="space-y-3">
|
||||||
<CardHeader className="pb-2">
|
<div className="flex justify-between">
|
||||||
<CardTitle className="text-lg flex items-center gap-2">
|
<label className="text-sm font-medium">H (Altura)</label>
|
||||||
<Info className="w-5 h-5 text-primary" />
|
<span className="font-mono text-sm">{h} m</span>
|
||||||
Resultados (Ca)
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<div className="space-y-4 mt-2">
|
|
||||||
<div className="flex justify-between items-center p-3 bg-background rounded-lg border">
|
|
||||||
<span className="font-medium text-muted-foreground">Baixa Turbulência</span>
|
|
||||||
<span className="text-2xl font-bold text-primary">{caLow.toFixed(2)}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-between items-center p-3 bg-background rounded-lg border">
|
|
||||||
<span className="font-medium text-muted-foreground">Alta Turbulência</span>
|
|
||||||
<span className="text-2xl font-bold text-primary">{caHigh.toFixed(2)}</span>
|
|
||||||
</div>
|
|
||||||
<div className="text-xs text-muted-foreground flex gap-4 mt-2 px-1">
|
|
||||||
<span>H/L₁ = {(safeH / safeL1).toFixed(2)}</span>
|
|
||||||
<span>L₁/L₂ = {(safeL1 / safeL2).toFixed(2)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
<Slider min={1} max={100} step={1} value={[h]} onValueChange={(v) => setH(v[0])} />
|
||||||
</Card>
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Coluna Central: 3D */}
|
||||||
|
<div className="flex-1 flex flex-col min-h-[500px] lg:min-h-0 bg-background rounded-xl border border-border shadow-sm overflow-hidden relative">
|
||||||
|
<div className="absolute top-4 right-16 z-10">
|
||||||
|
<div className="flex bg-background/80 backdrop-blur-sm border border-border/80 rounded-md shadow-sm p-1">
|
||||||
|
<button
|
||||||
|
onClick={() => setViewMode('solid')}
|
||||||
|
className={`px-3 py-1 text-xs font-medium rounded-sm transition-colors ${viewMode === 'solid' ? 'bg-primary/20 text-primary' : 'text-muted-foreground hover:bg-muted/50'}`}
|
||||||
|
>
|
||||||
|
<Box className="w-3.5 h-3.5 inline-block mr-1.5" />
|
||||||
|
Sólido
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setViewMode('airflow')}
|
||||||
|
className={`px-3 py-1 text-xs font-medium rounded-sm transition-colors ${viewMode === 'airflow' ? 'bg-primary/20 text-primary' : 'text-muted-foreground hover:bg-muted/50'}`}
|
||||||
|
>
|
||||||
|
<Wind className="w-3.5 h-3.5 inline-block mr-1.5" />
|
||||||
|
Fluxo
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="absolute top-4 right-4 z-10">
|
||||||
|
<EducationalManual type="calc_ca" params={{ l1: safeL1, l2: safeL2, h: safeH }} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Center Column: 3D Visualization */}
|
<SceneCanvas
|
||||||
<div className="lg:col-span-4">
|
moduleId="calc_ca"
|
||||||
<Card className="h-full flex flex-col">
|
camera={{ position: [50, 40, 50], fov: 45 }}
|
||||||
<CardHeader className="pb-2 shrink-0">
|
fallback={<div />}
|
||||||
<CardTitle className="text-lg">Visualização 3D</CardTitle>
|
frameloop={viewMode === 'airflow' ? 'always' : 'demand'}
|
||||||
<CardDescription>Proporções dinâmicas</CardDescription>
|
>
|
||||||
</CardHeader>
|
<ambientLight intensity={0.5} />
|
||||||
<CardContent className="flex-1 p-0 min-h-[400px] relative rounded-b-xl overflow-hidden bg-gradient-to-b from-muted/30 to-muted/10">
|
<directionalLight position={[10, 20, 10]} intensity={1} castShadow />
|
||||||
<div className="absolute top-4 right-4 z-10">
|
<Environment preset="city" />
|
||||||
<EducationalManual type="calc_ca" params={{ l1: safeL1, l2: safeL2, h: safeH }} />
|
<ResizableBox3D l1={safeL1} l2={safeL2} h={safeH} viewMode={viewMode} />
|
||||||
</div>
|
<OrbitControls makeDefault minPolarAngle={0} maxPolarAngle={Math.PI / 2 - 0.1} />
|
||||||
<SceneCanvas moduleId="calc_ca" camera={{ position: [50, 40, 50], fov: 45 }} fallback={<div />} frameloop="always">
|
</SceneCanvas>
|
||||||
<ambientLight intensity={0.5} />
|
|
||||||
<directionalLight position={[10, 20, 10]} intensity={1} castShadow />
|
|
||||||
<Environment preset="city" />
|
|
||||||
<ResizableBox3D l1={safeL1} l2={safeL2} h={safeH} />
|
|
||||||
<OrbitControls makeDefault minPolarAngle={0} maxPolarAngle={Math.PI / 2 - 0.1} />
|
|
||||||
</SceneCanvas>
|
|
||||||
<div className="absolute bottom-4 left-4 right-20 text-center text-xs text-muted-foreground pointer-events-none">
|
|
||||||
Arraste para rotacionar, role para aproximar
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right Column: Chart */}
|
<div className="absolute bottom-4 left-4 right-20 text-center text-xs text-muted-foreground pointer-events-none">
|
||||||
<div className="lg:col-span-4">
|
Arraste para rotacionar, role para aproximar
|
||||||
<Card className="h-full">
|
|
||||||
<CardHeader className="pb-2">
|
|
||||||
<CardTitle className="text-lg">Ábaco NBR 6123</CardTitle>
|
|
||||||
<CardDescription>Curvas isotermas aproximadas</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="flex items-center justify-center h-[calc(100%-80px)]">
|
|
||||||
<DragCoefficientChart l1={safeL1} l2={safeL2} h={safeH} caLow={caLow} caHigh={caHigh} />
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Coluna Direita: Resultados */}
|
||||||
|
<div className="w-full lg:w-96 shrink-0 flex flex-col gap-4 overflow-y-auto pb-8 lg:pb-0">
|
||||||
|
<Card className="shadow-sm border-border">
|
||||||
|
<CardHeader className="pb-3">
|
||||||
|
<CardTitle className="text-lg">Resultados (Ca)</CardTitle>
|
||||||
|
<CardDescription>Valores baseados nas tabelas 4 e 5</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="space-y-4">
|
||||||
|
<div className="flex justify-between items-center p-3 bg-background rounded-lg border">
|
||||||
|
<span className="font-medium text-muted-foreground">Baixa Turbulência</span>
|
||||||
|
<span className="text-2xl font-bold text-primary">{caLow.toFixed(2)}</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-between items-center p-3 bg-background rounded-lg border">
|
||||||
|
<span className="font-medium text-muted-foreground">Alta Turbulência</span>
|
||||||
|
<span className="text-2xl font-bold text-primary">{caHigh.toFixed(2)}</span>
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-muted-foreground flex gap-4 mt-2 px-1">
|
||||||
|
<span>H/L₁ = {(safeH / safeL1).toFixed(2)}</span>
|
||||||
|
<span>L₁/L₂ = {(safeL1 / safeL2).toFixed(2)}</span>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{/* Ábaco */}
|
||||||
|
<Card className="shadow-sm border-border flex-1 min-h-[300px]">
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<CardTitle className="text-lg">Ábaco NBR 6123</CardTitle>
|
||||||
|
<CardDescription>Curvas isotermas aproximadas</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="flex items-center justify-center h-[calc(100%-80px)] min-h-[250px]">
|
||||||
|
<DragCoefficientChart l1={safeL1} l2={safeL2} h={safeH} caLow={caLow} caHigh={caHigh} />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user