Codels
삼각형 1.2천개0.24 × 0.05 × 0.11 m

코드에서 사용하기

에디터에서 리믹스
독립형 ES 모듈이에요 — three에만 의존해요. 팩토리 함수를 호출하고 그룹을 씬에 추가하세요.
/**
 * Sushi Set — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 1,224 · Size (W × H × D): 0.24 × 0.05 × 0.10 m
 *
 * Usage:
 *   import { createSushi } from './sushi.js';
 *   
 *   const model = createSushi();
 *   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;
}

// 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 createSushi() {
  const root = new THREE.Group();
  root.name = 'Sushi';

  // Materials
  const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0xcf9f62, roughness: 0.8, flatShading: true });
  const woodDarkMat = new THREE.MeshStandardMaterial({ name: 'woodDark', color: 0x9a6b3a, roughness: 0.85, flatShading: true });
  const grainMat = new THREE.MeshStandardMaterial({ name: 'grain', color: 0xb98a50, roughness: 0.85, flatShading: true });
  const riceMat = new THREE.MeshStandardMaterial({ name: 'rice', color: 0xf7f4ec, roughness: 0.85, flatShading: true });
  const fishMat = new THREE.MeshStandardMaterial({ name: 'fish', color: 0xf7895a, roughness: 0.4, flatShading: true });
  const fatMat = new THREE.MeshStandardMaterial({ name: 'fat', color: 0xfde5db, roughness: 0.45, flatShading: true });
  const noriMat = new THREE.MeshStandardMaterial({ name: 'nori', color: 0x22301f, roughness: 0.7, flatShading: true });
  const fillingMat = new THREE.MeshStandardMaterial({ name: 'filling', color: 0x79c25a, roughness: 0.6, flatShading: true });
  const wasabiMat = new THREE.MeshStandardMaterial({ name: 'wasabi', color: 0x9cc44a, roughness: 0.7, flatShading: true });
  const gingerMat = new THREE.MeshStandardMaterial({ name: 'ginger', color: 0xf29d9a, roughness: 0.5, flatShading: true });

  // Shared geometries
  const boxGeo = new THREE.BoxGeometry(0.016, 0.014, 0.095);
  const capsuleGeo = jitter(new THREE.CapsuleGeometry(0.011, 0.026, 3, 7), 0.0007, 3);
  const extrudeGeo = extrude([[0.0135, 0.0029], [0.0109, 0.0085], [0.006, 0.0124], [0, 0.0138], [-0.006, 0.0124], [-0.0109, 0.0085], [-0.0135, 0.0029], [-0.0103, 0.0022], [-0.0083, 0.0065], [-0.0046, 0.0094], [0, 0.0105], [0.0046, 0.0094], [0.0083, 0.0065], [0.0103, 0.0022]], 0.056, [], [0.0015, 0.0012, 1]);
  const extrudeGeo2 = extrude([[0.0126, 0.0073], [0.0073, 0.0126], [0, 0.0146], [-0.0073, 0.0126], [-0.0126, 0.0073], [-0.0113, 0.0065], [-0.0065, 0.0113], [0, 0.013], [0.0065, 0.0113], [0.0113, 0.0065]], 0.0036);
  const cylinderGeo = new THREE.CylinderGeometry(0.0165, 0.0165, 0.021, 10);
  const cylinderGeo2 = jitter(new THREE.CylinderGeometry(0.0148, 0.0148, 0.0222, 10), 0.0004, 7);
  const cylinderGeo3 = new THREE.CylinderGeometry(0.0058, 0.0058, 0.0234, 6);
  const cylinderGeo4 = new THREE.CylinderGeometry(0.0042, 0.0042, 0.0236, 5);
  const sphereGeo = new THREE.SphereGeometry(0.014, 8, 4);

  // Parts
  const footR = new THREE.Mesh(boxGeo, woodDarkMat);
  footR.name = 'footR';
  footR.position.set(0.09, 0.007, 0);
  root.add(footR);
  const footL = new THREE.Mesh(boxGeo, woodDarkMat);
  footL.name = 'footL';
  footL.position.set(-0.09, 0.007, 0);
  root.add(footL);
  const board = new THREE.Mesh(new THREE.BoxGeometry(0.24, 0.016, 0.105), woodMat);
  board.name = 'board';
  board.position.set(0, 0.022, 0);
  root.add(board);
  const grain1 = new THREE.Mesh(new THREE.BoxGeometry(0.18, 0.002, 0.002), grainMat);
  grain1.name = 'grain1';
  grain1.position.set(-0.02, 0.0303, 0.038);
  root.add(grain1);
  const grain2 = new THREE.Mesh(new THREE.BoxGeometry(0.14, 0.002, 0.002), grainMat);
  grain2.name = 'grain2';
  grain2.position.set(0.03, 0.0303, -0.041);
  root.add(grain2);
  const nigiri1 = new THREE.Group();
  nigiri1.name = 'nigiri1';
  nigiri1.position.set(-0.084, 0.03, 0);
  nigiri1.rotation.set(0, deg(8), 0);
  root.add(nigiri1);
  const nigiri1Rice = new THREE.Mesh(capsuleGeo, riceMat);
  nigiri1Rice.name = 'nigiri1Rice';
  nigiri1Rice.position.set(0, 0.009, 0);
  nigiri1Rice.rotation.set(deg(90), 0, 0);
  nigiri1Rice.scale.set(1, 1, 0.82);
  nigiri1.add(nigiri1Rice);
  const nigiri1Fish = new THREE.Mesh(extrudeGeo, fishMat);
  nigiri1Fish.name = 'nigiri1Fish';
  nigiri1Fish.position.set(0, 0.0095, 0);
  nigiri1Fish.scale.set(1.05, 0.9, 1);
  nigiri1.add(nigiri1Fish);
  const nigiri1Fat1 = new THREE.Mesh(extrudeGeo2, fatMat);
  nigiri1Fat1.name = 'nigiri1Fat1';
  nigiri1Fat1.position.set(0, 0.0095, -0.017);
  nigiri1Fat1.rotation.set(0, deg(22), 0);
  nigiri1Fat1.scale.set(1.05, 0.9, 1);
  nigiri1.add(nigiri1Fat1);
  const nigiri1Fat2 = new THREE.Mesh(extrudeGeo2, fatMat);
  nigiri1Fat2.name = 'nigiri1Fat2';
  nigiri1Fat2.position.set(0, 0.0095, 0);
  nigiri1Fat2.rotation.set(0, deg(22), 0);
  nigiri1Fat2.scale.set(1.05, 0.9, 1);
  nigiri1.add(nigiri1Fat2);
  const nigiri1Fat3 = new THREE.Mesh(extrudeGeo2, fatMat);
  nigiri1Fat3.name = 'nigiri1Fat3';
  nigiri1Fat3.position.set(0, 0.0095, 0.017);
  nigiri1Fat3.rotation.set(0, deg(22), 0);
  nigiri1Fat3.scale.set(1.05, 0.9, 1);
  nigiri1.add(nigiri1Fat3);
  const nigiri2 = new THREE.Group();
  nigiri2.name = 'nigiri2';
  nigiri2.position.set(-0.046, 0.03, 0);
  nigiri2.rotation.set(0, deg(-4), 0);
  root.add(nigiri2);
  const nigiri2Rice = new THREE.Mesh(capsuleGeo, riceMat);
  nigiri2Rice.name = 'nigiri2Rice';
  nigiri2Rice.position.set(0, 0.009, 0);
  nigiri2Rice.rotation.set(deg(90), 0, 0);
  nigiri2Rice.scale.set(1, 1, 0.82);
  nigiri2.add(nigiri2Rice);
  const nigiri2Fish = new THREE.Mesh(extrudeGeo, fishMat);
  nigiri2Fish.name = 'nigiri2Fish';
  nigiri2Fish.position.set(0, 0.0095, 0);
  nigiri2Fish.scale.set(1.05, 0.9, 1);
  nigiri2.add(nigiri2Fish);
  const nigiri2Fat1 = new THREE.Mesh(extrudeGeo2, fatMat);
  nigiri2Fat1.name = 'nigiri2Fat1';
  nigiri2Fat1.position.set(0, 0.0095, -0.017);
  nigiri2Fat1.rotation.set(0, deg(22), 0);
  nigiri2Fat1.scale.set(1.05, 0.9, 1);
  nigiri2.add(nigiri2Fat1);
  const nigiri2Fat2 = new THREE.Mesh(extrudeGeo2, fatMat);
  nigiri2Fat2.name = 'nigiri2Fat2';
  nigiri2Fat2.position.set(0, 0.0095, 0);
  nigiri2Fat2.rotation.set(0, deg(22), 0);
  nigiri2Fat2.scale.set(1.05, 0.9, 1);
  nigiri2.add(nigiri2Fat2);
  const nigiri2Fat3 = new THREE.Mesh(extrudeGeo2, fatMat);
  nigiri2Fat3.name = 'nigiri2Fat3';
  nigiri2Fat3.position.set(0, 0.0095, 0.017);
  nigiri2Fat3.rotation.set(0, deg(22), 0);
  nigiri2Fat3.scale.set(1.05, 0.9, 1);
  nigiri2.add(nigiri2Fat3);
  const maki1 = new THREE.Group();
  maki1.name = 'maki1';
  maki1.position.set(-0.005, 0.03, -0.019);
  root.add(maki1);
  const maki1Nori = new THREE.Mesh(cylinderGeo, noriMat);
  maki1Nori.name = 'maki1Nori';
  maki1Nori.position.set(0, 0.0105, 0);
  maki1.add(maki1Nori);
  const maki1Rice = new THREE.Mesh(cylinderGeo2, riceMat);
  maki1Rice.name = 'maki1Rice';
  maki1Rice.position.set(0, 0.0111, 0);
  maki1.add(maki1Rice);
  const maki1Filling = new THREE.Mesh(cylinderGeo3, fillingMat);
  maki1Filling.name = 'maki1Filling';
  maki1Filling.position.set(0.002, 0.0117, 0);
  maki1.add(maki1Filling);
  const maki1FishCore = new THREE.Mesh(cylinderGeo4, fishMat);
  maki1FishCore.name = 'maki1FishCore';
  maki1FishCore.position.set(-0.004, 0.0118, 0.002);
  maki1.add(maki1FishCore);
  const maki2 = new THREE.Group();
  maki2.name = 'maki2';
  maki2.position.set(-0.002, 0.03, 0.019);
  root.add(maki2);
  const maki2Nori = new THREE.Mesh(cylinderGeo, noriMat);
  maki2Nori.name = 'maki2Nori';
  maki2Nori.position.set(0, 0.0105, 0);
  maki2.add(maki2Nori);
  const maki2Rice = new THREE.Mesh(cylinderGeo2, riceMat);
  maki2Rice.name = 'maki2Rice';
  maki2Rice.position.set(0, 0.0111, 0);
  maki2.add(maki2Rice);
  const maki2Filling = new THREE.Mesh(cylinderGeo3, fillingMat);
  maki2Filling.name = 'maki2Filling';
  maki2Filling.position.set(0.002, 0.0117, 0);
  maki2.add(maki2Filling);
  const maki2FishCore = new THREE.Mesh(cylinderGeo4, fishMat);
  maki2FishCore.name = 'maki2FishCore';
  maki2FishCore.position.set(-0.004, 0.0118, 0.002);
  maki2.add(maki2FishCore);
  const maki3 = new THREE.Group();
  maki3.name = 'maki3';
  maki3.position.set(0.033, 0.03, 0);
  root.add(maki3);
  const maki3Nori = new THREE.Mesh(cylinderGeo, noriMat);
  maki3Nori.name = 'maki3Nori';
  maki3Nori.position.set(0, 0.0105, 0);
  maki3.add(maki3Nori);
  const maki3Rice = new THREE.Mesh(cylinderGeo2, riceMat);
  maki3Rice.name = 'maki3Rice';
  maki3Rice.position.set(0, 0.0111, 0);
  maki3.add(maki3Rice);
  const maki3Filling = new THREE.Mesh(cylinderGeo3, fillingMat);
  maki3Filling.name = 'maki3Filling';
  maki3Filling.position.set(0.002, 0.0117, 0);
  maki3.add(maki3Filling);
  const maki3FishCore = new THREE.Mesh(cylinderGeo4, fishMat);
  maki3FishCore.name = 'maki3FishCore';
  maki3FishCore.position.set(-0.004, 0.0118, 0.002);
  maki3.add(maki3FishCore);
  const wasabi = new THREE.Mesh(jitter(new THREE.IcosahedronGeometry(0.013, 0), 0.0015, 4), wasabiMat);
  wasabi.name = 'wasabi';
  wasabi.position.set(0.084, 0.0361, -0.026);
  wasabi.scale.set(1, 0.62, 1);
  root.add(wasabi);
  const ginger1 = new THREE.Mesh(sphereGeo, gingerMat);
  ginger1.name = 'ginger1';
  ginger1.position.set(0.078, 0.034, 0.026);
  ginger1.rotation.set(deg(14), 0, deg(8));
  ginger1.scale.set(1, 0.16, 0.8);
  root.add(ginger1);
  const ginger2 = new THREE.Mesh(sphereGeo, gingerMat);
  ginger2.name = 'ginger2';
  ginger2.position.set(0.084, 0.036, 0.022);
  ginger2.rotation.set(deg(5), deg(50), deg(8));
  ginger2.scale.set(1, 0.16, 0.8);
  root.add(ginger2);
  const ginger3 = new THREE.Mesh(sphereGeo, gingerMat);
  ginger3.name = 'ginger3';
  ginger3.position.set(0.09, 0.038, 0.018);
  ginger3.rotation.set(deg(-4), deg(100), deg(8));
  ginger3.scale.set(1, 0.16, 0.8);
  root.add(ginger3);

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

export default createSushi;

평점 및 댓글

—
아직 평점이 없어요 — 첫 평점을 남겨 보세요.
5
0
4
0
3
0
2
0
1
0

평점과 댓글을 남기려면 로그인하세요.

댓글 0개

아직 댓글이 없어요. 이 모델을 어떻게 사용했는지, 어떤 점이 더 나아질 수 있을지 공유해 주세요.

관련 모델

같은 카테고리 또는 비슷한 태그