Spaces:
Running
Running
File size: 16,270 Bytes
02e1231 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | // Scenery & props, sculpted from the same SDF clay. Every call jitters proportions and colours.
(function (root) {
"use strict";
const { V, RNG, rotX, rotY, rotZ, Sculpt, mesh, paint, col, jitterColor, hashStr } = root.RigSculpt;
const cap = (a, b, r1, r2, mat, x) => Object.assign({ t: "cap", a, b, r1, r2, mat }, x || {});
const ell = (c, r, mat, x) => Object.assign({ t: "ell", c, r, mat }, x || {});
const cyl = (a, b, r1, r2, mat, x) => Object.assign({ t: "cone", a, b, r1, r2, mat }, x || {});
const box = (c, h, mat, x) => Object.assign({ t: "box", c, h, mat, rr: 0.01 }, x || {});
const O = {};
O.pine_tree = (r, s) => { const H = r.u(3, 7) * s, P = [cap([0, 0, 0], [0, H * 0.35, 0], H * 0.05, H * 0.035, "trunk")]; const n = 3 + r.i(2); for (let i = 0; i < n; i++) { const y = H * (0.25 + 0.6 * i / n), w = H * (0.33 - 0.22 * i / n); P.push(cyl([0, y, 0], [0, y + H * 0.35, 0], w, H * 0.01, "leaf")); } return { P, mats: { trunk: "#6b4a2f", leaf: r.pick(["#2f5d3a", "#3a6b3f", "#2a5236"]) }, k: H * 0.02 }; };
O.oak_tree = (r, s) => { const H = r.u(3, 6) * s, P = [cap([0, 0, 0], [0, H * 0.5, 0], H * 0.07, H * 0.05, "trunk")]; for (let i = 0; i < 5; i++) { const a = r() * 6.28, d = H * r.u(0, 0.18); P.push(ell([Math.cos(a) * d, H * r.u(0.55, 0.8), Math.sin(a) * d], [H * r.u(0.2, 0.3), H * r.u(0.17, 0.25), H * r.u(0.2, 0.3)], "leaf")); } return { P, mats: { trunk: "#6b4a2f", leaf: r.pick(["#4f8a3a", "#5d9a43", "#6a9e3a", "#d98a2b", "#c9562a"]) }, k: H * 0.06 }; };
O.birch_tree = (r, s) => { const H = r.u(4, 7) * s, P = [cap([0, 0, 0], [0, H * 0.75, 0], H * 0.03, H * 0.02, "trunk")]; for (let i = 0; i < 4; i++) P.push(ell([r.u(-0.1, 0.1) * H, H * r.u(0.6, 0.9), r.u(-0.1, 0.1) * H], [H * 0.13, H * 0.18, H * 0.13], "leaf")); return { P, mats: { trunk: "#ece8de", leaf: "#8fbf4a" }, k: H * 0.04 }; };
O.palm_tree = (r, s) => { const H = r.u(4, 7) * s, lean = r.u(0.05, 0.25) * H, top = [lean, H, 0]; const P = [cap([0, 0, 0], [lean * 0.4, H * 0.5, 0], H * 0.05, H * 0.04, "trunk"), cap([lean * 0.4, H * 0.5, 0], top, H * 0.04, H * 0.03, "trunk")]; for (let i = 0; i < 7; i++) { const a = i / 7 * 6.28; const e = V.add(top, [Math.cos(a) * H * 0.35, -H * 0.12, Math.sin(a) * H * 0.35]); P.push(cap(top, V.lerp(top, e, 0.6), H * 0.02, H * 0.05, "leaf")); P.push(cap(V.lerp(top, e, 0.6), e, H * 0.05, H * 0.008, "leaf")); } P.push(ell(V.add(top, [0, -H * 0.04, 0]), [H * 0.05, H * 0.05, H * 0.05], "nut")); return { P, mats: { trunk: "#9a7a52", leaf: "#3f8a3a", nut: "#5a3f22" }, k: H * 0.01 }; };
O.dead_tree = (r, s) => { const H = r.u(2.5, 5) * s, P = [cap([0, 0, 0], [0, H * 0.6, 0], H * 0.06, H * 0.035, "trunk")]; for (let i = 0; i < 4; i++) { const a = r() * 6.28, y = H * r.u(0.35, 0.6); P.push(cap([0, y, 0], [Math.cos(a) * H * 0.3, y + H * 0.3, Math.sin(a) * H * 0.3], H * 0.025, H * 0.008, "trunk")); } return { P, mats: { trunk: "#5a4a3c" }, k: H * 0.02 }; };
O.bush = (r, s) => { const R = r.u(0.4, 0.9) * s, P = []; for (let i = 0; i < 5; i++) P.push(ell([r.u(-0.5, 0.5) * R, R * r.u(0.4, 0.7), r.u(-0.5, 0.5) * R], [R * 0.55, R * 0.45, R * 0.55], "leaf")); if (r() < 0.4) for (let i = 0; i < 5; i++) P.push(ell([r.u(-0.7, 0.7) * R, R * r.u(0.6, 1.0), r.u(-0.7, 0.7) * R], [R * 0.1, R * 0.1, R * 0.1], "berry")); return { P, mats: { leaf: r.pick(["#4f8a3a", "#3f7a35", "#6a9a45"]), berry: r.pick(["#d8332b", "#f2d64a", "#8a4ad8"]) }, k: R * 0.2 }; };
O.rock = (r, s) => { const R = r.u(0.25, 0.7) * s, P = []; for (let i = 0; i < 4; i++) P.push(ell([r.u(-0.4, 0.4) * R, R * r.u(0.15, 0.4), r.u(-0.4, 0.4) * R], [R * r.u(0.4, 0.7), R * r.u(0.3, 0.5), R * r.u(0.4, 0.7)], "stone")); return { P, mats: { stone: r.pick(["#8a8780", "#7a7670", "#9a948a", "#6f6a66"]) }, k: R * 0.12 }; };
O.boulder = (r, s) => { const R = r.u(1.0, 2.2) * s, P = []; for (let i = 0; i < 5; i++) P.push(ell([r.u(-0.4, 0.4) * R, R * r.u(0.2, 0.5), r.u(-0.4, 0.4) * R], [R * r.u(0.4, 0.7), R * r.u(0.35, 0.6), R * r.u(0.4, 0.7)], "stone")); return { P, mats: { stone: r.pick(["#8a8780", "#7a7670", "#9a948a"]) }, k: R * 0.12 }; };
O.flower = (r, s) => { const H = r.u(0.25, 0.6) * s, P = [cap([0, 0, 0], [0, H, 0], H * 0.035, H * 0.03, "stem")], n = 5 + r.i(3); for (let i = 0; i < n; i++) { const a = i / n * 6.28; P.push(ell([Math.cos(a) * H * 0.12, H, Math.sin(a) * H * 0.12], [H * 0.09, H * 0.03, H * 0.09], "petal")); } P.push(ell([0, H + H * 0.02, 0], [H * 0.07, H * 0.05, H * 0.07], "center")); P.push(ell([H * 0.08, H * 0.4, 0], [H * 0.09, H * 0.02, H * 0.04], "stem")); return { P, mats: { stem: "#4f8a3a", petal: r.pick(["#f25a8a", "#f2d64a", "#ffffff", "#8a5ad8", "#f2742a", "#e8332b"]), center: "#f2b62a" }, k: H * 0.02 }; };
O.mushroom = (r, s) => { const H = r.u(0.15, 0.5) * s, P = [cap([0, 0, 0], [0, H, 0], H * 0.16, H * 0.12, "stem"), ell([0, H, 0], [H * 0.45, H * 0.3, H * 0.45], "cap")]; return { P, mats: { stem: "#efe6d2", cap: r.pick(["#d8332b", "#a8703f", "#d8a24a"]), accent: "#ffffff" }, k: H * 0.05, pattern: { type: "spots", scale: H * 0.25 }, patMats: ["cap"] }; };
O.cactus = (r, s) => { const H = r.u(1.0, 3.0) * s, R = H * 0.1, P = [cap([0, 0, 0], [0, H, 0], R, R * 0.9, "green")]; for (const sd of [1, -1]) if (r() < 0.8) { const y = H * r.u(0.3, 0.55), x = sd * R * 2.5; P.push(cap([0, y, 0], [x, y, 0], R * 0.6, R * 0.6, "green")); P.push(cap([x, y, 0], [x, y + H * r.u(0.2, 0.35), 0], R * 0.6, R * 0.55, "green")); } return { P, mats: { green: "#4f8a4a", accent: "#7ab05a" }, k: R * 0.4, pattern: { type: "stripes", scale: R * 0.6 }, patMats: ["green"] }; };
O.log = (r, s) => { const L = r.u(1, 2.5) * s, R = r.u(0.12, 0.25) * s; return { P: [cap([-L / 2, R, 0], [L / 2, R, 0], R, R * 0.95, "bark"), ell([L / 2 + R * 0.6, R, 0], [R * 0.1, R * 0.9, R * 0.9], "wood")], mats: { bark: "#6b4a2f", wood: "#d8b47a" }, k: R * 0.1 }; };
O.stump = (r, s) => { const R = r.u(0.25, 0.5) * s; return { P: [cyl([0, 0, 0], [0, R * 1.0, 0], R * 1.2, R, "bark"), ell([0, R * 1.02, 0], [R * 0.92, R * 0.05, R * 0.92], "wood")], mats: { bark: "#6b4a2f", wood: "#d8b47a" }, k: R * 0.1 }; };
O.house = (r, s) => { const W = r.u(2.5, 4.5) * s, D = W * r.u(0.7, 1.0), H = W * r.u(0.55, 0.75), rh = W * r.u(0.35, 0.5); const P = [box([0, H / 2, 0], [W / 2, H / 2, D / 2], "wall", { hard: 1 }), box([0, H + rh * 0.05, 0], [W * 0.38, W * 0.38, D / 2 + 0.15], "roof", { R: rotZ(Math.PI / 4), hard: 1 }), box([0, H * 0.28, D / 2], [W * 0.1, H * 0.28, 0.06], "door", { hard: 1 })]; for (const sd of [1, -1]) P.push(box([sd * W * 0.28, H * 0.55, D / 2], [W * 0.1, W * 0.1, 0.05], "window", { hard: 1 })); P.push(box([W * 0.25, H + rh * 0.6, -D * 0.1], [W * 0.07, rh * 0.5, W * 0.07], "chimney", { hard: 1 })); return { P, mats: { wall: r.pick(["#efe3c8", "#d8c4a0", "#c9d6e2", "#f2d0b4", "#e8e0d0"]), roof: r.pick(["#b04a3a", "#6a4a3a", "#3a4a6a", "#5a6a3a"]), door: "#6b4a2f", window: "#8ac0e0", chimney: "#8a5a4a" }, k: 0.05, cutRoof: true }; };
O.hut = (r, s) => { const R = r.u(1.2, 2) * s, H = R * 1.1; return { P: [cyl([0, 0, 0], [0, H, 0], R, R, "wall", { hard: 1 }), cyl([0, H, 0], [0, H + R * 1.2, 0], R * 1.25, 0.02, "roof", { hard: 1 }), box([0, H * 0.4, R * 0.95], [R * 0.25, H * 0.4, 0.1], "door", { hard: 1 })], mats: { wall: "#c9a870", roof: "#9a7a3a", door: "#4a3420" }, k: 0.05 }; };
O.tower = (r, s) => { const R = r.u(1, 1.8) * s, H = R * r.u(4, 6), P = [cyl([0, 0, 0], [0, H, 0], R, R * 0.9, "stone", { hard: 1 }), cyl([0, H, 0], [0, H + R * 1.8, 0], R * 1.2, 0.03, "roof", { hard: 1 })]; for (let i = 0; i < 3; i++) P.push(box([0, H * (0.3 + 0.25 * i), R * 0.9], [R * 0.15, R * 0.25, 0.1], "window", { hard: 1 })); return { P, mats: { stone: "#a8a49a", roof: r.pick(["#3a4a8a", "#8a3a3a", "#3a6a4a"]), window: "#2a2a30" }, k: 0.05 }; };
O.castle_wall = (r, s) => { const L = r.u(6, 10) * s, H = r.u(2.5, 4) * s, T = 0.8 * s, P = [box([0, H / 2, 0], [L / 2, H / 2, T / 2], "stone", { hard: 1 })]; for (let x = -L / 2 + 0.4; x < L / 2; x += 1.2 * s) P.push(box([x, H + 0.3 * s, 0], [0.3 * s, 0.3 * s, T / 2], "stone", { hard: 1 })); return { P, mats: { stone: "#a8a49a" }, k: 0.05 }; };
O.fence = (r, s) => { const L = r.u(3, 6) * s, P = []; for (let x = -L / 2; x <= L / 2 + 1e-6; x += 0.8 * s) P.push(box([x, 0.5 * s, 0], [0.06 * s, 0.5 * s, 0.06 * s], "wood", { hard: 1 })); P.push(box([0, 0.75 * s, 0], [L / 2, 0.05 * s, 0.04 * s], "wood", { hard: 1 })); P.push(box([0, 0.4 * s, 0], [L / 2, 0.05 * s, 0.04 * s], "wood", { hard: 1 })); return { P, mats: { wood: r.pick(["#a8845a", "#f2efe8", "#7a5a3a"]) }, k: 0.02 }; };
O.lamp_post = (r, s) => { const H = r.u(2.5, 3.5) * s; return { P: [cap([0, 0, 0], [0, H, 0], 0.06 * s, 0.045 * s, "metal"), ell([0, H + 0.15 * s, 0], [0.18 * s, 0.22 * s, 0.18 * s], "glass", { hard: 1 }), cyl([0, 0, 0], [0, 0.15, 0], 0.15 * s, 0.1 * s, "metal")], mats: { metal: "#2a2e34", glass: "#f8e7a0" }, k: 0.03, light: [0, H + 0.15 * s, 0] }; };
O.bench = (r, s) => { const L = r.u(1.3, 2) * s, P = [box([0, 0.45 * s, 0], [L / 2, 0.04 * s, 0.22 * s], "wood", { hard: 1 }), box([0, 0.75 * s, -0.22 * s], [L / 2, 0.15 * s, 0.03 * s], "wood", { hard: 1 })]; for (const x of [-L * 0.4, L * 0.4]) P.push(box([x, 0.22 * s, 0], [0.04 * s, 0.22 * s, 0.2 * s], "metal", { hard: 1 })); return { P, mats: { wood: "#a8743f", metal: "#2a2e34" }, k: 0.02 }; };
O.table = (r, s) => { const W = r.u(0.9, 1.6) * s, P = [box([0, 0.75 * s, 0], [W / 2, 0.04 * s, W * 0.32], "wood", { hard: 1 })]; for (const x of [-1, 1]) for (const z of [-1, 1]) P.push(box([x * W * 0.42, 0.37 * s, z * W * 0.26], [0.04 * s, 0.37 * s, 0.04 * s], "wood", { hard: 1 })); return { P, mats: { wood: r.pick(["#a8743f", "#8a5a3a", "#d8b47a"]) }, k: 0.02 }; };
O.chair = (r, s) => { const P = [box([0, 0.45 * s, 0], [0.22 * s, 0.03 * s, 0.22 * s], "wood", { hard: 1 }), box([0, 0.75 * s, -0.2 * s], [0.22 * s, 0.28 * s, 0.03 * s], "wood", { hard: 1 })]; for (const x of [-1, 1]) for (const z of [-1, 1]) P.push(box([x * 0.18 * s, 0.22 * s, z * 0.18 * s], [0.03 * s, 0.22 * s, 0.03 * s], "wood", { hard: 1 })); return { P, mats: { wood: r.pick(["#a8743f", "#8a5a3a", "#d8b47a", "#c9563a"]) }, k: 0.02 }; };
O.barrel = (r, s) => { const H = r.u(0.8, 1.1) * s; return { P: [cyl([0, 0, 0], [0, H / 2, 0], H * 0.3, H * 0.36, "wood"), cyl([0, H / 2, 0], [0, H, 0], H * 0.36, H * 0.3, "wood"), cyl([0, H * 0.22, 0], [0, H * 0.26, 0], H * 0.345, H * 0.35, "metal", { hard: 1 }), cyl([0, H * 0.74, 0], [0, H * 0.78, 0], H * 0.35, H * 0.345, "metal", { hard: 1 })], mats: { wood: "#9a6a3a", metal: "#4a4a50" }, k: 0.05 }; };
O.crate = (r, s) => { const a = r.u(0.5, 0.9) * s; return { P: [box([0, a / 2, 0], [a / 2, a / 2, a / 2], "wood", { rr: 0.03 }), box([0, a / 2, 0], [a * 0.52, a * 0.08, a * 0.52], "dark", { hard: 1 })], mats: { wood: "#c8964f", dark: "#8a5f2f" }, k: 0.02 }; };
O.tent = (r, s) => { const W = r.u(2, 3) * s; return { P: [box([0, 0, 0], [W * 0.5, W * 0.5, W * 0.6], "cloth", { R: rotZ(Math.PI / 4), hard: 1 }), box([0, W * 0.2, W * 0.6], [W * 0.12, W * 0.2, 0.04], "dark", { hard: 1 })], mats: { cloth: r.pick(["#e8823a", "#3a8ad8", "#4a9a5a", "#d84a4a"]), dark: "#2a2a30" }, k: 0.03 }; };
O.campfire = (r, s) => { const P = []; for (let i = 0; i < 8; i++) { const a = i / 8 * 6.28; P.push(ell([Math.cos(a) * 0.45 * s, 0.08 * s, Math.sin(a) * 0.45 * s], [0.13 * s, 0.1 * s, 0.13 * s], "stone")); } for (let i = 0; i < 4; i++) { const a = i / 4 * 3.14; P.push(cap([Math.cos(a) * 0.35 * s, 0.05, Math.sin(a) * 0.35 * s], [-Math.cos(a) * 0.35 * s, 0.15 * s, -Math.sin(a) * 0.35 * s], 0.05 * s, 0.05 * s, "wood")); } P.push(cyl([0, 0.05 * s, 0], [0, 0.75 * s, 0], 0.25 * s, 0.01 * s, "fire")); P.push(cyl([0.1 * s, 0.05 * s, 0.05 * s], [0.14 * s, 0.5 * s, 0.08 * s], 0.14 * s, 0.01 * s, "fire2")); return { P, mats: { stone: "#7a7670", wood: "#5a3f22", fire: "#ff9a2a", fire2: "#ffd84a" }, k: 0.03, light: [0, 0.4 * s, 0], emissive: ["fire", "fire2"] }; };
O.well = (r, s) => { const R = 0.7 * s; return { P: [cyl([0, 0, 0], [0, 0.8 * s, 0], R, R, "stone", { hard: 1 }), cyl([0, 0.78 * s, 0], [0, 0.82 * s, 0], R * 0.8, R * 0.8, "water", { hard: 1 }), box([-R * 0.9, 1.3 * s, 0], [0.05 * s, 0.55 * s, 0.05 * s], "wood", { hard: 1 }), box([R * 0.9, 1.3 * s, 0], [0.05 * s, 0.55 * s, 0.05 * s], "wood", { hard: 1 }), box([0, 1.95 * s, 0], [R * 1.1, R * 0.55, R * 0.7], "roof", { R: rotX(0), hard: 1 })], mats: { stone: "#9a948a", water: "#3a6a9a", wood: "#6b4a2f", roof: "#8a3a2a" }, k: 0.04 }; };
O.snowman = (r, s) => { const P = [ell([0, 0.4 * s, 0], [0.45 * s, 0.42 * s, 0.45 * s], "snow"), ell([0, 1.0 * s, 0], [0.32 * s, 0.3 * s, 0.32 * s], "snow"), ell([0, 1.45 * s, 0], [0.22 * s, 0.22 * s, 0.22 * s], "snow"), cap([0, 1.45 * s, 0.18 * s], [0, 1.43 * s, 0.42 * s], 0.04 * s, 0.01 * s, "carrot", { hard: 1 }), cyl([0, 1.6 * s, 0], [0, 1.9 * s, 0], 0.15 * s, 0.15 * s, "hat", { hard: 1 }), cyl([0, 1.6 * s, 0], [0, 1.64 * s, 0], 0.26 * s, 0.26 * s, "hat", { hard: 1 })]; return { P, mats: { snow: "#f6f8fa", carrot: "#f28a24", hat: "#1d1d22" }, k: 0.05, eyes: [{ c: [0.08 * s, 1.52 * s, 0.19 * s], r: 0.025 * s }, { c: [-0.08 * s, 1.52 * s, 0.19 * s], r: 0.025 * s }] }; };
O.car = (r, s) => { const L = r.u(3.6, 4.4) * s, P = [box([0, 0.55 * s, 0], [0.85 * s, 0.3 * s, L / 2], "paint", { rr: 0.12 * s }), box([0, 1.0 * s, -0.2 * s], [0.75 * s, 0.25 * s, L * 0.27], "glass", { rr: 0.1 * s })]; for (const x of [-0.85, 0.85]) for (const z of [-L * 0.32, L * 0.32]) P.push(cyl([x * s - 0.12 * Math.sign(x) * s, 0.33 * s, z], [x * s + 0.1 * Math.sign(x) * s, 0.33 * s, z], 0.33 * s, 0.33 * s, "tire", { hard: 1 })); return { P, mats: { paint: r.pick(["#d8332b", "#2a6fd1", "#f2d64a", "#2fa65a", "#f2f2f2", "#2a2a30"]), glass: "#9ac8e8", tire: "#1d1d22" }, k: 0.05 }; };
O.boat = (r, s) => { const L = r.u(3, 5) * s; return { P: [ell([0, 0.3 * s, 0], [0.8 * s, 0.45 * s, L / 2], "hull"), box([0, 0.75 * s, 0], [0.75 * s, 0.05 * s, L * 0.46], "deck", { hard: 1 }), cap([0, 0.75 * s, 0], [0, 4 * s, 0], 0.06 * s, 0.05 * s, "wood"), box([0.02, 2.4 * s, -0.6 * s], [0.05 * s, 1.4 * s, 0.9 * s], "sail", { hard: 1 })], mats: { hull: r.pick(["#8a5a3a", "#f2f2f2", "#2a4a8a"]), deck: "#c8a06a", wood: "#6b4a2f", sail: "#f6f2e8" }, k: 0.05 }; };
O.signpost = (r, s) => ({ P: [cyl([0, 0, 0], [0, 1.8 * s, 0], 0.05 * s, 0.05 * s, "wood"), box([0.25 * s, 1.55 * s, 0], [0.45 * s, 0.13 * s, 0.03 * s], "board", { hard: 1 })], mats: { wood: "#6b4a2f", board: "#c8a06a" }, k: 0.02 });
O.fountain = (r, s) => ({ P: [cyl([0, 0, 0], [0, 0.5 * s, 0], 1.6 * s, 1.6 * s, "stone", { hard: 1 }), cyl([0, 0.48 * s, 0], [0, 0.52 * s, 0], 1.45 * s, 1.45 * s, "water", { hard: 1 }), cyl([0, 0.5 * s, 0], [0, 1.5 * s, 0], 0.18 * s, 0.14 * s, "stone"), ell([0, 1.5 * s, 0], [0.6 * s, 0.12 * s, 0.6 * s], "stone"), ell([0, 1.62 * s, 0], [0.5 * s, 0.05 * s, 0.5 * s], "water", { hard: 1 })], mats: { stone: "#c9c4b8", water: "#5a9ad8" }, k: 0.05 });
O.pond = (r, s) => { const R = r.u(2, 4) * s; return { P: [ell([0, 0.0, 0], [R, 0.06, R * r.u(0.6, 1)], "water", { hard: 1 })], mats: { water: "#4a8ac8" }, k: 0.02 }; };
O.statue = (r, s) => ({ P: [box([0, 0.5 * s, 0], [0.6 * s, 0.5 * s, 0.6 * s], "stone", { hard: 1 }), cap([0, 1.0 * s, 0], [0, 2.2 * s, 0], 0.3 * s, 0.22 * s, "bronze"), ell([0, 2.45 * s, 0], [0.22 * s, 0.25 * s, 0.22 * s], "bronze"), cap([0.25 * s, 2.0 * s, 0], [0.5 * s, 2.7 * s, 0.1 * s], 0.08 * s, 0.06 * s, "bronze")], mats: { stone: "#c9c4b8", bronze: "#6a8a6a" }, k: 0.06 });
function makeObject(desc, res) {
const seed = desc.seed !== undefined ? desc.seed : hashStr(JSON.stringify(desc));
const rng = RNG(seed);
const B = O[desc.type](rng, desc.size || 1);
const mats = {};
for (const k in B.mats) mats[k] = jitterColor(col((desc.colors && desc.colors[k]) || (desc.color && k === Object.keys(B.mats)[0] ? desc.color : B.mats[k])), rng, 0.8);
mats.accent = mats.accent || col("#ffffff");
if (B.patMats) B.P.forEach(p => { if (B.patMats.includes(p.mat)) p.pat = 1; });
const sc = new Sculpt(B.P, B.k);
const M = mesh(sc, res || 40);
const colors = paint(sc, M, mats, B.eyes || [], B.pattern, seed);
return { kind: "object", type: desc.type, verts: M.verts, faces: M.faces, normals: M.normals, colors, light: B.light, emissive: !!B.emissive, height: Math.max(...M.verts.map(v => v[1])) };
}
root.RigObjects = { OBJECTS: O, list: () => Object.keys(O), makeObject };
})(typeof globalThis !== "undefined" ? globalThis : this);
|