Codels
1,2 B üçgen0,35 × 0,69 × 0,37 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.
/**
 * Energy Cell — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 1,204 · Size (W × H × D): 0.35 × 0.69 × 0.37 m
 *
 * Usage:
 *   import { createEnergyCell } from './energy-cell.js';
 *   
 *   const model = createEnergyCell();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

const deg = THREE.MathUtils.degToRad;

// Tube along a smooth curve through the given points.
function tube(path, radius, tubularSegments, radialSegments, closed = false) {
  const curve = new THREE.CatmullRomCurve3(path.map(([x, y, z]) => new THREE.Vector3(x, y, z)), closed);
  return new THREE.TubeGeometry(curve, tubularSegments, radius, radialSegments, closed);
}

export function createEnergyCell() {
  const root = new THREE.Group();
  root.name = 'EnergyCell';

  // Materials
  const metalMat = new THREE.MeshStandardMaterial({ name: 'metal', color: 0xb4bcc6, roughness: 0.3, metalness: 0.7, flatShading: true });
  const darkMat = new THREE.MeshStandardMaterial({ name: 'dark', color: 0x363c45, roughness: 0.55, metalness: 0.5, flatShading: true });
  const glassMat = new THREE.MeshStandardMaterial({ name: 'glass', color: 0xa8dcf0, roughness: 0.08, metalness: 0.2, transparent: true, opacity: 0.35 });
  const glowMat = new THREE.MeshStandardMaterial({ name: 'glow', color: 0x46ffa8, roughness: 0.4, emissive: 0x46ffa8, emissiveIntensity: 1.6, flatShading: true });

  // Shared geometries
  const cylinderGeo = new THREE.CylinderGeometry(0.155, 0.17, 0.05, 14);
  const boxGeo = new THREE.BoxGeometry(0.04, 0.03, 0.02);
  const boxGeo2 = new THREE.BoxGeometry(0.03, 0.36, 0.03);

  // Parts
  const cell = new THREE.Group();
  cell.name = 'cell';
  root.add(cell);
  const baseCap = new THREE.Mesh(new THREE.CylinderGeometry(0.17, 0.18, 0.08, 14), metalMat);
  baseCap.name = 'baseCap';
  baseCap.position.set(0, 0.04, 0);
  cell.add(baseCap);
  const baseRing = new THREE.Mesh(cylinderGeo, darkMat);
  baseRing.name = 'baseRing';
  baseRing.position.set(0, 0.105, 0);
  cell.add(baseRing);
  const chargeLed1 = new THREE.Mesh(boxGeo, glowMat);
  chargeLed1.name = 'chargeLed1';
  chargeLed1.position.set(-0.0724, 0.04, 0.1626);
  chargeLed1.rotation.set(0, deg(-24), 0);
  cell.add(chargeLed1);
  const chargeLed2 = new THREE.Mesh(boxGeo, glowMat);
  chargeLed2.name = 'chargeLed2';
  chargeLed2.position.set(-0.0248, 0.04, 0.1763);
  chargeLed2.rotation.set(0, deg(-8), 0);
  cell.add(chargeLed2);
  const chargeLed3 = new THREE.Mesh(boxGeo, glowMat);
  chargeLed3.name = 'chargeLed3';
  chargeLed3.position.set(0.0248, 0.04, 0.1763);
  chargeLed3.rotation.set(0, deg(8), 0);
  cell.add(chargeLed3);
  const chargeLed4 = new THREE.Mesh(boxGeo, darkMat);
  chargeLed4.name = 'chargeLed4';
  chargeLed4.position.set(0.0724, 0.04, 0.1626);
  chargeLed4.rotation.set(0, deg(24), 0);
  cell.add(chargeLed4);
  const glassTube = new THREE.Mesh(new THREE.CylinderGeometry(0.14, 0.14, 0.36, 18), glassMat);
  glassTube.name = 'glassTube';
  glassTube.position.set(0, 0.31, 0);
  cell.add(glassTube);
  const core = new THREE.Mesh(new THREE.CylinderGeometry(0.055, 0.055, 0.272, 10), glowMat);
  core.name = 'core';
  core.position.set(0, 0.276, 0);
  cell.add(core);
  const coreEmpty = new THREE.Mesh(new THREE.CylinderGeometry(0.045, 0.045, 0.068, 10), darkMat);
  coreEmpty.name = 'coreEmpty';
  coreEmpty.position.set(0, 0.446, 0);
  cell.add(coreEmpty);
  const coil = new THREE.Mesh(tube([[0, 0.16, 0.088], [0.044, 0.1671, 0.0762], [0.0762, 0.1743, 0.044], [0.088, 0.1814, 0], [0.0762, 0.1886, -0.044], [0.044, 0.1957, -0.0762], [0, 0.2029, -0.088], [-0.044, 0.21, -0.0762], [-0.0762, 0.2171, -0.044], [-0.088, 0.2243, 0], [-0.0762, 0.2314, 0.044], [-0.044, 0.2386, 0.0762], [0, 0.2457, 0.088], [0.044, 0.2529, 0.0762], [0.0762, 0.26, 0.044], [0.088, 0.2671, 0], [0.0762, 0.2743, -0.044], [0.044, 0.2814, -0.0762], [0, 0.2886, -0.088], [-0.044, 0.2957, -0.0762], [-0.0762, 0.3029, -0.044], [-0.088, 0.31, 0], [-0.0762, 0.3171, 0.044], [-0.044, 0.3243, 0.0762], [0, 0.3314, 0.088], [0.044, 0.3386, 0.0762], [0.0762, 0.3457, 0.044], [0.088, 0.3529, 0], [0.0762, 0.36, -0.044], [0.044, 0.3671, -0.0762], [0, 0.3743, -0.088], [-0.044, 0.3814, -0.0762], [-0.0762, 0.3886, -0.044], [-0.088, 0.3957, 0], [-0.0762, 0.4029, 0.044], [-0.044, 0.41, 0.0762], [0, 0.4171, 0.088], [0.044, 0.4243, 0.0762], [0.0762, 0.4314, 0.044], [0.088, 0.4386, 0], [0.0762, 0.4457, -0.044], [0.044, 0.4529, -0.0762], [0, 0.46, -0.088]], 0.008, 84, 4), glowMat);
  coil.name = 'coil';
  cell.add(coil);
  const cageBar1 = new THREE.Mesh(boxGeo2, darkMat);
  cageBar1.name = 'cageBar1';
  cageBar1.position.set(0.1299, 0.31, 0.075);
  cageBar1.rotation.set(0, deg(60), 0);
  cell.add(cageBar1);
  const cageBar2 = new THREE.Mesh(boxGeo2, darkMat);
  cageBar2.name = 'cageBar2';
  cageBar2.position.set(0, 0.31, -0.15);
  cageBar2.rotation.set(0, deg(180), 0);
  cell.add(cageBar2);
  const cageBar3 = new THREE.Mesh(boxGeo2, darkMat);
  cageBar3.name = 'cageBar3';
  cageBar3.position.set(-0.1299, 0.31, 0.075);
  cageBar3.rotation.set(0, deg(300), 0);
  cell.add(cageBar3);
  const topRing = new THREE.Mesh(cylinderGeo, darkMat);
  topRing.name = 'topRing';
  topRing.position.set(0, 0.515, 0);
  cell.add(topRing);
  const topCap = new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.17, 0.07, 14), metalMat);
  topCap.name = 'topCap';
  topCap.position.set(0, 0.575, 0);
  cell.add(topCap);
  const terminal = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.065, 0.07, 10), metalMat);
  terminal.name = 'terminal';
  terminal.position.set(0, 0.645, 0);
  cell.add(terminal);
  const terminalGlow = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.03, 0.012, 8), glowMat);
  terminalGlow.name = 'terminalGlow';
  terminalGlow.position.set(0, 0.686, 0);
  cell.add(terminalGlow);

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

export default createEnergyCell;

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