@adatechnology/game-items-three 0.11.7 → 0.11.8
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/dist/index.global.js +1125 -91
- package/dist/index.global.js.map +1 -1
- package/package.json +15 -15
package/dist/index.global.js
CHANGED
|
@@ -11742,7 +11742,7 @@ var GameItemsThree = (() => {
|
|
|
11742
11742
|
if (isOpen) for (const s of [-1, 1]) K.box("fabric", s * (w / 2 - pw * 0.25), y + h * 0.4, 0.04, pw * 0.5, 0.05, 0.02, shade2(color2, 0.7));
|
|
11743
11743
|
};
|
|
11744
11744
|
B.blinds = (M, a) => {
|
|
11745
|
-
const K = kit(M, a), { w, h } = K.dim("blinds"), y = M.y || 1, retract = M.retracted != null ? M.retracted : 0.15,
|
|
11745
|
+
const K = kit(M, a), { w, h } = K.dim("blinds"), y = M.y || 1, retract = M.retracted != null ? M.retracted : 0.15, isWood2 = M.variant === "wood", color2 = isWood2 ? K.wood(10123858) : K.color("wall_living", 15262420), mat = isWood2 ? "wood" : "plain", yb = y + h * retract, n = Math.floor((y + h - yb) / 0.055);
|
|
11746
11746
|
K.box("plain", 0, y + h - 0.05, 0, w, 0.05, 0.06, 14473424);
|
|
11747
11747
|
for (let i = 0; i < n; i++) K.box(mat, 0, y + h - 0.06 - (i + 1) * 0.055, 0, w - 0.05, 0.01, 0.035, color2, 0, 0.3);
|
|
11748
11748
|
for (const s of [-1, 1]) K.box("plain", s * (w / 2 - 0.05), yb, 0.02, 8e-3, y + h - 0.05 - yb, 8e-3, 12104876);
|
|
@@ -14790,6 +14790,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14790
14790
|
tension: {
|
|
14791
14791
|
elasticGPa: 200,
|
|
14792
14792
|
ultimateMPa: 400
|
|
14793
|
+
},
|
|
14794
|
+
elastic: {
|
|
14795
|
+
alongGPa: 200,
|
|
14796
|
+
shearGPa: 77
|
|
14793
14797
|
}
|
|
14794
14798
|
},
|
|
14795
14799
|
{
|
|
@@ -14828,7 +14832,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14828
14832
|
elasticGPa: 200,
|
|
14829
14833
|
absorbed: 0.2
|
|
14830
14834
|
},
|
|
14831
|
-
failureMPa: 1400
|
|
14835
|
+
failureMPa: 1400,
|
|
14836
|
+
elastic: {
|
|
14837
|
+
alongGPa: 200,
|
|
14838
|
+
shearGPa: 77
|
|
14839
|
+
}
|
|
14832
14840
|
},
|
|
14833
14841
|
{
|
|
14834
14842
|
id: "cast_iron",
|
|
@@ -14899,6 +14907,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14899
14907
|
tension: {
|
|
14900
14908
|
elasticGPa: 69,
|
|
14901
14909
|
ultimateMPa: 170
|
|
14910
|
+
},
|
|
14911
|
+
elastic: {
|
|
14912
|
+
alongGPa: 69,
|
|
14913
|
+
shearGPa: 26
|
|
14902
14914
|
}
|
|
14903
14915
|
},
|
|
14904
14916
|
{
|
|
@@ -14981,7 +14993,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14981
14993
|
tearJoules: 60
|
|
14982
14994
|
}
|
|
14983
14995
|
},
|
|
14984
|
-
failureMPa: 40
|
|
14996
|
+
failureMPa: 40,
|
|
14997
|
+
elastic: {
|
|
14998
|
+
alongGPa: 12.3,
|
|
14999
|
+
acrossGPa: 1.17,
|
|
15000
|
+
shearGPa: 1
|
|
15001
|
+
}
|
|
14985
15002
|
},
|
|
14986
15003
|
{
|
|
14987
15004
|
id: "wood_hard",
|
|
@@ -15032,7 +15049,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15032
15049
|
elasticGPa: 12,
|
|
15033
15050
|
absorbed: 0.3
|
|
15034
15051
|
},
|
|
15035
|
-
failureMPa: 80
|
|
15052
|
+
failureMPa: 80,
|
|
15053
|
+
elastic: {
|
|
15054
|
+
alongGPa: 12,
|
|
15055
|
+
acrossGPa: 1.42,
|
|
15056
|
+
shearGPa: 1.02
|
|
15057
|
+
}
|
|
15036
15058
|
},
|
|
15037
15059
|
{
|
|
15038
15060
|
id: "plywood",
|
|
@@ -15164,7 +15186,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15164
15186
|
"brittle"
|
|
15165
15187
|
],
|
|
15166
15188
|
compressive: 1e5,
|
|
15167
|
-
failureMPa: 45
|
|
15189
|
+
failureMPa: 45,
|
|
15190
|
+
elastic: {
|
|
15191
|
+
alongGPa: 70,
|
|
15192
|
+
shearGPa: 29
|
|
15193
|
+
}
|
|
15168
15194
|
},
|
|
15169
15195
|
{
|
|
15170
15196
|
id: "tempered_glass",
|
|
@@ -15199,7 +15225,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15199
15225
|
damageScale: {
|
|
15200
15226
|
shelter: 3
|
|
15201
15227
|
},
|
|
15202
|
-
failureMPa: 120
|
|
15228
|
+
failureMPa: 120,
|
|
15229
|
+
elastic: {
|
|
15230
|
+
alongGPa: 70,
|
|
15231
|
+
shearGPa: 29
|
|
15232
|
+
}
|
|
15203
15233
|
},
|
|
15204
15234
|
{
|
|
15205
15235
|
id: "ceramic",
|
|
@@ -16255,6 +16285,828 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16255
16285
|
if (ductility >= 0.3) return 1;
|
|
16256
16286
|
return (1 + 4 * (0.3 - ductility) / 0.3) * Math.min(25, Math.max(1, (0.02 / Math.max(thickness, 1e-4)) ** 2));
|
|
16257
16287
|
};
|
|
16288
|
+
var EPS2 = 1e-9;
|
|
16289
|
+
var rotateVecInto = (q, v, out) => {
|
|
16290
|
+
const qx = q[0], qy = q[1], qz = q[2], qw = q[3];
|
|
16291
|
+
const tx = 2 * (qy * v[2] - qz * v[1]);
|
|
16292
|
+
const ty = 2 * (qz * v[0] - qx * v[2]);
|
|
16293
|
+
const tz = 2 * (qx * v[1] - qy * v[0]);
|
|
16294
|
+
const x = v[0] + qw * tx + (qy * tz - qz * ty);
|
|
16295
|
+
const y = v[1] + qw * ty + (qz * tx - qx * tz);
|
|
16296
|
+
const z = v[2] + qw * tz + (qx * ty - qy * tx);
|
|
16297
|
+
out[0] = x;
|
|
16298
|
+
out[1] = y;
|
|
16299
|
+
out[2] = z;
|
|
16300
|
+
return out;
|
|
16301
|
+
};
|
|
16302
|
+
var normalizeInto = (x, y, z, out, fx, fy, fz) => {
|
|
16303
|
+
const l = Math.sqrt(x * x + y * y + z * z);
|
|
16304
|
+
if (l < EPS2) {
|
|
16305
|
+
out[0] = fx;
|
|
16306
|
+
out[1] = fy;
|
|
16307
|
+
out[2] = fz;
|
|
16308
|
+
return;
|
|
16309
|
+
}
|
|
16310
|
+
out[0] = x / l;
|
|
16311
|
+
out[1] = y / l;
|
|
16312
|
+
out[2] = z / l;
|
|
16313
|
+
};
|
|
16314
|
+
var boxInto = (size, o, d, out) => {
|
|
16315
|
+
let tmin = -Infinity, tmax = Infinity;
|
|
16316
|
+
let a0 = 0, s0 = 1;
|
|
16317
|
+
for (let i = 0; i < 3; i++) {
|
|
16318
|
+
const h = size[i] / 2;
|
|
16319
|
+
if (Math.abs(d[i]) < EPS2) {
|
|
16320
|
+
if (Math.abs(o[i]) > h) return false;
|
|
16321
|
+
continue;
|
|
16322
|
+
}
|
|
16323
|
+
let ta = (-h - o[i]) / d[i];
|
|
16324
|
+
let tb = (h - o[i]) / d[i];
|
|
16325
|
+
let sa = -1;
|
|
16326
|
+
if (ta > tb) {
|
|
16327
|
+
const t = ta;
|
|
16328
|
+
ta = tb;
|
|
16329
|
+
tb = t;
|
|
16330
|
+
sa = 1;
|
|
16331
|
+
}
|
|
16332
|
+
if (ta > tmin) {
|
|
16333
|
+
tmin = ta;
|
|
16334
|
+
a0 = i;
|
|
16335
|
+
s0 = sa;
|
|
16336
|
+
}
|
|
16337
|
+
if (tb < tmax) tmax = tb;
|
|
16338
|
+
if (tmin > tmax) return false;
|
|
16339
|
+
}
|
|
16340
|
+
if (tmax < 0 || !Number.isFinite(tmin) || !Number.isFinite(tmax)) return false;
|
|
16341
|
+
out.t0 = tmin;
|
|
16342
|
+
out.t1 = tmax;
|
|
16343
|
+
out.n0[0] = 0;
|
|
16344
|
+
out.n0[1] = 0;
|
|
16345
|
+
out.n0[2] = 0;
|
|
16346
|
+
out.n0[a0] = s0;
|
|
16347
|
+
return true;
|
|
16348
|
+
};
|
|
16349
|
+
var sphereInto = (radius, o, d, out) => {
|
|
16350
|
+
const b = o[0] * d[0] + o[1] * d[1] + o[2] * d[2];
|
|
16351
|
+
const a = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
|
|
16352
|
+
const c = o[0] * o[0] + o[1] * o[1] + o[2] * o[2] - radius * radius;
|
|
16353
|
+
const disc = b * b - a * c;
|
|
16354
|
+
if (disc < 0) return false;
|
|
16355
|
+
const sq = Math.sqrt(disc);
|
|
16356
|
+
const t0 = (-b - sq) / a;
|
|
16357
|
+
const t1 = (-b + sq) / a;
|
|
16358
|
+
if (t1 < 0) return false;
|
|
16359
|
+
out.t0 = t0;
|
|
16360
|
+
out.t1 = t1;
|
|
16361
|
+
normalizeInto(o[0] + d[0] * t0, o[1] + d[1] * t0, o[2] + d[2] * t0, out.n0, 0, 1, 0);
|
|
16362
|
+
return true;
|
|
16363
|
+
};
|
|
16364
|
+
var cylinderInto = (radius, height, o, d, out) => {
|
|
16365
|
+
const hh = height / 2;
|
|
16366
|
+
const a = d[0] * d[0] + d[2] * d[2];
|
|
16367
|
+
const c = o[0] * o[0] + o[2] * o[2] - radius * radius;
|
|
16368
|
+
let tA = -Infinity, tB = Infinity;
|
|
16369
|
+
if (a > EPS2) {
|
|
16370
|
+
const b = o[0] * d[0] + o[2] * d[2];
|
|
16371
|
+
const disc = b * b - a * c;
|
|
16372
|
+
if (disc < 0) return false;
|
|
16373
|
+
const sq = Math.sqrt(disc);
|
|
16374
|
+
tA = (-b - sq) / a;
|
|
16375
|
+
tB = (-b + sq) / a;
|
|
16376
|
+
} else if (c > 0) return false;
|
|
16377
|
+
let yA = -Infinity, yB = Infinity;
|
|
16378
|
+
if (Math.abs(d[1]) > EPS2) {
|
|
16379
|
+
yA = (-hh - o[1]) / d[1];
|
|
16380
|
+
yB = (hh - o[1]) / d[1];
|
|
16381
|
+
if (yA > yB) {
|
|
16382
|
+
const t = yA;
|
|
16383
|
+
yA = yB;
|
|
16384
|
+
yB = t;
|
|
16385
|
+
}
|
|
16386
|
+
} else if (Math.abs(o[1]) > hh) return false;
|
|
16387
|
+
const t0 = Math.max(tA, yA);
|
|
16388
|
+
const t1 = Math.min(tB, yB);
|
|
16389
|
+
if (t0 > t1 || t1 < 0 || !Number.isFinite(t0) || !Number.isFinite(t1)) return false;
|
|
16390
|
+
out.t0 = t0;
|
|
16391
|
+
out.t1 = t1;
|
|
16392
|
+
if (tA >= yA) normalizeInto(o[0] + d[0] * t0, 0, o[2] + d[2] * t0, out.n0, 1, 0, 0);
|
|
16393
|
+
else {
|
|
16394
|
+
out.n0[0] = 0;
|
|
16395
|
+
out.n0[1] = d[1] > 0 ? -1 : 1;
|
|
16396
|
+
out.n0[2] = 0;
|
|
16397
|
+
}
|
|
16398
|
+
return true;
|
|
16399
|
+
};
|
|
16400
|
+
var rayShapeInto = (s, o, d, out) => {
|
|
16401
|
+
if (s.kind === "box") return boxInto(s.size, o, d, out);
|
|
16402
|
+
if (s.kind === "sphere") return sphereInto(s.radius, o, d, out);
|
|
16403
|
+
return cylinderInto(s.radius, s.height, o, d, out);
|
|
16404
|
+
};
|
|
16405
|
+
var JOINT_FASTENERS = {
|
|
16406
|
+
screw: { diameterMm: 4.5, lateral: "predrilled", spacing: 0.2 },
|
|
16407
|
+
bolt: { diameterMm: 8, lateral: "predrilled", spacing: 0.2 },
|
|
16408
|
+
nail: { diameterMm: 3, lateral: "driven", spacing: 0.15 }
|
|
16409
|
+
};
|
|
16410
|
+
var RIGID_KINDS = /* @__PURE__ */ new Set(["glue", "weld", "fused", "mortar", "rebar"]);
|
|
16411
|
+
var RIGID_PUSH = 1e10;
|
|
16412
|
+
var RIGID_TURN = 1e8;
|
|
16413
|
+
var TOUCH = 0.01;
|
|
16414
|
+
var FOOT_BAND = 0.03;
|
|
16415
|
+
var SEAM_STATIONS = 5;
|
|
16416
|
+
var BEAM_PIECES = 4;
|
|
16417
|
+
var SLENDER = 4;
|
|
16418
|
+
var MAX_DOF = 1500;
|
|
16419
|
+
var MECHANISM = 0.5;
|
|
16420
|
+
var FOOT_FRICTION = 0.4;
|
|
16421
|
+
var UPRIGHT = 0.9;
|
|
16422
|
+
var SOFT = 1e-11;
|
|
16423
|
+
var GRAVITY2 = 9.81;
|
|
16424
|
+
var EDGE_D = 4;
|
|
16425
|
+
var ROW_D = 5;
|
|
16426
|
+
var END_D = 10;
|
|
16427
|
+
var THREAD_D = 6;
|
|
16428
|
+
var isWood = (m) => !!m.tags && m.tags.includes("wood");
|
|
16429
|
+
function fastenerStiffness(kind, a, b) {
|
|
16430
|
+
const f = JOINT_FASTENERS[kind];
|
|
16431
|
+
if (!f) return null;
|
|
16432
|
+
const woods = [a, b].filter(isWood);
|
|
16433
|
+
if (woods.length === 0) return null;
|
|
16434
|
+
const density = woods.length === 2 ? Math.sqrt(a.density * b.density) : woods[0].density;
|
|
16435
|
+
const d = f.diameterMm;
|
|
16436
|
+
const perMm = f.lateral === "predrilled" ? density ** 1.5 * d / 23 : density ** 1.5 * d ** 0.8 / 30;
|
|
16437
|
+
const lateral = perMm * 1e3 * (woods.length === 1 ? 2 : 1);
|
|
16438
|
+
const axial = kind === "screw" ? 234 * (density * d) ** 0.2 * (THREAD_D * d) ** 0.4 * 1e3 : lateral;
|
|
16439
|
+
return { lateral, axial, diameter: d / 1e3, spacing: f.spacing };
|
|
16440
|
+
}
|
|
16441
|
+
function torsionConstant(side, other) {
|
|
16442
|
+
const b = Math.max(side, other);
|
|
16443
|
+
const t = Math.min(side, other);
|
|
16444
|
+
if (b <= 0) return 0;
|
|
16445
|
+
const r = t / b;
|
|
16446
|
+
return b * t ** 3 * (1 / 3 - 0.21 * r * (1 - r ** 4 / 12));
|
|
16447
|
+
}
|
|
16448
|
+
var AXES = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
16449
|
+
function beamOf(part) {
|
|
16450
|
+
const d = part.dims;
|
|
16451
|
+
let a = 0;
|
|
16452
|
+
if (d[1] > d[a]) a = 1;
|
|
16453
|
+
if (d[2] > d[a]) a = 2;
|
|
16454
|
+
const ui = (a + 1) % 3;
|
|
16455
|
+
const vi = (a + 2) % 3;
|
|
16456
|
+
const axis = rotateVec(part.rotation, AXES[a]);
|
|
16457
|
+
const u = rotateVec(part.rotation, AXES[ui]);
|
|
16458
|
+
const v = rotateVec(part.rotation, AXES[vi]);
|
|
16459
|
+
const min = [Infinity, Infinity, Infinity];
|
|
16460
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
16461
|
+
for (let i = 0; i < 8; i++) {
|
|
16462
|
+
const c = cornerOf(part, i);
|
|
16463
|
+
for (let k = 0; k < 3; k++) {
|
|
16464
|
+
min[k] = Math.min(min[k], c[k]);
|
|
16465
|
+
max[k] = Math.max(max[k], c[k]);
|
|
16466
|
+
}
|
|
16467
|
+
}
|
|
16468
|
+
return { part, axis, u, v, length: d[a], stations: [], nodes: [], min, max };
|
|
16469
|
+
}
|
|
16470
|
+
function cornerOf(part, i) {
|
|
16471
|
+
const d = part.dims;
|
|
16472
|
+
const local = [(i & 1 ? 0.5 : -0.5) * d[0], (i & 2 ? 0.5 : -0.5) * d[1], (i & 4 ? 0.5 : -0.5) * d[2]];
|
|
16473
|
+
return vec.add(part.position, rotateVec(part.rotation, local));
|
|
16474
|
+
}
|
|
16475
|
+
function sectionOf(beam) {
|
|
16476
|
+
const elastic = beam.part.material.elastic;
|
|
16477
|
+
if (!elastic) return null;
|
|
16478
|
+
const d = beam.part.dims;
|
|
16479
|
+
let a = 0;
|
|
16480
|
+
if (d[1] > d[a]) a = 1;
|
|
16481
|
+
if (d[2] > d[a]) a = 2;
|
|
16482
|
+
const du = d[(a + 1) % 3];
|
|
16483
|
+
const dv = d[(a + 2) % 3];
|
|
16484
|
+
const along2 = beam.part.grain === void 0 || beam.part.grain === a;
|
|
16485
|
+
const e = (along2 ? elastic.alongGPa : elastic.acrossGPa ?? elastic.alongGPa) * 1e9;
|
|
16486
|
+
const g = elastic.shearGPa * 1e9;
|
|
16487
|
+
if (beam.part.round && a === 1) {
|
|
16488
|
+
const r = du / 2;
|
|
16489
|
+
const i = Math.PI * r ** 4 / 4;
|
|
16490
|
+
return { area: Math.PI * r * r, iu: i, iv: i, j: 2 * i, e, g };
|
|
16491
|
+
}
|
|
16492
|
+
return { area: du * dv, iu: du * dv ** 3 / 12, iv: dv * du ** 3 / 12, j: torsionConstant(du, dv), e, g };
|
|
16493
|
+
}
|
|
16494
|
+
function beamLocal(s, length) {
|
|
16495
|
+
const k = new Float64Array(144);
|
|
16496
|
+
const set = (i, j, value) => {
|
|
16497
|
+
k[i * 12 + j] = value;
|
|
16498
|
+
k[j * 12 + i] = value;
|
|
16499
|
+
};
|
|
16500
|
+
const L = length;
|
|
16501
|
+
const ea = s.e * s.area / L;
|
|
16502
|
+
const gj = s.g * s.j / L;
|
|
16503
|
+
const z = s.e * s.iv;
|
|
16504
|
+
const y = s.e * s.iu;
|
|
16505
|
+
set(0, 0, ea);
|
|
16506
|
+
set(0, 6, -ea);
|
|
16507
|
+
set(6, 6, ea);
|
|
16508
|
+
set(3, 3, gj);
|
|
16509
|
+
set(3, 9, -gj);
|
|
16510
|
+
set(9, 9, gj);
|
|
16511
|
+
set(1, 1, 12 * z / L ** 3);
|
|
16512
|
+
set(1, 5, 6 * z / L ** 2);
|
|
16513
|
+
set(1, 7, -12 * z / L ** 3);
|
|
16514
|
+
set(1, 11, 6 * z / L ** 2);
|
|
16515
|
+
set(5, 5, 4 * z / L);
|
|
16516
|
+
set(5, 7, -6 * z / L ** 2);
|
|
16517
|
+
set(5, 11, 2 * z / L);
|
|
16518
|
+
set(7, 7, 12 * z / L ** 3);
|
|
16519
|
+
set(7, 11, -6 * z / L ** 2);
|
|
16520
|
+
set(11, 11, 4 * z / L);
|
|
16521
|
+
set(2, 2, 12 * y / L ** 3);
|
|
16522
|
+
set(2, 4, -6 * y / L ** 2);
|
|
16523
|
+
set(2, 8, -12 * y / L ** 3);
|
|
16524
|
+
set(2, 10, -6 * y / L ** 2);
|
|
16525
|
+
set(4, 4, 4 * y / L);
|
|
16526
|
+
set(4, 8, 6 * y / L ** 2);
|
|
16527
|
+
set(4, 10, 2 * y / L);
|
|
16528
|
+
set(8, 8, 12 * y / L ** 3);
|
|
16529
|
+
set(8, 10, 6 * y / L ** 2);
|
|
16530
|
+
set(10, 10, 4 * y / L);
|
|
16531
|
+
return k;
|
|
16532
|
+
}
|
|
16533
|
+
function toObjectFrame(k, n, x, y, z) {
|
|
16534
|
+
const r = [x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]];
|
|
16535
|
+
const half = new Float64Array(n * n);
|
|
16536
|
+
const out = new Float64Array(n * n);
|
|
16537
|
+
for (let block = 0; block < n; block += 3) {
|
|
16538
|
+
for (let col = 0; col < n; col++) {
|
|
16539
|
+
for (let i = 0; i < 3; i++) {
|
|
16540
|
+
let sum = 0;
|
|
16541
|
+
for (let m = 0; m < 3; m++) sum += r[i * 3 + m] * k[(block + m) * n + col];
|
|
16542
|
+
half[(block + i) * n + col] = sum;
|
|
16543
|
+
}
|
|
16544
|
+
}
|
|
16545
|
+
}
|
|
16546
|
+
for (let row = 0; row < n; row++) {
|
|
16547
|
+
for (let block = 0; block < n; block += 3) {
|
|
16548
|
+
for (let i = 0; i < 3; i++) {
|
|
16549
|
+
let sum = 0;
|
|
16550
|
+
for (let m = 0; m < 3; m++) sum += half[row * n + block + m] * r[i * 3 + m];
|
|
16551
|
+
out[row * n + block + i] = sum;
|
|
16552
|
+
}
|
|
16553
|
+
}
|
|
16554
|
+
}
|
|
16555
|
+
return out;
|
|
16556
|
+
}
|
|
16557
|
+
function armRows(arm) {
|
|
16558
|
+
const [x, y, z] = arm;
|
|
16559
|
+
return [
|
|
16560
|
+
[1, 0, 0, 0, z, -y],
|
|
16561
|
+
[0, 1, 0, -z, 0, x],
|
|
16562
|
+
[0, 0, 1, y, -x, 0]
|
|
16563
|
+
];
|
|
16564
|
+
}
|
|
16565
|
+
function stationsOf(joint, a, b) {
|
|
16566
|
+
const lo = [0, 0, 0];
|
|
16567
|
+
const hi = [0, 0, 0];
|
|
16568
|
+
let touching = true;
|
|
16569
|
+
for (let k = 0; k < 3; k++) {
|
|
16570
|
+
lo[k] = Math.max(a.min[k], b.min[k]);
|
|
16571
|
+
hi[k] = Math.min(a.max[k], b.max[k]);
|
|
16572
|
+
if (hi[k] < lo[k] - TOUCH) touching = false;
|
|
16573
|
+
}
|
|
16574
|
+
const rigid = RIGID_KINDS.has(joint.kind);
|
|
16575
|
+
const fastener = rigid ? null : fastenerStiffness(joint.kind, a.part.material, b.part.material);
|
|
16576
|
+
const stiff = rigid || !fastener && JOINT_FASTENERS[joint.kind] !== void 0;
|
|
16577
|
+
if (!stiff && !fastener) return [];
|
|
16578
|
+
if (!touching) {
|
|
16579
|
+
const frame3 = [[0, 1, 0], [1, 0, 0], [0, 0, 1]];
|
|
16580
|
+
if (stiff || !fastener) return [{ at: joint.position, frame: frame3, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] }];
|
|
16581
|
+
return [{ at: joint.position, frame: frame3, push: [fastener.axial, fastener.lateral, fastener.lateral], turn: [0, 0, 0] }];
|
|
16582
|
+
}
|
|
16583
|
+
const size = [Math.max(0, hi[0] - lo[0]), Math.max(0, hi[1] - lo[1]), Math.max(0, hi[2] - lo[2])];
|
|
16584
|
+
const middle = [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2];
|
|
16585
|
+
let n = 0;
|
|
16586
|
+
if (size[1] < size[n]) n = 1;
|
|
16587
|
+
if (size[2] < size[n]) n = 2;
|
|
16588
|
+
let w = (n + 1) % 3;
|
|
16589
|
+
let c = (n + 2) % 3;
|
|
16590
|
+
if (size[c] > size[w]) [w, c] = [c, w];
|
|
16591
|
+
const frame2 = [AXES[n], AXES[w], AXES[c]];
|
|
16592
|
+
const along2 = size[w];
|
|
16593
|
+
const across2 = size[c];
|
|
16594
|
+
const d = fastener?.diameter ?? 5e-3;
|
|
16595
|
+
const spacing = fastener?.spacing ?? 0.2;
|
|
16596
|
+
const end = END_D * d;
|
|
16597
|
+
const count = along2 > 2 * end ? 1 + Math.ceil((along2 - 2 * end) / spacing) : 1;
|
|
16598
|
+
const stations = Math.min(count, SEAM_STATIONS);
|
|
16599
|
+
const each = count / stations;
|
|
16600
|
+
const out = [];
|
|
16601
|
+
for (let s = 0; s < stations; s++) {
|
|
16602
|
+
const t = stations === 1 ? 0 : -along2 / 2 + end + (along2 - 2 * end) * s / (stations - 1);
|
|
16603
|
+
const at2 = [middle[0], middle[1], middle[2]];
|
|
16604
|
+
at2[w] = middle[w] + t;
|
|
16605
|
+
if (stiff || !fastener) {
|
|
16606
|
+
out.push({ at: at2, frame: frame2, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] });
|
|
16607
|
+
continue;
|
|
16608
|
+
}
|
|
16609
|
+
const rows = across2 >= (2 * EDGE_D + ROW_D) * d ? [EDGE_D * d, across2 - EDGE_D * d] : [across2 / 2];
|
|
16610
|
+
const pry = rows.reduce((sum, r) => sum + r * r, 0) * fastener.axial * each;
|
|
16611
|
+
const lone = stations === 1;
|
|
16612
|
+
const pryAlong = lone ? (along2 / 2) ** 2 * fastener.axial * rows.length : 0;
|
|
16613
|
+
const twist = lone && rows.length > 1 ? rows.reduce((sum, r) => sum + (r - across2 / 2) ** 2, 0) * fastener.lateral : 0;
|
|
16614
|
+
out.push({ at: at2, frame: frame2, push: [fastener.axial * rows.length * each, fastener.lateral * rows.length * each, fastener.lateral * rows.length * each], turn: [twist, pry, pryAlong] });
|
|
16615
|
+
}
|
|
16616
|
+
return out;
|
|
16617
|
+
}
|
|
16618
|
+
function solve(k, f, n) {
|
|
16619
|
+
const first = new Int32Array(n);
|
|
16620
|
+
for (let i = 0; i < n; i++) {
|
|
16621
|
+
let j = 0;
|
|
16622
|
+
while (j < i && k[i * n + j] === 0) j++;
|
|
16623
|
+
first[i] = j;
|
|
16624
|
+
}
|
|
16625
|
+
for (let i = 0; i < n; i++) {
|
|
16626
|
+
const fi = first[i];
|
|
16627
|
+
for (let j = fi; j <= i; j++) {
|
|
16628
|
+
let sum = k[i * n + j];
|
|
16629
|
+
const from = Math.max(fi, first[j]);
|
|
16630
|
+
for (let m = from; m < j; m++) sum -= k[i * n + m] * k[j * n + m];
|
|
16631
|
+
if (j === i) {
|
|
16632
|
+
if (!(sum > 0)) return false;
|
|
16633
|
+
k[i * n + i] = Math.sqrt(sum);
|
|
16634
|
+
} else k[i * n + j] = sum / k[j * n + j];
|
|
16635
|
+
}
|
|
16636
|
+
}
|
|
16637
|
+
for (let i = 0; i < n; i++) {
|
|
16638
|
+
let sum = f[i];
|
|
16639
|
+
for (let m = first[i]; m < i; m++) sum -= k[i * n + m] * f[m];
|
|
16640
|
+
f[i] = sum / k[i * n + i];
|
|
16641
|
+
}
|
|
16642
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
16643
|
+
const x = f[i] / k[i * n + i];
|
|
16644
|
+
f[i] = x;
|
|
16645
|
+
for (let m = first[i]; m < i; m++) f[m] = f[m] - k[i * n + m] * x;
|
|
16646
|
+
}
|
|
16647
|
+
return true;
|
|
16648
|
+
}
|
|
16649
|
+
function hullOf(points) {
|
|
16650
|
+
const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
16651
|
+
const turn = (o, p, q) => (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0]);
|
|
16652
|
+
const lower = [];
|
|
16653
|
+
for (const p of sorted) {
|
|
16654
|
+
while (lower.length >= 2 && turn(lower[lower.length - 2], lower[lower.length - 1], p) <= 1e-12) lower.pop();
|
|
16655
|
+
lower.push([p[0], p[1]]);
|
|
16656
|
+
}
|
|
16657
|
+
const upper = [];
|
|
16658
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
16659
|
+
const p = sorted[i];
|
|
16660
|
+
while (upper.length >= 2 && turn(upper[upper.length - 2], upper[upper.length - 1], p) <= 1e-12) upper.pop();
|
|
16661
|
+
upper.push([p[0], p[1]]);
|
|
16662
|
+
}
|
|
16663
|
+
lower.pop();
|
|
16664
|
+
upper.pop();
|
|
16665
|
+
return [...lower, ...upper];
|
|
16666
|
+
}
|
|
16667
|
+
function assemblyFlex(input) {
|
|
16668
|
+
const g = input.gravity ?? GRAVITY2;
|
|
16669
|
+
const lost = new Set(input.lost ?? []);
|
|
16670
|
+
const beams = /* @__PURE__ */ new Map();
|
|
16671
|
+
for (const part of input.parts) {
|
|
16672
|
+
if (part.mass <= 0 || Math.max(...part.dims) <= 0) continue;
|
|
16673
|
+
beams.set(part.id, beamOf(part));
|
|
16674
|
+
}
|
|
16675
|
+
if (beams.size === 0) return null;
|
|
16676
|
+
const floor = input.floor ?? Math.min(...[...beams.values()].map((b) => b.min[1]));
|
|
16677
|
+
const joints = input.joints.filter((j) => beams.has(j.a) && beams.has(j.b) && j.a !== j.b);
|
|
16678
|
+
const structural = (j) => RIGID_KINDS.has(j.kind) || JOINT_FASTENERS[j.kind] !== void 0;
|
|
16679
|
+
const stationed = /* @__PURE__ */ new Map();
|
|
16680
|
+
const along2 = (beam, p) => Math.max(-beam.length / 2, Math.min(beam.length / 2, vec.dot(vec.sub(p, beam.part.position), beam.axis)));
|
|
16681
|
+
for (const beam of beams.values()) beam.stations.push(-beam.length / 2, beam.length / 2);
|
|
16682
|
+
for (const joint of joints) {
|
|
16683
|
+
if (!structural(joint)) continue;
|
|
16684
|
+
const a = beams.get(joint.a);
|
|
16685
|
+
const b = beams.get(joint.b);
|
|
16686
|
+
const stations = stationsOf(joint, a, b);
|
|
16687
|
+
stationed.set(joint, stations);
|
|
16688
|
+
for (const s of stations) {
|
|
16689
|
+
a.stations.push(along2(a, s.at));
|
|
16690
|
+
b.stations.push(along2(b, s.at));
|
|
16691
|
+
}
|
|
16692
|
+
}
|
|
16693
|
+
const footPoints = /* @__PURE__ */ new Map();
|
|
16694
|
+
for (const beam of beams.values()) {
|
|
16695
|
+
if (beam.min[1] > floor + FOOT_BAND) continue;
|
|
16696
|
+
const corners = [];
|
|
16697
|
+
for (let i = 0; i < 8; i++) {
|
|
16698
|
+
const c = cornerOf(beam.part, i);
|
|
16699
|
+
if (c[1] <= beam.min[1] + 5e-3) corners.push(c);
|
|
16700
|
+
}
|
|
16701
|
+
footPoints.set(beam.part.id, corners);
|
|
16702
|
+
for (const c of corners) beam.stations.push(along2(beam, c));
|
|
16703
|
+
}
|
|
16704
|
+
const nodes = [];
|
|
16705
|
+
for (const beam of beams.values()) {
|
|
16706
|
+
const sides = beam.part.dims.filter((d) => d !== beam.length);
|
|
16707
|
+
const merge = Math.max(2e-3, 0.5 * Math.min(...sides, beam.length));
|
|
16708
|
+
const sorted = [...beam.stations].sort((p, q) => p - q);
|
|
16709
|
+
const met = [];
|
|
16710
|
+
for (const s of sorted) if (met.length === 0 || s - met[met.length - 1] > merge) met.push(s);
|
|
16711
|
+
if (met.length > 1 && beam.length / 2 - met[met.length - 1] > 0) met[met.length - 1] = beam.length / 2;
|
|
16712
|
+
const longest = beam.length >= SLENDER * Math.max(...sides, 0) && Math.abs(beam.axis[1]) < UPRIGHT ? beam.length / BEAM_PIECES : Infinity;
|
|
16713
|
+
const kept = [];
|
|
16714
|
+
for (const [i, s] of met.entries()) {
|
|
16715
|
+
const from = met[i - 1];
|
|
16716
|
+
if (from !== void 0 && s - from > longest * 1.01) {
|
|
16717
|
+
const cuts = Math.ceil((s - from) / longest);
|
|
16718
|
+
for (let c = 1; c < cuts; c++) kept.push(from + (s - from) * c / cuts);
|
|
16719
|
+
}
|
|
16720
|
+
kept.push(s);
|
|
16721
|
+
}
|
|
16722
|
+
beam.stations = kept;
|
|
16723
|
+
beam.nodes = kept.map((s) => nodes.push({ at: vec.madd(beam.part.position, beam.axis, s) }) - 1);
|
|
16724
|
+
}
|
|
16725
|
+
if (nodes.length * 6 > MAX_DOF) return null;
|
|
16726
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
16727
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
16728
|
+
for (const node of nodes) for (let k = 0; k < 3; k++) {
|
|
16729
|
+
lo[k] = Math.min(lo[k], node.at[k]);
|
|
16730
|
+
hi[k] = Math.max(hi[k], node.at[k]);
|
|
16731
|
+
}
|
|
16732
|
+
let main = 0;
|
|
16733
|
+
if (hi[1] - lo[1] > hi[main] - lo[main]) main = 1;
|
|
16734
|
+
if (hi[2] - lo[2] > hi[main] - lo[main]) main = 2;
|
|
16735
|
+
const ranked = nodes.map((_, i) => i).sort((p, q) => nodes[p].at[main] - nodes[q].at[main] || p - q);
|
|
16736
|
+
const order2 = new Int32Array(nodes.length);
|
|
16737
|
+
ranked.forEach((node, rank) => {
|
|
16738
|
+
order2[node] = rank;
|
|
16739
|
+
});
|
|
16740
|
+
const dofsOf = (node) => [0, 1, 2, 3, 4, 5].map((i) => order2[node] * 6 + i);
|
|
16741
|
+
const nearest = (beam, p) => {
|
|
16742
|
+
const t = along2(beam, p);
|
|
16743
|
+
let best = 0;
|
|
16744
|
+
for (let i = 1; i < beam.stations.length; i++) if (Math.abs(beam.stations[i] - t) < Math.abs(beam.stations[best] - t)) best = i;
|
|
16745
|
+
return beam.nodes[best];
|
|
16746
|
+
};
|
|
16747
|
+
const elements = [];
|
|
16748
|
+
for (const beam of beams.values()) {
|
|
16749
|
+
const section = sectionOf(beam);
|
|
16750
|
+
if (!section) {
|
|
16751
|
+
const id = beam.part.id;
|
|
16752
|
+
if (footPoints.has(id) || joints.some((j) => structural(j) && (j.a === id || j.b === id))) return null;
|
|
16753
|
+
continue;
|
|
16754
|
+
}
|
|
16755
|
+
for (let i = 0; i + 1 < beam.nodes.length; i++) {
|
|
16756
|
+
const length = beam.stations[i + 1] - beam.stations[i];
|
|
16757
|
+
const k = toObjectFrame(beamLocal(section, length), 12, beam.axis, beam.u, beam.v);
|
|
16758
|
+
elements.push({ dofs: [...dofsOf(beam.nodes[i]), ...dofsOf(beam.nodes[i + 1])], k, parts: [beam.part.id] });
|
|
16759
|
+
}
|
|
16760
|
+
}
|
|
16761
|
+
for (const [joint, stations] of stationed) {
|
|
16762
|
+
const a = beams.get(joint.a);
|
|
16763
|
+
const b = beams.get(joint.b);
|
|
16764
|
+
for (const s of stations) {
|
|
16765
|
+
const na = nearest(a, s.at);
|
|
16766
|
+
const nb = nearest(b, s.at);
|
|
16767
|
+
const ra = armRows(vec.sub(s.at, nodes[na].at));
|
|
16768
|
+
const rb = armRows(vec.sub(s.at, nodes[nb].at));
|
|
16769
|
+
const rows = [];
|
|
16770
|
+
for (let i = 0; i < 3; i++) rows.push([...ra[i].map((x) => -x), ...rb[i]]);
|
|
16771
|
+
for (let i = 0; i < 3; i++) {
|
|
16772
|
+
const row = new Array(12).fill(0);
|
|
16773
|
+
row[3 + i] = -1;
|
|
16774
|
+
row[9 + i] = 1;
|
|
16775
|
+
rows.push(row);
|
|
16776
|
+
}
|
|
16777
|
+
const k = new Float64Array(144);
|
|
16778
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
16779
|
+
const e = s.frame[axis];
|
|
16780
|
+
for (const [stiffness, base2] of [[s.push[axis], 0], [s.turn[axis], 3]]) {
|
|
16781
|
+
if (stiffness === 0) continue;
|
|
16782
|
+
const b12 = new Array(12).fill(0);
|
|
16783
|
+
for (let i = 0; i < 3; i++) for (let m = 0; m < 12; m++) b12[m] = b12[m] + e[i] * rows[base2 + i][m];
|
|
16784
|
+
for (let p = 0; p < 12; p++) for (let q = 0; q < 12; q++) k[p * 12 + q] = k[p * 12 + q] + stiffness * b12[p] * b12[q];
|
|
16785
|
+
}
|
|
16786
|
+
}
|
|
16787
|
+
elements.push({ dofs: [...dofsOf(na), ...dofsOf(nb)], k, parts: [joint.a, joint.b] });
|
|
16788
|
+
}
|
|
16789
|
+
}
|
|
16790
|
+
const supports = [];
|
|
16791
|
+
for (const [id, corners] of footPoints) {
|
|
16792
|
+
const beam = beams.get(id);
|
|
16793
|
+
for (const at2 of corners) {
|
|
16794
|
+
const node = nearest(beam, at2);
|
|
16795
|
+
supports.push({ part: id, node, arm: vec.sub(at2, nodes[node].at), at: at2 });
|
|
16796
|
+
}
|
|
16797
|
+
}
|
|
16798
|
+
const frame2 = { nodes, beams, elements, supports, order: order2 };
|
|
16799
|
+
const before = lost.size > 0 ? solveFrame(frame2, input, joints, structural, /* @__PURE__ */ new Set(), g, null) : null;
|
|
16800
|
+
const after = solveFrame(frame2, input, joints, structural, lost, g, before);
|
|
16801
|
+
if (!after) return null;
|
|
16802
|
+
let mass = 0;
|
|
16803
|
+
const centre = [0, 0, 0];
|
|
16804
|
+
const shift = [0, 0, 0];
|
|
16805
|
+
let all = 0;
|
|
16806
|
+
const allCentre = [0, 0, 0];
|
|
16807
|
+
const moved = (s, point) => {
|
|
16808
|
+
const base2 = order2[point.node] * 6;
|
|
16809
|
+
const theta = [s.u[base2 + 3], s.u[base2 + 4], s.u[base2 + 5]];
|
|
16810
|
+
return vec.add([s.u[base2], s.u[base2 + 1], s.u[base2 + 2]], vec.cross(theta, point.arm));
|
|
16811
|
+
};
|
|
16812
|
+
for (const p of after.masses) {
|
|
16813
|
+
const at2 = vec.add(nodes[p.node].at, p.arm);
|
|
16814
|
+
const by = moved(after, p);
|
|
16815
|
+
all += p.mass;
|
|
16816
|
+
for (let k = 0; k < 3; k++) allCentre[k] = allCentre[k] + (at2[k] + by[k]) * p.mass;
|
|
16817
|
+
if (p.part === null) continue;
|
|
16818
|
+
mass += p.mass;
|
|
16819
|
+
for (let k = 0; k < 3; k++) {
|
|
16820
|
+
centre[k] = centre[k] + at2[k] * p.mass;
|
|
16821
|
+
shift[k] = shift[k] + by[k] * p.mass;
|
|
16822
|
+
}
|
|
16823
|
+
}
|
|
16824
|
+
if (mass <= 0) return null;
|
|
16825
|
+
for (let k = 0; k < 3; k++) {
|
|
16826
|
+
centre[k] = centre[k] / mass;
|
|
16827
|
+
shift[k] = shift[k] / mass;
|
|
16828
|
+
allCentre[k] = allCentre[k] / all;
|
|
16829
|
+
}
|
|
16830
|
+
const feet = after.holding.map((s) => s.at);
|
|
16831
|
+
let released = 0;
|
|
16832
|
+
let spin = null;
|
|
16833
|
+
if (before) {
|
|
16834
|
+
const n = nodes.length * 6;
|
|
16835
|
+
const delta = new Float64Array(n);
|
|
16836
|
+
for (let i = 0; i < n; i++) delta[i] = after.u[i] - before.u[i];
|
|
16837
|
+
for (const beam of beams.values()) if (!after.standing.has(beam.part.id)) for (const node of beam.nodes) for (const dof of dofsOf(node)) delta[dof] = 0;
|
|
16838
|
+
for (let i = 0; i < n; i++) {
|
|
16839
|
+
if (delta[i] === 0) continue;
|
|
16840
|
+
let row = 0;
|
|
16841
|
+
for (let j = 0; j < n; j++) row += after.k[i * n + j] * delta[j];
|
|
16842
|
+
released += 0.5 * delta[i] * row;
|
|
16843
|
+
}
|
|
16844
|
+
spin = spinOf({ frame: frame2, after, delta, released, centre: allCentre, mass: all, floor, g });
|
|
16845
|
+
}
|
|
16846
|
+
return {
|
|
16847
|
+
mass,
|
|
16848
|
+
centre,
|
|
16849
|
+
shift,
|
|
16850
|
+
released,
|
|
16851
|
+
spin,
|
|
16852
|
+
feet,
|
|
16853
|
+
deflection(id, point) {
|
|
16854
|
+
const beam = beams.get(id);
|
|
16855
|
+
if (!beam || !after.standing.has(id)) return null;
|
|
16856
|
+
const node = nearest(beam, point);
|
|
16857
|
+
return moved(after, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 });
|
|
16858
|
+
}
|
|
16859
|
+
};
|
|
16860
|
+
}
|
|
16861
|
+
function standingParts(frame2, joints, structural, gone) {
|
|
16862
|
+
const standing = /* @__PURE__ */ new Set();
|
|
16863
|
+
const queue = [];
|
|
16864
|
+
for (const s of frame2.supports) {
|
|
16865
|
+
if (gone.has(s.part) || standing.has(s.part)) continue;
|
|
16866
|
+
standing.add(s.part);
|
|
16867
|
+
queue.push(s.part);
|
|
16868
|
+
}
|
|
16869
|
+
while (queue.length > 0) {
|
|
16870
|
+
const id = queue.pop();
|
|
16871
|
+
for (const j of joints) {
|
|
16872
|
+
if (!structural(j) || j.a !== id && j.b !== id) continue;
|
|
16873
|
+
const other = j.a === id ? j.b : j.a;
|
|
16874
|
+
if (gone.has(other) || standing.has(other)) continue;
|
|
16875
|
+
standing.add(other);
|
|
16876
|
+
queue.push(other);
|
|
16877
|
+
}
|
|
16878
|
+
}
|
|
16879
|
+
return standing;
|
|
16880
|
+
}
|
|
16881
|
+
function solveFrame(frame2, input, joints, structural, gone, g, from) {
|
|
16882
|
+
const { nodes, beams, order: order2 } = frame2;
|
|
16883
|
+
const n = nodes.length * 6;
|
|
16884
|
+
const standing = standingParts(frame2, joints, structural, gone);
|
|
16885
|
+
if (standing.size === 0) return null;
|
|
16886
|
+
const nearestNode = (p, among) => {
|
|
16887
|
+
let best = -1;
|
|
16888
|
+
let bestDistance = Infinity;
|
|
16889
|
+
for (const id of among) {
|
|
16890
|
+
const beam = beams.get(id);
|
|
16891
|
+
for (const node of beam.nodes) {
|
|
16892
|
+
const d = vec.distance(nodes[node].at, p);
|
|
16893
|
+
if (d < bestDistance) {
|
|
16894
|
+
bestDistance = d;
|
|
16895
|
+
best = node;
|
|
16896
|
+
}
|
|
16897
|
+
}
|
|
16898
|
+
}
|
|
16899
|
+
return best;
|
|
16900
|
+
};
|
|
16901
|
+
const masses = [];
|
|
16902
|
+
for (const id of standing) {
|
|
16903
|
+
const beam = beams.get(id);
|
|
16904
|
+
const perMetre = beam.part.mass / beam.length;
|
|
16905
|
+
for (let i = 0; i < beam.nodes.length; i++) {
|
|
16906
|
+
const before = i > 0 ? beam.stations[i] - beam.stations[i - 1] : 0;
|
|
16907
|
+
const next = i + 1 < beam.nodes.length ? beam.stations[i + 1] - beam.stations[i] : 0;
|
|
16908
|
+
masses.push({ part: id, node: beam.nodes[i], arm: [0, 0, 0], mass: perMetre * (before + next) / 2 });
|
|
16909
|
+
}
|
|
16910
|
+
}
|
|
16911
|
+
const carried = /* @__PURE__ */ new Map();
|
|
16912
|
+
let grew = true;
|
|
16913
|
+
while (grew) {
|
|
16914
|
+
grew = false;
|
|
16915
|
+
for (const j of joints) {
|
|
16916
|
+
for (const [id, host] of [[j.a, j.b], [j.b, j.a]]) {
|
|
16917
|
+
if (gone.has(id) || gone.has(host) || standing.has(id) || carried.has(id)) continue;
|
|
16918
|
+
if (!standing.has(host) && !carried.has(host)) continue;
|
|
16919
|
+
carried.set(id, standing.has(host) ? host : carried.get(host));
|
|
16920
|
+
grew = true;
|
|
16921
|
+
}
|
|
16922
|
+
}
|
|
16923
|
+
}
|
|
16924
|
+
for (const [id, host] of carried) {
|
|
16925
|
+
const part = beams.get(id).part;
|
|
16926
|
+
const node = nearestNode(part.position, [host]);
|
|
16927
|
+
masses.push({ part: id, node, arm: vec.sub(part.position, nodes[node].at), mass: part.mass });
|
|
16928
|
+
}
|
|
16929
|
+
for (const load of input.loads ?? []) {
|
|
16930
|
+
if (load.mass <= 0) continue;
|
|
16931
|
+
const node = nearestNode(load.position, standing);
|
|
16932
|
+
masses.push({ part: null, node, arm: vec.sub(load.position, nodes[node].at), mass: load.mass });
|
|
16933
|
+
}
|
|
16934
|
+
const f = new Float64Array(n);
|
|
16935
|
+
for (const p of masses) {
|
|
16936
|
+
const base2 = order2[p.node] * 6;
|
|
16937
|
+
const weight = -p.mass * g;
|
|
16938
|
+
f[base2 + 1] = f[base2 + 1] + weight;
|
|
16939
|
+
f[base2 + 3] = f[base2 + 3] - p.arm[2] * weight;
|
|
16940
|
+
f[base2 + 5] = f[base2 + 5] + p.arm[0] * weight;
|
|
16941
|
+
}
|
|
16942
|
+
const structure = new Float64Array(n * n);
|
|
16943
|
+
let largest = 0;
|
|
16944
|
+
for (const element of frame2.elements) {
|
|
16945
|
+
if (!element.parts.every((id) => standing.has(id))) continue;
|
|
16946
|
+
const size = element.dofs.length;
|
|
16947
|
+
for (let p = 0; p < size; p++) {
|
|
16948
|
+
for (let q = 0; q < size; q++) structure[element.dofs[p] * n + element.dofs[q]] = structure[element.dofs[p] * n + element.dofs[q]] + element.k[p * size + q];
|
|
16949
|
+
}
|
|
16950
|
+
}
|
|
16951
|
+
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i * n + i]);
|
|
16952
|
+
if (largest <= 0) return null;
|
|
16953
|
+
const free = new Uint8Array(n);
|
|
16954
|
+
for (const id of standing) for (const node of beams.get(id).nodes) for (let i = 0; i < 6; i++) free[order2[node] * 6 + i] = 1;
|
|
16955
|
+
for (let i = 0; i < n; i++) {
|
|
16956
|
+
if (!free[i]) {
|
|
16957
|
+
structure[i * n + i] = largest;
|
|
16958
|
+
f[i] = 0;
|
|
16959
|
+
} else structure[i * n + i] = structure[i * n + i] + largest * SOFT;
|
|
16960
|
+
}
|
|
16961
|
+
const feet = frame2.supports.filter((s) => standing.has(s.part));
|
|
16962
|
+
const holds2 = feet.map((s) => !from || from.holding.includes(s));
|
|
16963
|
+
const footed = [...new Set(feet.map((s) => s.part))];
|
|
16964
|
+
const grips = new Map(footed.map((id) => [id, true]));
|
|
16965
|
+
const friction = input.friction ?? FOOT_FRICTION;
|
|
16966
|
+
const k = new Float64Array(n * n);
|
|
16967
|
+
const u = new Float64Array(n);
|
|
16968
|
+
const build = () => {
|
|
16969
|
+
k.set(structure);
|
|
16970
|
+
const held = /* @__PURE__ */ new Map();
|
|
16971
|
+
feet.forEach((s, index) => {
|
|
16972
|
+
if (!holds2[index]) return;
|
|
16973
|
+
const row = armRows(s.arm)[1];
|
|
16974
|
+
const base2 = order2[s.node] * 6;
|
|
16975
|
+
for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++) k[(base2 + p) * n + base2 + q] = k[(base2 + p) * n + base2 + q] + RIGID_PUSH * row[p] * row[q];
|
|
16976
|
+
held.set(s.part, [...held.get(s.part) ?? [], s]);
|
|
16977
|
+
});
|
|
16978
|
+
for (const [id, points] of held) {
|
|
16979
|
+
const { node, arm } = gripOf(points);
|
|
16980
|
+
const upright = order2[node] * 6 + 4;
|
|
16981
|
+
k[upright * n + upright] = k[upright * n + upright] + RIGID_TURN;
|
|
16982
|
+
if (!grips.get(id)) continue;
|
|
16983
|
+
const rows = armRows(arm);
|
|
16984
|
+
const base2 = order2[node] * 6;
|
|
16985
|
+
for (const row of [rows[0], rows[2]]) for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++) k[(base2 + p) * n + base2 + q] = k[(base2 + p) * n + base2 + q] + RIGID_PUSH * row[p] * row[q];
|
|
16986
|
+
}
|
|
16987
|
+
};
|
|
16988
|
+
const liftOf = (s) => {
|
|
16989
|
+
const base2 = order2[s.node] * 6;
|
|
16990
|
+
return u[base2 + 1] + (u[base2 + 5] * s.arm[0] - u[base2 + 3] * s.arm[2]);
|
|
16991
|
+
};
|
|
16992
|
+
const rounds = 4 * feet.length + 2 * footed.length + 4;
|
|
16993
|
+
for (let round3 = 0; round3 < rounds; round3++) {
|
|
16994
|
+
build();
|
|
16995
|
+
u.set(f);
|
|
16996
|
+
if (!solve(k, u, n)) return null;
|
|
16997
|
+
const pull = 1e-12;
|
|
16998
|
+
const sink = -1e-9;
|
|
16999
|
+
if (round3 === 0) {
|
|
17000
|
+
let any = false;
|
|
17001
|
+
feet.forEach((s, index) => {
|
|
17002
|
+
if (!holds2[index] || liftOf(s) <= pull) return;
|
|
17003
|
+
holds2[index] = false;
|
|
17004
|
+
any = true;
|
|
17005
|
+
});
|
|
17006
|
+
if (any) continue;
|
|
17007
|
+
}
|
|
17008
|
+
const worstOf = /* @__PURE__ */ new Map();
|
|
17009
|
+
feet.forEach((s, index) => {
|
|
17010
|
+
const lift = liftOf(s);
|
|
17011
|
+
const pulls = holds2[index] && lift > pull;
|
|
17012
|
+
if (!pulls && !(!holds2[index] && lift < sink)) return;
|
|
17013
|
+
const key2 = round3 < rounds / 2 ? s.part : "";
|
|
17014
|
+
const by = Math.abs(lift);
|
|
17015
|
+
const now = worstOf.get(key2);
|
|
17016
|
+
if (!now || pulls && !now.pulls || pulls === now.pulls && by > now.by) worstOf.set(key2, { index, by, pulls });
|
|
17017
|
+
});
|
|
17018
|
+
if (worstOf.size > 0) {
|
|
17019
|
+
for (const change of worstOf.values()) holds2[change.index] = !change.pulls;
|
|
17020
|
+
continue;
|
|
17021
|
+
}
|
|
17022
|
+
let slides = null;
|
|
17023
|
+
let over = 1;
|
|
17024
|
+
let gripping = 0;
|
|
17025
|
+
for (const id of footed) {
|
|
17026
|
+
const points = feet.filter((s, index) => s.part === id && holds2[index]);
|
|
17027
|
+
if (points.length === 0 || !grips.get(id)) continue;
|
|
17028
|
+
gripping++;
|
|
17029
|
+
let weight = 0;
|
|
17030
|
+
for (const s of points) weight += -RIGID_PUSH * liftOf(s);
|
|
17031
|
+
const { node, arm } = gripOf(points);
|
|
17032
|
+
const base2 = order2[node] * 6;
|
|
17033
|
+
const x = u[base2] + (u[base2 + 4] * arm[2] - u[base2 + 5] * arm[1]);
|
|
17034
|
+
const z = u[base2 + 2] + (u[base2 + 3] * arm[1] - u[base2 + 4] * arm[0]);
|
|
17035
|
+
const ratio = RIGID_PUSH * Math.hypot(x, z) / Math.max(friction * weight, 1e-9);
|
|
17036
|
+
if (ratio > over) {
|
|
17037
|
+
over = ratio;
|
|
17038
|
+
slides = id;
|
|
17039
|
+
}
|
|
17040
|
+
}
|
|
17041
|
+
if (slides !== null && gripping > 1) {
|
|
17042
|
+
grips.set(slides, false);
|
|
17043
|
+
continue;
|
|
17044
|
+
}
|
|
17045
|
+
let worst = 0;
|
|
17046
|
+
for (let i = 0; i < n; i++) if (free[i]) worst = Math.max(worst, Math.abs(u[i]));
|
|
17047
|
+
if (worst > MECHANISM) return null;
|
|
17048
|
+
const holding = feet.filter((_, index) => holds2[index]);
|
|
17049
|
+
if (holding.length < 3) return null;
|
|
17050
|
+
build();
|
|
17051
|
+
return { u: u.slice(), k: k.slice(), holding, masses, standing };
|
|
17052
|
+
}
|
|
17053
|
+
return null;
|
|
17054
|
+
}
|
|
17055
|
+
function gripOf(points) {
|
|
17056
|
+
const first = points[0];
|
|
17057
|
+
let arm = [0, 0, 0];
|
|
17058
|
+
for (const s of points) arm = vec.add(arm, vec.sub(s.at, vec.sub(first.at, first.arm)));
|
|
17059
|
+
return { node: first.node, arm: vec.scale(arm, 1 / points.length) };
|
|
17060
|
+
}
|
|
17061
|
+
function spinOf(input) {
|
|
17062
|
+
const { frame: frame2, after, delta, released, centre, mass, floor, g } = input;
|
|
17063
|
+
if (!(released > 0)) return null;
|
|
17064
|
+
const { nodes, order: order2 } = frame2;
|
|
17065
|
+
const points = after.masses.map((p) => {
|
|
17066
|
+
const base2 = order2[p.node] * 6;
|
|
17067
|
+
const theta = [delta[base2 + 3], delta[base2 + 4], delta[base2 + 5]];
|
|
17068
|
+
return { at: vec.add(nodes[p.node].at, p.arm), by: vec.add([delta[base2], delta[base2 + 1], delta[base2 + 2]], vec.cross(theta, p.arm)), mass: p.mass };
|
|
17069
|
+
});
|
|
17070
|
+
let moving = 0;
|
|
17071
|
+
for (const p of points) moving += p.mass * vec.dot(p.by, p.by);
|
|
17072
|
+
if (!(moving > 0)) return null;
|
|
17073
|
+
const scale = Math.sqrt(2 * released / moving);
|
|
17074
|
+
const hull = hullOf(after.holding.map((s) => [s.at[0], s.at[2]]));
|
|
17075
|
+
if (hull.length < 3) return null;
|
|
17076
|
+
let best = null;
|
|
17077
|
+
for (let i = 0; i < hull.length; i++) {
|
|
17078
|
+
const p = hull[i];
|
|
17079
|
+
const q = hull[(i + 1) % hull.length];
|
|
17080
|
+
const length = Math.hypot(q[0] - p[0], q[1] - p[1]);
|
|
17081
|
+
if (length < 1e-9) continue;
|
|
17082
|
+
const point = [p[0], floor, p[1]];
|
|
17083
|
+
let axis = [(q[0] - p[0]) / length, 0, (q[1] - p[1]) / length];
|
|
17084
|
+
const inward = [centre[0] - point[0], 0, centre[2] - point[2]];
|
|
17085
|
+
let out = vec.cross(axis, [0, 1, 0]);
|
|
17086
|
+
if (vec.dot(out, inward) > 0) {
|
|
17087
|
+
axis = vec.scale(axis, -1);
|
|
17088
|
+
out = vec.scale(out, -1);
|
|
17089
|
+
}
|
|
17090
|
+
const depth = -vec.dot(out, inward);
|
|
17091
|
+
let momentum = 0;
|
|
17092
|
+
let inertia = 0;
|
|
17093
|
+
for (const m of points) {
|
|
17094
|
+
const r = vec.sub(m.at, point);
|
|
17095
|
+
const off = vec.sub(r, vec.scale(axis, vec.dot(r, axis)));
|
|
17096
|
+
momentum += m.mass * vec.dot(vec.cross(r, vec.scale(m.by, scale)), axis);
|
|
17097
|
+
inertia += m.mass * vec.dot(off, off);
|
|
17098
|
+
}
|
|
17099
|
+
if (!(inertia > 0)) continue;
|
|
17100
|
+
const rate = momentum / inertia;
|
|
17101
|
+
if (!(rate > 0)) continue;
|
|
17102
|
+
const height = centre[1] - floor;
|
|
17103
|
+
const barrier = depth > 0 ? mass * g * (Math.hypot(height, depth) - height) : 0;
|
|
17104
|
+
const energy = 0.5 * inertia * rate * rate;
|
|
17105
|
+
const margin = energy - barrier;
|
|
17106
|
+
if (!best || margin > best.margin) best = { point, axis, rate, margin, energy, barrier };
|
|
17107
|
+
}
|
|
17108
|
+
return best ? { point: best.point, axis: best.axis, rate: best.rate, energy: best.energy, barrier: best.barrier } : null;
|
|
17109
|
+
}
|
|
16258
17110
|
var SWEEP_BROAD_SLACK = 1e-3;
|
|
16259
17111
|
var sweptBounds = (origins, direction, length) => {
|
|
16260
17112
|
if (origins.length === 0 || !Number.isFinite(length)) return null;
|
|
@@ -16484,9 +17336,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16484
17336
|
};
|
|
16485
17337
|
var BURIED_BLAST_REACH = 0.5;
|
|
16486
17338
|
var GIVE_AT_CUT_HP = 0.5;
|
|
17339
|
+
var lineToSegment = (o, d, a, b) => {
|
|
17340
|
+
const ab = vec.sub(b, a);
|
|
17341
|
+
const ao = vec.sub(a, o);
|
|
17342
|
+
const abab = vec.dot(ab, ab);
|
|
17343
|
+
const abd = vec.dot(ab, d);
|
|
17344
|
+
const denom = abab - abd * abd;
|
|
17345
|
+
if (abab < 1e-12) return null;
|
|
17346
|
+
if (denom < 1e-12) {
|
|
17347
|
+
const end = vec.dot(ao, d) <= vec.dot(vec.sub(b, o), d) ? a : b;
|
|
17348
|
+
return { point: end, distance: vec.distance(end, vec.madd(o, d, vec.dot(vec.sub(end, o), d))) };
|
|
17349
|
+
}
|
|
17350
|
+
const s = clamp2((abd * vec.dot(ao, d) - vec.dot(ao, ab)) / denom, 0, 1);
|
|
17351
|
+
const point = vec.madd(a, ab, s);
|
|
17352
|
+
const t = vec.dot(vec.sub(point, o), d);
|
|
17353
|
+
return { point, distance: vec.distance(point, vec.madd(o, d, t)) };
|
|
17354
|
+
};
|
|
17355
|
+
var cageLeft = (p) => {
|
|
17356
|
+
const r = p.spec.reinforcement;
|
|
17357
|
+
if (!r) return 1;
|
|
17358
|
+
const total = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length;
|
|
17359
|
+
return total > 0 ? Math.max(0, total - (p.rt.severedBars?.length ?? 0)) / total : 1;
|
|
17360
|
+
};
|
|
16487
17361
|
var capacityScale = (p, borne, through) => {
|
|
16488
17362
|
const residual = p.spec.reinforcement?.residualCapacity ?? RESIDUAL_CAPACITY;
|
|
16489
|
-
if (p.st.stripped) return residual;
|
|
17363
|
+
if (p.st.stripped) return residual * cageLeft(p);
|
|
16490
17364
|
const kept = Math.min(p.rt.removed ? 1 - p.rt.removed / p.mass0 : 1, sectionKept(p, residual, borne, through));
|
|
16491
17365
|
return Math.max(p.spec.reinforcement ? residual : 0.05, kept);
|
|
16492
17366
|
};
|
|
@@ -16561,6 +17435,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16561
17435
|
};
|
|
16562
17436
|
var HOSTED_TOLERANCE = 0.02;
|
|
16563
17437
|
var HOLE_SLACK = 0.05;
|
|
17438
|
+
var GRAIN_AXIS = { x: 0, y: 1, z: 2 };
|
|
16564
17439
|
var isLost = (p) => p.st.status === "broken" || p.st.status === "melted" || p.st.status === "ashes";
|
|
16565
17440
|
var clone = (v) => structuredClone(v);
|
|
16566
17441
|
var overloadRate = (stress) => Math.min(0.6, 0.12 + 0.8 * (stress - 1));
|
|
@@ -17135,7 +18010,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17135
18010
|
byKey.set(key2, span);
|
|
17136
18011
|
return span;
|
|
17137
18012
|
};
|
|
17138
|
-
const
|
|
18013
|
+
const sectionOf22 = (p, axis) => {
|
|
17139
18014
|
const g = p.bend;
|
|
17140
18015
|
const section = { b: sectionWidth(g, axis), h: g.dims[axis] };
|
|
17141
18016
|
const rebar2 = tensionSteel(p.spec, g.dims, section, flexure);
|
|
@@ -17150,7 +18025,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17150
18025
|
}
|
|
17151
18026
|
p.restMoment = 0;
|
|
17152
18027
|
if (g.gravity < 0 || p.span <= 0) return 0;
|
|
17153
|
-
const sec =
|
|
18028
|
+
const sec = sectionOf22(p, g.gravity);
|
|
17154
18029
|
p.restMoment = spanMoment(lineLoad(g, p.bendLoad) * Math.abs(g.up[g.gravity]), p.span);
|
|
17155
18030
|
const holds2 = (p.st.cracked ? sec.steel : sec.ultimate) * capacityScale(p);
|
|
17156
18031
|
return p.restMoment * structureSafety / Math.max(holds2, 1);
|
|
@@ -17185,7 +18060,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17185
18060
|
const impulse = sum / offsets.length * cos * reach2 * width * L;
|
|
17186
18061
|
const weight = axis === g.gravity ? p.bendLoad : p.st.mass;
|
|
17187
18062
|
const kinetic = impulseEnergy(impulse, lineLoad(g, weight) / GRAVITY * L, flexure);
|
|
17188
|
-
const sec =
|
|
18063
|
+
const sec = sectionOf22(p, axis);
|
|
17189
18064
|
const EI = s.elasticGPa * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
|
|
17190
18065
|
const along2 = axis === g.gravity ? -Math.sign(away[axis] * g.up[axis]) : 0;
|
|
17191
18066
|
const dynamic = momentOfEnergy(kinetic, L, EI, flexure.loadFactor);
|
|
@@ -17329,7 +18204,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17329
18204
|
p.bendLoad = p.st.mass + bending[i];
|
|
17330
18205
|
const bent = restFlexure(o, p, lowerOf(i));
|
|
17331
18206
|
p.st.flexure = bent;
|
|
17332
|
-
p.snap = bent > 1 && !p.st.stripped && !
|
|
18207
|
+
p.snap = bent > 1 && !p.st.stripped && !sectionOf22(p, p.bend.gravity).reinforced;
|
|
17333
18208
|
if (p.spec.structure?.capacity === void 0 || bent > p.st.stress) p.st.stress = bent;
|
|
17334
18209
|
}
|
|
17335
18210
|
if (p.st.stress > o.maxStress) o.maxStress = p.st.stress;
|
|
@@ -18360,11 +19235,56 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18360
19235
|
return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
|
|
18361
19236
|
};
|
|
18362
19237
|
const rayPart = (o, p, origin, d) => rayPartRaw(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
19238
|
+
const rayCentre = [0, 0, 0];
|
|
19239
|
+
const rayTurn = [0, 0, 0, 1];
|
|
19240
|
+
const rayTurnBack = [0, 0, 0, 1];
|
|
19241
|
+
const rayOrigin = [0, 0, 0];
|
|
19242
|
+
const rayDirection = [0, 0, 0];
|
|
19243
|
+
const rayShapeHit = { t0: 0, t1: 0, n0: [0, 0, 0] };
|
|
19244
|
+
const rayHitNormal = [0, 0, 0];
|
|
19245
|
+
const rayHit = { t0: 0, t1: 0, n: rayHitNormal };
|
|
19246
|
+
const rayPartInto = (pos, rot, spec, pq, origin, d, lp) => {
|
|
19247
|
+
rotateVecInto(rot, lp, rayCentre);
|
|
19248
|
+
rayCentre[0] += pos[0];
|
|
19249
|
+
rayCentre[1] += pos[1];
|
|
19250
|
+
rayCentre[2] += pos[2];
|
|
19251
|
+
rayTurn[0] = rot[3] * pq[0] + rot[0] * pq[3] + rot[1] * pq[2] - rot[2] * pq[1];
|
|
19252
|
+
rayTurn[1] = rot[3] * pq[1] - rot[0] * pq[2] + rot[1] * pq[3] + rot[2] * pq[0];
|
|
19253
|
+
rayTurn[2] = rot[3] * pq[2] + rot[0] * pq[1] - rot[1] * pq[0] + rot[2] * pq[3];
|
|
19254
|
+
rayTurn[3] = rot[3] * pq[3] - rot[0] * pq[0] - rot[1] * pq[1] - rot[2] * pq[2];
|
|
19255
|
+
rayTurnBack[0] = -rayTurn[0];
|
|
19256
|
+
rayTurnBack[1] = -rayTurn[1];
|
|
19257
|
+
rayTurnBack[2] = -rayTurn[2];
|
|
19258
|
+
rayTurnBack[3] = rayTurn[3];
|
|
19259
|
+
rayOrigin[0] = origin[0] - rayCentre[0];
|
|
19260
|
+
rayOrigin[1] = origin[1] - rayCentre[1];
|
|
19261
|
+
rayOrigin[2] = origin[2] - rayCentre[2];
|
|
19262
|
+
rotateVecInto(rayTurnBack, rayOrigin, rayOrigin);
|
|
19263
|
+
rotateVecInto(rayTurnBack, d, rayDirection);
|
|
19264
|
+
if (!rayShapeInto(spec.shape, rayOrigin, rayDirection, rayShapeHit)) return null;
|
|
19265
|
+
rayHit.t0 = rayShapeHit.t0;
|
|
19266
|
+
rayHit.t1 = rayShapeHit.t1;
|
|
19267
|
+
rayHit.n = rotateVecInto(rayTurn, rayShapeHit.n0, rayHitNormal);
|
|
19268
|
+
return rayHit;
|
|
19269
|
+
};
|
|
19270
|
+
const specTurns = /* @__PURE__ */ new WeakMap();
|
|
19271
|
+
const specTurnOf = (ps) => {
|
|
19272
|
+
let turn = specTurns.get(ps);
|
|
19273
|
+
if (!turn) {
|
|
19274
|
+
turn = quatFromEuler(...ps.rotation ?? [0, 0, 0]);
|
|
19275
|
+
specTurns.set(ps, turn);
|
|
19276
|
+
}
|
|
19277
|
+
return turn;
|
|
19278
|
+
};
|
|
19279
|
+
const copyOf = (v) => [v[0], v[1], v[2]];
|
|
19280
|
+
const objectTurnBack = [0, 0, 0, 1];
|
|
19281
|
+
const objectOrigin = [0, 0, 0];
|
|
19282
|
+
const objectDirection = [0, 0, 0];
|
|
18363
19283
|
const PART_BOUND_SLACK = 1e-6;
|
|
18364
19284
|
const raySphereMiss = (origin, d, c, r, maxDist) => {
|
|
18365
|
-
const
|
|
18366
|
-
const b =
|
|
18367
|
-
const cc =
|
|
19285
|
+
const ox = origin[0] - c[0], oy = origin[1] - c[1], oz = origin[2] - c[2];
|
|
19286
|
+
const b = ox * d[0] + oy * d[1] + oz * d[2];
|
|
19287
|
+
const cc = ox * ox + oy * oy + oz * oz - r * r;
|
|
18368
19288
|
if (cc > 0 && b > 0) return true;
|
|
18369
19289
|
const disc = b * b - cc;
|
|
18370
19290
|
if (disc < 0) return true;
|
|
@@ -18557,9 +19477,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18557
19477
|
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
18558
19478
|
if (outside && !outside.mayMeet(o.id)) continue;
|
|
18559
19479
|
if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
18560
|
-
const
|
|
18561
|
-
|
|
18562
|
-
|
|
19480
|
+
const turn = o.st.rotation;
|
|
19481
|
+
objectTurnBack[0] = -turn[0];
|
|
19482
|
+
objectTurnBack[1] = -turn[1];
|
|
19483
|
+
objectTurnBack[2] = -turn[2];
|
|
19484
|
+
objectTurnBack[3] = turn[3];
|
|
19485
|
+
objectOrigin[0] = origin[0] - o.st.position[0];
|
|
19486
|
+
objectOrigin[1] = origin[1] - o.st.position[1];
|
|
19487
|
+
objectOrigin[2] = origin[2] - o.st.position[2];
|
|
19488
|
+
const lo = rotateVecInto(objectTurnBack, objectOrigin, objectOrigin);
|
|
19489
|
+
const ld = rotateVecInto(objectTurnBack, d, objectDirection);
|
|
18563
19490
|
for (const p of scope?.parts.get(o) ?? (counts ? o.parts : partsAlong(o, lo, ld, maxDist))) {
|
|
18564
19491
|
if (counts) counts.partVisits++;
|
|
18565
19492
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
@@ -18568,15 +19495,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18568
19495
|
counts.shapeTests++;
|
|
18569
19496
|
counts.shapeTested.add(o.id);
|
|
18570
19497
|
}
|
|
18571
|
-
const r =
|
|
19498
|
+
const r = rayPartInto(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
19499
|
+
if (r && r.t0 < 0 && r.t1 > 0 && p.st.chipped?.length && inGap(p, toLocal(p.pos, p.q, objLocal(o, origin)))) {
|
|
19500
|
+
r.t0 = 0;
|
|
19501
|
+
r.n = vec.scale(d, -1);
|
|
19502
|
+
}
|
|
18572
19503
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
18573
19504
|
if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
18574
19505
|
if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
18575
|
-
|
|
18576
|
-
|
|
18577
|
-
|
|
19506
|
+
const cutBand = !!p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))));
|
|
19507
|
+
if (cutBand) {
|
|
19508
|
+
if (passed) {
|
|
19509
|
+
passed.push({ o, p, t: r.t0 });
|
|
19510
|
+
continue;
|
|
19511
|
+
}
|
|
19512
|
+
const bar2 = skip.body ? barAlong(o, p, origin, d, r.t0, r.t1) : null;
|
|
19513
|
+
if (bar2 === null) continue;
|
|
19514
|
+
r.t0 = bar2;
|
|
19515
|
+
r.n = vec.scale(d, -1);
|
|
18578
19516
|
}
|
|
18579
|
-
const
|
|
19517
|
+
const entry2 = p.st.chipped?.length && !cutBand ? toLocal(p.pos, p.q, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2)))) : null;
|
|
19518
|
+
const gap = entry2 ? skip.body && coreStands(p, entry2) ? coreBehind(o, p, origin, d, r.t0, r.t1) : pastChips(o, p, origin, d, r.t0, r.t1) : null;
|
|
18580
19519
|
if (gap === "through") continue;
|
|
18581
19520
|
if (gap) {
|
|
18582
19521
|
r.t0 = gap.t;
|
|
@@ -18591,8 +19530,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18591
19530
|
}
|
|
18592
19531
|
if (!best || r.t0 < best.distance) {
|
|
18593
19532
|
const point = vec.madd(origin, d, r.t0);
|
|
18594
|
-
const
|
|
18595
|
-
|
|
19533
|
+
const normal = copyOf(r.n);
|
|
19534
|
+
const member = p.castIn ? castMemberAt(o, { p, point, normal, dir: d, pathLen: r.t1 - r.t0 }, origin, d) : null;
|
|
19535
|
+
best = member ? { object: o.id, part: member.p.spec.id, point: member.point, normal: member.normal, distance: r.t0, pathLen: member.pathLen } : { object: o.id, part: p.spec.id, point, normal, distance: r.t0, pathLen: r.t1 - r.t0 };
|
|
18596
19536
|
}
|
|
18597
19537
|
}
|
|
18598
19538
|
}
|
|
@@ -18608,13 +19548,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18608
19548
|
counts.shapeTested.add(im.impl.id);
|
|
18609
19549
|
}
|
|
18610
19550
|
const ov = im.poses.get(ps.id);
|
|
18611
|
-
const r =
|
|
19551
|
+
const r = rayPartInto(im.position, im.rotation, ps, ov?.q ?? specTurnOf(ps), origin, d, ov?.pos ?? ps.position);
|
|
18612
19552
|
if (!r || r.t1 < 0 || r.t0 > maxDist) continue;
|
|
18613
19553
|
if (r.t0 < 0) {
|
|
18614
|
-
if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: r.n, distance: 0, pathLen: r.t1 };
|
|
19554
|
+
if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: copyOf(r.n), distance: 0, pathLen: r.t1 };
|
|
18615
19555
|
continue;
|
|
18616
19556
|
}
|
|
18617
|
-
if (!boxHit || r.t0 < boxHit.distance) boxHit = { object: im.impl.id, part: ps.id, point: vec.madd(origin, d, r.t0), normal: r.n, distance: r.t0, pathLen: r.t1 - r.t0 };
|
|
19557
|
+
if (!boxHit || r.t0 < boxHit.distance) boxHit = { object: im.impl.id, part: ps.id, point: vec.madd(origin, d, r.t0), normal: copyOf(r.n), distance: r.t0, pathLen: r.t1 - r.t0 };
|
|
18618
19558
|
}
|
|
18619
19559
|
if (!boxHit) continue;
|
|
18620
19560
|
if (precise && im.impl.surfaceRay) {
|
|
@@ -19297,11 +20237,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19297
20237
|
const toPart = quat.conjugate(p.q);
|
|
19298
20238
|
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
19299
20239
|
const ld = rotateVec(toPart, objLocalDir(o, d));
|
|
19300
|
-
const
|
|
20240
|
+
const EPS33 = 1e-4;
|
|
19301
20241
|
let t = t0;
|
|
19302
20242
|
let axis = -1;
|
|
19303
20243
|
for (let step = 0; step < cells.length + 1; step++) {
|
|
19304
|
-
const at2 = vec.madd(lo, ld, t +
|
|
20244
|
+
const at2 = vec.madd(lo, ld, t + EPS33);
|
|
19305
20245
|
const cell = cells.find((c) => Math.abs(at2[0] - c.center[0]) <= c.size[0] / 2 && Math.abs(at2[1] - c.center[1]) <= c.size[1] / 2 && Math.abs(at2[2] - c.center[2]) <= c.size[2] / 2);
|
|
19306
20246
|
if (!cell) break;
|
|
19307
20247
|
let out = Infinity;
|
|
@@ -19314,25 +20254,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19314
20254
|
axis = a;
|
|
19315
20255
|
}
|
|
19316
20256
|
}
|
|
19317
|
-
if (!Number.isFinite(out) || out >= t1 -
|
|
19318
|
-
t = out + 2 *
|
|
20257
|
+
if (!Number.isFinite(out) || out >= t1 - EPS33) return "through";
|
|
20258
|
+
t = out + 2 * EPS33;
|
|
19319
20259
|
}
|
|
19320
20260
|
if (axis < 0) return null;
|
|
19321
20261
|
const local = [0, 0, 0];
|
|
19322
20262
|
local[axis] = -Math.sign(ld[axis]);
|
|
19323
20263
|
return { t, n: rotateVec(o.st.rotation, rotateVec(p.q, local)) };
|
|
19324
20264
|
};
|
|
20265
|
+
const coreBehind = (o, p, origin, d, t0, t1) => {
|
|
20266
|
+
const gap = pastChips(o, p, origin, d, t0, t1);
|
|
20267
|
+
const core = Math.min(t1, t0 + REBAR_COVER);
|
|
20268
|
+
if (gap === null || gap !== "through" && gap.t <= core) return gap;
|
|
20269
|
+
return { t: core, n: vec.scale(d, -1) };
|
|
20270
|
+
};
|
|
20271
|
+
const inGap = (p, lp) => (p.st.chipped ?? []).some((c) => Math.abs(lp[0] - c.center[0]) <= c.size[0] / 2 && Math.abs(lp[1] - c.center[1]) <= c.size[1] / 2 && Math.abs(lp[2] - c.center[2]) <= c.size[2] / 2);
|
|
20272
|
+
const coreStands = (p, lp) => {
|
|
20273
|
+
if (!p.spec.reinforcement || !isMember(p.dims, p.spec.structure?.role) || p.st.stripped) return false;
|
|
20274
|
+
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
20275
|
+
const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
|
|
20276
|
+
const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
|
|
20277
|
+
return (p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS;
|
|
20278
|
+
};
|
|
19325
20279
|
const insideChip = (p, objectPoint) => {
|
|
19326
20280
|
const cells = p.st.chipped;
|
|
19327
20281
|
if (!cells?.length) return false;
|
|
19328
20282
|
const [u, v] = planeAxes(p.thin);
|
|
19329
20283
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
19330
|
-
if (
|
|
19331
|
-
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
19332
|
-
const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
|
|
19333
|
-
const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
|
|
19334
|
-
if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
|
|
19335
|
-
}
|
|
20284
|
+
if (coreStands(p, lp)) return false;
|
|
19336
20285
|
return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
|
|
19337
20286
|
};
|
|
19338
20287
|
const alongAt = (along2, at2) => {
|
|
@@ -19874,6 +20823,55 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19874
20823
|
emit({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
|
|
19875
20824
|
}
|
|
19876
20825
|
};
|
|
20826
|
+
const barAlong = (o, p, origin, d, t0, t1) => {
|
|
20827
|
+
const r = p.spec.reinforcement;
|
|
20828
|
+
if (!r || !isMember(p.dims, p.spec.structure?.role)) return null;
|
|
20829
|
+
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
20830
|
+
const [u, v] = [0, 1, 2].filter((k) => k !== along2);
|
|
20831
|
+
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
20832
|
+
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
20833
|
+
const across2 = Math.hypot(ld[u], ld[v]);
|
|
20834
|
+
if (across2 < 1e-6) return null;
|
|
20835
|
+
const cut = p.rt.severedBars ?? [];
|
|
20836
|
+
let best = null;
|
|
20837
|
+
rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
|
|
20838
|
+
if (cut.includes(i)) return;
|
|
20839
|
+
const du = a[u] - lo[u];
|
|
20840
|
+
const dv = a[v] - lo[v];
|
|
20841
|
+
if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2) return;
|
|
20842
|
+
const t = (du * ld[u] + dv * ld[v]) / (across2 * across2);
|
|
20843
|
+
if (t >= t0 && t <= t1 && (best === null || t < best)) best = t;
|
|
20844
|
+
});
|
|
20845
|
+
return best;
|
|
20846
|
+
};
|
|
20847
|
+
const cutCageBars = (o, p, origin, d, caliber, src) => {
|
|
20848
|
+
var _a;
|
|
20849
|
+
const r = p.spec.reinforcement;
|
|
20850
|
+
if (!r || isLost(p)) return;
|
|
20851
|
+
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
20852
|
+
const ld = vec.normalize(rotateVec(quat.conjugate(p.q), objLocalDir(o, d)));
|
|
20853
|
+
const reach2 = r.diameter / 2 + caliber / 2e3;
|
|
20854
|
+
const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
|
|
20855
|
+
let severed = 0;
|
|
20856
|
+
rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a, b], i) => {
|
|
20857
|
+
if (cut.includes(i)) return;
|
|
20858
|
+
const near = lineToSegment(lo, ld, a, b);
|
|
20859
|
+
if (!near || near.distance > reach2) return;
|
|
20860
|
+
cut.push(i);
|
|
20861
|
+
severed++;
|
|
20862
|
+
debris(o, p, "sparks", toWorld(o.st.position, o.st.rotation, toWorld(p.pos, p.q, near.point)), vec.scale(d, -1), 6, 3, src);
|
|
20863
|
+
});
|
|
20864
|
+
if (severed === 0) return;
|
|
20865
|
+
markDamaged(p);
|
|
20866
|
+
if (cageLeft(p) <= 0) {
|
|
20867
|
+
if (p.rt.hinges?.length) reyield(o, p, 0, src);
|
|
20868
|
+
loseCage(o, p, src);
|
|
20869
|
+
return;
|
|
20870
|
+
}
|
|
20871
|
+
if (p.rt.hinges?.length) reyield(o, p, barsMoment(p), src);
|
|
20872
|
+
solveStructure(o);
|
|
20873
|
+
collapseCheck(o, src);
|
|
20874
|
+
};
|
|
19877
20875
|
const severBars = (o, p, origin, d, caliber, src) => {
|
|
19878
20876
|
var _a;
|
|
19879
20877
|
const r = p.spec.reinforcement;
|
|
@@ -19973,7 +20971,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19973
20971
|
return;
|
|
19974
20972
|
}
|
|
19975
20973
|
if (p.bend) settleStructure(o);
|
|
19976
|
-
if (!force && p.bend && (p.st.flexure ?? 0) > 1 &&
|
|
20974
|
+
if (!force && p.bend && (p.st.flexure ?? 0) > 1 && sectionOf22(p, p.bend.gravity).reinforced) {
|
|
19977
20975
|
hingeDrop(o, p, src);
|
|
19978
20976
|
return;
|
|
19979
20977
|
}
|
|
@@ -20188,6 +21186,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20188
21186
|
const piece3 = round3.piece;
|
|
20189
21187
|
const weight = piece3?.weight ?? 1;
|
|
20190
21188
|
const piercing = round3.piercing ?? 1;
|
|
21189
|
+
if (p.st.stripped && p.spec.reinforcement) cutCageBars(o, p, entry2, d, caliber, src);
|
|
20191
21190
|
if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, vec.madd(entry2, d, Math.min(CHIP_PROBE_DEPTH, pathLen / 2))))) {
|
|
20192
21191
|
return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
|
|
20193
21192
|
}
|
|
@@ -21955,6 +22954,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21955
22954
|
return st ? clone(st) : null;
|
|
21956
22955
|
},
|
|
21957
22956
|
part: (id, partId) => objects.get(id)?.byId.get(partId)?.st ?? impls.get(id)?.impl.state().parts.find((p) => p.id === partId) ?? null,
|
|
22957
|
+
assemblyFlex(id, options2) {
|
|
22958
|
+
const o = objects.get(id);
|
|
22959
|
+
if (!o) return null;
|
|
22960
|
+
const lost = new Set(options2?.lost ?? []);
|
|
22961
|
+
const kept = new Set(o.st.groups[0] ?? []);
|
|
22962
|
+
const framed = o.parts.filter((p) => lost.has(p.spec.id) || kept.has(p.spec.id) && !isLost(p));
|
|
22963
|
+
const ids = new Set(framed.map((p) => p.spec.id));
|
|
22964
|
+
const parts2 = framed.map((p) => ({
|
|
22965
|
+
id: p.spec.id,
|
|
22966
|
+
material: p.mat,
|
|
22967
|
+
dims: p.dims,
|
|
22968
|
+
position: p.pos,
|
|
22969
|
+
rotation: p.q,
|
|
22970
|
+
// a part that went is taken whole, as it was while it held
|
|
22971
|
+
mass: lost.has(p.spec.id) ? p.mass0 : p.st.mass,
|
|
22972
|
+
...p.spec.grain ? { grain: GRAIN_AXIS[p.spec.grain] } : {},
|
|
22973
|
+
...p.spec.shape.kind === "cylinder" ? { round: true } : {}
|
|
22974
|
+
}));
|
|
22975
|
+
const joints = o.joints.filter((j) => ids.has(j.spec.a) && ids.has(j.spec.b) && (!j.st.open || lost.has(j.spec.a) || lost.has(j.spec.b))).map((j) => ({ a: j.spec.a, b: j.spec.b, kind: j.spec.kind, position: j.pos }));
|
|
22976
|
+
return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {} });
|
|
22977
|
+
},
|
|
21958
22978
|
reset(id) {
|
|
21959
22979
|
finishExplosions();
|
|
21960
22980
|
const im = impls.get(id);
|
|
@@ -22775,7 +23795,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22775
23795
|
});
|
|
22776
23796
|
return new Map([...sized].map(([part, capacity]) => [part.id, capacity]));
|
|
22777
23797
|
}
|
|
22778
|
-
var
|
|
23798
|
+
var EPS3 = 1e-6;
|
|
22779
23799
|
function linesOf(boxes) {
|
|
22780
23800
|
return boxes.map(([u0, v0, u1, v1]) => u1 - u0 >= v1 - v0 ? { dir: "u", at: (v0 + v1) / 2, from: u0, to: u1 } : { dir: "v", at: (u0 + u1) / 2, from: v0, to: v1 });
|
|
22781
23801
|
}
|
|
@@ -22820,11 +23840,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22820
23840
|
const depth = v1 - v0;
|
|
22821
23841
|
const candidates = [];
|
|
22822
23842
|
for (const at2 of positions(lines, "v", options.lineTolerance)) {
|
|
22823
|
-
if (at2 < u0 + options.minPanel -
|
|
23843
|
+
if (at2 < u0 + options.minPanel - EPS3 || at2 > u1 - options.minPanel + EPS3) continue;
|
|
22824
23844
|
candidates.push({ dir: "v", at: at2, coverage: coverage(lines, "v", at2, v0, v1, options), skew: Math.abs(at2 - (u0 + u1) / 2) / (width / 2) });
|
|
22825
23845
|
}
|
|
22826
23846
|
for (const at2 of positions(lines, "u", options.lineTolerance)) {
|
|
22827
|
-
if (at2 < v0 + options.minPanel -
|
|
23847
|
+
if (at2 < v0 + options.minPanel - EPS3 || at2 > v1 - options.minPanel + EPS3) continue;
|
|
22828
23848
|
candidates.push({ dir: "u", at: at2, coverage: coverage(lines, "u", at2, u0, u1, options), skew: Math.abs(at2 - (v0 + v1) / 2) / (depth / 2) });
|
|
22829
23849
|
}
|
|
22830
23850
|
const boundary = candidates.filter((c) => c.coverage >= options.lineCoverage);
|
|
@@ -23132,7 +24152,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23132
24152
|
}
|
|
23133
24153
|
return { u, v, alongU };
|
|
23134
24154
|
}
|
|
23135
|
-
function
|
|
24155
|
+
function sectionOf2(structure, options) {
|
|
23136
24156
|
const unit = structure.construction.walls.unit;
|
|
23137
24157
|
return typeof unit === "string" ? pillarSectionOf(getMasonryUnit(unit)) : { across: options.columnSide, along: options.columnSide };
|
|
23138
24158
|
}
|
|
@@ -23382,7 +24402,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23382
24402
|
panelsOf: /* @__PURE__ */ new Map(),
|
|
23383
24403
|
pillars: 0,
|
|
23384
24404
|
groundBase: firstColumn?.on ?? GROUND,
|
|
23385
|
-
section:
|
|
24405
|
+
section: sectionOf2(structure, options)
|
|
23386
24406
|
};
|
|
23387
24407
|
const walls = parts2.filter((p) => /^wall_/.test(p.id) && (p.role === "wall" || p.role === "partition"));
|
|
23388
24408
|
const jobs = [...bonds.map((part) => ({ part, bond: true })), ...slabs.map((part) => ({ part, bond: false }))].sort((a, b) => a.part.y0 - b.part.y0 || Number(b.bond) - Number(a.bond));
|
|
@@ -47399,7 +48419,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47399
48419
|
}
|
|
47400
48420
|
var residentialTower = residentialTowerTemplate();
|
|
47401
48421
|
|
|
47402
|
-
// ../game-floorplan-three/dist/chunk-
|
|
48422
|
+
// ../game-floorplan-three/dist/chunk-RW7ZTU76.js
|
|
47403
48423
|
var __defProp3 = Object.defineProperty;
|
|
47404
48424
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
47405
48425
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -47466,20 +48486,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47466
48486
|
var OPEN_ROOM_TYPES2 = /* @__PURE__ */ new Set(["balcony", "terrace", "veranda", "balcony_gourmet"]);
|
|
47467
48487
|
var rectsOf = (c) => c.parts && c.parts.length ? c.parts : [[c.u0, c.v0, c.u1, c.v1]];
|
|
47468
48488
|
var isOpenArea = (c) => OPEN_ROOM_TYPES2.has(c.type) || c.outdoor === true;
|
|
47469
|
-
var
|
|
48489
|
+
var EPS4 = 1e-6;
|
|
47470
48490
|
function subtractBox(a, b) {
|
|
47471
|
-
if (b[0] >= a[3] -
|
|
48491
|
+
if (b[0] >= a[3] - EPS4 || b[3] <= a[0] + EPS4 || b[1] >= a[4] - EPS4 || b[4] <= a[1] + EPS4 || b[2] >= a[5] - EPS4 || b[5] <= a[2] + EPS4) return [a];
|
|
47472
48492
|
const out = [];
|
|
47473
48493
|
const box4 = [...a];
|
|
47474
48494
|
for (let axis = 0; axis < 3; axis++) {
|
|
47475
48495
|
const lo = axis, hi = axis + 3;
|
|
47476
|
-
if (b[lo] > box4[lo] +
|
|
48496
|
+
if (b[lo] > box4[lo] + EPS4) {
|
|
47477
48497
|
const piece22 = [...box4];
|
|
47478
48498
|
piece22[hi] = b[lo];
|
|
47479
48499
|
out.push(piece22);
|
|
47480
48500
|
box4[lo] = b[lo];
|
|
47481
48501
|
}
|
|
47482
|
-
if (b[hi] < box4[hi] -
|
|
48502
|
+
if (b[hi] < box4[hi] - EPS4) {
|
|
47483
48503
|
const piece22 = [...box4];
|
|
47484
48504
|
piece22[lo] = b[hi];
|
|
47485
48505
|
out.push(piece22);
|
|
@@ -48234,7 +49254,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48234
49254
|
const OPEN_ROOM_TYPES22 = /* @__PURE__ */ new Set(["balcony", "terrace", "veranda", "balcony_gourmet"]);
|
|
48235
49255
|
const NO_CEILING = OPEN_ROOM_TYPES22;
|
|
48236
49256
|
const OPEN_AREA = (c) => OPEN_ROOM_TYPES22.has(c.type) || c.outdoor === true;
|
|
48237
|
-
const
|
|
49257
|
+
const EPS42 = 1e-3;
|
|
48238
49258
|
const Y0 = (f) => {
|
|
48239
49259
|
const A = shared2.ctx.r.floors;
|
|
48240
49260
|
return A[Math.max(0, Math.min(A.length - 1, f))].y0;
|
|
@@ -48243,19 +49263,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48243
49263
|
const rectsOf2 = (c) => c.parts && c.parts.length ? c.parts : [[c.u0, c.v0, c.u1, c.v1]];
|
|
48244
49264
|
function roomAt(f, u, v) {
|
|
48245
49265
|
for (const c of shared2.ctx.r.rooms) if (c.floor === f) {
|
|
48246
|
-
for (const [a, b, c2, d] of rectsOf2(c)) if (u > a +
|
|
49266
|
+
for (const [a, b, c2, d] of rectsOf2(c)) if (u > a + EPS42 && u < c2 - EPS42 && v > b + EPS42 && v < d - EPS42) return c;
|
|
48247
49267
|
}
|
|
48248
49268
|
return null;
|
|
48249
49269
|
}
|
|
48250
49270
|
function subRect(a, b) {
|
|
48251
49271
|
const [ax0, az0, ax1, az1] = a, [bx0, bz0, bx1, bz1] = b;
|
|
48252
|
-
if (bx0 >= ax1 -
|
|
49272
|
+
if (bx0 >= ax1 - EPS42 || bx1 <= ax0 + EPS42 || bz0 >= az1 - EPS42 || bz1 <= az0 + EPS42) return [a];
|
|
48253
49273
|
const o = [];
|
|
48254
|
-
if (bz0 > az0 +
|
|
48255
|
-
if (bz1 < az1 -
|
|
49274
|
+
if (bz0 > az0 + EPS42) o.push([ax0, az0, ax1, bz0]);
|
|
49275
|
+
if (bz1 < az1 - EPS42) o.push([ax0, bz1, ax1, az1]);
|
|
48256
49276
|
const z0 = Math.max(az0, bz0), z1 = Math.min(az1, bz1);
|
|
48257
|
-
if (bx0 > ax0 +
|
|
48258
|
-
if (bx1 < ax1 -
|
|
49277
|
+
if (bx0 > ax0 + EPS42) o.push([ax0, z0, bx0, z1]);
|
|
49278
|
+
if (bx1 < ax1 - EPS42) o.push([bx1, z0, ax1, z1]);
|
|
48259
49279
|
return o;
|
|
48260
49280
|
}
|
|
48261
49281
|
function subRects(rs, holes) {
|
|
@@ -48281,7 +49301,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48281
49301
|
const pitch = A[f + 1].y0 - A[f].y0;
|
|
48282
49302
|
return h > pitch && h - pitch <= 0.45 ? pitch : h;
|
|
48283
49303
|
}
|
|
48284
|
-
const defined = { OPEN_ROOM_TYPES: OPEN_ROOM_TYPES22, NO_CEILING, OPEN_AREA, EPS:
|
|
49304
|
+
const defined = { OPEN_ROOM_TYPES: OPEN_ROOM_TYPES22, NO_CEILING, OPEN_AREA, EPS: EPS42, Y0, colorOf, rectsOf: rectsOf2, roomAt, subRect, subRects, wallColor, floorColor, stairFootprint, effectiveHeight };
|
|
48285
49305
|
Object.assign(K, defined);
|
|
48286
49306
|
}
|
|
48287
49307
|
var DOOR_JAMB_WIDTH = 0.05;
|
|
@@ -48291,7 +49311,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48291
49311
|
var SLAB_CONCRETE = 9408138;
|
|
48292
49312
|
var WALL_FACE = 0.075;
|
|
48293
49313
|
function installHouseFloors(K, shared2) {
|
|
48294
|
-
const { rectsOf: rectsOf2, EPS:
|
|
49314
|
+
const { rectsOf: rectsOf2, EPS: EPS42, OPEN_AREA, Y0, bx, cursor, floorColor, stairFootprint, structurePiece, subRects } = K;
|
|
48295
49315
|
function outbuildingSlabEdge(room, y0, slab) {
|
|
48296
49316
|
const R = shared2.ctx.r;
|
|
48297
49317
|
const e = (R.outbuildings ?? []).find((o) => o.id === room.id);
|
|
@@ -48320,7 +49340,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48320
49340
|
const k = [m.link.from, m.link.to, m.x.toFixed(2), m.z.toFixed(2), (m.ry || 0).toFixed(2)].join("|");
|
|
48321
49341
|
if (!mp.has(k)) mp.set(k, { m, from: m.link.from, to: m.link.to, rect: stairFootprint(m) });
|
|
48322
49342
|
}
|
|
48323
|
-
const l = [...mp.values()], inter = (a, b) => a[0] < b[2] -
|
|
49343
|
+
const l = [...mp.values()], inter = (a, b) => a[0] < b[2] - EPS42 && a[2] > b[0] + EPS42 && a[1] < b[3] - EPS42 && a[3] > b[1] + EPS42;
|
|
48324
49344
|
for (const v of l) if (l.some((o) => o !== v && o.to === v.from && inter(o.rect, v.rect))) {
|
|
48325
49345
|
const m = v.m, H = Y0(v.to) - Y0(v.from), len = Math.min(m.d * 0.5, Math.max(0.7, m.d * (H - 0.24 - 1.95) / H)), c = Math.cos(m.ry), s_ = Math.sin(m.ry), lz = m.d / 2 - len / 2;
|
|
48326
49346
|
v.landing = stairFootprint({ x: m.x + lz * s_, z: m.z + lz * c, ry: m.ry, w: m.w, d: len });
|
|
@@ -48340,7 +49360,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48340
49360
|
const out = [], taken = [];
|
|
48341
49361
|
for (const p of ps) for (const q of panelRects(p)) {
|
|
48342
49362
|
const r = [Math.max(rc[0], q[0]), Math.max(rc[1], q[1]), Math.min(rc[2], q[2]), Math.min(rc[3], q[3])];
|
|
48343
|
-
if (r[2] - r[0] >
|
|
49363
|
+
if (r[2] - r[0] > EPS42 && r[3] - r[1] > EPS42) {
|
|
48344
49364
|
out.push([structurePiece(p.id), r]);
|
|
48345
49365
|
taken.push(r);
|
|
48346
49366
|
}
|
|
@@ -48351,7 +49371,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48351
49371
|
function panelAt(parent, x, z) {
|
|
48352
49372
|
const ps = shared2.ctx.panelsOf && shared2.ctx.panelsOf.get(parent);
|
|
48353
49373
|
if (!ps) return structurePiece(parent);
|
|
48354
|
-
for (const p of ps) for (const q of panelRects(p)) if (x >= q[0] -
|
|
49374
|
+
for (const p of ps) for (const q of panelRects(p)) if (x >= q[0] - EPS42 && x <= q[2] + EPS42 && z >= q[1] - EPS42 && z <= q[3] + EPS42) return structurePiece(p.id);
|
|
48355
49375
|
return null;
|
|
48356
49376
|
}
|
|
48357
49377
|
const hasSlab = (id) => !!(shared2.ctx.structureIndex[id] || shared2.ctx.panelsOf && shared2.ctx.panelsOf.has(id));
|
|
@@ -48438,7 +49458,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48438
49458
|
Object.assign(K, { flights, floorsAndSlabs, tilesOf, panelAt });
|
|
48439
49459
|
}
|
|
48440
49460
|
function installHouseWalls(K, shared2) {
|
|
48441
|
-
const { EPS:
|
|
49461
|
+
const { EPS: EPS42, Y0, boxC, bx, cursor, effectiveHeight, pieceRecord, structurePiece, wallColor } = K;
|
|
48442
49462
|
const sh = (...a) => K.sh(...a);
|
|
48443
49463
|
let solids = null;
|
|
48444
49464
|
const lay = (rank, mat, x0, y0, z0, x1, y1, z1, color2) => {
|
|
@@ -48501,7 +49521,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48501
49521
|
function nearestWall(f, axis, L, c) {
|
|
48502
49522
|
let m = null, md = 1e9;
|
|
48503
49523
|
for (const w of shared2.ctx.r.walls) {
|
|
48504
|
-
if (w.floor !== f || w.axis !== axis || w.type !== "wall" || Math.abs((axis === "u" ? w.v0 : w.u0) - L) >
|
|
49524
|
+
if (w.floor !== f || w.axis !== axis || w.type !== "wall" || Math.abs((axis === "u" ? w.v0 : w.u0) - L) > EPS42) continue;
|
|
48505
49525
|
const a = Math.min(axis === "u" ? w.u0 : w.v0, axis === "u" ? w.u1 : w.v1), b = Math.max(axis === "u" ? w.u0 : w.v0, axis === "u" ? w.u1 : w.v1), d = c < a ? a - c : c > b ? c - b : 0;
|
|
48506
49526
|
if (d < md) {
|
|
48507
49527
|
md = d;
|
|
@@ -48557,7 +49577,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48557
49577
|
wallBox(alongU, L, a, b, y0 + ya, y0 + yb, th, sideL.color, sideH.color, sideL.mat, sideH.mat);
|
|
48558
49578
|
};
|
|
48559
49579
|
const win = [
|
|
48560
|
-
...R.windows.filter((j) => j.floor === f && j.axis === w.axis && Math.abs(j.pos - L) <
|
|
49580
|
+
...R.windows.filter((j) => j.floor === f && j.axis === w.axis && Math.abs(j.pos - L) < EPS42 && j.at + j.width / 2 > s0 + EPS42 && j.at - j.width / 2 < s1 - EPS42),
|
|
48561
49581
|
...doorsInWall(R.doors, w, L, s0, s1).map((d) => ({ at: d.at, width: d.width, y0: 0, y1: doorHeightOf(d, h) }))
|
|
48562
49582
|
].sort((p, q) => p.at - q.at);
|
|
48563
49583
|
let cur = s0;
|
|
@@ -48633,14 +49653,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48633
49653
|
}
|
|
48634
49654
|
function installHouseDoors(K, shared2) {
|
|
48635
49655
|
const seedKey = (id) => K.seedKey(id);
|
|
48636
|
-
const { EPS:
|
|
49656
|
+
const { EPS: EPS42, Y0, boxC, bx, cursor, effectiveHeight, nearestWall, part, pieceOf, pieceRecord, roomAt, sideOf, wallBox } = K;
|
|
48637
49657
|
const SEED = (...a) => K.SEED(...a);
|
|
48638
49658
|
const definePiece = (...a) => K.definePiece(...a);
|
|
48639
49659
|
const rngString = (...a) => K.rngString(...a);
|
|
48640
49660
|
const sh = (...a) => K.sh(...a);
|
|
48641
49661
|
function doorLineSides(p) {
|
|
48642
49662
|
const R = shared2.ctx.r, alongU = p.axis === "u", a = p.at - p.width / 2, b = p.at + p.width / 2;
|
|
48643
|
-
const w = R.walls.find((w2) => w2.floor === p.floor && w2.axis === p.axis && Math.abs((alongU ? w2.v0 : w2.u0) - p.pos) <
|
|
49663
|
+
const w = R.walls.find((w2) => w2.floor === p.floor && w2.axis === p.axis && Math.abs((alongU ? w2.v0 : w2.u0) - p.pos) < EPS42 && w2.type === "wall" && (Math.abs((alongU ? w2.u1 : w2.v1) - a) < 0.02 || Math.abs((alongU ? w2.u0 : w2.v0) - b) < 0.02));
|
|
48644
49664
|
const sides = w ? w.sides : [p.a, p.b];
|
|
48645
49665
|
return [sideOf(sides[0], false), sideOf(sides[1], false)];
|
|
48646
49666
|
}
|
|
@@ -48652,7 +49672,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48652
49672
|
const f = p.floor;
|
|
48653
49673
|
cursor.group = "f" + f;
|
|
48654
49674
|
const y0 = Y0(f), alongU = p.axis === "u", L = p.pos, a = p.at - p.width / 2, b = p.at + p.width / 2;
|
|
48655
|
-
const wref = R.walls.find((w) => w.floor === f && w.axis === p.axis && Math.abs((alongU ? w.v0 : w.u0) - L) <
|
|
49675
|
+
const wref = R.walls.find((w) => w.floor === f && w.axis === p.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS42), th = wref ? wref.thickness || 0.15 : 0.15, wallHeight = wref ? wref.h : 3;
|
|
48656
49676
|
const PMAT = R.style === "budget" || R.style === "commercial" ? "doorPaint" : "doorWood";
|
|
48657
49677
|
const dH = doorHeightOf(p, wallHeight), visH = cut ? Math.min(dH, 1.2) : dH, [lL, lH] = doorLineSides(p);
|
|
48658
49678
|
const inWhole = R.walls.some((w) => doorsInWall([p], w, alongU ? w.v0 : w.u0, Math.min(alongU ? w.u0 : w.v0, alongU ? w.u1 : w.v1), Math.max(alongU ? w.u0 : w.v0, alongU ? w.u1 : w.v1)).length > 0);
|
|
@@ -48788,7 +49808,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48788
49808
|
Object.assign(K, defined);
|
|
48789
49809
|
}
|
|
48790
49810
|
function installHouseWindows(K, shared2) {
|
|
48791
|
-
const { EPS:
|
|
49811
|
+
const { EPS: EPS42, Y0, boxC, bx, cursor, pieceRecord, roomAt } = K;
|
|
48792
49812
|
const FRAME_COLORS = { budget: 15856110, mid: 12830924, high: 2829875, commercial: 11844287 };
|
|
48793
49813
|
const MULLION_THICKNESS = 0.04, PANE_THICKNESS = 0.012, PANE_CLEARANCE = 2e-3, GRILLE_FOOT = 2e-3, ALUMINIUM_PROFILE_KG_PER_M = 1.2, SILL_KG_PER_M = 6, STEEL_KG_PER_M3 = 7850, GRILLE_BAR = 0.016;
|
|
48794
49814
|
const GLASS_THICKNESS = 4e-3, GLASS_DENSITY = 2500;
|
|
@@ -48808,7 +49828,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48808
49828
|
if (ya >= 1.2) continue;
|
|
48809
49829
|
yb = Math.min(yb, 1.2);
|
|
48810
49830
|
}
|
|
48811
|
-
const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) <
|
|
49831
|
+
const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS42), th = wref ? wref.thickness || 0.15 : 0.15, t = 0.05, tt = th + 0.02;
|
|
48812
49832
|
const bar2 = (u0, y_0, u1, y_1, mat, color2, tw = tt, shift = 0) => {
|
|
48813
49833
|
const b2 = alongU ? [u0, y0 + y_0, L + shift - tw / 2, u1, y0 + y_1, L + shift + tw / 2] : [L + shift - tw / 2, y0 + y_0, u0, L + shift + tw / 2, y0 + y_1, u1];
|
|
48814
49834
|
bx(mat, b2[0], b2[1], b2[2], b2[3], b2[4], b2[5], color2);
|
|
@@ -49196,7 +50216,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49196
50216
|
}
|
|
49197
50217
|
var COVERING_CLEAR = 0.15;
|
|
49198
50218
|
function installLightsDecor(K, shared2) {
|
|
49199
|
-
const { EPS:
|
|
50219
|
+
const { EPS: EPS42, OPEN_AREA, SEED, Y0, cursor, rngString, roomAt, stairFootprint } = K;
|
|
49200
50220
|
const lightItem = (...a) => K.lightItem(...a);
|
|
49201
50221
|
function decorLights(api) {
|
|
49202
50222
|
const R = shared2.ctx.r, T2 = shared2.ctx.types, structure = R.style, chance = structure === "budget" ? 0.35 : structure === "mid" ? 0.75 : 1, rnd = rngString(SEED() + "|decorluz");
|
|
@@ -49255,7 +50275,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49255
50275
|
}
|
|
49256
50276
|
const pe = R.doors.find((p) => p.exterior && p.side === "front") || R.doors.find((p) => p.exterior);
|
|
49257
50277
|
if (pe && T2.outdoor_lamp) {
|
|
49258
|
-
const alongU = pe.axis === "u", wref = R.walls.find((w) => w.floor === pe.floor && w.axis === pe.axis && Math.abs((alongU ? w.v0 : w.u0) - pe.pos) <
|
|
50278
|
+
const alongU = pe.axis === "u", wref = R.walls.find((w) => w.floor === pe.floor && w.axis === pe.axis && Math.abs((alongU ? w.v0 : w.u0) - pe.pos) < EPS42), th = wref ? wref.thickness || 0.15 : 0.15, n = pe.b === "outside" ? 1 : -1;
|
|
49259
50279
|
const inside22 = roomAt(pe.floor, alongU ? pe.at : pe.pos - 0.4, alongU ? pe.pos - 0.4 : pe.at), sd = inside22 ? 1 : -1;
|
|
49260
50280
|
const sdf = roomAt(pe.floor, alongU ? pe.at : pe.pos + 0.4, alongU ? pe.pos + 0.4 : pe.at) ? -1 : 1;
|
|
49261
50281
|
const u = pe.at + pe.width / 2 + 0.32, face = pe.pos + sdf * th / 2, ry = alongU ? sdf > 0 ? 0 : Math.PI : sdf > 0 ? K.PE : -K.PE;
|
|
@@ -49337,7 +50357,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49337
50357
|
var LOT_WALL_BEAM_COLOR = 10132118;
|
|
49338
50358
|
var BURIED_INSET = 2e-3;
|
|
49339
50359
|
function installLotPerimeter(K, shared2) {
|
|
49340
|
-
const { EPS:
|
|
50360
|
+
const { EPS: EPS42, boxC, bx, colorOf, cursor, freeSpans, pieceRecord } = K;
|
|
49341
50361
|
const makeApi = (...a) => K.makeApi(...a);
|
|
49342
50362
|
const sh = (...a) => K.sh(...a);
|
|
49343
50363
|
function perimeter() {
|
|
@@ -49351,7 +50371,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49351
50371
|
const api = makeApi();
|
|
49352
50372
|
const houseWalls2 = shared2.ctx.visorScene ? [] : groundWallBoxes(shared2.ctx.r.walls);
|
|
49353
50373
|
for (const s of lt.perimeter) {
|
|
49354
|
-
const alongU = Math.abs(s.v1 - s.v0) <
|
|
50374
|
+
const alongU = Math.abs(s.v1 - s.v0) < EPS42, L = alongU ? s.v0 : s.u0, a = Math.min(alongU ? s.u0 : s.v0, alongU ? s.u1 : s.v1), b = Math.max(alongU ? s.u0 : s.v0, alongU ? s.u1 : s.v1);
|
|
49355
50375
|
const material = s.type === "wall" ? "brick" : s.type === "fence" ? "wood_soft" : "steel";
|
|
49356
50376
|
const length = Math.hypot(s.u1 - s.u0, s.v1 - s.v0);
|
|
49357
50377
|
cursor.pc = pieceRecord("lot_wall:" + s.id, material, null, { tags: ["wall"], holder: "ground", holdJoint: footingJointOf(material), embedment: { depth: GROUND_BEAM_DEPTH, width: length } });
|
|
@@ -49572,7 +50592,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49572
50592
|
Object.assign(K, defined);
|
|
49573
50593
|
}
|
|
49574
50594
|
function installRoofRoofs(K, shared2) {
|
|
49575
|
-
const { rectsOf: rectsOf2, EPS:
|
|
50595
|
+
const { rectsOf: rectsOf2, EPS: EPS42, OPEN_AREA, Y0, bx, cursor } = K;
|
|
49576
50596
|
const gutter = (...a) => K.gutter(...a);
|
|
49577
50597
|
const gutterConfig = (...a) => K.gutterConfig(...a);
|
|
49578
50598
|
const roofRect = (...a) => K.roofRect(...a);
|
|
@@ -49595,7 +50615,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49595
50615
|
const lines = shared2.ctx.visorScene ? rs : rs.concat(up);
|
|
49596
50616
|
const within = (v, k) => v >= Math.min(...rs.map((r) => r[k])) && v <= Math.max(...rs.map((r) => r[k + 2]));
|
|
49597
50617
|
const xs = [...new Set(lines.flatMap((r) => [r[0], r[2]]).filter((v) => within(v, 0)).map((v) => +v.toFixed(3)))].sort((a, b) => a - b), zs = [...new Set(lines.flatMap((r) => [r[1], r[3]]).filter((v) => within(v, 1)).map((v) => +v.toFixed(3)))].sort((a, b) => a - b);
|
|
49598
|
-
const em = (L, x, z) => L.some((r) => x > r[0] +
|
|
50618
|
+
const em = (L, x, z) => L.some((r) => x > r[0] + EPS42 && x < r[2] - EPS42 && z > r[1] + EPS42 && z < r[3] - EPS42), nx = xs.length - 1, nz = zs.length - 1;
|
|
49599
50619
|
const cxs = (i) => (xs[i] + xs[i + 1]) / 2, czs = (j) => (zs[j] + zs[j + 1]) / 2;
|
|
49600
50620
|
const occ = [];
|
|
49601
50621
|
for (let j = 0; j < nz; j++) {
|
|
@@ -49608,7 +50628,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
49608
50628
|
return true;
|
|
49609
50629
|
};
|
|
49610
50630
|
const pe = (x0, z0, x1, z1) => {
|
|
49611
|
-
const cs = R.rooms.filter((c) => c.floor === f && rectsOf2(c).some((r) => r[0] < x1 -
|
|
50631
|
+
const cs = R.rooms.filter((c) => c.floor === f && rectsOf2(c).some((r) => r[0] < x1 - EPS42 && r[2] > x0 + EPS42 && r[1] < z1 - EPS42 && r[3] > z0 + EPS42));
|
|
49612
50632
|
return Y0(f) + Math.max(...cs.map((c) => c.ceiling)) + 0.2;
|
|
49613
50633
|
};
|
|
49614
50634
|
if (type === "slab") {
|
|
@@ -55314,7 +56334,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
55314
56334
|
var SWITCH_HEIGHT = 1.1;
|
|
55315
56335
|
var SWITCH_REACH = 0.05;
|
|
55316
56336
|
function installInteractionFittings(K, shared2) {
|
|
55317
|
-
const { t, EPS:
|
|
56337
|
+
const { t, EPS: EPS42, OPEN_AREA, Y0, applyPiece, bx, cursor, definePiece, gates, lightOn, roomAt, slideDirection, toggleLight, togglePiece } = K;
|
|
55318
56338
|
const I = () => shared2.inter;
|
|
55319
56339
|
const house = () => shared2.ctx.r;
|
|
55320
56340
|
function gatesInteractive() {
|
|
@@ -55410,7 +56430,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
55410
56430
|
}
|
|
55411
56431
|
function putSwitch(c, p) {
|
|
55412
56432
|
const R = house(), f = p.floor, alongU = p.axis === "u", L = p.pos, a = p.at - p.width / 2, b = p.at + p.width / 2;
|
|
55413
|
-
const wref = R.walls.find((w) => w.floor === f && w.axis === p.axis && Math.abs((alongU ? w.v0 : w.u0) - L) <
|
|
56433
|
+
const wref = R.walls.find((w) => w.floor === f && w.axis === p.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS42), th = wref ? wref.thickness || 0.15 : 0.15;
|
|
55414
56434
|
const inside22 = (sd2) => {
|
|
55415
56435
|
const cc = roomAt(f, alongU ? p.at : L + sd2 * 0.4, alongU ? L + sd2 * 0.4 : p.at);
|
|
55416
56436
|
return !!cc && cc.id === c.id;
|
|
@@ -55420,8 +56440,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
55420
56440
|
const sides = p.hinge === "end" ? [-1, 1] : [1, -1];
|
|
55421
56441
|
for (const ld of sides) {
|
|
55422
56442
|
const u = ld > 0 ? b + 0.2 : a - 0.2, lo = u - 0.1, hi = u + 0.1;
|
|
55423
|
-
const wall = R.walls.some((w) => w.floor === f && w.axis === p.axis && w.type === "wall" && Math.abs((alongU ? w.v0 : w.u0) - L) <
|
|
55424
|
-
const free = !R.doors.concat(R.windows).some((o) => o.floor === f && o.axis === p.axis && Math.abs(o.pos - L) <
|
|
56443
|
+
const wall = R.walls.some((w) => w.floor === f && w.axis === p.axis && w.type === "wall" && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS42 && Math.min(alongU ? w.u0 : w.v0, alongU ? w.u1 : w.v1) <= lo - 0.08 && Math.max(alongU ? w.u0 : w.v0, alongU ? w.u1 : w.v1) >= hi + 0.08);
|
|
56444
|
+
const free = !R.doors.concat(R.windows).some((o) => o.floor === f && o.axis === p.axis && Math.abs(o.pos - L) < EPS42 && o.at + o.width / 2 > lo - 0.05 && o.c - o.width / 2 < hi + 0.05);
|
|
55425
56445
|
if (!wall || !free) continue;
|
|
55426
56446
|
const y0 = Y0(f), yc = y0 + SWITCH_HEIGHT, face = L + sd * th / 2, roomId = c.id, g0 = cursor.group;
|
|
55427
56447
|
if (!shared2.ctx.visorScene && behindFurniture(f, alongU ? u : face + sd * SWITCH_REACH, alongU ? face + sd * SWITCH_REACH : u)) continue;
|
|
@@ -57232,18 +58252,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
57232
58252
|
if (list2) mesh2.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
|
|
57233
58253
|
withdrawSolids(mesh2, v0);
|
|
57234
58254
|
}
|
|
58255
|
+
var hash2 = (i, j) => {
|
|
58256
|
+
const s = Math.sin(i * 127.1 + j * 311.7) * 43758.5453;
|
|
58257
|
+
return s - Math.floor(s);
|
|
58258
|
+
};
|
|
57235
58259
|
function noise2(x, y, cell) {
|
|
57236
|
-
const h = (i2, j2) => {
|
|
57237
|
-
const s = Math.sin(i2 * 127.1 + j2 * 311.7) * 43758.5453;
|
|
57238
|
-
return s - Math.floor(s);
|
|
57239
|
-
};
|
|
57240
58260
|
const fx = x / cell, fy = y / cell, i = Math.floor(fx), j = Math.floor(fy), u = fx - i, v = fy - j;
|
|
57241
58261
|
const su = u * u * (3 - 2 * u), sv = v * v * (3 - 2 * v);
|
|
57242
|
-
return (
|
|
58262
|
+
return (hash2(i, j) * (1 - su) + hash2(i + 1, j) * su) * (1 - sv) + (hash2(i, j + 1) * (1 - su) + hash2(i + 1, j + 1) * su) * sv;
|
|
57243
58263
|
}
|
|
57244
58264
|
var MASK_TEXEL = 0.02;
|
|
57245
58265
|
var SPALL_MIN = 0.025;
|
|
57246
58266
|
var SPALL_RAGGED = 0.045;
|
|
58267
|
+
var PLASTER_REACH = { least: SPALL_MIN, band: SPALL_RAGGED };
|
|
57247
58268
|
var COVER2 = 0.015;
|
|
57248
58269
|
var LUMP_BAR_INSET = 0.035;
|
|
57249
58270
|
var LUMPS_PER_BAR = 1;
|
|
@@ -57739,7 +58760,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
57739
58760
|
mask.data.fill(0);
|
|
57740
58761
|
core.data.fill(0);
|
|
57741
58762
|
const stamp = (m, s0, s1, y0, y1, inside22) => stampMask(m, { s0, s1, y0, y1, reach: reach2 }, inside22);
|
|
57742
|
-
const
|
|
58763
|
+
const texel = { s: 0, y: 0 };
|
|
58764
|
+
const raggedAtTexel = () => ragged(texel.s, texel.y);
|
|
58765
|
+
const coreNoiseAtTexel = () => noise2(texel.s * 1.7, texel.y * 1.3, 0.012);
|
|
58766
|
+
const plaster = (d, s, y) => {
|
|
58767
|
+
texel.s = s;
|
|
58768
|
+
texel.y = y;
|
|
58769
|
+
return isPlasterGone(d, PLASTER_REACH, raggedAtTexel);
|
|
58770
|
+
};
|
|
58771
|
+
const coreThrough = (distance2, depth, s, y) => {
|
|
58772
|
+
texel.s = s;
|
|
58773
|
+
texel.y = y;
|
|
58774
|
+
return isCoreThrough(distance2, depth, coreNoiseAtTexel);
|
|
58775
|
+
};
|
|
57743
58776
|
for (const c of holes) stamp(mask, c.a, c.b, c.y0, c.y1, (s, y) => plaster(boxDistance(s, y, c.a, c.b, c.y0, c.y1), s, y));
|
|
57744
58777
|
for (const d of discs) stamp(mask, d.s - d.r, d.s + d.r, d.y - d.r, d.y + d.r, (s, y) => plaster(Math.max(0, Math.hypot(s - d.s, y - d.y) - d.r), s, y));
|
|
57745
58778
|
for (const f of flakes) {
|
|
@@ -57748,7 +58781,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
57748
58781
|
}
|
|
57749
58782
|
for (const p of pits) {
|
|
57750
58783
|
stamp(mask, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => plaster(Math.max(0, ellipseDistance(s, y, p.s, p.y, p.rs, p.ry)), s, y));
|
|
57751
|
-
stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) =>
|
|
58784
|
+
stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => coreThrough(ellipseDistance(s, y, p.s, p.y, p.rs, p.ry), 0.35 * Math.min(p.rs, p.ry), s, y));
|
|
57752
58785
|
}
|
|
57753
58786
|
for (const q of pillars) {
|
|
57754
58787
|
const i0 = Math.max(0, Math.floor((q.a + 5e-3) / mask.len * mask.w)), i1 = Math.min(mask.w - 1, Math.floor((q.b - 5e-3) / mask.len * mask.w));
|
|
@@ -58492,7 +59525,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58492
59525
|
const left = breach.standing(part.id);
|
|
58493
59526
|
if (!left) return true;
|
|
58494
59527
|
const s0 = (left.alongU ? lx : lz) - left.start;
|
|
58495
|
-
|
|
59528
|
+
const low1 = Math.min(ly0, ly1), high1 = Math.max(ly0, ly1);
|
|
59529
|
+
for (const c of left.spans) if (c.b > s0 - radius && c.a < s0 + radius && c.y1 > low1 && c.y0 < high1) return true;
|
|
58496
59530
|
}
|
|
58497
59531
|
return false;
|
|
58498
59532
|
};
|
|
@@ -59336,7 +60370,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59336
60370
|
return { u: P.u - Math.sign(P.frontU || 0) * PANEL_RECESS, v: P.v - Math.sign(P.frontV || 0) * PANEL_RECESS, y0: P.y - h / 2 + PANEL_LIFT - BOX_CHASE_CLEAR, y1: P.y + h / 2 + PANEL_LIFT + BOX_CHASE_CLEAR, radius: w / 2, depth: 0 };
|
|
59337
60371
|
}
|
|
59338
60372
|
function installBuildBuild(K, shared2) {
|
|
59339
|
-
const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS:
|
|
60373
|
+
const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS42, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, walkInInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
|
|
59340
60374
|
function build(r0, options) {
|
|
59341
60375
|
const opts = options || {};
|
|
59342
60376
|
const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
|
|
@@ -59611,7 +60645,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59611
60645
|
});
|
|
59612
60646
|
cars.push({ i, k: C.k, seed: C.seed, pos: [C.x, C.y, C.z], ry: C.ry || 0, scale: s, parts: ids });
|
|
59613
60647
|
});
|
|
59614
|
-
const wallAt = (f, axis, L) => r.walls.find((w) => w.floor === f && w.axis === axis && Math.abs((axis === "u" ? w.v0 : w.u0) - L) <
|
|
60648
|
+
const wallAt = (f, axis, L) => r.walls.find((w) => w.floor === f && w.axis === axis && Math.abs((axis === "u" ? w.v0 : w.u0) - L) < EPS42);
|
|
59615
60649
|
for (const j of r.windows) {
|
|
59616
60650
|
const alongU = j.axis === "u", y0 = Y0(j.floor), a = j.at - j.width / 2, b = j.at + j.width / 2, w = wallAt(j.floor, j.axis, j.pos), th = w ? w.thickness || 0.15 : 0.15, L = j.pos, id = "window:" + j.id;
|
|
59617
60651
|
const jy0 = j.y0, jy1 = j.y1;
|
|
@@ -60118,7 +61152,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60118
61152
|
var HOLD_REACH2 = 0.05;
|
|
60119
61153
|
var BACK_TOUCH = 0.02;
|
|
60120
61154
|
var AGAINST_WALL = 0.1;
|
|
60121
|
-
var
|
|
61155
|
+
var SOFT2 = /* @__PURE__ */ new Set(["fabric", "paper", "foliage"]);
|
|
60122
61156
|
var gapOf = (a, b) => Math.max(0, ...[0, 1, 2].map((k) => Math.max(a.min[k] - b.max[k], b.min[k] - a.max[k])));
|
|
60123
61157
|
function groupsOf(parts2, joints) {
|
|
60124
61158
|
const root = new Map(parts2.map((part) => [part.id, part.id]));
|
|
@@ -60189,7 +61223,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60189
61223
|
continue;
|
|
60190
61224
|
}
|
|
60191
61225
|
const againstWall = held.length === 0 || held.some((part) => boxOf3(part.id).min[2] <= back2 + AGAINST_WALL);
|
|
60192
|
-
const onWall = againstWall ? group.filter((part) => !
|
|
61226
|
+
const onWall = againstWall ? group.filter((part) => !SOFT2.has(part.material) && boxOf3(part.id).min[2] <= back2 + BACK_TOUCH) : [];
|
|
60193
61227
|
if (onWall.length === 0) continue;
|
|
60194
61228
|
for (const part of onWall) part.anchored = true;
|
|
60195
61229
|
changed = true;
|