@chanmeng666/archlang-3d 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -0
- package/README.md +4 -4
- package/dist/browser.d.ts +3 -5
- package/dist/browser.js +98 -475
- package/dist/{camera-DcyxtBjK.d.ts → camera-BAsRq_eC.d.ts} +1 -1
- package/dist/{chunk-6WCS4TAT.js → chunk-B4PZWWSP.js} +452 -37
- package/dist/{chunk-TNNJ7CAO.js → chunk-LNIVDMPG.js} +103 -9
- package/dist/{chunk-LMFD5NP4.js → chunk-MCASL4MM.js} +18 -7
- package/dist/chunk-MXKKNJPU.js +983 -0
- package/dist/{chunk-CX6IVI7I.js → chunk-VMVKI2WQ.js} +65 -3
- package/dist/chunk-WARUDAOQ.js +2276 -0
- package/dist/cli.js +12 -6
- package/dist/{facts-Dje5wcHh.d.ts → facts-CsO0xtFw.d.ts} +1 -1
- package/dist/index.d.ts +341 -37
- package/dist/index.js +36 -6
- package/dist/node.d.ts +23 -7
- package/dist/node.js +4 -4
- package/dist/{strip-CA-IAT0N.d.ts → payload-DwiB2P7x.d.ts} +276 -12
- package/dist/replay.d.ts +1 -115
- package/dist/scene3d.schema.json +12 -0
- package/dist/viewer.iife.js +181 -181
- package/package.json +3 -3
- package/dist/chunk-VXGQYUMN.js +0 -1198
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
C16,
|
|
3
|
+
S16
|
|
4
|
+
} from "./chunk-LNIVDMPG.js";
|
|
5
|
+
|
|
1
6
|
// src/mesh/extrude.ts
|
|
2
7
|
import earcut from "earcut";
|
|
3
8
|
var area2 = (r) => {
|
|
@@ -371,13 +376,7 @@ var HEMI = [
|
|
|
371
376
|
[1, 0.132]
|
|
372
377
|
];
|
|
373
378
|
function dome(mat, cx, cz, rx, rz, y0, y1, table) {
|
|
374
|
-
|
|
375
|
-
return table.map(([t, f], k) => {
|
|
376
|
-
const hi = k === table.length - 1 ? y1 : y0 + (y1 - y0) * t;
|
|
377
|
-
const p = P(mat, cx - rx * f, cx + rx * f, cz - rz * f, cz + rz * f, lo, hi, { round: true });
|
|
378
|
-
lo = hi;
|
|
379
|
-
return p;
|
|
380
|
-
});
|
|
379
|
+
return [P(mat, cx - rx, cx + rx, cz - rz, cz + rz, y0, y1, { round: true, loft: table })];
|
|
381
380
|
}
|
|
382
381
|
function cabinet(W, D, opts = {}) {
|
|
383
382
|
const [hw, hd] = [W / 2, D / 2];
|
|
@@ -1164,8 +1163,93 @@ var T0_LIVING = {
|
|
|
1164
1163
|
P("cushion", -rx * 0.42, rx * 0.42, zs - D * 0.15, zs + D * 0.15, 372, 410, { round: true })
|
|
1165
1164
|
];
|
|
1166
1165
|
}
|
|
1166
|
+
},
|
|
1167
|
+
// ── the new-families batch (product-roadmap RM8.9) ──
|
|
1168
|
+
display_cabinet: {
|
|
1169
|
+
names: ["display_cabinet", "vitrine", "curio_cabinet"],
|
|
1170
|
+
heightMm: 1900,
|
|
1171
|
+
materials: ["wood", "metal", "glass"],
|
|
1172
|
+
gen(W, D) {
|
|
1173
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
1174
|
+
const side = W * 0.04;
|
|
1175
|
+
const k = Math.min(W * 0.01, 8);
|
|
1176
|
+
return [
|
|
1177
|
+
P("wood", -hw + W * 0.02, hw - W * 0.02, -hd, hd - D * 0.04, 0, 80),
|
|
1178
|
+
P("wood", -hw, hw, -hd, hd, 80, 120),
|
|
1179
|
+
P("wood", -hw, hw, -hd, -hd + D * 0.06, 120, 1860),
|
|
1180
|
+
...pair(P("wood", -hw, -hw + side, -hd, hd, 120, 1860)),
|
|
1181
|
+
P("wood", -hw, hw, -hd, hd, 1860, 1900),
|
|
1182
|
+
...[700, 1250].map((y) => P("glass", -hw + side, hw - side, -hd + D * 0.06, hd - D * 0.06, y, y + 10)),
|
|
1183
|
+
...span(2, hw - side, 4).map(([a, b]) => P("glass", a, b, hd - D * 0.05, hd - D * 0.02, 130, 1850)),
|
|
1184
|
+
...pair(P("metal", -W * 0.04 - k, -W * 0.04 + k, hd - D * 0.02, hd, 900, 1100))
|
|
1185
|
+
];
|
|
1186
|
+
}
|
|
1187
|
+
},
|
|
1188
|
+
folding_screen: {
|
|
1189
|
+
names: ["folding_screen", "room_divider", "privacy_screen"],
|
|
1190
|
+
heightMm: 1700,
|
|
1191
|
+
materials: ["wood", "fabric"],
|
|
1192
|
+
gen(W, D) {
|
|
1193
|
+
const n = 2 * clamp(Math.round(W / (2.2 * D)), 1, 4);
|
|
1194
|
+
return span(n, W / 2, 0).flatMap(([a, b], k) => {
|
|
1195
|
+
const zig = k % 2 === 0 ? SCREEN_PANEL : SCREEN_PANEL_BACK;
|
|
1196
|
+
const at = (mat, y0, y1) => P(mat, a, b, -D / 2, D / 2, y0, y1, { profile: zig });
|
|
1197
|
+
return [at("wood", 0, 120), at("fabric", 120, 1600), at("wood", 1600, 1700)];
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1201
|
+
daybed: {
|
|
1202
|
+
names: ["daybed", "day_bed"],
|
|
1203
|
+
heightMm: 750,
|
|
1204
|
+
materials: ["wood_dark", "fabric", "cushion"],
|
|
1205
|
+
gen(W, D) {
|
|
1206
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
1207
|
+
const s = Math.min(W, D);
|
|
1208
|
+
const back = D * 0.2;
|
|
1209
|
+
const arm = Math.min(W * 0.07, D * 0.2);
|
|
1210
|
+
const [c, leg] = [s * 0.04, s * 0.05];
|
|
1211
|
+
const g = s * 0.02;
|
|
1212
|
+
return [
|
|
1213
|
+
...[-hd + c, hd - c - leg].flatMap((z) => pair(P("wood_dark", -hw + c, -hw + c + leg, z, z + leg, 0, 100))),
|
|
1214
|
+
P("fabric", -hw, hw, -hd, hd, 100, 400, { radius: s * 0.03 }),
|
|
1215
|
+
P("fabric", -hw, hw, -hd, -hd + back, 400, 750, { axis: "x", radius: Math.min(back * 0.4, 60) }),
|
|
1216
|
+
...pair(P("fabric", -hw, -hw + arm, -hd, hd, 400, 650, { axis: "z", radius: Math.min(arm * 0.4, 60) })),
|
|
1217
|
+
P("cushion", -hw + arm + g, hw - arm - g, -hd + back + g, hd - g, 400, 520, { radius: s * 0.04 })
|
|
1218
|
+
];
|
|
1219
|
+
}
|
|
1220
|
+
},
|
|
1221
|
+
wall_art: {
|
|
1222
|
+
names: ["wall_art", "artwork", "painting", "picture"],
|
|
1223
|
+
heightMm: 1900,
|
|
1224
|
+
hungFromTop: true,
|
|
1225
|
+
materials: ["wood", "paint"],
|
|
1226
|
+
gen(W, D) {
|
|
1227
|
+
const [hw, hd, H] = [W / 2, D / 2, 1900];
|
|
1228
|
+
const ph = clamp(W * 0.75, 300, 1e3);
|
|
1229
|
+
const fw = Math.min(W * 0.06, ph * 0.08);
|
|
1230
|
+
const zf = hd - D * 0.4;
|
|
1231
|
+
return [
|
|
1232
|
+
P("wood", -hw, hw, -hd, zf, H - ph, H),
|
|
1233
|
+
P("paint", -hw + fw, hw - fw, zf, hd - D * 0.1, H - ph + fw, H - fw),
|
|
1234
|
+
P("wood", -hw, hw, zf, hd, H - fw, H),
|
|
1235
|
+
P("wood", -hw, hw, zf, hd, H - ph, H - ph + fw),
|
|
1236
|
+
...pair(P("wood", -hw, -hw + fw, zf, hd, H - ph + fw, H - fw))
|
|
1237
|
+
];
|
|
1238
|
+
}
|
|
1167
1239
|
}
|
|
1168
1240
|
};
|
|
1241
|
+
var SCREEN_PANEL = [
|
|
1242
|
+
[0, 0],
|
|
1243
|
+
[1, 55 / 64],
|
|
1244
|
+
[1, 1],
|
|
1245
|
+
[0, 9 / 64]
|
|
1246
|
+
];
|
|
1247
|
+
var SCREEN_PANEL_BACK = [
|
|
1248
|
+
[1, 9 / 64],
|
|
1249
|
+
[0, 1],
|
|
1250
|
+
[0, 55 / 64],
|
|
1251
|
+
[1, 0]
|
|
1252
|
+
];
|
|
1169
1253
|
|
|
1170
1254
|
// src/mesh/t0-office.ts
|
|
1171
1255
|
var SHELL = [
|
|
@@ -2495,8 +2579,155 @@ var T0_OUTDOOR = {
|
|
|
2495
2579
|
...seedlings
|
|
2496
2580
|
];
|
|
2497
2581
|
}
|
|
2582
|
+
},
|
|
2583
|
+
// ── the new-families batch (product-roadmap RM8.9) ──
|
|
2584
|
+
pool: {
|
|
2585
|
+
names: ["pool", "swimming_pool", "plunge_pool"],
|
|
2586
|
+
heightMm: 50,
|
|
2587
|
+
materials: ["stone", "water"],
|
|
2588
|
+
// The ground is the viewer's, drawn at floor level, so a pool dug below it would be hidden: the
|
|
2589
|
+
// water is a slab at grade inside the coping, never excavated (visual-language.md § 4.1).
|
|
2590
|
+
defaults: [{ field: "water_mm", value: 20, rule: "pool-water-at-grade" }],
|
|
2591
|
+
gen(W, D) {
|
|
2592
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
2593
|
+
const s = Math.min(W, D);
|
|
2594
|
+
const e = s * 0.08;
|
|
2595
|
+
const r = s * 0.03;
|
|
2596
|
+
const d = Math.min(10, e / 2);
|
|
2597
|
+
return [
|
|
2598
|
+
P("stone", -hw, hw, -hd, hd, 0, 50, {
|
|
2599
|
+
radius: s * 0.06,
|
|
2600
|
+
holes: [{ x0: -hw + e, x1: hw - e, z0: -hd + e, z1: hd - e, radius: r }]
|
|
2601
|
+
}),
|
|
2602
|
+
P("water", -hw + e - d, hw - e + d, -hd + e - d, hd - e + d, 0, 20, { radius: r + d })
|
|
2603
|
+
];
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
garden_gate: {
|
|
2607
|
+
names: ["garden_gate", "yard_gate"],
|
|
2608
|
+
heightMm: 1200,
|
|
2609
|
+
materials: ["wood", "stone"],
|
|
2610
|
+
gen(W, D) {
|
|
2611
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
2612
|
+
const t = Math.min(D * 0.12, W * 0.04);
|
|
2613
|
+
return [
|
|
2614
|
+
P("stone", -hw, hw, -hd, hd, 0, 10),
|
|
2615
|
+
...pair(P("wood", -hw, -hw + t, -hd, -hd + t, 0, 1200)),
|
|
2616
|
+
...span(2, hw - t, Math.min(W * 0.01, 10)).map(
|
|
2617
|
+
([a, b]) => P("wood", a, b, -hd + t * 0.2, -hd + t * 0.8, 60, 1100)
|
|
2618
|
+
)
|
|
2619
|
+
];
|
|
2620
|
+
}
|
|
2621
|
+
},
|
|
2622
|
+
gazebo: {
|
|
2623
|
+
names: ["gazebo", "pavilion", "garden_pavilion"],
|
|
2624
|
+
heightMm: 3e3,
|
|
2625
|
+
materials: ["wood", "wood_dark"],
|
|
2626
|
+
gen(W, D) {
|
|
2627
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
2628
|
+
const s = Math.min(W, D);
|
|
2629
|
+
const [px, pz, h] = [hw - s * 0.14, hd - s * 0.14, s * 0.025];
|
|
2630
|
+
return [
|
|
2631
|
+
P("wood", -hw + s * 0.1, hw - s * 0.1, -hd + s * 0.1, hd - s * 0.1, 0, 150, { radius: s * 0.02 }),
|
|
2632
|
+
...[-pz, pz].flatMap((z) => pair(P("wood", -px - h, -px + h, z - h, z + h, 150, 2400))),
|
|
2633
|
+
P("wood", -hw, hw, -hd, hd, 2400, 2460),
|
|
2634
|
+
P("wood_dark", -hw, hw, -hd, hd, 2460, 3e3, { loft: GAZEBO_ROOF })
|
|
2635
|
+
];
|
|
2636
|
+
}
|
|
2637
|
+
},
|
|
2638
|
+
greenhouse: {
|
|
2639
|
+
names: ["greenhouse", "glasshouse"],
|
|
2640
|
+
heightMm: 2400,
|
|
2641
|
+
materials: ["metal", "glass"],
|
|
2642
|
+
gen(W, D) {
|
|
2643
|
+
const fr = longFrame(W, D);
|
|
2644
|
+
const { L, S, part, ends, sides } = fr;
|
|
2645
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
2646
|
+
const f = Math.min(L, S) * 0.04;
|
|
2647
|
+
const bays = clamp(Math.round(L / (S * 0.45)), 2, 8);
|
|
2648
|
+
const mw = Math.min(f / 2, 15);
|
|
2649
|
+
const mullions = Array.from({ length: bays - 1 }, (_, i) => L * (2 * (i + 1) - bays) / (2 * bays));
|
|
2650
|
+
return [
|
|
2651
|
+
P("glass", -hw + f, hw - f, -hd + f, hd - f, 0, 1800),
|
|
2652
|
+
...ends(part("metal", -L / 2, -L / 2 + f, -S / 2, -S / 2 + f, 0, 1800)).flatMap(sides),
|
|
2653
|
+
...mullions.flatMap((a) => sides(part("metal", a - mw, a + mw, -S / 2, -S / 2 + f, 0, 1800))),
|
|
2654
|
+
P("metal", -hw, hw, -hd, hd, 1800, 1840),
|
|
2655
|
+
part("glass", -L / 2, L / 2, -S / 2, S / 2, 1840, 2400, { profile: GABLE }, "along"),
|
|
2656
|
+
part("metal", -L / 2, L / 2, -Math.min(S * 0.01, 15), Math.min(S * 0.01, 15), 2380, 2400)
|
|
2657
|
+
];
|
|
2658
|
+
}
|
|
2659
|
+
},
|
|
2660
|
+
climber: {
|
|
2661
|
+
names: ["climber", "climbing_plant"],
|
|
2662
|
+
heightMm: 2400,
|
|
2663
|
+
materials: ["wood", "foliage"],
|
|
2664
|
+
gen(W, D) {
|
|
2665
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
2666
|
+
const rail = D * 0.14;
|
|
2667
|
+
return [
|
|
2668
|
+
...pair(P("wood", -hw, -hw + Math.min(W * 0.03, 40), -hd, -hd + rail, 0, 2400)),
|
|
2669
|
+
...[600, 1300, 2e3].map((y) => P("wood", -hw, hw, -hd, -hd + rail * 0.5, y, y + 30)),
|
|
2670
|
+
P("foliage", -hw, hw, -hd + rail * 0.5, hd, 150, 2350, { radius: Math.min(D * 0.4, 200) })
|
|
2671
|
+
];
|
|
2672
|
+
}
|
|
2673
|
+
},
|
|
2674
|
+
bamboo: {
|
|
2675
|
+
names: ["bamboo"],
|
|
2676
|
+
heightMm: 4e3,
|
|
2677
|
+
materials: ["wood", "foliage"],
|
|
2678
|
+
gen(W, D) {
|
|
2679
|
+
const fr = longFrame(W, D);
|
|
2680
|
+
const { L, S, part, sides } = fr;
|
|
2681
|
+
const n = clamp(Math.round(L / (S * 0.35)), 1, 10);
|
|
2682
|
+
const rho = Math.min(S * 0.08, L / n * 0.3);
|
|
2683
|
+
const culms = Array.from({ length: n }, (_, i) => L * (2 * i + 1 - n) / (2 * n)).flatMap(
|
|
2684
|
+
(a) => sides(part("wood", a - rho, a + rho, S * 0.18 - rho, S * 0.18 + rho, 0, 3400, { round: true }))
|
|
2685
|
+
);
|
|
2686
|
+
return [...culms, P("foliage", -W / 2, W / 2, -D / 2, D / 2, 1600, 4e3, { round: true, loft: BAMBOO_CROWN })];
|
|
2687
|
+
}
|
|
2688
|
+
},
|
|
2689
|
+
potted_tree: {
|
|
2690
|
+
names: ["potted_tree", "indoor_tree"],
|
|
2691
|
+
heightMm: 2e3,
|
|
2692
|
+
materials: ["ceramic", "foliage", "bark"],
|
|
2693
|
+
gen(W, D) {
|
|
2694
|
+
const [rx, rz] = [W / 2, D / 2];
|
|
2695
|
+
const rt = clamp(Math.min(W, D) * 0.03, 10, 50);
|
|
2696
|
+
return [
|
|
2697
|
+
P("ceramic", -rx * 0.3, rx * 0.3, -rz * 0.3, rz * 0.3, 0, 440, { round: true }),
|
|
2698
|
+
P("ceramic", -rx * 0.33, rx * 0.33, -rz * 0.33, rz * 0.33, 420, 470, { round: true }),
|
|
2699
|
+
P("bark", -rt, rt, -rt, rt, 440, 1300, { round: true }),
|
|
2700
|
+
...dome("foliage", 0, 0, rx, rz, 1e3, 2e3, CROWN)
|
|
2701
|
+
];
|
|
2702
|
+
}
|
|
2703
|
+
},
|
|
2704
|
+
stepping_stones: {
|
|
2705
|
+
names: ["stepping_stones"],
|
|
2706
|
+
heightMm: 30,
|
|
2707
|
+
materials: ["stone"],
|
|
2708
|
+
gen(W, D) {
|
|
2709
|
+
const { L, S, part } = longFrame(W, D);
|
|
2710
|
+
const n = clamp(Math.round(L / (1.2 * S)), 2, 24);
|
|
2711
|
+
return span(n, L / 2, L / n * 0.25).map(
|
|
2712
|
+
([a0, a1]) => part("stone", a0, a1, -S / 2, S / 2, 0, 30, { radius: Math.min(a1 - a0, S) * 0.35 })
|
|
2713
|
+
);
|
|
2714
|
+
}
|
|
2498
2715
|
}
|
|
2499
2716
|
};
|
|
2717
|
+
var GAZEBO_ROOF = [
|
|
2718
|
+
[0.08, 1],
|
|
2719
|
+
[1, 0.04]
|
|
2720
|
+
];
|
|
2721
|
+
var GABLE = [
|
|
2722
|
+
[0, 0],
|
|
2723
|
+
[1, 0],
|
|
2724
|
+
[0.5, 1]
|
|
2725
|
+
];
|
|
2726
|
+
var BAMBOO_CROWN = [
|
|
2727
|
+
[0.3, 1],
|
|
2728
|
+
[0.8, 0.8],
|
|
2729
|
+
[1, 0.4]
|
|
2730
|
+
];
|
|
2500
2731
|
var DIR16 = [
|
|
2501
2732
|
[1, 0],
|
|
2502
2733
|
[0.9238795325112867, 0.3826834323650898],
|
|
@@ -2933,6 +3164,69 @@ var T0_UTILITY = {
|
|
|
2933
3164
|
P("linen", -W * 0.2, W * 0.2, -hd + D * 0.2, hd, 560, 1140, { radius: 8 })
|
|
2934
3165
|
];
|
|
2935
3166
|
}
|
|
3167
|
+
},
|
|
3168
|
+
// ── the new-families batch (product-roadmap RM8.9) ──
|
|
3169
|
+
wall_ac: {
|
|
3170
|
+
names: ["wall_ac", "split_ac", "air_conditioner", "ac_indoor"],
|
|
3171
|
+
heightMm: 2400,
|
|
3172
|
+
mountMm: 2100,
|
|
3173
|
+
materials: ["appliance"],
|
|
3174
|
+
gen(W, D) {
|
|
3175
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
3176
|
+
return [
|
|
3177
|
+
P("appliance", -hw, hw, -hd, hd - D * 0.1, 2130, 2400, { axis: "x", radius: Math.min(D * 0.3, 60) }),
|
|
3178
|
+
P("appliance", -hw + W * 0.04, hw - W * 0.04, hd - D * 0.12, hd, 2100, 2160, {
|
|
3179
|
+
axis: "x",
|
|
3180
|
+
radius: Math.min(D * 0.05, 20)
|
|
3181
|
+
})
|
|
3182
|
+
];
|
|
3183
|
+
}
|
|
3184
|
+
},
|
|
3185
|
+
condenser: {
|
|
3186
|
+
names: ["condenser", "ac_outdoor", "outdoor_unit", "heat_pump"],
|
|
3187
|
+
heightMm: 700,
|
|
3188
|
+
materials: ["metal", "appliance"],
|
|
3189
|
+
gen(W, D) {
|
|
3190
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
3191
|
+
const rf = Math.min(W * 0.4, D * 0.38);
|
|
3192
|
+
const zc = -hd + D * 0.56;
|
|
3193
|
+
return [
|
|
3194
|
+
...pair(P("metal", -hw + W * 0.08, -hw + W * 0.2, -hd + D * 0.1, hd - D * 0.1, 0, 40)),
|
|
3195
|
+
P("appliance", -hw, hw, -hd + D * 0.04, hd, 40, 690, { radius: Math.min(W, D) * 0.04 }),
|
|
3196
|
+
P("metal", -hw + W * 0.03, hw - W * 0.03, -hd, -hd + D * 0.06, 60, 660),
|
|
3197
|
+
P("metal", -rf, rf, zc - rf, zc + rf, 690, 700, { round: true })
|
|
3198
|
+
];
|
|
3199
|
+
}
|
|
3200
|
+
},
|
|
3201
|
+
chest_freezer: {
|
|
3202
|
+
names: ["chest_freezer"],
|
|
3203
|
+
heightMm: 850,
|
|
3204
|
+
materials: ["metal", "appliance"],
|
|
3205
|
+
gen(W, D) {
|
|
3206
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
3207
|
+
const s = Math.min(W, D);
|
|
3208
|
+
const hc = Math.min(W * 0.16, s * 0.3);
|
|
3209
|
+
return [
|
|
3210
|
+
P("appliance", -hw + W * 0.02, hw - W * 0.02, -hd + D * 0.02, hd - D * 0.05, 0, 60),
|
|
3211
|
+
P("appliance", -hw, hw, -hd, hd - D * 0.03, 60, 800, { radius: s * 0.04 }),
|
|
3212
|
+
P("appliance", -hw, hw, -hd, hd - D * 0.01, 800, 850, { radius: s * 0.05 }),
|
|
3213
|
+
P("metal", -hc, hc, hd - D * 0.03, hd, 760, 795, { axis: "x", round: true })
|
|
3214
|
+
];
|
|
3215
|
+
}
|
|
3216
|
+
},
|
|
3217
|
+
wine_fridge: {
|
|
3218
|
+
names: ["wine_fridge", "wine_cooler"],
|
|
3219
|
+
heightMm: 850,
|
|
3220
|
+
materials: ["metal", "glass", "appliance"],
|
|
3221
|
+
gen(W, D) {
|
|
3222
|
+
const [hw, hd] = [W / 2, D / 2];
|
|
3223
|
+
return [
|
|
3224
|
+
P("appliance", -hw + W * 0.02, hw - W * 0.02, -hd, hd - D * 0.06, 0, 80),
|
|
3225
|
+
P("appliance", -hw, hw, -hd, hd - D * 0.04, 80, 850, { radius: 4 }),
|
|
3226
|
+
P("glass", -hw + W * 0.04, hw - W * 0.04, hd - D * 0.04, hd - D * 0.015, 100, 830, { axis: "z", radius: 6 }),
|
|
3227
|
+
P("metal", -W * 0.3, W * 0.3, hd - D * 0.015, hd, 770, 800, { axis: "x", round: true })
|
|
3228
|
+
];
|
|
3229
|
+
}
|
|
2936
3230
|
}
|
|
2937
3231
|
};
|
|
2938
3232
|
|
|
@@ -2983,6 +3277,7 @@ var T0_HEIGHT_MM = {
|
|
|
2983
3277
|
};
|
|
2984
3278
|
var T0_MOUNT_MM = batchTable((f) => f.mountMm);
|
|
2985
3279
|
var T0_HUNG_FROM_TOP = new Set(Object.keys(batchTable((f) => f.hungFromTop)));
|
|
3280
|
+
var T0_DEFAULTS = batchTable((f) => f.defaults);
|
|
2986
3281
|
var isHung = (family) => family in T0_MOUNT_MM || T0_HUNG_FROM_TOP.has(family);
|
|
2987
3282
|
var T0_HANDED = new Set(Object.keys(batchTable((f) => f.handed)));
|
|
2988
3283
|
function handedAt(family, W, D) {
|
|
@@ -3196,25 +3491,6 @@ var GENERATORS = {
|
|
|
3196
3491
|
];
|
|
3197
3492
|
}
|
|
3198
3493
|
};
|
|
3199
|
-
var C16 = [
|
|
3200
|
-
1,
|
|
3201
|
-
0.9238795325112867,
|
|
3202
|
-
Math.SQRT1_2,
|
|
3203
|
-
0.3826834323650898,
|
|
3204
|
-
0,
|
|
3205
|
-
-0.3826834323650898,
|
|
3206
|
-
-Math.SQRT1_2,
|
|
3207
|
-
-0.9238795325112867,
|
|
3208
|
-
-1,
|
|
3209
|
-
-0.9238795325112867,
|
|
3210
|
-
-Math.SQRT1_2,
|
|
3211
|
-
-0.3826834323650898,
|
|
3212
|
-
0,
|
|
3213
|
-
0.3826834323650898,
|
|
3214
|
-
Math.SQRT1_2,
|
|
3215
|
-
0.9238795325112867
|
|
3216
|
-
];
|
|
3217
|
-
var S16 = C16.map((_, k) => C16[(k + 12) % 16]);
|
|
3218
3494
|
var um = (v) => (v < 0 ? -Math.round(-v * 1e3) : Math.round(v * 1e3)) || 0;
|
|
3219
3495
|
function sectionRing(u0, u1, v0, v1, shape = {}) {
|
|
3220
3496
|
if (!(u0 < u1 && v0 < v1)) return [];
|
|
@@ -3260,9 +3536,12 @@ function sectionRing(u0, u1, v0, v1, shape = {}) {
|
|
|
3260
3536
|
}
|
|
3261
3537
|
function partShell(p, dropped) {
|
|
3262
3538
|
if (p.axis && p.holes?.length) throw new Error("a sideways T0 part takes no holes");
|
|
3539
|
+
if (p.loft && (p.axis || p.holes?.length || p.profile)) throw new Error("a lofted T0 part is vertical and plain");
|
|
3263
3540
|
if (!(um(p.x0) < um(p.x1) && um(p.y0) < um(p.y1) && um(p.z0) < um(p.z1))) return null;
|
|
3264
3541
|
let s;
|
|
3265
|
-
if (
|
|
3542
|
+
if (p.loft) {
|
|
3543
|
+
s = loftShell(p, p.loft);
|
|
3544
|
+
} else if (!p.axis) {
|
|
3266
3545
|
const outer = sectionRing(p.x0, p.x1, p.z0, p.z1, p);
|
|
3267
3546
|
const holes = (p.holes ?? []).map((h) => sectionRing(h.x0, h.x1, h.z0, h.z1, h));
|
|
3268
3547
|
const poly = { outer, ...holes.length ? { holes } : {} };
|
|
@@ -3298,6 +3577,61 @@ function partShell(p, dropped) {
|
|
|
3298
3577
|
if (s && p.mat && p.mat !== "body") s.slot = p.mat;
|
|
3299
3578
|
return s;
|
|
3300
3579
|
}
|
|
3580
|
+
function loftShell(p, table) {
|
|
3581
|
+
if (table.length === 0) return null;
|
|
3582
|
+
const [cx, cz, rx, rz] = [(p.x0 + p.x1) / 2, (p.z0 + p.z1) / 2, (p.x1 - p.x0) / 2, (p.z1 - p.z0) / 2];
|
|
3583
|
+
const shape = { ...p.round ? { round: true } : {}, ...p.radius ? { radius: p.radius } : {} };
|
|
3584
|
+
const levels = [
|
|
3585
|
+
[um(p.y0), table[0][1]],
|
|
3586
|
+
...table.map(([t, f], k) => [
|
|
3587
|
+
k === table.length - 1 ? um(p.y1) : um(p.y0 + (p.y1 - p.y0) * t),
|
|
3588
|
+
f
|
|
3589
|
+
])
|
|
3590
|
+
];
|
|
3591
|
+
const rings = levels.map(([, f]) => sectionRing(cx - rx * f, cx + rx * f, cz - rz * f, cz + rz * f, shape));
|
|
3592
|
+
const n = rings[0]?.length ?? 0;
|
|
3593
|
+
if (n < 3 || rings.some((r) => r.length !== n)) return null;
|
|
3594
|
+
for (let k = 1; k < levels.length; k++)
|
|
3595
|
+
if (!(levels[k][0] > levels[k - 1][0])) return null;
|
|
3596
|
+
const positions = [];
|
|
3597
|
+
rings.forEach((r, k) => {
|
|
3598
|
+
for (const [x, z] of r) positions.push(x, levels[k][0], z);
|
|
3599
|
+
});
|
|
3600
|
+
const [ax, az] = [um(cx), um(cz)];
|
|
3601
|
+
const indices = [];
|
|
3602
|
+
const at = (i) => [
|
|
3603
|
+
positions[3 * i],
|
|
3604
|
+
positions[3 * i + 1],
|
|
3605
|
+
positions[3 * i + 2]
|
|
3606
|
+
];
|
|
3607
|
+
const face = (a, b, c, want) => {
|
|
3608
|
+
const [A, B, C] = [at(a), at(b), at(c)];
|
|
3609
|
+
const u = [B[0] - A[0], B[1] - A[1], B[2] - A[2]];
|
|
3610
|
+
const w = [C[0] - A[0], C[1] - A[1], C[2] - A[2]];
|
|
3611
|
+
const nx = u[1] * w[2] - u[2] * w[1];
|
|
3612
|
+
const ny = u[2] * w[0] - u[0] * w[2];
|
|
3613
|
+
const nz = u[0] * w[1] - u[1] * w[0];
|
|
3614
|
+
if (nx * want[0] + ny * want[1] + nz * want[2] >= 0) indices.push(a, b, c);
|
|
3615
|
+
else indices.push(a, c, b);
|
|
3616
|
+
};
|
|
3617
|
+
const last = rings.length - 1;
|
|
3618
|
+
for (let i = 1; i < n - 1; i++) {
|
|
3619
|
+
face(0, i, i + 1, [0, -1, 0]);
|
|
3620
|
+
face(last * n, last * n + i, last * n + i + 1, [0, 1, 0]);
|
|
3621
|
+
}
|
|
3622
|
+
for (let k = 0; k < last; k++) {
|
|
3623
|
+
for (let i = 0; i < n; i++) {
|
|
3624
|
+
const j = (i + 1) % n;
|
|
3625
|
+
const [a, b, c, d] = [k * n + i, k * n + j, (k + 1) * n + j, (k + 1) * n + i];
|
|
3626
|
+
const m = [a, b, c, d].map(at);
|
|
3627
|
+
const mx = m.reduce((s, q) => s + q[0], 0) / 4 - ax;
|
|
3628
|
+
const mz = m.reduce((s, q) => s + q[2], 0) / 4 - az;
|
|
3629
|
+
face(a, b, c, [mx, 0, mz]);
|
|
3630
|
+
face(a, c, d, [mx, 0, mz]);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
return { positions, indices };
|
|
3634
|
+
}
|
|
3301
3635
|
var MIN_PART_MM = 1;
|
|
3302
3636
|
function t0LocalParts(family, W, D) {
|
|
3303
3637
|
const gen = GENERATORS[family];
|
|
@@ -3571,7 +3905,7 @@ function floorLifts(floors, overlaps) {
|
|
|
3571
3905
|
}
|
|
3572
3906
|
|
|
3573
3907
|
// package.json
|
|
3574
|
-
var version = "0.
|
|
3908
|
+
var version = "0.8.0";
|
|
3575
3909
|
|
|
3576
3910
|
// src/scene3d/build.ts
|
|
3577
3911
|
import * as core2 from "@chanmeng666/archlang";
|
|
@@ -3628,7 +3962,14 @@ var box = (e) => ({
|
|
|
3628
3962
|
});
|
|
3629
3963
|
function floorOf(r, tol) {
|
|
3630
3964
|
const outer = r.circle ? circleRing(r.circle.c, r.circle.r, tol) : r.poly ?? rectRing(r.at, r.size);
|
|
3631
|
-
return {
|
|
3965
|
+
return {
|
|
3966
|
+
id: r.id,
|
|
3967
|
+
source: source(r),
|
|
3968
|
+
polygon: polygon(outer),
|
|
3969
|
+
...r.uses?.length ? { uses: [...r.uses] } : {},
|
|
3970
|
+
// The author's `floor` word (card RM8.7): a public, non-underscore field of `RRoom` (ADR 0031).
|
|
3971
|
+
...r.floor !== void 0 ? { pattern: r.floor } : {}
|
|
3972
|
+
};
|
|
3632
3973
|
}
|
|
3633
3974
|
function furnitureOf(f, mirrored, ledger) {
|
|
3634
3975
|
const rotate = f.rotate ?? 0;
|
|
@@ -3676,7 +4017,7 @@ var fenceOf = (f) => ({
|
|
|
3676
4017
|
closed: f.closed
|
|
3677
4018
|
});
|
|
3678
4019
|
var OPPOSITE = { top: "bottom", bottom: "top", left: "right", right: "left" };
|
|
3679
|
-
function stairPieces(s) {
|
|
4020
|
+
function stairPieces(s, ledger) {
|
|
3680
4021
|
const treadCount3 = core2.treadCount;
|
|
3681
4022
|
if (typeof treadCount3 !== "function") return void 0;
|
|
3682
4023
|
const flight = (at, size, tail2) => ({
|
|
@@ -3686,22 +4027,95 @@ function stairPieces(s) {
|
|
|
3686
4027
|
treads: treadCount3(tail2 === "top" || tail2 === "bottom" ? size.h : size.w)
|
|
3687
4028
|
});
|
|
3688
4029
|
if (s.flights && s.landings) {
|
|
4030
|
+
const flights = s.flights;
|
|
3689
4031
|
return {
|
|
3690
|
-
flights:
|
|
3691
|
-
landings: s.landings.map((l) =>
|
|
4032
|
+
flights: flights.map((f) => flight(f.at, f.size, f.tail)),
|
|
4033
|
+
landings: s.landings.map((l, i) => {
|
|
4034
|
+
const winders = winderRings(s.id, i, l, flights[i], flights[i + 1], ledger);
|
|
4035
|
+
return { at: umPoint(l.at), size: { w: um2(l.size.w), h: um2(l.size.h) }, ...winders ? { winders } : {} };
|
|
4036
|
+
})
|
|
3692
4037
|
};
|
|
3693
4038
|
}
|
|
3694
4039
|
const tail = entryEdges(s)[0];
|
|
3695
4040
|
return tail ? { flights: [flight(s.at, s.size, tail)], landings: [] } : void 0;
|
|
3696
4041
|
}
|
|
3697
|
-
var stairOf = (s) => ({
|
|
4042
|
+
var stairOf = (s, ledger) => ({
|
|
3698
4043
|
id: s.id,
|
|
3699
4044
|
source: source(s),
|
|
3700
4045
|
box: box(s),
|
|
3701
4046
|
dir: s.dir,
|
|
3702
4047
|
width: um2(s.width),
|
|
3703
|
-
...stairPieces(s)
|
|
4048
|
+
...stairPieces(s, ledger)
|
|
4049
|
+
});
|
|
4050
|
+
var rectOf = (p) => ({
|
|
4051
|
+
x: p.at.x,
|
|
4052
|
+
y: p.at.y,
|
|
4053
|
+
w: p.size.w,
|
|
4054
|
+
h: p.size.h
|
|
3704
4055
|
});
|
|
4056
|
+
function winderRings(id2, i, l, before, after, ledger) {
|
|
4057
|
+
if (l.winders === void 0) return void 0;
|
|
4058
|
+
const lines = core2.winderTreads;
|
|
4059
|
+
const rings = typeof lines === "function" && before && after ? treadRings(l, before, lines(l, rectOf(before), rectOf(after))) : void 0;
|
|
4060
|
+
if (!rings)
|
|
4061
|
+
ledger.push({
|
|
4062
|
+
kind: "stair",
|
|
4063
|
+
id: id2,
|
|
4064
|
+
field: `winders(landing ${i + 1})`,
|
|
4065
|
+
value: "level",
|
|
4066
|
+
provenance: "default",
|
|
4067
|
+
rule: "stair-winders-not-read"
|
|
4068
|
+
});
|
|
4069
|
+
return rings;
|
|
4070
|
+
}
|
|
4071
|
+
var NEAR_MM = 1e-6;
|
|
4072
|
+
function treadRings(l, before, lines) {
|
|
4073
|
+
const n = l.winders;
|
|
4074
|
+
if (n === void 0) return void 0;
|
|
4075
|
+
const near = (a, b) => Math.abs(a - b) <= NEAR_MM;
|
|
4076
|
+
const [x0, y0] = [l.at.x, l.at.y];
|
|
4077
|
+
const [x1, y1] = [x0 + l.size.w, y0 + l.size.h];
|
|
4078
|
+
const inside = (p) => p.x >= x0 - NEAR_MM && p.x <= x1 + NEAR_MM && p.y >= y0 - NEAR_MM && p.y <= y1 + NEAR_MM;
|
|
4079
|
+
const [bx0, by0, bx1, by1] = [before.at.x, before.at.y, before.at.x + before.size.w, before.at.y + before.size.h];
|
|
4080
|
+
const against = (ax, ay, bx, by) => ay === by ? (near(by0, ay) || near(by1, ay)) && bx0 < Math.max(ax, bx) - NEAR_MM && bx1 > Math.min(ax, bx) + NEAR_MM : (near(bx0, ax) || near(bx1, ax)) && by0 < Math.max(ay, by) - NEAR_MM && by1 > Math.min(ay, by) + NEAR_MM;
|
|
4081
|
+
const fans = [
|
|
4082
|
+
[x0, y0],
|
|
4083
|
+
[x1, y0],
|
|
4084
|
+
[x1, y1],
|
|
4085
|
+
[x0, y1]
|
|
4086
|
+
].flatMap(([cx, cy]) => {
|
|
4087
|
+
const [ox2, oy2] = [near(cx, x0) ? x1 : x0, near(cy, y0) ? y1 : y0];
|
|
4088
|
+
const alongX2 = against(cx, cy, ox2, cy);
|
|
4089
|
+
if (!alongX2 && !against(cx, cy, cx, oy2)) return [];
|
|
4090
|
+
const ends2 = lines.flatMap(([a, b]) => {
|
|
4091
|
+
for (const [p, q] of [
|
|
4092
|
+
[a, b],
|
|
4093
|
+
[b, a]
|
|
4094
|
+
])
|
|
4095
|
+
if (near(p.x, cx) && near(p.y, cy) && inside(q) && (near(q.x, ox2) || near(q.y, oy2))) return [q];
|
|
4096
|
+
return [];
|
|
4097
|
+
});
|
|
4098
|
+
return ends2.length === n - 1 ? [{ c: { x: cx, y: cy }, ox: ox2, oy: oy2, alongX: alongX2, ends: ends2 }] : [];
|
|
4099
|
+
});
|
|
4100
|
+
const fan = fans[0];
|
|
4101
|
+
if (fans.length !== 1 || !fan) return void 0;
|
|
4102
|
+
const { c, ox, oy, alongX } = fan;
|
|
4103
|
+
const entry = alongX ? { x: ox, y: c.y } : { x: c.x, y: oy };
|
|
4104
|
+
const exit = alongX ? { x: c.x, y: oy } : { x: ox, y: c.y };
|
|
4105
|
+
const [ux, uy] = [entry.x - c.x, entry.y - c.y];
|
|
4106
|
+
const angle = (p) => {
|
|
4107
|
+
const [vx, vy] = [p.x - c.x, p.y - c.y];
|
|
4108
|
+
return Math.atan2(Math.abs(ux * vy - uy * vx), ux * vx + uy * vy);
|
|
4109
|
+
};
|
|
4110
|
+
const ends = [entry, ...[...fan.ends].sort((a, b) => angle(a) - angle(b)), exit];
|
|
4111
|
+
const onX = (p) => near(p.x, ox);
|
|
4112
|
+
const onY = (p) => near(p.y, oy);
|
|
4113
|
+
return Array.from({ length: n }, (_, k) => {
|
|
4114
|
+
const [a, b] = [ends[k], ends[k + 1]];
|
|
4115
|
+
const far = !(onX(a) && onX(b)) && !(onY(a) && onY(b));
|
|
4116
|
+
return [c, a, ...far ? [{ x: ox, y: oy }] : [], b].map(umPoint);
|
|
4117
|
+
});
|
|
4118
|
+
}
|
|
3705
4119
|
function wallsAndOpenings(ir, byId, tol) {
|
|
3706
4120
|
const own = wallOwnership(ir.walls, (loops) => tessellateLoops(loops, tol));
|
|
3707
4121
|
const cutsOf = /* @__PURE__ */ new Map();
|
|
@@ -3864,7 +4278,7 @@ function levelOf(s, ledger, tol, mirrored) {
|
|
|
3864
4278
|
...demolished.length > 0 ? { demolished } : {},
|
|
3865
4279
|
openings,
|
|
3866
4280
|
furniture: of("furniture").map((f) => furnitureOf(f, mirrored, ledger)),
|
|
3867
|
-
stairs: of("stair").map(stairOf),
|
|
4281
|
+
stairs: of("stair").map((st) => stairOf(st, ledger)),
|
|
3868
4282
|
// A core `void … polygon` (an L) carries the rectangles its hole is made of (`parts`): each is
|
|
3869
4283
|
// one box, ids `<id>#<k>` (unique per collection), `source` still naming the void.
|
|
3870
4284
|
voids: of("void").flatMap(
|
|
@@ -3985,7 +4399,7 @@ var wall = object(
|
|
|
3985
4399
|
{ category: string, material: string }
|
|
3986
4400
|
);
|
|
3987
4401
|
var LEVEL_COLLECTIONS = {
|
|
3988
|
-
floors: array(object({ id, source: source2, polygon: polygon2 }, { uses: array(string), lift: integer })),
|
|
4402
|
+
floors: array(object({ id, source: source2, polygon: polygon2 }, { uses: array(string), pattern: string, lift: integer })),
|
|
3989
4403
|
walls: array(wall),
|
|
3990
4404
|
openings: array(
|
|
3991
4405
|
object(
|
|
@@ -4029,7 +4443,7 @@ var LEVEL_COLLECTIONS = {
|
|
|
4029
4443
|
}),
|
|
4030
4444
|
1
|
|
4031
4445
|
),
|
|
4032
|
-
landings: array(object({ at: pt, size: sized("w", "h") }))
|
|
4446
|
+
landings: array(object({ at: pt, size: sized("w", "h") }, { winders: array(ring2, 2) }))
|
|
4033
4447
|
}
|
|
4034
4448
|
)
|
|
4035
4449
|
),
|
|
@@ -4143,6 +4557,7 @@ export {
|
|
|
4143
4557
|
T0_HEIGHT_MM,
|
|
4144
4558
|
T0_MOUNT_MM,
|
|
4145
4559
|
T0_HUNG_FROM_TOP,
|
|
4560
|
+
T0_DEFAULTS,
|
|
4146
4561
|
isHung,
|
|
4147
4562
|
T0_HANDED,
|
|
4148
4563
|
handedAt,
|