Codels
921 Tris0,73 × 0,46 × 0,51 m

Im Code verwenden

Im Editor remixen
Eigenständiges ES-Modul — hängt nur von three ab. Ruf die Factory auf und füge die Gruppe deiner Szene hinzu.
/**
 * Toadstool Mushroom — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 921 · Size (W × H × D): 0.73 × 0.46 × 0.51 m
 *
 * Usage:
 *   import { createMushroom } from './mushroom.js';
 *   
 *   const model = createMushroom();
 *   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);
}

export function createMushroom() {
  const root = new THREE.Group();
  root.name = 'Mushroom';

  // Materials
  const capMat = new THREE.MeshStandardMaterial({ name: 'cap', color: 0xd8392c, roughness: 0.55, flatShading: true });
  const spotMat = new THREE.MeshStandardMaterial({ name: 'spot', color: 0xf8f3ea, roughness: 0.7, flatShading: true });
  const stemMat = new THREE.MeshStandardMaterial({ name: 'stem', color: 0xeee4cf, roughness: 0.8, flatShading: true });
  const gillsMat = new THREE.MeshStandardMaterial({ name: 'gills', color: 0xd6c3a0, roughness: 0.9, flatShading: true });

  // Shared geometries
  const icosahedronGeo = new THREE.IcosahedronGeometry(0.0262, 0);

  // Parts
  const mushroom1 = new THREE.Group();
  mushroom1.name = 'mushroom1';
  root.add(mushroom1);
  const stem = new THREE.Mesh(lathe([[0, 0], [0.0675, 0], [0.081, 0.036], [0.0563, 0.144], [0.054, 0.297], [0, 0.297]], 7), stemMat);
  stem.name = 'stem';
  mushroom1.add(stem);
  const cap = new THREE.Mesh(lathe([[0, 0.27], [0.2029, 0.27], [0.2111, 0.288], [0.1987, 0.3285], [0.1656, 0.387], [0.1035, 0.432], [0, 0.45]], 9), capMat);
  cap.name = 'cap';
  mushroom1.add(cap);
  const gills = new THREE.Mesh(new THREE.CircleGeometry(0.1946, 9), gillsMat);
  gills.name = 'gills';
  gills.position.set(0, 0.2664, 0);
  gills.rotation.set(deg(90), 0, 0);
  mushroom1.add(gills);
  const spot1 = new THREE.Mesh(icosahedronGeo, spotMat);
  spot1.name = 'spot1';
  spot1.position.set(0.0103, 0.4481, 0.0001);
  spot1.rotation.set(deg(12.4634), deg(53.598), deg(-17.5776));
  spot1.scale.set(1, 0.32, 1);
  mushroom1.add(spot1);
  const spot2 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0298, 0), spotMat);
  spot2.name = 'spot2';
  spot2.position.set(-0.0819, 0.4263, 0.0673);
  spot2.rotation.set(deg(-15.4859), deg(43.7171), deg(47.0297));
  spot2.scale.set(1, 0.32, 1);
  mushroom1.add(spot2);
  const spot3 = new THREE.Mesh(icosahedronGeo, spotMat);
  spot3.name = 'spot3';
  spot3.position.set(-0.0203, 0.4125, -0.1225);
  spot3.rotation.set(deg(-37.6374), deg(54.6963), 0);
  spot3.scale.set(1, 0.32, 1);
  mushroom1.add(spot3);
  const spot4 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0257, 0), spotMat);
  spot4.name = 'spot4';
  spot4.position.set(0.0873, 0.4064, 0.1071);
  spot4.rotation.set(deg(68.654), deg(68.4436), deg(-34.6423));
  spot4.scale.set(1, 0.32, 1);
  mushroom1.add(spot4);
  const spot5 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0278, 0), spotMat);
  spot5.name = 'spot5';
  spot5.position.set(-0.1487, 0.3915, -0.019);
  spot5.rotation.set(deg(-52.4084), deg(43.1013), deg(55.4517));
  spot5.scale.set(1, 0.32, 1);
  mushroom1.add(spot5);
  const spot6 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0223, 0), spotMat);
  spot6.name = 'spot6';
  spot6.position.set(0.1151, 0.3798, -0.1116);
  spot6.rotation.set(deg(-27.0563), deg(34.4142), deg(-43.4692));
  spot6.scale.set(1, 0.32, 1);
  mushroom1.add(spot6);
  const spot7 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0245, 0), spotMat);
  spot7.name = 'spot7';
  spot7.position.set(-0.0337, 0.3641, 0.1663);
  spot7.rotation.set(deg(30.1353), deg(57.925), deg(34.6586));
  spot7.scale.set(1, 0.32, 1);
  mushroom1.add(spot7);
  const spot8 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.027, 0), spotMat);
  spot8.name = 'spot8';
  spot8.position.set(-0.1152, 0.3444, -0.1361);
  spot8.rotation.set(deg(-75.7462), deg(26.9427), deg(39.5429));
  spot8.scale.set(1, 0.32, 1);
  mushroom1.add(spot8);
  const mushroom2 = new THREE.Group();
  mushroom2.name = 'mushroom2';
  mushroom2.position.set(-0.2225, 0.0081, 0.1145);
  mushroom2.rotation.set(deg(-177.648), deg(-18.6188), deg(166.3146));
  root.add(mushroom2);
  const stem2 = new THREE.Mesh(lathe([[0, 0], [0.0324, 0], [0.0389, 0.0173], [0.027, 0.0691], [0.0259, 0.1425], [0, 0.1425]], 7), stemMat);
  stem2.name = 'stem';
  mushroom2.add(stem2);
  const cap2 = new THREE.Mesh(lathe([[0, 0.1296], [0.0973, 0.1296], [0.1013, 0.1382], [0.0954, 0.1576], [0.0795, 0.1857], [0.0497, 0.2073], [0, 0.2159]], 9), capMat);
  cap2.name = 'cap';
  mushroom2.add(cap2);
  const gills2 = new THREE.Mesh(new THREE.CircleGeometry(0.0934, 9), gillsMat);
  gills2.name = 'gills';
  gills2.position.set(0, 0.1278, 0);
  gills2.rotation.set(deg(90), 0, 0);
  mushroom2.add(gills2);
  const spot12 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.013, 0), spotMat);
  spot12.name = 'spot1';
  spot12.position.set(0.005, 0.215, -0.0003);
  spot12.rotation.set(deg(9.1935), deg(46.5354), deg(-15.0262));
  spot12.scale.set(1, 0.32, 1);
  mushroom2.add(spot12);
  const spot22 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0141, 0), spotMat);
  spot22.name = 'spot2';
  spot22.position.set(-0.0341, 0.2017, 0.045);
  spot22.rotation.set(deg(21.0579), deg(50.2419), deg(19.0642));
  spot22.scale.set(1, 0.32, 1);
  mushroom2.add(spot22);
  const spot32 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0108, 0), spotMat);
  spot32.name = 'spot3';
  spot32.position.set(0.0145, 0.1925, -0.0659);
  spot32.rotation.set(deg(-37.6448), deg(12.7145), 0);
  spot32.scale.set(1, 0.32, 1);
  mushroom2.add(spot32);
  const spot42 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0118, 0), spotMat);
  spot42.name = 'spot4';
  spot42.position.set(0.0445, 0.187, 0.0616);
  spot42.rotation.set(deg(46.5216), deg(40.6963), deg(-15.9931));
  spot42.scale.set(1, 0.32, 1);
  mushroom2.add(spot42);
  const spot52 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0123, 0), spotMat);
  spot52.name = 'spot5';
  spot52.position.set(-0.0831, 0.1724, 0.0003);
  spot52.rotation.set(deg(-59.9898), deg(20.7738), deg(68.4338));
  spot52.scale.set(1, 0.32, 1);
  mushroom2.add(spot52);
  const mushroom3 = new THREE.Group();
  mushroom3.name = 'mushroom3';
  mushroom3.position.set(0.2425, 0.0062, 0.1817);
  mushroom3.rotation.set(deg(9.3529), deg(22.4281), deg(-8.6435));
  root.add(mushroom3);
  const stem3 = new THREE.Mesh(lathe([[0, 0], [0.0383, 0], [0.046, 0.0204], [0.0319, 0.0817], [0.0306, 0.1685], [0, 0.1685]], 7), stemMat);
  stem3.name = 'stem';
  mushroom3.add(stem3);
  const cap3 = new THREE.Mesh(lathe([[0, 0.1532], [0.1151, 0.1532], [0.1198, 0.1634], [0.1127, 0.1864], [0.0939, 0.2195], [0.0587, 0.2451], [0, 0.2553]], 9), capMat);
  cap3.name = 'cap';
  mushroom3.add(cap3);
  const gills3 = new THREE.Mesh(new THREE.CircleGeometry(0.1104, 9), gillsMat);
  gills3.name = 'gills';
  gills3.position.set(0, 0.1511, 0);
  gills3.rotation.set(deg(90), 0, 0);
  mushroom3.add(gills3);
  const spot13 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0168, 0), spotMat);
  spot13.name = 'spot1';
  spot13.position.set(0.0059, 0.2542, 0.0003);
  spot13.rotation.set(deg(11.0284), deg(50.7406), deg(-16.4374));
  spot13.scale.set(1, 0.32, 1);
  mushroom3.add(spot13);
  const spot23 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0132, 0), spotMat);
  spot23.name = 'spot2';
  spot23.position.set(-0.0553, 0.2363, 0.0374);
  spot23.rotation.set(deg(12.722), deg(13.2036), deg(32.9867));
  spot23.scale.set(1, 0.32, 1);
  mushroom3.add(spot23);
  const spot33 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0144, 0), spotMat);
  spot33.name = 'spot3';
  spot33.position.set(0.0035, 0.2261, -0.0797);
  spot33.rotation.set(deg(-37.738), deg(30.2386), 0);
  spot33.scale.set(1, 0.32, 1);
  mushroom3.add(spot33);
  const spot43 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0131, 0), spotMat);
  spot43.name = 'spot4';
  spot43.position.set(0.0646, 0.2203, 0.0623);
  spot43.rotation.set(deg(20.1751), deg(-1.5673), deg(-32.0224));
  spot43.scale.set(1, 0.32, 1);
  mushroom3.add(spot43);
  const spot53 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.0126, 0), spotMat);
  spot53.name = 'spot5';
  spot53.position.set(-0.0965, 0.2008, -0.0186);
  spot53.rotation.set(deg(-70.8619), deg(24.4273), deg(72.5967));
  spot53.scale.set(1, 0.32, 1);
  mushroom3.add(spot53);

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

export default createMushroom;

Bewertungen & Kommentare

—
Noch keine Bewertungen — gib die erste ab.
5
0
4
0
3
0
2
0
1
0

Melde dich an, um zu bewerten und zu kommentieren.

0 Kommentare

Noch keine Kommentare. Erzähl, wie du dieses Modell genutzt hast oder was besser sein könnte.

Ähnliche Modelle

Gleiche Kategorie oder ähnliche Tags