456 üçgen0,93 × 1,41 × 1,56 m
Kodda kullan
Editörde remix’lecow.js · 245 satır
Bağımsız bir ES modülü — yalnızca three paketine bağımlıdır. Fabrika fonksiyonunu çağırıp dönen grubu sahnene ekle.
/**
* Cow — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 456 · Size (W × H × D): 0.93 × 1.41 × 1.56 m
*
* Usage:
* import { createCow } from './cow.js';
*
* const model = createCow();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
export function createCow() {
const root = new THREE.Group();
root.name = 'Cow';
// Materials
const hideMat = new THREE.MeshStandardMaterial({ name: 'hide', color: 0xf3f0e8, roughness: 0.9, flatShading: true });
const spotMat = new THREE.MeshStandardMaterial({ name: 'spot', color: 0x2e2a28, roughness: 0.9, flatShading: true });
const pinkMat = new THREE.MeshStandardMaterial({ name: 'pink', color: 0xf0a6a0, roughness: 0.7, flatShading: true });
const hornMat = new THREE.MeshStandardMaterial({ name: 'horn', color: 0xeee0bd, roughness: 0.6, flatShading: true });
const hoofMat = new THREE.MeshStandardMaterial({ name: 'hoof', color: 0x4b3b34, roughness: 0.8, flatShading: true });
const eyeMat = new THREE.MeshStandardMaterial({ name: 'eye', color: 0x1d1a19, roughness: 0.4, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.17, 0.36, 0.17);
const boxGeo2 = new THREE.BoxGeometry(0.18, 0.08, 0.18);
const boxGeo3 = new THREE.BoxGeometry(0.035, 0.05, 0.035);
const boxGeo4 = new THREE.BoxGeometry(0.065, 0.05, 0.02);
const boxGeo5 = new THREE.BoxGeometry(0.08, 0.095, 0.08);
const boxGeo6 = new THREE.BoxGeometry(0.03, 0.03, 0.01);
const boxGeo7 = new THREE.BoxGeometry(0.18, 0.09, 0.08);
const boxGeo8 = new THREE.BoxGeometry(0.12, 0.05, 0.01);
const boxGeo9 = new THREE.BoxGeometry(0.13, 0.07, 0.07);
const boxGeo10 = new THREE.BoxGeometry(0.07, 0.15, 0.07);
// Parts
const legFL = new THREE.Group();
legFL.name = 'legFL';
legFL.position.set(0.21, 0.44, 0.33);
root.add(legFL);
const legFLUpper = new THREE.Mesh(boxGeo, hideMat);
legFLUpper.name = 'legFLUpper';
legFLUpper.position.set(0, -0.18, 0);
legFL.add(legFLUpper);
const legFLHoof = new THREE.Mesh(boxGeo2, hoofMat);
legFLHoof.name = 'legFLHoof';
legFLHoof.position.set(0, -0.4, 0);
legFL.add(legFLHoof);
const legFR = new THREE.Group();
legFR.name = 'legFR';
legFR.position.set(-0.21, 0.44, 0.33);
root.add(legFR);
const legFRUpper = new THREE.Mesh(boxGeo, spotMat);
legFRUpper.name = 'legFRUpper';
legFRUpper.position.set(0, -0.18, 0);
legFR.add(legFRUpper);
const legFRHoof = new THREE.Mesh(boxGeo2, hoofMat);
legFRHoof.name = 'legFRHoof';
legFRHoof.position.set(0, -0.4, 0);
legFR.add(legFRHoof);
const legBL = new THREE.Group();
legBL.name = 'legBL';
legBL.position.set(0.21, 0.44, -0.35);
root.add(legBL);
const legBLUpper = new THREE.Mesh(boxGeo, spotMat);
legBLUpper.name = 'legBLUpper';
legBLUpper.position.set(0, -0.18, 0);
legBL.add(legBLUpper);
const legBLHoof = new THREE.Mesh(boxGeo2, hoofMat);
legBLHoof.name = 'legBLHoof';
legBLHoof.position.set(0, -0.4, 0);
legBL.add(legBLHoof);
const legBR = new THREE.Group();
legBR.name = 'legBR';
legBR.position.set(-0.21, 0.44, -0.35);
root.add(legBR);
const legBRUpper = new THREE.Mesh(boxGeo, hideMat);
legBRUpper.name = 'legBRUpper';
legBRUpper.position.set(0, -0.18, 0);
legBR.add(legBRUpper);
const legBRHoof = new THREE.Mesh(boxGeo2, hoofMat);
legBRHoof.name = 'legBRHoof';
legBRHoof.position.set(0, -0.4, 0);
legBR.add(legBRHoof);
const body = new THREE.Group();
body.name = 'body';
root.add(body);
const torso = new THREE.Mesh(new THREE.BoxGeometry(0.66, 0.54, 1), hideMat);
torso.name = 'torso';
torso.position.set(0, 0.66, 0);
body.add(torso);
const spotTopL = new THREE.Mesh(new THREE.BoxGeometry(0.256, 0.306, 0.34), spotMat);
spotTopL.name = 'spotTopL';
spotTopL.position.set(0.208, 0.783, 0.09);
body.add(spotTopL);
const spotSideR = new THREE.Mesh(new THREE.BoxGeometry(0.136, 0.28, 0.34), spotMat);
spotSideR.name = 'spotSideR';
spotSideR.position.set(-0.268, 0.63, -0.25);
body.add(spotSideR);
const spotTopR = new THREE.Mesh(new THREE.BoxGeometry(0.296, 0.226, 0.26), spotMat);
spotTopR.name = 'spotTopR';
spotTopR.position.set(-0.188, 0.823, 0.27);
body.add(spotTopR);
const spotRear = new THREE.Mesh(new THREE.BoxGeometry(0.32, 0.26, 0.126), spotMat);
spotRear.name = 'spotRear';
spotRear.position.set(0.04, 0.68, -0.443);
body.add(spotRear);
const spotBackL = new THREE.Mesh(new THREE.BoxGeometry(0.196, 0.22, 0.206), spotMat);
spotBackL.name = 'spotBackL';
spotBackL.position.set(0.238, 0.56, -0.403);
body.add(spotBackL);
const udder = new THREE.Mesh(new THREE.BoxGeometry(0.24, 0.08, 0.24), pinkMat);
udder.name = 'udder';
udder.position.set(0, 0.36, -0.24);
body.add(udder);
const teat = new THREE.Mesh(boxGeo3, pinkMat);
teat.name = 'teat';
teat.position.set(0.06, 0.3, -0.18);
body.add(teat);
const teat2 = new THREE.Mesh(boxGeo3, pinkMat);
teat2.name = 'teat';
teat2.position.set(-0.06, 0.3, -0.18);
body.add(teat2);
const teat3 = new THREE.Mesh(boxGeo3, pinkMat);
teat3.name = 'teat';
teat3.position.set(0.06, 0.3, -0.3);
body.add(teat3);
const teat4 = new THREE.Mesh(boxGeo3, pinkMat);
teat4.name = 'teat';
teat4.position.set(-0.06, 0.3, -0.3);
body.add(teat4);
const tail = new THREE.Group();
tail.name = 'tail';
tail.position.set(0.07, 0.89, -0.52);
tail.rotation.set(deg(-10), 0, deg(8));
root.add(tail);
const tailRope = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.4, 0.05), hideMat);
tailRope.name = 'tailRope';
tailRope.position.set(0, -0.2, -0.02);
tail.add(tailRope);
const tailTuft = new THREE.Mesh(new THREE.BoxGeometry(0.09, 0.12, 0.09), spotMat);
tailTuft.name = 'tailTuft';
tailTuft.position.set(0, -0.42, -0.02);
tail.add(tailTuft);
const head = new THREE.Group();
head.name = 'head';
head.position.set(0, 0.86, 0.42);
root.add(head);
const skull = new THREE.Mesh(new THREE.BoxGeometry(0.56, 0.5, 0.46), hideMat);
skull.name = 'skull';
skull.position.set(0, 0.15, 0.2);
head.add(skull);
const spotHead = new THREE.Mesh(new THREE.BoxGeometry(0.24, 0.24, 0.3), spotMat);
spotHead.name = 'spotHead';
spotHead.position.set(0.166, 0.286, 0.114);
head.add(spotHead);
const muzzle = new THREE.Mesh(new THREE.BoxGeometry(0.6, 0.22, 0.14), pinkMat);
muzzle.name = 'muzzle';
muzzle.position.set(0, 0, 0.49);
head.add(muzzle);
const nostrilL = new THREE.Mesh(boxGeo4, hoofMat);
nostrilL.name = 'nostrilL';
nostrilL.position.set(0.12, 0.03, 0.566);
head.add(nostrilL);
const nostrilR = new THREE.Mesh(boxGeo4, hoofMat);
nostrilR.name = 'nostrilR';
nostrilR.position.set(-0.12, 0.03, 0.566);
head.add(nostrilR);
const eyeL = new THREE.Mesh(boxGeo5, eyeMat);
eyeL.name = 'eyeL';
eyeL.position.set(0.246, 0.22, 0.396);
head.add(eyeL);
const eyeShineL = new THREE.Mesh(boxGeo6, hornMat);
eyeShineL.name = 'eyeShineL';
eyeShineL.position.set(0.256, 0.24, 0.4405);
head.add(eyeShineL);
const eyeR = new THREE.Mesh(boxGeo5, eyeMat);
eyeR.name = 'eyeR';
eyeR.position.set(-0.246, 0.22, 0.396);
head.add(eyeR);
const eyeShineR = new THREE.Mesh(boxGeo6, hornMat);
eyeShineR.name = 'eyeShineR';
eyeShineR.position.set(-0.256, 0.24, 0.4405);
head.add(eyeShineR);
const earL = new THREE.Group();
earL.name = 'earL';
earL.position.set(0.28, 0.29, 0.12);
earL.rotation.set(0, 0, deg(-20));
head.add(earL);
const earFlapL = new THREE.Mesh(boxGeo7, hideMat);
earFlapL.name = 'earFlapL';
earFlapL.position.set(0.09, 0, 0);
earL.add(earFlapL);
const earInL = new THREE.Mesh(boxGeo8, pinkMat);
earInL.name = 'earInL';
earInL.position.set(0.1, 0, 0.043);
earL.add(earInL);
const earR = new THREE.Group();
earR.name = 'earR';
earR.position.set(-0.28, 0.29, 0.12);
earR.rotation.set(0, 0, deg(20));
head.add(earR);
const earFlapR = new THREE.Mesh(boxGeo7, hideMat);
earFlapR.name = 'earFlapR';
earFlapR.position.set(-0.09, 0, 0);
earR.add(earFlapR);
const earInR = new THREE.Mesh(boxGeo8, pinkMat);
earInR.name = 'earInR';
earInR.position.set(-0.1, 0, 0.043);
earR.add(earInR);
const hornBaseL = new THREE.Mesh(boxGeo9, hornMat);
hornBaseL.name = 'hornBaseL';
hornBaseL.position.set(0.315, 0.38, 0.16);
head.add(hornBaseL);
const hornTipL = new THREE.Mesh(boxGeo10, hornMat);
hornTipL.name = 'hornTipL';
hornTipL.position.set(0.355, 0.47, 0.16);
hornTipL.rotation.set(0, 0, deg(-12));
head.add(hornTipL);
const hornBaseR = new THREE.Mesh(boxGeo9, hornMat);
hornBaseR.name = 'hornBaseR';
hornBaseR.position.set(-0.315, 0.38, 0.16);
head.add(hornBaseR);
const hornTipR = new THREE.Mesh(boxGeo10, hornMat);
hornTipR.name = 'hornTipR';
hornTipR.position.set(-0.355, 0.47, 0.16);
hornTipR.rotation.set(0, 0, deg(12));
head.add(hornTipR);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createCow;
Puanlar ve yorumlar
0 yorum
Henüz yorum yok. Bu modeli nasıl kullandığını ya da neyin daha iyi olabileceğini paylaş.
Benzer modeller
Aynı kategori ya da benzer etiketler









