Codels
삼각형 1.3천개1.20 × 1.58 × 0.73 m

코드에서 사용하기

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

  // Materials
  const snowMat = new THREE.MeshStandardMaterial({ name: 'snow', color: 0xf3f6fb, roughness: 0.75, flatShading: true });
  const coalMat = new THREE.MeshStandardMaterial({ name: 'coal', color: 0x25232a, roughness: 0.6, flatShading: true });
  const carrotMat = new THREE.MeshStandardMaterial({ name: 'carrot', color: 0xf08a24, roughness: 0.6, flatShading: true });
  const stickMat = new THREE.MeshStandardMaterial({ name: 'stick', color: 0x6b4527, roughness: 0.9, flatShading: true });
  const scarfMat = new THREE.MeshStandardMaterial({ name: 'scarf', color: 0xd8433b, roughness: 0.95, flatShading: true });
  const scarfStripeMat = new THREE.MeshStandardMaterial({ name: 'scarfStripe', color: 0xf4efe6, roughness: 0.95, flatShading: true });
  const hatMat = new THREE.MeshStandardMaterial({ name: 'hat', color: 0x24222b, roughness: 0.5, flatShading: true });

  // Shared geometries
  const icosahedronGeo = new THREE.IcosahedronGeometry(0.032, 0);
  const cylinderGeo = new THREE.CylinderGeometry(0.016, 0.022, 0.5, 5);
  const cylinderGeo2 = new THREE.CylinderGeometry(0.009, 0.012, 0.14, 4);
  const cylinderGeo3 = new THREE.CylinderGeometry(0.009, 0.012, 0.12, 4);
  const torusGeo = new THREE.TorusGeometry(0.1848, 0.057, 6, 3, 0.4488);
  const boxGeo = new THREE.BoxGeometry(0.025, 0.05, 0.04);
  const icosahedronGeo2 = new THREE.IcosahedronGeometry(0.03, 0);
  const icosahedronGeo3 = new THREE.IcosahedronGeometry(0.018, 0);

  // Parts
  const snowman = new THREE.Group();
  snowman.name = 'snowman';
  snowman.scale.setScalar(0.9639);
  root.add(snowman);
  const base = new THREE.Group();
  base.name = 'base';
  snowman.add(base);
  const bottomBall = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.37, 12, 9), 0.012, 3), snowMat);
  bottomBall.name = 'bottomBall';
  bottomBall.position.set(0, 0.333, 0);
  bottomBall.scale.set(1, 0.9, 1);
  base.add(bottomBall);
  const body = new THREE.Group();
  body.name = 'body';
  snowman.add(body);
  const middleBall = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.28, 12, 9), 0.01, 5), snowMat);
  middleBall.name = 'middleBall';
  middleBall.position.set(0, 0.7893, 0);
  middleBall.scale.set(1, 0.9, 1);
  body.add(middleBall);
  const button1 = new THREE.Mesh(icosahedronGeo, coalMat);
  button1.name = 'button1';
  button1.position.set(0, 0.8993, 0.2399);
  body.add(button1);
  const button2 = new THREE.Mesh(icosahedronGeo, coalMat);
  button2.name = 'button2';
  button2.position.set(0, 0.7893, 0.268);
  button2.rotation.set(deg(30), deg(50), 0);
  body.add(button2);
  const button3 = new THREE.Mesh(icosahedronGeo, coalMat);
  button3.name = 'button3';
  button3.position.set(0, 0.6793, 0.2399);
  button3.rotation.set(deg(60), deg(100), 0);
  body.add(button3);
  const armL = new THREE.Group();
  armL.name = 'armL';
  armL.position.set(0.22, 0.8493, 0);
  armL.rotation.set(0, deg(-10), deg(-58));
  snowman.add(armL);
  const stickL = new THREE.Mesh(cylinderGeo, stickMat);
  stickL.name = 'stickL';
  stickL.position.set(0, 0.25, 0);
  armL.add(stickL);
  const twigL1 = new THREE.Mesh(cylinderGeo2, stickMat);
  twigL1.name = 'twigL1';
  twigL1.position.set(-0.045, 0.45, 0);
  twigL1.rotation.set(0, 0, deg(38));
  armL.add(twigL1);
  const twigL2 = new THREE.Mesh(cylinderGeo3, stickMat);
  twigL2.name = 'twigL2';
  twigL2.position.set(0.035, 0.38, 0);
  twigL2.rotation.set(0, 0, deg(-35));
  armL.add(twigL2);
  const armR = new THREE.Group();
  armR.name = 'armR';
  armR.position.set(-0.22, 0.8493, 0);
  armR.rotation.set(0, deg(10), deg(48));
  snowman.add(armR);
  const stickR = new THREE.Mesh(cylinderGeo, stickMat);
  stickR.name = 'stickR';
  stickR.position.set(0, 0.25, 0);
  armR.add(stickR);
  const twigR1 = new THREE.Mesh(cylinderGeo2, stickMat);
  twigR1.name = 'twigR1';
  twigR1.position.set(0.045, 0.45, 0);
  twigR1.rotation.set(0, 0, deg(-38));
  armR.add(twigR1);
  const twigR2 = new THREE.Mesh(cylinderGeo3, stickMat);
  twigR2.name = 'twigR2';
  twigR2.position.set(-0.035, 0.38, 0);
  twigR2.rotation.set(0, 0, deg(35));
  armR.add(twigR2);
  const scarf = new THREE.Group();
  scarf.name = 'scarf';
  snowman.add(scarf);
  const scarfWrap = new THREE.Mesh(new THREE.TorusGeometry(0.1848, 0.055, 6, 14), scarfMat);
  scarfWrap.name = 'scarfWrap';
  scarfWrap.position.set(0, 0.9959, 0);
  scarfWrap.rotation.set(deg(90), 0, 0);
  scarf.add(scarfWrap);
  const scarfBand1 = new THREE.Mesh(torusGeo, scarfStripeMat);
  scarfBand1.name = 'scarfBand1';
  scarfBand1.position.set(0, 0.9959, 0);
  scarfBand1.rotation.set(deg(90), 0, deg(-60));
  scarf.add(scarfBand1);
  const scarfBand2 = new THREE.Mesh(torusGeo, scarfStripeMat);
  scarfBand2.name = 'scarfBand2';
  scarfBand2.position.set(0, 0.9959, 0);
  scarfBand2.rotation.set(deg(90), 0, deg(10));
  scarf.add(scarfBand2);
  const scarfTail = new THREE.Group();
  scarfTail.name = 'scarfTail';
  scarfTail.position.set(0.1, 0.9859, 0.2148);
  scarfTail.rotation.set(deg(14), deg(20), deg(12));
  scarf.add(scarfTail);
  const scarfEnd = new THREE.Mesh(new THREE.BoxGeometry(0.11, 0.3, 0.05), scarfMat);
  scarfEnd.name = 'scarfEnd';
  scarfEnd.position.set(0, -0.15, 0);
  scarfTail.add(scarfEnd);
  const scarfEndStripe = new THREE.Mesh(new THREE.BoxGeometry(0.115, 0.04, 0.055), scarfStripeMat);
  scarfEndStripe.name = 'scarfEndStripe';
  scarfEndStripe.position.set(0, -0.22, 0);
  scarfTail.add(scarfEndStripe);
  const fringe = new THREE.Mesh(boxGeo, scarfMat);
  fringe.name = 'fringe';
  fringe.position.set(-0.035, -0.32, 0);
  scarfTail.add(fringe);
  const fringe2 = new THREE.Mesh(boxGeo, scarfMat);
  fringe2.name = 'fringe';
  fringe2.position.set(0, -0.32, 0);
  scarfTail.add(fringe2);
  const fringe3 = new THREE.Mesh(boxGeo, scarfMat);
  fringe3.name = 'fringe';
  fringe3.position.set(0.035, -0.32, 0);
  scarfTail.add(fringe3);
  const head = new THREE.Group();
  head.name = 'head';
  head.position.set(0, 0.9909, 0);
  snowman.add(head);
  const headBall = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.21, 12, 9), 0.007, 7), snowMat);
  headBall.name = 'headBall';
  headBall.position.set(0, 0.168, 0);
  head.add(headBall);
  const eyeL = new THREE.Mesh(icosahedronGeo2, coalMat);
  eyeL.name = 'eyeL';
  eyeL.position.set(0.075, 0.228, 0.18);
  eyeL.scale.set(1, 1.2, 0.8);
  head.add(eyeL);
  const eyeR = new THREE.Mesh(icosahedronGeo2, coalMat);
  eyeR.name = 'eyeR';
  eyeR.position.set(-0.075, 0.228, 0.18);
  eyeR.scale.set(1, 1.2, 0.8);
  head.add(eyeR);
  const carrotNose = new THREE.Mesh(new THREE.ConeGeometry(0.038, 0.2, 6), carrotMat);
  carrotNose.name = 'carrotNose';
  carrotNose.position.set(0, 0.168, 0.29);
  carrotNose.rotation.set(deg(85), 0, 0);
  head.add(carrotNose);
  const smile1 = new THREE.Mesh(icosahedronGeo3, coalMat);
  smile1.name = 'smile1';
  smile1.position.set(-0.0682, 0.1145, 0.1833);
  head.add(smile1);
  const smile2 = new THREE.Mesh(icosahedronGeo3, coalMat);
  smile2.name = 'smile2';
  smile2.position.set(-0.0366, 0.0986, 0.1868);
  head.add(smile2);
  const smile3 = new THREE.Mesh(icosahedronGeo3, coalMat);
  smile3.name = 'smile3';
  smile3.position.set(0, 0.093, 0.1882);
  head.add(smile3);
  const smile4 = new THREE.Mesh(icosahedronGeo3, coalMat);
  smile4.name = 'smile4';
  smile4.position.set(0.0366, 0.0986, 0.1868);
  head.add(smile4);
  const smile5 = new THREE.Mesh(icosahedronGeo3, coalMat);
  smile5.name = 'smile5';
  smile5.position.set(0.0682, 0.1145, 0.1833);
  head.add(smile5);
  const topHat = new THREE.Group();
  topHat.name = 'topHat';
  topHat.position.set(0.01, 0.3318, -0.01);
  topHat.rotation.set(deg(-6), 0, deg(-9));
  head.add(topHat);
  const hatBrim = new THREE.Mesh(new THREE.CylinderGeometry(0.25, 0.25, 0.03, 12), hatMat);
  hatBrim.name = 'hatBrim';
  hatBrim.position.set(0, 0.015, 0);
  topHat.add(hatBrim);
  const hatCrown = new THREE.Mesh(new THREE.CylinderGeometry(0.15, 0.14, 0.27, 12), hatMat);
  hatCrown.name = 'hatCrown';
  hatCrown.position.set(0, 0.165, 0);
  topHat.add(hatCrown);
  const hatBand = new THREE.Mesh(new THREE.CylinderGeometry(0.146, 0.146, 0.05, 12), scarfMat);
  hatBand.name = 'hatBand';
  hatBand.position.set(0, 0.06, 0);
  topHat.add(hatBand);

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

export default createSnowman;

평점 및 댓글

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

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

댓글 0개

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

관련 모델

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