Codels
366 ポリゴン0.10 × 0.69 × 0.30 m
自己完結型の ES モジュールで、依存先は three のみです。ファクトリー関数を呼び出し、返された group をシーンに追加してください。
/**
 * Torch — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 366 · Size (W × H × D): 0.10 × 0.69 × 0.30 m
 *
 * Usage:
 *   import { createWallTorch } from './wall-torch.js';
 *   
 *   const model = createWallTorch();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

const deg = THREE.MathUtils.degToRad;

// Deterministic vertex displacement (organic low-poly look).
function jitter(geometry, amount, seed) {
  const pos = geometry.attributes.position;
  const h = (a, b, c, s) => {
    let x = Math.imul(a, 73856093) ^ Math.imul(b, 19349663) ^ Math.imul(c, 83492791) ^ Math.imul(s, 2654435761);
    x = Math.imul(x ^ (x >>> 16), 2246822507);
    x = Math.imul(x ^ (x >>> 13), 3266489909);
    return ((x ^ (x >>> 16)) >>> 0) / 4294967295 - 0.5;
  };
  for (let i = 0; i < pos.count; i++) {
    const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);
    const qx = Math.round(x * 1000), qy = Math.round(y * 1000), qz = Math.round(z * 1000);
    pos.setXYZ(i, x + h(qx, qy, qz, seed) * 2 * amount, y + h(qx, qy, qz, seed + 1) * 2 * amount, z + h(qx, qy, qz, seed + 2) * 2 * amount);
  }
  pos.needsUpdate = true;
  geometry.computeVertexNormals();
  return geometry;
}

export function createWallTorch() {
  const root = new THREE.Group();
  root.name = 'WallTorch';

  // Materials
  const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0x8a5a32, roughness: 0.85, flatShading: true });
  const woodDarkMat = new THREE.MeshStandardMaterial({ name: 'woodDark', color: 0x5e3b20, roughness: 0.9, flatShading: true });
  const wrapMat = new THREE.MeshStandardMaterial({ name: 'wrap', color: 0x3a2a20, roughness: 1, flatShading: true });
  const ropeMat = new THREE.MeshStandardMaterial({ name: 'rope', color: 0xa07a4c, roughness: 0.95, flatShading: true });
  const ironMat = new THREE.MeshStandardMaterial({ name: 'iron', color: 0x4a4d54, roughness: 0.5, metalness: 0.5, flatShading: true });
  const flameOuterMat = new THREE.MeshStandardMaterial({ name: 'flameOuter', color: 0xff570f, roughness: 1, emissive: 0xff570f, emissiveIntensity: 1.3, flatShading: true });
  const flameMidMat = new THREE.MeshStandardMaterial({ name: 'flameMid', color: 0xff8a1e, roughness: 1, emissive: 0xff8a1e, emissiveIntensity: 1.7, flatShading: true });
  const flameCoreMat = new THREE.MeshStandardMaterial({ name: 'flameCore', color: 0xffd384, roughness: 1, emissive: 0xffd384, emissiveIntensity: 2, flatShading: true });

  // Shared geometries
  const cylinderGeo = new THREE.CylinderGeometry(0.01, 0.01, 0.006, 6);

  // Parts
  const wallTorch = new THREE.Group();
  wallTorch.name = 'wallTorch';
  wallTorch.position.set(0, 0, -0.15);
  root.add(wallTorch);
  const wallPlate = new THREE.Mesh(new THREE.BoxGeometry(0.09, 0.2, 0.014), ironMat);
  wallPlate.name = 'wallPlate';
  wallPlate.position.set(0, 0.14, 0.007);
  wallTorch.add(wallPlate);
  const rivet = new THREE.Mesh(cylinderGeo, woodDarkMat);
  rivet.name = 'rivet';
  rivet.position.set(0, 0.07, 0.016);
  rivet.rotation.set(deg(90), 0, 0);
  wallTorch.add(rivet);
  const rivet2 = new THREE.Mesh(cylinderGeo, woodDarkMat);
  rivet2.name = 'rivet';
  rivet2.position.set(0, 0.21, 0.016);
  rivet2.rotation.set(deg(90), 0, 0);
  wallTorch.add(rivet2);
  const arm = new THREE.Mesh(new THREE.BoxGeometry(0.022, 0.022, 0.1), ironMat);
  arm.name = 'arm';
  arm.position.set(0, 0.15, 0.06);
  wallTorch.add(arm);
  const strut = new THREE.Mesh(new THREE.BoxGeometry(0.018, 0.09, 0.018), ironMat);
  strut.name = 'strut';
  strut.position.set(0, 0.1, 0.05);
  strut.rotation.set(deg(-40), 0, 0);
  wallTorch.add(strut);
  const collar = new THREE.Mesh(new THREE.TorusGeometry(0.036, 0.009, 5, 10), ironMat);
  collar.name = 'collar';
  collar.position.set(0, 0.17, 0.11);
  collar.rotation.set(deg(70), 0, 0);
  wallTorch.add(collar);
  const torch = new THREE.Group();
  torch.name = 'torch';
  torch.position.set(0, 0, 0.0481);
  torch.rotation.set(deg(20), 0, 0);
  wallTorch.add(torch);
  const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.024, 0.017, 0.42, 6), woodMat);
  handle.name = 'handle';
  handle.position.set(0, 0.21, 0);
  torch.add(handle);
  const head = new THREE.Mesh(new THREE.CylinderGeometry(0.042, 0.03, 0.1, 7), wrapMat);
  head.name = 'head';
  head.position.set(0, 0.42, 0);
  torch.add(head);
  const band = new THREE.Mesh(new THREE.CylinderGeometry(0.044, 0.044, 0.016, 7), ropeMat);
  band.name = 'band';
  band.position.set(0, 0.393, 0);
  torch.add(band);
  const band2 = new THREE.Mesh(new THREE.CylinderGeometry(0.046, 0.046, 0.016, 7), ropeMat);
  band2.name = 'band';
  band2.position.set(0, 0.448, 0);
  torch.add(band2);
  const flame = new THREE.Group();
  flame.name = 'flame';
  flame.position.set(0, 0.47, 0);
  torch.add(flame);
  const flameBase = new THREE.Mesh(new THREE.IcosahedronGeometry(0.048, 0), flameMidMat);
  flameBase.name = 'flameBase';
  flameBase.position.set(0, 0.03, 0);
  flameBase.scale.set(1, 0.8, 1);
  flame.add(flameBase);
  const flameBack = new THREE.Mesh(jitter(new THREE.ConeGeometry(0.052, 0.24, 6), 0.008, 2), flameOuterMat);
  flameBack.name = 'flameBack';
  flameBack.position.set(0, 0.13, -0.012);
  flameBack.rotation.set(deg(-6), 0, 0);
  flame.add(flameBack);
  const tongueL = new THREE.Mesh(new THREE.ConeGeometry(0.032, 0.14, 5), flameOuterMat);
  tongueL.name = 'tongueL';
  tongueL.position.set(-0.03, 0.09, 0.006);
  tongueL.rotation.set(0, 0, deg(18));
  flame.add(tongueL);
  const tongueR = new THREE.Mesh(new THREE.ConeGeometry(0.03, 0.13, 5), flameMidMat);
  tongueR.name = 'tongueR';
  tongueR.position.set(0.032, 0.085, 0.004);
  tongueR.rotation.set(0, 0, deg(-16));
  flame.add(tongueR);
  const flameMid = new THREE.Mesh(jitter(new THREE.ConeGeometry(0.04, 0.17, 6), 0.006, 5), flameMidMat);
  flameMid.name = 'flameMid';
  flameMid.position.set(0.004, 0.1, 0.016);
  flameMid.rotation.set(deg(8), 0, deg(-4));
  flame.add(flameMid);
  const flameCore = new THREE.Mesh(new THREE.ConeGeometry(0.026, 0.1, 5), flameCoreMat);
  flameCore.name = 'flameCore';
  flameCore.position.set(0, 0.065, 0.034);
  flameCore.rotation.set(deg(10), 0, 0);
  flame.add(flameCore);

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

export default createWallTorch;

評価とコメント

—
まだ評価はありません。最初の評価をしてみましょう。
5
0
4
0
3
0
2
0
1
0

評価やコメントをするにはログインしてください。

0 件のコメント

まだコメントはありません。このモデルの使い方や改善できる点を共有しましょう。

関連モデル

同じカテゴリまたは似たタグ