Codels
624 tris1,04 × 1,13 × 1,04 m

Utiliser dans le code

Remixer dans l’éditeur
Module ES autonome — ne dépend que de three. Appelez la fonction factory et ajoutez le groupe à votre scène.
/**
 * Floating Block — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 624 · Size (W × H × D): 1.04 × 1.13 × 1.04 m
 *
 * Usage:
 *   import { createFloatingBlock } from './floating-block.js';
 *   
 *   const model = createFloatingBlock();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

const deg = THREE.MathUtils.degToRad;

export function createFloatingBlock() {
  const root = new THREE.Group();
  root.name = 'FloatingBlock';

  // Materials
  const dirtMat = new THREE.MeshStandardMaterial({ name: 'dirt', color: 0x9a6236, roughness: 0.95, flatShading: true });
  const dirtDarkMat = new THREE.MeshStandardMaterial({ name: 'dirtDark', color: 0x6f4424, roughness: 1, flatShading: true });
  const grassMat = new THREE.MeshStandardMaterial({ name: 'grass', color: 0x6cc644, roughness: 0.85, flatShading: true });
  const grassDarkMat = new THREE.MeshStandardMaterial({ name: 'grassDark', color: 0x4e9f33, roughness: 0.9, flatShading: true });
  const underMat = new THREE.MeshStandardMaterial({ name: 'under', color: 0xb98559, roughness: 0.9, emissive: 0xc48a55, emissiveIntensity: 0.35, flatShading: true });
  const flowerMat = new THREE.MeshStandardMaterial({ name: 'flower', color: 0xfff1a8, roughness: 0.6, emissive: 0xffe066, emissiveIntensity: 0.3, flatShading: true });

  // Shared geometries
  const sphereGeo = new THREE.SphereGeometry(0.03, 6, 4);

  // Parts
  const underside = new THREE.Mesh(new THREE.BoxGeometry(0.9, 0.06, 0.9), underMat);
  underside.name = 'underside';
  underside.position.set(0, 0.03, 0);
  root.add(underside);
  const body = new THREE.Mesh(new THREE.BoxGeometry(1, 0.78, 1), dirtMat);
  body.name = 'body';
  body.position.set(0, 0.44, 0);
  root.add(body);
  const turf = new THREE.Mesh(new THREE.BoxGeometry(1.04, 0.17, 1.04), grassMat);
  turf.name = 'turf';
  turf.position.set(0, 0.915, 0);
  root.add(turf);
  const dripsFront = new THREE.Group();
  dripsFront.name = 'dripsFront';
  dripsFront.position.set(0, 0.5, 0);
  root.add(dripsFront);
  const box5 = new THREE.Mesh(new THREE.BoxGeometry(0.1214, 0.0581, 0.04), grassMat);
  box5.position.set(-0.4393, 0.306, 0.5);
  dripsFront.add(box5);
  const box6 = new THREE.Mesh(new THREE.BoxGeometry(0.2039, 0.1178, 0.04), grassDarkMat);
  box6.position.set(-0.188, 0.2761, 0.5);
  dripsFront.add(box6);
  const box7 = new THREE.Mesh(new THREE.BoxGeometry(0.1759, 0.0812, 0.04), grassMat);
  box7.position.set(0.0562, 0.2944, 0.5);
  dripsFront.add(box7);
  const box8 = new THREE.Mesh(new THREE.BoxGeometry(0.2076, 0.0835, 0.04), grassDarkMat);
  box8.position.set(0.3112, 0.2932, 0.5);
  dripsFront.add(box8);
  const box9 = new THREE.Mesh(new THREE.BoxGeometry(0.2117, 0.1174, 0.04), grassMat);
  box9.position.set(0.4142, 0.2763, 0.5);
  dripsFront.add(box9);
  const box10 = new THREE.Mesh(new THREE.BoxGeometry(0.0821, 0.0517, 0.03), dirtDarkMat);
  box10.position.set(0.025, -0.2437, 0.5);
  box10.rotation.set(0, 0, deg(23.8973));
  dripsFront.add(box10);
  const box11 = new THREE.Mesh(new THREE.BoxGeometry(0.0749, 0.0751, 0.03), dirtDarkMat);
  box11.position.set(-0.2226, -0.3139, 0.5);
  box11.rotation.set(0, 0, deg(-17.2678));
  dripsFront.add(box11);
  const box12 = new THREE.Mesh(new THREE.BoxGeometry(0.0775, 0.0619, 0.03), dirtDarkMat);
  box12.position.set(0.1885, -0.3457, 0.5);
  box12.rotation.set(0, 0, deg(20.647));
  dripsFront.add(box12);
  const dripsRight = new THREE.Group();
  dripsRight.name = 'dripsRight';
  dripsRight.position.set(0, 0.5, 0);
  dripsRight.rotation.set(0, deg(90), 0);
  root.add(dripsRight);
  const box14 = new THREE.Mesh(new THREE.BoxGeometry(0.1864, 0.1308, 0.04), grassMat);
  box14.position.set(-0.4068, 0.2696, 0.5);
  dripsRight.add(box14);
  const box15 = new THREE.Mesh(new THREE.BoxGeometry(0.2359, 0.1312, 0.04), grassDarkMat);
  box15.position.set(-0.1248, 0.2694, 0.5);
  dripsRight.add(box15);
  const box16 = new THREE.Mesh(new THREE.BoxGeometry(0.2193, 0.0552, 0.04), grassMat);
  box16.position.set(0.1881, 0.3074, 0.5);
  dripsRight.add(box16);
  const box17 = new THREE.Mesh(new THREE.BoxGeometry(0.1628, 0.1053, 0.04), grassDarkMat);
  box17.position.set(0.4197, 0.2824, 0.5);
  dripsRight.add(box17);
  const box18 = new THREE.Mesh(new THREE.BoxGeometry(0.0653, 0.0707, 0.03), dirtDarkMat);
  box18.position.set(-0.0943, -0.1837, 0.5);
  box18.rotation.set(0, 0, deg(-1.5669));
  dripsRight.add(box18);
  const box19 = new THREE.Mesh(new THREE.BoxGeometry(0.1168, 0.0681, 0.03), dirtDarkMat);
  box19.position.set(0.1356, -0.2279, 0.5);
  box19.rotation.set(0, 0, deg(-7.1833));
  dripsRight.add(box19);
  const box20 = new THREE.Mesh(new THREE.BoxGeometry(0.0683, 0.0453, 0.03), dirtDarkMat);
  box20.position.set(0.2974, -0.2317, 0.5);
  box20.rotation.set(0, 0, deg(-15.4812));
  dripsRight.add(box20);
  const dripsBack = new THREE.Group();
  dripsBack.name = 'dripsBack';
  dripsBack.position.set(0, 0.5, 0);
  dripsBack.rotation.set(0, deg(180), 0);
  root.add(dripsBack);
  const box22 = new THREE.Mesh(new THREE.BoxGeometry(0.1959, 0.0938, 0.04), grassMat);
  box22.position.set(-0.4021, 0.2881, 0.5);
  dripsBack.add(box22);
  const box23 = new THREE.Mesh(new THREE.BoxGeometry(0.2021, 0.1698, 0.04), grassDarkMat);
  box23.position.set(-0.1705, 0.2501, 0.5);
  dripsBack.add(box23);
  const box24 = new THREE.Mesh(new THREE.BoxGeometry(0.2192, 0.1352, 0.04), grassMat);
  box24.position.set(0.1031, 0.2674, 0.5);
  dripsBack.add(box24);
  const box25 = new THREE.Mesh(new THREE.BoxGeometry(0.134, 0.1189, 0.04), grassDarkMat);
  box25.position.set(0.3649, 0.2756, 0.5);
  dripsBack.add(box25);
  const box26 = new THREE.Mesh(new THREE.BoxGeometry(0.1135, 0.0784, 0.03), dirtDarkMat);
  box26.position.set(0.2433, -0.1067, 0.5);
  box26.rotation.set(0, 0, deg(23.1935));
  dripsBack.add(box26);
  const box27 = new THREE.Mesh(new THREE.BoxGeometry(0.1181, 0.0619, 0.03), dirtDarkMat);
  box27.position.set(0.2293, -0.3774, 0.5);
  box27.rotation.set(0, 0, deg(0.8037));
  dripsBack.add(box27);
  const box28 = new THREE.Mesh(new THREE.BoxGeometry(0.0797, 0.069, 0.03), dirtDarkMat);
  box28.position.set(0.0356, -0.0325, 0.5);
  box28.rotation.set(0, 0, deg(23.8467));
  dripsBack.add(box28);
  const dripsLeft = new THREE.Group();
  dripsLeft.name = 'dripsLeft';
  dripsLeft.position.set(0, 0.5, 0);
  dripsLeft.rotation.set(0, deg(-90), 0);
  root.add(dripsLeft);
  const box30 = new THREE.Mesh(new THREE.BoxGeometry(0.1869, 0.157, 0.04), grassMat);
  box30.position.set(-0.4065, 0.2565, 0.5);
  dripsLeft.add(box30);
  const box31 = new THREE.Mesh(new THREE.BoxGeometry(0.1971, 0.146, 0.04), grassDarkMat);
  box31.position.set(-0.1588, 0.262, 0.5);
  dripsLeft.add(box31);
  const box32 = new THREE.Mesh(new THREE.BoxGeometry(0.1575, 0.0808, 0.04), grassMat);
  box32.position.set(0.0816, 0.2946, 0.5);
  dripsLeft.add(box32);
  const box33 = new THREE.Mesh(new THREE.BoxGeometry(0.1229, 0.1726, 0.04), grassDarkMat);
  box33.position.set(0.2524, 0.2487, 0.5);
  dripsLeft.add(box33);
  const box34 = new THREE.Mesh(new THREE.BoxGeometry(0.1957, 0.0519, 0.04), grassMat);
  box34.position.set(0.4222, 0.3091, 0.5);
  dripsLeft.add(box34);
  const box35 = new THREE.Mesh(new THREE.BoxGeometry(0.0957, 0.0687, 0.03), dirtDarkMat);
  box35.position.set(0.3563, -0.2521, 0.5);
  box35.rotation.set(0, 0, deg(24.3138));
  dripsLeft.add(box35);
  const box36 = new THREE.Mesh(new THREE.BoxGeometry(0.099, 0.0722, 0.03), dirtDarkMat);
  box36.position.set(0.0896, 0.0019, 0.5);
  box36.rotation.set(0, 0, deg(-18.0468));
  dripsLeft.add(box36);
  const box37 = new THREE.Mesh(new THREE.BoxGeometry(0.1197, 0.0603, 0.03), dirtDarkMat);
  box37.position.set(0.0482, -0.306, 0.5);
  box37.rotation.set(0, 0, deg(-5.1917));
  dripsLeft.add(box37);
  const tufts = new THREE.Group();
  tufts.name = 'tufts';
  root.add(tufts);
  const cone39 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.0926, 4), grassMat);
  cone39.position.set(-0.31, 1.0463, 0.2325);
  cone39.rotation.set(deg(10.1239), 0, deg(-18));
  tufts.add(cone39);
  const cone40 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1242, 4), grassDarkMat);
  cone40.position.set(-0.28, 1.0621, 0.2263);
  cone40.rotation.set(deg(13.7268), 0, 0);
  tufts.add(cone40);
  const cone41 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1166, 4), grassMat);
  cone41.position.set(-0.25, 1.0583, 0.2295);
  cone41.rotation.set(deg(12.7509), 0, deg(18));
  tufts.add(cone41);
  const sphere42 = new THREE.Mesh(sphereGeo, flowerMat);
  sphere42.position.set(-0.23, 1.03, 0.26);
  tufts.add(sphere42);
  const cone43 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1094, 4), grassMat);
  cone43.position.set(0.21, 1.0547, -0.2708);
  cone43.rotation.set(deg(2.3522), 0, deg(-18));
  tufts.add(cone43);
  const cone44 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1277, 4), grassDarkMat);
  cone44.position.set(0.24, 1.0639, -0.2458);
  cone44.rotation.set(deg(-8.6822), 0, 0);
  tufts.add(cone44);
  const cone45 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1133, 4), grassMat);
  cone45.position.set(0.27, 1.0567, -0.2609);
  cone45.rotation.set(deg(0.7181), 0, deg(18));
  tufts.add(cone45);
  const cone46 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.0908, 4), grassMat);
  cone46.position.set(0.27, 1.0454, 0.29);
  cone46.rotation.set(deg(-1.709), 0, deg(-18));
  tufts.add(cone46);
  const cone47 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1087, 4), grassDarkMat);
  cone47.position.set(0.3, 1.0543, 0.2868);
  cone47.rotation.set(deg(-13.9101), 0, 0);
  tufts.add(cone47);
  const cone48 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.0904, 4), grassMat);
  cone48.position.set(0.33, 1.0452, 0.281);
  cone48.rotation.set(deg(-10.9976), 0, deg(18));
  tufts.add(cone48);
  const sphere49 = new THREE.Mesh(sphereGeo, flowerMat);
  sphere49.position.set(0.35, 1.03, 0.34);
  tufts.add(sphere49);
  const cone50 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1326, 4), grassMat);
  cone50.position.set(-0.23, 1.0663, -0.2807);
  cone50.rotation.set(deg(-12.3166), 0, deg(-18));
  tufts.add(cone50);
  const cone51 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.0905, 4), grassDarkMat);
  cone51.position.set(-0.2, 1.0453, -0.3038);
  cone51.rotation.set(deg(-0.0281), 0, 0);
  tufts.add(cone51);
  const cone52 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1239, 4), grassMat);
  cone52.position.set(-0.17, 1.062, -0.3053);
  cone52.rotation.set(deg(-3.9196), 0, deg(18));
  tufts.add(cone52);
  const cone53 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1275, 4), grassMat);
  cone53.position.set(-0.01, 1.0638, 0.0584);
  cone53.rotation.set(deg(8.4032), 0, deg(-18));
  tufts.add(cone53);
  const cone54 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1118, 4), grassDarkMat);
  cone54.position.set(0.02, 1.0559, 0.0619);
  cone54.rotation.set(deg(-2.4594), 0, 0);
  tufts.add(cone54);
  const cone55 = new THREE.Mesh(new THREE.ConeGeometry(0.025, 0.1138, 4), grassMat);
  cone55.position.set(0.05, 1.0569, 0.0417);
  cone55.rotation.set(deg(0.7632), 0, deg(18));
  tufts.add(cone55);
  const sphere56 = new THREE.Mesh(sphereGeo, flowerMat);
  sphere56.position.set(0.07, 1.03, 0.09);
  tufts.add(sphere56);

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

export default createFloatingBlock;

Notes et commentaires

—
Aucune note pour l’instant — soyez le premier.
5
0
4
0
3
0
2
0
1
0

Connectez-vous pour noter et commenter.

0 commentaire

Aucun commentaire pour l’instant. Dites comment vous avez utilisé ce modèle ou ce qui pourrait être amélioré.

Modèles similaires

Même catégorie ou étiquettes proches