feat(3d): add realistic 3d layers, precast concrete posts with pyramid cap, wire strainers, diorama ground with 3 terrains

This commit is contained in:
cyber committed 2026-11-16 09:05:30 -04:00
1 parent 90a11c5e2d
commit 05d6ed3625
8 files changed
+346 -117

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 KiB

+346 -117
View File
@@ -153,7 +153,7 @@ export default function FenceViewer3D() {
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);
const groundGroupRef = useRef<THREE.Group | null>(null);
// 1. Inicialização do Three.js
useEffect(() => {
@@ -182,12 +182,12 @@ export default function FenceViewer3D() {
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.25;
renderer.toneMappingExposure = 1.35;
rendererRef.current = renderer;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a0c0e);
scene.fog = new THREE.FogExp2(0x0a0c0e, 0.025);
scene.background = new THREE.Color(0x0a0c0f);
scene.fog = new THREE.FogExp2(0x0a0c0f, 0.022);
sceneRef.current = scene;
const camera = new THREE.PerspectiveCamera(40, width / heightPx, 0.1, 100);
@@ -203,39 +203,40 @@ export default function FenceViewer3D() {
controls.target.set(0, 1.0, 0);
controlsRef.current = controls;
// Iluminação
const ambientLight = new THREE.AmbientLight(0xffffff, 1.2);
scene.add(ambientLight);
// Iluminação Realista de Estúdio & Luz Solar Externa
const hemiLight = new THREE.HemisphereLight(0xe0f2fe, 0x18181b, 1.4);
scene.add(hemiLight);
const sunLight = new THREE.DirectionalLight(0xffffff, 2.5);
sunLight.position.set(7, 14, 9);
const sunLight = new THREE.DirectionalLight(0xfffaed, 2.8);
sunLight.position.set(7, 15, 9);
sunLight.castShadow = true;
sunLight.shadow.mapSize.width = 1024;
sunLight.shadow.mapSize.height = 1024;
sunLight.shadow.mapSize.width = 2048;
sunLight.shadow.mapSize.height = 2048;
sunLight.shadow.bias = -0.0003;
sunLight.shadow.camera.near = 0.5;
sunLight.shadow.camera.far = 40;
sunLight.shadow.camera.left = -9;
sunLight.shadow.camera.right = 9;
sunLight.shadow.camera.top = 9;
sunLight.shadow.camera.bottom = -9;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0xa3c745, 0.5);
fillLight.position.set(-6, 4, -4);
// Rim light metálico para contorno dos arames e mourões
const rimLight = new THREE.DirectionalLight(0xa3c745, 0.85);
rimLight.position.set(-8, 6, -8);
scene.add(rimLight);
// Luz de preenchimento frontal suave
const fillLight = new THREE.DirectionalLight(0xffffff, 0.5);
fillLight.position.set(3, 5, 8);
scene.add(fillLight);
// Chão
const groundGeo = new THREE.PlaneGeometry(40, 40);
const groundMat = new THREE.MeshStandardMaterial({
color: 0x192d16,
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);
// Grupo de Terreno com Camadas Reais 3D
const groundGroup = new THREE.Group();
scene.add(groundGroup);
groundGroupRef.current = groundGroup;
// Grupo da Cerca
const fenceGroup = new THREE.Group();
scene.add(fenceGroup);
fenceGroupRef.current = fenceGroup;
@@ -270,19 +271,121 @@ export default function FenceViewer3D() {
};
}, []);
// 2. Chão
// 2. Terreno Realista com Camadas 3D (Solo Texturizado, Plataforma Diorama e Detalhes)
useEffect(() => {
if (!groundMeshRef.current) return;
const mat = groundMeshRef.current.material as THREE.MeshStandardMaterial;
if (ground === "grama") {
mat.color.setHex(0x192d16);
mat.roughness = 0.95;
if (!groundGroupRef.current || !sceneRef.current) return;
const gGroup = groundGroupRef.current;
while (gGroup.children.length > 0) {
const obj = gGroup.children[0];
gGroup.remove(obj);
if ((obj as THREE.Mesh).geometry) (obj as THREE.Mesh).geometry.dispose();
}
const texLoader = new THREE.TextureLoader();
// Plataforma / Bloco 3D de Terreno (16m x 16m x 0.35m de espessura com corte de solo)
const platformHeight = 0.35;
const platformGeo = new THREE.BoxGeometry(16, platformHeight, 16);
const platformSideMat = new THREE.MeshStandardMaterial({
color: ground === "concreto" ? 0x27272a : (ground === "terra" ? 0x2e1f14 : 0x1f241a),
roughness: 0.95,
metalness: 0.05,
});
const platformMesh = new THREE.Mesh(platformGeo, platformSideMat);
platformMesh.position.set(0, -platformHeight / 2, 0);
platformMesh.receiveShadow = true;
gGroup.add(platformMesh);
// Textura e material da superfície do solo
let terrainUrl = "/images/terrain-grama.png";
let repeatScale = 8;
let surfaceRoughness = 0.92;
let surfaceMetalness = 0.05;
if (ground === "terra") {
terrainUrl = "/images/terrain-terra.png";
repeatScale = 7;
surfaceRoughness = 0.98;
surfaceMetalness = 0.02;
} else if (ground === "concreto") {
mat.color.setHex(0x383b42);
mat.roughness = 0.7;
} else {
mat.color.setHex(0x38291a);
mat.roughness = 0.98;
terrainUrl = "/images/terrain-concreto.png";
repeatScale = 5;
surfaceRoughness = 0.65;
surfaceMetalness = 0.12;
}
const groundTex = texLoader.load(terrainUrl);
groundTex.wrapS = THREE.RepeatWrapping;
groundTex.wrapT = THREE.RepeatWrapping;
groundTex.repeat.set(repeatScale, repeatScale);
const surfaceGeo = new THREE.PlaneGeometry(16, 16);
const surfaceMat = new THREE.MeshStandardMaterial({
map: groundTex,
roughness: surfaceRoughness,
metalness: surfaceMetalness,
});
const surfaceMesh = new THREE.Mesh(surfaceGeo, surfaceMat);
surfaceMesh.rotation.x = -Math.PI / 2;
surfaceMesh.position.y = 0.001;
surfaceMesh.receiveShadow = true;
gGroup.add(surfaceMesh);
// Detalhes orgânicos de camadas reais 3D
if (ground === "grama") {
// Tufos de grama 3D orgânicos ao longo da cerca e na base dos mourões
const tuftMat = new THREE.MeshStandardMaterial({
color: 0x417c24,
roughness: 0.85,
side: THREE.DoubleSide,
});
const tuftGeo = new THREE.PlaneGeometry(0.14, 0.11);
for (let i = 0; i < 90; i++) {
const tx = (Math.random() - 0.5) * 11;
const tz = (Math.random() - 0.5) * 2.8;
const tuftA = new THREE.Mesh(tuftGeo, tuftMat);
tuftA.position.set(tx, 0.055, tz);
tuftA.rotation.y = Math.random() * Math.PI;
tuftA.castShadow = true;
gGroup.add(tuftA);
const tuftB = tuftA.clone();
tuftB.rotation.y += Math.PI / 2;
gGroup.add(tuftB);
}
} else if (ground === "terra") {
// Pedregulhos / cascalhos de chácara com relevo
const pebbleMat1 = new THREE.MeshStandardMaterial({ color: 0x6d4c41, roughness: 0.95 });
const pebbleMat2 = new THREE.MeshStandardMaterial({ color: 0x8d6e63, roughness: 0.95 });
const pebbleMat3 = new THREE.MeshStandardMaterial({ color: 0x546e7a, roughness: 0.88 });
const mats = [pebbleMat1, pebbleMat2, pebbleMat3];
for (let i = 0; i < 50; i++) {
const rad = 0.02 + Math.random() * 0.035;
const pGeo = new THREE.DodecahedronGeometry(rad);
const pMesh = new THREE.Mesh(pGeo, mats[i % 3]);
const px = (Math.random() - 0.5) * 11;
const pz = (Math.random() - 0.5) * 2.5;
pMesh.position.set(px, rad * 0.7, pz);
pMesh.rotation.set(Math.random() * Math.PI, Math.random() * Math.PI, 0);
pMesh.castShadow = true;
pMesh.receiveShadow = true;
gGroup.add(pMesh);
}
} else if (ground === "concreto") {
// Guia / cordão de concreto sob a cerca
const curbGeo = new THREE.BoxGeometry(11, 0.08, 0.35);
const curbMat = new THREE.MeshStandardMaterial({
color: 0x52525b,
roughness: 0.7,
});
const curbMesh = new THREE.Mesh(curbGeo, curbMat);
curbMesh.position.set(0, 0.04, 0);
curbMesh.receiveShadow = true;
curbMesh.castShadow = true;
gGroup.add(curbMesh);
}
}, [ground]);
@@ -298,25 +401,35 @@ export default function FenceViewer3D() {
}
const colConfig = colorMap[color];
const wireColorHex = fenceType === "alambrado_pvc" ? 0x22c55e : colConfig.threeHex;
const isPvc = fenceType === "alambrado_pvc" || color === "verde";
const wireColorHex = isPvc ? 0x22c55e : colConfig.threeHex;
// Material dos mourões de concreto
const textureLoader = new THREE.TextureLoader();
// Textura realista de concreto pré-moldado
const concreteTex = textureLoader.load("/images/post-concrete.png");
concreteTex.wrapS = THREE.RepeatWrapping;
concreteTex.wrapT = THREE.RepeatWrapping;
concreteTex.repeat.set(1, 4);
// Material dos mourões de concreto (com rugosidade e micro-poros de concreto vibrado)
const postMat = new THREE.MeshStandardMaterial({
color: fenceType === "alambrado_curvo" ? 0x82868e : colConfig.postHex,
roughness: 0.9,
metalness: 0.1,
map: concreteTex,
color: fenceType === "alambrado_curvo" ? 0x9ca3af : colConfig.postHex,
roughness: 0.88,
metalness: 0.06,
});
// Material dos arames guia de sustentação
// Material de aço galvanizado para arames, catracas e ferragens
const steelGuideMat = new THREE.MeshStandardMaterial({
color: 0xe2e8f0,
metalness: 0.9,
roughness: 0.25,
metalness: 0.92,
roughness: 0.20,
});
// Material de linhas sólidas visíveis para a tela de alambrado
const wireLineMat = new THREE.LineBasicMaterial({
color: wireColorHex,
color: isPvc ? 0x22c55e : (color === "preto" ? 0x334155 : 0xd1d5db),
linewidth: 2,
});
@@ -359,10 +472,13 @@ export default function FenceViewer3D() {
spans.push({ startX: spanLength, startZ: 0, endX: spanLength, endZ: spanLength });
}
// --- MOURÕES DE CONCRETO (10x10cm) ---
const totalLines = h >= 2.0 ? 4 : 3;
// --- CAMADA 1: MOURÕES DE CONCRETO PRÉ-MOLDADO REALISTAS ---
posts.forEach((p, idx) => {
const postHeight = h + (isCurved ? 0.45 : 0.05);
// Corpo principal do mourão (10x10cm)
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);
@@ -370,14 +486,37 @@ export default function FenceViewer3D() {
postMesh.receiveShadow = true;
group.add(postMesh);
// Base sapata
const baseGeo = new THREE.CylinderGeometry(0.14, 0.16, 0.08, 12);
// Topo chanfrado em 4 águas (Pyramid Cap - padrão de fábrica anti-empoçamento)
if (!isCurved) {
const capHeight = 0.045;
const capGeo = new THREE.ConeGeometry(0.071, capHeight, 4);
const capMesh = new THREE.Mesh(capGeo, postMat);
capMesh.rotation.y = Math.PI / 4;
capMesh.position.set(p.x, postHeight + capHeight / 2, p.z);
capMesh.castShadow = true;
group.add(capMesh);
}
// Base sapata chumbada no solo com colarinho octogonal de fundação
const baseGeo = new THREE.CylinderGeometry(0.12, 0.16, 0.10, 8);
const baseMesh = new THREE.Mesh(baseGeo, postMat);
baseMesh.position.set(p.x, 0.04, p.z);
baseMesh.position.set(p.x, 0.05, p.z);
baseMesh.receiveShadow = true;
baseMesh.castShadow = true;
group.add(baseMesh);
// Mourão Curvo (Braço 45°)
// Furos passantes no concreto para os arames tensores horizontais
for (let l = 1; l <= totalLines; l++) {
const wireY = (h / (totalLines + 0.5)) * l;
const holeGeo = new THREE.CylinderGeometry(0.007, 0.007, 0.105, 8);
const holeMat = new THREE.MeshBasicMaterial({ color: 0x18181b });
const holeMesh = new THREE.Mesh(holeGeo, holeMat);
holeMesh.rotation.z = Math.PI / 2;
holeMesh.position.set(p.x, wireY, p.z);
group.add(holeMesh);
}
// Mourão Curvo (Braço 45° com ponta chanfrada)
if (isCurved) {
const armLength = 0.50;
const armGeo = new THREE.BoxGeometry(0.08, armLength, 0.08);
@@ -385,10 +524,24 @@ export default function FenceViewer3D() {
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;
armMesh.receiveShadow = true;
group.add(armMesh);
// Ponta do braço
const armCapGeo = new THREE.ConeGeometry(0.056, 0.04, 4);
const armCap = new THREE.Mesh(armCapGeo, postMat);
armCap.rotation.z = -Math.PI / 4;
armCap.rotation.y = Math.PI / 4;
armCap.position.set(
p.x + armLength * Math.sin(Math.PI / 4),
postHeight + 0.12 + (armLength * Math.cos(Math.PI / 4)) / 2,
p.z
);
armCap.castShadow = true;
group.add(armCap);
}
// Escoras nos cantos e pontas (Contraventamento opcional)
// Escoras nos cantos e pontas (Contraventamento de sustentação)
if (showBraces && (idx === 0 || idx === posts.length - 1 || p.isCorner)) {
const braceLength = h * 0.95;
const braceGeo = new THREE.BoxGeometry(0.08, braceLength, 0.08);
@@ -396,20 +549,54 @@ export default function FenceViewer3D() {
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;
braceMesh.receiveShadow = true;
group.add(braceMesh);
// Sapata de apoio da escora
const braceBaseGeo = new THREE.BoxGeometry(0.14, 0.08, 0.14);
const braceBase = new THREE.Mesh(braceBaseGeo, postMat);
braceBase.position.set(idx === 0 ? p.x + 0.90 : p.x - 0.90, 0.04, p.z);
braceBase.receiveShadow = true;
braceBase.castShadow = true;
group.add(braceBase);
}
});
// --- 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);
// --- CAMADA 2: CATRACAS ESTICADORAS 3D NO MOURÃO MESTRE ---
if (posts.length > 0) {
for (let l = 1; l <= totalLines; l++) {
const wireY = (h / (totalLines + 0.5)) * l;
const ratchet = new THREE.Group();
// Chapa U da catraca
const rFrameGeo = new THREE.BoxGeometry(0.045, 0.035, 0.025);
const rFrame = new THREE.Mesh(rFrameGeo, steelGuideMat);
ratchet.add(rFrame);
// Carretel de tração cilíndrico
const rSpoolGeo = new THREE.CylinderGeometry(0.012, 0.012, 0.038, 12);
const rSpool = new THREE.Mesh(rSpoolGeo, steelGuideMat);
rSpool.rotation.z = Math.PI / 2;
ratchet.add(rSpool);
// Cabeça de parafuso de travamento
const rPinGeo = new THREE.CylinderGeometry(0.005, 0.005, 0.05, 8);
const rPin = new THREE.Mesh(rPinGeo, steelGuideMat);
ratchet.add(rPin);
ratchet.position.set(posts[0].x + 0.065, wireY, posts[0].z);
ratchet.castShadow = true;
group.add(ratchet);
}
}
// Carregador de Textura Woven 3D Realista com Tubos Sombreados
const wovenTexUrl = isPvc ? "/images/chainlink-woven-pvc.png" : "/images/chainlink-woven-galv.png";
const loadedTexture = textureLoader.load(wovenTexUrl);
loadedTexture.wrapS = THREE.RepeatWrapping;
loadedTexture.wrapT = THREE.RepeatWrapping;
const totalLines = h >= 2.0 ? 4 : 3;
// --- PAINÉIS DE TELA DE ALAMBRADO ---
// --- CAMADA 3: PAINÉIS DE TELA, ARAMES TENSORES E PRESILLHAS ---
spans.forEach((span) => {
const dx = span.endX - span.startX;
const dz = span.endZ - span.startZ;
@@ -418,26 +605,57 @@ export default function FenceViewer3D() {
const cx = (span.startX + span.endX) / 2;
const cz = (span.startZ + span.endZ) / 2;
// 1. Fiadas horizontais de arame guia (Tensionadores)
// 1. Fiadas horizontais de arame guia (Tensionadores BWG 10)
for (let l = 1; l <= totalLines; l++) {
const wireY = (h / (totalLines + 0.5)) * l;
const guideGeo = new THREE.CylinderGeometry(0.0035, 0.0035, len, 6);
const guideGeo = new THREE.CylinderGeometry(0.0035, 0.0035, len, 8);
const guideMesh = new THREE.Mesh(guideGeo, steelGuideMat);
guideMesh.rotation.z = Math.PI / 2;
guideMesh.rotation.y = -angle;
guideMesh.position.set(cx, wireY, cz);
guideMesh.castShadow = true;
group.add(guideMesh);
// Presilhas / amarras de arame torcido a cada 50cm prendendo a tela no fio guia
const numClips = Math.floor(len / 0.5);
for (let c = 1; c < numClips; c++) {
const clipX = span.startX + Math.cos(angle) * (c * 0.5);
const clipZ = span.startZ + Math.sin(angle) * (c * 0.5);
const clipGeo = new THREE.TorusGeometry(0.007, 0.002, 6, 8);
const clipMesh = new THREE.Mesh(clipGeo, steelGuideMat);
clipMesh.position.set(clipX, wireY, clipZ);
group.add(clipMesh);
}
}
// 2. Fios farpados no mourão curvo
// 2. Fios farpados no mourão curvo (com farpas duplas trançadas)
if (isCurved && hasBarbedWire) {
for (let b = 1; b <= 3; b++) {
const wireY = h + 0.15 + b * 0.10;
const wireXOffset = b * 0.09;
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;
barbedMesh.position.set(cx + b * 0.09, h + 0.15 + b * 0.10, cz);
barbedMesh.position.set(cx + wireXOffset, wireY, cz);
barbedMesh.castShadow = true;
group.add(barbedMesh);
// Farpas duplas de arame a cada 25cm
const numBarbs = Math.floor(len / 0.25);
for (let nb = 1; nb < numBarbs; nb++) {
const bx = span.startX + Math.cos(angle) * (nb * 0.25) + wireXOffset;
const bz = span.startZ + Math.sin(angle) * (nb * 0.25);
const barbGeo = new THREE.CylinderGeometry(0.0018, 0.0018, 0.024, 4);
const barb1 = new THREE.Mesh(barbGeo, steelGuideMat);
barb1.rotation.x = Math.PI / 4;
barb1.position.set(bx, wireY, bz);
group.add(barb1);
const barb2 = new THREE.Mesh(barbGeo, steelGuideMat);
barb2.rotation.z = Math.PI / 3;
barb2.position.set(bx, wireY, bz);
group.add(barb2);
}
}
}
@@ -459,16 +677,16 @@ export default function FenceViewer3D() {
}
}
// 4. ARAMES LOSANGULARES (SÓLIDOS 100% VISÍVEIS)
// 4. ARAMES LOSANGULARES (SÓLIDOS 3D + TEXTURA TUBULAR REALISTA)
if (fenceType !== "gradil_3d") {
// Constrói os arames diagonais cruzados a 45°
// Linhas sólidas 3D em diamante
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);
// Plano com textura metálica sombreada de fundo
// Plano com textura de arames tecidos e sombreados em tubo
const spanTex = loadedTexture.clone();
spanTex.needsUpdate = true;
spanTex.repeat.set(len / 0.10, h / 0.10);
@@ -477,14 +695,16 @@ export default function FenceViewer3D() {
const planeMat = new THREE.MeshStandardMaterial({
map: spanTex,
transparent: true,
alphaTest: 0.05,
alphaTest: 0.12,
side: THREE.DoubleSide,
metalness: fenceType === "alambrado_pvc" ? 0.2 : 0.85,
roughness: fenceType === "alambrado_pvc" ? 0.5 : 0.3,
metalness: isPvc ? 0.35 : 0.85,
roughness: isPvc ? 0.35 : 0.22,
shadowSide: THREE.DoubleSide,
});
const planeMesh = new THREE.Mesh(planeGeo, planeMat);
planeMesh.position.set(cx, h / 2, cz);
planeMesh.rotation.y = -angle;
planeMesh.castShadow = true;
group.add(planeMesh);
} else {
// Modo Gradil 3D (Linha Complementar)
@@ -508,52 +728,61 @@ export default function FenceViewer3D() {
}
});
// --- 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
// --- CAMADA 5: ROLO DE TELA DE ALAMBRADO COMPACTADO (PADRÃO DE FÁBRICA) ---
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);
rollGroup.position.set(posts[0].x - 0.70, 0, 0.40);
// Cilindro do rolo de tela
// Cilindro do rolo com textura de arame trançado enrolado
const rollTex = loadedTexture.clone();
rollTex.needsUpdate = true;
rollTex.repeat.set(6, rollHeight / 0.08);
const rollGeo = new THREE.CylinderGeometry(rollRadius, rollRadius, rollHeight, 24);
const rollGeo = new THREE.CylinderGeometry(rollRadius, rollRadius, rollHeight, 28);
const rollMat = new THREE.MeshStandardMaterial({
map: rollTex,
color: wireColorHex,
metalness: fenceType === "alambrado_pvc" ? 0.3 : 0.8,
roughness: 0.4,
metalness: isPvc ? 0.3 : 0.85,
roughness: 0.35,
});
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);
// Tampas em espiral de topo e base
const capRollGeo = new THREE.CircleGeometry(rollRadius, 24);
const capRollMat = new THREE.MeshStandardMaterial({
color: wireColorHex,
metalness: 0.8,
roughness: 0.4,
});
const topCap = new THREE.Mesh(capRollGeo, capRollMat);
topCap.rotation.x = -Math.PI / 2;
topCap.position.y = rollHeight;
rollGroup.add(topCap);
// Faixa / Rótulo da fábrica Cerca & Tela
const labelTex = textureLoader.load("/images/roll-label.png");
const labelGeo = new THREE.CylinderGeometry(rollRadius + 0.005, rollRadius + 0.005, 0.35, 28);
const labelMat = new THREE.MeshStandardMaterial({
color: fenceType === "alambrado_pvc" ? 0x166534 : 0x0f766e,
map: labelTex,
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);
// Arames de cintamento galvanizados no rolo (topo, centro e base)
for (const posFactor of [0.15, 0.5, 0.85]) {
const tieGeo = new THREE.TorusGeometry(rollRadius + 0.007, 0.004, 6, 24);
const tie = new THREE.Mesh(tieGeo, steelGuideMat);
tie.rotation.x = Math.PI / 2;
tie.position.y = rollHeight * posFactor;
rollGroup.add(tie);
}
group.add(rollGroup);
}
@@ -686,49 +915,49 @@ 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 de arame losangular e o rolo da fábrica</span>
<div className="relative z-10 m-4 pointer-events-none flex items-center gap-2 px-3.5 py-2 rounded-xl bg-black/85 backdrop-blur-md border border-zinc-800 text-[11px] text-zinc-300 w-fit shadow-xl">
<Compass className="w-3.5 h-3.5 text-[#a3c745] shrink-0" />
<span>3D Real: Gire em 360° • Zoom na malha de arame, mourões chanfrados e catracas esticadoras</span>
</div>
{/* Badge Inferior */}
<div className="relative z-10 m-4 pointer-events-none flex flex-wrap items-center justify-between gap-2">
<div className="bg-black/85 backdrop-blur-md px-3.5 py-2 rounded-xl border border-zinc-800 text-xs text-zinc-200">
<div className="relative z-10 m-4 pointer-events-none flex flex-wrap items-center justify-between gap-3">
<div className="bg-black/85 backdrop-blur-md px-4 py-2.5 rounded-xl border border-zinc-800 text-xs text-zinc-200 shadow-xl">
<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/85 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>
{/* Alternador de Terrenos Realistas 3D */}
<div className="pointer-events-auto flex items-center gap-1.5 bg-black/90 backdrop-blur-md p-1.5 rounded-xl border border-zinc-700/80 text-[11px] shadow-xl">
<span className="text-zinc-400 font-semibold px-2">Terreno 3D:</span>
<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"
className={`px-3 py-1.5 rounded-lg transition-all flex items-center gap-1 font-medium ${
ground === "grama" ? "bg-[#a3c745] text-black font-bold shadow-sm shadow-[#a3c745]/30" : "text-zinc-300 hover:text-white hover:bg-zinc-800/60"
}`}
>
Grama
🌱 Gramado
</button>
<button
type="button"
onClick={() => setGround("terra")}
className={`px-3 py-1.5 rounded-lg transition-all flex items-center gap-1 font-medium ${
ground === "terra" ? "bg-[#a3c745] text-black font-bold shadow-sm shadow-[#a3c745]/30" : "text-zinc-300 hover:text-white hover:bg-zinc-800/60"
}`}
>
🍂 Terra / Sítio
</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"
className={`px-3 py-1.5 rounded-lg transition-all flex items-center gap-1 font-medium ${
ground === "concreto" ? "bg-[#a3c745] text-black font-bold shadow-sm shadow-[#a3c745]/30" : "text-zinc-300 hover:text-white hover:bg-zinc-800/60"
}`}
>
Concreto
🏢 Concreto
</button>
</div>
</div>