tiny-scene-three / web /js /scene /things.js
paralaif's picture
Tiny Scene: text to animated three.js scenes with a 4.85M Transformer
dd53693 verified
Raw History Blame Contribute Delete
17.5 kB
// Vehicles and props. Forward is +Z, up is +Y, resting on y = 0.
import * as THREE from 'three';
import { at, ball, box, cone, cyl, joint, orb, rig, rockGeo, tint, torus } from './prims.js';
const DARK = 0x26262b, WHITE = 0xf4f4f0, GLASS = 0x26405e, WOOD = 0x8a5a3b, HALF = Math.PI / 2;
const glow = (c, g = 1.2) => ({ emissive: c, glow: g });
function shell() {
const root = new THREE.Group(), body = new THREE.Group();
root.add(body);
return [root, body];
}
function wheel(x, y, z, r, w = 0.2) {
return joint(x, y, z, at(cyl(r, r, w, DARK, null, 12), 0, 0, 0, 0, 0, HALF), at(cyl(r * 0.5, r * 0.5, w + 0.02, 0xb8bcc4, null, 8), 0, 0, 0, 0, 0, HALF));
}
function spinner(axis, always, x, y, z, ...children) {
const j = joint(x, y, z, ...children);
j.userData.axis = axis;
j.userData.always = always;
return j;
}
// ------------------------------------------------------------------ vehicles
function car(C) {
const c = C ?? 0xd63c33, [root, body] = shell();
body.add(at(box(1.5, 0.5, 3.2, c), 0, 0.6, 0), at(box(1.3, 0.48, 1.7, tint(c, 0.08)), 0, 1.07, -0.15),
at(box(1.32, 0.34, 1.5, GLASS), 0, 1.07, -0.15), at(box(1.1, 0.34, 1.72, GLASS), 0, 1.07, -0.15),
at(box(0.3, 0.14, 0.04, 0xfff3c4, glow(0xfff3c4)), 0.5, 0.66, 1.6), at(box(0.3, 0.14, 0.04, 0xfff3c4, glow(0xfff3c4)), -0.5, 0.66, 1.6),
at(box(0.3, 0.12, 0.04, 0xff3b30, glow(0xff3b30, 0.8)), 0.5, 0.66, -1.6), at(box(0.3, 0.12, 0.04, 0xff3b30, glow(0xff3b30, 0.8)), -0.5, 0.66, -1.6),
at(box(1.56, 0.12, 0.2, DARK), 0, 0.4, 1.55), at(box(1.56, 0.12, 0.2, DARK), 0, 0.4, -1.55));
const wheels = [[0.74, 1.05], [-0.74, 1.05], [0.74, -1.05], [-0.74, -1.05]].map(([x, z]) => wheel(x, 0.34, z, 0.34));
body.add(...wheels);
return rig(root, 'vehicle', { h: 1.32, r: 1.8, top: 1.31, seat: [0, 1.31, -0.15] }, { body, wheels });
}
function truck(C) {
const c = C ?? 0x2f6fde, [root, body] = shell();
body.add(at(box(1.8, 0.25, 5.2, DARK), 0, 0.62, -0.2), at(box(1.8, 1.4, 1.4, c), 0, 1.4, 1.7), at(box(1.82, 0.5, 1.0, GLASS), 0, 1.72, 1.8),
at(box(1.5, 0.5, 1.42, GLASS), 0, 1.72, 1.7), at(box(1.9, 1.9, 3.5, 0xe6e8ec), 0, 1.7, -0.95), at(box(1.92, 0.2, 3.52, tint(c, -0.1)), 0, 1.2, -0.95),
at(box(0.3, 0.16, 0.04, 0xfff3c4, glow(0xfff3c4)), 0.6, 0.95, 2.41), at(box(0.3, 0.16, 0.04, 0xfff3c4, glow(0xfff3c4)), -0.6, 0.95, 2.41));
const wheels = [];
for (const z of [1.7, -0.6, -1.9]) for (const x of [0.85, -0.85]) wheels.push(wheel(x, 0.42, z, 0.42, 0.26));
body.add(...wheels);
return rig(root, 'vehicle', { h: 2.65, r: 2.9, top: 2.65, seat: [0, 2.65, -0.9] }, { body, wheels });
}
function bus(C) {
const c = C ?? 0xf2c230, [root, body] = shell();
body.add(at(box(1.9, 1.9, 5.2, c), 0, 1.4, 0), at(box(1.92, 0.6, 4.6, GLASS), 0, 1.75, -0.1), at(box(1.6, 0.7, 5.22, GLASS), 0, 1.7, 0),
at(box(1.94, 0.12, 5.24, tint(c, -0.18)), 0, 1.05, 0), at(box(0.6, 1.3, 0.04, tint(c, -0.3)), 0.95, 1.15, 1.6, 0, HALF, 0),
at(box(0.3, 0.16, 0.04, 0xfff3c4, glow(0xfff3c4)), 0.6, 0.75, 2.61), at(box(0.3, 0.16, 0.04, 0xfff3c4, glow(0xfff3c4)), -0.6, 0.75, 2.61));
const wheels = [[0.9, 1.7], [-0.9, 1.7], [0.9, -1.7], [-0.9, -1.7]].map(([x, z]) => wheel(x, 0.42, z, 0.42, 0.26));
body.add(...wheels);
return rig(root, 'vehicle', { h: 2.4, r: 2.9, top: 2.36, seat: [0, 2.36, 0] }, { body, wheels });
}
function bike(C) {
const c = C ?? 0xd63c33, [root, body] = shell();
const wheels = [0.56, -0.56].map((z) => joint(0, 0.36, z, at(torus(0.33, 0.035, DARK), 0, 0, 0, 0, HALF, 0),
at(box(0.02, 0.64, 0.02, 0xb8bcc4), 0, 0, 0), at(box(0.02, 0.02, 0.64, 0xb8bcc4), 0, 0, 0)));
const tube = (len, y, z, rx) => at(box(0.05, len, 0.05, c), 0, y, z, rx);
body.add(...wheels, tube(0.62, 0.62, -0.22, 0.3), tube(0.66, 0.84, 0.1, HALF + 0.05), tube(0.7, 0.58, 0.14, -0.85),
tube(0.5, 0.42, -0.36, HALF + 0.25), tube(0.62, 0.64, 0.46, -0.3), at(box(0.5, 0.04, 0.04, DARK), 0, 0.98, 0.38),
at(box(0.16, 0.05, 0.28, DARK), 0, 0.95, -0.3), at(box(0.3, 0.04, 0.06, DARK), 0, 0.34, -0.08));
return rig(root, 'vehicle', { h: 1.0, r: 0.95, top: 0.97, seat: [0, 0.97, -0.3], narrow: true }, { body, wheels });
}
function skateboard(C) {
const c = C ?? 0x8a4fd3, [root, body] = shell();
body.add(at(box(0.3, 0.04, 0.8, c), 0, 0.14, 0), at(box(0.3, 0.04, 0.2, c), 0, 0.17, 0.48, -0.35), at(box(0.3, 0.04, 0.2, c), 0, 0.17, -0.48, 0.35),
at(box(0.26, 0.04, 0.06, 0xb8bcc4), 0, 0.1, 0.3), at(box(0.26, 0.04, 0.06, 0xb8bcc4), 0, 0.1, -0.3));
const wheels = [[0.13, 0.3], [-0.13, 0.3], [0.13, -0.3], [-0.13, -0.3]].map(([x, z]) =>
joint(x, 0.06, z, at(cyl(0.06, 0.06, 0.06, 0xf4f4f0, null, 8), 0, 0, 0, 0, 0, HALF)));
body.add(...wheels);
return rig(root, 'vehicle', { h: 0.2, r: 0.6, top: 0.16, seat: [0, 0.16, 0], board: true }, { body, wheels });
}
function boat(C) {
const c = C ?? 0xf4f4f0, [root, body] = shell();
body.add(at(box(1.3, 0.55, 2.6, c), 0, 0.3, -0.2), at(cone(0.92, 1.2, c, null, 4), 0, 0.3, 1.7, HALF, Math.PI / 4, 0, [1, 1, 0.42]),
at(box(1.34, 0.12, 2.62, 0x2f6fde), 0, 0.5, -0.2), at(box(1.1, 0.06, 2.4, WOOD), 0, 0.59, -0.2),
at(box(0.8, 0.5, 0.9, tint(c, -0.08)), 0, 0.85, -0.8), at(box(0.82, 0.2, 0.7, GLASS), 0, 0.92, -0.8),
at(cyl(0.04, 0.04, 2.4, WOOD, null, 6), 0, 1.8, 0.3), at(box(0.03, 1.8, 1.1, WHITE, { side: 1 }), 0, 1.95, -0.3, 0, 0, 0),
at(cone(0.5, 0.35, 0xd63c33, null, 3), 0, 3.05, 0.1, 0, 0, HALF, [0.1, 1, 1]));
return rig(root, 'vehicle', { h: 3.2, r: 1.9, top: 0.62, seat: [0, 0.62, 0.4], swims: true, floats: true }, { body });
}
function plane(C) {
const c = C ?? 0xf4f4f0, k = tint(c, -0.45) === c ? 0xd63c33 : 0xd63c33, [root, body] = shell();
const y = 1.0;
body.add(at(cyl(0.36, 0.3, 2.6, c, null, 10), 0, y, 0, HALF), at(cone(0.3, 1.0, c, null, 10), 0, y, -1.8, -HALF),
at(cone(0.36, 0.5, k, null, 10), 0, y, 1.55, HALF), at(box(4.6, 0.08, 0.85, c), 0, y - 0.1, 0.3), at(box(4.62, 0.09, 0.2, k), 0, y - 0.1, 0.62),
at(box(1.6, 0.06, 0.5, c), 0, y + 0.05, -1.9), at(box(0.06, 0.7, 0.55, k), 0, y + 0.4, -1.9),
at(box(0.5, 0.26, 0.7, GLASS), 0, y + 0.3, 0.55), at(cyl(0.03, 0.03, 0.6, DARK, null, 5), 0.5, 0.5, 0.5), at(cyl(0.03, 0.03, 0.6, DARK, null, 5), -0.5, 0.5, 0.5));
const wheels = [wheel(0.5, 0.2, 0.5, 0.2, 0.1), wheel(-0.5, 0.2, 0.5, 0.2, 0.1), wheel(0, 0.14, -1.9, 0.14, 0.08)];
const prop = spinner('z', false, 0, y, 1.82, at(box(1.5, 0.12, 0.03, DARK), 0, 0, 0), at(box(0.12, 1.5, 0.03, DARK), 0, 0, 0));
body.add(...wheels, prop);
return rig(root, 'vehicle', { h: 1.75, r: 2.4, top: 1.36, seat: [0, 1.36, 0], flyer: true }, { body, wheels, spinners: [prop] });
}
function rocket(C) {
const c = C ?? 0xf4f4f0, [root, body] = shell();
body.add(at(cyl(0.45, 0.45, 2.2, c, null, 12), 0, 1.6, 0), at(cone(0.45, 0.9, 0xd63c33, null, 12), 0, 3.15, 0),
at(cyl(0.3, 0.42, 0.3, 0x55585e, null, 12), 0, 0.42, 0), at(orb(0.19, GLASS), 0, 2.1, 0.36), at(torus(0.2, 0.04, 0xb8bcc4), 0, 2.1, 0.4),
at(cyl(0.455, 0.455, 0.14, 0xd63c33, null, 12), 0, 1.0, 0));
for (let i = 0; i < 3; i++) {
const a = i * 2.094;
body.add(at(box(0.06, 0.9, 0.6, 0xd63c33), Math.sin(a) * 0.6, 0.6, Math.cos(a) * 0.6, 0, a, 0));
}
const flame = joint(0, 0.3, 0, at(cone(0.3, 1.0, 0xffb02e, { ...glow(0xff7a1a, 2), noShadow: 1 }, 8), 0, -0.5, 0, Math.PI), at(cone(0.16, 0.6, 0xfff1a8, { ...glow(0xfff1a8, 2), noShadow: 1 }, 8), 0, -0.3, 0, Math.PI));
flame.visible = false;
body.add(flame);
return rig(root, 'vehicle', { h: 3.6, r: 0.95, top: 3.6, seat: [0, 2.7, 0.45], flyer: true, vertical: true }, { body, flame });
}
function train(C) {
const c = C ?? 0x2f7d5b, d = tint(c, -0.16), [root, body] = shell();
body.add(at(box(1.4, 0.3, 3.6, DARK), 0, 0.6, 0), at(cyl(0.56, 0.56, 2.1, c, null, 12), 0, 1.3, 0.6, HALF), at(box(1.45, 1.4, 1.2, d), 0, 1.45, -1.15),
at(box(1.6, 0.1, 1.4, DARK), 0, 2.2, -1.15), at(box(1.47, 0.5, 0.7, GLASS), 0, 1.75, -1.15), at(cyl(0.16, 0.12, 0.6, DARK, null, 8), 0, 2.1, 1.2),
at(cyl(0.22, 0.16, 0.14, DARK, null, 8), 0, 2.45, 1.2), at(cyl(0.2, 0.2, 0.24, 0xe2b23a, null, 8), 0, 1.95, 0.3),
at(cone(0.8, 0.7, 0xd63c33, null, 4), 0, 0.5, 2.0, HALF, Math.PI / 4, 0, [1, 1, 0.5]), at(orb(0.14, 0xfff3c4, glow(0xfff3c4)), 0, 1.3, 1.66));
const wheels = [];
for (const z of [1.1, 0.2, -1.1]) for (const x of [0.72, -0.72]) wheels.push(wheel(x, 0.36, z, 0.36, 0.14));
for (const w of wheels) w.children[1].material = w.children[1].material.clone(), w.children[1].material.color.setHex(0xd63c33);
body.add(...wheels);
return rig(root, 'vehicle', { h: 2.55, r: 2.2, top: 2.25, seat: [0, 2.25, -1.15] }, { body, wheels });
}
function ufo(C) {
const c = C ?? 0xc4c9d1, [root, body] = shell(), y = 1.5;
body.add(at(orb(1.3, c, { metal: 1 }), 0, y, 0, 0, 0, 0, [1, 0.22, 1]), at(orb(0.9, tint(c, -0.15), { metal: 1 }), 0, y - 0.15, 0, 0, 0, 0, [1, 0.3, 1]),
at(orb(0.56, 0x7fe9ff, { opacity: 0.6 }), 0, y + 0.2, 0, 0, 0, 0, [1, 0.85, 1]));
const ring = spinner('y', true, 0, y, 0);
for (let i = 0; i < 8; i++) ring.add(at(orb(0.09, i % 2 ? 0x7dff7a : 0xffe24a, glow(i % 2 ? 0x7dff7a : 0xffe24a, 1.8)), Math.cos(i * 0.785) * 1.05, -0.05, Math.sin(i * 0.785) * 1.05));
body.add(ring);
return rig(root, 'vehicle', { h: y + 0.7, r: 1.4, top: y + 0.68, seat: [0, y + 0.66, 0], flyer: true, floaty: true, hover: 0.4 }, { body, spinners: [ring] });
}
function helicopter(C) {
const c = C ?? 0xd63c33, [root, body] = shell(), y = 1.05;
body.add(at(ball(0.75, c), 0, y, 0.2, 0, 0, 0, [0.9, 0.9, 1.3]), at(orb(0.6, GLASS), 0, y + 0.05, 0.62, 0, 0, 0, [0.85, 0.8, 0.9]),
at(box(0.2, 0.2, 2.2, c), 0, y + 0.2, -1.6), at(box(0.06, 0.6, 0.4, tint(c, -0.15)), 0, y + 0.45, -2.6), at(cyl(0.05, 0.05, 0.4, DARK, null, 6), 0, y + 0.8, 0.2));
for (const sx of [1, -1]) body.add(at(box(0.07, 0.07, 1.9, DARK), sx * 0.55, 0.06, 0.2), at(box(0.05, 0.5, 0.05, DARK), sx * 0.5, 0.3, 0.7, 0, 0, sx * 0.2), at(box(0.05, 0.5, 0.05, DARK), sx * 0.5, 0.3, -0.3, 0, 0, sx * 0.2));
const main = spinner('y', false, 0, y + 1.0, 0.2, at(box(4.4, 0.04, 0.2, DARK), 0, 0, 0), at(box(0.2, 0.04, 4.4, DARK), 0, 0, 0));
const rear = spinner('x', false, 0.08, y + 0.5, -2.6, at(box(0.03, 0.8, 0.1, DARK), 0, 0, 0), at(box(0.03, 0.1, 0.8, DARK), 0, 0, 0));
body.add(main, rear);
return rig(root, 'vehicle', { h: 2.1, r: 2.3, top: y + 1.05, seat: [0, y + 0.7, -0.3], flyer: true }, { body, spinners: [main, rear] });
}
// ------------------------------------------------------------------ props
function tree(C) {
const c = C ?? 0x3f9a4a, [root, body] = shell();
const crown = joint(0, 1.5, 0, at(ball(1.0, c), 0, 0.6, 0), at(ball(0.75, tint(c, 0.06)), 0.5, 1.2, 0.2), at(ball(0.7, tint(c, -0.06)), -0.5, 1.1, -0.3), at(ball(0.6, tint(c, 0.03)), 0, 1.75, 0));
body.add(at(cyl(0.16, 0.24, 1.7, 0x7a5233, null, 7), 0, 0.85, 0), crown);
return rig(root, 'prop', { h: 3.8, r: 1.2, top: 3.8, seat: [0, 3.7, 0], sway: true }, { body, head: crown });
}
function house(C) {
const c = C ?? 0xe8d9b8, [root, body] = shell();
body.add(at(box(3.2, 2.2, 3.0, c), 0, 1.1, 0), at(cone(2.55, 1.5, 0xb5483a, null, 4), 0, 2.95, 0, 0, Math.PI / 4, 0),
at(box(0.7, 1.3, 0.06, 0x6b4a2a), 0, 0.65, 1.51), at(orb(0.05, 0xe2b23a), 0.22, 0.65, 1.56),
at(box(0.7, 0.7, 0.06, 0xffe7a3, glow(0xffd76a, 0.5)), 1.0, 1.3, 1.51), at(box(0.7, 0.7, 0.06, 0xffe7a3, glow(0xffd76a, 0.5)), -1.0, 1.3, 1.51),
at(box(0.06, 0.7, 0.7, 0xffe7a3, glow(0xffd76a, 0.5)), 1.61, 1.3, 0), at(box(0.4, 1.0, 0.4, 0x9a5a48), 0.9, 3.0, -0.5));
return rig(root, 'prop', { h: 3.7, r: 2.4, top: 3.7, seat: [0, 3.6, 0] }, { body });
}
function ballProp(C) {
const c = C ?? 0xd63c33, [root, body] = shell();
const b = joint(0, 0.36, 0, orb(0.36, c), at(torus(0.362, 0.03, WHITE), 0, 0, 0, HALF), at(torus(0.362, 0.03, WHITE), 0, 0, 0, 0, HALF));
body.add(b);
return rig(root, 'prop', { h: 0.72, r: 0.42, top: 0.72, seat: [0, 0.72, 0], round: 0.36 }, { body, roller: b });
}
function crate(C) {
const c = C ?? 0xb98a4f, d = tint(c, -0.16), [root, body] = shell();
body.add(at(box(0.8, 0.8, 0.8, c), 0, 0.4, 0));
for (const s of [1, -1]) {
body.add(at(box(0.86, 0.1, 0.86, d), 0, 0.4 + s * 0.36, 0), at(box(0.1, 0.8, 0.86, d), s * 0.38, 0.4, 0));
body.add(at(box(0.9, 0.08, 0.04, d), 0, 0.4, s * 0.41, 0, 0, 0.72));
}
return rig(root, 'prop', { h: 0.82, r: 0.6, top: 0.82, seat: [0, 0.82, 0] }, { body });
}
function chair(C) {
const c = C ?? WOOD, d = tint(c, -0.1), [root, body] = shell();
body.add(at(box(0.52, 0.06, 0.52, c), 0, 0.48, 0), at(box(0.52, 0.6, 0.06, c), 0, 0.82, -0.23), at(box(0.52, 0.1, 0.07, d), 0, 1.1, -0.23));
for (const [x, z] of [[1, 1], [-1, 1], [1, -1], [-1, -1]]) body.add(at(box(0.06, 0.48, 0.06, d), x * 0.22, 0.24, z * 0.22));
return rig(root, 'prop', { h: 1.15, r: 0.42, top: 0.51, seat: [0, 0.51, 0.02], chair: true }, { body });
}
function table(C) {
const c = C ?? WOOD, d = tint(c, -0.1), [root, body] = shell();
body.add(at(box(1.5, 0.08, 0.95, c), 0, 0.78, 0));
for (const [x, z] of [[1, 1], [-1, 1], [1, -1], [-1, -1]]) body.add(at(box(0.09, 0.76, 0.09, d), x * 0.66, 0.38, z * 0.39));
return rig(root, 'prop', { h: 0.82, r: 0.9, top: 0.82, seat: [0, 0.82, 0] }, { body });
}
function rock(C) {
const c = C ?? 0x8d9199, [root, body] = shell();
body.add(at(rockGeo(0.6, c), 0, 0.42, 0, 0.3, 0.5, 0.1, [1.25, 0.85, 1.0]), at(rockGeo(0.3, tint(c, -0.06)), 0.6, 0.2, 0.3, 0.8, 0.2, 0.4));
return rig(root, 'prop', { h: 0.95, r: 0.85, top: 0.92, seat: [0, 0.9, 0] }, { body });
}
function flower(C) {
const c = C ?? 0xf284b6, [root, body] = shell();
const head = joint(0, 0.7, 0, at(orb(0.1, 0xf2c230), 0, 0, 0.03));
for (let i = 0; i < 6; i++) head.add(at(ball(0.11, c), Math.cos(i * 1.047) * 0.17, Math.sin(i * 1.047) * 0.17, 0, 0, 0, 0, [1, 1, 0.4]));
head.rotation.x = -0.5;
body.add(at(cyl(0.025, 0.03, 0.7, 0x3f9a4a, null, 6), 0, 0.35, 0), at(box(0.22, 0.02, 0.1, 0x3f9a4a), 0.11, 0.3, 0, 0, 0, 0.5), at(box(0.22, 0.02, 0.1, 0x3f9a4a), -0.11, 0.2, 0, 0, 0, -0.5), head);
return rig(root, 'prop', { h: 0.95, r: 0.32, top: 0.9, seat: [0, 0.9, 0], sway: true }, { body, head });
}
function cactus(C) {
const c = C ?? 0x4f9a52, [root, body] = shell();
body.add(at(cyl(0.24, 0.26, 1.5, c, null, 8), 0, 0.75, 0), at(ball(0.24, c), 0, 1.5, 0), at(orb(0.09, 0xf284b6), 0, 1.76, 0));
for (const [s, y, l] of [[1, 0.8, 0.6], [-1, 0.6, 0.45]]) {
body.add(at(cyl(0.12, 0.12, 0.4, c, null, 7), s * 0.36, y, 0, 0, 0, HALF), at(cyl(0.12, 0.12, l, c, null, 7), s * 0.52, y + l / 2, 0), at(ball(0.12, c), s * 0.52, y + l, 0));
}
return rig(root, 'prop', { h: 1.8, r: 0.7, top: 1.75, seat: [0, 1.75, 0] }, { body });
}
function mushroom(C) {
const c = C ?? 0xd63c33, [root, body] = shell();
const cap = joint(0, 0.42, 0, at(orb(0.42, c), 0, 0, 0, 0, 0, 0, [1, 0.62, 1]));
for (const [x, y, z] of [[0.2, 0.2, 0.15], [-0.18, 0.21, 0.1], [0, 0.26, -0.1], [0.05, 0.14, 0.32], [-0.26, 0.12, -0.2]]) cap.add(at(orb(0.06, WHITE), x, y, z, 0, 0, 0, [1, 0.5, 1]));
body.add(at(cyl(0.12, 0.16, 0.45, 0xf2ead8, null, 8), 0, 0.22, 0), cap);
return rig(root, 'prop', { h: 0.72, r: 0.45, top: 0.7, seat: [0, 0.68, 0] }, { body, head: cap });
}
function tower(C) {
const c = C ?? 0x9aa0a8, d = tint(c, -0.1), [root, body] = shell();
body.add(at(cyl(0.95, 1.1, 4.2, c, null, 10), 0, 2.1, 0), at(cyl(1.15, 1.15, 0.3, d, null, 10), 0, 4.3, 0), at(cone(1.0, 1.4, 0xb5483a, null, 10), 0, 5.4, 0),
at(box(0.6, 1.1, 0.1, 0x6b4a2a), 0, 0.55, 1.06), at(box(0.3, 0.5, 0.1, 0xffe7a3, glow(0xffd76a, 0.6)), 0, 2.8, 0.97));
for (let i = 0; i < 8; i++) body.add(at(box(0.36, 0.34, 0.26, d), Math.cos(i * 0.785) * 1.05, 4.6, Math.sin(i * 0.785) * 1.05, 0, -i * 0.785 + HALF, 0));
return rig(root, 'prop', { h: 6.1, r: 1.3, top: 4.45, seat: [0, 4.45, 0.4] }, { body });
}
function lamp(C) {
const c = C ?? 0x33363c, [root, body] = shell();
body.add(at(cyl(0.06, 0.09, 2.7, c, null, 8), 0, 1.35, 0), at(cyl(0.16, 0.2, 0.14, c, null, 8), 0, 0.07, 0), at(box(0.06, 0.06, 0.6, c), 0, 2.7, 0.27),
at(cone(0.22, 0.16, c, null, 8), 0, 2.72, 0.55), at(orb(0.13, 0xfff0b8, glow(0xffd76a, 2.2)), 0, 2.58, 0.55));
const light = new THREE.PointLight(0xffd9a0, 6, 9, 1.6);
light.position.set(0, 2.5, 0.55);
body.add(light);
return rig(root, 'prop', { h: 2.85, r: 0.5, top: 2.8, seat: [0, 2.8, 0] }, { body });
}
function bench(C) {
const c = C ?? WOOD, [root, body] = shell();
for (const z of [-0.14, 0, 0.14]) body.add(at(box(1.6, 0.05, 0.12, c), 0, 0.47, z));
for (const y of [0.7, 0.88]) body.add(at(box(1.6, 0.12, 0.05, c), 0, y, -0.24, -0.12));
for (const x of [0.7, -0.7]) body.add(at(box(0.07, 0.46, 0.44, DARK), x, 0.23, 0), at(box(0.07, 0.5, 0.06, DARK), x, 0.72, -0.24, -0.12));
return rig(root, 'prop', { h: 0.96, r: 0.9, top: 0.5, seat: [0, 0.5, 0.02], chair: true }, { body });
}
function balloon(C) {
const c = C ?? 0xd63c33, [root, body] = shell();
body.add(at(orb(0.36, c), 0, 1.9, 0, 0, 0, 0, [1, 1.2, 1]), at(cone(0.06, 0.1, c, null, 6), 0, 1.44, 0), at(cyl(0.006, 0.006, 1.1, 0xe6e8ec, { noShadow: 1 }, 4), 0, 0.88, 0));
return rig(root, 'prop', { h: 2.35, r: 0.42, top: 2.33, seat: [0, 2.33, 0], floaty: true, hover: 0.3 }, { body });
}
export const THINGS = {
car, truck, bus, bike, skateboard, boat, plane, rocket, train, ufo, helicopter,
tree, house, ball: ballProp, box: crate, chair, table, rock, flower, cactus, mushroom, tower, lamp, bench, balloon,
};