342 треуг.0,17 × 0,34 × 0,11 m
Использовать в коде
Ремикс в редактореhammer.js · 99 строк
Самодостаточный ES-модуль — зависит только от three. Вызовите фабрику и добавьте группу в сцену.
/**
* Hammer — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 342 · Size (W × H × D): 0.17 × 0.34 × 0.11 m
*
* Usage:
* import { createHammer } from './hammer.js';
*
* const model = createHammer();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
// 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);
}
// 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 createHammer() {
const root = new THREE.Group();
root.name = 'Hammer';
// Materials
const steelMat = new THREE.MeshStandardMaterial({ name: 'steel', color: 0x7b828c, roughness: 0.42, metalness: 0.45, flatShading: true });
const polishedMat = new THREE.MeshStandardMaterial({ name: 'polished', color: 0xa9aeb4, roughness: 0.25, metalness: 0.55, flatShading: true });
const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0xb47a43, roughness: 0.75, flatShading: true });
// Shared geometries
const extrudeGeo = extrude([[-0.0446, 0.2955], [-0.0541, 0.2932], [-0.0635, 0.2898], [-0.0726, 0.2855], [-0.0813, 0.2801], [-0.0895, 0.2737], [-0.0971, 0.2664], [-0.1017, 0.2697], [-0.0959, 0.2793], [-0.089, 0.2884], [-0.0811, 0.2968], [-0.0722, 0.3045], [-0.0625, 0.3112], [-0.052, 0.317]], 0.009);
// Parts
const hammer = new THREE.Group();
hammer.name = 'hammer';
hammer.position.set(0, 0.002, 0);
hammer.rotation.set(0, deg(30), 0);
root.add(hammer);
const tool = new THREE.Group();
tool.name = 'tool';
tool.position.set(0, 0.33, 0);
tool.rotation.set(deg(180), 0, 0);
hammer.add(tool);
const handle = new THREE.Mesh(lathe([[0, -0.004], [0.015, -0.004], [0.018, 0.01], [0.018, 0.06], [0.015, 0.15], [0.0115, 0.25], [0.0125, 0.3], [0, 0.302]], 7), woodMat);
handle.name = 'handle';
handle.scale.set(1, 1, 0.72);
tool.add(handle);
const eye = new THREE.Mesh(new THREE.BoxGeometry(0.034, 0.048, 0.027), steelMat);
eye.name = 'eye';
eye.position.set(0, 0.304, 0);
tool.add(eye);
const wedge = new THREE.Mesh(new THREE.BoxGeometry(0.03, 0.006, 0.012), woodMat);
wedge.name = 'wedge';
wedge.position.set(0, 0.329, 0);
tool.add(wedge);
const neck = new THREE.Mesh(new THREE.CylinderGeometry(0.0135, 0.0115, 0.046, 8), steelMat);
neck.name = 'neck';
neck.position.set(0.039, 0.304, 0);
neck.rotation.set(0, 0, deg(-90));
tool.add(neck);
const face = new THREE.Mesh(new THREE.CylinderGeometry(0.0145, 0.0165, 0.018, 8), polishedMat);
face.name = 'face';
face.position.set(0.07, 0.304, 0);
face.rotation.set(0, 0, deg(-90));
tool.add(face);
const clawRoot = new THREE.Mesh(extrude([[-0.014, 0.296], [-0.0204, 0.2968], [-0.0269, 0.2971], [-0.0335, 0.2969], [-0.0401, 0.2962], [-0.0468, 0.2951], [-0.0534, 0.2934], [-0.0617, 0.3117], [-0.0545, 0.3158], [-0.0469, 0.3193], [-0.039, 0.3223], [-0.0309, 0.3248], [-0.0225, 0.3267], [-0.014, 0.328]], 0.024), steelMat);
clawRoot.name = 'clawRoot';
tool.add(clawRoot);
const clawProng = new THREE.Mesh(extrudeGeo, steelMat);
clawProng.name = 'clawProng';
clawProng.position.set(0, 0, -0.0068);
tool.add(clawProng);
const clawProng2 = new THREE.Mesh(extrudeGeo, steelMat);
clawProng2.name = 'clawProng';
clawProng2.position.set(0, 0, 0.0068);
tool.add(clawProng2);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createHammer;
Оценки и комментарии
0 комментариев
Комментариев пока нет. Расскажите, как вы использовали эту модель или что можно улучшить.
Похожие модели
Та же категория или похожие теги









