Codels
1470 Tris0,32 × 0,50 × 0,30 m

Im Code verwenden

Im Editor remixen
Eigenständiges ES-Modul — hängt nur von three ab. Ruf die Factory auf und füge die Gruppe deiner Szene hinzu.
/**
 * Desk Globe — Codels 3D model library
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 1,470 · Size (W × H × D): 0.32 × 0.50 × 0.30 m
 *
 * Usage:
 *   import { createGlobe } from './globe.js';
 *   
 *   const model = createGlobe();
 *   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;
}

// Revolve a 2D profile [[radius, y], ...] around the Y axis.
function lathe(points, segments, phiStart = 0, phiLength = Math.PI * 2) {
  return new THREE.LatheGeometry(points.map(([x, y]) => new THREE.Vector2(x, y)), segments, phiStart, phiLength);
}

export function createGlobe() {
  const root = new THREE.Group();
  root.name = 'Globe';

  // Materials
  const oceanMat = new THREE.MeshStandardMaterial({ name: 'ocean', color: 0x2f6db0, roughness: 0.45, flatShading: true });
  const landMat = new THREE.MeshStandardMaterial({ name: 'land', color: 0x74ad4c, roughness: 0.8, flatShading: true });
  const desertMat = new THREE.MeshStandardMaterial({ name: 'desert', color: 0xb8bc6d, roughness: 0.85, flatShading: true });
  const iceMat = new THREE.MeshStandardMaterial({ name: 'ice', color: 0xeef3f6, roughness: 0.7, flatShading: true });
  const standMat = new THREE.MeshStandardMaterial({ name: 'stand', color: 0x6b4528, roughness: 0.55, flatShading: true });
  const brassMat = new THREE.MeshStandardMaterial({ name: 'brass', color: 0xc79a45, roughness: 0.3, metalness: 0.75, flatShading: true });

  // Shared geometries
  const cylinderGeo = new THREE.CylinderGeometry(0.004, 0.004, 0.028, 6);
  const sphereGeo = new THREE.SphereGeometry(0.011, 6, 4);

  // Parts
  const stand = new THREE.Mesh(lathe([[0, 0], [0.11, 0], [0.116, 0.012], [0.104, 0.028], [0.06, 0.034], [0.036, 0.05], [0.024, 0.085], [0.032, 0.11], [0.02, 0.13], [0.016, 0.152], [0, 0.156]], 10), standMat);
  stand.name = 'stand';
  root.add(stand);
  const cradle = new THREE.Mesh(new THREE.SphereGeometry(0.016, 8, 6), brassMat);
  cradle.name = 'cradle';
  cradle.position.set(0, 0.156, 0);
  root.add(cradle);
  const tilted = new THREE.Group();
  tilted.name = 'tilted';
  tilted.position.set(0, 0.328, 0);
  tilted.rotation.set(0, 0, deg(-23.5));
  root.add(tilted);
  const earth = new THREE.Group();
  earth.name = 'earth';
  tilted.add(earth);
  const ocean = new THREE.Mesh(new THREE.SphereGeometry(0.15, 14, 10), oceanMat);
  ocean.name = 'ocean';
  earth.add(ocean);
  const land = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, -1.3614, 0.4887, 0.3316, 0.2269), 0.0007, 1), landMat);
  land.name = 'land';
  earth.add(land);
  const land2 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 2, -0.8727, Math.PI / 4, 0.3142, 0.2967), 0.0007, 2), landMat);
  land2.name = 'land';
  earth.add(land2);
  const land3 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 1, -0.0873, 0.576, 0.4538, 0.2443), 0.0007, 3), landMat);
  land3.name = 'land';
  earth.add(land3);
  const land4 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 4, 1, -Math.PI / 6, 0.8378, 0.1745, 0.1745), 0.0007, 4), landMat);
  land4.name = 'land';
  earth.add(land4);
  const land5 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 4, 2, -0.6109, 1.0297, 0.6109, 0.4363), 0.0007, 5), landMat);
  land5.name = 'land';
  earth.add(land5);
  const land6 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, -0.4712, 0.3491, 1.0123, 0.1745), 0.0007, 6), landMat);
  land6.name = 'land';
  earth.add(land6);
  const land7 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, -Math.PI / 12, 0.2967, 1.1519, 0.1571), 0.0007, 7), landMat);
  land7.name = 'land';
  earth.add(land7);
  const land8 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, -0.0349, 0.2443, 1.2915, 0.1396), 0.0007, 8), landMat);
  land8.name = 'land';
  earth.add(land8);
  const land9 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 0.1047, 0.0873, 1.0297, 0.1047), 0.0007, 9), landMat);
  land9.name = 'land';
  earth.add(land9);
  const land10 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 2, 0.1745, Math.PI / 4, 1.4312, 0.4014), 0.0007, 10), landMat);
  land10.name = 'land';
  earth.add(land10);
  const land11 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, 0.2094, 0.4887, 1.3614, 0.2094), 0.0007, 11), landMat);
  land11.name = 'land';
  earth.add(land11);
  const land12 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 1, Math.PI / 12, 0.6109, Math.PI * 0.5833, 0.1745), 0.0007, 12), landMat);
  land12.name = 'land';
  earth.add(land12);
  const land13 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, 0.2967, 0.3142, 2.0071, Math.PI / 12), 0.0007, 13), landMat);
  land13.name = 'land';
  earth.add(land13);
  const land14 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, Math.PI / 12, 0.1745, 2.2689, Math.PI / 12), 0.0007, 14), landMat);
  land14.name = 'land';
  earth.add(land14);
  const land15 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 1.3963, 0.2269, 0.8029, 0.1396), 0.0007, 15), landMat);
  land15.name = 'land';
  earth.add(land15);
  const land16 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 1, 1.4835, 0.6109, 0.5934, 0.2269), 0.0007, 16), landMat);
  land16.name = 'land';
  earth.add(land16);
  const land17 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 2, 1.6581, 0.4363, 0.3316, 0.2793), 0.0007, 17), landMat);
  land17.name = 'land';
  earth.add(land17);
  const land18 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 1.4312, 0.1745, 0.5585, 0.1396), 0.0007, 18), landMat);
  land18.name = 'land';
  earth.add(land18);
  const land19 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 1.7802, 0.1047, 0.7679, 0.1396), 0.0007, 19), landMat);
  land19.name = 'land';
  earth.add(land19);
  const land20 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 1.1519, 0.192, 0.4014, 0.0698), 0.0007, 20), landMat);
  land20.name = 'land';
  earth.add(land20);
  const land21 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 4, 2, 1.2741, 0.9076, 0.9425, 0.3665), 0.0007, 21), landMat);
  land21.name = 'land';
  earth.add(land21);
  const land22 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 5, 1, 1.2741, 1.1868, Math.PI * 0.4167, 0.192), 0.0007, 22), landMat);
  land22.name = 'land';
  earth.add(land22);
  const land23 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 2, 1.7104, 0.5934, 1.501, 0.2793), 0.0007, 23), landMat);
  land23.name = 'land';
  earth.add(land23);
  const land24 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 2, 1.7802, 0.4887, 1.7802, 0.384), 0.0007, 24), landMat);
  land24.name = 'land';
  earth.add(land24);
  const land25 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 2.3213, 0.1222, 1.7977, 0.2094), 0.0007, 25), landMat);
  land25.name = 'land';
  earth.add(land25);
  const land26 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 3, Math.PI * 0.6667, Math.PI / 6, 0.3142, 0.5585), 0.0007, 26), landMat);
  land26.name = 'land';
  earth.add(land26);
  const land27 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 8, 2, Math.PI * 0.8333, Math.PI * 0.6667, 0.2793, 0.4189), 0.0007, 27), landMat);
  land27.name = 'land';
  earth.add(land27);
  const land28 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 2, 2.1991, 0.4189, 1.0123, 0.3316), 0.0007, 28), landMat);
  land28.name = 'land';
  earth.add(land28);
  const land29 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 2, 2.3387, 0.5411, 0.8378, 0.2967), 0.0007, 29), landMat);
  land29.name = 'land';
  earth.add(land29);
  const land30 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 4, 2, Math.PI * 0.9167, Math.PI / 3, 0.6981, Math.PI / 6), 0.0007, 30), landMat);
  land30.name = 'land';
  earth.add(land30);
  const land31 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 2, 2.7576, 0.3491, 1.1345, 0.2967), 0.0007, 31), landMat);
  land31.name = 'land';
  earth.add(land31);
  const land32 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 2, 3.1765, 0.2793, 1.1868, 0.2793), 0.0007, 32), landMat);
  land32.name = 'land';
  earth.add(land32);
  const land33 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 3.3161, 0.0698, 1.4661, 0.0873), 0.0007, 33), landMat);
  land33.name = 'land';
  earth.add(land33);
  const land34 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 3.2289, 0.192, 1.501, 0.1745), 0.0007, 34), landMat);
  land34.name = 'land';
  earth.add(land34);
  const land35 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 3.4208, 0.1745, 1.6755, 0.0349), 0.0007, 35), landMat);
  land35.name = 'land';
  earth.add(land35);
  const land36 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 3.4732, 0.1745, 1.4835, 0.1571), 0.0007, 36), landMat);
  land36.name = 'land';
  earth.add(land36);
  const land37 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, Math.PI * 1.1667, 0.1047, 1.2566, 0.2269), 0.0007, 37), landMat);
  land37.name = 'land';
  earth.add(land37);
  const land38 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 3.8572, 0.192, 0.8378, 0.192), 0.0007, 38), landMat);
  land38.name = 'land';
  earth.add(land38);
  const land39 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, 3.8746, 0.3142, 1.6057, 0.1396), 0.0007, 39), landMat);
  land39.name = 'land';
  earth.add(land39);
  const land40 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 2, 3.5605, 0.6807, 1.885, 0.3491), 0.0007, 40), landMat);
  land40.name = 'land';
  earth.add(land40);
  const land41 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 2, 1, 3.7525, 0.3491, 1.7628, 0.1222), 0.0007, 41), landMat);
  land41.name = 'land';
  earth.add(land41);
  const land42 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 1, 1, 4.468, 0.2094, 2.1817, 0.192), 0.0007, 42), landMat);
  land42.name = 'land';
  earth.add(land42);
  const desert = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1531, 4, 1, Math.PI * 0.4167, 0.8203, 1.0297, 0.2269), 0.0007, 43), desertMat);
  desert.name = 'desert';
  earth.add(desert);
  const desert2 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1531, 2, 1, 2.234, 0.3142, 1.0647, 0.2269), 0.0007, 44), desertMat);
  desert2.name = 'desert';
  earth.add(desert2);
  const desert3 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1531, 2, 1, Math.PI * 1.1667, 0.384, 1.9373, 0.1745), 0.0007, 45), desertMat);
  desert3.name = 'desert';
  earth.add(desert3);
  const desert4 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1531, 2, 1, Math.PI, 0.384, 0.7679, 0.1222), 0.0007, 46), desertMat);
  desert4.name = 'desert';
  earth.add(desert4);
  const ice = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 3, 2, 0.5934, 0.6283, 0.1396, 0.384), 0.0007, 47), iceMat);
  ice.name = 'ice';
  earth.add(ice);
  const ice2 = new THREE.Mesh(jitter(new THREE.SphereGeometry(0.1524, 24, 2, -Math.PI / 2, Math.PI * 2, 2.7576, 0.384), 0.0007, 48), iceMat);
  ice2.name = 'ice';
  earth.add(ice2);
  const meridian = new THREE.Mesh(new THREE.TorusGeometry(0.168, 0.0065, 4, 16, Math.PI), brassMat);
  meridian.name = 'meridian';
  meridian.rotation.set(0, 0, deg(-90));
  tilted.add(meridian);
  const polePin = new THREE.Mesh(cylinderGeo, brassMat);
  polePin.name = 'polePin';
  polePin.position.set(0, 0.159, 0);
  tilted.add(polePin);
  const poleCap = new THREE.Mesh(sphereGeo, brassMat);
  poleCap.name = 'poleCap';
  poleCap.position.set(0, 0.172, 0);
  tilted.add(poleCap);
  const polePin2 = new THREE.Mesh(cylinderGeo, brassMat);
  polePin2.name = 'polePin';
  polePin2.position.set(0, -0.159, 0);
  tilted.add(polePin2);
  const poleCap2 = new THREE.Mesh(sphereGeo, brassMat);
  poleCap2.name = 'poleCap';
  poleCap2.position.set(0, -0.172, 0);
  tilted.add(poleCap2);

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

export default createGlobe;

Bewertungen & Kommentare

—
Noch keine Bewertungen — gib die erste ab.
5
0
4
0
3
0
2
0
1
0

Melde dich an, um zu bewerten und zu kommentieren.

0 Kommentare

Noch keine Kommentare. Erzähl, wie du dieses Modell genutzt hast oder was besser sein könnte.

Ähnliche Modelle

Gleiche Kategorie oder ähnliche Tags