feat(FenceViewer3D): render solid visible diamond chain-link wire lattice and 3D rolled fence bundle
This commit is contained in:
1 parent
3927630317
commit
ad34497813
4 files changed
+224
-125
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
+224
-125
@@ -13,7 +13,7 @@ import {
|
||||
MessageCircle,
|
||||
Compass,
|
||||
AlertTriangle,
|
||||
CheckCircle2
|
||||
Package
|
||||
} from "lucide-react";
|
||||
import { generateWhatsAppQuoteUrl } from "@/lib/whatsapp";
|
||||
|
||||
@@ -23,47 +23,56 @@ 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";
|
||||
|
||||
// Gerador de textura procedural perfeita para a malha losangular de Alambrado (Chain Link)
|
||||
function createChainLinkTexture(colorHex: string, wireWidth: number = 3): THREE.CanvasTexture {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 128;
|
||||
canvas.height = 128;
|
||||
const ctx = canvas.getContext("2d");
|
||||
// Construtor procedural de geometria de arames losangulares entrelaçados (Chain Link 45°)
|
||||
function buildChainLinkGeometry(spanLength: number, height: number, spacing: number = 0.08): THREE.BufferGeometry {
|
||||
const positions: number[] = [];
|
||||
const s = spacing;
|
||||
const L = spanLength;
|
||||
const H = height;
|
||||
|
||||
if (ctx) {
|
||||
ctx.clearRect(0, 0, 128, 128);
|
||||
// Família 1: Linhas diagonais a +45° (y - x = c)
|
||||
for (let c = -L; c <= H + s; c += s) {
|
||||
const pts: [number, number][] = [];
|
||||
if (c >= 0 && c <= H) pts.push([0, c]);
|
||||
if (L + c >= 0 && L + c <= H) pts.push([L, L + c]);
|
||||
if (-c >= 0 && -c <= L) pts.push([-c, 0]);
|
||||
if (H - c >= 0 && H - c <= L) pts.push([H - c, H]);
|
||||
|
||||
// Linha do arame com efeito metálico / degradê
|
||||
ctx.strokeStyle = colorHex;
|
||||
ctx.lineWidth = wireWidth;
|
||||
ctx.lineCap = "round";
|
||||
ctx.lineJoin = "round";
|
||||
|
||||
// Desenha losango central
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(64, 0);
|
||||
ctx.lineTo(128, 64);
|
||||
ctx.lineTo(64, 128);
|
||||
ctx.lineTo(0, 64);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
|
||||
// Linhas diagonais cruzadas nos 4 cantos para fechar o entrelaçamento contínuo
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, 0); ctx.lineTo(64, 64);
|
||||
ctx.moveTo(128, 0); ctx.lineTo(64, 64);
|
||||
ctx.moveTo(0, 128); ctx.lineTo(64, 64);
|
||||
ctx.moveTo(128, 128); ctx.lineTo(64, 64);
|
||||
ctx.stroke();
|
||||
const unique: [number, number][] = [];
|
||||
for (const p of pts) {
|
||||
if (!unique.some(u => Math.abs(u[0] - p[0]) < 1e-4 && Math.abs(u[1] - p[1]) < 1e-4)) {
|
||||
unique.push(p);
|
||||
}
|
||||
}
|
||||
if (unique.length === 2) {
|
||||
positions.push(unique[0][0] - L / 2, unique[0][1], 0.002);
|
||||
positions.push(unique[1][0] - L / 2, unique[1][1], 0.002);
|
||||
}
|
||||
}
|
||||
|
||||
const texture = new THREE.CanvasTexture(canvas);
|
||||
texture.wrapS = THREE.RepeatWrapping;
|
||||
texture.wrapT = THREE.RepeatWrapping;
|
||||
texture.generateMipmaps = true;
|
||||
texture.minFilter = THREE.LinearMipmapLinearFilter;
|
||||
texture.magFilter = THREE.LinearFilter;
|
||||
return texture;
|
||||
// Família 2: Linhas diagonais a -45° (y + x = c)
|
||||
for (let c = 0; c <= L + H + s; c += s) {
|
||||
const pts: [number, number][] = [];
|
||||
if (c >= 0 && c <= H) pts.push([0, c]);
|
||||
if (c - L >= 0 && c - L <= H) pts.push([L, c - L]);
|
||||
if (c >= 0 && c <= L) pts.push([c, 0]);
|
||||
if (c - H >= 0 && c - H <= L) pts.push([c - H, H]);
|
||||
|
||||
const unique: [number, number][] = [];
|
||||
for (const p of pts) {
|
||||
if (!unique.some(u => Math.abs(u[0] - p[0]) < 1e-4 && Math.abs(u[1] - p[1]) < 1e-4)) {
|
||||
unique.push(p);
|
||||
}
|
||||
}
|
||||
if (unique.length === 2) {
|
||||
positions.push(unique[0][0] - L / 2, unique[0][1], -0.002);
|
||||
positions.push(unique[1][0] - L / 2, unique[1][1], -0.002);
|
||||
}
|
||||
}
|
||||
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
|
||||
return geometry;
|
||||
}
|
||||
|
||||
export default function FenceViewer3D() {
|
||||
@@ -73,14 +82,14 @@ export default function FenceViewer3D() {
|
||||
// Estados
|
||||
const [fenceType, setFenceType] = useState<FenceType>("alambrado_curvo");
|
||||
const [color, setColor] = useState<FenceColor>("galvanizado");
|
||||
const [height, setHeight] = useState<FenceHeight>("2.00m");
|
||||
const [height, setHeight] = useState<FenceHeight>("1.80m");
|
||||
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 [showRoll, setShowRoll] = useState<boolean>(true);
|
||||
const [autoRotate, setAutoRotate] = useState<boolean>(false);
|
||||
const [webGLError, setWebGLError] = useState<boolean>(false);
|
||||
const [isLoaded, setIsLoaded] = useState<boolean>(false);
|
||||
|
||||
const cepInputId = useId();
|
||||
const [cep, setCep] = useState<string>("");
|
||||
@@ -91,36 +100,32 @@ export default function FenceViewer3D() {
|
||||
// Mapeamento de cores
|
||||
const colorMap = {
|
||||
galvanizado: {
|
||||
hex: "#b8c0c8",
|
||||
threeHex: 0xb8c0c8,
|
||||
hex: "#cbd5e1",
|
||||
threeHex: 0xd1d5db,
|
||||
name: "Aço Galvanizado a Fogo (Zincado)",
|
||||
metalness: 0.85,
|
||||
roughness: 0.35,
|
||||
postHex: 0x858990
|
||||
postHex: 0x8a8e96,
|
||||
textureUrl: "/images/chainlink-galvanizado.png"
|
||||
},
|
||||
verde: {
|
||||
hex: "#225528",
|
||||
threeHex: 0x225528,
|
||||
hex: "#22c55e",
|
||||
threeHex: 0x22c55e,
|
||||
name: "Revestido em PVC Verde Musgo (Quadras)",
|
||||
metalness: 0.15,
|
||||
roughness: 0.45,
|
||||
postHex: 0x1f3621
|
||||
postHex: 0x1f3621,
|
||||
textureUrl: "/images/chainlink-pvc-verde.png"
|
||||
},
|
||||
preto: {
|
||||
hex: "#1d1f22",
|
||||
threeHex: 0x1d1f22,
|
||||
hex: "#334155",
|
||||
threeHex: 0x334155,
|
||||
name: "Revestido em PVC Preto Nobre",
|
||||
metalness: 0.25,
|
||||
roughness: 0.5,
|
||||
postHex: 0x24272c
|
||||
postHex: 0x24272c,
|
||||
textureUrl: "/images/chainlink-preto.png"
|
||||
},
|
||||
cinza: {
|
||||
hex: "#5c6269",
|
||||
threeHex: 0x5c6269,
|
||||
hex: "#94a3b8",
|
||||
threeHex: 0x94a3b8,
|
||||
name: "Revestido em PVC Cinza Urbano",
|
||||
metalness: 0.3,
|
||||
roughness: 0.4,
|
||||
postHex: 0x484b50
|
||||
postHex: 0x484b50,
|
||||
textureUrl: "/images/chainlink-galvanizado.png"
|
||||
},
|
||||
};
|
||||
|
||||
@@ -148,10 +153,9 @@ export default function FenceViewer3D() {
|
||||
const fenceGroupRef = useRef<THREE.Group | null>(null);
|
||||
const groundMeshRef = useRef<THREE.Mesh | null>(null);
|
||||
|
||||
// 1. Inicialização do Three.js (com reutilização segura do Canvas sem duplicação)
|
||||
// 1. Inicialização do Three.js
|
||||
useEffect(() => {
|
||||
if (!canvasRef.current || !containerRef.current) return;
|
||||
|
||||
const canvas = canvasRef.current;
|
||||
let renderer: THREE.WebGLRenderer;
|
||||
|
||||
@@ -163,7 +167,7 @@ export default function FenceViewer3D() {
|
||||
powerPreference: "high-performance",
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("WebGL não suportado ou falhou na inicialização:", e);
|
||||
console.warn("WebGL não suportado:", e);
|
||||
setWebGLError(true);
|
||||
return;
|
||||
}
|
||||
@@ -176,7 +180,7 @@ export default function FenceViewer3D() {
|
||||
renderer.shadowMap.enabled = true;
|
||||
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
||||
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
||||
renderer.toneMappingExposure = 1.2;
|
||||
renderer.toneMappingExposure = 1.25;
|
||||
rendererRef.current = renderer;
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
@@ -185,7 +189,7 @@ export default function FenceViewer3D() {
|
||||
sceneRef.current = scene;
|
||||
|
||||
const camera = new THREE.PerspectiveCamera(40, width / heightPx, 0.1, 100);
|
||||
camera.position.set(4.8, 3.4, 6.2);
|
||||
camera.position.set(4.8, 3.2, 5.8);
|
||||
cameraRef.current = camera;
|
||||
|
||||
const controls = new OrbitControls(camera, canvas);
|
||||
@@ -194,11 +198,11 @@ export default function FenceViewer3D() {
|
||||
controls.maxPolarAngle = Math.PI / 2 - 0.02;
|
||||
controls.minDistance = 2.0;
|
||||
controls.maxDistance = 20.0;
|
||||
controls.target.set(0, 1.1, 0);
|
||||
controls.target.set(0, 1.0, 0);
|
||||
controlsRef.current = controls;
|
||||
|
||||
// Luzes
|
||||
const ambientLight = new THREE.AmbientLight(0xffffff, 1.0);
|
||||
// Iluminação
|
||||
const ambientLight = new THREE.AmbientLight(0xffffff, 1.2);
|
||||
scene.add(ambientLight);
|
||||
|
||||
const sunLight = new THREE.DirectionalLight(0xffffff, 2.5);
|
||||
@@ -206,10 +210,9 @@ export default function FenceViewer3D() {
|
||||
sunLight.castShadow = true;
|
||||
sunLight.shadow.mapSize.width = 1024;
|
||||
sunLight.shadow.mapSize.height = 1024;
|
||||
sunLight.shadow.bias = -0.0005;
|
||||
scene.add(sunLight);
|
||||
|
||||
const fillLight = new THREE.DirectionalLight(0xa3c745, 0.4);
|
||||
const fillLight = new THREE.DirectionalLight(0xa3c745, 0.5);
|
||||
fillLight.position.set(-6, 4, -4);
|
||||
scene.add(fillLight);
|
||||
|
||||
@@ -235,9 +238,6 @@ export default function FenceViewer3D() {
|
||||
scene.add(fenceGroup);
|
||||
fenceGroupRef.current = fenceGroup;
|
||||
|
||||
setIsLoaded(true);
|
||||
|
||||
// Loop
|
||||
let animId: number;
|
||||
const animate = () => {
|
||||
animId = requestAnimationFrame(animate);
|
||||
@@ -284,7 +284,7 @@ export default function FenceViewer3D() {
|
||||
}
|
||||
}, [ground]);
|
||||
|
||||
// 3. Renderização da Cerca em 3D
|
||||
// 3. Renderização da Cerca em 3D + Rolo de Alambrado
|
||||
useEffect(() => {
|
||||
if (!fenceGroupRef.current || !sceneRef.current) return;
|
||||
const group = fenceGroupRef.current;
|
||||
@@ -296,19 +296,26 @@ export default function FenceViewer3D() {
|
||||
}
|
||||
|
||||
const colConfig = colorMap[color];
|
||||
const wireColorHex = fenceType === "alambrado_pvc" ? "#225528" : colConfig.hex;
|
||||
const wireColorHex = fenceType === "alambrado_pvc" ? 0x22c55e : colConfig.threeHex;
|
||||
|
||||
// Material de mourão
|
||||
// Material dos mourões de concreto
|
||||
const postMat = new THREE.MeshStandardMaterial({
|
||||
color: fenceType === "alambrado_curvo" ? 0x82868e : colConfig.postHex,
|
||||
roughness: 0.9,
|
||||
metalness: 0.1,
|
||||
});
|
||||
|
||||
// Material dos arames guia de sustentação
|
||||
const steelGuideMat = new THREE.MeshStandardMaterial({
|
||||
color: 0x9ca3af,
|
||||
metalness: 0.8,
|
||||
roughness: 0.3,
|
||||
color: 0xe2e8f0,
|
||||
metalness: 0.9,
|
||||
roughness: 0.25,
|
||||
});
|
||||
|
||||
// Material de linhas sólidas visíveis para a tela de alambrado
|
||||
const wireLineMat = new THREE.LineBasicMaterial({
|
||||
color: wireColorHex,
|
||||
linewidth: 2,
|
||||
});
|
||||
|
||||
const spanLength = 2.5; // 2,50m entre mourões
|
||||
@@ -350,7 +357,7 @@ export default function FenceViewer3D() {
|
||||
spans.push({ startX: spanLength, startZ: 0, endX: spanLength, endZ: spanLength });
|
||||
}
|
||||
|
||||
// --- MOURÕES ---
|
||||
// --- MOURÕES DE CONCRETO (10x10cm) ---
|
||||
posts.forEach((p, idx) => {
|
||||
const postHeight = h + (isCurved ? 0.45 : 0.05);
|
||||
|
||||
@@ -391,11 +398,16 @@ export default function FenceViewer3D() {
|
||||
}
|
||||
});
|
||||
|
||||
// --- PAINÉIS DE TELA DE ALAMBRADO ---
|
||||
// Textura procedural ultra-leve e realista (zero crash de contexto WebGL)
|
||||
const meshTexture = createChainLinkTexture(wireColorHex, 3);
|
||||
// --- CARREGADOR DE TEXTURA REALISTA ---
|
||||
const texUrl = fenceType === "alambrado_pvc" ? "/images/chainlink-pvc-verde.png" : colConfig.textureUrl;
|
||||
const textureLoader = new THREE.TextureLoader();
|
||||
const loadedTexture = textureLoader.load(texUrl);
|
||||
loadedTexture.wrapS = THREE.RepeatWrapping;
|
||||
loadedTexture.wrapT = THREE.RepeatWrapping;
|
||||
|
||||
const totalLines = h >= 2.0 ? 4 : 3;
|
||||
|
||||
// --- PAINÉIS DE TELA DE ALAMBRADO ---
|
||||
spans.forEach((span) => {
|
||||
const dx = span.endX - span.startX;
|
||||
const dz = span.endZ - span.startZ;
|
||||
@@ -404,10 +416,10 @@ export default function FenceViewer3D() {
|
||||
const cx = (span.startX + span.endX) / 2;
|
||||
const cz = (span.startZ + span.endZ) / 2;
|
||||
|
||||
// Fiadas horizontais de arame guia
|
||||
// 1. Fiadas horizontais de arame guia (Tensionadores)
|
||||
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 guideGeo = new THREE.CylinderGeometry(0.0035, 0.0035, len, 6);
|
||||
const guideMesh = new THREE.Mesh(guideGeo, steelGuideMat);
|
||||
guideMesh.rotation.z = Math.PI / 2;
|
||||
guideMesh.rotation.y = -angle;
|
||||
@@ -415,10 +427,10 @@ export default function FenceViewer3D() {
|
||||
group.add(guideMesh);
|
||||
}
|
||||
|
||||
// Fios farpados no mourão curvo
|
||||
// 2. Fios farpados no 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 barbedGeo = new THREE.CylinderGeometry(0.0028, 0.0028, len, 6);
|
||||
const barbedMesh = new THREE.Mesh(barbedGeo, steelGuideMat);
|
||||
barbedMesh.rotation.z = Math.PI / 2;
|
||||
barbedMesh.rotation.y = -angle;
|
||||
@@ -427,14 +439,14 @@ export default function FenceViewer3D() {
|
||||
}
|
||||
}
|
||||
|
||||
// Concertina opcional
|
||||
// 3. Concertina opcional
|
||||
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 torusGeo = new THREE.TorusGeometry(concertinaRadius, 0.003, 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);
|
||||
@@ -445,30 +457,106 @@ export default function FenceViewer3D() {
|
||||
}
|
||||
}
|
||||
|
||||
// Plano da Tela de Alambrado com textura de malha losangular
|
||||
const spanTexture = meshTexture.clone();
|
||||
spanTexture.needsUpdate = true;
|
||||
const diamondScale = 0.055; // 50mm por losango
|
||||
spanTexture.repeat.set(len / diamondScale, h / diamondScale);
|
||||
// 4. ARAMES LOSANGULARES (SÓLIDOS 100% VISÍVEIS)
|
||||
if (fenceType !== "gradil_3d") {
|
||||
// Constrói os arames diagonais cruzados a 45°
|
||||
const wireGeo = buildChainLinkGeometry(len, h, 0.08);
|
||||
const wireSegments = new THREE.LineSegments(wireGeo, wireLineMat);
|
||||
wireSegments.position.set(cx, 0, cz);
|
||||
wireSegments.rotation.y = -angle;
|
||||
group.add(wireSegments);
|
||||
|
||||
const planeGeo = new THREE.PlaneGeometry(len, h);
|
||||
const planeMat = new THREE.MeshStandardMaterial({
|
||||
map: spanTexture,
|
||||
transparent: true,
|
||||
alphaTest: 0.15,
|
||||
side: THREE.DoubleSide,
|
||||
metalness: fenceType === "alambrado_pvc" ? 0.15 : 0.8,
|
||||
roughness: fenceType === "alambrado_pvc" ? 0.5 : 0.35,
|
||||
});
|
||||
// Plano com textura metálica sombreada de fundo
|
||||
const spanTex = loadedTexture.clone();
|
||||
spanTex.needsUpdate = true;
|
||||
spanTex.repeat.set(len / 0.10, h / 0.10);
|
||||
|
||||
const planeMesh = new THREE.Mesh(planeGeo, planeMat);
|
||||
planeMesh.position.set(cx, h / 2, cz);
|
||||
planeMesh.rotation.y = -angle;
|
||||
planeMesh.castShadow = true;
|
||||
group.add(planeMesh);
|
||||
const planeGeo = new THREE.PlaneGeometry(len, h);
|
||||
const planeMat = new THREE.MeshStandardMaterial({
|
||||
map: spanTex,
|
||||
transparent: true,
|
||||
alphaTest: 0.05,
|
||||
side: THREE.DoubleSide,
|
||||
metalness: fenceType === "alambrado_pvc" ? 0.2 : 0.85,
|
||||
roughness: fenceType === "alambrado_pvc" ? 0.5 : 0.3,
|
||||
});
|
||||
const planeMesh = new THREE.Mesh(planeGeo, planeMat);
|
||||
planeMesh.position.set(cx, h / 2, cz);
|
||||
planeMesh.rotation.y = -angle;
|
||||
group.add(planeMesh);
|
||||
} else {
|
||||
// Modo Gradil 3D (Linha Complementar)
|
||||
const vertSpacing = 0.05;
|
||||
const numVert = Math.floor(len / vertSpacing);
|
||||
const vertGeo = new THREE.CylinderGeometry(0.0025, 0.0025, h, 5);
|
||||
for (let v = -numVert / 2; v <= numVert / 2; v++) {
|
||||
const wire = new THREE.Mesh(vertGeo, steelGuideMat);
|
||||
wire.position.set(cx + v * vertSpacing * Math.cos(angle), h / 2, cz + v * vertSpacing * Math.sin(angle));
|
||||
group.add(wire);
|
||||
}
|
||||
const numHoriz = Math.floor(h / 0.20);
|
||||
const horizGeo = new THREE.CylinderGeometry(0.0025, 0.0025, len, 5);
|
||||
for (let hz = 1; hz <= numHoriz; hz++) {
|
||||
const wire = new THREE.Mesh(horizGeo, steelGuideMat);
|
||||
wire.rotation.z = Math.PI / 2;
|
||||
wire.rotation.y = -angle;
|
||||
wire.position.set(cx, hz * 0.20, cz);
|
||||
group.add(wire);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, [fenceType, color, height, layout, hasBarbedWire, hasConcertina]);
|
||||
// --- 5. ROLO DE TELA DE ALAMBRADO COMPACTADO (MODELO DE FÁBRICA) ---
|
||||
// Conforme foto de referência: o rolo de tela fica em pé ao lado da cerca
|
||||
if (showRoll && posts.length > 0) {
|
||||
const rollRadius = 0.18; // Diâmetro de 36cm
|
||||
const rollHeight = h;
|
||||
const rollGroup = new THREE.Group();
|
||||
rollGroup.position.set(posts[0].x - 0.65, 0, 0.35);
|
||||
|
||||
// Cilindro do rolo de tela
|
||||
const rollTex = loadedTexture.clone();
|
||||
rollTex.needsUpdate = true;
|
||||
rollTex.repeat.set(6, rollHeight / 0.08);
|
||||
|
||||
const rollGeo = new THREE.CylinderGeometry(rollRadius, rollRadius, rollHeight, 24);
|
||||
const rollMat = new THREE.MeshStandardMaterial({
|
||||
map: rollTex,
|
||||
color: wireColorHex,
|
||||
metalness: fenceType === "alambrado_pvc" ? 0.3 : 0.8,
|
||||
roughness: 0.4,
|
||||
});
|
||||
const rollMesh = new THREE.Mesh(rollGeo, rollMat);
|
||||
rollMesh.position.y = rollHeight / 2;
|
||||
rollMesh.castShadow = true;
|
||||
rollGroup.add(rollMesh);
|
||||
|
||||
// Faixa / Etiqueta central da fábrica (como na foto do cliente)
|
||||
const labelGeo = new THREE.CylinderGeometry(rollRadius + 0.005, rollRadius + 0.005, 0.35, 24);
|
||||
const labelMat = new THREE.MeshStandardMaterial({
|
||||
color: fenceType === "alambrado_pvc" ? 0x166534 : 0x0f766e,
|
||||
roughness: 0.3,
|
||||
});
|
||||
const labelMesh = new THREE.Mesh(labelGeo, labelMat);
|
||||
labelMesh.position.y = rollHeight / 2;
|
||||
rollGroup.add(labelMesh);
|
||||
|
||||
// Arame de amarração do rolo (topo e base)
|
||||
const tieGeo = new THREE.TorusGeometry(rollRadius + 0.008, 0.004, 6, 24);
|
||||
const tieTop = new THREE.Mesh(tieGeo, steelGuideMat);
|
||||
tieTop.rotation.x = Math.PI / 2;
|
||||
tieTop.position.y = rollHeight * 0.85;
|
||||
rollGroup.add(tieTop);
|
||||
|
||||
const tieBot = new THREE.Mesh(tieGeo, steelGuideMat);
|
||||
tieBot.rotation.x = Math.PI / 2;
|
||||
tieBot.position.y = rollHeight * 0.15;
|
||||
rollGroup.add(tieBot);
|
||||
|
||||
group.add(rollGroup);
|
||||
}
|
||||
|
||||
}, [fenceType, color, height, layout, hasBarbedWire, hasConcertina, showRoll]);
|
||||
|
||||
const setCameraView = (type: "geral" | "detalhe" | "topo") => {
|
||||
if (!cameraRef.current || !controlsRef.current) return;
|
||||
@@ -477,12 +565,12 @@ export default function FenceViewer3D() {
|
||||
|
||||
switch (type) {
|
||||
case "geral":
|
||||
cam.position.set(4.8, 3.4, 6.2);
|
||||
ctrl.target.set(0, 1.1, 0);
|
||||
cam.position.set(4.8, 3.2, 5.8);
|
||||
ctrl.target.set(0, 1.0, 0);
|
||||
break;
|
||||
case "detalhe":
|
||||
cam.position.set(0.8, 1.4, 1.5);
|
||||
ctrl.target.set(0, 1.2, 0);
|
||||
cam.position.set(0.6, 1.3, 1.4);
|
||||
ctrl.target.set(0, 1.1, 0);
|
||||
break;
|
||||
case "topo":
|
||||
cam.position.set(0.1, 8.0, 0.1);
|
||||
@@ -512,7 +600,7 @@ export default function FenceViewer3D() {
|
||||
estimatedPosts: currentLayout.posts,
|
||||
estimatedWireKg,
|
||||
estimatedTensioners,
|
||||
notes: `Simulação no site: ${hasBarbedWire ? "Com 3 fios de arame farpado" : "Sem arame farpado"}${hasConcertina ? " + Concertina" : ""}.`,
|
||||
notes: `Simulação 3D no site: ${hasBarbedWire ? "Com 3 fios de arame farpado" : "Sem arame farpado"}${hasConcertina ? " + Concertina" : ""}.`,
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -534,7 +622,7 @@ export default function FenceViewer3D() {
|
||||
</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.
|
||||
Gire em 360°, aproxime para inspecionar a malha losangular e veja o rolo compacto ao lado da cerca.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -571,27 +659,25 @@ export default function FenceViewer3D() {
|
||||
{/* Grid: Canvas 3D (8 cols) + Controles (4 cols) */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 min-h-[580px]">
|
||||
|
||||
{/* Canvas 3D Viewport com fallback visual garantido */}
|
||||
{/* Canvas 3D Viewport */}
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="lg:col-span-8 relative bg-[#0a0c0e] overflow-hidden flex flex-col justify-between min-h-[380px] sm:min-h-[480px] lg:min-h-[580px]"
|
||||
>
|
||||
{/* O CANVAS É DECLARATIVO E EXCLUSIVO (Zero duplicações ou broken image) */}
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
className="w-full h-full absolute inset-0 cursor-grab active:cursor-grabbing block bg-[#0a0c0e]"
|
||||
/>
|
||||
|
||||
{/* Fallback caso WebGL seja bloqueado na GPU do usuário */}
|
||||
{webGLError && (
|
||||
<div className="absolute inset-0 bg-[#0c0e12] flex flex-col items-center justify-center p-6 text-center z-20 space-y-4">
|
||||
<div className="w-12 h-12 rounded-xl bg-amber-500/10 text-amber-400 flex items-center justify-center border border-amber-500/30">
|
||||
<AlertTriangle className="w-6 h-6" />
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-base font-heading font-bold text-white">Visualizador em Modo Interativo 2D</h4>
|
||||
<h4 className="text-base font-heading font-bold text-white">Visualizador Interativo</h4>
|
||||
<p className="text-xs text-zinc-400 max-w-md mt-1">
|
||||
Seu navegador opera com aceleração gráfica limitada, mas todos os parâmetros e o cálculo de rolos e mourões continuam 100% funcionais abaixo!
|
||||
Seu navegador opera com aceleração gráfica limitada, mas todos os parâmetros e o cálculo continuam 100% funcionais!
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -600,7 +686,7 @@ export default function FenceViewer3D() {
|
||||
{/* Dica de Interação */}
|
||||
<div className="relative z-10 m-4 pointer-events-none flex items-center gap-2 px-3 py-1.5 rounded-lg bg-black/75 backdrop-blur-md border border-zinc-800/80 text-[11px] text-zinc-300 w-fit">
|
||||
<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>
|
||||
<span>Gire 360° • Aproxime para ver a malha de arame losangular e o rolo da fábrica</span>
|
||||
</div>
|
||||
|
||||
{/* Badge Inferior */}
|
||||
@@ -742,9 +828,9 @@ export default function FenceViewer3D() {
|
||||
<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: "verde", label: "Revestido em PVC Verde", hex: "bg-emerald-600" },
|
||||
{ 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" },
|
||||
{ id: "cinza", label: "Revestido em PVC Cinza", hex: "bg-zinc-500" },
|
||||
].map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
@@ -763,7 +849,7 @@ export default function FenceViewer3D() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4. Módulos na Prévia 3D */}
|
||||
{/* 4. Extensão na Simulação */}
|
||||
<div>
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-zinc-400 block mb-2">
|
||||
4. Extensão na Simulação:
|
||||
@@ -808,8 +894,21 @@ export default function FenceViewer3D() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Opcionais de Segurança */}
|
||||
{/* Opcionais de Fábrica */}
|
||||
<div className="pt-2 border-t border-zinc-800 space-y-2">
|
||||
<label className="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showRoll}
|
||||
onChange={(e) => setShowRoll(e.target.checked)}
|
||||
className="w-4 h-4 rounded accent-[#a3c745] bg-zinc-900 border-zinc-700"
|
||||
/>
|
||||
<span className="text-xs text-zinc-300 flex items-center gap-1.5 font-medium">
|
||||
<Package className="w-3.5 h-3.5 text-[#a3c745]" />
|
||||
Exibir Rolo de Tela ao lado da cerca
|
||||
</span>
|
||||
</label>
|
||||
|
||||
{isCurved && (
|
||||
<label className="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
|
||||
Reference in new issue
Block a user