Codels
304 треуг.0,27 × 0,12 × 0,04 m

Использовать в коде

Ремикс в редакторе
Самодостаточный ES-модуль — зависит только от three. Вызовите фабрику и добавьте группу в сцену.
/**
 * Carrot — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 304 · Size (W × H × D): 0.27 × 0.12 × 0.04 m
 *
 * Usage:
 *   import { createCarrot } from './carrot.js';
 *   
 *   const model = createCarrot();
 *   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 createCarrot() {
  const root = new THREE.Group();
  root.name = 'Carrot';

  // Materials
  const rootMat = new THREE.MeshStandardMaterial({ name: 'root', color: 0xee6c14, roughness: 0.75, flatShading: true });
  const crownMat = new THREE.MeshStandardMaterial({ name: 'crown', color: 0x7a9a2c, roughness: 0.8, flatShading: true });
  const leafMat = new THREE.MeshStandardMaterial({ name: 'leaf', color: 0x3f9a2c, roughness: 0.75, flatShading: true });
  const leafLightMat = new THREE.MeshStandardMaterial({ name: 'leafLight', color: 0x62bf3f, roughness: 0.75, flatShading: true });

  // Parts
  const carrot = new THREE.Group();
  carrot.name = 'carrot';
  carrot.position.set(0.0893, 0, 0);
  carrot.rotation.set(0, 0, deg(-7.3524));
  carrot.scale.setScalar(0.18);
  root.add(carrot);
  const root2 = new THREE.Mesh(lathe([[0, 0], [0.02, 0.0775], [0.0342, 0.155], [0.0432, 0.2325], [0.0556, 0.31], [0.0618, 0.3875], [0.0739, 0.465], [0.0782, 0.5425], [0.0903, 0.62], [0.0932, 0.6975], [0.1056, 0.775], [0.1073, 0.8525], [0.12, 0.93], [0.11, 0.97], [0.06, 0.995], [0, 1]], 8), rootMat);
  root2.name = 'root';
  root2.rotation.set(0, 0, deg(90));
  carrot.add(root2);
  const crown = new THREE.Mesh(new THREE.CylinderGeometry(0.06, 0.07, 0.05, 6), crownMat);
  crown.name = 'crown';
  crown.position.set(-1.01, 0, 0);
  crown.rotation.set(0, 0, deg(90));
  carrot.add(crown);
  const leaf1 = new THREE.Mesh(new THREE.ConeGeometry(0.085, 0.5, 4), leafLightMat);
  leaf1.name = 'leaf1';
  leaf1.position.set(-1.2512, 0.0842, 0.0443);
  leaf1.rotation.set(deg(27.7571), 0, deg(67.6427));
  leaf1.scale.set(1, 1, 0.35);
  carrot.add(leaf1);
  const leaf2 = new THREE.Mesh(new THREE.ConeGeometry(0.085, 0.56, 4), leafMat);
  leaf2.name = 'leaf2';
  leaf2.position.set(-1.2295, 0.1758, -0.0602);
  leaf2.rotation.set(deg(-18.894), 0, deg(48.4306));
  leaf2.scale.set(1, 1, 0.35);
  carrot.add(leaf2);
  const leaf3 = new THREE.Mesh(new THREE.ConeGeometry(0.085, 0.6, 4), leafLightMat);
  leaf3.name = 'leaf3';
  leaf3.position.set(-1.1785, 0.2536, 0.0239);
  leaf3.rotation.set(deg(5.389), 0, deg(31.8861));
  leaf3.scale.set(1, 1, 0.35);
  carrot.add(leaf3);
  const leaf4 = new THREE.Mesh(new THREE.ConeGeometry(0.085, 0.48, 4), leafMat);
  leaf4.name = 'leaf4';
  leaf4.position.set(-1.082, 0.2315, -0.012);
  leaf4.rotation.set(deg(-2.9632), 0, deg(14.9808));
  leaf4.scale.set(1, 1, 0.35);
  carrot.add(leaf4);
  const leaf5 = new THREE.Mesh(new THREE.ConeGeometry(0.085, 0.62, 4), leafLightMat);
  leaf5.name = 'leaf5';
  leaf5.position.set(-1.2884, 0.155, 0.0062);
  leaf5.rotation.set(deg(2.2906), 0, deg(59.9802));
  leaf5.scale.set(1, 1, 0.35);
  carrot.add(leaf5);

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

export default createCarrot;

Оценки и комментарии

—
Оценок пока нет — будьте первым.
5
0
4
0
3
0
2
0
1
0

Войдите, чтобы ставить оценки и оставлять комментарии.

0 комментариев

Комментариев пока нет. Расскажите, как вы использовали эту модель или что можно улучшить.

Похожие модели

Та же категория или похожие теги