1 B üçgen1,26 × 1,98 × 1,07 m
Kodda kullan
Editörde remix’lepitchfork.js · 342 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.
/**
* Pitchfork — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 1,027 · Size (W × H × D): 1.26 × 1.98 × 1.07 m
*
* Usage:
* import { createPitchfork } from './pitchfork.js';
*
* const model = createPitchfork();
* 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 createPitchfork() {
const root = new THREE.Group();
root.name = 'Pitchfork';
// Materials
const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0xb98952, roughness: 0.75, flatShading: true });
const woodDarkMat = new THREE.MeshStandardMaterial({ name: 'woodDark', color: 0x785935, roughness: 0.85, flatShading: true });
const steelMat = new THREE.MeshStandardMaterial({ name: 'steel', color: 0x6f767f, roughness: 0.45, metalness: 0.45, flatShading: true });
const steelDarkMat = new THREE.MeshStandardMaterial({ name: 'steelDark', color: 0x484d53, roughness: 0.5, metalness: 0.4, flatShading: true });
const hayMat = new THREE.MeshStandardMaterial({ name: 'hay', color: 0xd8b75e, roughness: 1, flatShading: true });
const hayDarkMat = new THREE.MeshStandardMaterial({ name: 'hayDark', color: 0xad8a3e, roughness: 1, flatShading: true });
// Shared geometries
const boxGeo = new THREE.BoxGeometry(0.008, 0.005, 0.203);
const sphereGeo = new THREE.SphereGeometry(0.012, 5, 3);
const cylinderGeo = new THREE.CylinderGeometry(0.014, 0.01, 0.0939, 5);
const cylinderGeo2 = new THREE.CylinderGeometry(0.0075, 0.0085, 0.1185, 5);
const cylinderGeo3 = new THREE.CylinderGeometry(0.0058, 0.0075, 0.1097, 5);
const cylinderGeo4 = new THREE.CylinderGeometry(0.0012, 0.0058, 0.094, 5);
// Parts
const hayPile = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.46, 9, 4, 0, Math.PI * 2, 0, Math.PI / 2), 0.035, 4), hayMat);
hayPile.name = 'hayPile';
hayPile.position.set(0, 0.027, 0);
hayPile.scale.set(1, 0.8696, 0.88);
root.add(hayPile);
const hayLump = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.16, 0), 0.024, 2), hayMat);
hayLump.name = 'hayLump';
hayLump.position.set(0.06, 0.32, -0.04);
hayLump.scale.set(1.2, 0.8, 1);
root.add(hayLump);
const hayLump2 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.15, 0), 0.0225, 3), hayDarkMat);
hayLump2.name = 'hayLump';
hayLump2.position.set(-0.17, 0.22, 0.13);
hayLump2.scale.set(1.2, 0.8, 1);
root.add(hayLump2);
const hayLump3 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.13, 0), 0.0195, 4), hayMat);
hayLump3.name = 'hayLump';
hayLump3.position.set(0.22, 0.18, 0.12);
hayLump3.scale.set(1.2, 0.8, 1);
root.add(hayLump3);
const hayLump4 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.14, 0), 0.021, 5), hayDarkMat);
hayLump4.name = 'hayLump';
hayLump4.position.set(-0.14, 0.27, -0.16);
hayLump4.scale.set(1.2, 0.8, 1);
root.add(hayLump4);
const hayLump5 = new THREE.Mesh(jitter(new THREE.DodecahedronGeometry(0.12, 0), 0.018, 6), hayMat);
hayLump5.name = 'hayLump';
hayLump5.position.set(0.2, 0.22, -0.2);
hayLump5.scale.set(1.2, 0.8, 1);
root.add(hayLump5);
const straw = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2008), hayDarkMat);
straw.name = 'straw';
straw.position.set(-0.2454, 0.348, -0.0158);
straw.rotation.set(deg(-152.1473), deg(-46.1452), deg(-105.1868));
root.add(straw);
const straw2 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.185), hayMat);
straw2.name = 'straw';
straw2.position.set(-0.2698, 0.3307, -0.0461);
straw2.rotation.set(deg(-158.2483), deg(-41.4822), deg(-5.5594));
root.add(straw2);
const straw3 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1579), hayMat);
straw3.name = 'straw';
straw3.position.set(-0.0457, 0.3985, -0.0876);
straw3.rotation.set(deg(-161.6999), deg(-33.9926), deg(-19.5736));
root.add(straw3);
const straw4 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1977), hayMat);
straw4.name = 'straw';
straw4.position.set(0.1886, 0.3333, 0.1712);
straw4.rotation.set(deg(-25.0648), deg(7.8036), deg(140.122));
root.add(straw4);
const straw5 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1652), hayMat);
straw5.name = 'straw';
straw5.position.set(-0.1156, 0.327, 0.2249);
straw5.rotation.set(deg(-39.5603), deg(-41.7555), deg(37.8097));
root.add(straw5);
const straw6 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1747), hayDarkMat);
straw6.name = 'straw';
straw6.position.set(0.1968, 0.293, 0.2277);
straw6.rotation.set(deg(-28.8628), deg(26.2101), deg(32.6362));
root.add(straw6);
const straw7 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1785), hayMat);
straw7.name = 'straw';
straw7.position.set(0.2073, 0.2659, -0.252);
straw7.rotation.set(deg(-154.2189), deg(-6.995), deg(59.6015));
root.add(straw7);
const straw8 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1902), hayDarkMat);
straw8.name = 'straw';
straw8.position.set(-0.148, 0.3881, -0.0216);
straw8.rotation.set(deg(-35.596), deg(-51.3899), deg(-9.4432));
root.add(straw8);
const straw9 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2384), hayMat);
straw9.name = 'straw';
straw9.position.set(-0.2678, 0.3241, 0.0856);
straw9.rotation.set(deg(-33.0334), deg(-62.637), deg(-11.7649));
root.add(straw9);
const straw10 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2159), hayMat);
straw10.name = 'straw';
straw10.position.set(-0.0214, 0.368, -0.1796);
straw10.rotation.set(deg(-165.6124), deg(-0.3125), deg(149.1568));
root.add(straw10);
const straw11 = new THREE.Mesh(boxGeo, hayDarkMat);
straw11.name = 'straw';
straw11.position.set(0.0502, 0.4016, 0.0698);
straw11.rotation.set(deg(-39.2108), deg(65.9951), deg(94.0174));
root.add(straw11);
const straw12 = new THREE.Mesh(boxGeo, hayMat);
straw12.name = 'straw';
straw12.position.set(0.3376, 0.2528, -0.1235);
straw12.rotation.set(deg(-45.9649), deg(61.5732), deg(106.6368));
root.add(straw12);
const straw13 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1409), hayDarkMat);
straw13.name = 'straw';
straw13.position.set(-0.0855, 0.351, 0.1977);
straw13.rotation.set(deg(-15.837), deg(-0.3528), deg(22.1795));
root.add(straw13);
const straw14 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1945), hayDarkMat);
straw14.name = 'straw';
straw14.position.set(0.2856, 0.2925, 0.1377);
straw14.rotation.set(deg(-120.9729), deg(67.2254), deg(-148.8694));
root.add(straw14);
const straw15 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1998), hayDarkMat);
straw15.name = 'straw';
straw15.position.set(0.3033, 0.1985, -0.2371);
straw15.rotation.set(deg(-150.3256), deg(52.1091), deg(140.0976));
root.add(straw15);
const straw16 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2395), hayDarkMat);
straw16.name = 'straw';
straw16.position.set(-0.1683, 0.3199, -0.2087);
straw16.rotation.set(deg(-151.0156), deg(-70.745), deg(-23.5423));
root.add(straw16);
const straw17 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2326), hayMat);
straw17.name = 'straw';
straw17.position.set(0.1744, 0.3792, -0.0272);
straw17.rotation.set(deg(-53.6946), deg(62.9286), deg(47.2603));
root.add(straw17);
const straw18 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1892), hayDarkMat);
straw18.name = 'straw';
straw18.position.set(-0.0675, 0.3164, 0.2533);
straw18.rotation.set(deg(-23.6712), deg(13.919), deg(59.6156));
root.add(straw18);
const straw19 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1781), hayMat);
straw19.name = 'straw';
straw19.position.set(0.2135, 0.3429, 0.1226);
straw19.rotation.set(deg(-29.7295), deg(21.3384), deg(140.8343));
root.add(straw19);
const straw20 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.225), hayDarkMat);
straw20.name = 'straw';
straw20.position.set(0.2101, 0.3658, 0.0059);
straw20.rotation.set(deg(-45.0537), deg(59.6537), deg(26.8974));
root.add(straw20);
const straw21 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1563), hayDarkMat);
straw21.name = 'straw';
straw21.position.set(-0.5977, 0.005, 0.013);
straw21.rotation.set(0, deg(15.2599), 0);
root.add(straw21);
const straw22 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2104), hayDarkMat);
straw22.name = 'straw';
straw22.position.set(0.627, 0.005, -0.0085);
straw22.rotation.set(0, deg(176.8255), 0);
root.add(straw22);
const straw23 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1996), hayMat);
straw23.name = 'straw';
straw23.position.set(0.4943, 0.005, 0.1432);
straw23.rotation.set(0, deg(95.9298), 0);
root.add(straw23);
const straw24 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1863), hayMat);
straw24.name = 'straw';
straw24.position.set(0.4699, 0.005, 0.136);
straw24.rotation.set(0, deg(130.6934), 0);
root.add(straw24);
const straw25 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1989), hayMat);
straw25.name = 'straw';
straw25.position.set(-0.4809, 0.005, 0.2545);
straw25.rotation.set(0, deg(53.435), 0);
root.add(straw25);
const straw26 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2084), hayMat);
straw26.name = 'straw';
straw26.position.set(-0.5076, 0.005, 0.159);
straw26.rotation.set(0, deg(115.8299), 0);
root.add(straw26);
const straw27 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1565), hayDarkMat);
straw27.name = 'straw';
straw27.position.set(0.5113, 0.005, 0.0079);
straw27.rotation.set(0, deg(147.0344), 0);
root.add(straw27);
const straw28 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2226), hayDarkMat);
straw28.name = 'straw';
straw28.position.set(0.2201, 0.005, 0.5211);
straw28.rotation.set(0, deg(17.969), 0);
root.add(straw28);
const straw29 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.1616), hayMat);
straw29.name = 'straw';
straw29.position.set(0.5592, 0.005, 0.3061);
straw29.rotation.set(0, deg(17.4788), 0);
root.add(straw29);
const straw30 = new THREE.Mesh(new THREE.BoxGeometry(0.008, 0.005, 0.2121), hayDarkMat);
straw30.name = 'straw';
straw30.position.set(0.4711, 0.005, -0.3726);
straw30.rotation.set(0, deg(127.1996), 0);
root.add(straw30);
const pitchfork = new THREE.Group();
pitchfork.name = 'pitchfork';
pitchfork.position.set(-0.0482, 0.6258, 0.0225);
pitchfork.rotation.set(0, deg(25), deg(9));
root.add(pitchfork);
const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.017, 0.018, 1.26, 7), woodMat);
handle.name = 'handle';
handle.position.set(0, 0.73, 0);
pitchfork.add(handle);
const endKnob = new THREE.Mesh(new THREE.SphereGeometry(0.021, 6, 4), woodDarkMat);
endKnob.name = 'endKnob';
endKnob.position.set(0, 1.36, 0);
endKnob.scale.set(1, 0.7, 1);
pitchfork.add(endKnob);
const ferrule = new THREE.Mesh(new THREE.CylinderGeometry(0.021, 0.015, 0.15, 7), steelDarkMat);
ferrule.name = 'ferrule';
ferrule.position.set(0, 0.065, 0);
pitchfork.add(ferrule);
const ferruleRing = new THREE.Mesh(new THREE.CylinderGeometry(0.024, 0.024, 0.012, 7), steelMat);
ferruleRing.name = 'ferruleRing';
ferruleRing.position.set(0, 0.131, 0);
pitchfork.add(ferruleRing);
const shoulder = new THREE.Mesh(new THREE.CylinderGeometry(0.011, 0.011, 0.182, 6), steelMat);
shoulder.name = 'shoulder';
shoulder.position.set(0, -0.04, 0);
shoulder.rotation.set(0, 0, deg(90));
pitchfork.add(shoulder);
const shoulderEnd = new THREE.Mesh(sphereGeo, steelMat);
shoulderEnd.name = 'shoulderEnd';
shoulderEnd.position.set(-0.091, -0.04, 0);
pitchfork.add(shoulderEnd);
const brace = new THREE.Mesh(cylinderGeo, steelMat);
brace.name = 'brace';
brace.position.set(-0.0425, -0.02, 0);
brace.rotation.set(0, 0, deg(-64.7989));
pitchfork.add(brace);
const shoulderEnd2 = new THREE.Mesh(sphereGeo, steelMat);
shoulderEnd2.name = 'shoulderEnd';
shoulderEnd2.position.set(0.091, -0.04, 0);
pitchfork.add(shoulderEnd2);
const brace2 = new THREE.Mesh(cylinderGeo, steelMat);
brace2.name = 'brace';
brace2.position.set(0.0425, -0.02, 0);
brace2.rotation.set(0, 0, deg(64.7989));
pitchfork.add(brace2);
const neck = new THREE.Mesh(new THREE.CylinderGeometry(0.016, 0.012, 0.04, 5), steelMat);
neck.name = 'neck';
neck.position.set(0, -0.02, 0);
pitchfork.add(neck);
const tine = new THREE.Mesh(cylinderGeo2, steelMat);
tine.name = 'tine';
tine.position.set(-0.0867, -0.095, 0.005);
tine.rotation.set(deg(173.4543), deg(37.4553), deg(2.2213));
pitchfork.add(tine);
const tine2 = new THREE.Mesh(cylinderGeo3, steelMat);
tine2.name = 'tine';
tine2.position.set(-0.0901, -0.2, 0.019);
tine2.rotation.set(deg(169.052), deg(21.2094), deg(2.0558));
pitchfork.add(tine2);
const tine3 = new THREE.Mesh(cylinderGeo4, steelMat);
tine3.name = 'tine';
tine3.position.set(-0.0926, -0.295, 0.0415);
tine3.rotation.set(deg(163.1725), deg(7.0522), deg(1.0444));
pitchfork.add(tine3);
const tine4 = new THREE.Mesh(cylinderGeo2, steelMat);
tine4.name = 'tine';
tine4.position.set(0, -0.095, 0.005);
tine4.rotation.set(deg(174.8056), 0, 0);
pitchfork.add(tine4);
const tine5 = new THREE.Mesh(new THREE.CylinderGeometry(0.0058, 0.0075, 0.1096, 5), steelMat);
tine5.name = 'tine';
tine5.position.set(0, -0.2, 0.019);
tine5.rotation.set(deg(169.796), 0, 0);
pitchfork.add(tine5);
const tine6 = new THREE.Mesh(cylinderGeo4, steelMat);
tine6.name = 'tine';
tine6.position.set(0, -0.295, 0.0415);
tine6.rotation.set(deg(163.3008), 0, 0);
pitchfork.add(tine6);
const tine7 = new THREE.Mesh(cylinderGeo2, steelMat);
tine7.name = 'tine';
tine7.position.set(0.0867, -0.095, 0.005);
tine7.rotation.set(deg(173.4543), deg(-37.4553), deg(-2.2213));
pitchfork.add(tine7);
const tine8 = new THREE.Mesh(cylinderGeo3, steelMat);
tine8.name = 'tine';
tine8.position.set(0.0901, -0.2, 0.019);
tine8.rotation.set(deg(169.052), deg(-21.2094), deg(-2.0558));
pitchfork.add(tine8);
const tine9 = new THREE.Mesh(cylinderGeo4, steelMat);
tine9.name = 'tine';
tine9.position.set(0.0927, -0.295, 0.0415);
tine9.rotation.set(deg(163.1725), deg(-7.0522), deg(-1.0444));
pitchfork.add(tine9);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createPitchfork;
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









