Codels
364 üçgen2,17 × 0,84 × 0,62 m
Bağımsız bir ES modülü — yalnızca three paketine bağımlıdır. Fabrika fonksiyonunu çağırıp dönen grubu sahnene ekle.
/**
 * Jersey Barrier — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 364 · Size (W × H × D): 2.17 × 0.83 × 0.62 m
 *
 * Usage:
 *   import { createJerseyBarrier } from './jersey-barrier.js';
 *   
 *   const model = createJerseyBarrier();
 *   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 createJerseyBarrier() {
  const root = new THREE.Group();
  root.name = 'JerseyBarrier';

  // Materials
  const concreteMat = new THREE.MeshStandardMaterial({ name: 'concrete', color: 0xb8b4aa, roughness: 0.95, flatShading: true });
  const darkMat = new THREE.MeshStandardMaterial({ name: 'dark', color: 0x343230, roughness: 1, flatShading: true });
  const steelMat = new THREE.MeshStandardMaterial({ name: 'steel', color: 0x6d7378, roughness: 0.5, metalness: 0.6, flatShading: true });
  const whiteMat = new THREE.MeshStandardMaterial({ name: 'white', color: 0xf1f1ec, roughness: 0.35, emissive: 0xffffff, emissiveIntensity: 0.15, flatShading: true });
  const redMat = new THREE.MeshStandardMaterial({ name: 'red', color: 0xcf2a24, roughness: 0.35, emissive: 0xa01010, emissiveIntensity: 0.25, flatShading: true });
  const amberMat = new THREE.MeshStandardMaterial({ name: 'amber', color: 0xffb22e, roughness: 0.25, emissive: 0xff9a1a, emissiveIntensity: 0.7, flatShading: true });

  // Shared geometries
  const boxGeo = new THREE.BoxGeometry(0.34, 0.07, 0.616);
  const torusGeo = new THREE.TorusGeometry(0.045, 0.012, 4, 8);
  const planeGeo = new THREE.PlaneGeometry(0.24, 0.1);
  const boxGeo2 = new THREE.BoxGeometry(0.08, 0.025, 0.05);

  // Parts
  const barrier = new THREE.Mesh(extrude([[-0.305, 0], [0.305, 0], [0.305, 0.075], [0.2, 0.33], [0.075, 0.81], [-0.075, 0.81], [-0.2, 0.33], [-0.305, 0.075]], 2), concreteMat);
  barrier.name = 'barrier';
  barrier.rotation.set(0, deg(90), 0);
  root.add(barrier);
  const slot = new THREE.Mesh(boxGeo, darkMat);
  slot.name = 'slot';
  slot.position.set(-0.5, 0.035, 0);
  root.add(slot);
  const slot2 = new THREE.Mesh(boxGeo, darkMat);
  slot2.name = 'slot';
  slot2.position.set(0.5, 0.035, 0);
  root.add(slot2);
  const loop = new THREE.Mesh(torusGeo, steelMat);
  loop.name = 'loop';
  loop.position.set(-1.03, 0.2, 0);
  loop.rotation.set(deg(90), 0, 0);
  root.add(loop);
  const loop2 = new THREE.Mesh(torusGeo, steelMat);
  loop2.name = 'loop';
  loop2.position.set(-1.03, 0.62, 0);
  loop2.rotation.set(deg(90), 0, 0);
  root.add(loop2);
  const loop3 = new THREE.Mesh(torusGeo, steelMat);
  loop3.name = 'loop';
  loop3.position.set(1.03, 0.2, 0);
  loop3.rotation.set(deg(90), 0, 0);
  root.add(loop3);
  const loop4 = new THREE.Mesh(torusGeo, steelMat);
  loop4.name = 'loop';
  loop4.position.set(1.03, 0.62, 0);
  loop4.rotation.set(deg(90), 0, 0);
  root.add(loop4);
  const reflectorTape = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape.name = 'reflectorTape';
  reflectorTape.position.set(-0.875, 0.6, -0.1327);
  reflectorTape.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape);
  const reflectorTape2 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape2.name = 'reflectorTape';
  reflectorTape2.position.set(-0.625, 0.6, -0.1327);
  reflectorTape2.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape2);
  const reflectorTape3 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape3.name = 'reflectorTape';
  reflectorTape3.position.set(-0.375, 0.6, -0.1327);
  reflectorTape3.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape3);
  const reflectorTape4 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape4.name = 'reflectorTape';
  reflectorTape4.position.set(-0.125, 0.6, -0.1327);
  reflectorTape4.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape4);
  const reflectorTape5 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape5.name = 'reflectorTape';
  reflectorTape5.position.set(0.125, 0.6, -0.1327);
  reflectorTape5.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape5);
  const reflectorTape6 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape6.name = 'reflectorTape';
  reflectorTape6.position.set(0.375, 0.6, -0.1327);
  reflectorTape6.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape6);
  const reflectorTape7 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape7.name = 'reflectorTape';
  reflectorTape7.position.set(0.625, 0.6, -0.1327);
  reflectorTape7.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape7);
  const reflectorTape8 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape8.name = 'reflectorTape';
  reflectorTape8.position.set(0.875, 0.6, -0.1327);
  reflectorTape8.rotation.set(deg(-165.4034), 0, 0);
  root.add(reflectorTape8);
  const reflectorTape9 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape9.name = 'reflectorTape';
  reflectorTape9.position.set(-0.875, 0.6, 0.1327);
  reflectorTape9.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape9);
  const reflectorTape10 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape10.name = 'reflectorTape';
  reflectorTape10.position.set(-0.625, 0.6, 0.1327);
  reflectorTape10.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape10);
  const reflectorTape11 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape11.name = 'reflectorTape';
  reflectorTape11.position.set(-0.375, 0.6, 0.1327);
  reflectorTape11.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape11);
  const reflectorTape12 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape12.name = 'reflectorTape';
  reflectorTape12.position.set(-0.125, 0.6, 0.1327);
  reflectorTape12.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape12);
  const reflectorTape13 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape13.name = 'reflectorTape';
  reflectorTape13.position.set(0.125, 0.6, 0.1327);
  reflectorTape13.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape13);
  const reflectorTape14 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape14.name = 'reflectorTape';
  reflectorTape14.position.set(0.375, 0.6, 0.1327);
  reflectorTape14.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape14);
  const reflectorTape15 = new THREE.Mesh(planeGeo, whiteMat);
  reflectorTape15.name = 'reflectorTape';
  reflectorTape15.position.set(0.625, 0.6, 0.1327);
  reflectorTape15.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape15);
  const reflectorTape16 = new THREE.Mesh(planeGeo, redMat);
  reflectorTape16.name = 'reflectorTape';
  reflectorTape16.position.set(0.875, 0.6, 0.1327);
  reflectorTape16.rotation.set(deg(-14.5966), 0, 0);
  root.add(reflectorTape16);
  const catEye = new THREE.Mesh(boxGeo2, amberMat);
  catEye.name = 'catEye';
  catEye.position.set(-0.5, 0.8225, 0);
  root.add(catEye);
  const catEye2 = new THREE.Mesh(boxGeo2, amberMat);
  catEye2.name = 'catEye';
  catEye2.position.set(0.5, 0.8225, 0);
  root.add(catEye2);

  root.traverse((o) => {
    if (o.isMesh) {
      o.castShadow = true;
      o.receiveShadow = true;
    }
  });
  return root;
}

export default createJerseyBarrier;

Puanlar ve yorumlar

—
Henüz puan yok — ilk puanı sen ver.
5
0
4
0
3
0
2
0
1
0

Puan vermek ve yorum yapmak için giriş yap.

0 yorum

Henüz yorum yok. Bu modeli nasıl kullandığını ya da neyin daha iyi olabileceğini paylaş.

Benzer modeller

Aynı kategori ya da benzer etiketler