feat: complete website implementation for Cerca & Tela with 3D simulator and Alambrado focus
This commit is contained in:
commit
419ffe3fc4
46 files changed
+20446
No files matched your search
@@ -0,0 +1,806 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState, useId } from "react";
|
||||
import * as THREE from "three";
|
||||
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
||||
import {
|
||||
Box,
|
||||
RotateCcw,
|
||||
Camera,
|
||||
Layers,
|
||||
Ruler,
|
||||
Palette,
|
||||
Sparkles,
|
||||
MessageCircle,
|
||||
Compass
|
||||
} from "lucide-react";
|
||||
import { generateWhatsAppQuoteUrl } from "@/lib/whatsapp";
|
||||
|
||||
export type FenceType = "alambrado_curvo" | "alambrado_reto" | "alambrado_pvc" | "gradil_3d";
|
||||
export type FenceColor = "galvanizado" | "verde" | "preto" | "cinza";
|
||||
export type FenceHeight = "1.50m" | "1.80m" | "2.00m" | "2.50m" | "3.00m";
|
||||
export type GroundType = "terra" | "grama" | "concreto";
|
||||
export type FenceLayout = "1_lance" | "2_lances" | "4_lances" | "canto_l";
|
||||
|
||||
export default function FenceViewer3D() {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// Foco 100% Alambrado por padrão!
|
||||
const [fenceType, setFenceType] = useState<FenceType>("alambrado_curvo");
|
||||
const [color, setColor] = useState<FenceColor>("galvanizado");
|
||||
const [height, setHeight] = useState<FenceHeight>("2.00m");
|
||||
const [ground, setGround] = useState<GroundType>("grama");
|
||||
const [layout, setLayout] = useState<FenceLayout>("2_lances");
|
||||
const [hasBarbedWire, setHasBarbedWire] = useState<boolean>(true);
|
||||
const [hasConcertina, setHasConcertina] = useState<boolean>(false);
|
||||
const [autoRotate, setAutoRotate] = useState<boolean>(false);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
|
||||
const cepInputId = useId();
|
||||
const [cep, setCep] = useState<string>("");
|
||||
|
||||
// Refs de Three.js
|
||||
const sceneRef = useRef<THREE.Scene | null>(null);
|
||||
const cameraRef = useRef<THREE.PerspectiveCamera | null>(null);
|
||||
const rendererRef = useRef<THREE.WebGLRenderer | null>(null);
|
||||
const controlsRef = useRef<OrbitControls | null>(null);
|
||||
const fenceGroupRef = useRef<THREE.Group | null>(null);
|
||||
const groundMeshRef = useRef<THREE.Mesh | null>(null);
|
||||
|
||||
// Cores de acabamento da tela e mourões
|
||||
const colorMap = {
|
||||
galvanizado: { hex: 0xb5bdc5, name: "Aço Galvanizado a Fogo (Zincado Puro)", metalness: 0.85, roughness: 0.35, postHex: 0x828489 },
|
||||
verde: { hex: 0x225528, name: "Revestido em PVC Verde Musgo (Quadras)", metalness: 0.15, roughness: 0.45, postHex: 0x1f3621 },
|
||||
preto: { hex: 0x1c1e21, name: "Revestido em PVC Preto Nobre", metalness: 0.25, roughness: 0.5, postHex: 0x26282c },
|
||||
cinza: { hex: 0x5a6066, name: "Revestido em PVC Cinza Urbano", metalness: 0.3, roughness: 0.4, postHex: 0x4a4d52 },
|
||||
};
|
||||
|
||||
const numericHeight = parseFloat(height.replace("m", ""));
|
||||
const isCurved = fenceType === "alambrado_curvo";
|
||||
|
||||
// Metragem e cálculo do alambrado
|
||||
const getLayoutDetails = () => {
|
||||
switch (layout) {
|
||||
case "1_lance":
|
||||
return { meters: 2.5, posts: 2, desc: "1 Lance de Alambrado (2,50m)" };
|
||||
case "2_lances":
|
||||
return { meters: 5.0, posts: 3, desc: "2 Lances contínuos (5,00m)" };
|
||||
case "4_lances":
|
||||
return { meters: 10.0, posts: 5, desc: "4 Lances contínuos (10,00m)" };
|
||||
case "canto_l":
|
||||
return { meters: 7.5, posts: 4, desc: "Canto de Esquina 90° (7,50m)" };
|
||||
}
|
||||
};
|
||||
|
||||
const currentLayout = getLayoutDetails();
|
||||
const estimatedRolls = Math.max(1, Math.ceil(currentLayout.meters / 25));
|
||||
const wireLines = numericHeight >= 2.0 ? 4 : 3;
|
||||
const estimatedWireKg = Math.max(2, Math.ceil((currentLayout.meters * wireLines) / 35));
|
||||
const estimatedTensioners = estimatedRolls * wireLines;
|
||||
|
||||
// 1. Inicialização do Three.js
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return;
|
||||
|
||||
const width = containerRef.current.clientWidth;
|
||||
const heightPx = containerRef.current.clientHeight || 560;
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color(0x0a0c0e);
|
||||
scene.fog = new THREE.FogExp2(0x0a0c0e, 0.025);
|
||||
sceneRef.current = scene;
|
||||
|
||||
const camera = new THREE.PerspectiveCamera(40, width / heightPx, 0.1, 100);
|
||||
camera.position.set(4.8, 3.4, 6.2);
|
||||
cameraRef.current = camera;
|
||||
|
||||
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
|
||||
renderer.setSize(width, heightPx);
|
||||
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
||||
renderer.shadowMap.enabled = true;
|
||||
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
||||
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
||||
renderer.toneMappingExposure = 1.15;
|
||||
rendererRef.current = renderer;
|
||||
|
||||
const controls = new OrbitControls(camera, renderer.domElement);
|
||||
controls.enableDamping = true;
|
||||
controls.dampingFactor = 0.05;
|
||||
controls.maxPolarAngle = Math.PI / 2 - 0.02;
|
||||
controls.minDistance = 2.0;
|
||||
controls.maxDistance = 20.0;
|
||||
controls.target.set(0, 1.1, 0);
|
||||
controlsRef.current = controls;
|
||||
|
||||
// Luzes
|
||||
const ambientLight = new THREE.AmbientLight(0xffffff, 0.95);
|
||||
scene.add(ambientLight);
|
||||
|
||||
const sunLight = new THREE.DirectionalLight(0xffffff, 2.5);
|
||||
sunLight.position.set(7, 14, 9);
|
||||
sunLight.castShadow = true;
|
||||
sunLight.shadow.mapSize.width = 2048;
|
||||
sunLight.shadow.mapSize.height = 2048;
|
||||
sunLight.shadow.bias = -0.0005;
|
||||
scene.add(sunLight);
|
||||
|
||||
const fillLight = new THREE.DirectionalLight(0xa3c745, 0.5);
|
||||
fillLight.position.set(-6, 4, -4);
|
||||
scene.add(fillLight);
|
||||
|
||||
const rimLight = new THREE.DirectionalLight(0xffffff, 0.7);
|
||||
rimLight.position.set(0, 6, -8);
|
||||
scene.add(rimLight);
|
||||
|
||||
// Chão
|
||||
const groundGeo = new THREE.PlaneGeometry(40, 40);
|
||||
const groundMat = new THREE.MeshStandardMaterial({
|
||||
color: 0x1a2e16,
|
||||
roughness: 0.95,
|
||||
metalness: 0.05,
|
||||
});
|
||||
const groundMesh = new THREE.Mesh(groundGeo, groundMat);
|
||||
groundMesh.rotation.x = -Math.PI / 2;
|
||||
groundMesh.position.y = 0;
|
||||
groundMesh.receiveShadow = true;
|
||||
scene.add(groundMesh);
|
||||
groundMeshRef.current = groundMesh;
|
||||
|
||||
const gridHelper = new THREE.GridHelper(26, 26, 0x334155, 0x1e293b);
|
||||
gridHelper.position.y = 0.005;
|
||||
scene.add(gridHelper);
|
||||
|
||||
const fenceGroup = new THREE.Group();
|
||||
scene.add(fenceGroup);
|
||||
fenceGroupRef.current = fenceGroup;
|
||||
|
||||
containerRef.current.appendChild(renderer.domElement);
|
||||
setLoading(false);
|
||||
|
||||
let animId: number;
|
||||
const animate = () => {
|
||||
animId = requestAnimationFrame(animate);
|
||||
if (controlsRef.current) {
|
||||
controlsRef.current.autoRotate = autoRotate;
|
||||
controlsRef.current.autoRotateSpeed = 1.2;
|
||||
controlsRef.current.update();
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
};
|
||||
animate();
|
||||
|
||||
const handleResize = () => {
|
||||
if (!containerRef.current || !renderer || !camera) return;
|
||||
const w = containerRef.current.clientWidth;
|
||||
const h = containerRef.current.clientHeight || 560;
|
||||
camera.aspect = w / h;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize(w, h);
|
||||
};
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
cancelAnimationFrame(animId);
|
||||
renderer.dispose();
|
||||
if (containerRef.current && renderer.domElement) {
|
||||
containerRef.current.removeChild(renderer.domElement);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 2. Chão
|
||||
useEffect(() => {
|
||||
if (!groundMeshRef.current) return;
|
||||
const mat = groundMeshRef.current.material as THREE.MeshStandardMaterial;
|
||||
if (ground === "grama") {
|
||||
mat.color.setHex(0x192d16);
|
||||
mat.roughness = 0.95;
|
||||
} else if (ground === "concreto") {
|
||||
mat.color.setHex(0x383b42);
|
||||
mat.roughness = 0.7;
|
||||
} else {
|
||||
mat.color.setHex(0x38291a);
|
||||
mat.roughness = 0.98;
|
||||
}
|
||||
}, [ground]);
|
||||
|
||||
// 3. Renderização Procedural da Tela de Alambrado e Mourões
|
||||
useEffect(() => {
|
||||
if (!fenceGroupRef.current || !sceneRef.current) return;
|
||||
const group = fenceGroupRef.current;
|
||||
|
||||
while (group.children.length > 0) {
|
||||
const obj = group.children[0];
|
||||
group.remove(obj);
|
||||
if ((obj as THREE.Mesh).geometry) (obj as THREE.Mesh).geometry.dispose();
|
||||
}
|
||||
|
||||
const colConfig = colorMap[color];
|
||||
const wireMat = new THREE.MeshStandardMaterial({
|
||||
color: fenceType === "alambrado_pvc" ? 0x225528 : colConfig.hex,
|
||||
metalness: fenceType === "alambrado_pvc" ? 0.15 : colConfig.metalness,
|
||||
roughness: fenceType === "alambrado_pvc" ? 0.45 : colConfig.roughness,
|
||||
});
|
||||
|
||||
// Mourão em concreto pré-moldado ou aço
|
||||
const postMat = new THREE.MeshStandardMaterial({
|
||||
color: fenceType === "alambrado_curvo" ? 0x7a7e85 : colConfig.postHex, // textura mourão de concreto
|
||||
roughness: 0.9,
|
||||
metalness: 0.1,
|
||||
});
|
||||
|
||||
const steelGuideMat = new THREE.MeshStandardMaterial({
|
||||
color: 0x9ca3af,
|
||||
metalness: 0.8,
|
||||
roughness: 0.3,
|
||||
});
|
||||
|
||||
const spanLength = 2.5; // 2,50m entre mourões
|
||||
const h = numericHeight;
|
||||
const isCurved = fenceType === "alambrado_curvo";
|
||||
|
||||
interface PostPos { x: number; z: number; isCorner?: boolean }
|
||||
interface SpanPos { startX: number; startZ: number; endX: number; endZ: number }
|
||||
|
||||
const posts: PostPos[] = [];
|
||||
const spans: SpanPos[] = [];
|
||||
|
||||
if (layout === "1_lance") {
|
||||
posts.push({ x: -spanLength / 2, z: 0 });
|
||||
posts.push({ x: spanLength / 2, z: 0 });
|
||||
spans.push({ startX: -spanLength / 2, startZ: 0, endX: spanLength / 2, endZ: 0 });
|
||||
} else if (layout === "2_lances") {
|
||||
posts.push({ x: -spanLength, z: 0 });
|
||||
posts.push({ x: 0, z: 0 });
|
||||
posts.push({ x: spanLength, z: 0 });
|
||||
spans.push({ startX: -spanLength, startZ: 0, endX: 0, endZ: 0 });
|
||||
spans.push({ startX: 0, startZ: 0, endX: spanLength, endZ: 0 });
|
||||
} else if (layout === "4_lances") {
|
||||
posts.push({ x: -spanLength * 2, z: 0 });
|
||||
posts.push({ x: -spanLength, z: 0 });
|
||||
posts.push({ x: 0, z: 0 });
|
||||
posts.push({ x: spanLength, z: 0 });
|
||||
posts.push({ x: spanLength * 2, z: 0 });
|
||||
spans.push({ startX: -spanLength * 2, startZ: 0, endX: -spanLength, endZ: 0 });
|
||||
spans.push({ startX: -spanLength, startZ: 0, endX: 0, endZ: 0 });
|
||||
spans.push({ startX: 0, startZ: 0, endX: spanLength, endZ: 0 });
|
||||
spans.push({ startX: spanLength, startZ: 0, endX: spanLength * 2, endZ: 0 });
|
||||
} else if (layout === "canto_l") {
|
||||
posts.push({ x: -spanLength, z: 0 });
|
||||
posts.push({ x: 0, z: 0, isCorner: true });
|
||||
posts.push({ x: spanLength, z: 0 });
|
||||
posts.push({ x: spanLength, z: spanLength });
|
||||
spans.push({ startX: -spanLength, startZ: 0, endX: 0, endZ: 0 });
|
||||
spans.push({ startX: 0, startZ: 0, endX: spanLength, endZ: 0 });
|
||||
spans.push({ startX: spanLength, startZ: 0, endX: spanLength, endZ: spanLength });
|
||||
}
|
||||
|
||||
// --- MOURÕES (CONCRETO 10x10cm OU TUBULAR METÁLICO) ---
|
||||
posts.forEach((p, idx) => {
|
||||
const postHeight = h + (isCurved ? 0.45 : 0.05);
|
||||
|
||||
// Mourão de Concreto ou Aço
|
||||
const postGeo = new THREE.BoxGeometry(0.10, postHeight, 0.10);
|
||||
const postMesh = new THREE.Mesh(postGeo, postMat);
|
||||
postMesh.position.set(p.x, postHeight / 2, p.z);
|
||||
postMesh.castShadow = true;
|
||||
postMesh.receiveShadow = true;
|
||||
group.add(postMesh);
|
||||
|
||||
// Base / sapata de concreto no solo
|
||||
const baseGeo = new THREE.CylinderGeometry(0.14, 0.16, 0.08, 12);
|
||||
const baseMesh = new THREE.Mesh(baseGeo, postMat);
|
||||
baseMesh.position.set(p.x, 0.04, p.z);
|
||||
baseMesh.receiveShadow = true;
|
||||
group.add(baseMesh);
|
||||
|
||||
// Se for Mourão Curvo (Braço a 45° no topo com 3 fios de arame farpado)
|
||||
if (isCurved) {
|
||||
const armLength = 0.50;
|
||||
const armGeo = new THREE.BoxGeometry(0.08, armLength, 0.08);
|
||||
const armMesh = new THREE.Mesh(armGeo, postMat);
|
||||
armMesh.rotation.z = -Math.PI / 4;
|
||||
armMesh.position.set(p.x + (armLength * Math.sin(Math.PI / 4)) / 2, postHeight + 0.12, p.z);
|
||||
armMesh.castShadow = true;
|
||||
group.add(armMesh);
|
||||
}
|
||||
|
||||
// Escora diagonal nos mourões de ponta / canto para dar firmeza ao alambrado
|
||||
if (idx === 0 || idx === posts.length - 1 || p.isCorner) {
|
||||
const braceLength = h * 0.95;
|
||||
const braceGeo = new THREE.BoxGeometry(0.08, braceLength, 0.08);
|
||||
const braceMesh = new THREE.Mesh(braceGeo, postMat);
|
||||
braceMesh.rotation.z = idx === 0 ? -Math.PI / 4.5 : Math.PI / 4.5;
|
||||
braceMesh.position.set(idx === 0 ? p.x + 0.55 : p.x - 0.55, h * 0.4, p.z);
|
||||
braceMesh.castShadow = true;
|
||||
group.add(braceMesh);
|
||||
}
|
||||
});
|
||||
|
||||
// --- LINHAS HORIZONTAIS DE ARAME GUIA (TENSIONADORES) ---
|
||||
// Passam por todos os mourões
|
||||
const totalLines = h >= 2.0 ? 4 : 3;
|
||||
spans.forEach((span) => {
|
||||
const dx = span.endX - span.startX;
|
||||
const dz = span.endZ - span.startZ;
|
||||
const len = Math.sqrt(dx * dx + dz * dz);
|
||||
const angle = Math.atan2(dz, dx);
|
||||
const cx = (span.startX + span.endX) / 2;
|
||||
const cz = (span.startZ + span.endZ) / 2;
|
||||
|
||||
// Fiadas de arame guia
|
||||
for (let l = 1; l <= totalLines; l++) {
|
||||
const wireY = (h / (totalLines + 0.5)) * l;
|
||||
const guideGeo = new THREE.CylinderGeometry(0.003, 0.003, len, 6);
|
||||
const guideMesh = new THREE.Mesh(guideGeo, steelGuideMat);
|
||||
guideMesh.rotation.z = Math.PI / 2;
|
||||
guideMesh.rotation.y = -angle;
|
||||
guideMesh.position.set(cx, wireY, cz);
|
||||
group.add(guideMesh);
|
||||
}
|
||||
|
||||
// Arames farpados no topo (se for mourão curvo)
|
||||
if (isCurved && hasBarbedWire) {
|
||||
for (let b = 1; b <= 3; b++) {
|
||||
const barbedGeo = new THREE.CylinderGeometry(0.0025, 0.0025, len, 6);
|
||||
const barbedMesh = new THREE.Mesh(barbedGeo, steelGuideMat);
|
||||
barbedMesh.rotation.z = Math.PI / 2;
|
||||
barbedMesh.rotation.y = -angle;
|
||||
barbedMesh.position.set(cx + b * 0.09, h + 0.15 + b * 0.10, cz);
|
||||
group.add(barbedMesh);
|
||||
}
|
||||
}
|
||||
|
||||
// Concertina opcional no topo
|
||||
if (hasConcertina) {
|
||||
const concertinaRadius = 0.18;
|
||||
const coils = Math.floor(len * 5.5);
|
||||
const step = len / coils;
|
||||
|
||||
for (let k = 0; k < coils; k++) {
|
||||
const torusGeo = new THREE.TorusGeometry(concertinaRadius, 0.0028, 6, 18);
|
||||
const torusMesh = new THREE.Mesh(torusGeo, steelGuideMat);
|
||||
torusMesh.rotation.y = -angle + Math.PI / 2;
|
||||
const px = span.startX + Math.cos(angle) * (k * step + step / 2);
|
||||
const pz = span.startZ + Math.sin(angle) * (k * step + step / 2);
|
||||
torusMesh.position.set(px, h + concertinaRadius + 0.02, pz);
|
||||
torusMesh.castShadow = true;
|
||||
group.add(torusMesh);
|
||||
}
|
||||
}
|
||||
|
||||
// --- TELA DE ALAMBRADO TRANÇADA (MALHA LOSANGULAR REAL) ---
|
||||
const diamondSize = 0.06; // malha ~50mm / 2 polegadas
|
||||
const cols = Math.floor(len / diamondSize);
|
||||
const rows = Math.floor(h / diamondSize);
|
||||
const strandGeo = new THREE.CylinderGeometry(0.0018, 0.0018, diamondSize * 1.414, 5);
|
||||
|
||||
const spanGroup = new THREE.Group();
|
||||
spanGroup.position.set(cx, 0, cz);
|
||||
spanGroup.rotation.y = -angle;
|
||||
|
||||
for (let r = 0; r < rows; r++) {
|
||||
const y = r * diamondSize + diamondSize / 2;
|
||||
for (let c = -cols / 2; c < cols / 2; c++) {
|
||||
const x = c * diamondSize + diamondSize / 2;
|
||||
|
||||
// Diagonal 1 (45°)
|
||||
const wire1 = new THREE.Mesh(strandGeo, wireMat);
|
||||
wire1.rotation.z = Math.PI / 4;
|
||||
wire1.position.set(x, y, 0.002);
|
||||
spanGroup.add(wire1);
|
||||
|
||||
// Diagonal 2 (-45°)
|
||||
const wire2 = new THREE.Mesh(strandGeo, wireMat);
|
||||
wire2.rotation.z = -Math.PI / 4;
|
||||
wire2.position.set(x, y, -0.002);
|
||||
spanGroup.add(wire2);
|
||||
}
|
||||
}
|
||||
|
||||
group.add(spanGroup);
|
||||
});
|
||||
|
||||
}, [fenceType, color, height, layout, hasBarbedWire, hasConcertina]);
|
||||
|
||||
const setCameraView = (type: "geral" | "detalhe" | "topo") => {
|
||||
if (!cameraRef.current || !controlsRef.current) return;
|
||||
const cam = cameraRef.current;
|
||||
const ctrl = controlsRef.current;
|
||||
|
||||
switch (type) {
|
||||
case "geral":
|
||||
cam.position.set(4.8, 3.4, 6.2);
|
||||
ctrl.target.set(0, 1.1, 0);
|
||||
break;
|
||||
case "detalhe":
|
||||
cam.position.set(0.8, 1.4, 1.5);
|
||||
ctrl.target.set(0, 1.2, 0);
|
||||
break;
|
||||
case "topo":
|
||||
cam.position.set(0.1, 8.0, 0.1);
|
||||
ctrl.target.set(0, 0, 0);
|
||||
break;
|
||||
}
|
||||
ctrl.update();
|
||||
};
|
||||
|
||||
const whatsappUrl = generateWhatsAppQuoteUrl({
|
||||
productType: fenceType,
|
||||
productName: fenceType === "alambrado_curvo"
|
||||
? "Tela de Alambrado com Mourão de Concreto Curvo (+ Arame Farpado)"
|
||||
: fenceType === "alambrado_pvc"
|
||||
? "Tela de Alambrado Revestida em PVC Verde (Quadras)"
|
||||
: fenceType === "alambrado_reto"
|
||||
? "Tela de Alambrado Galvanizada com Mourão Reto"
|
||||
: "Gradil 3D Eletrosoldado",
|
||||
linearMeters: currentLayout.meters,
|
||||
height,
|
||||
finish: colorMap[color].name,
|
||||
postType: fenceType === "alambrado_curvo" ? "Mourão de Concreto com Ponta Curva" : "Mourão de Concreto / Aço Reto",
|
||||
meshSize: "2 Polegadas (50mm)",
|
||||
wireGauge: "BWG 12 (2,77mm) ou BWG 10",
|
||||
cepOrCity: cep || "A Definir",
|
||||
estimatedRolls,
|
||||
estimatedPosts: currentLayout.posts,
|
||||
estimatedWireKg,
|
||||
estimatedTensioners,
|
||||
notes: `Simulação 3D no site: ${hasBarbedWire ? "Com 3 fios de arame farpado no topo" : "Sem arame farpado"}${hasConcertina ? " + Concertina" : ""}.`,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="w-full bg-[#0d0e12] border border-zinc-800 rounded-2xl overflow-hidden shadow-2xl">
|
||||
|
||||
{/* Barra de Título Superior do Simulador 3D */}
|
||||
<div className="bg-[#121419] px-4 py-3 sm:px-6 border-b border-zinc-800 flex flex-wrap items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-9 h-9 rounded-lg bg-[#a3c745]/15 text-[#a3c745] flex items-center justify-center border border-[#a3c745]/30">
|
||||
<Box className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-white font-heading font-bold text-sm sm:text-base">
|
||||
Studio 3D: Simulador de Telas de Alambrado & Mourões
|
||||
</span>
|
||||
<span className="px-2 py-0.5 rounded text-[10px] font-bold bg-[#a3c745] text-black">
|
||||
Foco em Alambrado
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-zinc-400">
|
||||
Gire em 360°, teste mourões retos ou curvos com arame farpado e receba a lista de rolos.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Câmera Rápida */}
|
||||
<div className="flex items-center gap-2 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setCameraView("geral")}
|
||||
className="px-2.5 py-1.5 rounded-lg bg-zinc-900 border border-zinc-800 text-zinc-300 hover:text-white hover:bg-zinc-800 transition-colors"
|
||||
>
|
||||
Visão Geral
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setCameraView("detalhe")}
|
||||
className="px-2.5 py-1.5 rounded-lg bg-zinc-900 border border-zinc-800 text-zinc-300 hover:text-white hover:bg-zinc-800 transition-colors hidden sm:inline-block"
|
||||
>
|
||||
Detalhe da Malha
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setAutoRotate(!autoRotate)}
|
||||
className={`p-1.5 rounded-lg border transition-colors ${
|
||||
autoRotate ? "bg-[#a3c745] text-black border-[#a3c745]" : "bg-zinc-900 text-zinc-400 border-zinc-800 hover:text-white"
|
||||
}`}
|
||||
title="Giro Automático 360°"
|
||||
>
|
||||
<RotateCcw className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Grid: Canvas 3D (8 cols) + Controles de Alambrado (4 cols) */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 min-h-[580px]">
|
||||
|
||||
{/* Canvas 3D */}
|
||||
<div className="lg:col-span-8 relative bg-[#07080a] overflow-hidden flex flex-col justify-between">
|
||||
<div ref={containerRef} className="w-full h-[380px] sm:h-[480px] lg:h-[580px] cursor-grab active:cursor-grabbing" />
|
||||
|
||||
{/* Dica */}
|
||||
<div className="absolute top-4 left-4 pointer-events-none flex items-center gap-2 px-3 py-1.5 rounded-lg bg-black/60 backdrop-blur-md border border-zinc-800/80 text-[11px] text-zinc-300">
|
||||
<Compass className="w-3.5 h-3.5 text-[#a3c745]" />
|
||||
<span>Gire 360° • Aproxime para ver a malha losangular e mourões de concreto</span>
|
||||
</div>
|
||||
|
||||
{/* Badge Inferior */}
|
||||
<div className="absolute bottom-4 left-4 right-4 pointer-events-none flex flex-wrap items-center justify-between gap-2">
|
||||
<div className="bg-black/80 backdrop-blur-md px-3.5 py-2 rounded-xl border border-zinc-800 text-xs text-zinc-200">
|
||||
<span className="text-[#a3c745] font-bold block">{currentLayout.desc}</span>
|
||||
<span className="text-[11px] text-zinc-400">
|
||||
Altura: {height} • Mourão: {isCurved ? "Ponta Curva com Arame Farpado" : "Reto"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Alternador de Solo */}
|
||||
<div className="pointer-events-auto flex items-center gap-1 bg-black/80 backdrop-blur-md p-1 rounded-xl border border-zinc-800 text-[11px]">
|
||||
<span className="text-zinc-500 px-2">Solo:</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setGround("terra")}
|
||||
className={`px-2.5 py-1 rounded-lg transition-all ${
|
||||
ground === "terra" ? "bg-[#a3c745] text-black font-bold" : "text-zinc-400 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
Terra
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setGround("grama")}
|
||||
className={`px-2.5 py-1 rounded-lg transition-all ${
|
||||
ground === "grama" ? "bg-[#a3c745] text-black font-bold" : "text-zinc-400 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
Grama
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setGround("concreto")}
|
||||
className={`px-2.5 py-1 rounded-lg transition-all ${
|
||||
ground === "concreto" ? "bg-[#a3c745] text-black font-bold" : "text-zinc-400 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
Concreto
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Controles Específicos para Alambrado */}
|
||||
<div className="lg:col-span-4 bg-[#111317] border-t lg:border-t-0 lg:border-l border-zinc-800 p-5 sm:p-6 space-y-5 flex flex-col justify-between overflow-y-auto max-h-[580px]">
|
||||
|
||||
<div className="space-y-5">
|
||||
|
||||
{/* 1. Tipo de Alambrado & Mourão */}
|
||||
<div>
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-[#a3c745] block mb-2 flex items-center gap-1.5">
|
||||
<Layers className="w-3.5 h-3.5" /> 1. Tipo de Alambrado & Mourão
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => { setFenceType("alambrado_curvo"); setHasBarbedWire(true); }}
|
||||
className={`p-2.5 rounded-xl border text-left transition-all ${
|
||||
fenceType === "alambrado_curvo"
|
||||
? "bg-[#181b22] border-[#a3c745] text-white ring-1 ring-[#a3c745]"
|
||||
: "bg-zinc-900/60 border-zinc-800 text-zinc-400 hover:bg-zinc-800 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-heading font-bold text-xs text-white">Mourão Curvo</span>
|
||||
<span className="text-[10px] text-zinc-400 block mt-0.5">+ 3 fios farpados</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFenceType("alambrado_reto")}
|
||||
className={`p-2.5 rounded-xl border text-left transition-all ${
|
||||
fenceType === "alambrado_reto"
|
||||
? "bg-[#181b22] border-[#a3c745] text-white ring-1 ring-[#a3c745]"
|
||||
: "bg-zinc-900/60 border-zinc-800 text-zinc-400 hover:bg-zinc-800 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-heading font-bold text-xs text-white">Mourão Reto</span>
|
||||
<span className="text-[10px] text-zinc-400 block mt-0.5">Padrão Chácaras</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFenceType("alambrado_pvc")}
|
||||
className={`p-2.5 rounded-xl border text-left transition-all ${
|
||||
fenceType === "alambrado_pvc"
|
||||
? "bg-[#181b22] border-[#a3c745] text-white ring-1 ring-[#a3c745]"
|
||||
: "bg-zinc-900/60 border-zinc-800 text-zinc-400 hover:bg-zinc-800 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-heading font-bold text-xs text-white">PVC Verde</span>
|
||||
<span className="text-[10px] text-zinc-400 block mt-0.5">Especial Quadras</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFenceType("gradil_3d")}
|
||||
className={`p-2.5 rounded-xl border text-left transition-all ${
|
||||
fenceType === "gradil_3d"
|
||||
? "bg-[#181b22] border-[#a3c745] text-white ring-1 ring-[#a3c745]"
|
||||
: "bg-zinc-900/60 border-zinc-800 text-zinc-400 hover:bg-zinc-800 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-heading font-bold text-xs text-white">Gradil 3D</span>
|
||||
<span className="text-[10px] text-zinc-400 block mt-0.5">Complementar</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 2. Altura do Alambrado */}
|
||||
<div>
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-[#a3c745] block mb-2 flex items-center gap-1.5">
|
||||
<Ruler className="w-3.5 h-3.5" /> 2. Altura da Tela
|
||||
</label>
|
||||
<div className="grid grid-cols-5 gap-1.5">
|
||||
{(["1.50m", "1.80m", "2.00m", "2.50m", "3.00m"] as FenceHeight[]).map((h) => (
|
||||
<button
|
||||
key={h}
|
||||
type="button"
|
||||
onClick={() => setHeight(h)}
|
||||
className={`py-2 rounded-lg border text-center text-xs font-heading font-bold transition-all ${
|
||||
height === h
|
||||
? "bg-[#181b22] border-[#a3c745] text-[#a3c745] ring-1 ring-[#a3c745]"
|
||||
: "bg-zinc-900/60 border-zinc-800 text-zinc-400 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
{h}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Acabamento do Arame */}
|
||||
<div>
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-[#a3c745] block mb-2 flex items-center gap-1.5">
|
||||
<Palette className="w-3.5 h-3.5" /> 3. Acabamento do Arame
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{[
|
||||
{ id: "galvanizado", label: "Galvanizado a Fogo", hex: "bg-zinc-300" },
|
||||
{ id: "verde", label: "Revestido em PVC Verde", hex: "bg-emerald-800" },
|
||||
{ id: "preto", label: "Revestido em PVC Preto", hex: "bg-zinc-950 border border-zinc-700" },
|
||||
{ id: "cinza", label: "Revestido em PVC Cinza", hex: "bg-zinc-600" },
|
||||
].map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
type="button"
|
||||
onClick={() => setColor(c.id as FenceColor)}
|
||||
className={`flex items-center gap-2 p-2 rounded-xl border text-left transition-all ${
|
||||
color === c.id
|
||||
? "bg-[#181b22] border-[#a3c745] text-white ring-1 ring-[#a3c745]"
|
||||
: "bg-zinc-900/60 border-zinc-800 text-zinc-400 hover:text-white"
|
||||
}`}
|
||||
>
|
||||
<span className={`w-3.5 h-3.5 rounded-full shrink-0 ${c.hex}`} />
|
||||
<span className="text-[11px] font-medium truncate">{c.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4. Módulos na Prévia 3D */}
|
||||
<div>
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-zinc-400 block mb-2">
|
||||
4. Extensão na Simulação:
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setLayout("1_lance")}
|
||||
className={`p-2 rounded-lg border text-left ${
|
||||
layout === "1_lance" ? "bg-[#181b22] border-[#a3c745] text-white" : "bg-zinc-900/60 border-zinc-800 text-zinc-400"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-bold">1 Lance (2,5m)</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setLayout("2_lances")}
|
||||
className={`p-2 rounded-lg border text-left ${
|
||||
layout === "2_lances" ? "bg-[#181b22] border-[#a3c745] text-white" : "bg-zinc-900/60 border-zinc-800 text-zinc-400"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-bold">2 Lances (5,0m)</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setLayout("4_lances")}
|
||||
className={`p-2 rounded-lg border text-left ${
|
||||
layout === "4_lances" ? "bg-[#181b22] border-[#a3c745] text-white" : "bg-zinc-900/60 border-zinc-800 text-zinc-400"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-bold">4 Lances (10m)</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setLayout("canto_l")}
|
||||
className={`p-2 rounded-lg border text-left ${
|
||||
layout === "canto_l" ? "bg-[#181b22] border-[#a3c745] text-white" : "bg-zinc-900/60 border-zinc-800 text-zinc-400"
|
||||
}`}
|
||||
>
|
||||
<span className="block font-bold">Canto 90° (7,5m)</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Opcionais de Segurança */}
|
||||
<div className="pt-2 border-t border-zinc-800 space-y-2">
|
||||
{isCurved && (
|
||||
<label className="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={hasBarbedWire}
|
||||
onChange={(e) => setHasBarbedWire(e.target.checked)}
|
||||
className="w-4 h-4 rounded accent-[#a3c745] bg-zinc-900 border-zinc-700"
|
||||
/>
|
||||
<span className="text-xs text-zinc-300">
|
||||
Incluir 3 fiadas de arame farpado no topo
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
|
||||
<label className="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={hasConcertina}
|
||||
onChange={(e) => setHasConcertina(e.target.checked)}
|
||||
className="w-4 h-4 rounded accent-[#a3c745] bg-zinc-900 border-zinc-700"
|
||||
/>
|
||||
<span className="text-xs text-zinc-300">
|
||||
Adicionar Concertina Perimetral
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Resumo de Peças para Alambrado */}
|
||||
<div className="pt-4 border-t border-zinc-800 space-y-3">
|
||||
<div className="bg-zinc-900/90 p-3 rounded-xl border border-zinc-800 space-y-1 text-xs">
|
||||
<div className="flex justify-between text-zinc-400">
|
||||
<span>Extensão visualizada:</span>
|
||||
<strong className="text-white">{currentLayout.meters}m lineares</strong>
|
||||
</div>
|
||||
<div className="flex justify-between text-zinc-400">
|
||||
<span>Mourões de Concreto/Aço:</span>
|
||||
<strong className="text-[#a3c745]">{currentLayout.posts} unidades</strong>
|
||||
</div>
|
||||
<div className="flex justify-between text-zinc-400">
|
||||
<span>Arame Guia / Tensionador:</span>
|
||||
<strong className="text-white">~{estimatedWireKg} kg</strong>
|
||||
</div>
|
||||
<div className="flex justify-between text-zinc-400">
|
||||
<span>Catracas Esticadoras:</span>
|
||||
<strong className="text-white">{estimatedTensioners} un</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor={cepInputId} className="text-[11px] text-zinc-400 block mb-1">
|
||||
CEP para cálculo do frete:
|
||||
</label>
|
||||
<input
|
||||
id={cepInputId}
|
||||
type="text"
|
||||
placeholder="Ex: 18000-000 ou sua cidade"
|
||||
value={cep}
|
||||
onChange={(e) => setCep(e.target.value)}
|
||||
className="w-full bg-zinc-900 border border-zinc-700/80 rounded-lg px-3 py-1.5 text-xs text-white placeholder-zinc-500 focus:outline-none focus:border-[#a3c745]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<a
|
||||
href={whatsappUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-full flex items-center justify-center gap-2 bg-[#a3c745] hover:bg-[#b5db50] text-black font-heading font-bold text-xs sm:text-sm py-3.5 px-4 rounded-xl shadow-lg shadow-[#a3c745]/20 transition-all text-center pulse-glow"
|
||||
>
|
||||
<MessageCircle className="w-4 h-4 fill-black shrink-0" />
|
||||
<span>Solicitar Orçamento de Alambrado no WhatsApp</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user