Codels
464 ポリゴン1.00 × 0.21 × 1.00 m
自己完結型の ES モジュールで、依存先は three のみです。ファクトリー関数を呼び出し、返された group をシーンに追加してください。
/**
 * Pressure Plate — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 464 · Size (W × H × D): 1.00 × 0.21 × 1.00 m
 *
 * Usage:
 *   import { createPressurePlate } from './pressure-plate.js';
 *   
 *   const model = createPressurePlate();
 *   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 createPressurePlate() {
  const root = new THREE.Group();
  root.name = 'PressurePlate';

  // Materials
  const frameMat = new THREE.MeshStandardMaterial({ name: 'frame', color: 0x3a4252, roughness: 0.6, metalness: 0.35, flatShading: true });
  const darkMat = new THREE.MeshStandardMaterial({ name: 'dark', color: 0x1c1f26, roughness: 0.8, flatShading: true });
  const steelMat = new THREE.MeshStandardMaterial({ name: 'steel', color: 0xaeb6c2, roughness: 0.3, metalness: 0.75, flatShading: true });
  const plateMat = new THREE.MeshStandardMaterial({ name: 'plate', color: 0xff8a2a, roughness: 0.5, flatShading: true });
  const plateTopMat = new THREE.MeshStandardMaterial({ name: 'plateTop', color: 0xff9844, roughness: 0.5, flatShading: true });
  const markMat = new THREE.MeshStandardMaterial({ name: 'mark', color: 0xa65a1b, roughness: 0.6, flatShading: true });
  const glowMat = new THREE.MeshStandardMaterial({ name: 'glow', color: 0xffb347, roughness: 0.4, emissive: 0xff9a1f, emissiveIntensity: 0.7, flatShading: true });

  // Shared geometries
  const boxGeo = new THREE.BoxGeometry(1, 0.06, 0.09);
  const boxGeo2 = new THREE.BoxGeometry(0.09, 0.06, 0.82);
  const boxGeo3 = new THREE.BoxGeometry(1, 0.012, 0.02);
  const boxGeo4 = new THREE.BoxGeometry(0.02, 0.012, 0.8);
  const cylinderGeo = new THREE.CylinderGeometry(0.022, 0.022, 0.015, 6);
  const boxGeo5 = new THREE.BoxGeometry(0.24, 0.014, 0.035);
  const boxGeo6 = new THREE.BoxGeometry(0.035, 0.014, 0.24);
  const extrudeGeo = extrude([[0, 0], [0.12, -0.12], [0.12, -0.17], [0, -0.05], [-0.12, -0.17], [-0.12, -0.12]], 0.012);

  // Parts
  const frameBase = new THREE.Mesh(new THREE.BoxGeometry(1, 0.04, 1), frameMat);
  frameBase.name = 'frameBase';
  frameBase.position.set(0, 0.02, 0);
  root.add(frameBase);
  const gapGlow = new THREE.Mesh(new THREE.BoxGeometry(0.82, 0.012, 0.82), glowMat);
  gapGlow.name = 'gapGlow';
  gapGlow.position.set(0, 0.046, 0);
  root.add(gapGlow);
  const box3 = new THREE.Mesh(boxGeo, frameMat);
  box3.position.set(0, 0.07, -0.455);
  root.add(box3);
  const box4 = new THREE.Mesh(boxGeo2, frameMat);
  box4.position.set(-0.455, 0.07, 0);
  root.add(box4);
  const box5 = new THREE.Mesh(boxGeo3, darkMat);
  box5.position.set(0, 0.106, -0.422);
  root.add(box5);
  const box6 = new THREE.Mesh(boxGeo4, darkMat);
  box6.position.set(-0.422, 0.106, 0);
  root.add(box6);
  const box7 = new THREE.Mesh(boxGeo, frameMat);
  box7.position.set(0, 0.07, 0.455);
  root.add(box7);
  const box8 = new THREE.Mesh(boxGeo2, frameMat);
  box8.position.set(0.455, 0.07, 0);
  root.add(box8);
  const box9 = new THREE.Mesh(boxGeo3, darkMat);
  box9.position.set(0, 0.106, 0.422);
  root.add(box9);
  const box10 = new THREE.Mesh(boxGeo4, darkMat);
  box10.position.set(0.422, 0.106, 0);
  root.add(box10);
  const cylinder11 = new THREE.Mesh(cylinderGeo, steelMat);
  cylinder11.position.set(-0.455, 0.1075, -0.455);
  root.add(cylinder11);
  const cylinder12 = new THREE.Mesh(cylinderGeo, steelMat);
  cylinder12.position.set(0.455, 0.1075, -0.455);
  root.add(cylinder12);
  const cylinder13 = new THREE.Mesh(cylinderGeo, steelMat);
  cylinder13.position.set(0.455, 0.1075, 0.455);
  root.add(cylinder13);
  const cylinder14 = new THREE.Mesh(cylinderGeo, steelMat);
  cylinder14.position.set(-0.455, 0.1075, 0.455);
  root.add(cylinder14);
  const box15 = new THREE.Mesh(boxGeo5, glowMat);
  box15.position.set(0, 0.107, 0.455);
  root.add(box15);
  const box16 = new THREE.Mesh(boxGeo6, glowMat);
  box16.position.set(0.455, 0.107, 0);
  root.add(box16);
  const box17 = new THREE.Mesh(boxGeo5, glowMat);
  box17.position.set(0, 0.107, -0.455);
  root.add(box17);
  const box18 = new THREE.Mesh(boxGeo6, glowMat);
  box18.position.set(-0.455, 0.107, 0);
  root.add(box18);
  const plate = new THREE.Group();
  plate.name = 'plate';
  plate.position.set(0, 0.08, 0);
  root.add(plate);
  const plateBody = new THREE.Mesh(new THREE.BoxGeometry(0.74, 0.08, 0.74), plateMat);
  plateBody.name = 'plateBody';
  plateBody.position.set(0, 0.04, 0);
  plate.add(plateBody);
  const plateTop = new THREE.Mesh(new THREE.BoxGeometry(0.66, 0.012, 0.66), plateTopMat);
  plateTop.name = 'plateTop';
  plateTop.position.set(0, 0.086, 0);
  plate.add(plateTop);
  const stud = new THREE.Mesh(new THREE.CylinderGeometry(0.09, 0.1, 0.025, 12), markMat);
  stud.name = 'stud';
  stud.position.set(0, 0.1045, 0);
  plate.add(stud);
  const studLight = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 0.012, 12), glowMat);
  studLight.name = 'studLight';
  studLight.position.set(0, 0.123, 0);
  plate.add(studLight);
  const chevron1 = new THREE.Group();
  chevron1.name = 'chevron1';
  chevron1.position.set(0, 0.098, 0);
  plate.add(chevron1);
  const extrude25 = new THREE.Mesh(extrudeGeo, markMat);
  extrude25.position.set(0, 0, -0.12);
  extrude25.rotation.set(deg(90), 0, 0);
  chevron1.add(extrude25);
  const chevron2 = new THREE.Group();
  chevron2.name = 'chevron2';
  chevron2.position.set(0, 0.098, 0);
  chevron2.rotation.set(0, deg(90), 0);
  plate.add(chevron2);
  const extrude27 = new THREE.Mesh(extrudeGeo, markMat);
  extrude27.position.set(0, 0, -0.12);
  extrude27.rotation.set(deg(90), 0, 0);
  chevron2.add(extrude27);
  const chevron3 = new THREE.Group();
  chevron3.name = 'chevron3';
  chevron3.position.set(0, 0.098, 0);
  chevron3.rotation.set(0, deg(180), 0);
  plate.add(chevron3);
  const extrude29 = new THREE.Mesh(extrudeGeo, markMat);
  extrude29.position.set(0, 0, -0.12);
  extrude29.rotation.set(deg(90), 0, 0);
  chevron3.add(extrude29);
  const chevron4 = new THREE.Group();
  chevron4.name = 'chevron4';
  chevron4.position.set(0, 0.098, 0);
  chevron4.rotation.set(0, deg(270), 0);
  plate.add(chevron4);
  const extrude31 = new THREE.Mesh(extrudeGeo, markMat);
  extrude31.position.set(0, 0, -0.12);
  extrude31.rotation.set(deg(90), 0, 0);
  chevron4.add(extrude31);

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

export default createPressurePlate;

評価とコメント

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

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

0 件のコメント

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

関連モデル

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