Post Your Generations!

by•

Have any favorite generations? Share images (or even the raw JS code if you like) with others below!

To start, here's the first generation I prompted with GPT-6 that made me realize that model really gave this repo legs:

Code:

function createAsset(THREE, seed, textures, params, addons) {
  params = params || {};
  const group = new THREE.Group();
  group.name = "Mid-century modern butterfly-roof house";
  let state = (Number(seed) || 1) >>> 0;
  const random = () => {
    state = (1664525 * state + 1013904223) >>> 0;
    return state / 4294967296;
  };
  const geometries = new Set();
  const materials = new Set();
  const batches = new Map();
  const geo = g => { geometries.add(g); return g; };
  function material(color, roughness = 0.75, metalness = 0) {
    const m = new THREE.MeshStandardMaterial({ color, roughness, metalness });
    materials.add(m);
    return m;
  }
  const plaster = material(0xeee8d6);
  const concrete = material(0xb4b3a5);
  const paving = material(0xe2dccb);
  const roofMat = material(0x354746, 0.65, 0.18);
  const cedar = material(0xa65c30);
  const cedarLight = material(0xc88948);
  const cedarDark = material(0x77452d);
  const trim = material(0x293d3c, 0.48, 0.25);
  const brass = material(0xcda358, 0.3, 0.7);
  const soil = material(0x473c30);
  const green = material(0x597d4b);
  const lawn = material(0x718363);
  const upholstery = material(0xdb813e);
  const glass = material(0x719d9e, 0.18, 0.3);
  glass.transparent = true;
  glass.opacity = 0.68;
  glass.depthWrite = false;
  glass.side = THREE.DoubleSide;
  const stoneMats = [0xc6b693, 0xd6c5a1, 0xbba886, 0xdfcbaa].map(c => material(c));

  const boxGeometry = geo(new THREE.BoxGeometry(1, 1, 1));
  const dummy = new THREE.Object3D();
  function box(w, h, d, x, y, z, mat, rz = 0, ry = 0) {
    if (!batches.has(mat)) batches.set(mat, []);
    batches.get(mat).push({ w, h, d, x, y, z, rz, ry });
  }
  function mesh(g, m, x, y, z) {
    const object = new THREE.Mesh(g, m);
    object.position.set(x, y, z);
    object.castShadow = true;
    object.receiveShadow = true;
    group.add(object);
    return object;
  }
  function beam(a, b, thickness, depth, mat) {
    const dx = b[0] - a[0], dy = b[1] - a[1];
    box(Math.hypot(dx, dy), thickness, depth,
      (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, a[2],
      mat, Math.atan2(dy, dx));
  }

  // A restrained, integrated architectural presentation base.
  box(13.5, 0.16, 10, 0, 0.08, 0, concrete);
  box(13.28, 0.035, 9.78, 0, 0.1775, 0, lawn);
  box(10.65, 0.24, 6.65, 0, 0.30, -0.5, concrete);
  box(10.45, 0.06, 6.45, 0, 0.45, -0.5, paving);
  box(10.6, 0.20, 1.28, 0, 0.30, 3.35, paving);
  box(2.5, 0.105, 0.55, 0.55, 0.2475, 4.23, concrete);
  for (let i = 0; i < 3; i++) {
    box(1.58, 0.025, 0.43, 0.55, 0.205, 4.48 + i * 0.16, paving);
  }

  // Solid rear wall and perimeter wall segments, assembled around openings.
  box(10, 2.72, 0.20, 0, 1.84, -3.5, plaster);
  box(0.20, 2.72, 1.0, -4.9, 1.84, -3.0, plaster);
  box(0.20, 2.72, 1.0, 4.9, 1.84, -3.0, plaster);
  box(0.20, 0.5, 5, -4.9, 0.73, 0, plaster);
  box(0.20, 0.5, 5, 4.9, 0.73, 0, plaster);
  box(0.20, 0.30, 5, -4.9, 3.01, 0, plaster);
  box(0.20, 0.30, 5, 4.9, 3.01, 0, plaster);
  box(0.20, 2.20, 0.20, -4.9, 1.9, 2.5, plaster);
  box(0.20, 2.20, 0.20, 4.9, 1.9, 2.5, plaster);

  function frontWindow(x, width, bottom, top, z, divisions) {
    box(width, top - bottom, 0.035, x, (top + bottom) / 2, z, glass);
    box(width + 0.08, 0.065, 0.095, x, bottom, z + 0.035, trim);
    box(width + 0.08, 0.065, 0.095, x, top, z + 0.035, trim);
    for (let i = 0; i <= divisions; i++) {
      box(0.055, top - bottom, 0.095,
        x - width / 2 + width * i / divisions, (top + bottom) / 2, z + 0.035, trim);
    }
  }
  box(4.7, 0.19, 0.20, -2.45, 0.575, 2.5, plaster);
  box(3.45, 0.19, 0.20, 3.075, 0.575, 2.5, plaster);
  frontWindow(-2.45, 4.60, 0.68, 2.9, 2.50, 4);
  frontWindow(2.77, 2.70, 0.68, 2.9, 2.50, 3);
  // Entry is a warm, vertically boarded pivot door with a sidelight.
  box(1.18, 2.39, 0.13, 0.54, 1.675, 2.51, cedarDark);
  for (let i = 0; i < 9; i++) {
    box(0.12, 2.30, 0.045, 0.02 + i * 0.13, 1.675, 2.596,
      i % 3 ? cedar : cedarLight);
  }
  box(0.035, 0.53, 0.045, 0.95, 1.65, 2.66, brass);
  frontWindow(1.255, 0.20, 0.51, 2.90, 2.5, 1);
  box(0.73, 2.46, 0.18, 4.51, 1.71, 2.49, cedarDark);
  for (let i = 0; i < 6; i++) {
    box(0.085, 2.40, 0.045, 4.24 + i * 0.108, 1.73, 2.605, cedar);
  }
  for (const side of [-1, 1]) {
    box(0.032, 1.85, 4.82, side * 4.91, 1.925, 0, glass);
    for (let i = 0; i <= 4; i++) {
      box(0.095, 1.92, 0.055, side * 4.94, 1.93, -2.4 + i * 1.2, trim);
    }
    for (const y of [0.99, 2.87]) {
      box(0.095, 0.06, 4.87, side * 4.94, y, 0, trim);
    }
  }

  // Two shallow roof planes drain toward an off-center butterfly valley.
  const valleyX = 0.7;
  const roofY = x => x <= valleyX
    ? 3.20 + (valleyX - x) * 0.115
    : 3.20 + (x - valleyX) * 0.18;
  function wallBand(x1, x2, z) {
    const shape = new THREE.Shape();
    shape.moveTo(x1, 2.92);
    shape.lineTo(x2, 2.92);
    shape.lineTo(x2, roofY(x2) - 0.08);
    shape.lineTo(x1, roofY(x1) - 0.08);
    shape.closePath();
    mesh(geo(new THREE.ExtrudeGeometry(shape, {
      depth: 0.18, bevelEnabled: false, steps: 1
    })), plaster, 0, 0, z);
  }
  for (const z of [2.41, -3.59]) {
    wallBand(-5, valleyX, z);
    wallBand(valleyX, 5, z);
  }
  for (const x of [-4.9, 4.9]) {
    const h = roofY(x) - 3.04;
    box(0.2, h, 6, x, 3.04 + h / 2, -0.5, plaster);
  }
  for (const ends of [[-5.7, valleyX], [valleyX, 5.7]]) {
    const a = ends[0], b = ends[1];
    beam([a, roofY(a), -0.5], [b, roofY(b), -0.5], 0.16, 7.65, roofMat);
    beam([a, roofY(a) - 0.105, -0.5], [b, roofY(b) - 0.105, -0.5],
      0.045, 7.58, cedarLight);
    for (const z of [-4.34, 3.34]) {
      beam([a, roofY(a), z], [b, roofY(b), z], 0.19, 0.085, plaster);
    }
  }
  for (const x of [-5.68, 5.68]) {
    box(0.085, 0.18, 7.72, x, roofY(x), -0.5, plaster);
  }
  box(0.17, 0.045, 7.62, valleyX, 3.29, -0.5, trim);
  box(0.085, 2.9, 0.085, valleyX, 1.83, -3.7, trim);

  // Slender porch posts and a signature open cedar privacy screen.
  for (const x of [-4.90, 4.9]) {
    const top = roofY(x) - 0.12;
    box(0.075, top - 0.4, 0.075, x, (top + 0.4) / 2, 3.12, trim);
  }
  for (let i = 0; i < 13; i++) {
    const z = 1.18 + i * 0.158;
    box(0.095, 2.55, 0.065, 5.16, 1.675, z, i % 4 ? cedar : cedarLight);
  }
  box(0.13, 0.09, 2.04, 5.16, 2.95, 2.12, cedarDark);
  box(0.13, 0.09, 2.04, 5.16, 0.43, 2.12, cedarDark);

  // Tall sandstone chimney, with individually coursed, staggered blocks.
  box(1.25, 4.55, 1.0, -3.5, 2.755, -1.85, stoneMats[0]);
  for (let row = 0; row < 24; row++) {
    const y = 0.58 + row * 0.184;
    const widths = row % 2 ? [0.30, 0.62, 0.30] : [0.61, 0.61];
    for (const z of [-2.365, -1.335]) {
      let left = -4.125;
      for (const w of widths) {
        box(w - 0.018, 0.168, 0.045, left + w / 2, y, z,
          stoneMats[Math.floor(random() * stoneMats.length)]);
        left += w;
      }
    }
    for (const x of [-4.14, -2.86]) {
      for (let j = 0; j < 2; j++) {
        box(0.045, 0.168, 0.48, x, y, -2.10 + j * 0.5,
          stoneMats[Math.floor(random() * stoneMats.length)]);
      }
    }
  }
  box(1.40, 0.12, 1.14, -3.5, 5.08, -1.85, concrete);
  box(0.82, 0.035, 0.55, -3.5, 5.155, -1.85, trim);

  // Visible interior furniture adds depth behind the glass.
  box(3.1, 0.22, 1.10, -2.65, 0.76, 0.40, cedarDark);
  box(3.05, 0.32, 0.90, -2.65, 0.99, 0.47, upholstery);
  box(3.05, 0.76, 0.22, -2.65, 1.19, -0.04, upholstery);
  for (const x of [-4.1, -1.2]) {
    box(0.19, 0.49, 1.0, x, 1.07, 0.40, upholstery);
    box(0.075, 0.24, 0.075, x, 0.60, 0.74, cedarDark);
  }
  box(1.65, 0.075, 0.70, -2.65, 0.97, 1.68, cedarLight);
  for (const x of [-3.28, -2.02]) {
    for (const z of [1.46, 1.90]) {
      box(0.045, 0.45, 0.045, x, 0.725, z, trim);
    }
  }
  box(2.7, 1.6, 0.12, 2.4, 1.28, -1.65, cedar);
  for (let i = 0; i < 12; i++) {
    box(0.045, 1.58, 0.035, 1.17 + i * 0.22, 1.28, -1.565, cedarLight);
  }

  // Integrated low planter, compact sculptural planting.
  box(3.6, 0.43, 0.86, -3.35, 0.41, 3.65, plaster);
  box(3.35, 0.035, 0.63, -3.35, 0.637, 3.65, soil);
  const leafGeometry = geo(new THREE.SphereGeometry(1, 8, 5));
  const shrubs = new THREE.InstancedMesh(leafGeometry, green, 12);
  for (let i = 0; i < 12; i++) {
    const plant = Math.floor(i / 3), angle = i * 2.4;
    const r = 0.25 + random() * 0.045;
    dummy.position.set(-4.54 + plant * 0.79 + Math.cos(angle) * 0.12,
      0.73 + r * 0.45, 3.65 + Math.sin(angle) * 0.13);
    dummy.rotation.set(0, angle, 0);
    dummy.scale.set(r * 1.35, r, r);
    dummy.updateMatrix();
    shrubs.setMatrixAt(i, dummy.matrix);
  }
  shrubs.castShadow = true;
  shrubs.receiveShadow = true;
  group.add(shrubs);

  // Entry lamp and minimal brass address marks.
  box(0.19, 0.34, 0.08, 1.48, 2.30, 2.64, trim);
  const lampMat = material(0xffe8b2);
  lampMat.emissive.set(0xffc675);
  lampMat.emissiveIntensity = 0.45;
  box(0.13, 0.24, 0.085, 1.48, 2.30, 2.69, lampMat);
  for (let i = 0; i < 3; i++) {
    box(0.035, 0.14, 0.027, 4.35 + i * 0.13, 2.14, 2.65, brass);
  }

  // Batch repeated architectural parts into material-based instanced meshes.
  for (const [mat, entries] of batches) {
    const instances = new THREE.InstancedMesh(boxGeometry, mat, entries.length);
    entries.forEach((b, i) => {
      dummy.position.set(b.x, b.y, b.z);
      dummy.rotation.set(0, b.ry, b.rz);
      dummy.scale.set(b.w, b.h, b.d);
      dummy.updateMatrix();
      instances.setMatrixAt(i, dummy.matrix);
    });
    instances.instanceMatrix.needsUpdate = true;
    instances.castShadow = mat !== glass;
    instances.receiveShadow = true;
    group.add(instances);
  }
  const scale = Number(params.scale);
  if (Number.isFinite(scale) && scale > 0) group.scale.setScalar(scale);

  return {
    root: group,
    dispose: () => {
      group.traverse(object => {
        if (object.isInstancedMesh) object.dispose();
      });
      geometries.forEach(g => g.dispose());
      materials.forEach(m => m.dispose());
    }
  };
}
2 views

Add a comment

Replies

Be the first to comment