528 tris4,00 × 0,17 × 4,00 m
Use no código
Fazer remix no editorroad-t-junction.js · 199 linhas
Módulo ES autocontido — depende apenas do three. Chame a factory e adicione o grupo à sua cena.
/**
* Road T-Junction — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 528 · Size (W × H × D): 4.00 × 0.17 × 4.00 m
*
* Usage:
* import { createRoadTJunction } from './road-t-junction.js';
*
* const model = createRoadTJunction();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
// Extrude a 2D outline along Z (centered). bevel = [thickness, size, segments].
function extrude(outline, depth, holes = [], bevel = null) {
const shape = new THREE.Shape(outline.map(([x, y]) => new THREE.Vector2(x, y)));
for (const hole of holes) shape.holes.push(new THREE.Path(hole.map(([x, y]) => new THREE.Vector2(x, y))));
const options = bevel
? { depth, bevelEnabled: true, bevelThickness: bevel[0], bevelSize: bevel[1], bevelSegments: bevel[2] }
: { depth, bevelEnabled: false };
return new THREE.ExtrudeGeometry(shape, options).translate(0, 0, -depth / 2);
}
export function createRoadTJunction() {
const root = new THREE.Group();
root.name = 'RoadTJunction';
// Materials
const asphaltMat = new THREE.MeshStandardMaterial({ name: 'asphalt', color: 0x41454b, roughness: 0.95, flatShading: true });
const whiteMat = new THREE.MeshStandardMaterial({ name: 'white', color: 0xecebe4, roughness: 0.7, flatShading: true });
const yellowMat = new THREE.MeshStandardMaterial({ name: 'yellow', color: 0xe9b72c, roughness: 0.7, flatShading: true });
const curbMat = new THREE.MeshStandardMaterial({ name: 'curb', color: 0xb4b2ab, roughness: 0.9, flatShading: true });
const paverMat = new THREE.MeshStandardMaterial({ name: 'paver', color: 0x92918b, roughness: 0.95, flatShading: true });
const baseMat = new THREE.MeshStandardMaterial({ name: 'base', color: 0x64635f, roughness: 1, flatShading: true });
const grateMat = new THREE.MeshStandardMaterial({ name: 'grate', color: 0x26292c, roughness: 0.6, metalness: 0.5, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.1, 0.006, 0.65);
const boxGeo2 = new THREE.BoxGeometry(0.11, 0.006, 1);
const boxGeo3 = new THREE.BoxGeometry(0.1, 0.006, 0.45);
const boxGeo4 = new THREE.BoxGeometry(0.498, 0.02, 0.988);
const boxGeo5 = new THREE.BoxGeometry(0.24, 0.006, 0.035);
const extrudeGeo = extrude([[1.35, 2], [1.35, 1.65], [1.3728, 1.5352], [1.4379, 1.4379], [1.5352, 1.3728], [1.65, 1.35], [2, 1.35], [2, 1.49], [1.65, 1.49], [1.5888, 1.5022], [1.5369, 1.5369], [1.5022, 1.5888], [1.49, 1.65], [1.49, 2]], 0.165);
const extrudeGeo2 = extrude([[1.49, 2], [1.49, 1.65], [1.5022, 1.5888], [1.5369, 1.5369], [1.5888, 1.5022], [1.65, 1.49], [2, 1.49], [2, 2]], 0.13);
const extrudeGeo3 = extrude([[1.496, 1.994], [1.496, 1.65], [1.5077, 1.5911], [1.5411, 1.5411], [1.5911, 1.5077], [1.65, 1.496], [1.994, 1.496], [1.994, 1.994]], 0.02);
// Parts
const asphalt = new THREE.Mesh(extrude([[1.35, 2], [1.35, 1.65], [1.3728, 1.5352], [1.4379, 1.4379], [1.5352, 1.3728], [1.65, 1.35], [2, 1.35], [2, -1.35], [-2, -1.35], [-2, 1.35], [-1.65, 1.35], [-1.5352, 1.3728], [-1.4379, 1.4379], [-1.3728, 1.5352], [-1.35, 1.65], [-1.35, 2]], 0.02), asphaltMat);
asphalt.name = 'asphalt';
asphalt.position.set(0, 0.01, 0);
asphalt.rotation.set(deg(90), 0, 0);
root.add(asphalt);
const mainMarkings = new THREE.Group();
mainMarkings.name = 'mainMarkings';
mainMarkings.rotation.set(0, deg(90), 0);
root.add(mainMarkings);
const edgeLine = new THREE.Mesh(new THREE.BoxGeometry(0.1, 0.006, 4), whiteMat);
edgeLine.name = 'edgeLine';
edgeLine.position.set(0.93, 0.022, 0);
mainMarkings.add(edgeLine);
const edgeLine2 = new THREE.Mesh(boxGeo, whiteMat);
edgeLine2.name = 'edgeLine';
edgeLine2.position.set(-0.93, 0.022, -1.675);
mainMarkings.add(edgeLine2);
const edgeLine3 = new THREE.Mesh(boxGeo, whiteMat);
edgeLine3.name = 'edgeLine';
edgeLine3.position.set(-0.93, 0.022, 1.675);
mainMarkings.add(edgeLine3);
const centerDash = new THREE.Mesh(boxGeo2, yellowMat);
centerDash.name = 'centerDash';
centerDash.position.set(0, 0.022, -1);
mainMarkings.add(centerDash);
const centerDash2 = new THREE.Mesh(boxGeo2, yellowMat);
centerDash2.name = 'centerDash';
centerDash2.position.set(0, 0.022, 1);
mainMarkings.add(centerDash2);
const sideArm = new THREE.Group();
sideArm.name = 'sideArm';
root.add(sideArm);
const stopLine = new THREE.Mesh(new THREE.BoxGeometry(0.895, 0.006, 0.1), whiteMat);
stopLine.name = 'stopLine';
stopLine.position.set(0.5325, 0.022, 1.5);
sideArm.add(stopLine);
const centerLine = new THREE.Mesh(new THREE.BoxGeometry(0.11, 0.006, 0.45), yellowMat);
centerLine.name = 'centerLine';
centerLine.position.set(0, 0.022, 1.775);
sideArm.add(centerLine);
const edgeLine4 = new THREE.Mesh(boxGeo3, whiteMat);
edgeLine4.name = 'edgeLine';
edgeLine4.position.set(-0.93, 0.022, 1.775);
sideArm.add(edgeLine4);
const edgeLine5 = new THREE.Mesh(boxGeo3, whiteMat);
edgeLine5.name = 'edgeLine';
edgeLine5.position.set(0.93, 0.022, 1.775);
sideArm.add(edgeLine5);
const sidewalk = new THREE.Group();
sidewalk.name = 'sidewalk';
sidewalk.rotation.set(0, deg(90), 0);
root.add(sidewalk);
const curb = new THREE.Mesh(new THREE.BoxGeometry(0.14, 0.165, 4), curbMat);
curb.name = 'curb';
curb.position.set(1.42, 0.0825, 0);
sidewalk.add(curb);
const sidewalkBase = new THREE.Mesh(new THREE.BoxGeometry(0.51, 0.13, 4), baseMat);
sidewalkBase.name = 'sidewalkBase';
sidewalkBase.position.set(1.745, 0.065, 0);
sidewalk.add(sidewalkBase);
const paver = new THREE.Mesh(boxGeo4, paverMat);
paver.name = 'paver';
paver.position.set(1.745, 0.14, -1.5);
sidewalk.add(paver);
const paver2 = new THREE.Mesh(boxGeo4, paverMat);
paver2.name = 'paver';
paver2.position.set(1.745, 0.14, -0.5);
sidewalk.add(paver2);
const paver3 = new THREE.Mesh(boxGeo4, paverMat);
paver3.name = 'paver';
paver3.position.set(1.745, 0.14, 0.5);
sidewalk.add(paver3);
const paver4 = new THREE.Mesh(boxGeo4, paverMat);
paver4.name = 'paver';
paver4.position.set(1.745, 0.14, 1.5);
sidewalk.add(paver4);
const drainGrate = new THREE.Mesh(new THREE.BoxGeometry(0.3, 0.012, 0.6), grateMat);
drainGrate.name = 'drainGrate';
drainGrate.position.set(1.17, 0.022, -1);
sidewalk.add(drainGrate);
const grateBar = new THREE.Mesh(boxGeo5, baseMat);
grateBar.name = 'grateBar';
grateBar.position.set(1.17, 0.028, -1.22);
sidewalk.add(grateBar);
const grateBar2 = new THREE.Mesh(boxGeo5, baseMat);
grateBar2.name = 'grateBar';
grateBar2.position.set(1.17, 0.028, -1.11);
sidewalk.add(grateBar2);
const grateBar3 = new THREE.Mesh(boxGeo5, baseMat);
grateBar3.name = 'grateBar';
grateBar3.position.set(1.17, 0.028, -1);
sidewalk.add(grateBar3);
const grateBar4 = new THREE.Mesh(boxGeo5, baseMat);
grateBar4.name = 'grateBar';
grateBar4.position.set(1.17, 0.028, -0.89);
sidewalk.add(grateBar4);
const grateBar5 = new THREE.Mesh(boxGeo5, baseMat);
grateBar5.name = 'grateBar';
grateBar5.position.set(1.17, 0.028, -0.78);
sidewalk.add(grateBar5);
const cornerRight = new THREE.Group();
cornerRight.name = 'cornerRight';
root.add(cornerRight);
const curb2 = new THREE.Mesh(extrudeGeo, curbMat);
curb2.name = 'curb';
curb2.position.set(0, 0.0825, 0);
curb2.rotation.set(deg(90), 0, 0);
cornerRight.add(curb2);
const sidewalkBase2 = new THREE.Mesh(extrudeGeo2, baseMat);
sidewalkBase2.name = 'sidewalkBase';
sidewalkBase2.position.set(0, 0.065, 0);
sidewalkBase2.rotation.set(deg(90), 0, 0);
cornerRight.add(sidewalkBase2);
const paver5 = new THREE.Mesh(extrudeGeo3, paverMat);
paver5.name = 'paver';
paver5.position.set(0, 0.14, 0);
paver5.rotation.set(deg(90), 0, 0);
cornerRight.add(paver5);
const cornerLeft = new THREE.Group();
cornerLeft.name = 'cornerLeft';
cornerLeft.rotation.set(0, deg(270), 0);
root.add(cornerLeft);
const curb3 = new THREE.Mesh(extrudeGeo, curbMat);
curb3.name = 'curb';
curb3.position.set(0, 0.0825, 0);
curb3.rotation.set(deg(90), 0, 0);
cornerLeft.add(curb3);
const sidewalkBase3 = new THREE.Mesh(extrudeGeo2, baseMat);
sidewalkBase3.name = 'sidewalkBase';
sidewalkBase3.position.set(0, 0.065, 0);
sidewalkBase3.rotation.set(deg(90), 0, 0);
cornerLeft.add(sidewalkBase3);
const paver6 = new THREE.Mesh(extrudeGeo3, paverMat);
paver6.name = 'paver';
paver6.position.set(0, 0.14, 0);
paver6.rotation.set(deg(90), 0, 0);
cornerLeft.add(paver6);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createRoadTJunction;
Avaliações e comentários
0 comentário
Nenhum comentário ainda. Conte como você usou este modelo ou o que poderia melhorar.
Modelos relacionados
Mesma categoria ou tags parecidas









