Codels
328 tris0,92 × 1,01 × 0,59 m

Úsalo en código

Hacer remix en el editor
Módulo ES autónomo — solo depende de three. Llama a la función factory y añade el grupo a tu escena.
/**
 * Pickaxe — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 328 · Size (W × H × D): 0.92 × 1.01 × 0.59 m
 *
 * Usage:
 *   import { createPickaxe } from './pickaxe.js';
 *   
 *   const model = createPickaxe();
 *   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 createPickaxe() {
  const root = new THREE.Group();
  root.name = 'Pickaxe';

  // Materials
  const ironMat = new THREE.MeshStandardMaterial({ name: 'iron', color: 0x7c838e, roughness: 0.45, metalness: 0.4, flatShading: true });
  const ironDarkMat = new THREE.MeshStandardMaterial({ name: 'ironDark', color: 0x4d5158, roughness: 0.5, metalness: 0.4, flatShading: true });
  const handleMat = new THREE.MeshStandardMaterial({ name: 'handle', color: 0xa9733f, roughness: 0.8, flatShading: true });
  const wrapMat = new THREE.MeshStandardMaterial({ name: 'wrap', color: 0x5a3b26, roughness: 0.95, flatShading: true });
  const rockMat = new THREE.MeshStandardMaterial({ name: 'rock', color: 0x6b6762, roughness: 0.95, flatShading: true });
  const rockDarkMat = new THREE.MeshStandardMaterial({ name: 'rockDark', color: 0x55524e, roughness: 0.95, flatShading: true });
  const goldMat = new THREE.MeshStandardMaterial({ name: 'gold', color: 0xf2c14e, roughness: 0.3, metalness: 0.4, emissive: 0x5a3c00, emissiveIntensity: 0.4, flatShading: true });

  // Shared geometries
  const cylinderGeo = new THREE.CylinderGeometry(0.026, 0.032, 0.13, 6);

  // Parts
  const boulder = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.3, 0), 0.04, 3), rockMat);
  boulder.name = 'boulder';
  boulder.position.set(0, 0.232, 0);
  boulder.rotation.set(0, deg(15), 0);
  boulder.scale.set(1.25, 0.75, 1);
  root.add(boulder);
  const stone = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.13, 0), 0.02, 8), rockDarkMat);
  stone.name = 'stone';
  stone.position.set(0.33, 0.088, 0.18);
  stone.scale.set(1, 0.65, 1);
  root.add(stone);
  const pebble = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.09, 0), 0.015, 9), rockDarkMat);
  pebble.name = 'pebble';
  pebble.position.set(-0.36, 0.06, 0.12);
  pebble.scale.set(1, 0.6, 1);
  root.add(pebble);
  const nugget = new THREE.Mesh(jitter(new THREE.OctahedronGeometry(0.0386, 0), 0.004, 0), goldMat);
  nugget.name = 'nugget';
  nugget.position.set(-0.1861, 0.3234, 0.1895);
  nugget.rotation.set(deg(6.8101), deg(52.2145), 0);
  nugget.scale.set(1, 0.8, 1);
  root.add(nugget);
  const nugget2 = new THREE.Mesh(jitter(new THREE.OctahedronGeometry(0.0491, 0), 0.004, 1), goldMat);
  nugget2.name = 'nugget';
  nugget2.position.set(0.1198, 0.2731, 0.2464);
  nugget2.rotation.set(deg(13.7494), deg(1.2319), 0);
  nugget2.scale.set(1, 0.8, 1);
  root.add(nugget2);
  const nugget3 = new THREE.Mesh(jitter(new THREE.OctahedronGeometry(0.0451, 0), 0.004, 2), goldMat);
  nugget3.name = 'nugget';
  nugget3.position.set(-0.3275, 0.2538, -0.0582);
  nugget3.rotation.set(deg(57.6117), deg(49.9328), 0);
  nugget3.scale.set(1, 0.8, 1);
  root.add(nugget3);
  const nugget4 = new THREE.Mesh(jitter(new THREE.OctahedronGeometry(0.0458, 0), 0.004, 3), goldMat);
  nugget4.name = 'nugget';
  nugget4.position.set(0.2909, 0.3141, -0.0821);
  nugget4.rotation.set(deg(2.7396), deg(83.5264), 0);
  nugget4.scale.set(1, 0.8, 1);
  root.add(nugget4);
  const nugget5 = new THREE.Mesh(jitter(new THREE.OctahedronGeometry(0.0392, 0), 0.004, 4), goldMat);
  nugget5.name = 'nugget';
  nugget5.position.set(0.017, 0.3848, -0.1766);
  nugget5.rotation.set(deg(46.3755), deg(67.4749), 0);
  nugget5.scale.set(1, 0.8, 1);
  root.add(nugget5);
  const nugget6 = new THREE.Mesh(jitter(new THREE.OctahedronGeometry(0.0444, 0), 0.004, 5), goldMat);
  nugget6.name = 'nugget';
  nugget6.position.set(-0.0692, 0.2113, 0.2628);
  nugget6.rotation.set(deg(47.8231), deg(71.8247), 0);
  nugget6.scale.set(1, 0.8, 1);
  root.add(nugget6);
  const pickaxe = new THREE.Group();
  pickaxe.name = 'pickaxe';
  pickaxe.rotation.set(0, deg(18), 0);
  root.add(pickaxe);
  const tool = new THREE.Group();
  tool.name = 'tool';
  tool.position.set(-0.4201, 0.9851, 0);
  tool.rotation.set(0, 0, deg(-118));
  pickaxe.add(tool);
  const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.021, 0.019, 0.86, 7), handleMat);
  handle.name = 'handle';
  handle.position.set(0, 0.43, 0);
  tool.add(handle);
  const buttCap = new THREE.Mesh(new THREE.CylinderGeometry(0.026, 0.024, 0.024, 7), ironDarkMat);
  buttCap.name = 'buttCap';
  buttCap.position.set(0, 0.004, 0);
  tool.add(buttCap);
  const gripWrap = new THREE.Mesh(new THREE.CylinderGeometry(0.025, 0.025, 0.16, 7), wrapMat);
  gripWrap.name = 'gripWrap';
  gripWrap.position.set(0, 0.13, 0);
  tool.add(gripWrap);
  const collar = new THREE.Mesh(new THREE.BoxGeometry(0.07, 0.085, 0.06), ironDarkMat);
  collar.name = 'collar';
  collar.position.set(0, 0.8, 0);
  tool.add(collar);
  const pickBase = new THREE.Mesh(cylinderGeo, ironMat);
  pickBase.name = 'pickBase';
  pickBase.position.set(0.0942, 0.7898, 0);
  pickBase.rotation.set(0, 0, deg(-99));
  tool.add(pickBase);
  const pickPoint = new THREE.Mesh(new THREE.ConeGeometry(0.026, 0.17, 6), ironMat);
  pickPoint.name = 'pickPoint';
  pickPoint.position.set(0.2361, 0.7451, 0);
  pickPoint.rotation.set(0, 0, deg(-114));
  tool.add(pickPoint);
  const chiselBase = new THREE.Mesh(cylinderGeo, ironMat);
  chiselBase.name = 'chiselBase';
  chiselBase.position.set(-0.0942, 0.7898, 0);
  chiselBase.rotation.set(0, 0, deg(99));
  tool.add(chiselBase);
  const adze = new THREE.Mesh(new THREE.CylinderGeometry(0.032, 0.024, 0.1445, 4), ironMat);
  adze.name = 'adze';
  adze.position.set(-0.2251, 0.75, 0);
  adze.rotation.set(0, 0, deg(114));
  adze.scale.set(0.32, 1, 1.6);
  tool.add(adze);

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

export default createPickaxe;

Valoraciones y comentarios

—
Aún no hay valoraciones — sé el primero.
5
0
4
0
3
0
2
0
1
0

Inicia sesión para valorar y comentar.

0 comentarios

Aún no hay comentarios. Cuenta cómo usaste este modelo o qué se podría mejorar.

Modelos relacionados

Misma categoría o etiquetas similares