Codels
864 三角面0.51 × 0.42 × 0.38 m

在代码中使用

在编辑器中改编
自包含的 ES 模块,仅依赖 three。调用工厂函数,然后把返回的 group 添加到场景中。
/**
 * Toolbox — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 864 · Size (W × H × D): 0.51 × 0.42 × 0.38 m
 *
 * Usage:
 *   import { createToolbox } from './toolbox.js';
 *   
 *   const model = createToolbox();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

const deg = THREE.MathUtils.degToRad;

export function createToolbox() {
  const root = new THREE.Group();
  root.name = 'Toolbox';

  // Materials
  const paintMat = new THREE.MeshStandardMaterial({ name: 'paint', color: 0xc4372d, roughness: 0.45, metalness: 0.25, flatShading: true });
  const paintDarkMat = new THREE.MeshStandardMaterial({ name: 'paintDark', color: 0x7f241d, roughness: 0.5, metalness: 0.2, flatShading: true });
  const metalMat = new THREE.MeshStandardMaterial({ name: 'metal', color: 0xb9bfc7, roughness: 0.3, metalness: 0.6, flatShading: true });
  const blackMat = new THREE.MeshStandardMaterial({ name: 'black', color: 0x26272b, roughness: 0.7, flatShading: true });
  const steelMat = new THREE.MeshStandardMaterial({ name: 'steel', color: 0x8a929c, roughness: 0.35, metalness: 0.55, flatShading: true });
  const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0xc08850, roughness: 0.75, flatShading: true });
  const yellowMat = new THREE.MeshStandardMaterial({ name: 'yellow', color: 0xefbc2c, roughness: 0.5, flatShading: true });

  // Shared geometries
  const boxGeo = new THREE.BoxGeometry(0.5, 0.2, 0.008);
  const boxGeo2 = new THREE.BoxGeometry(0.008, 0.2, 0.204);
  const boxGeo3 = new THREE.BoxGeometry(0.44, 0.012, 0.004);
  const boxGeo4 = new THREE.BoxGeometry(0.504, 0.014, 0.012);
  const boxGeo5 = new THREE.BoxGeometry(0.012, 0.014, 0.216);
  const boxGeo6 = new THREE.BoxGeometry(0.035, 0.03, 0.01);
  const boxGeo7 = new THREE.BoxGeometry(0.014, 0.03, 0.03);
  const boxGeo8 = new THREE.BoxGeometry(0.008, 0.03, 0.01);
  const boxGeo9 = new THREE.BoxGeometry(0.035, 0.035, 0.008);
  const boxGeo10 = new THREE.BoxGeometry(0.275, 0.045, 0.005);
  const boxGeo11 = new THREE.BoxGeometry(0.005, 0.045, 0.194);
  const cylinderGeo = new THREE.CylinderGeometry(0.003, 0.003, 0.035, 4);

  // Parts
  const toolbox = new THREE.Group();
  toolbox.name = 'toolbox';
  toolbox.position.set(0, 0, 0.14);
  root.add(toolbox);
  const bottom = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.008, 0.22), paintMat);
  bottom.name = 'bottom';
  bottom.position.set(0, 0.004, 0);
  toolbox.add(bottom);
  const back = new THREE.Mesh(boxGeo, paintMat);
  back.name = 'back';
  back.position.set(0, 0.1, -0.106);
  toolbox.add(back);
  const side = new THREE.Mesh(boxGeo2, paintMat);
  side.name = 'side';
  side.position.set(-0.246, 0.1, 0);
  toolbox.add(side);
  const rib = new THREE.Mesh(boxGeo3, paintMat);
  rib.name = 'rib';
  rib.position.set(0, 0.05, -0.112);
  toolbox.add(rib);
  const rib2 = new THREE.Mesh(boxGeo3, paintMat);
  rib2.name = 'rib';
  rib2.position.set(0, 0.1, -0.112);
  toolbox.add(rib2);
  const rim = new THREE.Mesh(boxGeo4, paintDarkMat);
  rim.name = 'rim';
  rim.position.set(0, 0.195, -0.106);
  toolbox.add(rim);
  const rim2 = new THREE.Mesh(boxGeo5, paintDarkMat);
  rim2.name = 'rim';
  rim2.position.set(-0.246, 0.195, 0);
  toolbox.add(rim2);
  const latchCatch = new THREE.Mesh(boxGeo6, metalMat);
  latchCatch.name = 'latchCatch';
  latchCatch.position.set(-0.1562, 0.17, 0.114);
  toolbox.add(latchCatch);
  const front = new THREE.Mesh(boxGeo, paintMat);
  front.name = 'front';
  front.position.set(0, 0.1, 0.106);
  toolbox.add(front);
  const side2 = new THREE.Mesh(boxGeo2, paintMat);
  side2.name = 'side';
  side2.position.set(0.246, 0.1, 0);
  toolbox.add(side2);
  const rib3 = new THREE.Mesh(boxGeo3, paintMat);
  rib3.name = 'rib';
  rib3.position.set(0, 0.05, 0.112);
  toolbox.add(rib3);
  const rib4 = new THREE.Mesh(boxGeo3, paintMat);
  rib4.name = 'rib';
  rib4.position.set(0, 0.1, 0.112);
  toolbox.add(rib4);
  const rim3 = new THREE.Mesh(boxGeo4, paintDarkMat);
  rim3.name = 'rim';
  rim3.position.set(0, 0.195, 0.106);
  toolbox.add(rim3);
  const rim4 = new THREE.Mesh(boxGeo5, paintDarkMat);
  rim4.name = 'rim';
  rim4.position.set(0.246, 0.195, 0);
  toolbox.add(rim4);
  const latchCatch2 = new THREE.Mesh(boxGeo6, metalMat);
  latchCatch2.name = 'latchCatch';
  latchCatch2.position.set(0.1563, 0.17, 0.114);
  toolbox.add(latchCatch2);
  const hinge = new THREE.Mesh(new THREE.CylinderGeometry(0.006, 0.006, 0.48, 6), metalMat);
  hinge.name = 'hinge';
  hinge.position.set(0, 0.202, -0.114);
  hinge.rotation.set(0, 0, deg(90));
  toolbox.add(hinge);
  const lid = new THREE.Group();
  lid.name = 'lid';
  lid.position.set(0, 0.2, -0.11);
  lid.rotation.set(deg(-112), 0, 0);
  toolbox.add(lid);
  const lidSkirt = new THREE.Mesh(new THREE.BoxGeometry(0.508, 0.03, 0.228), paintMat);
  lidSkirt.name = 'lidSkirt';
  lidSkirt.position.set(0, 0.015, 0.11);
  lid.add(lidSkirt);
  const lidRoof = new THREE.Mesh(new THREE.CylinderGeometry(0.31, 0.5, 0.045, 4, 1, false, Math.PI / 4), paintMat);
  lidRoof.name = 'lidRoof';
  lidRoof.position.set(0, 0.0525, 0.11);
  lidRoof.scale.set(0.7184, 1, 0.3224);
  lid.add(lidRoof);
  const lidLip = new THREE.Mesh(new THREE.BoxGeometry(0.512, 0.008, 0.232), paintDarkMat);
  lidLip.name = 'lidLip';
  lidLip.position.set(0, 0.008, 0.11);
  lid.add(lidLip);
  const handleGrip = new THREE.Mesh(new THREE.CylinderGeometry(0.014, 0.014, 0.2, 7), blackMat);
  handleGrip.name = 'handleGrip';
  handleGrip.position.set(0, 0.108, 0.11);
  handleGrip.rotation.set(0, 0, deg(90));
  lid.add(handleGrip);
  const handleBracket = new THREE.Mesh(boxGeo7, metalMat);
  handleBracket.name = 'handleBracket';
  handleBracket.position.set(-0.09, 0.085, 0.11);
  lid.add(handleBracket);
  const handleArm = new THREE.Mesh(boxGeo8, metalMat);
  handleArm.name = 'handleArm';
  handleArm.position.set(-0.1, 0.092, 0.11);
  lid.add(handleArm);
  const latch = new THREE.Mesh(boxGeo9, metalMat);
  latch.name = 'latch';
  latch.position.set(-0.1562, 0.005, 0.228);
  lid.add(latch);
  const handleBracket2 = new THREE.Mesh(boxGeo7, metalMat);
  handleBracket2.name = 'handleBracket';
  handleBracket2.position.set(0.09, 0.085, 0.11);
  lid.add(handleBracket2);
  const handleArm2 = new THREE.Mesh(boxGeo8, metalMat);
  handleArm2.name = 'handleArm';
  handleArm2.position.set(0.1, 0.092, 0.11);
  lid.add(handleArm2);
  const latch2 = new THREE.Mesh(boxGeo9, metalMat);
  latch2.name = 'latch';
  latch2.position.set(0.1563, 0.005, 0.228);
  lid.add(latch2);
  const tray = new THREE.Group();
  tray.name = 'tray';
  tray.position.set(-0.0995, 0.145, 0);
  toolbox.add(tray);
  const trayBottom = new THREE.Mesh(new THREE.BoxGeometry(0.275, 0.006, 0.194), paintDarkMat);
  trayBottom.name = 'trayBottom';
  trayBottom.position.set(0, 0.003, 0);
  tray.add(trayBottom);
  const trayWall = new THREE.Mesh(boxGeo10, paintDarkMat);
  trayWall.name = 'trayWall';
  trayWall.position.set(0, 0.0225, -0.0945);
  tray.add(trayWall);
  const trayWall2 = new THREE.Mesh(boxGeo11, paintDarkMat);
  trayWall2.name = 'trayWall';
  trayWall2.position.set(-0.135, 0.0225, 0);
  tray.add(trayWall2);
  const trayWall3 = new THREE.Mesh(boxGeo10, paintDarkMat);
  trayWall3.name = 'trayWall';
  trayWall3.position.set(0, 0.0225, 0.0945);
  tray.add(trayWall3);
  const trayWall4 = new THREE.Mesh(boxGeo11, paintDarkMat);
  trayWall4.name = 'trayWall';
  trayWall4.position.set(0.135, 0.0225, 0);
  tray.add(trayWall4);
  const trayDivider = new THREE.Mesh(new THREE.BoxGeometry(0.005, 0.035, 0.194), paintDarkMat);
  trayDivider.name = 'trayDivider';
  trayDivider.position.set(0.0275, 0.0175, 0);
  tray.add(trayDivider);
  const tapeMeasure = new THREE.Mesh(new THREE.CylinderGeometry(0.034, 0.034, 0.026, 9), yellowMat);
  tapeMeasure.name = 'tapeMeasure';
  tapeMeasure.position.set(-0.0875, 0.04, 0);
  tapeMeasure.rotation.set(deg(90), 0, 0);
  tray.add(tapeMeasure);
  const tapeHub = new THREE.Mesh(new THREE.CylinderGeometry(0.014, 0.014, 0.028, 6), blackMat);
  tapeHub.name = 'tapeHub';
  tapeHub.position.set(-0.0875, 0.04, 0);
  tapeHub.rotation.set(deg(90), 0, 0);
  tray.add(tapeHub);
  const tapeTab = new THREE.Mesh(new THREE.BoxGeometry(0.02, 0.012, 0.03), blackMat);
  tapeTab.name = 'tapeTab';
  tapeTab.position.set(-0.0525, 0.012, 0);
  tray.add(tapeTab);
  const screw = new THREE.Mesh(cylinderGeo, steelMat);
  screw.name = 'screw';
  screw.position.set(0.0909, 0.01, -0.0766);
  screw.rotation.set(deg(90), deg(119.3709), 0);
  tray.add(screw);
  const screw2 = new THREE.Mesh(cylinderGeo, steelMat);
  screw2.name = 'screw';
  screw2.position.set(0.0642, 0.01, 0.0065);
  screw2.rotation.set(deg(90), deg(12.7375), 0);
  tray.add(screw2);
  const screw3 = new THREE.Mesh(cylinderGeo, steelMat);
  screw3.name = 'screw';
  screw3.position.set(0.0479, 0.01, 0.0648);
  screw3.rotation.set(deg(90), deg(174.7), 0);
  tray.add(screw3);
  const screw4 = new THREE.Mesh(cylinderGeo, steelMat);
  screw4.name = 'screw';
  screw4.position.set(0.0648, 0.01, 0.0668);
  screw4.rotation.set(deg(90), deg(68.8931), 0);
  tray.add(screw4);
  const screw5 = new THREE.Mesh(cylinderGeo, steelMat);
  screw5.name = 'screw';
  screw5.position.set(0.0493, 0.01, -0.0691);
  screw5.rotation.set(deg(90), deg(81.5393), 0);
  tray.add(screw5);
  const screw6 = new THREE.Mesh(cylinderGeo, steelMat);
  screw6.name = 'screw';
  screw6.position.set(0.1122, 0.01, 0.0202);
  screw6.rotation.set(deg(90), deg(86.5884), 0);
  tray.add(screw6);
  const screw7 = new THREE.Mesh(cylinderGeo, steelMat);
  screw7.name = 'screw';
  screw7.position.set(0.081, 0.01, -0.0463);
  screw7.rotation.set(deg(90), deg(177.8184), 0);
  tray.add(screw7);
  const pencil = new THREE.Mesh(new THREE.CylinderGeometry(0.004, 0.004, 0.15, 6), yellowMat);
  pencil.name = 'pencil';
  pencil.position.set(0.0688, 0.012, -0.077);
  pencil.rotation.set(0, deg(8), deg(90));
  tray.add(pencil);
  const hammer = new THREE.Group();
  hammer.name = 'hammer';
  hammer.position.set(-0.08, 0.022, -0.06);
  hammer.rotation.set(0, 0, deg(12));
  toolbox.add(hammer);
  const hammerHandle = new THREE.Mesh(new THREE.CylinderGeometry(0.011, 0.012, 0.3, 6), woodMat);
  hammerHandle.name = 'hammerHandle';
  hammerHandle.position.set(0.15, 0, 0);
  hammerHandle.rotation.set(0, 0, deg(-90));
  hammerHandle.scale.set(1, 1, 0.75);
  hammer.add(hammerHandle);
  const hammerHead = new THREE.Mesh(new THREE.BoxGeometry(0.024, 0.024, 0.11), steelMat);
  hammerHead.name = 'hammerHead';
  hammerHead.position.set(0.3, 0, 0.02);
  hammer.add(hammerHead);
  const hammerFace = new THREE.Mesh(new THREE.CylinderGeometry(0.013, 0.013, 0.012, 7), steelMat);
  hammerFace.name = 'hammerFace';
  hammerFace.position.set(0.3, 0, 0.08);
  hammerFace.rotation.set(deg(90), 0, 0);
  hammer.add(hammerFace);
  const screwdriver = new THREE.Group();
  screwdriver.name = 'screwdriver';
  screwdriver.position.set(0.1795, 0.012, 0.055);
  screwdriver.rotation.set(deg(-27.3841), deg(-5.161), deg(20.9615));
  toolbox.add(screwdriver);
  const driverShaft = new THREE.Mesh(new THREE.CylinderGeometry(0.0045, 0.0045, 0.13, 5), steelMat);
  driverShaft.name = 'driverShaft';
  driverShaft.position.set(0, 0.065, 0);
  screwdriver.add(driverShaft);
  const driverHandle = new THREE.Mesh(new THREE.CylinderGeometry(0.014, 0.016, 0.095, 6), yellowMat);
  driverHandle.name = 'driverHandle';
  driverHandle.position.set(0, 0.1775, 0);
  screwdriver.add(driverHandle);
  const driverCap = new THREE.Mesh(new THREE.CylinderGeometry(0.016, 0.014, 0.015, 6), blackMat);
  driverCap.name = 'driverCap';
  driverCap.position.set(0, 0.2325, 0);
  screwdriver.add(driverCap);
  const wrench = new THREE.Group();
  wrench.name = 'wrench';
  wrench.position.set(0.0795, 0.02, 0);
  wrench.rotation.set(deg(-90), 0, deg(95));
  toolbox.add(wrench);
  const wrenchBar = new THREE.Mesh(new THREE.BoxGeometry(0.022, 0.17, 0.006), steelMat);
  wrenchBar.name = 'wrenchBar';
  wrenchBar.position.set(0, 0.085, 0);
  wrench.add(wrenchBar);
  const wrenchRing = new THREE.Mesh(new THREE.TorusGeometry(0.019, 0.007, 3, 8), steelMat);
  wrenchRing.name = 'wrenchRing';
  wrenchRing.position.set(0, 0.19, 0);
  wrench.add(wrenchRing);
  const wrenchJaw = new THREE.Mesh(new THREE.TorusGeometry(0.018, 0.007, 3, 8, 4.0841), steelMat);
  wrenchJaw.name = 'wrenchJaw';
  wrenchJaw.position.set(0, -0.012, 0);
  wrenchJaw.rotation.set(0, 0, deg(113));
  wrench.add(wrenchJaw);

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

export default createToolbox;

评分与评论

—
暂无评分,快来抢先评分吧。
5
0
4
0
3
0
2
0
1
0

登录后即可评分和评论。

0 条评论

暂无评论。分享一下你是如何使用这个模型的,或者有哪些可以改进的地方。

相关模型

同一分类或相似标签