784 ポリゴン0.62 × 0.90 × 0.63 m
コードで使う
エディターでリミックスbarrel.js · 71 行
自己完結型の ES モジュールで、依存先は three のみです。ファクトリー関数を呼び出し、返された group をシーンに追加してください。
/**
* Barrel — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 784 · Size (W × H × D): 0.62 × 0.90 × 0.63 m
*
* Usage:
* import { createBarrel } from './barrel.js';
*
* const model = createBarrel();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
// Revolve a 2D profile [[radius, y], ...] around the Y axis.
function lathe(points, segments, phiStart = 0, phiLength = Math.PI * 2) {
return new THREE.LatheGeometry(points.map(([x, y]) => new THREE.Vector2(x, y)), segments, phiStart, phiLength);
}
export function createBarrel() {
const root = new THREE.Group();
root.name = 'Barrel';
// Materials
const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0xa8703c, roughness: 0.88, flatShading: true });
const darkMat = new THREE.MeshStandardMaterial({ name: 'dark', color: 0x54381e, roughness: 0.95, flatShading: true });
const hoopMat = new THREE.MeshStandardMaterial({ name: 'hoop', color: 0x55585e, roughness: 0.45, metalness: 0.55, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.4105, 0.004, 0.008);
// Parts
const body = new THREE.Mesh(lathe([[0, 0.03], [0.223, 0.03], [0.223, 0], [0.245, 0], [0.2734, 0.1125], [0.2938, 0.225], [0.3059, 0.3375], [0.31, 0.45], [0.3059, 0.5625], [0.2938, 0.675], [0.2734, 0.7875], [0.245, 0.9], [0.223, 0.9], [0.223, 0.87], [0, 0.87]], 14), woodMat);
body.name = 'body';
root.add(body);
const seam = new THREE.Mesh(boxGeo, darkMat);
seam.name = 'seam';
seam.position.set(0, 0.872, -0.0743);
root.add(seam);
const seam2 = new THREE.Mesh(boxGeo, darkMat);
seam2.name = 'seam';
seam2.position.set(0, 0.872, 0.0743);
root.add(seam2);
const bung = new THREE.Mesh(new THREE.CylinderGeometry(0.028, 0.03, 0.016, 8), darkMat);
bung.name = 'bung';
bung.position.set(0.11, 0.878, 0.06);
root.add(bung);
const hoopBottom = new THREE.Mesh(lathe([[0.2545, 0.0495], [0.2705, 0.0495], [0.2825, 0.099], [0.2665, 0.099]], 14), hoopMat);
hoopBottom.name = 'hoopBottom';
root.add(hoopBottom);
const hoopLow = new THREE.Mesh(lathe([[0.2972, 0.284], [0.3132, 0.284], [0.3172, 0.328], [0.3012, 0.328]], 14), hoopMat);
hoopLow.name = 'hoopLow';
root.add(hoopLow);
const hoopHigh = new THREE.Mesh(lathe([[0.3012, 0.572], [0.3172, 0.572], [0.3132, 0.616], [0.2972, 0.616]], 14), hoopMat);
hoopHigh.name = 'hoopHigh';
root.add(hoopHigh);
const hoopTop = new THREE.Mesh(lathe([[0.2665, 0.801], [0.2825, 0.801], [0.2705, 0.8505], [0.2545, 0.8505]], 14), hoopMat);
hoopTop.name = 'hoopTop';
root.add(hoopTop);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createBarrel;
評価とコメント
0 件のコメント
まだコメントはありません。このモデルの使い方や改善できる点を共有しましょう。
関連モデル
同じカテゴリまたは似たタグ









